MG32L003 Standard Peripherals Firmware Library
Modules | Data Structures | Macros | Functions

RTC driver modules. More...

Modules

 RTC_Exported_Constants
 
 RTC_Private_Functions
 

Data Structures

struct  RTC_TimeTypeDef
 RTC Time structure definition. More...
 
struct  RTC_DateTypeDef
 RTC Date structure definition. More...
 
struct  RTC_AlarmEnableTypeDef
 RTC ALARM Enable structure definition. More...
 
struct  RTC_AlarmTypeDef
 RTC Alarm structure definition. More...
 
struct  RTC_InitTypeDef
 RTC Init structures definition. More...
 
struct  RTC_HandleTypeDef
 Time Handle Structure definition. More...
 

Macros

#define RTC_TIME_RESERVED_MASK   ((uint32_t)0x073F7F7F)
 
#define RTC_DATE_RESERVED_MASK   ((uint32_t)0x00FF9F3F)
 
#define RTC_WeekDay_RESERVED_MASK   ((uint32_t)0x07000000)
 
#define RTC_INIT_MASK   ((uint32_t)RTC_ISR_WAIT_Msk)
 
#define RTC_ISR_INITF   ((uint32_t)RTC_ISR_WAITF)
 
#define RTC_ISR_INIT   ((uint32_t)RTC_ISR_WAIT)
 
#define RTC_RSF_MASK   ((uint32_t)0xFFFFFFFA)
 
#define RTC_FLAGS_MASK
 
#define INITMODE_TIMEOUT   ((uint32_t)0x00010000)
 
#define SYNCHRO_TIMEOUT   ((uint32_t)0x00020000)
 

Functions

ErrorStatus RTC_Init (RTC_InitTypeDef *RTC_InitStruct)
 Initializes the RTC registers according to the specified parameters in RTC_InitStruct. More...
 
void RTC_WriteProtectionCmd (FunctionalState NewState)
 Enables or disables the RTC registers write protection. More...
 
ErrorStatus RTC_EnterInitMode (void)
 Enters the RTC Initialization mode. More...
 
void RTC_ExitInitMode (void)
 Exits the RTC Initialization mode. More...
 
ErrorStatus RTC_WaitForSynchro (void)
 Waits until the RTC Time and Date registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock. More...
 
void RTC_BypassShadowCmd (FunctionalState NewState)
 Enables or Disables the Bypass Shadow feature. More...
 
ErrorStatus RTC_SetTime (uint32_t RTC_Format, RTC_TimeTypeDef *RTC_TimeStruct)
 Set the RTC current time. More...
 
void RTC_TimeStructInit (RTC_TimeTypeDef *RTC_TimeStruct)
 Fills each RTC_TimeStruct member with its default value (Time = 00h:00min:00sec). More...
 
void RTC_GetTime (uint32_t RTC_Format, RTC_TimeTypeDef *RTC_TimeStruct)
 Get the RTC current Time. More...
 
ErrorStatus RTC_SetDate (uint32_t RTC_Format, RTC_DateTypeDef *RTC_DateStruct)
 Set the RTC current date. More...
 
void RTC_DateStructInit (RTC_DateTypeDef *RTC_DateStruct)
 Fills each RTC_DateStruct member with its default value (Monday, January 01 xx00). More...
 
void RTC_GetDate (uint32_t RTC_Format, RTC_DateTypeDef *RTC_DateStruct)
 Get the RTC current date. More...
 
void RTC_SetAlarm1 (uint32_t RTC_Format, RTC_AlarmTypeDef *RTC_AlarmStruct)
 Set the specified RTC Alarm1. More...
 
void RTC_AlarmStructInit (RTC_AlarmTypeDef *RTC_AlarmStruct)
 
void RTC_Alarm1Cmd (FunctionalState NewState)
 Enables or disables the specified RTC Alarm. More...
 
void RTC_GetAlarm1 (uint32_t RTC_Format, RTC_AlarmTypeDef *RTC_AlarmStruct)
 Get the RTC Alarm value and masks. More...
 
ErrorStatus RTC_AlarmCmd (uint32_t RTC_Alarm, FunctionalState NewState)
 
void RTC_SetALARM2Period (uint32_t Period)
 Set the specified RTC Alarm2. More...
 
void RTC_1HZ_Config (FunctionalState NewState)
 Deactive the specified 1HZ out. More...
 
void RTC_CalibConfig (uint32_t RTC_CalibPeriod, uint32_t RTC_CalibMinusPulsesValue)
 Configures the Calibration Settings. More...
 
