Macros | Functions
stm32f30x_rtc.c File Reference

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

#include "stm32f30x_rtc.h"
#include "stm32f30x_rcc.h"
Include dependency graph for stm32f30x_rtc.c:

Go to the source code of this file.

Macros

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

Functions

ErrorStatus RTC_AlarmCmd (uint32_t RTC_Alarm, FunctionalState NewState)
 Enables or disables 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_AlarmSubSecondConfig (uint32_t RTC_Alarm, uint32_t RTC_AlarmSubSecondValue, uint32_t RTC_AlarmSubSecondMask)
 Configure the RTC AlarmA/B Sub seconds value and mask.*. More...
 
static uint8_t RTC_Bcd2ToByte (uint8_t Value)
 Convert from 2 digit BCD to Binary. More...
 
void RTC_BypassShadowCmd (FunctionalState NewState)
 Enables or Disables the Bypass Shadow feature. More...
 
static uint8_t RTC_ByteToBcd2 (uint8_t Value)
 Converts a 2 digit decimal to BCD format. 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...
 
void RTC_ClearFlag (uint32_t RTC_FLAG)
 Clears the RTC's pending flags. More...
 
void RTC_ClearITPendingBit (uint32_t RTC_IT)
 Clears the RTC's interrupt pending bits. More...
 
void RTC_DateStructInit (RTC_DateTypeDef *RTC_DateStruct)
 Fills each RTC_DateStruct member with its default value (Monday, January 01 xx00). More...
 
void RTC_DayLightSavingConfig (uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation)
 Adds or substract one hour from the current time. More...
 
ErrorStatus RTC_DeInit (void)
 Deinitializes the RTC registers to their default reset values. More...
 
ErrorStatus RTC_EnterInitMode (void)
 Enters the RTC Initialization mode. More...
 
void RTC_ExitInitMode (void)
 Exits the RTC Initialization mode. More...
 
void RTC_GetAlarm (uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef *RTC_AlarmStruct)
 Get the RTC Alarm value and masks. More...
 
uint32_t RTC_GetAlarmSubSecond (uint32_t RTC_Alarm)
 Gets the RTC Alarm Sub seconds value. More...
 
void RTC_GetDate (uint32_t RTC_Format, RTC_DateTypeDef *RTC_DateStruct)
 Get the RTC current date. More...
 
FlagStatus RTC_GetFlagStatus (uint32_t RTC_FLAG)
 Checks whether the specified RTC flag is set or not. More...
 
ITStatus RTC_GetITStatus (uint32_t RTC_IT)
 Checks whether the specified RTC interrupt has occurred or not. More...
 
uint32_t RTC_GetStoreOperation (void)
 Returns the RTC Day Light Saving stored operation. More...
 
uint32_t RTC_GetSubSecond (void)
 Gets the RTC current Calendar Sub seconds value. More...
 
void RTC_GetTime (uint32_t RTC_Format, RTC_TimeTypeDef *RTC_TimeStruct)
 Get the RTC current Time. 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 Sub seconds value. More...
 
uint32_t RTC_GetWakeUpCounter (void)
 Returns the RTC WakeUp timer counter value. More...
 
ErrorStatus RTC_Init (RTC_InitTypeDef *RTC_InitStruct)
 Initializes the RTC registers according to the specified parameters in RTC_InitStruct. More...
 
void RTC_ITConfig (uint32_t RTC_IT, FunctionalState NewState)
 Enables or disables the specified RTC interrupts. More...
 
void RTC_OutputConfig (uint32_t RTC_Output, uint32_t RTC_OutputPolarity)
 Configures the RTC output source (AFO_ALARM). More...
 
void RTC_OutputTypeConfig (uint32_t RTC_OutputType)
 Configures the RTC Output Pin mode. More...
 
uint32_t RTC_ReadBackupRegister (uint32_t RTC_BKP_DR)
 Reads data from the specified RTC Backup data Register. More...
 
ErrorStatus RTC_RefClockCmd (FunctionalState NewState)
 Enables or disables the RTC reference clock detection. More...
 
void RTC_SetAlarm (uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef *RTC_AlarmStruct)
 Set the specified RTC Alarm. More...
 
ErrorStatus RTC_SetDate (uint32_t RTC_Format, RTC_DateTypeDef *RTC_DateStruct)
 Set the RTC current date. More...
 
ErrorStatus RTC_SetTime (uint32_t RTC_Format, RTC_TimeTypeDef *RTC_TimeStruct)
 Set the RTC current time. More...
 
void RTC_SetWakeUpCounter (uint32_t RTC_WakeUpCounter)
 Configures the RTC Wakeup counter. More...
 
ErrorStatus RTC_SmoothCalibConfig (uint32_t RTC_SmoothCalibPeriod, uint32_t RTC_SmoothCalibPlusPulses, uint32_t RTC_SmouthCalibMinusPulsesValue)
 Configures the Smooth Calibration Settings. More...
 
void RTC_StructInit (RTC_InitTypeDef *RTC_InitStruct)
 Fills each RTC_InitStruct member with its default value. More...
 
