mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-21 15:34:33 +08:00
Fix DRV lock-up problem when using absolute encoders
This commit is contained in:
@@ -85,10 +85,9 @@ static void step_cb_wrapper(void* ctx) {
|
||||
}
|
||||
|
||||
|
||||
// @brief Sets up all components of the axis,
|
||||
// such as gate driver and encoder hardware.
|
||||
// @brief Does Nothing
|
||||
void Axis::setup() {
|
||||
motor_.setup();
|
||||
// Does nothing - Motor and encoder setup called separately.
|
||||
}
|
||||
|
||||
static void run_state_machine_loop_wrapper(void* ctx) {
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
#error "This file should not be included directly. Include odrive_main.h instead."
|
||||
#endif
|
||||
|
||||
|
||||
class Encoder : public ODriveIntf::EncoderIntf {
|
||||
public:
|
||||
const uint32_t MODE_FLAG_ABS = 0x100;
|
||||
static constexpr uint32_t MODE_FLAG_ABS = 0x100;
|
||||
|
||||
struct Config_t {
|
||||
Mode mode = MODE_INCREMENTAL;
|
||||
|
||||
@@ -262,15 +262,28 @@ int odrive_main(void) {
|
||||
// must happen after communication is initialized
|
||||
pwm_in_init();
|
||||
|
||||
// Setup hardware for all components
|
||||
for (size_t i = 0; i < AXIS_COUNT; ++i) {
|
||||
axes[i]->setup();
|
||||
// Set up the CS pins for absolute encoders
|
||||
for(auto& axis : axes){
|
||||
if(axis->encoder_.config_.mode & Encoder::MODE_FLAG_ABS){
|
||||
axis->encoder_.abs_spi_cs_pin_init();
|
||||
}
|
||||
}
|
||||
|
||||
// Setup motors (DRV8301 SPI transactions here)
|
||||
for(auto& axis : axes){
|
||||
axis->motor_.setup();
|
||||
}
|
||||
|
||||
// Setup encoders (Starts encoder SPI transactions)
|
||||
for(auto& axis : axes){
|
||||
axis->encoder_.setup();
|
||||
}
|
||||
|
||||
// Setup anything remaining in each axis
|
||||
for(auto& axis : axes){
|
||||
axis->setup();
|
||||
}
|
||||
|
||||
// Start PWM and enable adc interrupts/callbacks
|
||||
start_adc_pwm();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user