STM32F0 Standard Peripheral bibliotheek  1.0
ST Microelectronics standard peripheral bibliotheek documentatie voor de STM32F0 familie
 All Data Structures Files Functions Variables Enumerations Enumerator Groups

RTC driver modules. More...

Modules

 RTC_Exported_Constants
 
 RTC_Private_Functions
 

Data Structures

struct  RTC_InitTypeDef
 RTC Init structures definition. More...
 
struct  RTC_TimeTypeDef
 RTC Time structure definition. More...
 
struct  RTC_DateTypeDef
 RTC Date structure definition. More...
 
struct  RTC_AlarmTypeDef
 RTC Alarm structure definition. More...
 

Macros

#define RTC_TR_RESERVED_MASK   ((uint32_t)0x007F7F7F)
 
#define RTC_DR_RESERVED_MASK   ((uint32_t)0x00FFFF3F)
 
#define RTC_INIT_MASK   ((uint32_t)0xFFFFFFFF)
 
#define RTC_RSF_MASK   ((uint32_t)0xFFFFFF5F)
 
#define RTC_FLAGS_MASK
 
#define INITMODE_TIMEOUT   ((uint32_t) 0x00004000)
 
#define SYNCHRO_TIMEOUT   ((uint32_t) 0x00008000)
 
#define RECALPF_TIMEOUT   ((uint32_t) 0x00001000)
 
#define SHPF_TIMEOUT   ((uint32_t) 0x00001000)
 

Functions

ErrorStatus RTC_DeInit (void)
 Deinitializes the RTC registers to their default reset values. More...
 
ErrorStatus RTC_Init (RTC_InitTypeDef *RTC_InitStruct)
 Initializes the RTC registers according to the specified parameters in RTC_InitStruct. More...
 
void RTC_StructInit (RTC_InitTypeDef *RTC_InitStruct)
 Fills each RTC_InitStruct member with its default value. 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...
 
ErrorStatus RTC_RefClockCmd (FunctionalState NewState)
 Enables or disables the RTC reference clock detection. 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...
 
uint32_t RTC_GetSubSecond (void)
 Gets the RTC current Calendar Subseconds value. 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_SetAlarm (uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef *RTC_AlarmStruct)
 Set the specified RTC Alarm. More...
 
void RTC_AlarmStructInit (RTC_AlarmTypeDef *RTC_AlarmStruct)
 Fills each RTC_AlarmStruct member with its default value (Time = 00h:00mn:00sec / Date = 1st day of the month/Mask = all fields are masked). More...
 
void RTC_GetAlarm (uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef *RTC_AlarmStruct)
 Get the RTC Alarm value and masks. More...
 
ErrorStatus RTC_AlarmCmd (uint32_t RTC_Alarm, FunctionalState NewState)
 Enables or disables the specified RTC Alarm. More...
 
void RTC_AlarmSubSecondConfig (uint32_t RTC_Alarm, uint32_t RTC_AlarmSubSecondValue, uint8_t RTC_AlarmSubSecondMask)
 Configure the RTC AlarmA/B Subseconds value and mask. More...
 
uint32_t RTC_GetAlarmSubSecond (uint32_t RTC_Alarm)
 Gets the RTC Alarm Subseconds value. More...
 
void RTC_DayLightSavingConfig (uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation)
 Adds or substract one hour from the current time. More...
 
uint32_t RTC_GetStoreOperation (void)
 Returns the RTC Day Light Saving stored operation. More...
 
void RTC_OutputConfig (uint32_t RTC_Output, uint32_t RTC_OutputPolarity)
 Configures the RTC output source (AFO_ALARM). More...
 
void RTC_CalibOutputCmd (FunctionalState NewState)
 Enables or disables the RTC clock to be output through the relative pin. More...
 
void RTC_CalibOutputConfig (uint32_t RTC_CalibOutput)
 Configure the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz). More...
 
