STM8L15x Standard Peripherals Drivers: RTC

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

RTC driver modules. More...

Modules

 RTC_Exported_Types
 RTC_Exported_Macros
 RTC_Private_Functions_Prototype
 RTC_Private_Functions

Defines

#define ALRAWF_TIMEOUT   ((uint16_t)0xFFFF)
#define INIT_TIMEOUT   ((uint16_t)0xFFFF)
#define INITF_TIMEOUT   ((uint16_t)0xFFFF)
#define RECALPF_TIMEOUT   ((uint16_t)0xFFFF)
#define RSF_TIMEOUT   ((uint16_t)0xFFFF)
#define SHPF_TIMEOUT   ((uint16_t)0xFFFF)
#define TEN_VALUE_BCD   ((uint8_t)0x10)
#define TEN_VALUE_BIN   ((uint8_t)0x0A)
#define WUTWF_TIMEOUT   ((uint16_t)0xFFFF)

Functions

ErrorStatus RTC_AlarmCmd (FunctionalState NewState)
 Enables or disables the RTC Alarm.
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).
ErrorStatus RTC_AlarmSubSecondConfig (uint16_t RTC_AlarmSubSecondValue, RTC_AlarmSubSecondMask_TypeDef RTC_AlarmSubSecondMask)
 Configure the RTC Alarm Subseconds value and mask.
void RTC_BypassShadowCmd (FunctionalState NewState)
 Enables or Disables the Bypass Shadow feature.
void RTC_CalibOutputCmd (FunctionalState NewState)
 Enables or disables the RTC clock to be output through the relative pin.
void RTC_CalibOutputConfig (RTC_CalibOutput_TypeDef RTC_CalibOutput)
 Configure the Calibration Pin-out (RTC_CALIB) Selection (1Hz or 512Hz).
void RTC_ClearFlag (RTC_Flag_TypeDef RTC_FLAG)
 Clears the RTC's pending flags.
void RTC_ClearITPendingBit (RTC_IT_TypeDef RTC_IT)
 Clears the RTC's interrupt pending bits.
void RTC_DateStructInit (RTC_DateTypeDef *RTC_DateStruct)
 Fills each RTC_DateStruct member with its default value (Monday 01 January xx00).
void RTC_DayLightSavingConfig (RTC_DayLightSaving_TypeDef RTC_DayLightSaving, RTC_StoreOperation_TypeDef RTC_StoreOperation)
 Adds or subtracts one hour from the current time depending on the daylight saving parameter.
ErrorStatus RTC_DeInit (void)
 Deinitializes the RTC registers to their default reset values.
ErrorStatus RTC_EnterInitMode (void)
 Enters the RTC Initialization mode.
void RTC_ExitInitMode (void)
 Exits the RTC Initialization mode.
void RTC_GetAlarm (RTC_Format_TypeDef RTC_Format, RTC_AlarmTypeDef *RTC_AlarmStruct)
 Gets the RTC Alarm configuration.
void RTC_GetDate (RTC_Format_TypeDef RTC_Format, RTC_DateTypeDef *RTC_DateStruct)
 Get the RTC current date.
FlagStatus RTC_GetFlagStatus (RTC_Flag_TypeDef RTC_FLAG)
 Checks whether the specified RTC flag is set or not.
ITStatus RTC_GetITStatus (RTC_IT_TypeDef RTC_IT)
 Checks whether the specified RTC interrupt has occurred or not.
RTC_StoreOperation_TypeDef RTC_GetStoreOperation (void)
 Returns the stored operation.
uint16_t RTC_GetSubSecond (void)
 Gets the RTC current Calendar Subseconds value.
void RTC_GetTime (RTC_Format_TypeDef RTC_Format, RTC_TimeTypeDef *RTC_TimeStruct)
 Gets the RTC current Time.
uint16_t RTC_GetWakeUpCounter (void)
 Returns the RTC Wakeup timer counter value.
ErrorStatus RTC_Init (RTC_InitTypeDef *RTC_InitStruct)
 Initializes the RTC registers according to the specified parameters in RTC_InitStruct.
void RTC_ITConfig (RTC_IT_TypeDef RTC_IT, FunctionalState NewState)
 Enables or Disables the specified RTC interrupts.
void RTC_OutputConfig (RTC_Output_TypeDef RTC_Output, RTC_OutputPolarity_TypeDef RTC_OutputPolarity)
 Configures the RTC output for the output pin (RTC_ALARM output).
void RTC_RatioCmd (FunctionalState NewState)
 Enables or Disables the RTC Ratio.
void RTC_SetAlarm (RTC_Format_TypeDef RTC_Format, RTC_AlarmTypeDef *RTC_AlarmStruct)
 Sets the RTC Alarm configuration.
