Fix GPIO Subscribe issues

This commit is contained in:
Paul Guenette
2019-04-23 22:03:25 +02:00
parent 35d07595ac
commit e720b5239d
3 changed files with 4 additions and 7 deletions
+1 -2
View File
@@ -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);
+2 -3
View File
@@ -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);
+1 -2
View File
@@ -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 {