Hi Dialog
In the demo project proximity->reporter_fh.I found the Wakeup Timer Interrupt callback function,and I have some problems to consult.
void app_button_press_cb(void)
{
...
if(GetBits16(SYS_STAT_REG, PER_IS_DOWN))
periph_init();//Why does it do peripheral initialization here? What will happen if I remove the function?
if (app_ble_ext_wakeup_get())
{
#if (EXT_SLEEP_ENABLED)
app_set_extended_sleep();
#elif (DEEP_SLEEP_ENABLED)
app_set_deep_sleep();
#else
app_disable_sleep();
#endif
SetBits32(GP_CONTROL_REG, BLE_WAKEUP_REQ, 1);
app_ble_ext_wakeup_off();
ke_msg_send_basic(APP_WAKEUP_MSG, TASK_APP, NULL);
}
app_button_enable();//And why I need to enable the button again even if I have do that in other places.
}
Hi SK,
In sleep mode the peripheral block is powered down. At wake-up the peripherals need to be intialized again (for instance SPI or UART function needs to be restored).
Enabling the wake-up button again in the call-back routine also enables asynchronous wake-up during sleep mode when the device is connected.
BR
Dialog Bluetooth Smart Team
Hi AK_Dialog
I got it,and it's heplful to me.
Thank you very much.
@AK_Dialog, Hi, I have one question, as far as I am concerned, periph_init() is called periodic each time the BLE wakes up. So when should periph_init() be called in app_button_press_cb ? Is it because of the fact that when device is connected, the advertising is stopped and therefore periph_init() is not called periodic ?
Hi summer20100514,
体育riph_init() is called in order to initialize the peripherals every time the da has to do something, whether it is a connection interval or an advertising interval (when there is no external interrupt the periph_init is called from BLE_WAKEUP_Handler). In case of an external wake up event the callback function should be called first, thats why you have to call the periph_init() in the press_button function.
Thanks MT_dialog
OK, I get it. So there is need to call periph_init() when the system is waken up by BLE timers to do something ?
Hi summer20100514,
When the system is awake by the BLE timer the WAKEUP_handler is called, and in the wake up ISR the periph_init() function is called also. You wont have to call it by yourself it is called by the ISR.
Thanks MT_dialog
Thank you.