Skip to content

添加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

Merged
merged 6 commits into from
Jun 15, 2022
Merged

Conversation

xiaoxiaolisunny
Copy link
Contributor

拉取/合并请求描述:(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开发板测试通过。
image

]

以下的内容不应该在提交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):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 本拉取/合并请求代码是高质量的 Code in this PR is of high quality
  • 本拉取/合并使用formatting等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification

@mysterywolf mysterywolf added the BSP: HC32 BSP related with HC32 label Jun 10, 2022
Comment on lines 50 to 54
p_tm = gmtime(&time_stamp);
if (p_tm->tm_year < 100)
{
return -RT_ERROR;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#6012 这个位置参见这个pr改一下gmtime不是线程安全函数

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

比较奇怪,换成gmtime_r后,时间也能设置成功,但是设置为立马会重启,或者hardfault。暂时还未找出来问题

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那就先合并这个吧

@mysterywolf mysterywolf added the in progress PR/issue in progress. label Jun 10, 2022
@mysterywolf mysterywolf added +1 Agree +1 wait_+2 wait for "+2" to confirm and removed in progress PR/issue in progress. labels Jun 11, 2022
修复替换后设置日期会复位或者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>
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参考下time_t结构变量的取值范围。

Copy link
Contributor Author

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;
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要配周期中断,虽然中断没有开不会产生实际中断

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

@mysterywolf
Copy link
Member

请解决一下冲突

@mysterywolf mysterywolf added the fix_for_conflicting Please fix conflicting files. label Jun 13, 2022
@mysterywolf mysterywolf removed the fix_for_conflicting Please fix conflicting files. label Jun 14, 2022
@JamieTx
Copy link
Contributor

JamieTx commented Jun 14, 2022

+1

@mysterywolf mysterywolf added +2 Agree +2 and removed wait_+2 wait for "+2" to confirm labels Jun 14, 2022
@Guozhanxin Guozhanxin merged commit 9d0f088 into RT-Thread:master Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BSP: HC32 BSP related with HC32 +1 Agree +1 +2 Agree +2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants