![]() |
Kinetis SDK v.1.2 API Reference Manual
Rev. 0
Freescale Semiconductor, Inc.
|
This section describes the programming interface of the RTC HAL driver. The RTC HAL driver initializes the RTC registers and provides functions to read or modify the RTC registers. These are mostly invoked by the RTC Peripheral driver.
The HAL driver provides the enable (RTC_HAL_Enable()) and disable (RTC_HAL_Disable()) functions to enable or disable the RTC oscillator or the 32 KHz clock from the system oscillator if the platform does not have an RTC oscillator. It also provides an initialization function (RTC_HAL_Init()) to reset the RTC module.
The HAL driver provides RTC_HAL_SetDatetime() and RTC_HAL_GetDatetime() functions to set and read the date and time using an instantiation of the rtc_datetime_t structure. These are the structure details:
The HAL driver also provides the ability to set and read the date and time in seconds using the RTC_HAL_SetDatetimeInsecs() and RTC_HAL_GetDatetimeInsecs() functions.
NOTE: If the RTC counter clock is not 32 KHz, the RTC_HAL_SetDatetime() and RTC_HAL_GetDatetime() functions do not provide accurate results. On such boards, use the RTC_HAL_SetDatetimeInsecs() and RTC_HAL_GetDatetimeInsecs() functions and adjust the second calculation taking into account the clock source difference. The RTC peripheral driver adjusts its seconds calculation if the clock feeding RTC counter clock is not 32 KHz. Use the peripheral driver instead of calling the HAL functions directly.
The HAL driver provides RTC_HAL_SetAlarm() and RTC_HAL_GetAlarm() functions to set an alarm and read back the alarm time.
Data Structures | |
struct | irtc_datetime_t |
Structure is used to hold the time in a simple "date" format. More... | |
struct | irtc_daylight_time_t |
Structure is used to hold the daylight saving time. More... | |
struct | rtc_datetime_t |
Structure is used to hold the time in a simple "date" format. More... | |
Macros | |
#define | IRTC_BASE_YEAR (2112U) |
#define | RTC_WRITE_ENABLE(base, value) (*(__IO uint8_t*)(&RTC_STATUS_REG(base)) = (value)) |
Enumerations | |
enum | irtc_clock_output_t { kIRTCNoOutputClk = 0x0, kIRTCFine1hzClk = 0x1, kIRTC32khzClk = 0x2, kIRTCCoarse1hzClck = 0x3 } |
IRTC clock output selection. More... | |
enum | irtc_alarm_match_t { kIRTCSecMinHour = 0x0, kIRTCSecMinHourDay = 0x1, kIRTCSecMinHourDayMon = 0x2, kIRTCSecMinHourDayMonYear = 0x3 } |
IRTC alarm match selection. More... | |
enum | irtc_status_flag_t { kIRTCInvalidate = RTC_STATUS_INVAL_BIT_SHIFT, kIRTCReadOnly = RTC_STATUS_WRITE_PROT_EN_SHIFT, kIRTCLowVoltage = RTC_STATUS_CPU_LOW_VOLT_SHIFT, kIRTCResetSrc = RTC_STATUS_RST_SRC_SHIFT, kIRTCCmpInterval = RTC_STATUS_CMP_INT_SHIFT, kIRTCBusErr = RTC_STATUS_BUS_ERR_SHIFT, kIRTCCmpDone = RTC_STATUS_CMP_DONE_SHIFT } |
IRTC status flags. More... | |
enum | irtc_int_status_flag_t { kIRTCTamperIntFlag = RTC_ISR_TAMPER_IS_SHIFT, kIRTCAlarmIntFlag = RTC_ISR_ALM_IS_SHIFT, kIRTCDayIntFlag = RTC_ISR_DAY_IS_SHIFT, kIRTCHourIntFlag = RTC_ISR_HOUR_IS_SHIFT, kIRTCMinIntFlag = RTC_ISR_MIN_IS_SHIFT, kIRTC1hzIntFlag = RTC_ISR_IS_1HZ_SHIFT, kIRTC2hzIntFlag = RTC_ISR_IS_2HZ_SHIFT, kIRTC4hzIntFlag = RTC_ISR_IS_4HZ_SHIFT, kIRTC8hzIntFlag = RTC_ISR_IS_8HZ_SHIFT, kIRTC16hzIntFlag = RTC_ISR_IS_16HZ_SHIFT, kIRTC32hzIntFlag = RTC_ISR_IS_32HZ_SHIFT, kIRTC64hzIntFlag = RTC_ISR_IS_64HZ_SHIFT, kIRTC128hzIntFlag = RTC_ISR_IS_128HZ_SHIFT, kIRTC256hzIntFlag = RTC_ISR_IS_256HZ_SHIFT, kIRTC512hzIntFlag = RTC_ISR_IS_512HZ_SHIFT } |
IRTC interrupt status flags. More... | |
enum | irtc_int_t { kIRTCTamperInt = RTC_IER_TAMPER_IE_SHIFT, kIRTCAlarmInt = RTC_IER_ALM_IE_SHIFT, kIRTCDayInt = RTC_IER_DAY_IE_SHIFT, kIRTCHourInt = RTC_IER_HOUR_IE_SHIFT, kIRTCMinInt = RTC_IER_MIN_IE_SHIFT, kIRTC1hzInt = RTC_IER_IE_1HZ_SHIFT, kIRTC2hzInt = RTC_IER_IE_2HZ_SHIFT, kIRTC4hzInt = RTC_IER_IE_4HZ_SHIFT, kIRTC8hzInt = RTC_IER_IE_8HZ_SHIFT, kIRTC16hzInt = RTC_IER_IE_16HZ_SHIFT, kIRTC32hzInt = RTC_IER_IE_32HZ_SHIFT, kIRTC64hzInt = RTC_IER_IE_64HZ_SHIFT, kIRTC128hzInt = RTC_IER_IE_128HZ_SHIFT, kIRTC256hzInt = RTC_IER_IE_256HZ_SHIFT, kIRTC512hzInt = RTC_IER_IE_512HZ_SHIFT } |
IRTC interrupts. More... | |
enum | rtc_status_t { kStatusRtcSuccess = 0x00U, kStatusRtcFail = 0x01U } |
Error codes for RTC driver. More... | |
Initialization | |
void | IRTC_HAL_Init (RTC_Type *base, const irtc_datetime_t *datetime, const irtc_datetime_t *alarmDatetime, irtc_alarm_match_t alarmMode, const irtc_daylight_time_t *daylightTime) |
Resets the IRTC module. More... | |
void | IRTC_HAL_SetLockRegisterCmd (RTC_Type *base, bool lock) |
Lock or unlock IRTC registers for write access. More... | |
Date and Time Setting | |
| |
void | IRTC_HAL_SetYearMonth (RTC_Type *base, uint16_t year, uint16_t month) |
Sets the IRTC year and month. More... | |
void | IRTC_HAL_GetYearMonth (RTC_Type *base, uint16_t *year, uint16_t *month) |
Gets the IRTC current year and month. More... | |
static void | IRTC_HAL_SetDayWeek (RTC_Type *base, uint16_t day, uint16_t weekDay) |
Sets the IRTC day and day of week. More... | |
void | IRTC_HAL_GetDayWeek (RTC_Type *base, uint16_t *day, uint16_t *weekDay) |
Gets the IRTC current day and day of week. More... | |
static void | IRTC_HAL_SetHourMin (RTC_Type *base, uint16_t hour, uint16_t min) |
Sets the IRTC hour and min. More... | |
void | IRTC_HAL_GetHourMin (RTC_Type *base, uint16_t *hour, uint16_t *min) |
Gets the IRTC current hour and min. More... | |
static void | IRTC_HAL_SetSec (RTC_Type *base, uint16_t sec) |
Sets the IRTC second counter. More... | |
static void | IRTC_HAL_GetSec (RTC_Type *base, uint16_t *sec) |
Gets the IRTC current second counter. More... | |
void | IRTC_HAL_SetDatetime (RTC_Type *base, const irtc_datetime_t *datetime) |
Sets the IRTC date and time according to the given time structure. More... | |
void | IRTC_HAL_GetDatetime (RTC_Type *base, irtc_datetime_t *datetime) |
Gets the IRTC time and stores it in the given time structure. More... | |
Alarm Time Setting | |
static void | IRTC_HAL_SetAlarmMatchMode (RTC_Type *base, irtc_alarm_match_t alarmType) |
Sets alarm match type. More... | |
void | IRTC_HAL_SetAlarmYearMonth (RTC_Type *base, uint16_t year, uint16_t month) |
Sets the IRTC year and month alarm. More... | |
void | IRTC_HAL_GetAlarmYearMonth (RTC_Type *base, uint16_t *year, uint16_t *month) |
Gets the IRTC current year and month alarm. More... | |
static void | IRTC_HAL_SetAlarmDay (RTC_Type *base, uint16_t day) |
Sets the IRTC day alarm. More... | |
static void | IRTC_HAL_GetAlarmDay (RTC_Type *base, uint16_t *day) |
Gets the IRTC current day alarm. More... | |
static void | IRTC_HAL_SetAlarmHourMin (RTC_Type *base, uint16_t hour, uint16_t min) |
Sets the IRTC hour and min alarm. More... | |
void | IRTC_HAL_GetAlarmHourMin (RTC_Type *base, uint16_t *hour, uint16_t *min) |
Gets the IRTC current hour and min alarm. More... | |
static void | IRTC_HAL_SetAlarmSec (RTC_Type *base, uint16_t sec) |
Sets the IRTC second counter alarm. More... | |
static void | IRTC_HAL_GetAlarmSec (RTC_Type *base, uint16_t *sec) |
Gets the IRTC current second counter alarm. More... | |
void | IRTC_HAL_SetAlarm (RTC_Type *base, const irtc_datetime_t *datetime) |
Sets the IRTC alarm time and enables the alarm interrupt. More... | |
void | IRTC_HAL_GetAlarm (RTC_Type *base, irtc_datetime_t *datetime) |
Reads the value of the time alarm. More... | |
Daylight Saving Time Setting | |
static void | IRTC_HAL_SetDaylightMonth (RTC_Type *base, uint16_t startMonth, uint16_t endMonth) |
Sets IRTC daylight saving start month and end month. More... | |
void | IRTC_HAL_GetDaylightMonth (RTC_Type *base, uint16_t *startMonth, uint16_t *endMonth) |
Gets the IRTC current daylight saving start and end month. More... | |
static void | IRTC_HAL_SetDaylightDay (RTC_Type *base, uint16_t startDay, uint16_t endDay) |
Sets the IRTC daylight saving start and end day. More... | |
void | IRTC_HAL_GetDaylightDay (RTC_Type *base, uint16_t *startDay, uint16_t *endDay) |
Gets the IRTC current daylight saving start and end day. More... | |
static void | IRTC_HAL_SetDaylightHour (RTC_Type *base, uint16_t startHour, uint16_t endHour) |
Sets the IRTC current daylight saving start and end hour. More... | |
void | IRTC_HAL_GetDaylightHour (RTC_Type *base, uint16_t *startHour, uint16_t *endHour) |
Gets the IRTC current daylight saving start and end hour. More... | |
void | IRTC_HAL_SetDaylightTime (RTC_Type *base, const irtc_daylight_time_t *datetime) |
Sets the IRTC daylight saving date and time. More... | |
void | IRTC_HAL_GetDaylightTime (RTC_Type *base, irtc_daylight_time_t *datetime) |
Gets the IRTC daylight saving time and stores it in the given time structure. More... | |
Status | |
static bool | IRTC_HAL_GetStatusFlag (RTC_Type *base, irtc_status_flag_t statusFlag) |
Gets the IRTC status flag state. More... | |
Interrupts | |
static void | IRTC_HAL_SetIntCmd (RTC_Type *base, irtc_int_t interrupt, bool enable) |
Enable or disable related IRTC interrupt. More... | |
static bool | IRTC_HAL_GetIntCmd (RTC_Type *base, irtc_int_t interrupt) |
Whether the IRTC interrupt is enabled or not. More... | |
static bool | IRTC_HAL_GetIntStatusFlag (RTC_Type *base, irtc_int_status_flag_t statusFlag) |
Gets the IRTC interrupt status flag state. More... | |
static void | IRTC_HAL_ClearIntStatusFlag (RTC_Type *base, irtc_int_status_flag_t statusFlag) |
Clear the IRTC interrupt status flag. More... | |
IRTC Time Compensation | |
static void | IRTC_HAL_SetCompensation (RTC_Type *base, bool enableFine, uint16_t compValue) |
Writes the value to the IRTC compensation register. More... | |
static uint16_t | IRTC_HAL_GetCompensation (RTC_Type *base) |
Reads the time compensation register contents. More... | |
IRTC Control | |
static void | IRTC_HAL_SetClockOutMode (RTC_Type *base, irtc_clock_output_t clock) |
Select which clock to output from SoC for use outside RTC. More... | |
static void | IRTC_HAL_SoftwareReset (RTC_Type *base) |
Performs a software reset on the IRTC module. More... | |
RTC HAL API Functions | |
void | RTC_HAL_Enable (RTC_Type *rtcBase) |
Initializes the RTC module. More... | |
void | RTC_HAL_Disable (RTC_Type *rtcBase) |
Disables the RTC module. More... | |
void | RTC_HAL_Init (RTC_Type *rtcBase) |
This function will clear all interrupts. More... | |
void | RTC_HAL_ConvertSecsToDatetime (const uint32_t *seconds, rtc_datetime_t *datetime) |
Converts seconds to date time format data structure. More... | |
bool | RTC_HAL_IsDatetimeCorrectFormat (const rtc_datetime_t *datetime) |
Checks whether the date time structure elements have the information that is within the range. More... | |
void | RTC_HAL_ConvertDatetimeToSecs (const rtc_datetime_t *datetime, uint32_t *seconds) |
Converts the date time format data structure to seconds. More... | |
void | RTC_HAL_SetDatetime (RTC_Type *rtcBase, const rtc_datetime_t *datetime) |
Sets the RTC date and time according to the given time structure. More... | |
void | RTC_HAL_SetDatetimeInsecs (RTC_Type *rtcBase, const uint32_t seconds) |
Sets the RTC date and time according to the given time provided in seconds. More... | |
void | RTC_HAL_GetDatetime (RTC_Type *rtcBase, rtc_datetime_t *datetime) |
Gets the RTC time and stores it in the given time structure. More... | |
void | RTC_HAL_GetDatetimeInSecs (RTC_Type *rtcBase, uint32_t *seconds) |
Gets the RTC time and returns it in seconds. More... | |
void | RTC_HAL_GetAlarm (RTC_Type *rtcBase, rtc_datetime_t *date) |
Reads the value of the time alarm. More... | |
bool | RTC_HAL_SetAlarm (RTC_Type *rtcBase, const rtc_datetime_t *date) |
Sets the RTC alarm time and enables the alarm interrupt. More... | |
RTC register access functions | |
static uint32_t | RTC_HAL_GetSecsReg (RTC_Type *rtcBase) |
Reads the value of the time seconds counter. More... | |
static void | RTC_HAL_SetSecsReg (RTC_Type *rtcBase, const uint32_t seconds) |
Writes to the time seconds counter. More... | |
static void | RTC_HAL_SetAlarmReg (RTC_Type *rtcBase, const uint32_t seconds) |
Sets the time alarm and clears the time alarm flag. More... | |
static uint32_t | RTC_HAL_GetAlarmReg (RTC_Type *rtcBase) |
Gets the time alarm register contents. More... | |
static uint16_t | RTC_HAL_GetPrescaler (RTC_Type *rtcBase) |
Reads the value of the time prescaler. More... | |
static void | RTC_HAL_SetPrescaler (RTC_Type *rtcBase, const uint16_t prescale) |
Sets the time prescaler. More... | |
static uint32_t | RTC_HAL_GetCompensationReg (RTC_Type *rtcBase) |
Reads the time compensation register contents. More... | |
static void | RTC_HAL_SetCompensationReg (RTC_Type *rtcBase, const uint32_t compValue) |
Writes the value to the RTC TCR register. More... | |
static uint8_t | RTC_HAL_GetCompensationIntervalCounter (RTC_Type *rtcBase) |
Reads the current value of the compensation interval counter, which is the field CIC in the RTC TCR register. More... | |
static uint8_t | RTC_HAL_GetTimeCompensationValue (RTC_Type *rtcBase) |
Reads the current value used by the compensation logic for the present second interval. More... | |
static uint8_t | RTC_HAL_GetCompensationIntervalRegister (RTC_Type *rtcBase) |
Reads the compensation interval register. More... | |
static void | RTC_HAL_SetCompensationIntervalRegister (RTC_Type *rtcBase, const uint8_t value) |
Writes the compensation interval. More... | |
static uint8_t | RTC_HAL_GetTimeCompensationRegister (RTC_Type *rtcBase) |
Reads the time compensation value which is the configured number of 32.768 kHz clock cycles in each second. More... | |
static void | RTC_HAL_SetTimeCompensationRegister (RTC_Type *rtcBase, const uint8_t compValue) |
Writes to the field Time Compensation Register (TCR) of the RTC Time Compensation Register (RTC_TCR). More... | |
static void | RTC_HAL_SetOsc2pfLoadCmd (RTC_Type *rtcBase, bool enable) |
Enables/disables the oscillator configuration for the 2pF load. More... | |
static bool | RTC_HAL_GetOsc2pfLoad (RTC_Type *rtcBase) |
Reads the oscillator 2pF load configure bit. More... | |
static void | RTC_HAL_SetOsc4pfLoadCmd (RTC_Type *rtcBase, bool enable) |
Enables/disables the oscillator configuration for the 4pF load. More... | |
static bool | RTC_HAL_GetOsc4pfLoad (RTC_Type *rtcBase) |
Reads the oscillator 4pF load configure bit. More... | |
static void | RTC_HAL_SetOsc8pfLoadCmd (RTC_Type *rtcBase, bool enable) |
Enables/disables the oscillator configuration for the 8pF load. More... | |
static bool | RTC_HAL_GetOsc8pfLoad (RTC_Type *rtcBase) |
Reads the oscillator 8pF load configure bit. More... | |
static void | RTC_HAL_SetOsc16pfLoadCmd (RTC_Type *rtcBase, bool enable) |
Enables/disables the oscillator configuration for the 16pF load. More... | |
static bool | RTC_HAL_GetOsc16pfLoad (RTC_Type *rtcBase) |
Reads the oscillator 16pF load configure bit. More... | |
static void | RTC_HAL_SetClockOutCmd (RTC_Type *rtcBase, bool enable) |
Enables/disables the 32 kHz clock output to other peripherals. More... | |
static bool | RTC_HAL_GetClockOutCmd (RTC_Type *rtcBase) |
Reads the RTC_CR CLKO bit. More... | |
static void | RTC_HAL_SetOscillatorCmd (RTC_Type *rtcBase, bool enable) |
Enables/disables the oscillator. More... | |
static bool | RTC_HAL_IsOscillatorEnabled (RTC_Type *rtcBase) |
Reads the RTC_CR OSCE bit. More... | |
static void | RTC_HAL_SoftwareReset (RTC_Type *rtcBase) |
Performs a software reset on the RTC module. More... | |
static void | RTC_HAL_SoftwareResetFlagClear (RTC_Type *rtcBase) |
Clears the software reset flag. More... | |
static bool | RTC_HAL_ReadSoftwareResetStatus (RTC_Type *rtcBase) |
Reads the RTC_CR SWR bit. More... | |
static bool | RTC_HAL_IsCounterEnabled (RTC_Type *rtcBase) |
Reads the time counter status (enabled/disabled). More... | |
static void | RTC_HAL_EnableCounter (RTC_Type *rtcBase, bool enable) |
Changes the time counter status. More... | |
static bool | RTC_HAL_HasAlarmOccured (RTC_Type *rtcBase) |
Checks whether the configured time alarm has occurred. More... | |
static bool | RTC_HAL_IsTimeInvalid (RTC_Type *rtcBase) |
Checks whether the time has been marked as invalid. More... | |
static bool | RTC_HAL_IsSecsIntEnabled (RTC_Type *rtcBase) |
Checks whether the Time Seconds Interrupt is enabled/disabled. More... | |
static void | RTC_HAL_SetSecsIntCmd (RTC_Type *rtcBase, bool enable) |
Enables/disables the Time Seconds Interrupt. More... | |
static bool | RTC_HAL_ReadAlarmInt (RTC_Type *rtcBase) |
Checks whether the Time Alarm Interrupt is enabled/disabled. More... | |
static void | RTC_HAL_SetAlarmIntCmd (RTC_Type *rtcBase, bool enable) |
Enables/disables the Time Alarm Interrupt. More... | |
static void | RTC_HAL_SetTimeOverflowIntCmd (RTC_Type *rtcBase, bool enable) |
Enables/disables the Time Overflow Interrupt. More... | |
static void | RTC_HAL_SetTimeInvalidIntCmd (RTC_Type *rtcBase, bool enable) |
Enables/disables the Time Invalid Interrupt. More... | |
struct irtc_datetime_t |
Data Fields | |
uint16_t | year |
Range from 1984 to 2239. More... | |
uint16_t | month |
Range from 1 to 12. More... | |
uint16_t | day |
Range from 1 to 31 (depending on month). More... | |
uint16_t | weekDay |
Range from 0(Sunday) to 6(Saturday) | |
uint16_t | hour |
Range from 0 to 23. More... | |
uint16_t | minute |
Range from 0 to 59. More... | |
uint16_t | second |
Range from 0 to 59. More... | |
uint16_t irtc_datetime_t::year |
uint16_t irtc_datetime_t::month |
uint16_t irtc_datetime_t::day |
uint16_t irtc_datetime_t::hour |
uint16_t irtc_datetime_t::minute |
uint16_t irtc_datetime_t::second |
struct irtc_daylight_time_t |
Data Fields | |
uint16_t | startMonth |
Range from 1 to 12. More... | |
uint16_t | endMonth |
Range from 1 to 12. More... | |
uint16_t | startDay |
Range from 1 to 31 (depending on month). More... | |
uint16_t | endDay |
Range from 1 to 31 (depending on month). More... | |
uint16_t | startHour |
Range from 0 to 23. More... | |
uint16_t | endHour |
Range from 0 to 23. More... | |
uint16_t irtc_daylight_time_t::startMonth |
uint16_t irtc_daylight_time_t::endMonth |
uint16_t irtc_daylight_time_t::startDay |
uint16_t irtc_daylight_time_t::endDay |
uint16_t irtc_daylight_time_t::startHour |
uint16_t irtc_daylight_time_t::endHour |
struct rtc_datetime_t |
Data Fields | |
uint16_t | year |
Range from 1970 to 2099. More... | |
uint16_t | month |
Range from 1 to 12. More... | |
uint16_t | day |
Range from 1 to 31 (depending on month). More... | |
uint16_t | hour |
Range from 0 to 23. More... | |
uint16_t | minute |
Range from 0 to 59. More... | |
uint8_t | second |
Range from 0 to 59. More... | |
uint16_t rtc_datetime_t::year |
uint16_t rtc_datetime_t::month |
uint16_t rtc_datetime_t::day |
uint16_t rtc_datetime_t::hour |
uint16_t rtc_datetime_t::minute |
uint8_t rtc_datetime_t::second |
enum irtc_clock_output_t |
enum irtc_alarm_match_t |
enum irtc_status_flag_t |
enum irtc_int_t |
enum rtc_status_t |
void IRTC_HAL_Init | ( | RTC_Type * | base, |
const irtc_datetime_t * | datetime, | ||
const irtc_datetime_t * | alarmDatetime, | ||
irtc_alarm_match_t | alarmMode, | ||
const irtc_daylight_time_t * | daylightTime | ||
) |
This function initiates a soft-reset of the IRTC module to reset the IRTC registers, and configure IRTC according to user settings.
base | The IRTC base address pointer. |
datetime | Date and time need to set, pass NULL to ignore. |
alarmDatetime | Alarm of date and time need to set, pass NULL to ignore. |
alarmMode | Alarm mode to set when will generate alarm. |
daylightTime | Daylight saving time need to set, pass NULL to ignore. |
void IRTC_HAL_SetLockRegisterCmd | ( | RTC_Type * | base, |
bool | lock | ||
) |
base | The IRTC base address pointer. |
lock | Lock(true) or unlock(false) IRTC registers. |
void IRTC_HAL_SetYearMonth | ( | RTC_Type * | base, |
uint16_t | year, | ||
uint16_t | month | ||
) |
base | The IRTC base address pointer |
year | Year number from 1984 to 2239. |
month | Month number from 1 to 12. |
void IRTC_HAL_GetYearMonth | ( | RTC_Type * | base, |
uint16_t * | year, | ||
uint16_t * | month | ||
) |
base | The IRTC base address pointer |
year | Current year number from 1984 to 2239. |
month | Current month number from 1 to 12. |
|
inlinestatic |
base | The IRTC base address pointer |
day | Day number from 1 to 31. |
weekDay | Day of week number from 0(Sunday) to 6(Saturday). |
void IRTC_HAL_GetDayWeek | ( | RTC_Type * | base, |
uint16_t * | day, | ||
uint16_t * | weekDay | ||
) |
base | The IRTC base address pointer |
day | Current day number from 1 to 31. |
weekDay | Current day of week number from 0(Sunday) to 6(Saturday). |
|
inlinestatic |
base | The IRTC base address pointer |
hour | Hour number from 0 to 23. |
min | Min number from 0 to 59. |
void IRTC_HAL_GetHourMin | ( | RTC_Type * | base, |
uint16_t * | hour, | ||
uint16_t * | min | ||
) |
base | The IRTC base address pointer |
hour | Current hour number from 0 to 23. |
min | Current min number from 0 to 59. |
|
inlinestatic |
base | The IRTC base address pointer |
sec | Second number from 0 to 59. |
|
inlinestatic |
base | The IRTC base address pointer |
sec | Current second number from 0 to 59. |
void IRTC_HAL_SetDatetime | ( | RTC_Type * | base, |
const irtc_datetime_t * | datetime | ||
) |
base | The IRTC base address pointer |
datetime | Pointer to a structure where the date and time details are stored. |
void IRTC_HAL_GetDatetime | ( | RTC_Type * | base, |
irtc_datetime_t * | datetime | ||
) |
base | The IRTC base address pointer |
datetime | Pointer to a structure where the date and time details are stored. |
|
inlinestatic |
base | The IRTC base address pointer |
alarmType | Alarm match selections that when an alarm will happen. |
void IRTC_HAL_SetAlarmYearMonth | ( | RTC_Type * | base, |
uint16_t | year, | ||
uint16_t | month | ||
) |
base | The IRTC base address pointer |
year | Year number from 1984 to 2239. |
month | Month number from 1 to 12. |
void IRTC_HAL_GetAlarmYearMonth | ( | RTC_Type * | base, |
uint16_t * | year, | ||
uint16_t * | month | ||
) |
base | The IRTC base address pointer |
year | Current year number from 1984 to 2239. |
month | Current month number from 1 to 12. |
|
inlinestatic |
base | The IRTC base address pointer |
day | Day number from 1 to 31. |
|
inlinestatic |
base | The IRTC base address pointer |
day | Current day number from 1984 to 2239. |
|
inlinestatic |
base | The IRTC base address pointer |
hour | Hour number from 0 to 23. |
min | Min number from 0 to 59. |
void IRTC_HAL_GetAlarmHourMin | ( | RTC_Type * | base, |
uint16_t * | hour, | ||
uint16_t * | min | ||
) |
base | The IRTC base address pointer |
hour | Current hour number from 0 to 23. |
min | Current min number from 0 to 59. |
|
inlinestatic |
base | The IRTC base address pointer |
sec | Second number from 0 to 59. |
|
inlinestatic |
base | The IRTC base address pointer |
sec | Current second number from 0 to 59. |
void IRTC_HAL_SetAlarm | ( | RTC_Type * | base, |
const irtc_datetime_t * | datetime | ||
) |
The function checks whether the specified alarm time is greater than the present time. If not, the function does not set the alarm and returns an error.
base | The IRTC base address pointer. |
datetime | Pointer to structure where the alarm date and time details will be stored at. |
void IRTC_HAL_GetAlarm | ( | RTC_Type * | base, |
irtc_datetime_t * | datetime | ||
) |
base | The IRTC base address pointer |
datetime | Pointer to a variable where the alarm date and time details are stored. |
|
inlinestatic |
base | The IRTC base address pointer |
startMonth | Daylight saving start month number from 1 to 12. |
endMonth | Daylight saving end month number from 1 to 12. |
void IRTC_HAL_GetDaylightMonth | ( | RTC_Type * | base, |
uint16_t * | startMonth, | ||
uint16_t * | endMonth | ||
) |
base | The IRTC base address pointer |
startMonth | Current daylight saving start month number from 1 to 12. |
endMonth | Current daylight saving end month number from 1 to 12. |
|
inlinestatic |
base | The IRTC base address pointer |
startDay | Daylight saving day start value number from 1 to 31. |
endDay | Daylight saving day end value number from 1 to 31. |
void IRTC_HAL_GetDaylightDay | ( | RTC_Type * | base, |
uint16_t * | startDay, | ||
uint16_t * | endDay | ||
) |
base | The IRTC base address pointer |
startDay | Current daylight saving day start value number from 1 to 31. |
endDay | Current daylight saving day end value number from 1 to 31. |
|
inlinestatic |
base | The IRTC base address pointer |
startHour | Daylight saving hour start value. |
endHour | Daylight saving hour end value. |
void IRTC_HAL_GetDaylightHour | ( | RTC_Type * | base, |
uint16_t * | startHour, | ||
uint16_t * | endHour | ||
) |
base | The IRTC base address pointer |
startHour | Current daylight saving hour start value. |
endHour | Current daylight saving hour end value. |
void IRTC_HAL_SetDaylightTime | ( | RTC_Type * | base, |
const irtc_daylight_time_t * | datetime | ||
) |
base | The IRTC base address pointer |
datetime | Pointer to a structure where the date and time details are stored. |
void IRTC_HAL_GetDaylightTime | ( | RTC_Type * | base, |
irtc_daylight_time_t * | datetime | ||
) |
base | The IRTC base address pointer |
datetime | Pointer to a structure where the date and time details are stored. |
|
inlinestatic |
base The IRTC peripheral base pointer.
statusFlag | The status flag, defined in type irtc_status_flag_t. |
|
inlinestatic |
base The IRTC peripheral base pointer.
interrupt | The interrupt name, defined in type irtc_int_t. |
enable | Enable(ture) or disable(false) related interrupt. |
|
inlinestatic |
base The IRTC peripheral base pointer.
interrupt | The interrupt name, defined in type irtc_int_t. |
|
inlinestatic |
base The IRTC peripheral base pointer.
statusFlag | The status flag, defined in type irtc_int_status_flag_t. |
|
inlinestatic |
Tamper interrupt status flag is cleared when TAMPER_SCR[TMPR_STS] is cleared.
base The IRTC peripheral base pointer.
statusFlag | The status flag, defined in type irtc_int_status_flag_t. |
|
inlinestatic |
base | The IRTC base address pointer |
enableFine | Enable(true) or disable(false) fine compensation. |
compValue | value to be written to the compensation register. |
|
inlinestatic |
base | The IRTC base address pointer |
|
inlinestatic |
base | The IRTC base address pointer. |
clock | OUtput clock selection from list of irtc_clock_output_t. |
|
inlinestatic |
This clears the contents of alarm, interrupt(status and enable except tamper interrupt enable bit) registers, STATUS[CMP_DONE], and STATUS[BUS_ERR] and has no effect on DST, calendaring, standby time and tamper detect registers.
base | The IRTC base address pointer |
void RTC_HAL_Enable | ( | RTC_Type * | rtcBase | ) |
This function enables the RTC oscillator.
rtcBase | The RTC base address pointer |
void RTC_HAL_Disable | ( | RTC_Type * | rtcBase | ) |
This function disables the RTC counter and oscillator.
rtcBase | The RTC base address pointer |
void RTC_HAL_Init | ( | RTC_Type * | rtcBase | ) |
This function initiates a soft-reset of the RTC module if the time invalid flag is set.
rtcBase | The RTC base address pointer. |
void RTC_HAL_ConvertSecsToDatetime | ( | const uint32_t * | seconds, |
rtc_datetime_t * | datetime | ||
) |
seconds | holds the date and time information in seconds |
datetime | holds the converted information from seconds in date and time format |
bool RTC_HAL_IsDatetimeCorrectFormat | ( | const rtc_datetime_t * | datetime | ) |
datetime | holds the date and time information that needs to be converted to seconds |
void RTC_HAL_ConvertDatetimeToSecs | ( | const rtc_datetime_t * | datetime, |
uint32_t * | seconds | ||
) |
datetime | holds the date and time information that needs to be converted to seconds |
seconds | holds the converted date and time in seconds |
void RTC_HAL_SetDatetime | ( | RTC_Type * | rtcBase, |
const rtc_datetime_t * | datetime | ||
) |
The function converts the data from the time structure to seconds and writes the seconds value to the RTC register. The RTC counter is started after setting the time.
rtcBase | The RTC base address pointer |
datetime | [in] Pointer to structure where the date and time details to set are stored. |
void RTC_HAL_SetDatetimeInsecs | ( | RTC_Type * | rtcBase, |
const uint32_t | seconds | ||
) |
The RTC counter is started after setting the time.
rtcBase | The RTC base address pointer |
seconds | [in] Time in seconds |
void RTC_HAL_GetDatetime | ( | RTC_Type * | rtcBase, |
rtc_datetime_t * | datetime | ||
) |
The function reads the value in seconds from the RTC register. It then converts to the time structure which provides the time in date, hour, minutes and seconds.
rtcBase | The RTC base address pointer |
datetime | [out] pointer to a structure where the date and time details are stored. |
void RTC_HAL_GetDatetimeInSecs | ( | RTC_Type * | rtcBase, |
uint32_t * | seconds | ||
) |
rtcBase | The RTC base address pointer |
seconds | [out] pointer to variable where the RTC time is stored in seconds |
void RTC_HAL_GetAlarm | ( | RTC_Type * | rtcBase, |
rtc_datetime_t * | date | ||
) |
rtcBase | The RTC base address pointer |
date | [out] pointer to a variable where the alarm date and time details are stored. |
bool RTC_HAL_SetAlarm | ( | RTC_Type * | rtcBase, |
const rtc_datetime_t * | date | ||
) |
The function checks whether the specified alarm time is greater than the present time. If not, the function does not set the alarm and returns an error.
rtcBase | The RTC base address pointer. |
date | [in] pointer to structure where the alarm date and time details will be stored at. |
|
inlinestatic |
The time counter reads as zero if either the SR[TOF] or the SR[TIF] is set.
rtcBase | The RTC base address pointer. |
|
inlinestatic |
When the time counter is enabled, the TSR is read only and increments once every second provided the SR[TOF] or SR[TIF] is not set. When the time counter is disabled, the TSR can be read or written. Writing to the TSR when the time counter is disabled clears the SR[TOF] and/or the SR[TIF]. Writing to the TSR register with zero is supported, but not recommended, since the TSR reads as zero when either the SR[TIF] or the SR[TOF] is set (indicating the time is invalid).
rtcBase | The RTC base address pointer. |
seconds | [in] seconds value. |
|
inlinestatic |
When the time counter is enabled, the SR[TAF] is set whenever the TAR[TAR] equals the TSR[TSR] and the TSR[TSR] increments. Writing to the TAR clears the SR[TAF].
rtcBase | The RTC base address pointer. |
seconds | [in] alarm value in seconds. |
|
inlinestatic |
rtcBase | The RTC base address pointer |
|
inlinestatic |
The time counter reads as zero when either the SR[TOF] or the SR[TIF] is set.
rtcBase | The RTC base address pointer |
|
inlinestatic |
When the time counter is enabled, the TPR is read only and increments every 32.768 kHz clock cycle. When the time counter is disabled, the TPR can be read or written. The TSR[TSR] increments when bit 14 of the TPR transitions from a logic one to a logic zero.
rtcBase | The RTC base address pointer |
prescale | Prescaler value |
|
inlinestatic |
rtcBase | The RTC base address pointer |
|
inlinestatic |
rtcBase | The RTC base address pointer |
compValue | value to be written to the compensation register. |
|
inlinestatic |
rtcBase | The RTC base address pointer. |
|
inlinestatic |
rtcBase | The RTC base address pointer |
|
inlinestatic |
The value is the configured compensation interval in seconds from 1 to 256 to control how frequently the time compensation register should adjust the number of 32.768 kHz cycles in each second. The value is one less than the number of seconds (for example, zero means a configuration for a compensation interval of one second).
rtcBase | The RTC base address pointer. |
|
inlinestatic |
This configures the compensation interval in seconds from 1 to 256 to control how frequently the TCR should adjust the number of 32.768 kHz cycles in each second. The value written should be one less than the number of seconds (for example, write zero to configure for a compensation interval of one second). This register is double buffered and writes do not take affect until the end of the current compensation interval.
rtcBase | The RTC base address pointer. |
value | the compensation interval value. |
|
inlinestatic |
rtcBase | The RTC base address pointer |
|
inlinestatic |
Configures the number of 32.768 kHz clock cycles in each second. This register is double buffered and writes do not take affect until the end of the current compensation interval.
rtcBase | The RTC base address pointer |
compValue | value of the time compensation. |
|
inlinestatic |
rtcBase | The RTC base address pointer |
enable | can be true or false -true: enables load -false: disables load. |
|
inlinestatic |
rtcBase | The RTC base address pointer |
|
inlinestatic |
rtcBase | The RTC base address pointer |
enable | can be true or false -true: enables load. -false: disables load |
|
inlinestatic |
rtcBase | The RTC base address pointer |
|
inlinestatic |
rtcBase | The RTC base address pointer |
enable | can be true or false -true: enables load. -false: disables load. |
|
inlinestatic |
rtcBase | The RTC base address pointer |
|
inlinestatic |
rtcBase | The RTC base address pointer |
enable | can be true or false -true: enables load. -false: disables load. |
|
inlinestatic |
rtcBase | The RTC base address pointer |
|
inlinestatic |
rtcBase | The RTC base address pointer |
enable | can be true or false -true: enables clock out. -false: disables clock out. |
|
inlinestatic |
rtcBase | The RTC base address pointer |
|
inlinestatic |
After enabling, waits for the oscillator startup time before enabling the time counter to allow the 32.768 kHz clock time to stabilize.
rtcBase | The RTC base address pointer |
enable | can be true or false -true: enables oscillator. -false: disables oscillator. |
|
inlinestatic |
rtcBase | The RTC base address pointer |
|
inlinestatic |
This resets all RTC registers except for the SWR bit and the RTC_WAR and RTC_RAR registers. The SWR bit is cleared after VBAT POR and by software explicitly clearing it. Note: access control features (RTC_WAR and RTC_RAR registers) are not available in all MCUs.
rtcBase | The RTC base address pointer |
|
inlinestatic |
rtcBase | The RTC base address pointer |
|
inlinestatic |
rtcBase | The RTC base address pointer |
|
inlinestatic |
rtcBase | The RTC base address pointer |
|
inlinestatic |
rtcBase | The RTC base address pointer |
enable | can be true or false -true: enables the time counter -false: disables the time counter. |
|
inlinestatic |
Reads time alarm flag (TAF). This flag is set when the time alarm register (TAR) equals the time seconds register (TSR) and the TSR increments. This flag is cleared by writing the TAR register.
rtcBase | The RTC base address pointer. |
|
inlinestatic |
Reads the value of RTC Status Register (RTC_SR), field Time Invalid Flag (TIF). This flag is set on VBAT POR or software reset. The TSR and TPR do not increment and read as zero when this bit is set. This flag is cleared by writing the TSR register when the time counter is disabled.
rtcBase | The RTC base address pointer. |
|
inlinestatic |
Reads the value of field Time Seconds Interrupt Enable (TSIE)of the RTC Interrupt Enable Register (RTC_IER). The seconds interrupt is an edge-sensitive interrupt with a dedicated interrupt vector. It is generated once a second and requires no software overhead (there is no corresponding status flag to clear).
rtcBase | The RTC base address pointer |
|
inlinestatic |
Writes to the field Time Seconds Interrupt Enable (TSIE) of the RTC Interrupt Enable Register (RTC_IER). Note: The seconds interrupt is an edge-sensitive interrupt with a dedicated interrupt vector. It is generated once a second and requires no software overhead (there is no corresponding status flag to clear).
rtcBase | The RTC base address pointer |
enable | can be true or false -true: Seconds interrupt is enabled. -false: Seconds interrupt is disabled. |
|
inlinestatic |
Reads the field Time Alarm Interrupt Enable (TAIE) value of the RTC Interrupt Enable Register (RTC_IER).
rtcBase | The RTC base address pointer |
|
inlinestatic |
Writes to the field Time Alarm Interrupt Enable (TAIE) of the RTC Interrupt Enable Register (RTC_IER).
rtcBase | The RTC base address pointer |
enable | can be true or false -true: Time alarm flag does generate an interrupt. -false: Time alarm flag does not generate an interrupt. |
|
inlinestatic |
Writes to the field Time Overflow Interrupt Enable (TOIE) of the RTC Interrupt Enable Register (RTC_IER).
rtcBase | The RTC base address pointer |
enable | can be true or false -true: Time overflow flag does generate an interrupt. -false: Time overflow flag does not generate an interrupt. |
|
inlinestatic |
Writes to the field Time Invalid Interrupt Enable (TIIE) of the RTC Interrupt Enable Register (RTC_IER).
rtcBase | The RTC base address pointer |
enable | can be true or false -true: Time invalid flag does generate an interrupt. -false: Time invalid flag does not generate an interrupt. |