diff --git a/examples/dfu/open_bootloader/main.c b/examples/dfu/open_bootloader/main.c index 48dd76b..c93eec1 100644 --- a/examples/dfu/open_bootloader/main.c +++ b/examples/dfu/open_bootloader/main.c @@ -63,6 +63,7 @@ #include "app_timer.h" #include "nrf_delay.h" #include "nrf_clock.h" +#include "nrf_drv_gpiote.h" /* Timer used to blink LED on DFU progress. */ APP_TIMER_DEF(m_dfu_progress_led_timer); @@ -194,6 +195,31 @@ static void dfu_observer(nrf_dfu_evt_type_t evt_type) break; } } + + +void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action) +{ + NRF_LOG_INFO("Pin change interrupt!"); +} + + +static void gpio_in_init(void) +{ + ret_code_t err_code; + + err_code = nrf_drv_gpiote_init(); + APP_ERROR_CHECK(err_code); + + nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true); + in_config.pull = NRF_GPIO_PIN_PULLUP; + + err_code = nrf_drv_gpiote_in_init(BSP_BUTTON_0, &in_config, in_pin_handler); + APP_ERROR_CHECK(err_code); + + nrf_drv_gpiote_in_event_enable(BSP_BUTTON_0, true); +} + + /**@brief Function for application main entry. */ int main(void) @@ -216,6 +242,8 @@ int main(void) NRF_LOG_INFO("Open USB bootloader started"); NRF_LOG_FLUSH(); + gpio_in_init(); + ret_val = nrf_bootloader_init(dfu_observer); APP_ERROR_CHECK(ret_val);