Microchip® Advanced Software Framework

rtc_calendar.h File Reference

SAM RTC Driver (Calendar Mode)

Copyright (c) 2012-2020 Microchip Technology Inc. and its subsidiaries.

#include <conf_clocks.h>
#include <system_interrupt.h>

Data Structures

struct  rtc_calendar_alarm_time
 Alarm structure. More...
 
struct  rtc_calendar_config
 RTC configuration structure. More...
 
struct  rtc_calendar_events
 RTC Calendar event enable/disable structure. More...
 
struct  rtc_calendar_time
 Time structure. More...
 

Macros

#define FEATURE_RTC_CONTINUOUSLY_UPDATED
 Define port features set according to different device family. More...
 

Enumerations

enum  rtc_calendar_alarm {
  RTC_CALENDAR_ALARM_0 = 0,
  RTC_CALENDAR_ALARM_1 = 1,
  RTC_CALENDAR_ALARM_2 = 2,
  RTC_CALENDAR_ALARM_3 = 3
}
 Available alarm channels. More...
 
enum  rtc_calendar_alarm_mask {
  RTC_CALENDAR_ALARM_MASK_DISABLED = RTC_MODE2_MASK_SEL_OFF,
  RTC_CALENDAR_ALARM_MASK_SEC = RTC_MODE2_MASK_SEL_SS,
  RTC_CALENDAR_ALARM_MASK_MIN = RTC_MODE2_MASK_SEL_MMSS,
  RTC_CALENDAR_ALARM_MASK_HOUR = RTC_MODE2_MASK_SEL_HHMMSS,
  RTC_CALENDAR_ALARM_MASK_DAY = RTC_MODE2_MASK_SEL_DDHHMMSS,
  RTC_CALENDAR_ALARM_MASK_MONTH = RTC_MODE2_MASK_SEL_MMDDHHMMSS,
  RTC_CALENDAR_ALARM_MASK_YEAR = RTC_MODE2_MASK_SEL_YYMMDDHHMMSS
}
 Available mask options for alarms. More...
 
enum  rtc_calendar_callback {
  RTC_CALENDAR_CALLBACK_ALARM_0 = 0,
  RTC_CALENDAR_CALLBACK_ALARM_1,
  RTC_CALENDAR_CALLBACK_ALARM_2,
  RTC_CALENDAR_CALLBACK_ALARM_3,
  RTC_CALENDAR_CALLBACK_OVERFLOW
}
 Callback types. More...
 
enum  rtc_calendar_prescaler {
  RTC_CALENDAR_PRESCALER_DIV_1 = RTC_MODE2_CTRL_PRESCALER_DIV1,
  RTC_CALENDAR_PRESCALER_DIV_2 = RTC_MODE2_CTRL_PRESCALER_DIV2,
  RTC_CALENDAR_PRESCALER_DIV_4 = RTC_MODE2_CTRL_PRESCALER_DIV4,
  RTC_CALENDAR_PRESCALER_DIV_8 = RTC_MODE2_CTRL_PRESCALER_DIV8,
  RTC_CALENDAR_PRESCALER_DIV_16 = RTC_MODE2_CTRL_PRESCALER_DIV16,
  RTC_CALENDAR_PRESCALER_DIV_32 = RTC_MODE2_CTRL_PRESCALER_DIV32,
  RTC_CALENDAR_PRESCALER_DIV_64 = RTC_MODE2_CTRL_PRESCALER_DIV64,
  RTC_CALENDAR_PRESCALER_DIV_128 = RTC_MODE2_CTRL_PRESCALER_DIV128,
  RTC_CALENDAR_PRESCALER_DIV_256 = RTC_MODE2_CTRL_PRESCALER_DIV256,
  RTC_CALENDAR_PRESCALER_DIV_512 = RTC_MODE2_CTRL_PRESCALER_DIV512,
  RTC_CALENDAR_PRESCALER_DIV_1024 = RTC_MODE2_CTRL_PRESCALER_DIV1024
}
 RTC input clock prescaler settings. More...
 

Functions

Configuration and Initialization
static void rtc_calendar_get_time_defaults (struct rtc_calendar_time *const time)
 Initialize a time structure. More...
 
static void rtc_calendar_get_config_defaults (struct rtc_calendar_config *const config)
 Gets the RTC default settings. More...
 
void rtc_calendar_reset (struct rtc_module *const module)
 Resets the RTC module. More...
 
void rtc_calendar_enable (struct rtc_module *const module)
 Enables the RTC module. More...
 
void rtc_calendar_disable (struct rtc_module *const module)
 Disables the RTC module. More...
 
void rtc_calendar_init (struct rtc_module *const module, Rtc *const hw, const struct rtc_calendar_config *const config)
 Initializes the RTC module with given configurations. More...
 
void rtc_calendar_swap_time_mode (struct rtc_module *const module)
 Swaps between 12h and 24h clock mode. More...
 
enum status_code rtc_calendar_frequency_correction (struct rtc_module *const module, const int8_t value)
 Calibrate for too-slow or too-fast oscillator. More...
 
Time and Alarm Management
uint32_t rtc_calendar_time_to_register_value (struct rtc_module *const module, const struct rtc_calendar_time *const time)
 Convert time structure to register_value. More...
 
void rtc_calendar_register_value_to_time (struct rtc_module *const module, const uint32_t register_value, struct rtc_calendar_time *const time)
 Convert register_value to time structure. More...
 
void rtc_calendar_set_time (struct rtc_module *const module, const struct rtc_calendar_time *const time)
 Set the current calendar time to desired time. More...
 
void rtc_calendar_get_time (struct rtc_module *const module, struct rtc_calendar_time *const time)
 Get the current calendar value. More...
 
enum status_code rtc_calendar_set_alarm (struct rtc_module *const module, const struct rtc_calendar_alarm_time *const alarm, const enum rtc_calendar_alarm alarm_index)
 Set the alarm time for the specified alarm. More...
 
enum status_code rtc_calendar_get_alarm (struct rtc_module *const module, struct rtc_calendar_alarm_time *const alarm, const enum rtc_calendar_alarm alarm_index)
 Get the current alarm time of specified alarm. More...
 
Status Flag Management
static bool rtc_calendar_is_overflow (struct rtc_module *const module)
 Check if an RTC overflow has occurred. More...
 
static void rtc_calendar_clear_overflow (struct rtc_module *const module)
 Clears the RTC overflow flag. More...
 
static bool rtc_calendar_is_alarm_match (struct rtc_module *const module, const enum rtc_calendar_alarm alarm_index)
 Check the RTC alarm flag. More...
 
static enum status_code rtc_calendar_clear_alarm_match (struct rtc_module *const module, const enum rtc_calendar_alarm alarm_index)
 Clears the RTC alarm match flag. More...
 
Event Management
static void rtc_calendar_enable_events (struct rtc_module *const module, struct rtc_calendar_events *const events)
 Enables an RTC event output. More...
 
static void rtc_calendar_disable_events (struct rtc_module *const module, struct rtc_calendar_events *const events)
 Disables an RTC event output. More...