ErrorStatus RTC_SmoothCalibConfig (uint32_t RTC_SmoothCalibPeriod, uint32_t RTC_SmoothCalibPlusPulses, uint32_t RTC_SmouthCalibMinusPulsesValue)
 Configures the Smooth Calibration Settings. More...
 
void RTC_TimeStampCmd (uint32_t RTC_TimeStampEdge, FunctionalState NewState)
 Enables or Disables the RTC TimeStamp functionality with the specified time stamp pin stimulating edge. More...
 
void RTC_GetTimeStamp (uint32_t RTC_Format, RTC_TimeTypeDef *RTC_StampTimeStruct, RTC_DateTypeDef *RTC_StampDateStruct)
 Get the RTC TimeStamp value and masks. More...
 
uint32_t RTC_GetTimeStampSubSecond (void)
 Get the RTC timestamp Subseconds value. More...
 
void RTC_TamperTriggerConfig (uint32_t RTC_Tamper, uint32_t RTC_TamperTrigger)
 Configures the select Tamper pin edge. More...
 
void RTC_TamperCmd (uint32_t RTC_Tamper, FunctionalState NewState)
 Enables or Disables the Tamper detection. More...
 
void RTC_TamperFilterConfig (uint32_t RTC_TamperFilter)
 Configures the Tampers Filter. More...
 
void RTC_TamperSamplingFreqConfig (uint32_t RTC_TamperSamplingFreq)
 Configures the Tampers Sampling Frequency. More...
 
void RTC_TamperPinsPrechargeDuration (uint32_t RTC_TamperPrechargeDuration)
 Configures the Tampers Pins input Precharge Duration. More...
 
void RTC_TimeStampOnTamperDetectionCmd (FunctionalState NewState)
 Enables or Disables the TimeStamp on Tamper Detection Event. More...
 
void RTC_TamperPullUpCmd (FunctionalState NewState)
 Enables or Disables the Precharge of Tamper pin. More...
 
void RTC_WriteBackupRegister (uint32_t RTC_BKP_DR, uint32_t Data)
 Writes a data in a specified RTC Backup data register. More...
 
uint32_t RTC_ReadBackupRegister (uint32_t RTC_BKP_DR)
 Reads data from the specified RTC Backup data Register. More...
 
void RTC_OutputTypeConfig (uint32_t RTC_OutputType)
 Configures the RTC Output Pin mode. More...
 
ErrorStatus RTC_SynchroShiftConfig (uint32_t RTC_ShiftAdd1S, uint32_t RTC_ShiftSubFS)
 Configures the Synchronization Shift Control Settings. More...
 
void RTC_ITConfig (uint32_t RTC_IT, FunctionalState NewState)
 Enables or disables the specified RTC interrupts. More...
 
FlagStatus RTC_GetFlagStatus (uint32_t RTC_FLAG)
 Checks whether the specified RTC flag is set or not. More...
 
void RTC_ClearFlag (uint32_t RTC_FLAG)
 Clears the RTC's pending flags. More...
 
ITStatus RTC_GetITStatus (uint32_t RTC_IT)
 Checks whether the specified RTC interrupt has occurred or not. More...
 
void RTC_ClearITPendingBit (uint32_t RTC_IT)
 Clears the RTC's interrupt pending bits. More...
 

Detailed Description

RTC driver modules.

Macro Definition Documentation

#define RTC_FLAGS_MASK
Value:
((uint32_t)(RTC_FLAG_TSOVF | RTC_FLAG_TSF | RTC_FLAG_ALRAF | \
RTC_FLAG_RSF | RTC_FLAG_INITS |RTC_FLAG_INITF | \
RTC_FLAG_TAMP1F | RTC_FLAG_TAMP2F | RTC_FLAG_RECALPF | \
RTC_FLAG_SHPF))

Function Documentation

ErrorStatus RTC_AlarmCmd ( uint32_t  RTC_Alarm,
FunctionalState  NewState 
)

Enables or disables the specified RTC Alarm.

Parameters
RTC_Alarm,:specifies the alarm to be configured. This parameter can be any combination of the following values:
  • RTC_Alarm_A: to select Alarm A
