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 has triggered. More... | |
uint32_t | rtc_get_time (void) |
Get current time. More... | |
void | rtc_init (void) |
Initialize the 32kHz oscillator and RTC32. 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 has triggered.
true | Alarm has triggered |
false | Alarm is pending |
Check if pending alarm has triggered.
true | Alarm have triggered |
false | Alarm is pending |
References RTC32, and RTC32_COMPARE_INT_LEVEL.
uint32_t rtc_get_time | ( | void | ) |
Get current time.
References rtc_data_struct::counter_high, cpu_irq_restore(), cpu_irq_save(), rtc_data, rtc_get_counter(), and rtc_is_busy().
Referenced by get_fattime(), ISR(), and rtc_set_alarm_relative().
void rtc_init | ( | void | ) |
Initialize the 32kHz oscillator and RTC32.
Starts up the 32kHz oscillator in the backup system and initializes the RTC32.
Initialize the 32kHz oscillator and RTC32.
Start up the RTC and start counting from 0
References CONFIG_RTC_PRESCALER, RTC32, rtc_is_busy(), RTC_OVERFLOW_INT_LEVEL, sleepmgr_lock_mode(), SLEEPMGR_PSAVE, sysclk_enable_module(), SYSCLK_PORT_GEN, SYSCLK_RTC, and vbat_init().
Referenced by main(), and timeout_init().
void rtc_set_alarm | ( | uint32_t | time | ) |
Set 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 |
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 |
References rtc_data_struct::alarm_high, rtc_data_struct::alarm_low, RTC32, RTC32_COMPARE_INT_LEVEL, RTC_COMPARE_INT_LEVEL, rtc_data, rtc_is_busy(), and RTC_OVERFLOW_INT_LEVEL.
Referenced by alarm(), rtc_set_alarm_relative(), tick_handler(), and timeout_init().
|
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().
void rtc_set_callback | ( | rtc_callback_t | callback | ) |
Set callback to call on alarm.
callback | Callback function pointer |
References rtc_data_struct::callback, and rtc_data.
Referenced by main(), and timeout_init().
void rtc_set_time | ( | uint32_t | time | ) |
Set current time.
time | Time value to set |
References CONFIG_RTC_PRESCALER, rtc_data_struct::counter_high, RTC32, rtc_data, and rtc_is_busy().
Referenced by tick_handler(), and timeout_init().