代码拉取完成,页面将自动刷新
实时时钟(RTC)提供可靠的系统时间,包括年月日和时分秒。
通过采用电池供电,在系统处于关机状态时,RTC也能正常工作。
RTC 驱动支持的平台包括 FT2000/4、D2000。
RTC 驱动程序主要完成RTC模块的初始化、时间设置和读取,该驱动程序具备以下功能:
相关源文件为:
frtc
├── frtc.c
├── frtc.h
├── frtc_g.c
├── frtc_hw.c
├── frtc_hw.h
├── frtc_intr.c
└── frtc_sinit.c
以下部分将指导您完成 RTC 驱动的软件配置:
暂未重构
typedef struct
{
uintptr control_base_addr; /* rtc控制寄存器基地址 */
const char *instance_name; /* instance name */
} FRtcConfig; /* rtc配置 */
typedef struct
{
FRtcConfig config; /* rtc配置 */
u32 is_ready; /* rtc初始化完成标志 */
} FRtcCtrl;
typedef struct
{
u16 year; /*Specifies the RTC Date Year.
This parameter must be a number between Min_Data = 2000 and Max_Data = 2099 */
u8 month; /*Specifies the RTC Date Month.
This parameter must be a number between Min_Data = 1 and Max_Data = 12 */
u8 mday; /*Specifies the RTC day of Month.
This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
u8 hour; /*Specifies the RTC Time Hour.
This parameter must be a number between Min_Data = 0 and Max_Data = 23 */
u8 minute; /*Specifies the RTC Time Minute.
This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
u8 second; /*Specifies the RTC Time Second.
This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
} FRtcDateTime;
模块错误码编号 0x1020000
[0x0] FRTC_SUCCESS : success
[0x1020001] FRTC_ERR_DATE_INVALID : invalid date parameters
[0x1020002] FRTC_ERR_TIME_INVALID : invalid time parameters
const FRtcConfig *FRtcLookupConfig(void);
Note:
- 用户需要修改配置参数时,可以通过修改返回的FRtcConfig副本,作为后续使用函数的入参,
Input:
- void, 只有一个RTC模块
Return:
- const FRTCConfig *, 返回驱动默认参数, NULL表示失败
FError FRtcCfgInitialize(FRtcCtrl *instance_p, const FRtcConfig *config_p);
Note:
- 用户需要修改配置参数时,可以通过修改返回的FRtcConfig副本,作为后续使用函数的入参,
Input:
- FRtcCtrl *instance_p, RTC驱动控制块
- const FRtcConfig *config_p, RTC驱动配置数据
Return:
- 返回初始化错误码,FRTC_SUCCESS表示初始化成功
FError FRtcSetDateTime(FRtcCtrl *pctrl, const FRtcDateTime *date_time);
Note:
- 此函数会根据传入的时间初始化RTC时间寄存器
Input:
- FRtcCtrl *pctrl, RTC驱动实例数据
- const FRtcDateTime *date, 设置的RTC时间年月日时分秒
Return:
- u32, 参考5.2章错误码定义
FError FRtcGetDateTime(FRtcCtrl *pctrl, FRtcDateTime *date_time);
Note:
- 此函数会获取当前的RTC时间
Input:
- FRtcCtrl *pctrl, RTC驱动实例数据
- FRtcDateTime *date, 获取的RTC时间年月日时分秒
Return:
- u32, 参考5.2章错误码定义
time_t FRtcReadTimeStamp(FRtcCtrl *pctrl, time_t *sec, time_t *msec);
Note:
- 此函数会读取RTC时间,并返回time_t格式的时间值
Input:
- FRtcCtrl *pctrl, RTC驱动实例数据
- time_t *sec, 获取的秒时间戳,传入NULL表示不需要获取
- time_t *msec, 获取的毫秒时间戳,传入NULL表示不需要获取
Return:
- time_t, 详见<time.h>中的定义
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。