NewState,:new state of the specified alarm. This parameter can be: ENABLE or DISABLE.
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RTC Alarm is enabled/disabled
  • ERROR: RTC Alarm is not enabled/disabled
void RTC_AlarmStructInit ( RTC_AlarmTypeDef RTC_AlarmStruct)

Fills each RTC_AlarmStruct member with its default value (Time = 00h:00mn:00sec / Date = 1st day of the month/Mask = all fields are masked).

Parameters
RTC_AlarmStruct,:pointer to a RTC_AlarmTypeDef structure which will be initialized.
Return values
None
void RTC_AlarmSubSecondConfig ( uint32_t  RTC_Alarm,
uint32_t  RTC_AlarmSubSecondValue,
uint8_t  RTC_AlarmSubSecondMask 
)

Configure the RTC AlarmA/B Subseconds value and mask.

Note
This function is performed only when the Alarm is disabled.
Parameters
RTC_Alarm,:specifies the alarm to be configured. This parameter can be one of the following values:
  • RTC_Alarm_A: to select Alarm A
RTC_AlarmSubSecondValue,:specifies the Subseconds value. This parameter can be a value from 0 to 0x00007FFF.
RTC_AlarmSubSecondMask,:specifies the Subseconds Mask. This parameter can be any combination of the following values:
  • RTC_AlarmSubSecondMask_All: All Alarm SS fields are masked. There is no comparison on sub seconds for Alarm.
  • RTC_AlarmSubSecondMask_SS14_1: SS[14:1] are don't care in Alarm comparison. Only SS[0] is compared
  • RTC_AlarmSubSecondMask_SS14_2: SS[14:2] are don't care in Alarm comparison. Only SS[1:0] are compared
  • RTC_AlarmSubSecondMask_SS14_3: SS[14:3] are don't care in Alarm comparison. Only SS[2:0] are compared
  • RTC_AlarmSubSecondMask_SS14_4: SS[14:4] are don't care in Alarm comparison. Only SS[3:0] are compared
  • RTC_AlarmSubSecondMask_SS14_5: SS[14:5] are don't care in Alarm comparison. Only SS[4:0] are compared
  • RTC_AlarmSubSecondMask_SS14_6: SS[14:6] are don't care in Alarm comparison. Only SS[5:0] are compared
  • RTC_AlarmSubSecondMask_SS14_7: SS[14:7] are don't care in Alarm comparison. Only SS[6:0] are compared
  • RTC_AlarmSubSecondMask_SS14_8: SS[14:8] are don't care in Alarm comparison. Only SS[7:0] are compared
  • RTC_AlarmSubSecondMask_SS14_9: SS[14:9] are don't care in Alarm comparison. Only SS[8:0] are compared
  • RTC_AlarmSubSecondMask_SS14_10: SS[14:10] are don't care in Alarm comparison. Only SS[9:0] are compared
  • RTC_AlarmSubSecondMask_SS14_11: SS[14:11] are don't care in Alarm comparison. Only SS[10:0] are compared
  • RTC_AlarmSubSecondMask_SS14_12: SS[14:12] are don't care in Alarm comparison. Only SS[11:0] are compared
  • RTC_AlarmSubSecondMask_SS14_13: SS[14:13] are don't care in Alarm comparison. Only SS[12:0] are compared
  • RTC_AlarmSubSecondMask_SS14: SS[14] is don't care in Alarm comparison. Only SS[13:0] are compared
  • RTC_AlarmSubSecondMask_None: SS[14:0] are compared and must match to activate alarm
Return values
None
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
NewState,:new state of the Bypass Shadow feature. This parameter can be: ENABLE or DISABLE.
Return values
None
void RTC_CalibOutputCmd ( FunctionalState  NewState)

Enables or disables the RTC clock to be output through the relative pin.

Parameters
NewState,:new state of the digital calibration Output. This parameter can be: ENABLE or DISABLE.
Return values
None
void RTC_CalibOutputConfig ( uint32_t  RTC_CalibOutput)