ErrorStatus RTC_SynchroShiftConfig (uint32_t RTC_ShiftAdd1S, uint32_t RTC_ShiftSubFS)
 Configures the Synchronization Shift Control Settings. 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_TamperPinsPrechargeDuration (uint32_t RTC_TamperPrechargeDuration)
 Configures the Tampers Pins input Precharge Duration. More...
 
void RTC_TamperPullUpCmd (FunctionalState NewState)
 Enables or Disables the Precharge of Tamper pin. More...
 
void RTC_TamperSamplingFreqConfig (uint32_t RTC_TamperSamplingFreq)
 Configures the Tampers Sampling Frequency. More...
 
void RTC_TamperTriggerConfig (uint32_t RTC_Tamper, uint32_t RTC_TamperTrigger)
 Configures the select Tamper pin edge. 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_TimeStampOnTamperDetectionCmd (FunctionalState NewState)
 Enables or Disables the TimeStamp on Tamper Detection Event. More...
 
void RTC_TimeStructInit (RTC_TimeTypeDef *RTC_TimeStruct)
 Fills each RTC_TimeStruct member with its default value (Time = 00h:00min:00sec). 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_WakeUpClockConfig (uint32_t RTC_WakeUpClock)
 Configures the RTC Wakeup clock source. More...
 
ErrorStatus RTC_WakeUpCmd (FunctionalState NewState)
 Enables or Disables the RTC WakeUp timer. More...
 
void RTC_WriteBackupRegister (uint32_t RTC_BKP_DR, uint32_t Data)
 Writes a data in a specified RTC Backup data register. More...
 
void RTC_WriteProtectionCmd (FunctionalState NewState)
 Enables or disables the RTC registers write protection. More...
 

Detailed Description

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

Author
MCD Application Team
Version
V1.1.1
Date
04-April-2014
  • Initialization
  • Calendar (Time and Date) configuration
  • Alarms (Alarm A and Alarm B) configuration
  • WakeUp Timer configuration
  • Daylight Saving configuration
  • Output pin Configuration
  • Smooth digital Calibration configuration
  • TimeStamp configuration
  • Tampers configuration
  • Backup Data Registers configuration
  • Output Type Config configuration
  • Shift control synchronisation
  • Interrupts and flags management
===============================================================================     
                         ##### RTC Operating Condition #####
