【技术干货】TuyaOS(NB-IoT)新平台移植指导:适配tkl_nbiot_psm.c
Posted: 2023年 Sep 22日 12:08
本章介绍对tkl_nbiot_psm.c的接口相关适配
平台psm配置相关
Code: Select all
/** * @brief Set config about the paltform * * @return OPERATE_RET OPRT_OK: success others: fail */ OPERATE_RET tkl_nbiot_psm_plat_config(VOID) { // --- BEGIN: user implements --- return OPRT_NOT_SUPPORTED; // --- END: user implements --- }
对于PSM相关初始化无特殊操作,直接返回OPRT_OK
Code: Select all
/** * @brief Regist the PSM sleep notify cb * * @param cb notify callback function * @return OPERATE_RET OPRT_OK: success others: fail */ OPERATE_RET tkl_nbiot_psm_sleep_notify_reg(TKL_NB_PSM_NOTIFY_CB_T cb) { // --- BEGIN: user implements --- return OPRT_NOT_SUPPORTED; // --- END: user implements --- }
系统睡眠事件通知回调注册(设备睡眠前需要将各种睡眠类型通过回调cb通知SDK)
Code: Select all
/** * @brief Specify a pin for wakeup trigger * * @param pin_num @ref TKL_GPIO_NAME_E * @param wakeup_cb call back funtion * @return OPERATE_RET OPRT_OK: success others: failed */ OPERATE_RET tkl_nbiot_psm_wakeup_pin_cfg(INT_T pin_num, TKL_NB_WAKEUP_CB wakeup_cb) { // --- BEGIN: user implements --- return OPRT_NOT_SUPPORTED; // --- END: user implements --- }
PSM外部硬件唤醒脚及唤醒后回调函数注册
睡眠锁操作
Code: Select all
/** * @brief Create a psm manager lock * * @param lock_name name of the lock * @param handle sleeplock handle * @return OPERATE_RET OPRT_OK: success others: fail */ OPERATE_RET tkl_nbiot_psm_create_sleeplock(CONST PCHAR_T lock_name, UCHAR_T *handle) { // --- BEGIN: user implements --- return OPRT_NOT_SUPPORTED; // --- END: user implements --- }
创建睡眠锁
Code: Select all
/** * @brief Acquire the sleeplock, keep awake * * @param handle sleeplock handle * @return OPERATE_RET OPRT_OK: success others: fail */ OPERATE_RET tkl_nbiot_psm_acquire_sleeplock(UCHAR_T handle) { // --- BEGIN: user implements --- return OPRT_NOT_SUPPORTED; // --- END: user implements --- }
睡眠锁定(禁止系统进入睡眠)
Code: Select all
/** * @brief Release the sleeplock, allow psm * * @param handle sleeplock handle * @return OPERATE_RET OPRT_OK: success others: fail */ OPERATE_RET tkl_nbiot_psm_release_sleeplock(UCHAR_T handle) { // --- BEGIN: user implements --- return OPRT_NOT_SUPPORTED; // --- END: user implements --- }
睡眠锁释放(允许系统进入睡眠)
睡眠操作相关
Code: Select all
/** * @brief Force enter psm mode * * @return VOID */ VOID tkl_nbiot_psm_force_sleep(VOID) { // --- BEGIN: user implements --- return ; // --- END: user implements --- }
强制睡眠(立即进入睡眠)
Code: Select all
/** * @brief Get the power on reason * * @param result powerson reason * @return OPERATE_RET OPRT_OK: success others: fail */ OPERATE_RET tkl_nbiot_psm_get_poweron_result(TKL_NB_POWER_ON_RESULT_E *result) { // --- BEGIN: user implements --- return OPRT_NOT_SUPPORTED; // --- END: user implements --- }
获取系统从何种状态醒来(上电启动/睡眠/系统复位/看门狗复位等)
Code: Select all
/** * @brief Get the wake up reason * * @param src wakeup reason reason * @return OPERATE_RET OPRT_OK: success others: fail */ OPERATE_RET tkl_nbiot_psm_get_wakeup_source(TKL_NB_WAKEUP_SOURCE_E *src) { // --- BEGIN: user implements --- return OPRT_NOT_SUPPORTED; // --- END: user implements --- }
获取系统被何种唤醒源唤醒(上电唤醒/RTC定时唤醒/PSM按键唤醒)
睡眠定时器相关操作
Code: Select all
/** * @brief Create rtc timer * * @param time_period_sec time period of the timer * @param is_periodic if the timer is perodic * @param cb timer callback * @return OPERATE_RET OPRT_OK: success others: failed */ OPERATE_RET tkl_nbiot_psm_rtc_timer_create(UINT_T time_period_sec, BOOL_T is_periodic,TKL_NB_SLP_TIMER_CB_T cb) { // --- BEGIN: user implements --- return OPRT_NOT_SUPPORTED; // --- END: user implements --- }
创建睡眠定时器
Code: Select all
/** * @brief Start a rtc timer * * @param null * @return OPERATE_RET OPRT_OK: success others: failed */ OPERATE_RET tkl_nbiot_psm_rtc_timer_start(VOID) { // --- BEGIN: user implements --- return OPRT_NOT_SUPPORTED; // --- END: user implements --- }
启动睡眠定时器
Code: Select all
/** * @brief Stop rtc timer * * @param null * @return OPERATE_RET OPRT_OK: success others: failed */ OPERATE_RET tkl_nbiot_psm_rtc_timer_stop(VOID) { // --- BEGIN: user implements --- return OPRT_NOT_SUPPORTED; // --- END: user implements --- }
停止睡眠定时器
Code: Select all
/** * @brief Del rtc timer * * @param null * @return OPERATE_RET OPRT_OK: success others: failed */ OPERATE_RET tkl_nbiot_psm_rtc_timer_delete(VOID) { // --- BEGIN: user implements --- return OPRT_NOT_SUPPORTED; // --- END: user implements --- }
删除睡眠定时器
其他
Code: Select all
/** * @brief Check the usb is active * * @return BOOL_T true: active false: not active */ BOOL_T tkl_nbiot_psm_usb_is_active(VOID) { // --- BEGIN: user implements --- return false; // --- END: user implements --- }
返回USB是否处于激活状态,系统无USB直接返回false.