See Quick start guide for RTC driver.
This is a driver implementation for the XMEGA RTC.
If current time is close to a time unit roll over, there is a risk to miss this when using a value of 0.
A safe use of this can be in an alarm callback.
Modules | |
Related Project(s) | |
In this section you can find all the projects related to the Real Time Counter (RTC). | |
Quick Start Guide(s) | |
In this section you can find a list of all Quick Start guides related to the Real Time Counter (RTC). | |
Macros | |
#define | CONFIG_RTC_COMPARE_INT_LEVEL |
Configuration symbol for interrupt level to use on alarm. More... | |
#define | CONFIG_RTC_OVERFLOW_INT_LEVEL |
Configuration symbol for interrupt level to use on overflow. More... | |
#define | CONFIG_RTC_PRESCALER |
Configuration symbol for prescaler to use. More... | |
Typedefs | |
typedef void(* | rtc_callback_t )(uint32_t time) |
Callback definition for alarm callback. More... | |
Functions | |
bool | rtc_alarm_has_triggered (void) |
Check if pending alarm have triggered. More... | |
uint32_t | rtc_get_time (void) |
Get current time. More... | |
void | rtc_init (void) |
Initialize the RTC. More... | |
void | rtc_set_alarm (uint32_t time) |
Set alarm time. More... | |
static void | rtc_set_alarm_relative (uint32_t offset) |
Set alarm relative to current time. More... | |
void | rtc_set_callback (rtc_callback_t callback) |
Set callback to call on alarm. More... | |
void | rtc_set_time (uint32_t time) |
Set current time. More... | |
#define CONFIG_RTC_COMPARE_INT_LEVEL |
Configuration symbol for interrupt level to use on alarm.
Possible values:
#define CONFIG_RTC_OVERFLOW_INT_LEVEL |
Configuration symbol for interrupt level to use on overflow.
Possible values:
#define CONFIG_RTC_PRESCALER |
Configuration symbol for prescaler to use.
Possible values:
Referenced by rtc_init(), and rtc_set_time().
typedef void(* rtc_callback_t)(uint32_t time) |
Callback definition for alarm callback.
time | The time of the alarm |
bool rtc_alarm_has_triggered | ( | void | ) |
Check if pending alarm have triggered.
true | Alarm have triggered |
false | Alarm is pending |
Check if pending alarm have triggered.
true | Alarm has triggered |
false | Alarm is pending |
uint32_t rtc_get_time | ( | void | ) |
Get current time.
void rtc_init | ( | void | ) |
Initialize the RTC.
Start up the RTC and start counting from 0
Initialize the RTC.
Starts up the 32kHz oscillator in the backup system and initializes the RTC32.
void rtc_set_alarm | ( | uint32_t | time | ) |
Set alarm time.
Will set absolute alarm time that will call the callback specified by rtc_set_callback on completion. Or possibly use rtc_alarm_has_triggered to check for it.
Any pending alarm will be overwritten with this function.
time | Absolute time value. See also Minimum allowed alarm time |
Will set absolute time of the alarm that will call the callback function specified by rtc_set_callback on expiration. Alternatively, you may use rtc_alarm_has_triggered to check if the alarm has expired.
Any pending alarm will be overwritten with this function.
time | Absolute time value. See also Minimum allowed alarm time |
|
inlinestatic |
Set alarm relative to current time.
offset | Offset to current time. This is minimum value, so the alarm might happen at up to one time unit later. See also Minimum allowed alarm time |
References rtc_get_time(), and rtc_set_alarm().
Referenced by classb_rtc_callback(), main(), and oven_classb_init_tests().
void rtc_set_callback | ( | rtc_callback_t | callback | ) |
Set callback to call on alarm.
callback | Callback function pointer |
void rtc_set_time | ( | uint32_t | time | ) |
Set current time.
time | Time value to set |