2018-09-04 10:47 AM
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.
2018-09-04 05:16 PM
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");
2018-09-04 06:14 PM
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.