基本功能已完成,还差功耗和架构优化
This commit is contained in:
@@ -64,7 +64,7 @@ static void usr_rtc_save_tz(int32_t tz_s);
|
||||
|
||||
/**
|
||||
* @brief 打开 rtc 设备并加载时区
|
||||
* @return UsrRtc_Ret_t
|
||||
* @return USR_RTC_OK=成功,USR_RTC_ERR_NOT_INIT=设备打开失败或 RTC 未使能
|
||||
*/
|
||||
UsrRtc_Ret_t usr_rtc_init(void)
|
||||
{
|
||||
@@ -101,7 +101,7 @@ UsrRtc_Ret_t usr_rtc_init(void)
|
||||
/**
|
||||
* @brief 获取当前本地时间
|
||||
* @param t 成功时赋值;失败不改动
|
||||
* @return 1/0
|
||||
* @return 1=已对时且读成功,0=未初始化/未对时/参数非法
|
||||
*/
|
||||
uint8_t usr_rtc_get_time(struct sys_time *t)
|
||||
{
|
||||
@@ -127,7 +127,7 @@ uint8_t usr_rtc_get_time(struct sys_time *t)
|
||||
* @brief UTC 秒 + 时区 → 本地日历写入 RTC
|
||||
* @param unix_utc UTC 秒
|
||||
* @param tz_s 时区偏移秒
|
||||
* @return UsrRtc_Ret_t
|
||||
* @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)
|
||||
{
|
||||
@@ -184,7 +184,7 @@ UsrRtc_Ret_t usr_rtc_set_from_unix(uint64_t unix_utc, int32_t tz_s)
|
||||
/**
|
||||
* @brief 写硬件日历
|
||||
* @param t 本地日历
|
||||
* @return UsrRtc_Ret_t
|
||||
* @return USR_RTC_OK=成功,USR_RTC_ERR_PARAM=参数非法,USR_RTC_ERR_NOT_INIT=未初始化
|
||||
*/
|
||||
static UsrRtc_Ret_t usr_rtc_write(const struct sys_time *t)
|
||||
{
|
||||
@@ -216,7 +216,7 @@ static UsrRtc_Ret_t usr_rtc_write(const struct sys_time *t)
|
||||
/**
|
||||
* @brief 是否闰年
|
||||
* @param year 公历年
|
||||
* @return 1/0
|
||||
* @return 1=闰年,0=平年
|
||||
*/
|
||||
static uint8_t usr_rtc_is_leap(uint16_t year)
|
||||
{
|
||||
@@ -235,7 +235,7 @@ static uint8_t usr_rtc_is_leap(uint16_t year)
|
||||
* @brief 某月天数
|
||||
* @param year 年
|
||||
* @param month 月 1~12
|
||||
* @return 天数,非法月返回 0
|
||||
* @return 该月天数;非法月份返回 0
|
||||
*/
|
||||
static uint8_t usr_rtc_days_in_month(uint16_t year, uint8_t month)
|
||||
{
|
||||
@@ -256,7 +256,7 @@ static uint8_t usr_rtc_days_in_month(uint16_t year, uint8_t month)
|
||||
/**
|
||||
* @brief 年份是否在合法窗口
|
||||
* @param year 年
|
||||
* @return 1/0
|
||||
* @return 1=合法,0=非法
|
||||
*/
|
||||
static uint8_t usr_rtc_year_ok(uint16_t year)
|
||||
{
|
||||
@@ -266,8 +266,9 @@ static uint8_t usr_rtc_year_ok(uint16_t year)
|
||||
/**
|
||||
* @brief UTC 秒 + 时区 → 本地日历
|
||||
* @param unix_utc UTC 秒
|
||||
* @param tz_s 时区偏移
|
||||
* @param t 输出
|
||||
* @param tz_s 时区偏移秒
|
||||
* @param t 输出本地日历
|
||||
* @return 无
|
||||
*/
|
||||
static void usr_rtc_unix_to_calendar(uint32_t unix_utc, int32_t tz_s,
|
||||
struct sys_time *t)
|
||||
@@ -324,6 +325,7 @@ static void usr_rtc_unix_to_calendar(uint32_t unix_utc, int32_t tz_s,
|
||||
|
||||
/**
|
||||
* @brief 从 VM 加载时区
|
||||
* @return 无
|
||||
*/
|
||||
static void usr_rtc_load_tz(void)
|
||||
{
|
||||
@@ -350,6 +352,7 @@ static void usr_rtc_load_tz(void)
|
||||
/**
|
||||
* @brief 时区写入 VM
|
||||
* @param tz_s 时区偏移秒
|
||||
* @return 无
|
||||
*/
|
||||
static void usr_rtc_save_tz(int32_t tz_s)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user