Fix DRV lock-up problem when using absolute encoders

This commit is contained in:
Unknown
2020-09-02 20:44:56 -04:00
parent e9810e5014
commit f691536b3c
3 changed files with 20 additions and 7 deletions
+2 -3
View File
@@ -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) {
+2 -1
View File
@@ -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;
+16 -3
View File
@@ -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();