void RTC_ITConfig (uint32_t RTC_IT, FunctionalState NewState)
 Enables or disables the specified RTC interrupts. More...
 
ITStatus RTC_GetITStatus (uint32_t RTC_IT)
 
void RTC_ClearITPendingBit (uint32_t RTC_IT)
 Clears the RTC's interrupt pending bits. More...
 

Detailed Description

RTC driver modules.

Macro Definition Documentation

◆ RTC_FLAGS_MASK

#define RTC_FLAGS_MASK
Value:
((uint32_t)(RTC_FLAG_ALR2F | RTC_FLAG_ALR1F | RTC_FLAG_RSF | \
RTC_FLAG_WAITF | RTC_FLAG_WAIT))

Function Documentation

◆ RTC_1HZ_Config()

void RTC_1HZ_Config ( FunctionalState  NewState)

Deactive the specified 1HZ out.

Parameters
NewStatethe 1HZ out enable or disable. This parameter can be one of the following values:
  • DISABLE
  • ENABLE
Return values
None

◆ RTC_Alarm1Cmd()

void RTC_Alarm1Cmd ( FunctionalState  NewState)

Enables or disables the specified RTC Alarm.

Parameters
NewStatenew state of the specified alarm. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ RTC_BypassShadowCmd()

void RTC_BypassShadowCmd ( FunctionalState  NewState)

Enables or Disables the Bypass Shadow feature.

Note
When the Bypass Shadow is enabled the calendar value are taken directly from the Calendar counter.
Parameters
NewStatenew state of the Bypass Shadow feature. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ RTC_CalibConfig()

void RTC_CalibConfig ( uint32_t  RTC_CalibPeriod,
uint32_t  RTC_CalibMinusPulsesValue 
)

Configures the Calibration Settings.

Parameters
RTC_CalibPeriod:
RTC_CalibMinusPulsesValue
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RTC Calib registers are configured.
  • ERROR: RTC Calib registers are not configured.

◆ RTC_ClearITPendingBit()

void RTC_ClearITPendingBit ( uint32_t  RTC_IT)

Clears the RTC's interrupt pending bits.

Parameters
RTC_ITspecifies the RTC interrupt pending bit to clear. This parameter can be any combination of the following values:
  • RTC_IT_ALR2: Alarm 2 interrupt.
  • RTC_IT_ALR1: Alarm 1 interrupt.
Return values
None

◆ RTC_DateStructInit()

void RTC_DateStructInit ( RTC_DateTypeDef RTC_DateStruct)

Fills each RTC_DateStruct member with its default value (Monday, January 01 xx00).

Parameters
RTC_DateStructpointer to a RTC_DateTypeDef structure which will be initialized.
Return values
None

◆ RTC_EnterInitMode()

ErrorStatus RTC_EnterInitMode ( void  )

Enters the RTC Initialization mode.

Note
The RTC Initialization mode is write protected, use the RTC_WriteProtectionCmd(DISABLE) before calling this function.
Parameters
None
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RTC is in Init mode.
  • ERROR: RTC is not in Init mode.

◆ RTC_ExitInitMode()

void RTC_ExitInitMode ( void  )

Exits the RTC Initialization mode.

Note
When the initialization sequence is complete, the calendar restarts counting after 4 RTCCLK cycles.
The RTC Initialization mode is write protected, use the RTC_WriteProtectionCmd(DISABLE) before calling this function.
Parameters
None
Return values
None

◆ RTC_GetAlarm1()

void RTC_GetAlarm1 ( uint32_t  RTC_Format,
RTC_AlarmTypeDef RTC_AlarmStruct 
)

Get the RTC Alarm value and masks.

Parameters
RTC_Formatspecifies the format of the output parameters. This parameter can be one of the following values:
  • RTC_Format_BIN: Binary data format.
  • RTC_Format_BCD: BCD data format.
RTC_AlarmStructpointer to a RTC_AlarmTypeDef structure that will contains the output alarm configuration values.
Return values
None

◆ RTC_GetDate()

void RTC_GetDate ( uint32_t  RTC_Format,
RTC_DateTypeDef RTC_DateStruct 
)

Get the RTC current date.

Parameters
RTC_Formatspecifies the format of the returned parameters. This parameter can be one of the following values:
  • RTC_Format_BIN: Binary data format.
  • RTC_Format_BCD: BCD data format.
RTC_DateStructpointer to a RTC_DateTypeDef structure that will contain the returned current date configuration.
Return values
None

◆ RTC_GetTime()

void RTC_GetTime ( uint32_t  RTC_Format,
RTC_TimeTypeDef RTC_TimeStruct 
)

