mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-08-22 16:20:30 +08:00
Fix GPIO Subscribe issues
This commit is contained in:
@@ -72,8 +72,7 @@ void MX_GPIO_Init(void);
|
||||
|
||||
void SetGPIO12toUART();
|
||||
bool GPIO_subscribe(GPIO_TypeDef* GPIO_port, uint16_t GPIO_pin,
|
||||
uint32_t pull_up_down, uint32_t interrupt_mode,
|
||||
void (*callback)(void*), void* ctx);
|
||||
uint32_t pull_up_down, void (*callback)(void*), void* ctx);
|
||||
void GPIO_unsubscribe(GPIO_TypeDef* GPIO_port, uint16_t GPIO_pin);
|
||||
void GPIO_set_to_analog(GPIO_TypeDef* GPIO_port, uint16_t GPIO_pin);
|
||||
|
||||
|
||||
@@ -205,8 +205,7 @@ size_t n_subscriptions = 0;
|
||||
// on a rising edge of the GPIO.
|
||||
// @param pull_up_down: one of GPIO_NOPULL, GPIO_PULLUP or GPIO_PULLDOWN
|
||||
bool GPIO_subscribe(GPIO_TypeDef* GPIO_port, uint16_t GPIO_pin,
|
||||
uint32_t pull_up_down, uint32_t interrupt_mode,
|
||||
void (*callback)(void*), void* ctx) {
|
||||
uint32_t pull_up_down, void (*callback)(void*), void* ctx) {
|
||||
|
||||
// Register handler (or reuse existing registration)
|
||||
// TODO: make thread safe
|
||||
@@ -232,7 +231,7 @@ bool GPIO_subscribe(GPIO_TypeDef* GPIO_port, uint16_t GPIO_pin,
|
||||
// Set up GPIO
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
GPIO_InitStruct.Pin = GPIO_pin;
|
||||
GPIO_InitStruct.Mode = interrupt_mode;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
||||
GPIO_InitStruct.Pull = pull_up_down;
|
||||
HAL_GPIO_Init(GPIO_port, &GPIO_InitStruct);
|
||||
|
||||
|
||||
@@ -121,8 +121,7 @@ void Axis::set_step_dir_active(bool active) {
|
||||
HAL_GPIO_Init(dir_port_, &GPIO_InitStruct);
|
||||
|
||||
// Subscribe to rising edges of the step GPIO
|
||||
GPIO_subscribe(step_port_, step_pin_, GPIO_PULLDOWN,
|
||||
GPIO_MODE_IT_FALLING, step_cb_wrapper, this);
|
||||
GPIO_subscribe(step_port_, step_pin_, GPIO_PULLDOWN, step_cb_wrapper, this);
|
||||
|
||||
step_dir_active_ = true;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user