驱动配置
在 Luban-Lite 根目录下执行 scons --menuconfig
,进入 menuconfig 的功能配置界面,按如下选择:
Board options --->
[*] Using RTC
RTC parameter --->
(3276800) The actual rate of 32K clock
[ ] Enable the alarm IO output
[ ] Enable the 32K clock output
1
2
3
4
5
6
2
3
4
5
6
当使用 RT-Thread 内核的时候,RTC 驱动需要依赖 RT-Thread 的 RTC 设备驱动框架和 alarm 框架,也是在 menuconfig 界面中打开:
Rt-Thread options --->
RT-Thread Components --->
Device Drivers --->
[*] Using RTC device drivers
[*] Using RTC alarm
1
2
3
4
5
2
3
4
5
TIP
为了简化使用,Using RTC
会自动打开 RT-Thread 的 RTC设备驱动框架。
RTC 自定义参数
RTC 驱动在 menuconfig 中提供了一些扩展参数,方便客户根据板级硬件设计来进行调整。如下表:
参数名称 | 适用版本 | 类型 | 取值范围 | 功能说明 |
---|---|---|---|---|
AIC_RTC_CLK_RATE | V1.0 | 正整数 | 3276800±3196 | 时钟源的实测频率值*100,用于时钟校准 |
AIC_RTC_ALARM_IO_OUTPUT | V1.0 | boolean | 1-是, 0-否 | 是否使能Alarm的IO输出功能 |
AIC_RTC_32K_IO_OUTPUT | V1.0 | boolean | 1-是, 0-否 | 是否使能32K时钟输出功能 |
INFO
AIC_RTC_CLK_RATE
取时钟源频率值的 100倍,是为了提高校准的精度,校准可以精确到0.03Hz。参数
aic,alarm-io-output
和aic,32k-io-output
共用一个IO输出,所以只能二选一。
时区配置
在 RT-Thread 组件中提供了时区管理功能,Luban-Lite SDK 中默认配置时区为 中国的 +8 时区
。 在 Luban-Lite 根目录下执行 scons --menuconfig
,进入 menuconfig 的功能配置界面,进入功能配置:
Rt-Thread options --->
RT-Thread Components --->
C/C++ and POSIX layer --->
(8) Set the default time zone (UTC+)
1
2
3
4
2
3
4
有没有时区配置,可以通过 Shell 命令 date
的输出信息判断,有 UTC+8
字样表示已经配置了 +8 时区。
aic /> date
local time: Sat May 20 11:22:05 2023
timestamps: 1684552925
timezone: UTC+8
1
2
3
4
2
3
4
此时,RTC 控制器中的时间信息和 date 时间存在一个时区差。 关系如下:
系统时间 = RTC 时间 + 时区
1