|
1、应用层私有的调度任务可以放置在user_schedule()里面实现,代码如下: int main(void)
{
ble_stack_config();
rwip_init() //om_ble_enable();
co_power_register_user_status(power_sleep_status_handler);
co_power_register_sleep_event(power_sleep_event_handler);
while(1)
{
rwip_schedule();
user_schedule();
}
}2、需要确保能执行到user_schedule(),必须在power_sleep_status_handler()中将user_power_status设置为POWER_ACTIVE,否则芯片则可能会因没有任何任务了而进入Sleep或者WFI,此时芯片只会在底层有中断或其它事件才会退出Sleep、WFI去执行user_schedule(); 需要注意POWER_ACTIVE也会阻止芯片睡眠且CPU一直在运行,如果应用层需要让芯片可以进入休眠,则需要更改user_power_status的值为POWER_SLEEP(或POWER_DEEP_SLEEP、POWER_SHUTDOWN); static co_power_status_t power_sleep_status_handler(void)
{
co_power_status_t user_power_status=POWER_ACTIVE;
return MIN(user_power_status, pmu_power_status());
}3、软定时器co_timer以及消息处理,都是在rwip_schedule_event()里面; 4、在power_sleep_event_handler()中POWER_SLEEP_LEAVE_TOP_HALF中需要将一些会使用到高速时钟的外设(比如UART、硬件timer等)重新设置一次(因为sleep后外设掉电,休眠前的配置都已丢失),对应函数peripheral_restore();不可在这个函数内放置uart的打印信息,可能无法工作,因为休眠会关闭一些外设; static void power_sleep_event_handler(co_power_sleep_state_t sleep_state, co_power_status_t power_status)
{
switch(sleep_state)
{
case POWER_SLEEP_ENTRY:
break;
case POWER_SLEEP_LEAVE_TOP_HALF:
peripheral_restore();
break;
case POWER_SLEEP_LEAVE_BOTTOM_HALF:
break;
}
}5、om_ble_enable()为OM6621E的初始化协议栈,HS6621x系列的初始化协议栈是rwip_init(); GAPM_RESET为HS6621x系列的复位协议栈,而OM6621E不需要复位协议栈; 6、rwip_schedule_event()在底层,应用层看不到,对应的OM6621E该函数名称是co_sche_once(); 7、rwip_schedule()是HS6621x系列的调度函数,对应的OM6621E该函数需要这2个函数组成co_sche_once();co_power_manage(); 8、OM6621E的co_sche(); 底层是由下面代码实现的 while(1) { co_sche_once(); co_power_manage(); }
|

