See Quickstart guide for SAM RTC driver.
The RTC provides a full binary-coded decimal (BCD) clock that includes century (19/20), year (with leap years), month, date, day, hour, minute and second.
Macros | |
#define | BCD_FACTOR 10 |
#define | BCD_MASK 0xfu |
#define | BCD_SHIFT 4 |
#define | RTC_WP_KEY (0x525443) |
Functions | |
void | rtc_clear_date_alarm (Rtc *p_rtc) |
Clear the RTC date alarm setting. More... | |
void | rtc_clear_status (Rtc *p_rtc, uint32_t ul_clear) |
Set the RTC SCCR to clear status bits. More... | |
void | rtc_clear_time_alarm (Rtc *p_rtc) |
Clear the RTC time alarm setting. More... | |
void | rtc_disable_interrupt (Rtc *p_rtc, uint32_t ul_sources) |
Disable RTC interrupts. More... | |
void | rtc_enable_interrupt (Rtc *p_rtc, uint32_t ul_sources) |
Enable RTC interrupts. More... | |
void | rtc_get_date (Rtc *p_rtc, uint32_t *pul_year, uint32_t *pul_month, uint32_t *pul_day, uint32_t *pul_week) |
Get the RTC date value. More... | |
uint32_t | rtc_get_hour_mode (Rtc *p_rtc) |
Get the RTC hour mode. More... | |
uint32_t | rtc_get_interrupt_mask (Rtc *p_rtc) |
Read RTC interrupt mask. More... | |
uint32_t | rtc_get_status (Rtc *p_rtc) |
Get the RTC status. More... | |
void | rtc_get_time (Rtc *p_rtc, uint32_t *pul_hour, uint32_t *pul_minute, uint32_t *pul_second) |
Get the RTC time value. More... | |
uint32_t | rtc_get_valid_entry (Rtc *p_rtc) |
Get the RTC valid entry. More... | |
void | rtc_set_calendar_event (Rtc *p_rtc, uint32_t ul_selection) |
Set the RTC calendar event selection. More... | |
uint32_t | rtc_set_date (Rtc *p_rtc, uint32_t ul_year, uint32_t ul_month, uint32_t ul_day, uint32_t ul_week) |
Set the RTC date. More... | |
uint32_t | rtc_set_date_alarm (Rtc *p_rtc, uint32_t ul_month_flag, uint32_t ul_month, uint32_t ul_day_flag, uint32_t ul_day) |
Set the RTC alarm date value. More... | |
void | rtc_set_hour_mode (Rtc *p_rtc, uint32_t ul_mode) |
Set the RTC hour mode. More... | |
uint32_t | rtc_set_time (Rtc *p_rtc, uint32_t ul_hour, uint32_t ul_minute, uint32_t ul_second) |
Set the RTC time value. More... | |
uint32_t | rtc_set_time_alarm (Rtc *p_rtc, uint32_t ul_hour_flag, uint32_t ul_hour, uint32_t ul_minute_flag, uint32_t ul_minute, uint32_t ul_second_flag, uint32_t ul_second) |
Set the RTC alarm time value. More... | |
void | rtc_set_time_event (Rtc *p_rtc, uint32_t ul_selection) |
Set the RTC time event selection. More... | |
#define BCD_FACTOR 10 |
Referenced by rtc_get_date(), rtc_get_time(), rtc_set_date(), rtc_set_date_alarm(), rtc_set_time(), and rtc_set_time_alarm().
#define BCD_MASK 0xfu |
Referenced by rtc_get_date(), and rtc_get_time().
#define BCD_SHIFT 4 |
Referenced by rtc_get_date(), rtc_get_time(), rtc_set_date(), rtc_set_date_alarm(), rtc_set_time(), and rtc_set_time_alarm().
#define RTC_WP_KEY (0x525443) |
void rtc_clear_date_alarm | ( | Rtc * | p_rtc | ) |
Clear the RTC date alarm setting.
p_rtc | Pointer to an RTC instance. |
void rtc_clear_status | ( | Rtc * | p_rtc, |
uint32_t | ul_clear | ||
) |
Set the RTC SCCR to clear status bits.
p_rtc | Pointer to an RTC instance. |
ul_clear | Some flag bits which will be cleared. |
void rtc_clear_time_alarm | ( | Rtc * | p_rtc | ) |
Clear the RTC time alarm setting.
p_rtc | Pointer to an RTC instance. |
void rtc_disable_interrupt | ( | Rtc * | p_rtc, |
uint32_t | ul_sources | ||
) |
Disable RTC interrupts.
p_rtc | Pointer to an RTC instance. |
ul_sources | Interrupts to be disabled. |
void rtc_enable_interrupt | ( | Rtc * | p_rtc, |
uint32_t | ul_sources | ||
) |
Enable RTC interrupts.
p_rtc | Pointer to an RTC instance. |
ul_sources | Interrupts to be enabled. |
void rtc_get_date | ( | Rtc * | p_rtc, |
uint32_t * | pul_year, | ||
uint32_t * | pul_month, | ||
uint32_t * | pul_day, | ||
uint32_t * | pul_week | ||
) |
Get the RTC date value.
p_rtc | Pointer to an RTC instance. |
pul_year | Current year. |
pul_month | Current month. |
pul_day | Current day. |
pul_week | Current day in current week. |
References BCD_FACTOR, BCD_MASK, and BCD_SHIFT.
Referenced by get_fattime().
uint32_t rtc_get_hour_mode | ( | Rtc * | p_rtc | ) |
Get the RTC hour mode.
p_rtc | Pointer to an RTC instance. |
uint32_t rtc_get_interrupt_mask | ( | Rtc * | p_rtc | ) |
Read RTC interrupt mask.
p_rtc | Pointer to an RTC instance. |
uint32_t rtc_get_status | ( | Rtc * | p_rtc | ) |
Get the RTC status.
p_rtc | Pointer to an RTC instance. |
void rtc_get_time | ( | Rtc * | p_rtc, |
uint32_t * | pul_hour, | ||
uint32_t * | pul_minute, | ||
uint32_t * | pul_second | ||
) |
Get the RTC time value.
p_rtc | Pointer to an RTC instance. |
pul_hour | Current hour, 24-hour mode. |
pul_minute | Current minute. |
pul_second | Current second. |
References BCD_FACTOR, BCD_MASK, and BCD_SHIFT.
Referenced by get_fattime().
uint32_t rtc_get_valid_entry | ( | Rtc * | p_rtc | ) |
Get the RTC valid entry.
p_rtc | Pointer to an RTC instance. |
void rtc_set_calendar_event | ( | Rtc * | p_rtc, |
uint32_t | ul_selection | ||
) |
Set the RTC calendar event selection.
p_rtc | Pointer to an RTC instance. |
ul_selection | Calendar event selection to be enabled.. |
uint32_t rtc_set_date | ( | Rtc * | p_rtc, |
uint32_t | ul_year, | ||
uint32_t | ul_month, | ||
uint32_t | ul_day, | ||
uint32_t | ul_week | ||
) |
Set the RTC date.
p_rtc | Pointer to an RTC instance. |
ul_year | Current year. |
ul_month | Current month. |
ul_day | Current day. |
ul_week | Current day in current week. |
References BCD_FACTOR, and BCD_SHIFT.
uint32_t rtc_set_date_alarm | ( | Rtc * | p_rtc, |
uint32_t | ul_month_flag, | ||
uint32_t | ul_month, | ||
uint32_t | ul_day_flag, | ||
uint32_t | ul_day | ||
) |
Set the RTC alarm date value.
p_rtc | Pointer to an RTC instance. |
ul_month_flag | 1 for setting, 0 for not setting. |
ul_month | Alarm month value. |
ul_day_flag | 1 for setting, 0 for not setting. |
ul_day | Alarm day value. |
References BCD_FACTOR, and BCD_SHIFT.
void rtc_set_hour_mode | ( | Rtc * | p_rtc, |
uint32_t | ul_mode | ||
) |
Set the RTC hour mode.
p_rtc | Pointer to an RTC instance. |
ul_mode | 1 for 12-hour mode, 0 for 24-hour mode. |
Referenced by disk_initialize().
uint32_t rtc_set_time | ( | Rtc * | p_rtc, |
uint32_t | ul_hour, | ||
uint32_t | ul_minute, | ||
uint32_t | ul_second | ||
) |
Set the RTC time value.
p_rtc | Pointer to an RTC instance. |
ul_hour | Current hour, 24-hour mode. |
ul_minute | Current minute. |
ul_second | Current second. |
References BCD_FACTOR, and BCD_SHIFT.
uint32_t rtc_set_time_alarm | ( | Rtc * | p_rtc, |
uint32_t | ul_hour_flag, | ||
uint32_t | ul_hour, | ||
uint32_t | ul_minute_flag, | ||
uint32_t | ul_minute, | ||
uint32_t | ul_second_flag, | ||
uint32_t | ul_second | ||
) |
Set the RTC alarm time value.
p_rtc | Pointer to an RTC instance. |
ul_hour_flag | 1 for setting, 0 for not setting. |
ul_hour | Alarm hour value, 24-hour mode. |
ul_minute_flag | 1 for setting, 0 for not setting. |
ul_minute | Alarm minute value. |
ul_second_flag | 1 for setting, 0 for not setting. |
ul_second | Alarm second value. |
References BCD_FACTOR, and BCD_SHIFT.
void rtc_set_time_event | ( | Rtc * | p_rtc, |
uint32_t | ul_selection | ||
) |
Set the RTC time event selection.
p_rtc | Pointer to an RTC instance. |
ul_selection | Time event selection to be enabled. |