diff --git a/head/firmware/motor_hardware_rev1.c b/head/firmware/motor_hardware_rev1.c index 1b3f49d43..478decc79 100644 --- a/head/firmware/motor_hardware_rev1.c +++ b/head/firmware/motor_hardware_rev1.c @@ -20,9 +20,7 @@ void initialize_rev_specific_pins() { HAL_GPIO_Init(GPIOC, // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) &GPIO_InitStruct); - // TODO: Handle brakes better, this just disengages - // them at boot - HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5 | GPIO_PIN_0, GPIO_PIN_SET); + HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5 | GPIO_PIN_0, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOC, GPIO_PIN_4, GPIO_PIN_RESET); diff --git a/include/motor-control/firmware/motor_control_hardware.h b/include/motor-control/firmware/motor_control_hardware.h index a9b0ca4f1..2cdcc123d 100644 --- a/include/motor-control/firmware/motor_control_hardware.h +++ b/include/motor-control/firmware/motor_control_hardware.h @@ -24,6 +24,7 @@ uint16_t motor_hardware_encoder_pulse_count(void* encoder_handle); uint16_t motor_hardware_encoder_pulse_count_with_overflow(void* encoder_handle, int8_t *overflows); void motor_hardware_reset_encoder_count(void* encoder_handle, uint16_t reset_value); uint16_t motor_hardware_get_stopwatch_pulses(void* stopwatch_handle, uint8_t clear); +void motor_hardware_delay(uint32_t delay); #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/motor-control/firmware/motor_control_hardware.c b/motor-control/firmware/motor_control_hardware.c index bf13b9043..d4cdb534a 100644 --- a/motor-control/firmware/motor_control_hardware.c +++ b/motor-control/firmware/motor_control_hardware.c @@ -7,6 +7,7 @@ #include "FreeRTOS.h" #include "platform_specific_hal_conf.h" #include "stm32g4xx_hal_tim.h" +#include "stm32g4xx_hal.h" #include "task.h" HAL_StatusTypeDef custom_stop_pwm_it(TIM_HandleTypeDef* htim, @@ -131,3 +132,8 @@ uint16_t motor_hardware_get_stopwatch_pulses(void* stopwatch_handle, uint8_t cle return count; } +void motor_hardware_delay(uint32_t delay) { + HAL_Delay(delay); +} + + diff --git a/motor-control/firmware/stepper_motor/motor_hardware.cpp b/motor-control/firmware/stepper_motor/motor_hardware.cpp index 9b4d38151..a28dcef33 100644 --- a/motor-control/firmware/stepper_motor/motor_hardware.cpp +++ b/motor-control/firmware/stepper_motor/motor_hardware.cpp @@ -23,6 +23,7 @@ void MotorHardware::activate_motor() { void MotorHardware::deactivate_motor() { if (pins.ebrake.has_value()) { gpio::set(pins.ebrake.value()); + motor_hardware_delay(10); } gpio::reset(pins.enable); }