Configure the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).

Parameters
RTC_CalibOutput,:Select the Calibration output Selection . This parameter can be one of the following values:
  • RTC_CalibOutput_512Hz: A signal has a regular waveform at 512Hz.
  • RTC_CalibOutput_1Hz: A signal has a regular waveform at 1Hz.
Return values
None
void RTC_ClearFlag ( uint32_t  RTC_FLAG)

Clears the RTC's pending flags.

Parameters
RTC_FLAG,:specifies the RTC flag to clear. This parameter can be any combination of the following values:
  • RTC_FLAG_TAMP2F: Tamper 2 event flag
  • RTC_FLAG_TAMP1F: Tamper 1 event flag
  • RTC_FLAG_TSOVF: Time Stamp Overflow flag
  • RTC_FLAG_TSF: Time Stamp event flag
  • RTC_FLAG_ALRAF: Alarm A flag
  • RTC_FLAG_RSF: Registers Synchronized flag
Return values
None
void RTC_ClearITPendingBit ( uint32_t  RTC_IT)

Clears the RTC's interrupt pending bits.

Parameters
RTC_IT,:specifies the RTC interrupt pending bit to clear. This parameter can be any combination of the following values:
  • RTC_IT_TS: Time Stamp interrupt
  • RTC_IT_ALRA: Alarm A interrupt
  • RTC_IT_TAMP1: Tamper1 event interrupt
  • RTC_IT_TAMP2: Tamper2 event interrupt
Return values
None
void RTC_DateStructInit ( RTC_DateTypeDef RTC_DateStruct)

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

Parameters
RTC_DateStruct,:pointer to a RTC_DateTypeDef structure which will be initialized.
Return values
None
void RTC_DayLightSavingConfig ( uint32_t  RTC_DayLightSaving,
uint32_t  RTC_StoreOperation 
)

Adds or substract one hour from the current time.

Parameters
RTC_DayLightSaveOperation,:the value of hour adjustment. This parameter can be one of the following values:
  • RTC_DayLightSaving_SUB1H: Substract one hour (winter time)
  • RTC_DayLightSaving_ADD1H: Add one hour (summer time)
RTC_StoreOperation,:Specifies the value to be written in the BCK bit in CR register to store the operation. This parameter can be one of the following values:
  • RTC_StoreOperation_Reset: BCK Bit Reset
  • RTC_StoreOperation_Set: BCK Bit Set
Return values
None
ErrorStatus RTC_DeInit ( void  )

Deinitializes the RTC registers to their default reset values.

Note
This function doesn't reset the RTC Clock source and RTC Backup Data registers.
Parameters
None
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RTC registers are deinitialized
  • ERROR: RTC registers are not deinitialized
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
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
void RTC_GetAlarm ( uint32_t  RTC_Format,
uint32_t  RTC_Alarm,
RTC_AlarmTypeDef RTC_AlarmStruct 
)

Get the RTC Alarm value and masks.

Parameters
RTC_Format,:specifies 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_Alarm,:specifies the alarm to be read. This parameter can be one of the following values:
  • RTC_Alarm_A: to select Alarm A
RTC_AlarmStruct,:pointer to a RTC_AlarmTypeDef structure that will contains the output alarm configuration values.
Return values
None
uint32_t RTC_GetAlarmSubSecond ( uint32_t  RTC_Alarm)

Gets the RTC Alarm Subseconds value.

Parameters
RTC_Alarm,:specifies the alarm to be read. This parameter can be one of the following values:
  • RTC_Alarm_A: to select Alarm A
None
Return values
RTCAlarm Subseconds value.
void RTC_GetDate ( uint32_t  RTC_Format,
RTC_DateTypeDef RTC_DateStruct 
)

Get the RTC current date.

Parameters
RTC_Format,:specifies 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_DateStruct,:pointer to a RTC_DateTypeDef structure that will contain the returned current date configuration.
Return values
None
FlagStatus RTC_GetFlagStatus ( uint32_t  RTC_FLAG)

