T1模组,SDK为T1-AHL_TuyaOS-3.8.6怎么让模块进入休眠模式还有设置唤醒源

Wi-Fi 设备、Wi-Fi 低功耗设备、Wi-Fi BLE 双模设备、Ethernet设备、Ethernet+Wi-Fi设备等
Post Reply
Chefil
Posts: 25

如图所示,之前用CBU模组可以调用原厂的接口使模块进入休眠,我想问下T1模块怎么设置模块进入深度休眠

Attachments
a6bdd148ef526ac4c577f56ec01d9f65.png
JSHANG
Posts: 39

Re: T1模组,SDK为T1-AHL_TuyaOS-3.8.6怎么让模块进入休眠模式还有设置唤醒源

T1模组设置休眠的接口实现参考如下文件:
tuyaos/tuyaos_adapter/include/wakeup/include/tkl_wakeup.h
tuyaos/tuyaos_adapter/src/driver/tkl_wakeup.c

支持GPIO和Timer唤醒:
TUYA_WAKEUP_SOURCE_BASE_CFG_T cfg;

cfg.source = BIT(TUYA_WAKEUP_SOURCE_GPIO);
cfg.wakeup_para.gpio_param.gpio_num = TUYA_GPIO_NUM_0;
cfg.wakeup_param.gpio_param.level = TUYA_GPIO_LEVEL_HIGH;

tkl_wakeup_source_set(&cfg); /* 设置GPIO 唤醒 */

Chefil
Posts: 25

Re: T1模组,SDK为T1-AHL_TuyaOS-3.8.6怎么让模块进入休眠模式还有设置唤醒源

需要设置gpio和定时器一起唤醒,应该怎么写

Chefil
Posts: 25

Re: T1模组,SDK为T1-AHL_TuyaOS-3.8.6怎么让模块进入休眠模式还有设置唤醒源

还有就是,唤醒以后我怎么判断是定时器唤醒还是gpio唤醒,如果有多个个gpio唤醒,怎么判断对应的gpio

JSHANG
Posts: 39

Re: T1模组,SDK为T1-AHL_TuyaOS-3.8.6怎么让模块进入休眠模式还有设置唤醒源

当前版本不支持同时设置多个唤醒源;唤醒后,可以通过tkl_wakeup_source_get获取被那个gpio唤醒的

JSHANG
Posts: 39

Re: T1模组,SDK为T1-AHL_TuyaOS-3.8.6怎么让模块进入休眠模式还有设置唤醒源

设置多个唤醒参考如下:
OPERATE_RET tkl_wakeup_source_set_x(void)
{
PS_DEEP_CTRL_PARAM ps_cfg;

Code: Select all

memset(&ps_cfg, 0, sizeof(ps_cfg));

/* Set wakeup by timer */
ps_cfg.wake_up_way |= PS_DEEP_WAKEUP_RTC;
ps_cfg.lpo_32k_src = LPO_SELECT_ROSC;
ps_cfg.sleep_time = 60000;    /* 设置休眠时间 */

/* Set wakeup by gpio */
ps_cfg.wake_up_way |= PS_DEEP_WAKEUP_GPIO;
ps_cfg.gpio_index_map |= (1 << gpio_num);  /* 设置的唤醒GPIO */
ps_cfg.gpio_edge_map |= (1 << gpio_num); /* 高电平唤醒对应位置1, 低电平唤醒不用设置 */

bk_enter_deep_sleep_mode(&ps_cfg);  /* 进入休眠 */
return 0;

}

JSHANG
Posts: 39

Re: T1模组,SDK为T1-AHL_TuyaOS-3.8.6怎么让模块进入休眠模式还有设置唤醒源

ps_cfg.gpio_edge_map |= (1 << gpio_num); /* 下降沿唤醒对应位置1, 默认上升沿唤醒不用设置 */

Chefil
Posts: 25

Re: T1模组,SDK为T1-AHL_TuyaOS-3.8.6怎么让模块进入休眠模式还有设置唤醒源

好的,我试下

Post Reply