STM8L15x Standard Peripherals Drivers
|
Initialization and Configuration functions. More...
Functions | |
void | RTC_BypassShadowCmd (FunctionalState NewState) |
Enables or Disables the Bypass Shadow feature. | |
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. | |
ErrorStatus | RTC_Init (RTC_InitTypeDef *RTC_InitStruct) |
Initializes the RTC registers according to the specified parameters in RTC_InitStruct. | |
void | RTC_RatioCmd (FunctionalState NewState) |
Enables or Disables the RTC Ratio. | |
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_WaitForSynchro (void) |
Waits until the RTC Calendar registers (Time and Date) are synchronized with RTC clock. | |
void | RTC_WriteProtectionCmd (FunctionalState NewState) |
Enables or disables the RTC registers write protection. |
Detailed Description
Initialization and Configuration functions.
=============================================================================== Initialization and Configuration functions =============================================================================== This section provide functions allowing to initialize and configure the RTC Prescaler (Synchronous and Asynchronous), RTC Hour format, disable RTC registers Write protection, enter and exit the RTC initialization mode, RTC registers synchronization check and reference clock detection enable. 1. The RTC Prescaler is programmed to generate the RTC 1Hz time base. It is split into 2 programmable prescaler to minimize power consumption. - A 7-bit asynchronous prescaler and A 13-bit or 15-bit synchronous prescaler depending to density of the mcu package. - When both prescaler are used, it is recommended to configure the asynchronous prescaler to a high value to minimize consumption. 2. All RTC registers are Write protected. Writing to the RTC registers is enabled by writing a key into the Write Protection register, RTC_WPR. 3. To Configure the RTC Calendar, user application should enter initialization mode. In this mode, the Calendar counter is stopped and its value can be updated. When the initialization sequence is complete, the Calendar restarts counting after 4 RTCCLK cycles. 4. 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. The RTC_WaitForSynchro() function implements the above software sequence (RSF clear and RSF check).
Function Documentation
void RTC_BypassShadowCmd | ( | FunctionalState | NewState | ) |
Enables or Disables the Bypass Shadow feature.
Definition at line 592 of file stm8l15x_rtc.c.
References DISABLE, IS_FUNCTIONAL_STATE, RTC, and RTC_CR1_BYPSHAD.
ErrorStatus RTC_DeInit | ( | void | ) |
Deinitializes the RTC registers to their default reset values.
- Note:
- This function doesn't reset the RTC Clock source.
Definition at line 226 of file stm8l15x_rtc.c.
References ERROR, RECALPF_TIMEOUT, RESET, RTC, RTC_ALRMAR1_RESET_VALUE, RTC_ALRMAR2_RESET_VALUE, RTC_ALRMAR3_RESET_VALUE, RTC_ALRMAR4_RESET_VALUE, RTC_ALRMASSMSKR_RESET_VALUE, RTC_ALRMASSRH_RESET_VALUE, RTC_ALRMASSRL_RESET_VALUE, RTC_APRER_RESET_VALUE, RTC_CALRH_RESET_VALUE, RTC_CALRL_RESET_VALUE, RTC_CR1_RESET_VALUE, RTC_CR2_RESET_VALUE, RTC_CR3_RESET_VALUE, RTC_DR1_RESET_VALUE, RTC_DR2_RESET_VALUE, RTC_DR3_RESET_VALUE, RTC_EnterInitMode(), RTC_ISR1_RECALPF, RTC_ISR1_WUTWF, RTC_ISR2_RESET_VALUE, RTC_SPRERH_RESET_VALUE, RTC_SPRERL_RESET_VALUE, RTC_TCR1_RESET_VALUE, RTC_TCR2_RESET_VALUE, RTC_TR1_RESET_VALUE, RTC_TR2_RESET_VALUE, RTC_TR3_RESET_VALUE, RTC_WaitForSynchro(), RTC_WUTRH_RESET_VALUE, RTC_WUTRL_RESET_VALUE, SUCCESS, and WUTWF_TIMEOUT.
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.
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.
Definition at line 492 of file stm8l15x_rtc.c.
References RTC, and RTC_ISR1_INIT.
ErrorStatus RTC_Init | ( | RTC_InitTypeDef * | RTC_InitStruct | ) |
Initializes the RTC registers according to the specified parameters in RTC_InitStruct.
- Note:
- The RTC Prescaler register is write protected and can be written in initialization mode only.
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_RatioCmd | ( | FunctionalState | NewState | ) |
Enables or Disables the RTC Ratio.
Definition at line 562 of file stm8l15x_rtc.c.
References DISABLE, IS_FUNCTIONAL_STATE, RTC, and RTC_CR1_RATIO.
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.
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_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.
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_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.
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.