This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Simple wakeup on GPIO after sd_power_system_off

Hi, I'm building a BLE peripheral with one button only. The button exposed over bluetooth. Obviously, the button handling module (GPIOTE) is used. After advertisement timeout the device goes off and then the button should be used to wake it up. Simple reset would be just fine. However, after entering sleep mode the device becomes unresponsive.

I'm prototyping on NRF52 DK, initialization code is as follows (please note it's compiled with CFLAGS+=-DBSP_SIMPLE):

#define CONTROL_BUTTON      BUTTON_1

static app_button_cfg_t buttons[] = {
    {CONTROL_BUTTON, BUTTONS_ACTIVE_STATE, BUTTON_PULL, button_evt_handler}
};

bsp_board_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS);

err_code = app_button_init(buttons, ARRAY_SIZE(buttons), BUTTON_RELEASE_TIMEOUT);
APP_ERROR_CHECK(err_code);

err_code = app_button_enable();
APP_ERROR_CHECK(err_code);

Then the following code is executed on BLE_ADV_EVT_IDLE to put the system to sleep:

NRF_LOG_INFO("Power off");
NRF_LOG_FLUSH();
        
/* Prepare wakeup buttons */
nrf_gpio_pin_sense_t sense = BUTTONS_ACTIVE_STATE ?
      NRF_GPIO_PIN_SENSE_HIGH : NRF_GPIO_PIN_SENSE_LOW;
nrf_gpio_cfg_sense_set(CONTROL_BUTTON, sense);
        
/* Go to system-off mode (won't return; wakeup will cause a reset) */
err_code = sd_power_system_off();
/* NOT REACHED */
APP_ERROR_CHECK(err_code);

I see the "Power off" message, and the device stops responding to BLE and button press (no more calls to the button_evt_handler()). Everything after the sd_power_system_off() seem never executed. But the button can't wake the device up. It's either stuck somewhere in the sd_power_system_off() or I just misconfigured the wakeup button.

Looks like a trivial issue, but can't nail it down for the day :-/ Any help would be greatly appreciated.

Parents Reply Children
Related