| NUC472_NUC442_BSP V3.04.000 The Board Support Package for NUC472/NUC442

Macros | Functions | Variables
RTC Exported Functions
NUC472/NUC442 Device Driver » RTC Driver » RTC Exported Constants » RTC Exported Structs
Collaboration diagram for RTC Exported Functions:

## Macros
#define | RTC_READ_SPARE_REGISTER(u32RegNum)
| Read spare register. More...
#define | RTC_WRITE_SPARE_REGISTER(u32RegNum, u32RegValue)
| Write spare register. More...
#define | RTC_IS_LEAP_YEAR
| According to current time, return this year is leap year or not. More...
#define | RTC_CLEAR_ALARM_INT_FLAG
| Clear alarm interrupt status. More...
#define | RTC_CLEAR_TICK_INT_FLAG
| Clear tick interrupt status. More...
#define | RTC_CLEAR_TAMPER_FLAG(u32PinNum)
| Clear tamper detect pin status. More...
#define | RTC_GET_ALARM_INT_FLAG
| Get alarm interrupt status. More...
#define | RTC_GET_TICK_INT_FLAG
| Get alarm interrupt status. More...
#define | RTC_GET_TAMPER_FLAG(u32PinNum)
| Get tamper detect pin status. More...

## Functions
void | RTC_Open (S_RTC_TIME_DATA_T *sPt)
| This function is used to: More...
void | RTC_Close (void)
| Disable RTC clock. More...
void | RTC_32KCalibration (int32_t i32FrequencyX100)
| Set Frequency Compensation Data. More...
void | RTC_SetTickPeriod (uint32_t u32TickSelection)
| The function is used to set time tick period for periodic time tick Interrupt. More...
void | RTC_EnableInt (uint32_t u32IntFlagMask)
| The function is used to enable specified interrupt. More...
void | RTC_DisableInt (uint32_t u32IntFlagMask)
| The function is used to disable specified interrupt. More...
uint32_t | RTC_GetDayOfWeek (void)
| This function is used to get day of week. More...
void | RTC_DisableTamperDetection (uint32_t u32PinNumber)
| This function is used to disable tamper detection function. More...
void | RTC_EnableTamperDetection (uint32_t u32PinNumber, uint32_t u32PinCondition, uint32_t u32IntFlag, uint32_t u32ClearFlag, uint32_t u32DestroyEn)
| This function is used to: More...
int32_t | RTC_EnableSpareAccess (void)
| The spare registers access enable. More...
void | RTC_SetAlarmTime (uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
| This function is used to set alarm date to RTC. More...
void | RTC_SetAlarmDate (uint32_t u32Year, uint32_t u32Month, uint32_t u32Day)
| This function is used to set alarm date to RTC. More...
void | RTC_SetTime (uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm)
| This function is used to update time to RTC. More...
void | RTC_SetDate (uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek)
| This function is used to update date to RTC. More...
void | RTC_SetAlarmDateAndTime (S_RTC_TIME_DATA_T *sPt)
| This function is used to set alarm date/time to RTC. More...
void | RTC_SetDateAndTime (S_RTC_TIME_DATA_T *sPt)
| This function is used to update date/time to RTC. More...
void | RTC_GetAlarmDateAndTime (S_RTC_TIME_DATA_T *sPt)
| Read alarm date/time from RTC setting. More...
void | RTC_GetDateAndTime (S_RTC_TIME_DATA_T *sPt)
| Read current date/time from RTC setting. More...

## Variables
uint32_t | S_RTC_TIME_DATA_T::u32Year
uint32_t | S_RTC_TIME_DATA_T::u32Month
uint32_t | S_RTC_TIME_DATA_T::u32Day
uint32_t | S_RTC_TIME_DATA_T::u32DayOfWeek
uint32_t | S_RTC_TIME_DATA_T::u32Hour
uint32_t | S_RTC_TIME_DATA_T::u32Minute
uint32_t | S_RTC_TIME_DATA_T::u32Second
uint32_t | S_RTC_TIME_DATA_T::u32TimeScale
uint32_t | S_RTC_TIME_DATA_T::u32AmPm

## Detailed Description

## Macro Definition Documentation

## ◆ RTC_CLEAR_ALARM_INT_FLAG

#define RTC_CLEAR_ALARM_INT_FLAG

Clear alarm interrupt status.

Parameters

  None |

Returns
  None

Definition at line 146 of file rtc.h.

## ◆ RTC_CLEAR_TAMPER_FLAG

#define RTC_CLEAR_TAMPER_FLAG | ( |  | u32PinNum | ) |

Clear tamper detect pin status.

Parameters

  [in] | u32PinNum | tamper detect pin number. [ RTC_TAMPER_0 / RTC_TAMPER_1]

Returns
  None

Definition at line 166 of file rtc.h.

## ◆ RTC_CLEAR_TICK_INT_FLAG

#define RTC_CLEAR_TICK_INT_FLAG

Clear tick interrupt status.

Parameters

  None |

Returns
  None

Definition at line 156 of file rtc.h.

## ◆ RTC_GET_ALARM_INT_FLAG

#define RTC_GET_ALARM_INT_FLAG

Get alarm interrupt status.

Parameters

  None |

Returns
  Alarm interrupt status

Definition at line 176 of file rtc.h.

## ◆ RTC_GET_TAMPER_FLAG

#define RTC_GET_TAMPER_FLAG | ( |  | u32PinNum | ) |

Get tamper detect pin status.

Parameters

  [in] | u32PinNum | tamper detect pin number. [ RTC_TAMPER_0 / RTC_TAMPER_1]

Returns
  Tamper detect pin status

Definition at line 196 of file rtc.h.

## ◆ RTC_GET_TICK_INT_FLAG

#define RTC_GET_TICK_INT_FLAG

Get alarm interrupt status.

Parameters

  None |

Returns
  Alarm interrupt status

Definition at line 186 of file rtc.h.

## ◆ RTC_IS_LEAP_YEAR

#define RTC_IS_LEAP_YEAR

According to current time, return this year is leap year or not.

Parameters

  None |

Returns
  0 = This year is not a leap year.
  1 = This year is a leap year.

Definition at line 136 of file rtc.h.

## ◆ RTC_READ_SPARE_REGISTER

#define RTC_READ_SPARE_REGISTER | ( |  | u32RegNum | ) |

Read spare register.

Parameters

  [in] | u32RegNum | The spare register number(0~23)

Returns
  Spare register content.

Definition at line 114 of file rtc.h.

## ◆ RTC_WRITE_SPARE_REGISTER

#define RTC_WRITE_SPARE_REGISTER | ( |  | u32RegNum,
|  |  | u32RegValue
| ) |  |

