Copy-paste the following code to your user application:
if (system_get_reset_cause() == SYSTEM_RESET_CAUSE_BACKUP
&& system_get_backup_exit_source() == SYSTEM_RESET_BACKKUP_EXIT_EXTWAKE
&& (system_get_pin_wakeup_cause() & (1 << CONF_EXT_WAKEUP_PIN))){
system_init();
delay_init();
config_clock_output_and_extwake_pin();
led_toggle_indication(4);
port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE);
while(1);
}
system_io_retension_disable();
system_init();
delay_init();
port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE);
config_clock_output_and_extwake_pin();
configure_extint_channel();
delay_s(1);
port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE);
system_set_sleepmode(SYSTEM_SLEEPMODE_STANDBY);
system_sleep();
port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE);
extint_chan_disable_callback(BUTTON_0_EIC_LINE,
EXTINT_CALLBACK_TYPE_DETECT);
extint_chan_clear_detected(BUTTON_0_EIC_LINE);
performance_level_switch_test();
led_toggle_indication(2);
system_set_pin_wakeup_polarity_low(1<<CONF_EXT_WAKEUP_PIN);
system_enable_pin_wakeup(1<<CONF_EXT_WAKEUP_PIN);
system_set_pin_wakeup_debounce_counter(SYSTEM_WAKEUP_DEBOUNCE_2CK32);
system_set_sleepmode(SYSTEM_SLEEPMODE_BACKUP);
system_sleep();