Real Time Clock Driver Peripheral Driver.
Data Structures | |
struct | rtc_timedate_t |
RTC Time Date structure Implements : rtc_timedate_t_Class. More... | |
struct | rtc_init_config_t |
RTC Initialization structure Implements : rtc_init_config_t_Class. More... | |
struct | rtc_alarm_config_t |
RTC alarm configuration Implements : rtc_alarm_config_t_Class. More... | |
struct | rtc_interrupt_config_t |
RTC interrupt configuration. It is used to configure interrupt other than Time Alarm and Time Seconds interrupt Implements : rtc_interrupt_config_t_Class. More... | |
struct | rtc_seconds_int_config_t |
RTC Seconds Interrupt Configuration Implements : rtc_seconds_int_config_t_Class. More... | |
struct | rtc_register_lock_config_t |
RTC Register Lock Configuration Implements : rtc_register_lock_config_t_Class. More... | |
Macros | |
#define | SECONDS_IN_A_DAY (86400UL) |
#define | SECONDS_IN_A_HOUR (3600U) |
#define | SECONDS_IN_A_MIN (60U) |
#define | MINS_IN_A_HOUR (60U) |
#define | HOURS_IN_A_DAY (24U) |
#define | DAYS_IN_A_YEAR (365U) |
#define | DAYS_IN_A_LEAP_YEAR (366U) |
#define | YEAR_RANGE_START (1970U) |
#define | YEAR_RANGE_END (2099U) |
Enumerations | |
enum | rtc_second_int_cfg_t { RTC_INT_1HZ = 0x00U, RTC_INT_2HZ = 0x01U, RTC_INT_4HZ = 0x02U, RTC_INT_8HZ = 0x03U, RTC_INT_16HZ = 0x04U, RTC_INT_32HZ = 0x05U, RTC_INT_64HZ = 0x06U, RTC_INT_128HZ = 0x07U } |
RTC Seconds interrupt configuration Implements : rtc_second_int_cfg_t_Class. More... | |
enum | rtc_clk_out_config_t { RTC_CLKOUT_DISABLED = 0x00U, RTC_CLKOUT_SRC_TSIC = 0x01U, RTC_CLKOUT_SRC_32KHZ = 0x02U } |
RTC CLKOUT pin configuration Implements : rtc_clk_out_config_t_Class. More... | |
enum | rtc_clk_select_t { RTC_CLK_SRC_OSC_32KHZ = 0x00U, RTC_CLK_SRC_LPO_1KHZ = 0x01U } |
RTC clock select Implements : rtc_clk_select_t_Class. More... | |
enum | rtc_lock_register_select_t { RTC_LOCK_REG_LOCK = 0x00U, RTC_STATUS_REG_LOCK = 0x01U, RTC_CTRL_REG_LOCK = 0x02U, RTC_TCL_REG_LOCK = 0x03U } |
RTC register lock Implements : rtc_lock_register_select_t_Class. More... | |
Functions | |
status_t | RTC_DRV_Init (uint32_t instance, const rtc_init_config_t *const rtcUserCfg) |
This function initializes the RTC instance with the settings provided by the user via the rtcUserCfg parameter. The user must ensure that clock is enabled for the RTC instance used. If the Control register is locked then this method returns STATUS_ERROR. In order to clear the CR Lock the user must perform a power-on reset. More... | |
status_t | RTC_DRV_Deinit (uint32_t instance) |
This function deinitializes the RTC instance. If the Control register is locked then this method returns STATUS_ERROR. More... | |
void | RTC_DRV_GetDefaultConfig (rtc_init_config_t *const config) |
This function will set the default configuration values into the structure passed as a parameter. More... | |
status_t | RTC_DRV_StartCounter (uint32_t instance) |
Start RTC instance counter. Before calling this function the user should use RTC_DRV_SetTimeDate to configure the start time. More... | |
status_t | RTC_DRV_StopCounter (uint32_t instance) |
Disable RTC instance counter. More... | |
status_t | RTC_DRV_GetCurrentTimeDate (uint32_t instance, rtc_timedate_t *const currentTime) |
Get current time and date from RTC instance. More... | |
status_t | RTC_DRV_SetTimeDate (uint32_t instance, const rtc_timedate_t *const time) |
Set time and date for RTC instance. The user must stop the counter before using this function. Otherwise it will return an error. More... | |
status_t | RTC_DRV_ConfigureRegisterLock (uint32_t instance, const rtc_register_lock_config_t *const lockConfig) |
This method configures register lock for the corresponding RTC instance. Remember that all the registers are unlocked only by software reset or power on reset. (Except for CR that is unlocked only by POR). More... | |
void | RTC_DRV_GetRegisterLock (uint32_t instance, rtc_register_lock_config_t *const lockConfig) |
Get which registers are locked for RTC instance. More... | |
status_t | RTC_DRV_ConfigureTimeCompensation (uint32_t instance, uint8_t compInterval, int8_t compensation) |
This method configures time compensation. Data is passed by the compInterval and compensation parameters. For more details regarding coefficient calculation see the Reference Manual. More... | |
void | RTC_DRV_GetTimeCompensation (uint32_t instance, uint8_t *compInterval, int8_t *compensation) |
This retrieves the time compensation coefficients and saves them on the variables referenced by the parameters. More... | |
void | RTC_DRV_ConfigureFaultInt (uint32_t instance, rtc_interrupt_config_t *const intConfig) |
This method configures fault interrupts such as: More... | |
void | RTC_DRV_ConfigureSecondsInt (uint32_t instance, rtc_seconds_int_config_t *const intConfig) |
This method configures the Time Seconds Interrupt with the configuration from the intConfig parameter. More... | |
status_t | RTC_DRV_ConfigureAlarm (uint32_t instance, rtc_alarm_config_t *const alarmConfig) |
This method configures the alarm with the configuration from the alarmConfig parameter. More... | |
void | RTC_DRV_GetAlarmConfig (uint32_t instance, rtc_alarm_config_t *alarmConfig) |
Get alarm configuration for RTC instance. More... | |
bool | RTC_DRV_IsAlarmPending (uint32_t instance) |
Check if alarm is pending. More... | |
void | RTC_DRV_ConvertSecondsToTimeDate (const uint32_t *seconds, rtc_timedate_t *const timeDate) |
Convert seconds to rtc_timedate_t structure. More... | |
void | RTC_DRV_ConvertTimeDateToSeconds (const rtc_timedate_t *const timeDate, uint32_t *const seconds) |
Convert seconds to rtc_timedate_t structure. More... | |
bool | RTC_DRV_IsYearLeap (uint16_t year) |
Check if the current year is leap. More... | |
bool | RTC_DRV_IsTimeDateCorrectFormat (const rtc_timedate_t *const timeDate) |
Check if the date time struct is configured properly. More... | |
status_t | RTC_DRV_GetNextAlarmTime (uint32_t instance, rtc_timedate_t *const alarmTime) |
Gets the next alarm time. More... | |
void | RTC_DRV_IRQHandler (uint32_t instance) |
This method is the API's Interrupt handler for generic and alarm IRQ. It will handle the alarm repetition and calls the user callbacks if they are not NULL. More... | |
void | RTC_DRV_SecondsIRQHandler (uint32_t instance) |
This method is the API's Interrupt handler for RTC Second interrupt. This ISR will call the user callback if defined. More... | |
#define DAYS_IN_A_LEAP_YEAR (366U) |
Definition at line 42 of file rtc_driver.h.
#define DAYS_IN_A_YEAR (365U) |
Definition at line 41 of file rtc_driver.h.
#define HOURS_IN_A_DAY (24U) |
Definition at line 40 of file rtc_driver.h.
#define MINS_IN_A_HOUR (60U) |
Definition at line 39 of file rtc_driver.h.
#define SECONDS_IN_A_DAY (86400UL) |
Definition at line 36 of file rtc_driver.h.
#define SECONDS_IN_A_HOUR (3600U) |
Definition at line 37 of file rtc_driver.h.
#define SECONDS_IN_A_MIN (60U) |
Definition at line 38 of file rtc_driver.h.
#define YEAR_RANGE_END (2099U) |
Definition at line 44 of file rtc_driver.h.
#define YEAR_RANGE_START (1970U) |
Definition at line 43 of file rtc_driver.h.
enum rtc_clk_out_config_t |
RTC CLKOUT pin configuration Implements : rtc_clk_out_config_t_Class.
Enumerator | |
---|---|
RTC_CLKOUT_DISABLED |
Clock out pin is disabled |
RTC_CLKOUT_SRC_TSIC |
Output on RTC_CLKOUT as configured on Time seconds interrupt |
RTC_CLKOUT_SRC_32KHZ |
Output on RTC_CLKOUT of the 32KHz clock |
Definition at line 66 of file rtc_driver.h.
enum rtc_clk_select_t |
RTC clock select Implements : rtc_clk_select_t_Class.
Enumerator | |
---|---|
RTC_CLK_SRC_OSC_32KHZ |
RTC Prescaler increments using 32 KHz crystal |
RTC_CLK_SRC_LPO_1KHZ |
RTC Prescaler increments using 1KHz LPO |
Definition at line 77 of file rtc_driver.h.
RTC register lock Implements : rtc_lock_register_select_t_Class.
Enumerator | |
---|---|
RTC_LOCK_REG_LOCK |
RTC Lock Register lock |
RTC_STATUS_REG_LOCK |
RTC Status Register lock |
RTC_CTRL_REG_LOCK |
RTC Control Register lock |
RTC_TCL_REG_LOCK |
RTC Time Compensation Reg lock |
Definition at line 87 of file rtc_driver.h.
enum rtc_second_int_cfg_t |
RTC Seconds interrupt configuration Implements : rtc_second_int_cfg_t_Class.
Definition at line 50 of file rtc_driver.h.
status_t RTC_DRV_ConfigureAlarm | ( | uint32_t | instance, |
rtc_alarm_config_t *const | alarmConfig | ||
) |
This method configures the alarm with the configuration from the alarmConfig parameter.
[in] | instance | The number of the RTC instance used |
[in] | alarmConfig | Pointer to the structure which holds the alarm configuration |
Definition at line 934 of file rtc_driver.c.
void RTC_DRV_ConfigureFaultInt | ( | uint32_t | instance, |
rtc_interrupt_config_t *const | intConfig | ||
) |
This method configures fault interrupts such as:
[in] | instance | The number of the RTC instance used |
[in] | intConfig | Pointer to the structure which holds the configuration |
Definition at line 877 of file rtc_driver.c.
status_t RTC_DRV_ConfigureRegisterLock | ( | uint32_t | instance, |
const rtc_register_lock_config_t *const | lockConfig | ||
) |
This method configures register lock for the corresponding RTC instance. Remember that all the registers are unlocked only by software reset or power on reset. (Except for CR that is unlocked only by POR).
[in] | instance | The number of the RTC instance used |
[in] | lockConfig | Pointer to the lock configuration structure |
Definition at line 427 of file rtc_driver.c.
void RTC_DRV_ConfigureSecondsInt | ( | uint32_t | instance, |
rtc_seconds_int_config_t *const | intConfig | ||
) |
This method configures the Time Seconds Interrupt with the configuration from the intConfig parameter.
[in] | instance | The number of the RTC instance used |
[in] | intConfig | Pointer to the structure which holds the configuration |
Definition at line 904 of file rtc_driver.c.
status_t RTC_DRV_ConfigureTimeCompensation | ( | uint32_t | instance, |
uint8_t | compInterval, | ||
int8_t | compensation | ||
) |
This method configures time compensation. Data is passed by the compInterval and compensation parameters. For more details regarding coefficient calculation see the Reference Manual.
[in] | instance | The number of the RTC instance used |
[in] | compInterval | Compensation interval |
[in] | compensation | Compensation value |
Definition at line 502 of file rtc_driver.c.
void RTC_DRV_ConvertSecondsToTimeDate | ( | const uint32_t * | seconds, |
rtc_timedate_t *const | timeDate | ||
) |
Convert seconds to rtc_timedate_t structure.
[in] | seconds | Pointer to the seconds |
[out] | timeDate | Pointer to the structure in which to store the result |
Definition at line 552 of file rtc_driver.c.
void RTC_DRV_ConvertTimeDateToSeconds | ( | const rtc_timedate_t *const | timeDate, |
uint32_t *const | seconds | ||
) |
Convert seconds to rtc_timedate_t structure.
[in] | timeDate | Pointer to the source struct |
[out] | seconds | Pointer to the variable in which to store the result |
Definition at line 646 of file rtc_driver.c.
status_t RTC_DRV_Deinit | ( | uint32_t | instance | ) |
This function deinitializes the RTC instance. If the Control register is locked then this method returns STATUS_ERROR.
[in] | instance | The number of the RTC instance used |
Definition at line 159 of file rtc_driver.c.
void RTC_DRV_GetAlarmConfig | ( | uint32_t | instance, |
rtc_alarm_config_t * | alarmConfig | ||
) |
Get alarm configuration for RTC instance.
[in] | instance | The number of the RTC instance used |
[out] | alarmConfig | Pointer to the structure in which to store the alarm configuration |
Definition at line 988 of file rtc_driver.c.
status_t RTC_DRV_GetCurrentTimeDate | ( | uint32_t | instance, |
rtc_timedate_t *const | currentTime | ||
) |
Get current time and date from RTC instance.
[in] | instance | The number of the RTC instance used |
[out] | currentTime | Pointer to the variable in which to store the result |
Definition at line 328 of file rtc_driver.c.
void RTC_DRV_GetDefaultConfig | ( | rtc_init_config_t *const | config | ) |
This function will set the default configuration values into the structure passed as a parameter.
[out] | config | Pointer to the structure in which the configuration will be saved. |
Definition at line 195 of file rtc_driver.c.
status_t RTC_DRV_GetNextAlarmTime | ( | uint32_t | instance, |
rtc_timedate_t *const | alarmTime | ||
) |
Gets the next alarm time.
[in] | instance | The number of the RTC instance used |
[out] | alarmTime | Pointer to the variable in which to store the data |
Definition at line 1020 of file rtc_driver.c.
void RTC_DRV_GetRegisterLock | ( | uint32_t | instance, |
rtc_register_lock_config_t *const | lockConfig | ||
) |
Get which registers are locked for RTC instance.
[in] | instance | The number of the RTC instance used |
[out] | lockConfig | Pointer to the lock configuration structure in which to save the data |
Definition at line 474 of file rtc_driver.c.
void RTC_DRV_GetTimeCompensation | ( | uint32_t | instance, |
uint8_t * | compInterval, | ||
int8_t * | compensation | ||
) |
This retrieves the time compensation coefficients and saves them on the variables referenced by the parameters.
[in] | instance | The number of the RTC instance used |
[out] | compInterval | Pointer to the variable in which to save the compensation interval |
[out] | compensation | Pointer to the variable in which to save the compensation value |
Definition at line 535 of file rtc_driver.c.
status_t RTC_DRV_Init | ( | uint32_t | instance, |
const rtc_init_config_t *const | rtcUserCfg | ||
) |
This function initializes the RTC instance with the settings provided by the user via the rtcUserCfg parameter. The user must ensure that clock is enabled for the RTC instance used. If the Control register is locked then this method returns STATUS_ERROR. In order to clear the CR Lock the user must perform a power-on reset.
[in] | instance | The number of the RTC instance used |
[in] | rtcUserCfg | Pointer to the user's configuration structure |
Definition at line 100 of file rtc_driver.c.
void RTC_DRV_IRQHandler | ( | uint32_t | instance | ) |
This method is the API's Interrupt handler for generic and alarm IRQ. It will handle the alarm repetition and calls the user callbacks if they are not NULL.
[in] | instance | RTC instance used |
Definition at line 774 of file rtc_driver.c.
bool RTC_DRV_IsAlarmPending | ( | uint32_t | instance | ) |
Check if alarm is pending.
[in] | instance | The number of the RTC instance used |
Definition at line 1003 of file rtc_driver.c.
bool RTC_DRV_IsTimeDateCorrectFormat | ( | const rtc_timedate_t *const | timeDate | ) |
Check if the date time struct is configured properly.
[in] | timeDate | Structure to check to check |
Definition at line 696 of file rtc_driver.c.
bool RTC_DRV_IsYearLeap | ( | uint16_t | year | ) |
Check if the current year is leap.
[in] | year | Year to check |
Definition at line 738 of file rtc_driver.c.
void RTC_DRV_SecondsIRQHandler | ( | uint32_t | instance | ) |
This method is the API's Interrupt handler for RTC Second interrupt. This ISR will call the user callback if defined.
[in] | instance | RTC instance used |
Definition at line 851 of file rtc_driver.c.
status_t RTC_DRV_SetTimeDate | ( | uint32_t | instance, |
const rtc_timedate_t *const | time | ||
) |
Set time and date for RTC instance. The user must stop the counter before using this function. Otherwise it will return an error.
[in] | instance | The number of the RTC instance used |
[in] | time | Pointer to the variable in which the time is stored |
Definition at line 383 of file rtc_driver.c.
status_t RTC_DRV_StartCounter | ( | uint32_t | instance | ) |
Start RTC instance counter. Before calling this function the user should use RTC_DRV_SetTimeDate to configure the start time.
[in] | instance | The number of the RTC instance used |
Definition at line 266 of file rtc_driver.c.
status_t RTC_DRV_StopCounter | ( | uint32_t | instance | ) |
Disable RTC instance counter.
[in] | instance | The number of the RTC instance used |
Definition at line 297 of file rtc_driver.c.