ErrorStatus RTC_SetDate (RTC_Format_TypeDef RTC_Format, RTC_DateTypeDef *RTC_DateStruct)
 Set the RTC current date.
ErrorStatus RTC_SetTime (RTC_Format_TypeDef RTC_Format, RTC_TimeTypeDef *RTC_TimeStruct)
 Sets the RTC current time.
void RTC_SetWakeUpCounter (uint16_t RTC_WakeupCounter)
 Sets the RTC Wakeup counter.
ErrorStatus RTC_SmoothCalibConfig (RTC_SmoothCalibPeriod_TypeDef RTC_SmoothCalibPeriod, RTC_SmoothCalibPlusPulses_TypeDef RTC_SmoothCalibPlusPulses, uint16_t RTC_SmouthCalibMinusPulsesValue)
 Configures the Smooth Calibration Settings.
void RTC_StructInit (RTC_InitTypeDef *RTC_InitStruct)
 Fills each RTC_InitStruct member with its default value Hour format = 24h / Prescalers configured to their reset values.
ErrorStatus RTC_SynchroShiftConfig (RTC_ShiftAdd1S_TypeDef RTC_ShiftAdd1S, uint16_t RTC_ShiftSubFS)
 Configures the Synchronization Shift Control Settings.
void RTC_TamperCmd (RTC_Tamper_TypeDef RTC_Tamper, FunctionalState NewState)
 Enables or Disables the Tamper detection.
void RTC_TamperFilterConfig (RTC_TamperFilter_TypeDef RTC_TamperFilter)
 Configures the Tampers Filter.
void RTC_TamperLevelConfig (RTC_Tamper_TypeDef RTC_Tamper, RTC_TamperLevel_TypeDef RTC_TamperLevel)
 Configures the Tamper Sensitive Level.
void RTC_TamperPinsPrechargeDuration (RTC_TamperPrechargeDuration_TypeDef RTC_TamperPrechargeDuration)
 Configures the Tampers Pins input Precharge Duration.
void RTC_TamperSamplingFreqConfig (RTC_TamperSamplingFreq_TypeDef RTC_TamperSamplingFreq)
 Configures the Tampers Sampling Frequency.
void RTC_TimeStructInit (RTC_TimeTypeDef *RTC_TimeStruct)
 Fills each RTC_TimeStruct member with its default value (Time = 00h:00min:00sec).
ErrorStatus RTC_WaitForSynchro (void)
 Waits until the RTC Calendar registers (Time and Date) are synchronized with RTC clock.
void RTC_WakeUpClockConfig (RTC_WakeUpClock_TypeDef RTC_WakeUpClock)
 Configures the RTC Wakeup clock source.
ErrorStatus RTC_WakeUpCmd (FunctionalState NewState)
 Enables or Disables the RTC Wakeup Unit.
void RTC_WriteProtectionCmd (FunctionalState NewState)
 Enables or disables the RTC registers write protection.

Detailed Description

RTC driver modules.


Define Documentation

#define ALRAWF_TIMEOUT   ((uint16_t)0xFFFF)

Definition at line 155 of file stm8l15x_rtc.c.

Referenced by RTC_AlarmCmd().

#define INIT_TIMEOUT   ((uint16_t)0xFFFF)

Definition at line 151 of file stm8l15x_rtc.c.

#define INITF_TIMEOUT   ((uint16_t)0xFFFF)

Definition at line 153 of file stm8l15x_rtc.c.

Referenced by RTC_EnterInitMode().

#define RECALPF_TIMEOUT   ((uint16_t)0xFFFF)

Definition at line 156 of file stm8l15x_rtc.c.

Referenced by RTC_DeInit(), and RTC_SmoothCalibConfig().

#define RSF_TIMEOUT   ((uint16_t)0xFFFF)

Definition at line 152 of file stm8l15x_rtc.c.

Referenced by RTC_WaitForSynchro().

#define SHPF_TIMEOUT   ((uint16_t)0xFFFF)

Definition at line 157 of file stm8l15x_rtc.c.

Referenced by RTC_SynchroShiftConfig().

#define TEN_VALUE_BCD   ((uint8_t)0x10)

Definition at line 159 of file stm8l15x_rtc.c.

Referenced by RTC_SetDate().

#define TEN_VALUE_BIN   ((uint8_t)0x0A)

Definition at line 160 of file stm8l15x_rtc.c.

Referenced by RTC_SetDate().

#define WUTWF_TIMEOUT   ((uint16_t)0xFFFF)

Definition at line 154 of file stm8l15x_rtc.c.

Referenced by RTC_DeInit(), and RTC_WakeUpCmd().


Function Documentation

ErrorStatus RTC_AlarmCmd ( FunctionalState  NewState)

