The S32 SDK provides the Peripheral Driver for the Real Time Clock (RTC) module of S32 SDK devices.
The Real Time Clock Module is a independent timer that keeps track of the exact date and time with no software overhead, with low power usage.
Features of the RTC module include:
In order to be able to use the RTC in your application, the first thing to do is initializing it with the desired configuration. This is done by calling the RTC_DRV_Init function. One of the arguments passed to this function is the configuration which will be used for the RTC instance, specified by the rtc_init_config_t structure.
The rtc_init_config_t structure allows you to configure the following:
The rtc_seconds_int_config_t structure configures the time seconds interrupt. To setup an interrupt every seconds you have to configure the structure mentioned with the following parameters:
An alarm is configured with rtc_alarm_config_t structure, which is described by the following parameters:
After the RTC_DRV_Init() function call and, if needed, alarm and other configurations the RTC counter is started by calling RTC_DRV_StartCounter.
To update desired time date use RTC_DRV_SetTimeDate() function, this method use a Time and Date structure rtc_timedate_t in a calendar format mode.
To get the current time and date you can call RTC_DRV_GetCurrentTimeDate() function, this method will get the seconds from the Time Seconds Register and will convert into human readable format as rtc_timedate_t.
To check if a structure rtc_timedate_t is properly configured use RTC_DRV_IsTimeDateCorrectFormat() function that will return true if configuration is valid or false if configuration is invalid.
To set an alarm at a desired date and time use RTC_DRV_ConfigureAlarm() function, this method will use a structure rtc_alarm_config_t with Time, Date and Alarm Handler and will trigger at set time an interrupt set by user.
To get the configured alarm use RTC_DRV_GetAlarmConfig() function, this method will return the Time and Date for alarm in a structure rtc_alarm_config_t.
To check if an alarm is pending use RTC_DRV_IsAlarmPending() function, this method will return true if alarm is pending or false if no alarm pending.
To configure a seconds interrupt use RTC_DRV_ConfigureSecondsInt() function, this method use structure rtc_seconds_int_config_t to be configured with a callback function.
After driver configuration the user can use RTC_DRV_StartCounter() function to start the timer and RTC_DRV_StopCounter() function to stop it.
To lock access to RTC registers use RTC_DRV_ConfigureRegisterLock() function, this method use a structure rtc_register_lock_config_t that describe what registers will be lock. Attention all the registers are unlocked only by software reset or power on reset.
To check if RTC registers are locked use RTC_DRV_GetRegisterLock() function, this will return a structure rtc_register_lock_config_t with registers locked.
To convert seconds to a human readable value use RTC_DRV_ConvertSecondsToTimeDate() function, this will return a structure rtc_timedate_t based on the seconds value.
To convert a time date to seconds use RTC_DRV_ConvertTimeDateToSeconds() function, this will return seconds value based on time date structure rtc_timedate_t.
To get the time date for next alarm use RTC_DRV_GetNextAlarmTime() function, this will return a structure rtc_timedate_t.
To configure a fault handler for cases as Overflow and Invalid Time use RTC_DRV_ConfigureFaultInt() function, this method will use a structure rtc_interrupt_config_t with a callback function.
Modules | |
Real Time Clock Driver | |
Real Time Clock Driver Peripheral Driver. | |