Good morning/afternoon/evening,
So I am fairly new to nRF system and wanted to know if there is a way to execute an interrupt when one of the buttons on the board is pressed. Using the secure dfu bootloader example. I am working with nRF SDK 16.0v and with a nRF52 DK.
/**@brief Suspend the CPU until an interrupt occurs.
*/
static void wait_for_event(void)
{
#if defined(BLE_STACK_SUPPORT_REQD) || defined(ANT_STACK_SUPPORT_REQD)
(void)sd_app_evt_wait();
#else
// Wait for an event.
__WFE();
// Clear the internal event register.
__SEV();
__WFE();
#endif
}
/**@brief Continually sleep and process tasks whenever woken.
*/
static void loop_forever(void)
{
while (true)
{
//feed the watchdog if enabled.
nrf_bootloader_wdt_feed();
app_sched_execute();
//======Button event ======================
bool volatile tempBool = bsp_board_button_state_get(BSP_BUTTON_0);
NRF_LOG_INFO("The current value of tempBool is:%d", tempBool);
if(tempBool)
{
bsp_board_led_on(BSP_BOARD_LED_1);
}
else
{
bsp_board_led_off(BSP_BOARD_LED_1);
}
//=========================================
if (!NRF_LOG_PROCESS())
{
wait_for_event();
}
}
}
The code posted here is from the example. Here I make a call to get the button state, but for some reason it is reading the button as pressed even though I haven't touched. Is There a way to add an event that will cause an interrupt and toggle the button on or off.
Thank you for your help.
Jose