mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-26 03:23:39 +08:00
Add selectable intterupt mode to gpio_subscribe
This commit is contained in:
@@ -72,8 +72,8 @@ void MX_GPIO_Init(void);
|
||||
|
||||
void SetGPIO12toUART();
|
||||
bool GPIO_subscribe(GPIO_TypeDef* GPIO_port, uint16_t GPIO_pin,
|
||||
uint32_t pull_up_down,
|
||||
void (*callback)(void*), void* ctx);
|
||||
uint32_t pull_up_down, uint32_t interrupt_mode,
|
||||
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,8 @@ 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,
|
||||
void (*callback)(void*), void* ctx) {
|
||||
uint32_t pull_up_down, uint32_t interrupt_mode,
|
||||
void (*callback)(void*), void* ctx) {
|
||||
|
||||
// Register handler (or reuse existing registration)
|
||||
// TODO: make thread safe
|
||||
@@ -232,7 +232,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 = GPIO_MODE_IT_RISING;
|
||||
GPIO_InitStruct.Mode = interrupt_mode;
|
||||
GPIO_InitStruct.Pull = pull_up_down;
|
||||
HAL_GPIO_Init(GPIO_port, &GPIO_InitStruct);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user