Write spare register.

Parameters

  [in] | u32RegNum | The spare register number(0~23)
  [in] | u32RegValue | The spare register value

Returns
  None

Definition at line 125 of file rtc.h.

## Function Documentation

## ◆ RTC_32KCalibration()

void RTC_32KCalibration | ( | int32_t | i32FrequencyX100 | ) |

Set Frequency Compensation Data.

Parameters

  [in] | i32FrequencyX100 | Specify the RTC clock X100, ex: 3277365 means 32773.65.

Returns
  None

Definition at line 81 of file rtc.c.

## ◆ RTC_Close()

void RTC_Close | ( | void |  | ) |

Disable RTC clock.

Returns
  None

Definition at line 916 of file rtc.c.

## ◆ RTC_DisableInt()

void RTC_DisableInt | ( | uint32_t | u32IntFlagMask | ) |

The function is used to disable specified interrupt.

Parameters

  [in] | u32IntFlagMask | The structure of interrupt source. It consists of: RTC_INTEN_ALMIEN_Msk : Alarm interrupt RTC_INTEN_TICKIEN_Msk : Tick interrupt

Returns
  None

Definition at line 892 of file rtc.c.

## ◆ RTC_DisableTamperDetection()

void RTC_DisableTamperDetection | ( | uint32_t | u32PinNumber | ) |

