diff --git a/Firmware/MotorControl/low_level.c b/Firmware/MotorControl/low_level.c index 4a0eb7e0..34927e8e 100644 --- a/Firmware/MotorControl/low_level.c +++ b/Firmware/MotorControl/low_level.c @@ -530,12 +530,14 @@ void step_cb(uint16_t GPIO_Pin) { } } -void enc_index_cb(uint16_t GPIO_Pin, int index){ - setEncoderCount(&motors[index], 0); - motors[index].IndexFound = true; +// Triggered when an encoder passes over the "Index" pin +void enc_index_cb(uint16_t GPIO_Pin, int index) { + if (!motors[index].encoder.index_found) { + setEncoderCount(&motors[index], 0); + motors[index].encoder.index_found = true; + } } - void vbus_sense_adc_cb(ADC_HandleTypeDef* hadc, bool injected) { static const float voltage_scale = 3.3f * 11.0f / (float)(1 << 12); // Only one conversion in sequence, so only rank1