Checks whether the specified RTC flag is set or not.

Parameters
RTC_FLAG,:specifies the flag to check. This parameter can be one of the following values:
  • RTC_FLAG_RECALPF: RECALPF event flag
  • RTC_FLAG_TAMP2F: Tamper 2 event flag
  • RTC_FLAG_TAMP1F: Tamper 1 event flag
  • RTC_FLAG_TSOVF: Time Stamp OverFlow flag
  • RTC_FLAG_TSF: Time Stamp event flag
  • RTC_FLAG_ALRAF: Alarm A flag
  • RTC_FLAG_INITF: Initialization mode flag
  • RTC_FLAG_RSF: Registers Synchronized flag
  • RTC_FLAG_INITS: Registers Configured flag
Return values
Thenew state of RTC_FLAG (SET or RESET).
ITStatus RTC_GetITStatus ( uint32_t  RTC_IT)

Checks whether the specified RTC interrupt has occurred or not.

Parameters
RTC_IT,:specifies the RTC interrupt source to check. This parameter can be one of the following values:
  • RTC_IT_TS: Time Stamp interrupt
  • RTC_IT_ALRA: Alarm A interrupt
  • RTC_IT_TAMP1: Tamper1 event interrupt
  • RTC_IT_TAMP2: Tamper2 event interrupt
Return values
Thenew state of RTC_IT (SET or RESET).
uint32_t RTC_GetStoreOperation ( void  )

Returns the RTC Day Light Saving stored operation.

Parameters
None
Return values
RTCDay Light Saving stored operation.
  • RTC_StoreOperation_Reset
  • RTC_StoreOperation_Set
uint32_t RTC_GetSubSecond ( void  )

Gets the RTC current Calendar Subseconds value.

Note
This function freeze the Time and Date registers after reading the SSR register.
Parameters
None
Return values
RTCcurrent Calendar Subseconds value.
void RTC_GetTime ( uint32_t  RTC_Format,
RTC_TimeTypeDef RTC_TimeStruct 
)

Get the RTC current Time.

Parameters
RTC_Format,:specifies 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_TimeStruct,:pointer to a RTC_TimeTypeDef structure that will contain the returned current time configuration.
Return values
None
void RTC_GetTimeStamp ( uint32_t  RTC_Format,
RTC_TimeTypeDef RTC_StampTimeStruct,
RTC_DateTypeDef RTC_StampDateStruct 
)

Get the RTC TimeStamp value and masks.

Parameters
RTC_Format,:specifies 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_StampTimeStruct,:pointer to a RTC_TimeTypeDef structure that will contains the TimeStamp time values.
RTC_StampDateStruct,:pointer to a RTC_DateTypeDef structure that will contains the TimeStamp date values.
Return values
None
uint32_t RTC_GetTimeStampSubSecond ( void  )

Get the RTC timestamp Subseconds value.

Parameters
None
Return values
RTCcurrent timestamp Subseconds value.
ErrorStatus RTC_Init ( RTC_InitTypeDef RTC_InitStruct)

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

Parameters
RTC_InitStruct,:pointer 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
void RTC_ITConfig ( uint32_t  RTC_IT,
FunctionalState  NewState 
)

Enables or disables the specified RTC interrupts.

Parameters
RTC_IT,:specifies the RTC interrupt sources to be enabled or disabled. This parameter can be any combination of the following values:
  • RTC_IT_TS: Time Stamp interrupt mask
  • RTC_IT_ALRA: Alarm A interrupt mask
  • RTC_IT_TAMP: Tamper event interrupt mask
NewState,:new state of the specified RTC interrupts. This parameter can be: ENABLE or DISABLE.
Return values
None
void RTC_OutputConfig ( uint32_t  RTC_Output,
uint32_t  RTC_OutputPolarity 
)

Configures the RTC output source (AFO_ALARM).

Parameters
RTC_Output,:Specifies which signal will be routed to the RTC output. This parameter can be one of the following values:
  • RTC_Output_Disable: No output selected
  • RTC_Output_AlarmA: signal of AlarmA mapped to output
