-
Notifications
You must be signed in to change notification settings - Fork 5.2k
添加HC32F460系列RTC外设驱动 #6069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
添加HC32F460系列RTC外设驱动 #6069
Conversation
p_tm = gmtime(&time_stamp); | ||
if (p_tm->tm_year < 100) | ||
{ | ||
return -RT_ERROR; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#6012 这个位置参见这个pr改一下gmtime不是线程安全函数
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
比较奇怪,换成gmtime_r后,时间也能设置成功,但是设置为立马会重启,或者hardfault。暂时还未找出来问题
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那就先合并这个吧
修复替换后设置日期会复位或者hardfault的bug,原因是定义p_tm指针未初始化。 struct tm p_tm = {0}; gmtime_r(&time_stamp, &p_tm);
#include <rtthread.h> | ||
#include <rtdevice.h> | ||
#include <sys/time.h> | ||
#include <drivers/adc.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不需要包含这个头文件。
tm_new.tm_sec = stcRtcTime.u8Second; | ||
tm_new.tm_min = stcRtcTime.u8Minute; | ||
tm_new.tm_hour = stcRtcTime.u8Hour; | ||
tm_new.tm_mday = stcRtcDate.u8Day + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参考下time_t结构变量的取值范围。
stcRtcTime.u8Second = p_tm->tm_sec ; | ||
stcRtcTime.u8Minute = p_tm->tm_min ; | ||
stcRtcTime.u8Hour = p_tm->tm_hour; | ||
stcRtcDate.u8Day = p_tm->tm_mday + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参考下time_t结构变量的取值范围。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
设置时间后读出的才是有效数据,日1~31,月1~12,修改与tm数据范围一致。
stcRtcDate.u8Day = p_tm.tm_mday - 1; | ||
stcRtcDate.u8Month = p_tm.tm_mon ; | ||
stcRtcDate.u8Day = p_tm.tm_mday; | ||
stcRtcDate.u8Month = p_tm.tm_mon + 1; | ||
stcRtcDate.u8Year = p_tm.tm_year - 100; | ||
stcRtcDate.u8Weekday = p_tm.tm_wday + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不需要+1
stcRtcInit.u8ClockSrc = RTC_CLK_SRC_LRC; | ||
#endif | ||
stcRtcInit.u8HourFormat = RTC_HOUR_FMT_24H; | ||
stcRtcInit.u8IntPeriod = RTC_INT_PERIOD_PER_SEC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不需要配周期中断,虽然中断没有开不会产生实际中断
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
请解决一下冲突 |
+1 |
拉取/合并请求描述:(PR description)
[

【ev_hc32f460_lqfp100_v2】BSP中添加RTC驱动。
1.hc32\libraries\hc32_drivers中添加drv_rtc.c文件;
2.修改hc32\libraries\hc32_drivers中sconscript文件;
3.修改board文件夹下Kconfig文件,增加RTC选项;
本次PR代码已在ev_hc32f460_lqfp100_v2开发板测试通过。
]
以下的内容不应该在提交PR时的message修改,修改下述message,PR会被直接关闭。请在提交PR后,浏览器查看PR并对以下检查项逐项check,没问题后逐条在页面上打钩。
The following content must not be changed in the submitted PR message. Otherwise, the PR will be closed immediately. After submitted PR, please use a web browser to visit PR, and check items one by one, and ticked them if no problem.
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0
代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up