int app_wakeup_handler(ke_msg_id_t const msgid,
void *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
if(power_on_flag==1)
{
power_on_flag= 0;
app_timer_set(APP_LED_TIMER, TASK_APP, 10);
}
power_on_flag= 1;
app_timer_set(APP_LED_TIMER, TASK_APP, 1)
app_timer_set(APP_LED_TIMER, TASK_APP, 1)
app_timer_set(APP_LED_TIMER, TASK_APP,10); < / p > < p > app_adv_start (); < / p > < p >} < br / >} < / p > < p >空白app_button_enable (void) < br / > {< br / > wkupct_register_callback (app_button_press_process);
if(GPIO_GetPinStatus(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN))
{
wkupct_enable_irq(0x200, 0x200, 1,40);/ / P1_1,极性低,1事件,消除抖动时间= 40 ms < br / >} < / p > < p >} < / p > < p >空白app_button_press_process (void) < br / > {< br / >如果(GetBits16 (SYS_STAT_REG PER_IS_DOWN)) < br / > {< br / > periph_init (); < br / >} < / p > < p >如果(app_ble_ext_wakeup_get ()) < br / > {< / p > < p > / /唤醒BLE这里< / p > < p > #如果(EXT_SLEEP_ENABLED) < br / > app_set_extended_sleep (); < br / > # elif (DEEP_SLEEP_ENABLED) < br / > app_set_deep_sleep();其他< br / > # < br / > app_disable_sleep (); < br / > # endif < / p > < p > SetBits32 (GP_CONTROL_REG,BLE_WAKEUP_REQ 1); < br / > app_ble_ext_wakeup_off (); < / p > < p >} < / p > < p > app_button_enable (); < br / > SysTick_Config (160000 - 1), < br / >} < / p > < p >空白SysTick_Handler (void) < br / > {< / p > < p >如果(GPIO_GetPinStatus (GPIO_BUTTON_PORT GPIO_BUTTON_PIN) = = 0) < br / > {< / p > < p > key_press_time_count + +; < br / >} < br / >其他< br / > {< / p > < p > key_press_time_count = 0; < br / > app_button_enable (); < br / > SysTick→CTRL, = ~ (SysTick_CTRL_TICKINT_Msk);< / p > < p >} < / p > < p >如果(power_on_flag = = 1) < br / > {< / p > < p >如果(key_press_time_count = = 300) / / 3 s < br / > {< br / > key_press_time_count = 0; < br / > SysTick→CTRL, = ~ (SysTick_CTRL_TICKINT_Msk); < br / > ke_msg_send_basic (APP_WAKEUP_MSG TASK_APP 0); < / p > < p >} < br / >} < br / >其他< br / > {< br / >如果(key_press_time_count = = 200) / / 2 s < br / > {< br / > key_press_time_count = 0; < br / > SysTick→CTRL, = ~ (SysTick_CTRL_TICKINT_Msk); < br / > ke_msg_send_basic (APP_WAKEUP_MSG TASK_APP,0), < br / >} < br / >} < / p > < p >} < / p > < p >我现在遇到的问题是:在睡眠状态下,我如果按按键的时间小于2 s(本次可以进入app_button_press_process),那么我再次按按键程序没有进入app_button_press_process函数。
如果每次按按键时间都大于2s,整个系统工作正常。< / p > < p >小于2 s程序会执行SysTick_Handler中的这段< br / > {< / p > < p > key_press_time_count = 0; < br / > app_button_enable (); < br / > SysTick→CTRL, = ~ (SysTick_CTRL_TICKINT_Msk);< / p > < p >} < / p > < p >我如果这段程序中的“SysTick→CTRL, = ~ (SysTick_CTRL_TICKINT_Msk); ”屏蔽掉,系统也可以正常工作。
要实现我上门提到的功能有什么需要注意的地方吗? 用什么方法可以实现啊?