STM8L15x Standard Peripherals Drivers: stm8l15x_rtc.c File Reference

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

stm8l15x_rtc.c File Reference

This file provides firmware functions to manage the following functionalities of the Real-Time Clock (RTC) peripheral:

  • Initialization
  • Calendar (Time and Date) configuration
  • Alarm configuration
  • WakeUp Timer configuration
  • Daylight Saving configuration
  • Output pin Configuration
  • Smooth Calibration configuration
  • Tampers configuration
  • Output Type configuration
  • Interrupts and flags management.
More...
#include "stm8l15x_rtc.h"

Go to the source code of this file.

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

static uint8_t Bcd2ToByte (uint8_t Value)
 Converts from 2 digit BCD to Binary format.
static uint8_t ByteToBcd2 (uint8_t Value)
 Converts a 2 digit decimal to BCD format.
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

This file provides firmware functions to manage the following functionalities of the Real-Time Clock (RTC) peripheral:

  • Initialization
  • Calendar (Time and Date) configuration
  • Alarm configuration
  • WakeUp Timer configuration
  • Daylight Saving configuration
  • Output pin Configuration
  • Smooth Calibration configuration
  • Tampers configuration
  • Output Type configuration
  • Interrupts and flags management.
Author:
MCD Application Team
Version:
V1.5.0
Date:
13-May-2011
  *       
  *          ===================================================================      
  *                                    RTC Domain Reset
  *          ===================================================================          
  *          After power-on reset, the RTC domain (RTC registers) is reset.        
  *         
  *          ===================================================================      
  *                                  RTC Operating Condition      
  *          ===================================================================            
  *          As long as the supply voltage remains in the operating range, 
  *          the RTC never stops, regardless of the device status (Run mode, 
  *          low power modes or under reset).
  *              
  *          ===================================================================      
  *                                   RTC Domain Access     
  *          ===================================================================         
  *          After reset, the RTC domain (RTC registers) is protected against 
  *          possible stray write accesses. 
  *          To enable access to the RTC registers, proceed as follows:
  *            - Select the RTC clock source using the CLK_RTCClockConfig()
  *              function : HSE, HSI, LSE or LSI.
  *              CLK_RTCClockConfig(CLK_RTCCLKSource_HSI, CLK_RTCCLKDiv_1)    
  *            - Enable RTC Clock using the CLK_PeripheralClockConfig() function 
  *               : CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE).
  *              
  *          ===================================================================      
  *                                   RTC Driver: how to use it
  *          ===================================================================          
  *            - Enable the RTC domain access (see description in the section above)
  *            - Configure the RTC Prescaler (Asynchronous and Synchronous) and
  *              RTC hour format using the RTC_Init() function.
  *                
  *          Time and Date configuration
  *          ===========================    
  *            - To configure the RTC Calendar (Time and Date) use the RTC_SetTime()
  *              and RTC_SetDate() functions.
  *            - To read the RTC Calendar, use the RTC_GetTime() and RTC_GetDate()
  *              functions.
  *            - Use the RTC_DayLightSavingConfig() function to add or sub 1hour
  *              to the RTC Calendar.    
  *                
  *          Alarm configuration
  *          ===================    
  *            - To configure the RTC Alarm use the RTC_SetAlarm() function.
  *            - Enable the selected RTC Alarm using the RTC_AlarmCmd() function  
  *            - To read the RTC Alarm, use the RTC_GetAlarm() function.
  *              
  *          RTC Wakeup configuration
  *          ========================    
  *            - Configure the RTC Wakeup Clock source use the RTC_WakeUpClockConfig()
  *              function.
  *            - Configure the RTC WakeUp Counter using the RTC_SetWakeUpCounter() 
  *              function  
  *            - Enable the RTC WakeUp using the RTC_WakeUpCmd() function  
  *            - To read the RTC WakeUp Counter register, use the RTC_GetWakeUpCounter() 
  *              function.
  *                
  *          Outputs configuration
  *          =====================  
  *          The RTC has 2 different outputs:
  *            - AFO_ALARM: this output is used to manage the RTC Alarm and 
  *              WaKeUp signals.          
  *              To output the selected RTC signal on RTC_ALARM pin, use the 
  *              RTC_OutputConfig() function.                
  *            - AFO_CALIB: this output is used to manage the RTC Clock divided 
  *              by 64 (512Hz) signal or divided by 32768 (1Hz) which can be 
  *              configured using RTC_CalibOutputConfig() function.
  *              To output the RTC Clock on RTC_CALIB pin, use the 
  *              RTC_CalibOutputCmd() function.                
  *                                                           
  *          Smooth Calibration configuration                    
  *          =================================    
  *            - Configure the RTC Smooth Calibration Value and the corresponding
  *              sign using the RTC_SmoothCalibConfig() function.

  *                
  *
  *          Tamper configuration                     
  *          ====================    
  *            - Configure the RTC Tamper Level using the RTC_TamperConfig() 
  *              function.
  *            - Enable the RTC Tamper using the RTC_TamperCmd() function.
  *
  *                                  
  *          ===================================================================      
  *                                  RTC and low power modes
  *          =================================================================== 
  *           The MCU can be woken up from a low power mode by an RTC alternate 
  *           function.
  *           The RTC alternate functions are the RTC alarms, 
  *           RTC wakeup and RTC tamper event detection.
  *           These RTC alternate functions can wake up the system from the 
  *           lowpower modes.
  *           The system can also wake up from low power modes without depending 
  *           on an external interrupt (Auto-wakeup mode), by using the RTC alarm 
  *           or the RTC wakeup events.
  *           The RTC provides a programmable time base for waking up from the 
  *           halt or wfe or wfi modes at regular intervals.
  *           
  *                         
  *  
Attention:

THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.

© COPYRIGHT 2011 STMicroelectronics

Definition in file stm8l15x_rtc.c.

STM8S Firmware Library: Overview

 

 

 

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