Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

components: drivers: rtc: add the alarm using local time for calculation #10361

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

Conversation

RCSN
Copy link
Contributor

@RCSN RCSN commented Jun 4, 2025

  • add the alarm using local time for calculation

为什么提交这份PR (why to submit this PR)

rtc的alarm驱动不支持带时区(local time)的时间比较闹钟事件触发

你的解决方案是什么 (what is your solution)

在kconfig中加入使用本地时间的alarm的配置,RT_ALARM_USING_LOCAL_TIME,默认不使能,也就是默认还是UTC时区闹钟。

另外rt_alarm_dump命令加入支持timezone显示,这样比较直观些。

4e0eab221709821b29904b1713693013

44c4631cb1eaac063f82fd8aaf94f34d

- add the alarm using local time for calculation

Signed-off-by: Runcheng Lu <runcheng.lu@hpmicro.com>
@RCSN RCSN force-pushed the feature/add_support_local_time_for_alarm_calc branch from f84ba70 to 9c44652 Compare June 4, 2025 06:26
@Rbb666 Rbb666 self-requested a review June 4, 2025 06:27
@hydevcode
Copy link
Contributor

Hi,作者您好。我在使用 STM32F407-RT-Spark 验证当前 PR 时,遇到了一个关于闹钟中断的问题。

我按照文档中的 Demo 进行了测试,并将设置闹钟时间的函数修改为了 localtime_r。运行发现无法触发闹钟中断。

检查后发现,当 RT_LIBC_TZ_DEFAULT_HOUR 默认设置为 8 (即 UTC+8) 时,闹钟中断无法触发。但当将其设置为 0 (即 UTC+0) 时,闹钟中断就能正常触发。看起来目前闹钟功能似乎只能在 UTC+0 时区下正常工作。

您那边能帮忙看看这个问题吗

@RCSN
Copy link
Contributor Author

RCSN commented Jun 5, 2025

Hi,感谢测试,不过我是基于先楫BSP来的。默认alarm确实是UTC+0,你在master上应该也是这样的现象。RT_LIBC_TZ_DEFAULT_HOUR你并不需要改动,只需要使能下alarm驱动的RT_ALARM_USING_LOCAL_TIME,本Pr的alarm内部就会以local_time作为时间判断,应该就可以了。另外建议你测试的bsp,drv_rtc那里的闹钟设置和获取也可以进行判断下,比如:
image
image

…t stamp

-  include the year, month, and day for rtc_alarm_time_set API
- add local time conversion for get timeval and set stamp

Signed-off-by: Runcheng Lu <runcheng.lu@hpmicro.com>
@RCSN RCSN force-pushed the feature/add_support_local_time_for_alarm_calc branch from 95aa5c5 to 8eaf252 Compare June 5, 2025 08:36
@github-actions github-actions bot added BSP: STM32 BSP related with ST/STM32 BSP labels Jun 5, 2025
@Rbb666 Rbb666 merged commit 7568ec9 into RT-Thread:master Jun 9, 2025
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.