This function is used to disable tamper detection function.

Parameters

  [in] | u32PinNumber | tamper detect pin number: RTC_TAMPER_0, RTC_TAMPER_1

Returns
  None

Definition at line 812 of file rtc.c.

## ◆ RTC_EnableInt()

void RTC_EnableInt | ( | uint32_t | u32IntFlagMask | ) |

The function is used to enable specified interrupt.

Parameters

  [in] | u32IntFlagMask | The structure of interrupt source. It consists of: RTC_INTEN_ALMIEN_Msk : Alarm interrupt RTC_INTEN_TICKIEN_Msk : Tick interrupt

Returns
  None

Definition at line 875 of file rtc.c.

## ◆ RTC_EnableSpareAccess()

int32_t RTC_EnableSpareAccess | ( | void |  | ) |

The spare registers access enable.

Return values

  0 | spare registers access enable
  -1 | spare registers access enable timeout

Definition at line 703 of file rtc.c.

## ◆ RTC_EnableTamperDetection()

void RTC_EnableTamperDetection | ( | uint32_t | u32PinNumber,
|  | uint32_t | u32PinCondition,
|  | uint32_t | u32IntFlag,
|  | uint32_t | u32ClearFlag,
|  | uint32_t | u32DestroyEn
| ) |  |

This function is used to:

1. Enable tamper detection function.
2. Set tamper detect pin number.
3. Set tamper control register, interrupt.
4. Clear tamper status.
5. Destroy Spare Register when tamper detected
   Parameters

     [in] | u32PinNumber | tamper detect pin number. [ RTC_TAMPER_0 / RTC_TAMPER_1]
     [in] | u32PinCondition | set tamper detection condition: 1=High level detect, 0=Low level detect
     [in] | u32IntFlag | Enable/Disable tamper interrupt: 1=Enable, 0=Disable
     [in] | u32ClearFlag | Clear tamper status
     [in] | u32DestroyEn | Enable/Disable Destroy Spare Register when tamper detected: 1=Enable, 0=Disable

   Returns
     None

Definition at line 741 of file rtc.c.

## ◆ RTC_GetAlarmDateAndTime()

void RTC_GetAlarmDateAndTime | ( | S_RTC_TIME_DATA_T * | sPt | ) |

Read alarm date/time from RTC setting.

Parameters

  [out] | sPt | Specify the time property and current time. It includes: u32Year: Year value u32Month: Month value u32Day: Day value u32DayOfWeek: Day of week u32Hour: Hour value u32Minute: Minute value u32Second: Second value u32TimeScale: RTC_CLOCK_12 / RTC_CLOCK_24 u8AmPm: RTC_AM / RTC_PM

Returns
  None

Definition at line 318 of file rtc.c.

## ◆ RTC_GetDateAndTime()

void RTC_GetDateAndTime | ( | S_RTC_TIME_DATA_T * | sPt | ) |

Read current date/time from RTC setting.

Parameters

  [out] | sPt | Specify the time property and current time. It includes: u32Year: Year value u32Month: Month value u32Day: Day value u32DayOfWeek: Day of week u32Hour: Hour value u32Minute: Minute value u32Second: Second value u32TimeScale: RTC_CLOCK_12 / RTC_CLOCK_24 u8AmPm: RTC_AM / RTC_PM

Returns
  None

Definition at line 224 of file rtc.c.

## ◆ RTC_GetDayOfWeek()

uint32_t RTC_GetDayOfWeek | ( | void |  | ) |

This function is used to get day of week.

Parameters

  None |

Returns
  Day of week

Definition at line 835 of file rtc.c.

## ◆ RTC_Open()

void RTC_Open | ( | S_RTC_TIME_DATA_T * | sPt | ) |

This function is used to:

