gossamer 0.0.0
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
rtc.h File Reference

Real-Time Clock. More...

#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

union  rtc_date_time
 

Macros

#define RTC_REFERENCE_YEAR   (2020)
 

Typedefs

typedef enum rtc_alarm_match rtc_alarm_match
 
typedef void(* rtc_cb_t) (uint8_t source)
 

Enumerations

enum  rtc_alarm_match { ALARM_MATCH_DISABLED = 0 , ALARM_MATCH_SS , ALARM_MATCH_MMSS , ALARM_MATCH_HHMMSS }
 

Functions

void rtc_init (void)
 Initializes the RTC. More...
 
void rtc_enable (void)
 Enables the RTC.
 
bool rtc_is_enabled (void)
 Checks if the RTC is enabled. More...
 
void rtc_set_date_time (rtc_date_time date_time)
 Sets the date and time. More...
 
rtc_date_time rtc_get_date_time (void)
 Returns the date and time. More...
 
void rtc_enable_alarm_interrupt (rtc_date_time alarm_time, rtc_alarm_match mask)
 Enables the alarm interrupt. More...
 
void rtc_disable_alarm_interrupt (void)
 Disables the alarm callback.
 
void rtc_configure_callback (rtc_cb_t callback)
 Configures the RTC alarm callback. More...
 

Detailed Description

Real-Time Clock.

Function Documentation

◆ rtc_configure_callback()

void rtc_configure_callback ( rtc_cb_t  callback)

Configures the RTC alarm callback.

Parameters
callbackThe function to call when an RTC interrupt occurs.

◆ rtc_enable_alarm_interrupt()

void rtc_enable_alarm_interrupt ( rtc_date_time  alarm_time,
rtc_alarm_match  mask 
)

Enables the alarm interrupt.

Parameters
alarm_timeThe time that you wish to match. The date is currently ignored.
maskOne of the values in rtc_alarm_match indicating which values to check.

◆ rtc_get_date_time()

rtc_date_time rtc_get_date_time ( void  )

Returns the date and time.

Returns
A rtc_date_time 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()

void rtc_init ( void  )

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()

void rtc_set_date_time ( rtc_date_time  date_time)

Sets the date and time.

Parameters
date_timeThe 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.