RTC_OutputPolarity,:Specifies the polarity of the output signal. This parameter can be one of the following:
  • RTC_OutputPolarity_High: The output pin is high when the ALRAF is high (depending on OSEL)
  • RTC_OutputPolarity_Low: The output pin is low when the ALRAF is high (depending on OSEL)
Return values
None
void RTC_OutputTypeConfig ( uint32_t  RTC_OutputType)

Configures the RTC Output Pin mode.

Parameters
RTC_OutputType,:specifies the RTC Output (PC13) pin mode. This parameter can be one of the following values:
  • RTC_OutputType_OpenDrain: RTC Output (PC13) is configured in Open Drain mode.
  • RTC_OutputType_PushPull: RTC Output (PC13) is configured in Push Pull mode.
Return values
None
uint32_t RTC_ReadBackupRegister ( uint32_t  RTC_BKP_DR)

Reads data from the specified RTC Backup data Register.

Parameters
RTC_BKP_DR,:RTC Backup data Register number. This parameter can be: RTC_BKP_DRx where x can be from 0 to 19 to specify the register.
Return values
None
ErrorStatus RTC_RefClockCmd ( FunctionalState  NewState)

Enables or disables the RTC reference clock detection.

Parameters
NewState,:new state of the RTC reference clock. This parameter can be: ENABLE or DISABLE.
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RTC reference clock detection is enabled
  • ERROR: RTC reference clock detection is disabled
void RTC_SetAlarm ( uint32_t  RTC_Format,
uint32_t  RTC_Alarm,
RTC_AlarmTypeDef RTC_AlarmStruct 
)

Set the specified RTC Alarm.

Note
The Alarm register can only be written when the corresponding Alarm is disabled (Use the RTC_AlarmCmd(DISABLE)).
Parameters
RTC_Format,:specifies 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_Alarm,:specifies the alarm to be configured. This parameter can be one of the following values:
  • RTC_Alarm_A: to select Alarm A
RTC_AlarmStruct,:pointer to a RTC_AlarmTypeDef structure that contains the alarm configuration parameters.
Return values
None
ErrorStatus RTC_SetDate ( uint32_t  RTC_Format,
RTC_DateTypeDef RTC_DateStruct 
)

Set the RTC current date.

Parameters
RTC_Format,:specifies 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_DateStruct,:pointer 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
ErrorStatus RTC_SetTime ( uint32_t  RTC_Format,
RTC_TimeTypeDef RTC_TimeStruct 
)

Set the RTC current time.

Parameters
RTC_Format,:specifies 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_TimeStruct,:pointer 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
ErrorStatus RTC_SmoothCalibConfig ( uint32_t  RTC_SmoothCalibPeriod,
uint32_t  RTC_SmoothCalibPlusPulses,
uint32_t  RTC_SmouthCalibMinusPulsesValue 
)

Configures the Smooth Calibration Settings.

Parameters
RTC_SmoothCalibPeriod,:Select the Smooth Calibration Period. This parameter can be can be one of the following values:
  • RTC_SmoothCalibPeriod_32sec: The smooth calibration periode is 32s.
  • RTC_SmoothCalibPeriod_16sec: The smooth calibration periode is 16s.
  • RTC_SmoothCalibPeriod_8sec: The smooth calibartion periode is 8s.
RTC_SmoothCalibPlusPulses,:Select to Set or reset the CALP bit. This parameter can be one of the following values:
  • RTC_SmoothCalibPlusPulses_Set: Add one RTCCLK puls every 2**11 pulses.
  • RTC_SmoothCalibPlusPulses_Reset: No RTCCLK pulses are added.
RTC_SmouthCalibMinusPulsesValue,:Select the value of CALM[8:0] bits. This parameter can be one any value from 0 to 0x000001FF.
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RTC Calib registers are configured
  • ERROR: RTC Calib registers are not configured
void RTC_StructInit ( RTC_InitTypeDef RTC_InitStruct)

Fills each RTC_InitStruct member with its default value.

