Functions for configuring and using the Real-Time Clock peripheral.
More...
|
#define | RTC_REFERENCE_YEAR (2020) |
|
|
typedef enum rtc_alarm_match_t | rtc_alarm_match_t |
|
typedef void(* | rtc_cb_t) (uint16_t intflag) |
|
|
enum | rtc_alarm_match_t { ALARM_MATCH_DISABLED = 0
, ALARM_MATCH_SS
, ALARM_MATCH_MMSS
, ALARM_MATCH_HHMMSS
} |
|
Functions for configuring and using the Real-Time Clock peripheral.
Gossamer supports use of the RTC peripheral in MODE2 (calendar) mode only.
◆ rtc_configure_callback()
void rtc_configure_callback |
( |
rtc_cb_t |
callback | ) |
|
Configures the RTC alarm callback.
- Parameters
-
callback | The function to call when an RTC interrupt occurs. The callback will be passed a bitmask of the interrupt flags, the full contents of the RTC peripheral's INTFLAG register. |
◆ rtc_enable_alarm_interrupt()
void rtc_enable_alarm_interrupt |
( |
rtc_date_time_t |
alarm_time, |
|
|
rtc_alarm_match_t |
mask |
|
) |
| |
Enables the alarm interrupt.
- Parameters
-
alarm_time | The time that you wish to match. The date is currently ignored. |
mask | One of the values in rtc_alarm_match_t indicating which values to check. |
◆ rtc_get_date_time()
Returns the date and time.
- Returns
- A rtc_date_time_t with the current date and time, with a year value from 0-63 representing 2020-2083.
- See also
- rtc_set_date_time for notes about how the year is stored.
◆ rtc_init()
Initializes the RTC.
Configures the RTC for 24-hour clock / calendar mode, with a 1 Hz tick derived from the 1024 Hz clock on GCLK3 (for SAM D devices) or OSC32KCTRL's most accurate 1024 Hz output (for SAM L devices).
◆ rtc_is_enabled()
bool rtc_is_enabled |
( |
void |
| ) |
|
Checks if the RTC is enabled.
- Returns
- true if the RTC is enabled; false if not.
◆ rtc_set_date_time()
Sets the date and time.
- Parameters
-
date_time | The date and time you wish to set, with a year value from 0-63 representing 2020-2083. |
- Note
- The RTC stores the year as six bits representing a value from 0 to 63. It treats this as a year offset from a reference year, which must be a leap year. Since 2020 was a leap year, and it allows useful dates through 2083, it is assumed that apps will use 2020 as the reference year; thus 1 means 2021, 2 means 2022, etc. You will be responsible for handling this offset in your code, if the calendar year is needed for timestamp calculation logic or display purposes.