-
Notifications
You must be signed in to change notification settings - Fork 2k
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
periph_drivers: Proposal for a minimal RTC interface #1020
periph_drivers: Proposal for a minimal RTC interface #1020
Conversation
* @arg RTC_IRQ_PERIODIC | ||
* @param[in] callback The ISR to use for specified *irq_type*. | ||
*/ | ||
void rtc_install_isr(rtc_irq_t irq_type, void (*callback)(int)); |
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.
I'd like an explicit typedef void (rtc_alarm_callback_t *)(int irq_type);
better.
IMO all functions should return an error if the access was successful. |
/** | ||
* @brief Resets set alarms | ||
*/ | ||
void rtc_reset_alarm(void); |
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.
Use the plural in the name, too.
I seem to have some trouble to understand the specific usage of this interface. I would imagine and interface for the RTC maybe as this:
I am not quite sure that the IRQ masks and types are i) portable enough and ii) needed for a clean and easy interface?! |
@haukepetersen Well most platforms I checked provide alarm/time registers in their RTC module someone can write seconds minutes and hours to. So someone could say "alarm in 2 months" or "alarm in 87840 seconds". Using |
oh, actually the |
updated addressing @Kijewski's and @haukepetersen's comments |
@@ -0,0 +1,74 @@ | |||
/* | |||
* Copyright (C) 2013 Thomas Eichinger <[email protected]> |
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.
2014
ACK |
Now that i look at this again, I have some remarks which I didn't think of before:
|
I'd say use int instead of int8_t for the return values. |
I'm not sure registering an alarm callback on init makes sense. Edit: yes it does (these devices tend not to have several alarm registers, so that functionality would need to be implemented in a high-level driver anyway). |
Can RTC's be turned on and off at all? If so, I'm in favor of functions like @haukepetersen proposed. Edit: yes they can |
Other than that I'd rather like to see this merged asap, the current interface is not so great. |
-> ACK when types changed, anything else can come later. |
One last remark: it might make sense to explicitly specify the format expected in the Edit: aha, the old driver actually complied with the specification.. http://pubs.opengroup.org/onlinepubs/7908799/xsh/time.h.html |
updated addressing @LudwigOrtmann's comments and rebased |
* @brief Set an alarm for RTC to the specified value. | ||
* | ||
* The expects values in `tm` that comply to the Gregorian calendar | ||
* format and calculates those to the hardware's specific format. |
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.
* The values in `tm` are expected to conform to the `struct tm` specification.
* Compare: http://pubs.opengroup.org/onlinepubs/7908799/xsh/time.h.html
?
e085e35
to
9033f5d
Compare
0265643
to
43b9661
Compare
Updated addressing @haukepetersen's offline comments. |
Looking nice! ACK when squashed, merge at will |
5ce1f42
to
b904bc3
Compare
squashed and go |
periph_drivers: Introduce a minimal RTC interface
This is a proposal for a low-level RTC driver. (now for real)
It tries to follow the principles of @haukepetersen's low-level driver interfaces and is open for discussion.