cancel
Showing results for 
Search instead for 
Did you mean: 

User Button Configuration for STM32LO72 and LoRa Discovery Kit

BBarr.0
Associate

I want to configure the user button on this LoRa discovery board, and I see various functions regarding the on-board user button, but I am not sure which ones are necessary, nor how to use them, in order to configure the button.

Any help is greatly appreciated. Thank you.

2 REPLIES 2

You should use BSP_PB_Init() to configure the button, and BSP_PB_GetState() to read the current state.

Reading the documentation

BSP_PB_Init(BUTTON_USER, BUTTON_MODE_GPIO);

if (BSP_PB_GetState(BUTTON_USER))

puts("High");

else

puts("Low");

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
T J
Lead

You can read the pin directly, but you would definitely want to add some debouncing,

unstableButton = GPIO_EXTI0_Port->IDR & GPIO_EXTI0_Pin;

if this unstableButton is not the same as the buttonState then increment a counter.

if the counter exceeds some number of scans, then report the new buttonState.