Parameters
RTC_InitStruct,:pointer to a RTC_InitTypeDef structure which will be initialized.
Return values
None
ErrorStatus RTC_SynchroShiftConfig ( uint32_t  RTC_ShiftAdd1S,
uint32_t  RTC_ShiftSubFS 
)

Configures the Synchronization Shift Control Settings.

Note
When REFCKON is set, firmware must not write to Shift control register
Parameters
RTC_ShiftAdd1S,:Select to add or not 1 second to the time Calendar. This parameter can be one of the following values :
  • RTC_ShiftAdd1S_Set: Add one second to the clock calendar.
  • RTC_ShiftAdd1S_Reset: No effect.
RTC_ShiftSubFS,:Select the number of Second Fractions to Substitute. This parameter can be one any value from 0 to 0x7FFF.
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RTC Shift registers are configured
  • ERROR: RTC Shift registers are not configured
void RTC_TamperCmd ( uint32_t  RTC_Tamper,
FunctionalState  NewState 
)

Enables or Disables the Tamper detection.

Parameters
RTC_Tamper,:Selected tamper pin. This parameter can be any combination of the following values:
  • RTC_Tamper_1: Select Tamper 1.
  • RTC_Tamper_2: Select Tamper 2.
NewState,:new state of the tamper pin. This parameter can be: ENABLE or DISABLE.
Return values
None
void RTC_TamperFilterConfig ( uint32_t  RTC_TamperFilter)

Configures the Tampers Filter.

Parameters
RTC_TamperFilter,:Specifies the tampers filter. This parameter can be one of the following values:
  • RTC_TamperFilter_Disable: Tamper filter is disabled.
  • RTC_TamperFilter_2Sample: Tamper is activated after 2 consecutive samples at the active level
  • RTC_TamperFilter_4Sample: Tamper is activated after 4 consecutive samples at the active level
  • RTC_TamperFilter_8Sample: Tamper is activated after 8 consecutive samples at the active level
Return values
None
void RTC_TamperPinsPrechargeDuration ( uint32_t  RTC_TamperPrechargeDuration)

Configures the Tampers Pins input Precharge Duration.

Parameters
RTC_TamperPrechargeDuration,:Specifies the Tampers Pins input Precharge Duration. This parameter can be one of the following values:
  • RTC_TamperPrechargeDuration_1RTCCLK: Tamper pins are pre-charged before sampling during 1 RTCCLK cycle
  • RTC_TamperPrechargeDuration_2RTCCLK: Tamper pins are pre-charged before sampling during 2 RTCCLK cycle
  • RTC_TamperPrechargeDuration_4RTCCLK: Tamper pins are pre-charged before sampling during 4 RTCCLK cycle
  • RTC_TamperPrechargeDuration_8RTCCLK: Tamper pins are pre-charged before sampling during 8 RTCCLK cycle
Return values
None
void RTC_TamperPullUpCmd ( FunctionalState  NewState)

Enables or Disables the Precharge of Tamper pin.

Parameters
NewState,:new state of tamper pull up. This parameter can be: ENABLE or DISABLE.
Return values
None
void RTC_TamperSamplingFreqConfig ( uint32_t  RTC_TamperSamplingFreq)

Configures the Tampers Sampling Frequency.

Parameters
RTC_TamperSamplingFreq,:Specifies the tampers Sampling Frequency. This parameter can be one of the following values:
  • RTC_TamperSamplingFreq_RTCCLK_Div32768: Each of the tamper inputs are sampled with a frequency = RTCCLK / 32768
  • RTC_TamperSamplingFreq_RTCCLK_Div16384: Each of the tamper inputs are sampled with a frequency = RTCCLK / 16384
  • RTC_TamperSamplingFreq_RTCCLK_Div8192: Each of the tamper inputs are sampled with a frequency = RTCCLK / 8192
  • RTC_TamperSamplingFreq_RTCCLK_Div4096: Each of the tamper inputs are sampled with a frequency = RTCCLK / 4096
  • RTC_TamperSamplingFreq_RTCCLK_Div2048: Each of the tamper inputs are sampled with a frequency = RTCCLK / 2048
  • RTC_TamperSamplingFreq_RTCCLK_Div1024: Each of the tamper inputs are sampled with a frequency = RTCCLK / 1024
  • RTC_TamperSamplingFreq_RTCCLK_Div512: Each of the tamper inputs are sampled with a frequency = RTCCLK / 512
  • RTC_TamperSamplingFreq_RTCCLK_Div256: Each of the tamper inputs are sampled with a frequency = RTCCLK / 256
