【已解决】BK7231N设置深度睡眠
Posted: 2022年 Nov 4日 10:43
您好,请问B7231N 如何实现设置深度睡眠 是否是示例
新版Tuya OS
您好,请问B7231N 如何实现设置深度睡眠 是否是示例
新版Tuya OS
tuyaos bk7231n的开发框架目前不支持深度睡眠,如果需要深度睡眠的功能,需要使用原厂提供的接口。具体使用的方法我看看内部有没有。
刚刚和我们的同事确认了,BK7231N原厂深度睡眠效果不好,所以我们bk7231n的开发框架没有支持这个功能。如果需要使用深度睡眠的功能,要用bk7231NL这款芯片。
bk平台 深入睡眠使用:
Code: Select all
VOID tuya_deepsleep_enter(_TUYA_FRAME_S *pframe)
{
PR_NOTICE("pframe -> %d, %d %d %d", pframe->data[0],pframe->data[1],pframe->data[2],pframe->data[3],pframe->data[4]);
if(TEST_SUITE_DEEPSLEEP != pframe->data[0]) {
PR_ERR("deep sleep cmd error !!!");
return;
}
PS_DEEP_CTRL_PARAM deep_sleep_param;
//IO_LEVEL_E curr_io_level = 0;
UINT_T time = pframe->data[1] * 60; //转成分钟
TY_GPIO_PORT_E io_prot = pframe->data[2];
IO_LEVEL_E io_level = pframe->data[3];
BOOL_T io_float = pframe->data[4];
if (time){
deep_sleep_param.wake_up_way = (PS_DEEP_WAKEUP_RTC+PS_DEEP_WAKEUP_GPIO);
}else {
deep_sleep_param.wake_up_way = PS_DEEP_WAKEUP_GPIO;
}
UINT_T io_sleep_config = 1 << io_prot;
deep_sleep_param.gpio_index_map = io_sleep_config;
deep_sleep_param.gpio_edge_map = io_level << io_prot;
deep_sleep_param.gpio_stay_lo_map =io_sleep_config;
deep_sleep_param.gpio_last_index_map = 0;
deep_sleep_param.gpio_last_edge_map = 0;
deep_sleep_param.gpio_stay_hi_map = 0;
if(time) {
deep_sleep_param.sleep_time = time; //入参为秒
deep_sleep_param.lpo_32k_src = LPO_SELECT_32K_DIV;
}
if(!io_float) {
io_level = tuya_gpio_read(io_prot); //浮空时, 唤醒有效电平取决于io 当前电平
//io_level = !io_level;
deep_sleep_param.gpio_edge_map = io_level << io_prot;
sctrl_set_deep_sleep_gpio_floating_map(io_sleep_config);
}
PR_NOTICE("enter sleep mode,sleep_timer is %d, %x, %x",time, deep_sleep_param.gpio_index_map, deep_sleep_param.gpio_edge_map);
bk_enter_deep_sleep_mode(&deep_sleep_param); //进入休眠
}
chaser 2022年 Nov 4日 18:48bk平台 深入睡眠使用:
Code: Select all
VOID tuya_deepsleep_enter(_TUYA_FRAME_S *pframe)
{
PR_NOTICE("pframe -> %d, %d %d %d", pframe->data[0],pframe->data[1],pframe->data[2],pframe->data[3],pframe->data[4]);
if(TEST_SUITE_DEEPSLEEP != pframe->data[0]) {
PR_ERR("deep sleep cmd error !!!");
return;
}
PS_DEEP_CTRL_PARAM deep_sleep_param;
//IO_LEVEL_E curr_io_level = 0;
UINT_T time = pframe->data[1] * 60; //转成分钟
TY_GPIO_PORT_E io_prot = pframe->data[2];
IO_LEVEL_E io_level = pframe->data[3];
BOOL_T io_float = pframe->data[4];
if (time){
deep_sleep_param.wake_up_way = (PS_DEEP_WAKEUP_RTC+PS_DEEP_WAKEUP_GPIO);
}else {
deep_sleep_param.wake_up_way = PS_DEEP_WAKEUP_GPIO;
}
UINT_T io_sleep_config = 1 << io_prot;
deep_sleep_param.gpio_index_map = io_sleep_config;
deep_sleep_param.gpio_edge_map = io_level << io_prot;
deep_sleep_param.gpio_stay_lo_map =io_sleep_config;
deep_sleep_param.gpio_last_index_map = 0;
deep_sleep_param.gpio_last_edge_map = 0;
deep_sleep_param.gpio_stay_hi_map = 0;
if(time) {
deep_sleep_param.sleep_time = time; //入参为秒
deep_sleep_param.lpo_32k_src = LPO_SELECT_32K_DIV;
}
if(!io_float) {
io_level = tuya_gpio_read(io_prot); //浮空时, 唤醒有效电平取决于io 当前电平
//io_level = !io_level;
deep_sleep_param.gpio_edge_map = io_level << io_prot;
sctrl_set_deep_sleep_gpio_floating_map(io_sleep_config);
}
PR_NOTICE("enter sleep mode,sleep_timer is %d, %x, %x",time, deep_sleep_param.gpio_index_map, deep_sleep_param.gpio_edge_map);
bk_enter_deep_sleep_mode(&deep_sleep_param); //进入休眠
}
好的 感谢