CNT is 32 bit, so count should be too

Also, explicitly cast count to a float for pll_pos
This commit is contained in:
Paul Guenette
2017-11-23 15:48:40 -05:00
parent 2880b65a1e
commit e82da352e0
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -1380,9 +1380,9 @@ void motor_thread(void const * argument) {
motor->thread_ready = false;
}
void setEncoderCount(Motor_t* motor, uint16_t count){
/** Function that sets the current encoder count to a desired 32-bit value. */
void setEncoderCount(Motor_t* motor, uint32_t count){
motor->encoder.encoder_state = count;
motor->motor_timer->Instance->CNT = count;
motor->encoder.pll_pos = count;
motor->encoder.pll_pos = (float)count;
}
+1 -1
View File
@@ -172,7 +172,7 @@ void step_cb(uint16_t GPIO_Pin);
void pwm_trig_adc_cb(ADC_HandleTypeDef* hadc, bool injected);
void vbus_sense_adc_cb(ADC_HandleTypeDef* hadc, bool injected);
void setEncoderCount(Motor_t* motor, uint16_t count);
void setEncoderCount(Motor_t* motor, uint32_t count);
bool anti_cogging_calibration(Motor_t* motor);