Problem about Wakeup Timer interrupt callback function

8 posts / 0 new
Last post
sklin
Offline
Last seen:5 years 8 months ago
Expert
加入:2014-08-12 08:01
Problem about Wakeup Timer interrupt callback function

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.
}

AK_Dialog
Offline
Last seen:3 weeks 15 hours ago
工作人员
加入:2013-12-16 15:49
Hi SK,

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

sklin
Offline
Last seen:5 years 8 months ago
Expert
加入:2014-08-12 08:01
Hi AK_Dialog

Hi AK_Dialog
I got it,and it's heplful to me.
Thank you very much.

summer20100514
Offline
Last seen:4 years 2 months ago
Guru
加入:2014-12-30 05:01
@AK_Dialog, Hi, I have one

@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 ?

MT_dialog
Offline
Last seen:一周14小时前
工作人员
加入:2015-06-08 11:34
Hi summer20100514,

Hi summer20100514,

The periph_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

summer20100514
Offline
Last seen:4 years 2 months ago
Guru
加入:2014-12-30 05:01
OK, I get it. So there is

OK, I get it. So there is need to call periph_init() when the system is waken up by BLE timers to do something ?

MT_dialog
Offline
Last seen:一周14小时前
工作人员
加入:2015-06-08 11:34
Hi summer20100514,

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

summer20100514
Offline
Last seen:4 years 2 months ago
Guru
加入:2014-12-30 05:01
Thank you.

Thank you.