1. Write initial key to let RTC start count.
2. Input parameter indicates start time.
   Null pointer for using default starting time.
   Parameters

     [in] | sPt | Specify the time property and current time. It includes: u32Year: Year value. u32Month: Month value. u32Day: Day value. u32DayOfWeek: Day of week. [ RTC_SUNDAY / RTC_MONDAY / RTC_TUESDAY / RTC_WEDNESDAY / RTC_THURSDAY / RTC_FRIDAY / RTC_SATURDAY] u32Hour: Hour value. u32Minute: Minute value. u32Second: Second value. u32TimeScale: [ RTC_CLOCK_12 / RTC_CLOCK_24] u8AmPm: [ RTC_AM / RTC_PM]

   Returns
     None

Definition at line 124 of file rtc.c.

## ◆ RTC_SetAlarmDate()

void RTC_SetAlarmDate | ( | uint32_t | u32Year,
|  | uint32_t | u32Month,
|  | uint32_t | u32Day
| ) |  |

This function is used to set alarm date to RTC.

Parameters

  [in] | u32Year | The Year Calendar Digit of Alarm Setting
  [in] | u32Month | The Month Calendar Digit of Alarm Setting
  [in] | u32Day | The Day Calendar Digit of Alarm Setting

Returns
  None

Definition at line 630 of file rtc.c.

## ◆ RTC_SetAlarmDateAndTime()

void RTC_SetAlarmDateAndTime | ( | S_RTC_TIME_DATA_T * | sPt | ) |

This function is used to set alarm date/time to RTC.

Parameters

  [in] | sPt | Specify the time property and current time. It includes: u32Year: Year value. u32Month: Month value. u32Day: Day value. u32DayOfWeek: Day of week. [ RTC_SUNDAY / RTC_MONDAY / RTC_TUESDAY / RTC_WEDNESDAY / RTC_THURSDAY / RTC_FRIDAY / RTC_SATURDAY] u32Hour: Hour value. u32Minute: Minute value. u32Second: Second value. u32TimeScale: [ RTC_CLOCK_12 / RTC_CLOCK_24] u8AmPm: [ RTC_AM / RTC_PM]

Returns
  None

Definition at line 489 of file rtc.c.

## ◆ RTC_SetAlarmTime()

void RTC_SetAlarmTime | ( | uint32_t | u32Hour,
|  | uint32_t | u32Minute,
|  | uint32_t | u32Second,
|  | uint32_t | u32TimeMode,
|  | uint32_t | u32AmPm
| ) |  |

This function is used to set alarm date to RTC.

Parameters

  [in] | u32Hour | The Hour Time Digit of Alarm Setting.
  [in] | u32Minute | The Minute Time Digit of Alarm Setting
  [in] | u32Second | The Second Time Digit of Alarm Setting
  [in] | u32TimeMode | The 24-Hour / 12-Hour Time Scale Selection. [ RTC_CLOCK_12 / RTC_CLOCK_24]
  [in] | u32AmPm | 12-hour time scale with AM and PM indication. Only Time Scale select 12-hour used. [ RTC_AM / RTC_PM]

Returns
  None

Definition at line 662 of file rtc.c.

## ◆ RTC_SetDate()

void RTC_SetDate | ( | uint32_t | u32Year,
|  | uint32_t | u32Month,
|  | uint32_t | u32Day,
|  | uint32_t | u32DayOfWeek
| ) |  |

This function is used to update date to RTC.

Parameters

  [in] | u32Year | The Year Calendar Digit of Alarm Setting
  [in] | u32Month | The Month Calendar Digit of Alarm Setting
  [in] | u32Day | The Day Calendar Digit of Alarm Setting
  [in] | u32DayOfWeek | The Day of Week. [ RTC_SUNDAY / RTC_MONDAY / RTC_TUESDAY / RTC_WEDNESDAY / RTC_THURSDAY / RTC_FRIDAY / RTC_SATURDAY]

Returns
  None

Definition at line 553 of file rtc.c.

## ◆ RTC_SetDateAndTime()

void RTC_SetDateAndTime | ( | S_RTC_TIME_DATA_T * | sPt | ) |