Enables or disables the RTC Alarm.

Parameters:
NewState,:new state of the 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

Definition at line 1236 of file stm8l15x_rtc.c.

References __IO, ALRAWF_TIMEOUT, DISABLE, ERROR, IS_FUNCTIONAL_STATE, RESET, RTC, RTC_CR2_ALRAE, RTC_ISR1_ALRAWF, and SUCCESS.

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

Definition at line 1159 of file stm8l15x_rtc.c.

References RTC_AlarmTypeDef::RTC_AlarmDateWeekDay, RTC_AlarmTypeDef::RTC_AlarmDateWeekDaySel, RTC_AlarmDateWeekDaySel_Date, RTC_AlarmTypeDef::RTC_AlarmMask, RTC_AlarmMask_All, RTC_AlarmTypeDef::RTC_AlarmTime, RTC_TimeTypeDef::RTC_H12, RTC_H12_AM, RTC_TimeTypeDef::RTC_Hours, RTC_TimeTypeDef::RTC_Minutes, and RTC_TimeTypeDef::RTC_Seconds.

ErrorStatus RTC_AlarmSubSecondConfig ( uint16_t  RTC_AlarmSubSecondValue,
RTC_AlarmSubSecondMask_TypeDef  RTC_AlarmSubSecondMask 
)

Configure the RTC Alarm Subseconds value and mask.

Parameters:
RTC_AlarmSubSecondValue,:specifies the Subseconds value. This parameter can be a value from 0 to 0x7FFF.
RTC_AlarmSubSecondMask,:specifies the Subseconds Mask. This parameter can be one of the RTC_AlarmSubSecondMask_TypeDef enumeration.
Return values:
AnErrorStatus enumeration value:
  • SUCCESS: Alarm Subseconds value and mask are configured
  • ERROR: Alarm Subseconds value and mask are not configured

Definition at line 1292 of file stm8l15x_rtc.c.

References ERROR, IS_RTC_ALARM_SS_MASK, IS_RTC_ALARM_SS_VALUE, RESET, RTC, RTC_CR2_ALRAE, RTC_ISR1_INITF, and SUCCESS.

void RTC_BypassShadowCmd ( FunctionalState  NewState)

Enables or Disables the Bypass Shadow feature.

Parameters:
NewState,:new state of the Bypass Shadow feature. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 592 of file stm8l15x_rtc.c.

References DISABLE, IS_FUNCTIONAL_STATE, RTC, and RTC_CR1_BYPSHAD.

void RTC_CalibOutputCmd ( FunctionalState  NewState)

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

Parameters:
NewState,:new state of the RTC Calibration output This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 1814 of file stm8l15x_rtc.c.

References DISABLE, IS_FUNCTIONAL_STATE, RTC, and RTC_CR3_COE.

void RTC_CalibOutputConfig ( RTC_CalibOutput_TypeDef  RTC_CalibOutput)

Configure the Calibration Pin-out (RTC_CALIB) Selection (1Hz or 512Hz).

Parameters:
RTC_CalibOutput: Select the Calibration output Selection . This parameter can be one parameter from the RTC_CalibOutput_TypeDef enumeration.
Return values:
None

Definition at line 1784 of file stm8l15x_rtc.c.

References IS_RTC_CALOUTPUT_SELECT, RTC, RTC_CalibOutput_512Hz, and RTC_CR3_COSEL.

