S32 SDK
rtc_driver.c File Reference
#include "rtc_hw_access.h"

Go to the source code of this file.

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...
 
static bool RTC_DRV_CanWriteTCE (uint32_t instance)
 
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_ConvertSecondsToTimeDate (const uint32_t *const 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_IsTimeDateCorrectFormat (const rtc_timedate_t *const timeDate)
 Check if the date time struct is configured properly. More...
 
bool RTC_DRV_IsYearLeap (uint16_t year)
 Check if the current year is leap. 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...
 
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...
 
status_t RTC_DRV_GetNextAlarmTime (uint32_t instance, rtc_timedate_t *const alarmTime)
 Gets the next alarm time. More...
 

Variables

static RTC_Type *const g_rtcBase [RTC_INSTANCE_COUNT] = RTC_BASE_PTRS
 
const IRQn_Type g_rtcIrqNumbers [RTC_IRQS_CH_COUNT]
 Table used to store the RTC IRQ names. More...
 
const IRQn_Type g_rtcSecondsIrqNb [RTC_SECONDS_IRQS_CH_COUNT]
 
static const uint8_t ULY [] = {0U, 31U, 28U, 31U, 30U, 31U, 30U, 31U, 31U, 30U, 31U, 30U, 31U}
 
static const uint8_t LY [] = {0U, 31U, 29U, 31U, 30U, 31U, 30U, 31U, 31U, 30U, 31U, 30U, 31U}
 
static const uint16_t MONTH_DAYS [] = {0U, 0U, 31U, 59U, 90U, 120U, 151U, 181U, 212U, 243U, 273U, 304U, 334U}
 
struct {
   rtc_alarm_config_t *   alarmConfig
 
   bool   isAlarmTimeNew
 
   rtc_interrupt_config_t *   intConfig
 
   rtc_seconds_int_config_t *   secondsIntConfig
 
g_rtcRuntimeConfig [RTC_INSTANCE_COUNT]
 static RTC runtime structure, it is designed only for internal purposes such as storing interrupt configuration for each instance. More...
 

Function Documentation

static bool RTC_DRV_CanWriteTCE ( uint32_t  instance)
static

Definition at line 221 of file rtc_driver.c.

Variable Documentation

rtc_alarm_config_t* alarmConfig

Alarm configuration

Definition at line 76 of file rtc_driver.c.

RTC_Type* const g_rtcBase[RTC_INSTANCE_COUNT] = RTC_BASE_PTRS
static

< Table of RTC base pointers Table of RTC IRQ Numbers

Definition at line 54 of file rtc_driver.c.

const IRQn_Type g_rtcIrqNumbers[RTC_IRQS_CH_COUNT]

Table used to store the RTC IRQ names.

Table of RTC Second IRQ Numbers

<Table used to store the RTC Seconds IRQ names

Definition at line 35 of file rtc_irq.c.

struct { ... } g_rtcRuntimeConfig[RTC_INSTANCE_COUNT]

static RTC runtime structure, it is designed only for internal purposes such as storing interrupt configuration for each instance.

const IRQn_Type g_rtcSecondsIrqNb[RTC_SECONDS_IRQS_CH_COUNT]

Definition at line 37 of file rtc_irq.c.

Interrupt configuration

Definition at line 78 of file rtc_driver.c.

bool isAlarmTimeNew

Check if there is a new alarm

Definition at line 77 of file rtc_driver.c.

const uint8_t LY[] = {0U, 31U, 29U, 31U, 30U, 31U, 30U, 31U, 31U, 30U, 31U, 30U, 31U}
static

Definition at line 65 of file rtc_driver.c.

const uint16_t MONTH_DAYS[] = {0U, 0U, 31U, 59U, 90U, 120U, 151U, 181U, 212U, 243U, 273U, 304U, 334U}
static

Definition at line 68 of file rtc_driver.c.

rtc_seconds_int_config_t* secondsIntConfig

Time seconds interrupt configuration

Definition at line 79 of file rtc_driver.c.

const uint8_t ULY[] = {0U, 31U, 28U, 31U, 30U, 31U, 30U, 31U, 31U, 30U, 31U, 30U, 31U}
static

Definition at line 62 of file rtc_driver.c.