Skip to content

Commit

Permalink
this seems to work?!
Browse files Browse the repository at this point in the history
  • Loading branch information
ahiuchingau committed Nov 8, 2023
1 parent cd2ae02 commit 3c2b1b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/motor-control/firmware/motor_control_hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions motor-control/firmware/motor_control_hardware.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}


4 changes: 4 additions & 0 deletions motor-control/firmware/stepper_motor/motor_hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ void MotorHardware::positive_direction() { gpio::set(pins.direction); }
void MotorHardware::negative_direction() { gpio::reset(pins.direction); }
void MotorHardware::activate_motor() {
gpio::set(pins.enable);
motor_hardware_delay(10);
if (pins.ebrake.has_value()) {
gpio::reset(pins.ebrake.value());
}
motor_hardware_delay(10);
}
void MotorHardware::deactivate_motor() {
if (pins.ebrake.has_value()) {
gpio::set(pins.ebrake.value());
}
motor_hardware_delay(10);
gpio::reset(pins.enable);
motor_hardware_delay(10);
}
void MotorHardware::start_timer_interrupt() {
LOG("Starting timer interrupt")
Expand Down

0 comments on commit 3c2b1b2

Please sign in to comment.