void RTC_ClearFlag ( RTC_Flag_TypeDef  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 RTC_Flag_TypeDef enumeration.
Return values:
None

Definition at line 2116 of file stm8l15x_rtc.c.

References IS_RTC_CLEAR_FLAG, RTC, and RTC_ISR1_INIT.

void RTC_ClearITPendingBit ( RTC_IT_TypeDef  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 RTC_IT_TypeDef enumeration.
Return values:
None

Definition at line 2166 of file stm8l15x_rtc.c.

References IS_RTC_CLEAR_IT, and RTC.

void RTC_DateStructInit ( RTC_DateTypeDef RTC_DateStruct)

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

Parameters:
RTC_DateStruct,:pointer to a RTC_DateTypeDef structure which will be initialized.
Return values:
None

Definition at line 962 of file stm8l15x_rtc.c.

References RTC_DateTypeDef::RTC_Date, RTC_DateTypeDef::RTC_Month, RTC_Month_January, RTC_DateTypeDef::RTC_WeekDay, RTC_Weekday_Monday, and RTC_DateTypeDef::RTC_Year.

void RTC_DayLightSavingConfig ( RTC_DayLightSaving_TypeDef  RTC_DayLightSaving,
RTC_StoreOperation_TypeDef  RTC_StoreOperation 
)

Adds or subtracts one hour from the current time depending on the daylight saving parameter.

Parameters:
RTC_DayLightSaving,:the day light saving Mode This parameter can be one of the RTC_DayLightSaving_TypeDef enumeration.
RTC_StoreOperation,:the day light saving store operation This parameter can be one of the RTC_StoreOperation_TypeDef enumeration.
Return values:
None

Definition at line 1516 of file stm8l15x_rtc.c.

References IS_RTC_DAYLIGHT_SAVING, IS_RTC_STORE_OPERATION, RTC, and RTC_CR3_BCK.

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

Definition at line 452 of file stm8l15x_rtc.c.

References ERROR, INITF_TIMEOUT, RESET, RTC, RTC_ISR1_INIT, RTC_ISR1_INITF, and SUCCESS.

Referenced by RTC_DeInit(), RTC_Init(), RTC_SetDate(), and RTC_SetTime().

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

Definition at line 492 of file stm8l15x_rtc.c.

References RTC, and RTC_ISR1_INIT.

void RTC_GetAlarm ( RTC_Format_TypeDef  RTC_Format,
RTC_AlarmTypeDef RTC_AlarmStruct 
)

Gets the RTC Alarm configuration.

Parameters:
RTC_Format,:specifies the format of the entered parameters. This parameter can be one of the RTC_Format_TypeDef enumeration.
RTC_AlarmStruct,:pointer to a RTC_AlarmTypeDef structure that will contain the Alarm configuration information of the RTC.
Return values:
None

Definition at line 1182 of file stm8l15x_rtc.c.

References Bcd2ToByte(), IS_RTC_FORMAT, RTC, RTC_AlarmTypeDef::RTC_AlarmDateWeekDay, RTC_AlarmTypeDef::RTC_AlarmDateWeekDaySel, RTC_AlarmTypeDef::RTC_AlarmMask, RTC_AlarmTypeDef::RTC_AlarmTime, RTC_ALRMAR1_MSK1, RTC_ALRMAR1_ST, RTC_ALRMAR1_SU, RTC_ALRMAR2_MNT, RTC_ALRMAR2_MNU, RTC_ALRMAR2_MSK2, RTC_ALRMAR3_HT, RTC_ALRMAR3_HU, RTC_ALRMAR3_MSK3, RTC_ALRMAR3_PM, RTC_ALRMAR4_DT, RTC_ALRMAR4_DU, RTC_ALRMAR4_MSK4, RTC_ALRMAR4_WDSEL, RTC_Format_BIN, RTC_TimeTypeDef::RTC_H12, RTC_TimeTypeDef::RTC_Hours, RTC_TimeTypeDef::RTC_Minutes, and RTC_TimeTypeDef::RTC_Seconds.

void RTC_GetDate ( RTC_Format_TypeDef  RTC_Format,
RTC_DateTypeDef RTC_DateStruct 
)

Get the RTC current date.

Note:
To read the Calendar after wake up from low power mode, user software must first check that the RSF flag is set in RTC_ISR1, using RTC_WaitForSynchro() function, which means that the Calendar registers have been correctly copied into the shadow registers (RTC_TRx and RTC_DRx).
Parameters:
RTC_Format,:specifies the format of the returned parameters. This parameter can be one of the RTC_Format_TypeDef enumeration.
RTC_DateStruct,:pointer to a RTC_DateTypeDef structure that will contain the returned current Date configuration.
Return values:
None

Definition at line 982 of file stm8l15x_rtc.c.

References Bcd2ToByte(), IS_RTC_FORMAT, RTC, RTC_DateTypeDef::RTC_Date, RTC_DR2_MT, RTC_DR2_MU, RTC_DR2_WDU, RTC_Format_BIN, RTC_DateTypeDef::RTC_Month, RTC_DateTypeDef::RTC_WeekDay, and RTC_DateTypeDef::RTC_Year.

FlagStatus RTC_GetFlagStatus ( RTC_Flag_TypeDef  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 RTC_Flag_TypeDef enumeration.
Return values:
Statusof RTC_FLAG (SET or RESET)

Definition at line 2084 of file stm8l15x_rtc.c.

References IS_RTC_GET_FLAG, RESET, RTC, and SET.

ITStatus RTC_GetITStatus ( RTC_IT_TypeDef  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 RTC_IT_TypeDef enumeration.
Return values:
Statusof RTC_IT (SET or RESET).

Definition at line 2132 of file stm8l15x_rtc.c.

References IS_RTC_GET_IT, RESET, RTC, and SET.

RTC_StoreOperation_TypeDef RTC_GetStoreOperation ( void  )

Returns the stored operation.

Parameters:
None
Return values:
thestore operation, this parameter can be one of the RTC_StoreOperation_TypeDef enumeration.

Definition at line 1543 of file stm8l15x_rtc.c.

References RTC, and RTC_CR3_BCK.

uint16_t RTC_GetSubSecond ( void  )

Gets the RTC current Calendar Subseconds value.

Note:
To read the Calendar after wake up from low power mode, user software must first check that the RSF flag is set in RTC_ISR1, using RTC_WaitForSynchro() function, which means that the Calendar registers have been correctly copied into the shadow registers (RTC_TRx and RTC_DRx).
Parameters:
None
Return values:
RTCcurrent Calendar Subseconds value.

Definition at line 839 of file stm8l15x_rtc.c.

References RTC.

void RTC_GetTime ( RTC_Format_TypeDef  RTC_Format,
RTC_TimeTypeDef RTC_TimeStruct 
)

Gets the RTC current Time.

Note:
To read the Calendar after wake up from low power mode, user software must first check that the RSF flag is set in RTC_ISR1, using RTC_WaitForSynchro() function, which means that the Calendar registers have been correctly copied into the shadow registers (RTC_TRx and RTC_DRx).
Parameters:
RTC_Format,:specifies the format of the returned parameters. This parameter can be one of the RTC_Format_TypeDef enumeration.
RTC_TimeStruct,:pointer to a RTC_TimeTypeDef structure that will contain the returned current time configuration.
Return values:
None

Definition at line 792 of file stm8l15x_rtc.c.

References Bcd2ToByte(), IS_RTC_FORMAT, RTC, RTC_Format_BIN, RTC_TimeTypeDef::RTC_H12, RTC_TimeTypeDef::RTC_Hours, RTC_TimeTypeDef::RTC_Minutes, RTC_TimeTypeDef::RTC_Seconds, and RTC_TR3_PM.

uint16_t RTC_GetWakeUpCounter ( void  )

Returns the RTC Wakeup timer counter value.

Parameters:
None.
Return values:
RTCWakeup Counter value.

Definition at line 1414 of file stm8l15x_rtc.c.

References RTC.

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

Definition at line 353 of file stm8l15x_rtc.c.

References ERROR, IS_RTC_ASYNCH_PREDIV, IS_RTC_HOUR_FORMAT, IS_RTC_SYNCH_PREDIV, RTC, RTC_InitTypeDef::RTC_AsynchPrediv, RTC_CR1_FMT, RTC_EnterInitMode(), RTC_InitTypeDef::RTC_HourFormat, RTC_ISR1_INIT, RTC_InitTypeDef::RTC_SynchPrediv, and SUCCESS.

void RTC_ITConfig ( RTC_IT_TypeDef  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_ALRA: Alarm A interrupt
  • RTC_IT_TAMP: Tampers interrupt
  • RTC_IT_WUT: WakeUp Timer interrupt
NewState,:new state of the specified RTC interrupts. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 2052 of file stm8l15x_rtc.c.

References DISABLE, IS_FUNCTIONAL_STATE, IS_RTC_CONFIG_IT, RTC, and RTC_TCR1_TAMPIE.

void RTC_OutputConfig ( RTC_Output_TypeDef  RTC_Output,
RTC_OutputPolarity_TypeDef  RTC_OutputPolarity 
)

Configures the RTC output for the output pin (RTC_ALARM output).

Parameters:
RTC_OutputSel,:Specifies which signal will be mapped to the output. This parameter can be one parameter from the RTC_OutputSel_TypeDef enumeration.
RTC_OutputPolarity,:Specifies the polarity of the output signal. This parameter can be one parameter from the RTC_OutputPolarity_TypeDef enumeration.
Return values:
None

Definition at line 1581 of file stm8l15x_rtc.c.

References IS_RTC_OUTPUT_POL, IS_RTC_OUTPUT_SEL, RTC, RTC_CR3_OSEL, and RTC_CR3_POL.

void RTC_RatioCmd ( FunctionalState  NewState)

Enables or Disables the RTC Ratio.

Parameters:
NewState,:new state of the Ratio feature. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 562 of file stm8l15x_rtc.c.

References DISABLE, IS_FUNCTIONAL_STATE, RTC, and RTC_CR1_RATIO.

void RTC_SetAlarm ( RTC_Format_TypeDef  RTC_Format,
RTC_AlarmTypeDef RTC_AlarmStruct 
)

Sets the RTC Alarm configuration.

Note:
Before configuring the Alarm settings, the Alarm Unit must be disabled (if enabled) using RTC_AlarmCmd(DISABLE) function.
Parameters:
RTC_Format,:specifies the format of the entered parameters. This parameter can be one of the RTC_Format_TypeDef enumeration.
RTC_AlarmStruct,:pointer to a RTC_AlarmTypeDef structure that contains the Alarm configuration information for the RTC.
Return values:
None.

Definition at line 1038 of file stm8l15x_rtc.c.

References Bcd2ToByte(), ByteToBcd2(), IS_RTC_ALARM_DATEWEEKDAY_SEL, IS_RTC_ALARM_MASK, IS_RTC_DATE_MAX, IS_RTC_DATE_MIN, IS_RTC_FORMAT, IS_RTC_H12, IS_RTC_HOUR12_MAX, IS_RTC_HOUR12_MIN, IS_RTC_HOUR24, IS_RTC_MINUTES, IS_RTC_SECONDS, IS_RTC_WEEKDAY, RESET, RTC, RTC_AlarmTypeDef::RTC_AlarmDateWeekDay, RTC_AlarmTypeDef::RTC_AlarmDateWeekDaySel, RTC_AlarmDateWeekDaySel_WeekDay, RTC_AlarmTypeDef::RTC_AlarmMask, RTC_AlarmMask_DateWeekDay, RTC_AlarmTypeDef::RTC_AlarmTime, RTC_ALRMAR1_MSK1, RTC_ALRMAR2_MSK2, RTC_ALRMAR3_MSK3, RTC_ALRMAR4_MSK4, RTC_CR1_FMT, RTC_Format_BIN, RTC_TimeTypeDef::RTC_H12, RTC_TimeTypeDef::RTC_Hours, RTC_TimeTypeDef::RTC_Minutes, and RTC_TimeTypeDef::RTC_Seconds.

ErrorStatus RTC_SetDate ( RTC_Format_TypeDef  RTC_Format,
RTC_DateTypeDef RTC_DateStruct 
)

Set the RTC current date.

Note:
After updating the Calendar, this routine clears the RSF flag and waits until it is set again (using RTC_WaitForSynchro() function) , which means that the Calendar registers have been correctly copied into the RTC_TRx and RTC_DRx shadow registers.
Parameters:
RTC_Format,:specifies the format of the entered parameters. This parameter can be one of the RTC_Format_TypeDef enumeration.
RTC_DateStruct,:pointer to a RTC_TimeTypeDef 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

Definition at line 870 of file stm8l15x_rtc.c.

References Bcd2ToByte(), ByteToBcd2(), ERROR, IS_RTC_DATE_MAX, IS_RTC_DATE_MIN, IS_RTC_FORMAT, IS_RTC_MONTH_MAX, IS_RTC_MONTH_MIN, IS_RTC_WEEKDAY, IS_RTC_YEAR, RESET, RTC, RTC_CR1_BYPSHAD, RTC_DateTypeDef::RTC_Date, RTC_EnterInitMode(), RTC_Format_BIN, RTC_ISR1_INIT, RTC_DateTypeDef::RTC_Month, RTC_WaitForSynchro(), RTC_DateTypeDef::RTC_WeekDay, RTC_DateTypeDef::RTC_Year, SUCCESS, TEN_VALUE_BCD, and TEN_VALUE_BIN.

ErrorStatus RTC_SetTime ( RTC_Format_TypeDef  RTC_Format,
RTC_TimeTypeDef RTC_TimeStruct 
)

Sets the RTC current time.

Note:
After updating the Calendar, this routine clears the RSF flag and waits until it is set again (using RTC_WaitForSynchro() function) , which means that the Calendar registers have been correctly copied into the RTC_TRx and RTC_DRx shadow registers.
Parameters:
RTC_Format,:specifies the format of the entered parameters. This parameter can be one of the RTC_Format_TypeDef enumeration.
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

Definition at line 653 of file stm8l15x_rtc.c.

References Bcd2ToByte(), ByteToBcd2(), ERROR, IS_RTC_FORMAT, IS_RTC_H12, IS_RTC_HOUR12_MAX, IS_RTC_HOUR12_MIN, IS_RTC_HOUR24, IS_RTC_MINUTES, IS_RTC_SECONDS, RESET, RTC, RTC_CR1_BYPSHAD, RTC_CR1_FMT, RTC_EnterInitMode(), RTC_Format_BIN, RTC_TimeTypeDef::RTC_H12, RTC_TimeTypeDef::RTC_Hours, RTC_ISR1_INIT, RTC_TimeTypeDef::RTC_Minutes, RTC_TimeTypeDef::RTC_Seconds, RTC_WaitForSynchro(), and SUCCESS.

void RTC_SetWakeUpCounter ( uint16_t  RTC_WakeupCounter)

Sets the RTC Wakeup counter.

Note:
Before configuring the wakeup unit counter, the wake up Unit must be disabled (if enabled) using RTC_WakeUpCmd(Disable).
Parameters:
RTC_WakeupCounter,:specifies the Wake up counter, This parameter can be a value from 0x0000 to 0xFFFF.
Return values:
None.

Definition at line 1394 of file stm8l15x_rtc.c.

References RTC.

ErrorStatus RTC_SmoothCalibConfig ( RTC_SmoothCalibPeriod_TypeDef  RTC_SmoothCalibPeriod,
RTC_SmoothCalibPlusPulses_TypeDef  RTC_SmoothCalibPlusPulses,
uint16_t  RTC_SmouthCalibMinusPulsesValue 
)

Configures the Smooth Calibration Settings.

Parameters:
RTC_SmoothCalibPeriod: Select the Smooth Calibration Period. This parameter can be one parameter from the RTC_SmoothCalibPeriod_TypeDef enumeration.
RTC_SmoothCalibPlusPulses: Select to Set or reset the CALP bit. This parameter can be one parameter from the RTC_SmoothCalibPlusPulses_TypeDef enumeration.
RTC_SmouthCalibMinusPulsesValue,:Select the value of CALM[8:0] bits. This parameter can be one any value from 0 to 0x01FF.
Return values:
AnErrorStatus enumeration value:
  • SUCCESS: RTC Calib registers are configured
  • ERROR: RTC Calib registers are not configured

Definition at line 1712 of file stm8l15x_rtc.c.

References ERROR, IS_RTC_SMOOTH_CALIB_MINUS, IS_RTC_SMOOTH_CALIB_PERIOD, IS_RTC_SMOOTH_CALIB_PLUS, RECALPF_TIMEOUT, RESET, RTC, RTC_ISR1_RECALPF, and SUCCESS.

void RTC_StructInit ( RTC_InitTypeDef RTC_InitStruct)

Fills each RTC_InitStruct member with its default value Hour format = 24h / Prescalers configured to their reset values.

Parameters:
RTC_InitStruct,:pointer to a RTC_InitTypeDef structure which will be initialized.
Return values:
None

Definition at line 404 of file stm8l15x_rtc.c.

References RTC_APRER_RESET_VALUE, RTC_InitTypeDef::RTC_AsynchPrediv, RTC_InitTypeDef::RTC_HourFormat, RTC_HourFormat_24, RTC_SPRERL_RESET_VALUE, and RTC_InitTypeDef::RTC_SynchPrediv.

ErrorStatus RTC_SynchroShiftConfig ( RTC_ShiftAdd1S_TypeDef  RTC_ShiftAdd1S,
uint16_t  RTC_ShiftSubFS 
)

Configures the Synchronization Shift Control Settings.

Parameters:
RTC_ShiftAdd1S: Select to add or not 1 second to the time Calendar. This parameter can be one parameter from the RTC_ShiftAdd1S_TypeDef enumeration.
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

Definition at line 1633 of file stm8l15x_rtc.c.

References ERROR, IS_RTC_SHIFT_ADD1S, IS_RTC_SHIFT_SUBFS, RESET, RTC, RTC_ISR1_SHPF, SHPF_TIMEOUT, and SUCCESS.

void RTC_TamperCmd ( RTC_Tamper_TypeDef  RTC_Tamper,
FunctionalState  NewState 
)

Enables or Disables the Tamper detection.

Parameters:
RTC_Tamper,:Select the tamper to configure. This parameter can be one parameter from the RTC_Tamper_TypeDef enumeration.
NewState,:new state of the tamper pin. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 1981 of file stm8l15x_rtc.c.

References DISABLE, IS_FUNCTIONAL_STATE, IS_RTC_TAMPER, and RTC.

void RTC_TamperFilterConfig ( RTC_TamperFilter_TypeDef  RTC_TamperFilter)

Configures the Tampers Filter.

Parameters:
RTC_TamperFilter,:Specifies the tampers filter. This parameter can be one parameter from the RTC_TamperFilter_TypeDef enumeration.
Return values:
None

Definition at line 1897 of file stm8l15x_rtc.c.

References IS_RTC_TAMPER_FILTER, RTC, and RTC_TCR2_TAMPFLT.

void RTC_TamperLevelConfig ( RTC_Tamper_TypeDef  RTC_Tamper,
RTC_TamperLevel_TypeDef  RTC_TamperLevel 
)

Configures the Tamper Sensitive Level.

Parameters:
RTC_Tamper,:Select the tamper to configure. This parameter can be one parameter from the RTC_Tamper_TypeDef enumeration.
RTC_TamperLevel,:Select the tamper Sensitive Level. This parameter can be one parameter from the RTC_TamperLevel_TypeDef enumeration.
Return values:
None

Definition at line 1865 of file stm8l15x_rtc.c.

References IS_RTC_TAMPER, IS_RTC_TAMPER_LEVEL, RTC, and RTC_TamperLevel_Low.

void RTC_TamperPinsPrechargeDuration ( RTC_TamperPrechargeDuration_TypeDef  RTC_TamperPrechargeDuration)

Configures the Tampers Pins input Precharge Duration.

Parameters:
RTC_TamperPrechargeDuration,:Specifies the Tampers Pins input Precharge Duration. This parameter can be one parameter from the RTC_TamperPrechargeDuration_TypeDef enumeration.
Return values:
None

Definition at line 1952 of file stm8l15x_rtc.c.

References IS_RTC_TAMPER_PINS_PRECHAR_DURATION, RTC, RTC_TCR2_TAMPPRCH, and RTC_TCR2_TAMPPUDIS.

void RTC_TamperSamplingFreqConfig ( RTC_TamperSamplingFreq_TypeDef  RTC_TamperSamplingFreq)

Configures the Tampers Sampling Frequency.

Parameters:
RTC_TamperSamplingFreq,:Specifies the tampers Sampling Frequency. This parameter can be one parameter from the RTC_TamperSamplingFreq_TypeDef enumeration.
Return values:
None

Definition at line 1925 of file stm8l15x_rtc.c.

References IS_RTC_TAMPER_SAMPLING_FREQ, RTC, and RTC_TCR2_TAMPFREQ.

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

Definition at line 769 of file stm8l15x_rtc.c.

References RTC_TimeTypeDef::RTC_H12, RTC_H12_AM, RTC_TimeTypeDef::RTC_Hours, RTC_TimeTypeDef::RTC_Minutes, and RTC_TimeTypeDef::RTC_Seconds.

ErrorStatus RTC_WaitForSynchro ( void  )

Waits until the RTC Calendar registers (Time and Date) are synchronized with RTC clock.

Note:
This function is meaningless when BAYPASS feature is enabled in RTC_CR1 register.
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 (if not yet done), which means that the Calendar registers have been correctly copied into the RTC_TRx and RTC_DRx shadow registers.
RTC_SetTime() and RTC_SetDate() functions call RTC_WaitForSynchro() function after updating the Calendar. In Run mode, User can use RTC_GetDate(), RTC_GetTime() and/or RTC_GetSubSecond() without need to call RTC_WaitForSynchro() function. After waking up from low power mode, this function must be called before calling RTC_GetDate(), RTC_GetTime() or RTC_GetSubSecond() functions.
Parameters:
None
Return values:
AnErrorStatus enumeration value:
  • SUCCESS: RTC registers are synchronized
  • ERROR: RTC registers are not synchronized

Definition at line 521 of file stm8l15x_rtc.c.

References ERROR, RESET, RSF_TIMEOUT, RTC, RTC_ISR1_INIT, RTC_ISR1_RSF, and SUCCESS.

Referenced by RTC_DeInit(), RTC_SetDate(), and RTC_SetTime().

void RTC_WakeUpClockConfig ( RTC_WakeUpClock_TypeDef  RTC_WakeUpClock)

Configures the RTC Wakeup clock source.

Precondition:
Before configuring the wakeup unit Clock source, the wake up Unit must be disabled (if enabled) using RTC_WakeUpCmd(Disable) .
Parameters:
RTC_WakeupClockSrc,:specifies the Wakeup clock source, this parameter can be one of the RTC_WakeupClockSrc_TypeDef enumeration.
Return values:
None

Definition at line 1363 of file stm8l15x_rtc.c.

References IS_RTC_WAKEUP_CLOCK, RTC, RTC_CR1_WUCKSEL, and RTC_CR2_WUTE.

ErrorStatus RTC_WakeUpCmd ( FunctionalState  NewState)

Enables or Disables the RTC Wakeup Unit.

Parameters:
NewState,:new state of the Wakeup Unit. This parameter can be: ENABLE or DISABLE.
Return values:
AnErrorStatus enumeration value:
  • SUCCESS : RTC Wakeup Unit is enabled/disabled
  • ERROR : RTC Wakeup Unit is not enabled/disabled

Definition at line 1434 of file stm8l15x_rtc.c.

References DISABLE, ERROR, IS_FUNCTIONAL_STATE, RESET, RTC, RTC_CR2_WUTE, RTC_ISR1_WUTWF, SUCCESS, and WUTWF_TIMEOUT.

void RTC_WriteProtectionCmd ( FunctionalState  NewState)

Enables or disables the RTC registers write protection.

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

Definition at line 424 of file stm8l15x_rtc.c.

References DISABLE, IS_FUNCTIONAL_STATE, RTC, RTC_WPR_DisableKey1, RTC_WPR_DisableKey2, and RTC_WPR_EnableKey.

STM8S Firmware Library: Overview

 

 

 

For complete documentation on STM8L15x 8-bit microcontrollers platform visit www.st.com