rtc_driver.h File Reference
#include <stddef.h>
#include "status.h"
#include "interrupt_manager.h"

Go to the source code of this file.

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