Return values
None
void RTC_TamperTriggerConfig ( uint32_t  RTC_Tamper,
uint32_t  RTC_TamperTrigger 
)

Configures the select Tamper pin edge.

Parameters
RTC_Tamper,:Selected tamper pin. This parameter can be any combination of the following values:
  • RTC_Tamper_1: Select Tamper 1.
  • RTC_Tamper_2: Select Tamper 2.
RTC_TamperTrigger,:Specifies the trigger on the tamper pin that stimulates tamper event. This parameter can be one of the following values:
  • RTC_TamperTrigger_RisingEdge: Rising Edge of the tamper pin causes tamper event.
  • RTC_TamperTrigger_FallingEdge: Falling Edge of the tamper pin causes tamper event.
  • RTC_TamperTrigger_LowLevel: Low Level of the tamper pin causes tamper event.
  • RTC_TamperTrigger_HighLevel: High Level of the tamper pin causes tamper event.
Return values
None
void RTC_TimeStampCmd ( uint32_t  RTC_TimeStampEdge,
FunctionalState  NewState 
)

Enables or Disables the RTC TimeStamp functionality with the specified time stamp pin stimulating edge.

Parameters
RTC_TimeStampEdge,:Specifies the pin edge on which the TimeStamp is activated. This parameter can be one of the following:
  • RTC_TimeStampEdge_Rising: the Time stamp event occurs on the rising edge of the related pin.
  • RTC_TimeStampEdge_Falling: the Time stamp event occurs on the falling edge of the related pin.
NewState,:new state of the TimeStamp. This parameter can be: ENABLE or DISABLE.
Return values
None
void RTC_TimeStampOnTamperDetectionCmd ( FunctionalState  NewState)

Enables or Disables the TimeStamp on Tamper Detection Event.

Note
The timestamp is valid even the TSE bit in tamper control register is reset.
Parameters
NewState,:new state of the timestamp on tamper event. This parameter can be: ENABLE or DISABLE.
Return values
None
void RTC_TimeStructInit ( RTC_TimeTypeDef RTC_TimeStruct)

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

Parameters
RTC_TimeStruct,:pointer to a RTC_TimeTypeDef structure which will be initialized.
Return values
None
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.
To read the calendar through the shadow registers after Calendar initialization, calendar update or after wakeup from low power modes the software must first clear the RSF flag. The software must then wait until it is set again before reading the calendar, which means that the calendar registers have been correctly copied into the RTC_TR and RTC_DR shadow registers.
Parameters
None
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RTC registers are synchronised
  • ERROR: RTC registers are not synchronised
void RTC_WriteBackupRegister ( uint32_t  RTC_BKP_DR,
uint32_t  Data 
)

Writes a data in a specified RTC Backup data register.

Parameters
RTC_BKP_DR,:RTC Backup data Register number. This parameter can be: RTC_BKP_DRx where x can be from 0 to 4 to specify the register.
Data,:Data to be written in the specified RTC Backup data register.
Return values
None
void RTC_WriteProtectionCmd ( FunctionalState  NewState)

Enables or disables the RTC registers write protection.

Note
All the RTC registers are write protected except for RTC_ISR[13:8], RTC_TAFCR and RTC_BKPxR.
Writing a wrong key reactivates the write protection.
The protection mechanism is not affected by system reset.
Parameters
NewState,:new state of the write protection. This parameter can be: ENABLE or DISABLE.
Return values
None