===============================================================================
   [..] The real-time clock (RTC) and the RTC backup registers can be powered
        from the VBAT voltage when the main VDD supply is powered off.
        To retain the content of the RTC backup registers and supply the RTC 
        when VDD is turned off, VBAT pin can be connected to an optional
        standby voltage supplied by a battery or by another source.
 
   [..] To allow the RTC to operate even when the main digital supply (VDD) 
        is turned off, the VBAT pin powers the following blocks:
          (#) The RTC
          (#) The LSE oscillator
          (#) PC13 to PC15 I/Os (when available)
 
   [..] When the backup domain is supplied by VDD (analog switch connected 
        to VDD), the following functions are available:
          (#) PC14 and PC15 can be used as either GPIO or LSE pins
          (#) PC13 can be used as a GPIO or as the RTC_AF pin
 
   [..] When the backup domain is supplied by VBAT (analog switch connected 
        to VBAT because VDD is not present), the following functions are available:
          (#) PC14 and PC15 can be used as LSE pins only
          (#) PC13 can be used as the RTC_AF pin 

                       ##### Backup Domain Reset #####
===============================================================================
   [..] The backup domain reset sets all RTC registers and the RCC_BDCR 
        register to their reset values. 
        A backup domain reset is generated when one of the following events
        occurs:
          (#) Software reset, triggered by setting the BDRST bit in the 
              RCC Backup domain control register (RCC_BDCR). You can use the
              RCC_BackupResetCmd().
          (#) VDD or VBAT power on, if both supplies have previously been
              powered off.
                        
                       ##### Backup Domain Access #####
===============================================================================
   [..] After reset, the backup domain (RTC registers and RTC backup data 
        registers) is protected against possible unwanted write accesses. 
   [..] To enable access to the Backup Domain and RTC registers, proceed as follows:
        (#) Enable the Power Controller (PWR) APB1 interface clock using the
            RCC_APB1PeriphClockCmd() function.
        (#) Enable access to Backup domain using the PWR_BackupAccessCmd() function.
        (#) Select the RTC clock source using the RCC_RTCCLKConfig() function.
        (#) Enable RTC Clock using the RCC_RTCCLKCmd() function.
             
                        ##### How to use this driver #####
===============================================================================
   [..]     
       (+) Enable the backup 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.
        (+) To read the RTC subsecond, use the RTC_GetSubSecond() function.
        (+) Use the RTC_DayLightSavingConfig() function to add or sub one
            hour 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.
        (+) To read the RTC alarm SubSecond, use the RTC_GetAlarmSubSecond() 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 A, Alarm B
            and WaKeUp signals.          
            To output the selected RTC signal on RTC_AF pin, use the 
            RTC_OutputConfig() function.                
        (+) AFO_CALIB: this output is 512Hz signal or 1Hz .
            To output the RTC Clock on RTC_AF pin, use the RTC_CalibOutputCmd()
            function.                
               
   *** Smooth digital Calibration configuration ***
   ================================================    
   [..]
        (+) Configure the RTC Original Digital Calibration Value and the corresponding
            calibration cycle period (32s,16s and 8s) using the RTC_SmoothCalibConfig() 
            function.                                                       
               
   *** TimeStamp configuration ***
   ===============================    
   [..]
        (+) Configure the RTC_AF trigger and enables the RTC TimeStamp 
            using the RTC_TimeStampCmd() function.
        (+) To read the RTC TimeStamp Time and Date register, use the 
            RTC_GetTimeStamp() function.
        (+) To read the RTC TimeStamp SubSecond register, use the 
            RTC_GetTimeStampSubSecond() function.    

   *** Tamper configuration ***
   ============================    
   [..]
        (+) Configure the Tamper filter count using RTC_TamperFilterConfig()
            function. 
        (+) Configure the RTC Tamper trigger Edge or Level according to the Tamper 
            filter (if equal to 0 Edge else Level) value using the RTC_TamperConfig() function.
        (+) Configure the Tamper sampling frequency using RTC_TamperSamplingFreqConfig()
            function.
        (+) Configure the Tamper precharge or discharge duration using 
            RTC_TamperPinsPrechargeDuration() function.
        (+) Enable the Tamper Pull-UP using RTC_TamperPullUpDisableCmd() function.
        (+) Enable the RTC Tamper using the RTC_TamperCmd() function.
        (+) Enable the Time stamp on Tamper detection event using  
            RTC_TSOnTamperDetecCmd() function.     

   *** Backup Data Registers configuration ***
   ===========================================    
   [..]
        (+) To write to the RTC Backup Data registers, use the RTC_WriteBackupRegister()
            function.  
        (+) To read the RTC Backup Data registers, use the RTC_ReadBackupRegister()
            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 (Alarm A and Alarm B), 
        RTC wakeup, RTC tamper event detection and RTC time stamp event detection.
        These RTC alternate functions can wake up the system from the Stop 
        and Standby 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 
        Stop or Standby mode at regular intervals.
        Wakeup from STOP and Standby modes is possible only when the RTC 
        clock source is LSE or LSI.
          
               ##### Selection of RTC_AF alternate functions #####
===============================================================================
   [..] The RTC_AF pin (PC13) can be used for the following purposes:
        (+) Wakeup pin 2 (WKUP2) using the PWR_WakeUpPinCmd() function.
        (+) AFO_ALARM output      
        (+) AFO_CALIB output
        (+) AFI_TAMPER
        (+) AFI_TIMESTAMP
                        
+------------------------------------------------------------------------------------------+
|     Pin         |RTC ALARM |RTC CALIB |RTC TAMPER |RTC TIMESTAMP |PC13MODE|  PC13VALUE   |
|  configuration  | OUTPUT   | OUTPUT   |  INPUT    |    INPUT     |  bit   |     bit      |
|  and function   | ENABLED  | ENABLED  | ENABLED   |   ENABLED    |        |              |
|-----------------|----------|----------|-----------|--------------|--------|--------------|
|   Alarm out     |          |          |           |              | Don't  |              |
|   output OD     |     1    |Don't care|Don't care | Don't care   | care   |      0       |
|-----------------|----------|----------|-----------|--------------|--------|--------------|
|   Alarm out     |          |          |           |              | Don't  |              |
|   output PP     |     1    |Don't care|Don't care | Don't care   | care   |      1       |
|-----------------|----------|----------|-----------|--------------|--------|--------------|
| Calibration out |          |          |           |              | Don't  |              |
|   output PP     |     0    |    1     |Don't care | Don't care   | care   |  Don't care  |
|-----------------|----------|----------|-----------|--------------|--------|--------------|
|  TAMPER input   |          |          |           |              | Don't  |              |
|   floating      |     0    |    0     |     1     |      0       | care   |  Don't care  |
|-----------------|----------|----------|-----------|--------------|--------|--------------|
|  TIMESTAMP and  |          |          |           |              | Don't  |              |
|  TAMPER input   |     0    |    0     |     1     |      1       | care   |  Don't care  |
|   floating      |          |          |           |              |        |              |
|-----------------|----------|----------|-----------|--------------|--------|--------------|
| TIMESTAMP input |          |          |           |              | Don't  |              |
|    floating     |     0    |    0     |     0     |      1       | care   |  Don't care  |
|-----------------|----------|----------|-----------|--------------|--------|--------------|
|   Output PP     |     0    |    0     |     0     |      0       |   1    | PC13 output  |
|    Forced       |          |          |           |              |        |              |
|-----------------|----------|----------|-----------|--------------|--------|--------------|
|  Wakeup Pin or  |     0    |    0     |     0     |      0       |   0    | Don't care   |
|  Standard GPIO  |          |          |           |              |        |              |
+------------------------------------------------------------------------------------------+
Attention

© COPYRIGHT 2014 STMicroelectronics

Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at:

   http://www.st.com/software_license_agreement_liberty_v2

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file stm32f30x_rtc.c.



rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:07:52