| NANO102/112 BSP V3.04.000 The Board Support Package for Nano102/112 Series

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

## Macros
#define | RTC_READ_SPARE_REGISTER(u32RegNum) (RTC->SPR[u32RegNum])
| Read spare register. More...
#define | RTC_WRITE_SPARE_REGISTER(u32RegNum, u32RegValue) (RTC->SPR[u32RegNum] = u32RegValue)
| Write spare register. More...
#define | RTC_IS_LEAP_YEAR() ((RTC->LIR & (RTC_LIR_LIR_Msk))?1:0)
| According to current time, return this year is leap year or not. More...
#define | RTC_CLEAR_ALARM_INT_FLAG() (RTC->RIIR = RTC_RIIR_AIF_Msk)
| Clear alarm interrupt status. More...
#define | RTC_CLEAR_TICK_INT_FLAG() (RTC->RIIR = RTC_RIIR_TIF_Msk)
| Clear tick interrupt status. More...
#define | RTC_GET_ALARM_INT_FLAG() ((RTC->RIIR & RTC_RIIR_AIF_Msk) >> RTC_RIIR_AIF_Pos)
| Get alarm interrupt status. More...
#define | RTC_CLEAR_TAMPER_FLAG(u32PinNum) (RTC->RIIR = RTC_RIIR_SNOOPIF_Msk)
| Clear tamper detect pin status. More...
#define | RTC_GET_TICK_INT_FLAG() ((RTC->RIIR & RTC_RIIR_TIF_Msk) >> RTC_RIIR_TIF_Pos)
| Get alarm interrupt status. More...
#define | RTC_GET_TAMPER_FLAG() ( (RTC->RIIR & RTC_RIIR_SNOOPIF_Msk) >> RTC_RIIR_SNOOPIF_Pos)
| Get tamper detect pin status. More...
#define | RTC_ENABLE_TICK_WAKEUP() (RTC->TTR |= RTC_TTR_TWKE_Msk);
| Enable Timer tick wakeup function. More...
#define | RTC_DISABLE_TICK_WAKEUP() (RTC->TTR &= ~RTC_TTR_TWKE_Msk);
| Disable Timer tick wakeup function. 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 i32FrequencyX10000)
| 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 (void)
| This function is used to disable tamper detection function. More...
void | RTC_EnableTamperDetection (uint32_t u32PinCondition)
| This function is used to: . 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 | ( |  | ) | (RTC->RIIR = RTC_RIIR_AIF_Msk)

Clear alarm interrupt status.

Parameters

  None |

Returns
  None

Definition at line 141 of file rtc.h.

## ◆ RTC_CLEAR_TAMPER_FLAG

#define RTC_CLEAR_TAMPER_FLAG | ( |  | u32PinNum | ) | (RTC->RIIR = RTC_RIIR_SNOOPIF_Msk)

Clear tamper detect pin status.

Parameters

  [in] | u32PinNum | tamper detect pin number.

Returns
  None

Definition at line 171 of file rtc.h.

## ◆ RTC_CLEAR_TICK_INT_FLAG

#define RTC_CLEAR_TICK_INT_FLAG | ( |  | ) | (RTC->RIIR = RTC_RIIR_TIF_Msk)

Clear tick interrupt status.

Parameters

  None |

Returns
  None

Definition at line 151 of file rtc.h.

## ◆ RTC_DISABLE_TICK_WAKEUP

#define RTC_DISABLE_TICK_WAKEUP | ( |  | ) | (RTC->TTR &= ~RTC_TTR_TWKE_Msk);

Disable Timer tick wakeup function.

Parameters

  None |

Returns
  None

Definition at line 212 of file rtc.h.

## ◆ RTC_ENABLE_TICK_WAKEUP

#define RTC_ENABLE_TICK_WAKEUP | ( |  | ) | (RTC->TTR |= RTC_TTR_TWKE_Msk);

Enable Timer tick wakeup function.

Parameters

  None |

Returns
  None

Definition at line 202 of file rtc.h.

## ◆ RTC_GET_ALARM_INT_FLAG

#define RTC_GET_ALARM_INT_FLAG | ( |  | ) | ((RTC->RIIR & RTC_RIIR_AIF_Msk) >> RTC_RIIR_AIF_Pos)

Get alarm interrupt status.

Parameters

  None |

Returns
  Alarm interrupt status

Definition at line 161 of file rtc.h.

## ◆ RTC_GET_TAMPER_FLAG