This function is used to update date/time to RTC.

Parameters

  [in] | sPt | Specify the time property and current time. It includes: u32Year: Year value. u32Month: Month value. u32Day: Day value. u32DayOfWeek: Day of week. [ RTC_SUNDAY / RTC_MONDAY / RTC_TUESDAY / RTC_WEDNESDAY / RTC_THURSDAY / RTC_FRIDAY / RTC_SATURDAY] u32Hour: Hour value. u32Minute: Minute value. u32Second: Second value. u32TimeScale: [ RTC_CLOCK_12 / RTC_CLOCK_24] u8AmPm: [ RTC_AM / RTC_PM]

Returns
  None

Definition at line 420 of file rtc.c.

## ◆ RTC_SetTickPeriod()

void RTC_SetTickPeriod | ( | uint32_t | u32TickSelection | ) |

The function is used to set time tick period for periodic time tick Interrupt.

Parameters

  [in] | u32TickSelection | It is used to set the RTC time tick period for Periodic Time Tick Interrupt request. It consists of: RTC_TICK_1_SEC : Time tick is 1 second RTC_TICK_1_2_SEC : Time tick is 1/2 second RTC_TICK_1_4_SEC : Time tick is 1/4 second RTC_TICK_1_8_SEC : Time tick is 1/8 second RTC_TICK_1_16_SEC : Time tick is 1/16 second RTC_TICK_1_32_SEC : Time tick is 1/32 second RTC_TICK_1_64_SEC : Time tick is 1/64 second RTC_TICK_1_128_SEC : Time tick is 1/128 second

Returns
  None

Definition at line 858 of file rtc.c.

## ◆ RTC_SetTime()

void RTC_SetTime | ( | uint32_t | u32Hour,
|  | uint32_t | u32Minute,
|  | uint32_t | u32Second,
|  | uint32_t | u32TimeMode,
|  | uint32_t | u32AmPm
| ) |  |

This function is used to update time to RTC.

Parameters

  [in] | u32Hour | The Hour Time Digit of Alarm Setting.
  [in] | u32Minute | The Month Calendar Digit of Alarm Setting
  [in] | u32Second | The Day Calendar Digit of Alarm Setting
  [in] | u32TimeMode | The 24-Hour / 12-Hour Time Scale Selection. [ RTC_CLOCK_12 / RTC_CLOCK_24]
  [in] | u32AmPm | 12-hour time scale with AM and PM indication. Only Time Scale select 12-hour used. [ RTC_AM / RTC_PM]

Returns
  None

Definition at line 587 of file rtc.c.

## Variable Documentation

## ◆ u32AmPm

uint32_t S_RTC_TIME_DATA_T::u32AmPm

Only Time Scale select 12-hr used

Definition at line 92 of file rtc.h.

## ◆ u32Day

uint32_t S_RTC_TIME_DATA_T::u32Day

Day value

Definition at line 86 of file rtc.h.

## ◆ u32DayOfWeek

uint32_t S_RTC_TIME_DATA_T::u32DayOfWeek

Day of week value

Definition at line 87 of file rtc.h.

## ◆ u32Hour

uint32_t S_RTC_TIME_DATA_T::u32Hour

Hour value

Definition at line 88 of file rtc.h.

## ◆ u32Minute

uint32_t S_RTC_TIME_DATA_T::u32Minute

Minute value

Definition at line 89 of file rtc.h.

## ◆ u32Month

uint32_t S_RTC_TIME_DATA_T::u32Month

Month value

Definition at line 85 of file rtc.h.

## ◆ u32Second

uint32_t S_RTC_TIME_DATA_T::u32Second

Second value

Definition at line 90 of file rtc.h.

## ◆ u32TimeScale

uint32_t S_RTC_TIME_DATA_T::u32TimeScale

12-Hour, 24-Hour

Definition at line 91 of file rtc.h.

## ◆ u32Year

uint32_t S_RTC_TIME_DATA_T::u32Year

Year value

Definition at line 84 of file rtc.h.