RTC
概述
实时时钟( Real Time Clock )的内部计数器计数达到指定值时,会产生定时中断,该指定值由软件配置。
WQ7036 片载 4 路 32KHzRTC , WQSDK 可以提供当前 core RTC 和全局 RTC 控制接口。
功能特性
RTC 主要支持如下特性:
32bit 的计数数值。
只支持向上计数。
设置补偿值。
软件暂停计数和清零。
单 cycle 计数和多 cycle 计数。
2 个 timer 级联成 1 个 64bit counter mode。
资源依赖
RTC
工作模式
调用 wq_rtc_init() 或者 wq_rtc_global_init() 函数时,则对应 RTC TIMER 有以下工作特征:
对应 core 或者 global RTC timer 默认支持级联模式,两个计数器可以级联成一个 64bit 的计数器。
对应 core 或者 global RTC timer 被设置为计数到指定值后,计数器仍继续计数。
对应 core 或者 global RTC timer div 设为 1 ,即每一个周期计数 1 。
使能对应 core 或者 global RTC timer 。
用法流程
当前 core RTC
初始化
wq_rtc_init()设置 RTC tick
wq_rtc_set_time()获取 RTC tick
wq_rtc_get_time()获取级联 64 位 RTC tick
wq_rtc_get_time64()获取微秒时间
wq_rtc_get_time_us()获取毫秒时间
wq_rtc_get_time_ms()获取秒时间
wq_rtc_get_time_s()注销
wq_rtc_deinit()
全局 RTC
初始化
wq_rtc_global_init()设置 RTC tick
wq_rtc_global_set_time()获取 RTC tick
wq_rtc_get_global_time()获取级联 64 位 RTC tick
wq_rtc_get_global_time64()获取微秒时间
wq_rtc_get_global_time_us()获取毫秒时间
wq_rtc_get_global_time_ms()获取秒时间
wq_rtc_get_global_time_s()获取唤醒 RTC 时间
wq_rtc_get_wakeup_rtc_time()注销
wq_rtc_global_deinit()
API 介绍
Functions
-
uint64_t wq_rtc_to_us64(uint64_t rtc)
This function is to convert rtc time in Microseconds.
- 参数:
rtc -- is rtc time.
- 返回:
uint64_t is rtc time in Microseconds.
-
uint64_t wq_ms_to_rtc64(uint64_t ms)
This function is to convert milliseconds time in rtc time.
- 参数:
ms -- is milliseconds time.
- 返回:
uint64_t is milliseconds time in rtc time.
-
uint64_t wq_rtc_to_ms64(uint64_t rtc)
This function is to convert rtc time in milliseconds.
- 参数:
rtc -- is rtc time.
- 返回:
uint64_t is rtc time in milliseconds.
-
uint32_t wq_rtc_to_us(uint32_t rtc)
This function is to convert rtc time in Microseconds.
- 参数:
rtc -- is rtc time.
- 返回:
uint32_t is rtc time in Microseconds.
-
uint32_t wq_ms_to_rtc(uint32_t ms)
This function is to convert milliseconds time in rtc time.
- 参数:
ms -- is milliseconds time.
- 返回:
uint32_t is milliseconds time in rtc time.
-
uint32_t wq_rtc_to_ms(uint32_t rtc)
This function is to convert rtc time in milliseconds.
- 参数:
rtc -- is rtc time.
- 返回:
uint32_t is rtc time in milliseconds.
-
WQ_RET wq_rtc_init(bool clear)
This function is to init rtc module.
- 参数:
clear -- is true to clear current counter else not clear.
- 返回:
WQ_RET_OK Success.
WQ_RET_AGAIN Repeated initialization.
-
WQ_RET wq_rtc_set_time(uint32_t time)
This function is to set time for rtc.
- 参数:
time -- is the time to set.
- 返回:
WQ_RET_OK Success.
-
uint32_t wq_rtc_get_time(void)
This function is to get current rtc time.
- 返回:
uint32_t is current time.
-
uint32_t wq_rtc_get_time_us(void)
This function is to get current rtc time in Microseconds.
- 返回:
uint32_t is current time in Microseconds.
-
uint32_t wq_rtc_get_time_ms(void)
This function is to get current rtc time in milliseconds.
- 返回:
uint32_t is current time in milliseconds.
-
uint32_t wq_rtc_get_time_s(void)
This function is to get current rtc time in seconds.
- 返回:
uint32_t is current time in seconds.
-
WQ_RET wq_rtc_global_init(bool clear)
This function is to init rtc globally.
- 参数:
clear -- is true to clear current counter else not clear.
- 返回:
WQ_RET_OK Success.
-
WQ_RET wq_rtc_global_deinit(void)
This function is to deinitialize rtc globally.
- 返回:
WQ_RET_OK Success.
-
WQ_RET wq_rtc_global_set_time(uint32_t time)
This function is to set time for globally rtc.
- 参数:
time -- is the time to set.
- 返回:
WQ_RET_OK Success.
-
uint32_t wq_rtc_get_global_time(void)
This function is to get current global time.
- 返回:
uint32_t is current global time.
-
uint64_t wq_rtc_get_global_time64(void)
This function is to get current global time.
- 返回:
uint64_t is current global time.
-
uint32_t wq_rtc_get_global_time_us(void)
This function is to get current global time in Microseconds.
- 返回:
uint32_t is current global time in Microseconds.
-
uint32_t wq_rtc_get_global_time_ms(void)
This function is to get current global time in milliseconds.
- 返回:
uint32_t is current global time in milliseconds.
-
uint32_t wq_rtc_get_global_time_s(void)
This function is to get current global time in seconds.
- 返回:
uint32_t is current global time in seconds.
-
uint32_t wq_rtc_get_wakeup_rtc_time(void)
This function is to get current time of wakeup rtc.
- 返回:
uint32_t is current time of wakeup rtc.