#define RTC_GET_TAMPER_FLAG | ( |  | ) | ( (RTC->RIIR & RTC_RIIR_SNOOPIF_Msk) >> RTC_RIIR_SNOOPIF_Pos)

Get tamper detect pin status.

Parameters

  None |

Returns
  1: Snooper Pin Event Detected
  0: Snooper Pin Event Never Detected

Definition at line 192 of file rtc.h.

## ◆ RTC_GET_TICK_INT_FLAG

#define RTC_GET_TICK_INT_FLAG | ( |  | ) | ((RTC->RIIR & RTC_RIIR_TIF_Msk) >> RTC_RIIR_TIF_Pos)

Get alarm interrupt status.

Parameters

  None |

Returns
  Alarm interrupt status

Definition at line 181 of file rtc.h.

## ◆ RTC_IS_LEAP_YEAR

#define RTC_IS_LEAP_YEAR | ( |  | ) | ((RTC->LIR & (RTC_LIR_LIR_Msk))?1:0)

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 131 of file rtc.h.

## ◆ RTC_READ_SPARE_REGISTER

#define RTC_READ_SPARE_REGISTER | ( |  | u32RegNum | ) | (RTC->SPR[u32RegNum])

Read spare register.

Parameters

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

Returns
  Spare register content.

Definition at line 109 of file rtc.h.

## ◆ RTC_WRITE_SPARE_REGISTER

#define RTC_WRITE_SPARE_REGISTER | ( |  | u32RegNum,
|  |  | u32RegValue
| ) |  | (RTC->SPR[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 120 of file rtc.h.

## Function Documentation

## ◆ RTC_32KCalibration()

void RTC_32KCalibration | ( | int32_t | i32FrequencyX10000 | ) |

Set Frequency Compensation Data.

Parameters

  [in] | i32FrequencyX10000 | Specify the RTC clock X10000, ex: 327736512 means 32773.6512.

Returns
  None

Definition at line 58 of file rtc.c.

## ◆ RTC_Close()

void RTC_Close | ( | void |  | ) |

Disable RTC clock.

Returns
  None

Definition at line 952 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_RIER_AIER_Msk : Alarm interrupt RTC_RIER_TIER_Msk : Tick interrupt RTC_RIER_SNOOPIER_Msk : Snooper Pin Event Detection Interrupt

Returns
  None

Definition at line 915 of file rtc.c.

## ◆ RTC_DisableTamperDetection()

void RTC_DisableTamperDetection | ( | void |  | ) |

This function is used to disable tamper detection function.

Parameters

  None |

Returns
  None

Definition at line 819 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_RIER_AIER_Msk : Alarm interrupt RTC_RIER_TIER_Msk : Tick interrupt RTC_RIER_SNOOPIER_Msk : Snooper Pin Event Detection Interrupt

Returns
  None

Definition at line 890 of file rtc.c.

## ◆ RTC_EnableTamperDetection()

void RTC_EnableTamperDetection | ( | uint32_t | u32PinCondition | ) |

This function is used to:
.

1. Enable tamper detection function.
2. Set tamper control register, interrupt.
   Parameters

     [in] | u32PinCondition | set tamper detection condition: 1=Falling detect, 0=Rising detect

   Returns
     None

Definition at line 790 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 316 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 223 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 841 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 106 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 692 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 513 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 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 735 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 593 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 428 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 865 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 638 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 90 of file rtc.h.

## ◆ u32Day

uint32_t S_RTC_TIME_DATA_T::u32Day

Day value

Definition at line 84 of file rtc.h.

## ◆ u32DayOfWeek

uint32_t S_RTC_TIME_DATA_T::u32DayOfWeek

Day of week value

Definition at line 85 of file rtc.h.

## ◆ u32Hour

uint32_t S_RTC_TIME_DATA_T::u32Hour

Hour value

Definition at line 86 of file rtc.h.

## ◆ u32Minute

uint32_t S_RTC_TIME_DATA_T::u32Minute

Minute value

Definition at line 87 of file rtc.h.

## ◆ u32Month

uint32_t S_RTC_TIME_DATA_T::u32Month

Month value

Definition at line 83 of file rtc.h.

## ◆ u32Second

uint32_t S_RTC_TIME_DATA_T::u32Second

Second value

Definition at line 88 of file rtc.h.

## ◆ u32TimeScale

uint32_t S_RTC_TIME_DATA_T::u32TimeScale

12-Hour, 24-Hour

Definition at line 89 of file rtc.h.

## ◆ u32Year

uint32_t S_RTC_TIME_DATA_T::u32Year

Year value

Definition at line 82 of file rtc.h.