This section describes the programming interface of the IRTC HAL driver. The IRTC HAL driver initializes the IRTC registers and provides functions to read or modify the IRTC registers. These are mostly invoked by the IRTC Peripheral driver.
IRTC Initialization
This function initiates a soft-reset of the IRTC module to reset the IRTC registers and configure IRTC according to user settings. It doesn't un-gate the IRTC clock.
IRTC Setting and reading the IRTC time
The HAL driver provides IRTC_HAL_SetDatetime() and IRTC_HAL_GetDatetime() functions to set and read the date and time using an instantiation of the irtc_datetime_t structure. This example describes the structure:
typedef struct IrtcDatetime
{
uint16_t year;
uint16_t month;
uint16_t day;
uint16_t weekDay;
IRTC Setting and reading the Alarm
The HAL driver provides IRTC_HAL_SetAlarm() and IRTC_HAL_GetAlarm() functions to set an alarm and read back the alarm time.
|
enum | irtc_status_t |
| Error codes for the IRTC driver. More...
|
|
enum | irtc_filter_clock_source_t {
kIRTC32K = 0x0,
kIRTC512 = 0x1,
kIRTC128 = 0x2,
kIRTC64 = 0x3,
kIRTC16 = 0x4,
kIRTC8 = 0x5,
kIRTC4 = 0x6,
kIRTC2 = 0x7
} |
| IRTC filter clock source options. More...
|
|
enum | irtc_tamper_pins_t {
kIRTCTamper0 = 0x0,
kIRTCTamper1 = 0x1,
kIRTCTamper2 = 0x2,
kIRTCTamper3 = 0x3
} |
| IRTC Tamper pins. More...
|
|
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 |
| IRTC status flags. More...
|
|
enum | irtc_int_status_flag_t |
| IRTC interrupt status flags. More...
|
|
enum | irtc_int_t |
| IRTC interrupts. More...
|
|
|
- Note
- All Date and Time settings APIs except the IRTC_HAL_SetDatetime and the IRTC_HAL_GetDatetime settings, should first determine the state of the INVAL bit in the STATUS(bit 0) to determine that the counters are stable before their value can be read or changed (this be done by calling IRTC_HAL_GetStatusFlag(base, kIRTCInvalidate)). The assertion of INVAL bit ensures that no operation is done at the boundary of a second when counters change value.
|
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 hours and minutes. More...
|
|
void | IRTC_HAL_GetHourMin (RTC_Type *base, uint16_t *hour, uint16_t *min) |
| Gets the IRTC current hours and minutes. 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...
|
|
|
static void | IRTC_HAL_SetDaylightMonth (RTC_Type *base, uint16_t startMonth, uint16_t endMonth) |
| Sets IRTC daylight savings start month and end month. More...
|
|
void | IRTC_HAL_GetDaylightMonth (RTC_Type *base, uint16_t *startMonth, uint16_t *endMonth) |
| Gets the IRTC current daylight savings start and end month. More...
|
|
static void | IRTC_HAL_SetDaylightDay (RTC_Type *base, uint16_t startDay, uint16_t endDay) |
| Sets the IRTC daylight savings start and end day. More...
|
|
void | IRTC_HAL_GetDaylightDay (RTC_Type *base, uint16_t *startDay, uint16_t *endDay) |
| Gets the IRTC current daylight savings start and end day. More...
|
|
static void | IRTC_HAL_SetDaylightHour (RTC_Type *base, uint16_t startHour, uint16_t endHour) |
| Sets the IRTC current daylight savings start and end hour. More...
|
|
void | IRTC_HAL_GetDaylightHour (RTC_Type *base, uint16_t *startHour, uint16_t *endHour) |
| Gets the IRTC current daylight savings start and end hour. More...
|
|
void | IRTC_HAL_SetDaylightTime (RTC_Type *base, const irtc_daylight_time_t *datetime) |
| Sets the IRTC daylight savings date and time. More...
|
|
void | IRTC_HAL_GetDaylightTime (RTC_Type *base, irtc_daylight_time_t *datetime) |
| Gets the IRTC daylight savings time and stores it in the given time structure. More...
|
|
|
void | IRTC_HAL_SetCoarseCompensation (RTC_Type *base, uint8_t compVal, uint8_t compInterval) |
| Enables the coarse compensation and sets the value to the IRTC compensation register. More...
|
|
void | IRTC_HAL_SetFineCompensation (RTC_Type *base, uint8_t integralVal, uint8_t fracVal, bool accumulateFrac) |
| Enables the fine compensation and sets the value to the IRTC compensation register. More...
|
|
Data Fields |
uint16_t | year |
| Range from 1984 to 2239.
|
|
uint16_t | month |
| Range from 1 to 12.
|
|
uint16_t | day |
| Range from 1 to 31 (depending on month).
|
|
uint16_t | weekDay |
| Range from 0(Sunday) to 6(Saturday).
|
|
uint16_t | hour |
| Range from 0 to 23.
|
|
uint16_t | minute |
| Range from 0 to 59.
|
|
uint16_t | second |
| Range from 0 to 59.
|
|
struct irtc_daylight_time_t |
Data Fields |
uint16_t | startMonth |
| Range from 1 to 12.
|
|
uint16_t | endMonth |
| Range from 1 to 12.
|
|
uint16_t | startDay |
| Range from 1 to 31 (depending on month).
|
|
uint16_t | endDay |
| Range from 1 to 31 (depending on month).
|
|
uint16_t | startHour |
| Range from 0 to 23.
|
|
uint16_t | endHour |
| Range from 0 to 23.
|
|
struct irtc_tamper_config_t |
uint8_t irtc_tamper_config_t::filterDuration |
Enumerator |
---|
kIRTC32K |
Use 32 kHz clock source for the tamper filter.
|
kIRTC512 |
Use 512 Hz clock source for the tamper filter.
|
kIRTC128 |
Use 128 Hz clock source for the tamper filter.
|
kIRTC64 |
Use 64 Hz clock source for the tamper filter.
|
kIRTC16 |
Use 16 Hz clock source for the tamper filter.
|
kIRTC8 |
Use 8 Hz clock source for the tamper filter.
|
kIRTC4 |
Use 4 Hz clock source for the tamper filter.
|
kIRTC2 |
Use 2 Hz clock source for the tamper filter.
|
Enumerator |
---|
kIRTCTamper0 |
External Tamper 0.
|
kIRTCTamper1 |
External Tamper 1.
|
kIRTCTamper2 |
External Tamper 2.
|
kIRTCTamper3 |
Internal tamper, does not have filter configuration.
|
Enumerator |
---|
kIRTCNoOutputClk |
No output clock.
|
kIRTCFine1hzClk |
Fine 1 Hz clock.
|
kIRTC32khzClk |
32.768 kHz clock
|
kIRTCCoarse1hzClck |
Coarse 1Hz clock.
|
Enumerator |
---|
kIRTCSecMinHour |
Generate alarm when sec/min/hour are matched.
|
kIRTCSecMinHourDay |
Generate alarm when sec/min/hour/day are matched.
|
kIRTCSecMinHourDayMon |
Generate alarm when sec/min/hour/day/month are matched.
|
kIRTCSecMinHourDayMonYear |
Generate alarm when sec/min/hour/day/month/year are matched.
|
void IRTC_HAL_Init |
( |
RTC_Type * |
base | ) |
|
This function initiates a soft-reset of the IRTC module to reset the IRTC registers.
- Parameters
-
base | The IRTC base address pointer. |
void IRTC_HAL_SetLockRegisterCmd |
( |
RTC_Type * |
base, |
|
|
bool |
lock |
|
) |
| |
- Note
- When the registers are unlocked, they remain in unlocked state for 2 seconds, after which they are locked automatically. After power-on-reset, the registers come out unlocked and they are locked automatically 15 seconds after power on.
- Parameters
-
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 |
|
) |
| |
- Parameters
-
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 |
|
) |
| |
- Parameters
-
base | The IRTC base address pointer |
year | Current year number from 1984 to 2239. |
month | Current month number from 1 to 12. |
static void IRTC_HAL_SetDayWeek |
( |
RTC_Type * |
base, |
|
|
uint16_t |
day, |
|
|
uint16_t |
weekDay |
|
) |
| |
|
inlinestatic |
- Parameters
-
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 |
|
) |
| |
- Parameters
-
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). |
static void IRTC_HAL_SetHourMin |
( |
RTC_Type * |
base, |
|
|
uint16_t |
hour, |
|
|
uint16_t |
min |
|
) |
| |
|
inlinestatic |
- Parameters
-
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 |
|
) |
| |
- Parameters
-
base | The IRTC base address pointer |
hour | Current hour number from 0 to 23. |
min | Current minute number from 0 to 59. |
static void IRTC_HAL_SetSec |
( |
RTC_Type * |
base, |
|
|
uint16_t |
sec |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | The IRTC base address pointer |
sec | Second number from 0 to 59. |
static void IRTC_HAL_GetSec |
( |
RTC_Type * |
base, |
|
|
uint16_t * |
sec |
|
) |
| |
|
inlinestatic |
- Parameters
-
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 |
|
) |
| |
- Parameters
-
base | The IRTC base address pointer |
datetime | Pointer to a structure where the date and time details are stored. |
- Parameters
-
base | The IRTC base address pointer |
datetime | Pointer to a structure where the date and time details are stored. |
- Parameters
-
base | The IRTC base address pointer |
alarmType | Alarm match selections that when an alarm happens. |
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.
- Parameters
-
base | The IRTC base address pointer. |
datetime | Pointer to structure where the alarm date and time details will be stored at. |
- Parameters
-
base | The IRTC base address pointer |
datetime | Pointer to a variable where the alarm date and time details are stored. |
static void IRTC_HAL_SetDaylightMonth |
( |
RTC_Type * |
base, |
|
|
uint16_t |
startMonth, |
|
|
uint16_t |
endMonth |
|
) |
| |
|
inlinestatic |
- Parameters
-
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 |
|
) |
| |
- Parameters
-
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. |
static void IRTC_HAL_SetDaylightDay |
( |
RTC_Type * |
base, |
|
|
uint16_t |
startDay, |
|
|
uint16_t |
endDay |
|
) |
| |
|
inlinestatic |
- Parameters
-
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 |
|
) |
| |
- Parameters
-
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. |
static void IRTC_HAL_SetDaylightHour |
( |
RTC_Type * |
base, |
|
|
uint16_t |
startHour, |
|
|
uint16_t |
endHour |
|
) |
| |
|
inlinestatic |
- Parameters
-
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 |
|
) |
| |
- Parameters
-
base | The IRTC base address pointer |
startHour | Current daylight saving hour start value. |
endHour | Current daylight saving hour end value. |
- Parameters
-
base | The IRTC base address pointer |
datetime | Pointer to a structure where the date and time details are stored. |
- Parameters
-
base | The IRTC base address pointer |
datetime | Pointer to a structure where the date and time details are stored. |
- Parameters
-
base | The IRTC peripheral base pointer. |
statusFlag | The status flag, defined in type irtc_status_flag_t. |
- Returns
- State of the status flag: asserted (true) or not-asserted (false).
- true: related status flag is being set.
- false: related status flag is not set.
static void IRTC_HAL_SetIntCmd |
( |
RTC_Type * |
base, |
|
|
irtc_int_t |
interrupt, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | The IRTC peripheral base pointer. |
interrupt | The interrupt name, defined in type irtc_int_t. |
enable | Enable (true) or disable (false) related interrupt. |
static bool IRTC_HAL_GetIntCmd |
( |
RTC_Type * |
base, |
|
|
irtc_int_t |
interrupt |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | The IRTC peripheral base pointer. |
interrupt | The interrupt name, defined in type irtc_int_t. |
- Returns
- State of the interrupt: asserted (true) or not-asserted (false).
- true: related interrupt is being enabled.
- false: related interrupt is not enabled.
- Parameters
-
base | The IRTC peripheral base pointer. |
statusFlag | The status flag, defined in type irtc_int_status_flag_t. |
- Returns
- State of the status flag: asserted (true) or not-asserted (false).
- true: related status flag is being set.
- false: related status flag is not set.
Tamper interrupt status flag is cleared when the TAMPER_SCR[TMPR_STS] is cleared.
- Parameters
-
base | The IRTC peripheral base pointer. |
statusFlag | The status flag, defined in type irtc_int_status_flag_t. |
void IRTC_HAL_SetCoarseCompensation |
( |
RTC_Type * |
base, |
|
|
uint8_t |
compVal, |
|
|
uint8_t |
compInterval |
|
) |
| |
- Parameters
-
base | The IRTC base address pointer |
compVal | Compensation value is a 2's complement value. |
compInterval | Compensation interval. |
void IRTC_HAL_SetFineCompensation |
( |
RTC_Type * |
base, |
|
|
uint8_t |
integralVal, |
|
|
uint8_t |
fracVal, |
|
|
bool |
accumulateFrac |
|
) |
| |
- Parameters
-
base | The IRTC base address pointer |
integralVal | Compensation integral value is a twos complement value of the integer part. |
fracVal | Compensation fraction value expressed as number of clock cycles of a fixed 4.194304Mhz clock that have to be added. |
accumulateFrac | Flag indicating if we want to add to previous fractional part; true: accumulate fractional part, false: start afresh and overwrite current value |
- Parameters
-
base | The IRTC base address pointer. |
clock | OUtput clock selection from list of irtc_clock_output_t. |
static void IRTC_HAL_SoftwareReset |
( |
RTC_Type * |
base | ) |
|
|
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.
- Parameters
-
base | The IRTC base address pointer |
The function configures the filter properties for the three external tampers i.e., 0, 1, and 2. It also sets up active/passive and direction of the tamper bits, which are not available on all platforms. NOTE: This function programs the tamper filter parameters. The user must gate the 32 K clock to the RTC before calling this function. It is assumed that the time and date are set after this and the tamper parameters do not require to be changed again later.
- Parameters
-
base | The IRTC base address pointer |
tamperNum | The IRTC tamper input to configure |
tamperConfig | The IRTC tamper properties |
static void IRTC_HAL_EnableTamper |
( |
RTC_Type * |
base | ) |
|
|
inlinestatic |
The function should be called after all required tamper features have been configured by calling the IRTC_HAL_ConfigTamperParams functions.
- Parameters
-
base | The IRTC base address pointer |
static void IRTC_HAL_DisableTamper |
( |
RTC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | The IRTC base address pointer |