-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
driver: rtc: RV3028 use INT without setting callback, no AIE reset during init #87131
Comments
Hi @visuphi! We appreciate you submitting your first issue for our open-source project. 🌟 Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙 |
Hi, thanks for bringing this up, definitely something we need to align :)
To mirror integrated RTCs, and keep consistent behavior, it seems reasonable to always enable the interrupt output, given the bus attached RTC has the int-gpios pin connected in the devicetree. Integrated RTCs set the interrupt pending bit, and keep it set, regardless of whether a callback is set, since the interrupt is masked. The same behavior can be achieved for bus attached RTCs by just not configuring the interrupt gpio callback unless the rtc callback is set.
Integrated RTCs keep their interrupt pending but masked if they caused a wakeup in most cases, in other cases, some "reset cause" register stores that the RTC interrupt caused the wakeup. If the int-gpios is configured, it should not be cleared on init , to produce the same behavior as integrated RTCs. This way, the driver can just check the GPIO state and clear it on For bus attached RTCs with no connected interrupt pin, don't clear the alarm set bit in the RTCs regs on init, let it be cleared by Note: The GPIO routed interrupt on bus attached RTCs usually can indicate more than just the alarm being triggered, it can also be triggered by periodic interrupts, like on each second, or if there are multiple alarms, any of them. So just checking that the pin is not 0 is not enough check the alarm status. registers still need to be fetched to check why the int pin was set. Suggested clarifications to RTC API header/docs:
WDYT? |
Is your enhancement proposal related to a problem? Please describe.
this diagram is from the RV3028 datasheet.
To use the INT pin for an alarm, one must set a callback with
rtc_alarm_set_callback
which sets the AIE bit to 1, and then set an alarm with
rtc_alarm_set_time
.Assuming that the RV3028 is running on backup-voltage and the MCU is off:
When an alarm occurs, the INT pin goes low, which e.g. powers on the MCU.
The MCU boots up, initializes the RV3028 and and performs the following step:
zephyr/drivers/rtc/rtc_rv3028.c
Lines 863 to 867 in 2e23dfd
During initialization, the AIE bit is reset to 0, disabling INT → INT goes high again.
The callback is executed, and then the AF flag is cleared.
To Reproduce
You'll need a setup where you can run RV3028 and a MCU independently.
rtc_set_time()
rtc_alarm_set_callback()
rtc_alarm_set_time()
, e.g. one minute laterDescribe the solution you'd like
In some cases, it is necessary to keep INT low until the AF flag is cleared manually (e.g. with
rtc_alarm_is_pending
.)This is not possible in the current implementation because, during RV3028 initialization, the AIE bit is set to 0, causing INT to go high.
Additionally, the AF flag is immediately cleared in the callback, which must be set if one wants to use INT.
Therefore, i propose the following:
rtc_alarm_set_time()
and still use INT without setting a callback. → The AIE flag should be set when an alarm is configured.Describe alternatives you've considered
Additional context
I would like to hear your opinion, depending on the effort I can also do a PR. :)
The text was updated successfully, but these errors were encountered: