|
Information
说明: |
建议参照本版块置顶帖内容输入必要信息 |
芯片型号: |
8258 |
SDK及版本: |
- |
本帖最后由 wx_5701358130 于 2024-11-1 18:42 编辑
void sensor_deep_sleep()
{
run_state = SWITCH_SCAN;
// bls_ll_setAdvEnable(BLC_ADV_DISABLE);
int ret = cpu_sleep_wakeup(DEEPSLEEP_MODE_RET_SRAM_LOW16K, PM_WAKEUP_PAD | PM_WAKEUP_TIMER, clock_time() + 200 * CLOCK_16M_SYS_TIMER_CLK_1S);
printf("16K:%d\r\n", ret);
for (u8 i = 0; i < KEY_NUM; i ++)
{
if(gpio_read(key_list))
continue;
cpu_set_gpio_wakeup (key_list, 1, 1); // reverse stuck key pad wakeup level
bls_pm_setWakeupSource(PM_WAKEUP_PAD); //gpio PAD wakeup deesleep
cpu_sleep_wakeup(DEEPSLEEP_MODE_RET_SRAM_LOW16K, PM_WAKEUP_PAD | PM_WAKEUP_TIMER, clock_time() + 10 * CLOCK_16M_SYS_TIMER_CLK_1S);
}
}
void sensor_suspend(void)
{
int ret = cpu_sleep_wakeup(SUSPEND_MODE, PM_WAKEUP_TIMER, 500 * 1000);
printf("suspend:%d\r\n", ret);
}
调用:
void ble_stk_sleep_callback()
{
if (SWITCH_BROADCAST == run_state)
{
// 数据广播模式发送完成后进入深度睡眠
if (++msg_send_count >= MSG_SEND_PACKET_NUM)
{
sensor_suspend();
sensor_deep_sleep();
}
}
}
代码如上,我设置了六个独立按键IO口作为唤醒源,低电平唤醒。进入低功耗时,调用cpu_sleep_wakeup函数的返回值为STATUS_GPIO_ERR_NO_ENTER_PM 时,翻转卡键的唤醒电平状态进入睡眠。我交替的去按下按键,会出现芯片睡眠以后,IO口无法唤醒,只能通过定时器200s唤醒
|
|