Get the RTC current Time.

Parameters
RTC_Formatspecifies the format of the returned parameters. This parameter can be one of the following values:
  • RTC_Format_BIN: Binary data format.
  • RTC_Format_BCD: BCD data format.
RTC_TimeStructpointer to a RTC_TimeTypeDef structure that will contain the returned current time configuration.
Return values
None

◆ RTC_Init()

ErrorStatus RTC_Init ( RTC_InitTypeDef RTC_InitStruct)

Initializes the RTC registers according to the specified parameters in RTC_InitStruct.

Parameters
RTC_InitStructpointer to a RTC_InitTypeDef structure that contains the configuration information for the RTC peripheral.
Note
The RTC Prescaler register is write protected and can be written in initialization mode only.
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RTC registers are initialized.
  • ERROR: RTC registers are not initialized.

◆ RTC_ITConfig()

void RTC_ITConfig ( uint32_t  RTC_IT,
FunctionalState  NewState 
)

Enables or disables the specified RTC interrupts.

Parameters
RTC_ITspecifies the RTC interrupt sources to be enabled or disabled. This parameter can be any combination of the following values:
  • RTC_IT_ALR2: Alarm 2 interrupt.
  • RTC_IT_ALR1: Alarm 1 interrupt.
NewStatenew state of the specified RTC interrupts. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ RTC_SetAlarm1()

void RTC_SetAlarm1 ( uint32_t  RTC_Format,
RTC_AlarmTypeDef RTC_AlarmStruct 
)

Set the specified RTC Alarm1.

Note
The Alarm1 register can only be written when the corresponding Alarm is disabled (Use the RTC_AlarmCmd(DISABLE)).
Parameters
RTC_Formatspecifies the format of the returned parameters. This parameter can be one of the following values:
  • RTC_Format_BIN: Binary data format.
  • RTC_Format_BCD: BCD data format.
RTC_AlarmStructpointer to a RTC_AlarmTypeDef structure that contains the alarm configuration parameters.
Return values
None

◆ RTC_SetALARM2Period()

void RTC_SetALARM2Period ( uint32_t  Period)

Set the specified RTC Alarm2.

Parameters
Periodthe Alarm2 cycle time set. This parameter can be a value of Definitions
Return values
None

◆ RTC_SetDate()

ErrorStatus RTC_SetDate ( uint32_t  RTC_Format,
RTC_DateTypeDef RTC_DateStruct 
)

Set the RTC current date.

Parameters
RTC_Formatspecifies the format of the entered parameters. This parameter can be one of the following values:
  • RTC_Format_BIN: Binary data format.
  • RTC_Format_BCD: BCD data format.
RTC_DateStructpointer to a RTC_DateTypeDef structure that contains the date configuration information for the RTC.
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RTC Date register is configured.
  • ERROR: RTC Date register is not configured.

◆ RTC_SetTime()

ErrorStatus RTC_SetTime ( uint32_t  RTC_Format,
RTC_TimeTypeDef RTC_TimeStruct 
)

Set the RTC current time.

Parameters
RTC_Formatspecifies the format of the entered parameters. This parameter can be one of the following values:
  • RTC_Format_BIN: Binary data format.
  • RTC_Format_BCD: BCD data format.
RTC_TimeStructpointer to a RTC_TimeTypeDef structure that contains the time configuration information for the RTC.
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RTC Time register is configured.
  • ERROR: RTC Time register is not configured.

◆ RTC_TimeStructInit()

void RTC_TimeStructInit ( RTC_TimeTypeDef RTC_TimeStruct)

Fills each RTC_TimeStruct member with its default value (Time = 00h:00min:00sec).

Parameters
RTC_TimeStructpointer to a RTC_TimeTypeDef structure which will be initialized.
Return values
None

◆ RTC_WaitForSynchro()

ErrorStatus RTC_WaitForSynchro ( void  )

Waits until the RTC Time and Date registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock.

Note
The RTC Resynchronization mode is write protected, use the RTC_WriteProtectionCmd(DISABLE) before calling this function.
Parameters
None
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RTC registers are synchronised.
  • ERROR: RTC registers are not synchronised.

◆ RTC_WriteProtectionCmd()

void RTC_WriteProtectionCmd ( FunctionalState  NewState)

Enables or disables the RTC registers write protection.

Note
Writing a wrong key reactivates the write protection.
The protection mechanism is not affected by system reset.
Parameters
NewStatenew state of the write protection. This parameter can be: ENABLE or DISABLE.
Return values
None