Files
JBao_Magic_Box_FW/apps/usr_periph/usr_rtc.h
T
wuchuyuan fdb43011b7 1、低电 3.7V 只闪红灯不再 1 分钟后关机;电量低于约 5% 自动关机,未充电开机先闪 5 下红灯再睡回,只能充电后才能开机
2、自动/手动互相切换都闪 2 下灯;APP 发停止后再发自动模式可正常启动,手动残留停止不再挡住自动
3、自动模式 1~6 单次最长跑 10 分钟后回待机;关机时长按 12 秒进 OTA,OTA 期间红绿交替闪
2026-08-27 10:20:48 +08:00

64 lines
2.6 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/******************************************************************************
* @file usr_rtc.h
* @brief 板级 RTC:硬件对时 + 客户读本地日历
* @author cyWu <1917507415@qq.com>
* @date 2026.08.19
* @version V1.1.0
* @history
* - V1.0.0, 2026.08.19, cyWu, 首次发布,实现板级硬件 RTC 对时与本地日历读取
* - V1.1.0, 2026.08.19, cyWu, 精简接口;usr_rtc_get_time 返回本地日历
******************************************************************************/
#ifndef __USR_RTC_H__
#define __USR_RTC_H__
#include <stdint.h>
#include "system/sys_time.h"
/*============================================================================*/
/* 宏定义 */
/*============================================================================*/
#define USR_RTC_YEAR_MIN (2026u) /**< 合法年份下限 */
#define USR_RTC_YEAR_MAX (2098u) /**< 合法年份上限 */
#define USR_RTC_TZ_ABS_MAX_S (57600) /**< 时区偏移绝对值上限(±16h) */
#define USR_RTC_SYNC_COMPENSATE_S (1u) /**< 网关对时延迟补偿(秒) */
/*============================================================================*/
/* 错误码(init / set_from_unix */
/*============================================================================*/
typedef enum {
USR_RTC_OK = 0,
USR_RTC_ERR_PARAM,
USR_RTC_ERR_NOT_INIT,
USR_RTC_ERR_INVALID, /**< 年份非法,等待 App 对时 */
} UsrRtc_Ret_t;
/*============================================================================*/
/* 外部接口 */
/*============================================================================*/
/**
* @brief 打开 rtc 设备并加载时区
* @return USR_RTC_OK=成功,USR_RTC_ERR_NOT_INIT=设备打开失败或 RTC 未使能
*/
UsrRtc_Ret_t usr_rtc_init(void);
/**
* @brief 获取当前本地时间(客户常用)
* @param t 成功时写入年月日时分秒;失败时不改动
* @return 1=已对时且读成功,0=未初始化/未对时/参数非法
*/
uint8_t usr_rtc_get_time(struct sys_time *t);
/**
* @brief App/网关 DEVICEINFOUTC 秒 + 时区写入 RTC
* @param unix_utc UTC Unix 秒;0 无效
* @param tz_s 时区偏移秒(东八区 28800)
* @return USR_RTC_OK=成功,USR_RTC_ERR_NOT_INIT=未初始化,USR_RTC_ERR_PARAM=参数非法,USR_RTC_ERR_INVALID=年份非法
*/
UsrRtc_Ret_t usr_rtc_set_from_unix(uint64_t unix_utc, int32_t tz_s);
#endif /* __USR_RTC_H__ */