diff --git a/boards/arm/stm32/nucleo-g431rb/src/Make.defs b/boards/arm/stm32/nucleo-g431rb/src/Make.defs index 23c2705ece8..f55b633e59e 100644 --- a/boards/arm/stm32/nucleo-g431rb/src/Make.defs +++ b/boards/arm/stm32/nucleo-g431rb/src/Make.defs @@ -29,6 +29,10 @@ else CSRCS += stm32_userleds.c endif +ifeq ($(CONFIG_ARCH_BUTTONS),y) +CSRCS += stm32_buttons.c +endif + ifeq ($(CONFIG_LIB_BOARDCTL),y) CSRCS += stm32_appinit.c endif diff --git a/boards/arm/stm32/nucleo-g431rb/src/nucleo-g431rb.h b/boards/arm/stm32/nucleo-g431rb/src/nucleo-g431rb.h index 5c51f0ac36c..557c9536d9b 100644 --- a/boards/arm/stm32/nucleo-g431rb/src/nucleo-g431rb.h +++ b/boards/arm/stm32/nucleo-g431rb/src/nucleo-g431rb.h @@ -57,6 +57,24 @@ #define LED_DRIVER_PATH "/dev/userleds" +/* Button definitions *******************************************************/ + +/* The Nucleo G431RB supports two buttons; only one button is controllable + * by software: + * + * B1 USER: user button connected to the I/O PC13 of the STM32G431RB. + * B2 RESET: push button connected to NRST is used to RESET the + * STM32G431R. + * + * NOTE that EXTI interrupts are configured. + */ + +#define MIN_IRQBUTTON BUTTON_USER +#define MAX_IRQBUTTON BUTTON_USER +#define NUM_IRQBUTTONS 1 + +#define GPIO_BTN_USER (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTC|GPIO_PIN13) + /* PWM */ #define NUCLEOG431RB_PWMTIMER 1 diff --git a/boards/arm/stm32/nucleo-g431rb/src/stm32_buttons.c b/boards/arm/stm32/nucleo-g431rb/src/stm32_buttons.c index 0f5ef872552..d1664202e47 100644 --- a/boards/arm/stm32/nucleo-g431rb/src/stm32_buttons.c +++ b/boards/arm/stm32/nucleo-g431rb/src/stm32_buttons.c @@ -74,11 +74,11 @@ uint32_t board_button_initialize(void) uint32_t board_buttons(void) { - /* Check the state of the USER button. A LOW value means that the key is + /* Check the state of the USER button. A HIGH value means that the key is * pressed. */ - return stm32_gpioread(GPIO_BTN_USER) ? 0 : BUTTON_USER_BIT; + return stm32_gpioread(GPIO_BTN_USER) ? BUTTON_USER_BIT : 0; } /****************************************************************************