nucleo-g431rb: fixes for button

This commit is contained in:
raiden00pl 2021-04-14 15:08:25 +02:00 committed by Xiang Xiao
parent 82ce1de7cd
commit 5e59d3753a
3 changed files with 24 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
}
/****************************************************************************