STM32L443xx HAL User Manual
stm32l4xx_hal_rtc.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_hal_rtc.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of RTC HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2017 STMicroelectronics.
00010   * All rights reserved.
00011   *
00012   * This software is licensed under terms that can be found in the LICENSE file
00013   * in the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015   *
00016   ******************************************************************************
00017   */
00018 
00019 /* Define to prevent recursive inclusion -------------------------------------*/
00020 #ifndef STM32L4xx_HAL_RTC_H
00021 #define STM32L4xx_HAL_RTC_H
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 /* Includes ------------------------------------------------------------------*/
00028 #include "stm32l4xx_hal_def.h"
00029 
00030 /** @addtogroup STM32L4xx_HAL_Driver
00031   * @{
00032   */
00033 
00034 /** @defgroup RTC RTC
00035   * @{
00036   */
00037 
00038 /* Exported types ------------------------------------------------------------*/
00039 /** @defgroup RTC_Exported_Types RTC Exported Types
00040   * @{
00041   */
00042 
00043 /**
00044   * @brief  HAL State structures definition
00045   */
00046 typedef enum
00047 {
00048   HAL_RTC_STATE_RESET             = 0x00U,  /*!< RTC not yet initialized or disabled */
00049   HAL_RTC_STATE_READY             = 0x01U,  /*!< RTC initialized and ready for use   */
00050   HAL_RTC_STATE_BUSY              = 0x02U,  /*!< RTC process is ongoing              */
00051   HAL_RTC_STATE_TIMEOUT           = 0x03U,  /*!< RTC timeout state                   */
00052   HAL_RTC_STATE_ERROR             = 0x04U   /*!< RTC error state                     */
00053 
00054 } HAL_RTCStateTypeDef;
00055 
00056 /**
00057   * @brief  RTC Configuration Structure definition
00058   */
00059 typedef struct
00060 {
00061   uint32_t HourFormat;      /*!< Specifies the RTC Hour Format.
00062                                  This parameter can be a value of @ref RTC_Hour_Formats */
00063 
00064   uint32_t AsynchPrediv;    /*!< Specifies the RTC Asynchronous Predivider value.
00065                                  This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */
00066 
00067   uint32_t SynchPrediv;     /*!< Specifies the RTC Synchronous Predivider value.
00068                                  This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF */
00069 
00070   uint32_t OutPut;          /*!< Specifies which signal will be routed to the RTC output.
00071                                  This parameter can be a value of @ref RTCEx_Output_selection_Definitions */
00072 
00073   uint32_t OutPutRemap;     /*!< Specifies the remap for RTC output.
00074                                  This parameter can be a value of @ref  RTC_Output_ALARM_OUT_Remap */
00075 
00076   uint32_t OutPutPolarity;  /*!< Specifies the polarity of the output signal.
00077                                  This parameter can be a value of @ref RTC_Output_Polarity_Definitions */
00078 
00079   uint32_t OutPutType;      /*!< Specifies the RTC Output Pin mode.
00080                                  This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */
00081 #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00082   uint32_t OutPutPullUp;    /*!< Specifies the RTC Output Pull-Up mode.
00083                                  This parameter can be a value of @ref RTC_Output_PullUp_ALARM_OUT */
00084 #endif
00085 
00086 #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00087   uint32_t BinMode;         /*!< Specifies the RTC binary mode.
00088                                  This parameter can be a value of @ref RTCEx_Binary_Mode */
00089 
00090   uint32_t BinMixBcdU;      /*!< Specifies the BCD calendar update if and only if BinMode = RTC_BINARY_MIX.
00091                                  This parameter can be a value of @ref RTCEx_Binary_mix_BCDU */
00092 #endif
00093 } RTC_InitTypeDef;
00094 
00095 /**
00096   * @brief  RTC Time structure definition
00097   */
00098 typedef struct
00099 {
00100   uint8_t Hours;            /*!< Specifies the RTC Time Hour.
00101                                  This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected.
00102                                  This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */
00103 
00104   uint8_t Minutes;          /*!< Specifies the RTC Time Minutes.
00105                                  This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
00106 
00107   uint8_t Seconds;          /*!< Specifies the RTC Time Seconds.
00108                                  This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
00109 
00110   uint8_t TimeFormat;       /*!< Specifies the RTC AM/PM Time.
00111                                  This parameter can be a value of @ref RTC_AM_PM_Definitions */
00112 
00113 #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00114   uint32_t SubSeconds;      /*!< Specifies the RTC_SSR RTC Sub Second register content.
00115                                  This field is not used by HAL_RTC_SetTime.
00116                                  If the free running 32 bit counter is not activated (mode binary none)
00117                                     - This parameter corresponds to a time unit range between [0-1] Second with [1 Sec / SecondFraction +1] granularity
00118                                  else
00119                                     - This parameter corresponds to the free running 32 bit counter. */
00120 #else
00121   uint32_t SubSeconds;      /*!< Specifies the RTC_SSR RTC Sub Second register content.
00122                                  This parameter corresponds to a time unit range between [0-1] Second
00123                                  with [1 Sec / SecondFraction +1] granularity */
00124 #endif
00125 
00126   uint32_t SecondFraction;  /*!< Specifies the range or granularity of Sub Second register content
00127                                  corresponding to Synchronous pre-scaler factor value (PREDIV_S)
00128                                  This parameter corresponds to a time unit range between [0-1] Second
00129                                  with [1 Sec / SecondFraction +1] granularity.
00130                                  This field will be used only by HAL_RTC_GetTime function */
00131 
00132   uint32_t DayLightSaving;  /*!< This interface is deprecated. To manage Daylight Saving Time, please use HAL_RTC_DST_xxx functions */
00133 
00134   uint32_t StoreOperation;  /*!< This interface is deprecated. To manage Daylight Saving Time, please use HAL_RTC_DST_xxx functions */
00135 } RTC_TimeTypeDef;
00136 
00137 /**
00138   * @brief  RTC Date structure definition
00139   */
00140 typedef struct
00141 {
00142   uint8_t WeekDay;  /*!< Specifies the RTC Date WeekDay.
00143                          This parameter can be a value of @ref RTC_WeekDay_Definitions */
00144 
00145   uint8_t Month;    /*!< Specifies the RTC Date Month (in BCD format).
00146                          This parameter can be a value of @ref RTC_Month_Date_Definitions */
00147 
00148   uint8_t Date;     /*!< Specifies the RTC Date.
00149                          This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
00150 
00151   uint8_t Year;     /*!< Specifies the RTC Date Year.
00152                          This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
00153 
00154 } RTC_DateTypeDef;
00155 
00156 /**
00157   * @brief  RTC Alarm structure definition
00158   */
00159 typedef struct
00160 {
00161   RTC_TimeTypeDef AlarmTime;     /*!< Specifies the RTC Alarm Time members */
00162 
00163   uint32_t AlarmMask;            /*!< Specifies the RTC Alarm Masks.
00164                                       This parameter can be a value of @ref RTC_AlarmMask_Definitions */
00165 
00166 #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00167   uint32_t SubSeconds;           /*!< Specifies the RTC_SSR RTC Sub Second register content.
00168                                       This field is not used by HAL_RTC_SetTime.
00169                                        If the free running 32 bit counter is not activated (mode binary none)
00170                                           - This parameter corresponds to a time unit range between [0-1] Second with [1 Sec / SecondFraction +1] granularity
00171                                        else
00172                                           - This parameter corresponds to the free running 32 bit counter. */
00173   uint32_t BinaryAutoClr;        /*!< Clear synchronously counter (RTC_SSR) on binary alarm.
00174                                       RTC_ALARMSUBSECONDBIN_AUTOCLR_YES must only be used if Binary mode is RTC_BINARY_ONLY
00175                                       This parameter can be a value of @ref RTCEx_Alarm_Sub_Seconds_binary_Clear_Definitions */
00176 #else
00177   uint32_t SubSeconds;           /*!< Specifies the RTC_SSR RTC Sub Second register content. */
00178 #endif
00179 
00180   uint32_t AlarmSubSecondMask;   /*!< Specifies the RTC Alarm SubSeconds Masks.
00181                                       This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */
00182 
00183   uint32_t AlarmDateWeekDaySel;  /*!< Specifies the RTC Alarm is on Date or WeekDay.
00184                                      This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
00185 
00186   uint8_t AlarmDateWeekDay;      /*!< Specifies the RTC Alarm Date/WeekDay.
00187                                       If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range.
00188                                       If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */
00189 
00190   uint32_t Alarm;                /*!< Specifies the alarm .
00191                                       This parameter can be a value of @ref RTC_Alarms_Definitions */
00192 } RTC_AlarmTypeDef;
00193 
00194 /**
00195   * @brief  RTC Handle Structure definition
00196   */
00197 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
00198 typedef struct __RTC_HandleTypeDef
00199 #else
00200 typedef struct
00201 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
00202 {
00203   RTC_TypeDef               *Instance;  /*!< Register base address    */
00204 
00205 #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00206   uint32_t                  TampOffset; /*!< Offset to TAMP instance  */
00207 #endif
00208   RTC_InitTypeDef           Init;       /*!< RTC required parameters  */
00209 
00210   HAL_LockTypeDef           Lock;       /*!< RTC locking object       */
00211 
00212   __IO HAL_RTCStateTypeDef  State;      /*!< Time communication state */
00213 
00214 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
00215   void (* AlarmAEventCallback)(struct __RTC_HandleTypeDef *hrtc);                    /*!< RTC Alarm A Event callback            */
00216   void (* AlarmBEventCallback)(struct __RTC_HandleTypeDef *hrtc);                    /*!< RTC Alarm B Event callback            */
00217   void (* TimeStampEventCallback)(struct __RTC_HandleTypeDef *hrtc);                 /*!< RTC TimeStamp Event callback          */
00218   void (* WakeUpTimerEventCallback)(struct __RTC_HandleTypeDef *hrtc);               /*!< RTC WakeUpTimer Event callback        */
00219 #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00220   void (* SSRUEventCallback)(struct __RTC_HandleTypeDef *hrtc);                      /*!< RTC SSRU Event callback               */
00221 #endif
00222 #if defined(RTC_TAMPER1_SUPPORT)
00223   void (* Tamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc);                   /*!< RTC Tamper 1 Event callback           */
00224 #endif /* RTC_TAMPER1_SUPPORT */
00225   void (* Tamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc);                   /*!< RTC Tamper 2 Event callback           */
00226 #if defined(RTC_TAMPER3_SUPPORT)
00227   void (* Tamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc);                   /*!< RTC Tamper 3 Event callback           */
00228 #endif /* RTC_TAMPER3_SUPPORT */
00229   void (* MspInitCallback)(struct __RTC_HandleTypeDef *hrtc);                        /*!< RTC Msp Init callback                 */
00230   void (* MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc);                      /*!< RTC Msp DeInit callback               */
00231 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
00232 
00233 } RTC_HandleTypeDef;
00234 
00235 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
00236 /**
00237   * @brief  HAL RTC Callback ID enumeration definition
00238   */
00239 typedef enum
00240 {
00241   HAL_RTC_ALARM_A_EVENT_CB_ID            =  0u,    /*!< RTC Alarm A Event Callback ID      */
00242   HAL_RTC_ALARM_B_EVENT_CB_ID            =  1u,    /*!< RTC Alarm B Event Callback ID      */
00243   HAL_RTC_TIMESTAMP_EVENT_CB_ID          =  2u,    /*!< RTC TimeStamp Event Callback ID    */
00244   HAL_RTC_WAKEUPTIMER_EVENT_CB_ID        =  3u,    /*!< RTC WakeUp Timer Event Callback ID */
00245 #if defined(RTC_TAMPER1_SUPPORT)
00246   HAL_RTC_TAMPER1_EVENT_CB_ID            =  4u,    /*!< RTC Tamper 1 Callback ID           */
00247 #endif /* RTC_TAMPER1_SUPPORT */
00248   HAL_RTC_TAMPER2_EVENT_CB_ID            =  5u,    /*!< RTC Tamper 2 Callback ID           */
00249 #if defined(RTC_TAMPER3_SUPPORT)
00250   HAL_RTC_TAMPER3_EVENT_CB_ID            =  6u,    /*!< RTC Tamper 3 Callback ID           */
00251 #endif /* RTC_TAMPER3_SUPPORT */
00252   HAL_RTC_MSPINIT_CB_ID                  =  7u,    /*!< RTC Msp Init callback ID           */
00253   HAL_RTC_MSPDEINIT_CB_ID                =  8u     /*!< RTC Msp DeInit callback ID         */
00254 } HAL_RTC_CallbackIDTypeDef;
00255 
00256 /**
00257   * @brief  HAL RTC Callback pointer definition
00258   */
00259 typedef  void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc);  /*!< pointer to an RTC callback function */
00260 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
00261 
00262 /**
00263   * @}
00264   */
00265 
00266 /* Exported constants --------------------------------------------------------*/
00267 /** @defgroup RTC_Exported_Constants RTC Exported Constants
00268   * @{
00269   */
00270 
00271 /** @defgroup RTC_Hour_Formats_Definitions RTC Hour Formats Definitions
00272   * @{
00273   */
00274 #define RTC_HOURFORMAT_24                   0x00000000u
00275 #define RTC_HOURFORMAT_12                   RTC_CR_FMT
00276 /**
00277   * @}
00278   */
00279 
00280 /** @defgroup RTCEx_Output_selection_Definitions RTCEx Output Selection Definitions
00281   * @{
00282   */
00283 #define RTC_OUTPUT_DISABLE                  0x00000000u
00284 #define RTC_OUTPUT_ALARMA                   RTC_CR_OSEL_0
00285 #define RTC_OUTPUT_ALARMB                   RTC_CR_OSEL_1
00286 #define RTC_OUTPUT_WAKEUP                   RTC_CR_OSEL
00287 #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00288 #define RTC_OUTPUT_TAMPER                   RTC_CR_TAMPOE
00289 #endif
00290 /**
00291   * @}
00292   */
00293 
00294 /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions
00295   * @{
00296   */
00297 #define RTC_OUTPUT_POLARITY_HIGH            0x00000000u
00298 #define RTC_OUTPUT_POLARITY_LOW             RTC_CR_POL
00299 /**
00300   * @}
00301   */
00302 
00303 /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT
00304   * @{
00305   */
00306 #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00307 #define RTC_OUTPUT_TYPE_PUSHPULL            0x00000000u
00308 #define RTC_OUTPUT_TYPE_OPENDRAIN           RTC_CR_TAMPALRM_TYPE
00309 #else
00310 #define RTC_OUTPUT_TYPE_PUSHPULL            RTC_OR_ALARMOUTTYPE
00311 #define RTC_OUTPUT_TYPE_OPENDRAIN           0x00000000u
00312 #endif
00313 /**
00314   * @}
00315   */
00316 
00317 /** @defgroup RTC_Output_PullUp_ALARM_OUT RTC Output Pull-Up ALARM OUT
00318   * @{
00319   */
00320 #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00321 #define RTC_OUTPUT_PULLUP_NONE              0x00000000u
00322 #define RTC_OUTPUT_PULLUP_ON                RTC_CR_TAMPALRM_PU
00323 #endif
00324 /**
00325   * @}
00326   */
00327 
00328 /** @defgroup RTC_Output_ALARM_OUT_Remap RTC Output ALARM OUT Remap
00329   * @{
00330   */
00331 #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00332 #define RTC_OUTPUT_REMAP_NONE               0x00000000u
00333 #define RTC_OUTPUT_REMAP_POS1               RTC_CR_OUT2EN
00334 #else
00335 #define RTC_OUTPUT_REMAP_NONE               0x00000000u
00336 #define RTC_OUTPUT_REMAP_POS1               RTC_OR_OUT_RMP
00337 #endif
00338 /**
00339   * @}
00340   */
00341 
00342 /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions
00343   * @{
00344   */
00345 #define RTC_HOURFORMAT12_AM            ((uint8_t)0x00)
00346 #define RTC_HOURFORMAT12_PM            ((uint8_t)0x01)
00347 /**
00348   * @}
00349   */
00350 
00351 /** @defgroup RTC_DayLightSaving_Definitions RTC DayLightSaving Definitions
00352   * @{
00353   */
00354 #define RTC_DAYLIGHTSAVING_SUB1H            RTC_CR_SUB1H
00355 #define RTC_DAYLIGHTSAVING_ADD1H            RTC_CR_ADD1H
00356 #define RTC_DAYLIGHTSAVING_NONE             0x00000000u
00357 /**
00358   * @}
00359   */
00360 
00361 /** @defgroup RTC_StoreOperation_Definitions RTC StoreOperation Definitions
00362   * @{
00363   */
00364 #define RTC_STOREOPERATION_RESET            0x00000000u
00365 #define RTC_STOREOPERATION_SET              RTC_CR_BKP
00366 /**
00367   * @}
00368   */
00369 
00370 #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00371 /** @defgroup RTC_Input_parameter_format_definitions RTC input or output data format for date (Year, Month, Weekday) and time (Hours, Minutes, Seconds).
00372   *           Warning : It Should not be confused with the Binary mode @ref RTCEx_Binary_Mode.
00373   * @{
00374   */
00375 #define RTC_FORMAT_BIN                      0x00000000u /* This parameter will trigger a SW conversion to fit with the native BCD format of the HW Calendar.
00376                                                            It should not be confused with the Binary mode @ref RTCEx_Binary_Mode. */
00377 
00378 #define RTC_FORMAT_BCD                      0x00000001u /* Native format of the HW Calendar.
00379                                                            It should not be confused with the Binary mode @ref RTCEx_Binary_Mode. */
00380 /**
00381   * @}
00382   */
00383 #else
00384 
00385 /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions
00386   * @{
00387   */
00388 #define RTC_FORMAT_BIN                      0x00000000u
00389 #define RTC_FORMAT_BCD                      0x00000001u
00390 /**
00391   * @}
00392   */
00393 #endif
00394 
00395 /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions (in BCD format)
00396   * @{
00397   */
00398 
00399 /* Coded in BCD format */
00400 #define RTC_MONTH_JANUARY                   ((uint8_t)0x01U)
00401 #define RTC_MONTH_FEBRUARY                  ((uint8_t)0x02U)
00402 #define RTC_MONTH_MARCH                     ((uint8_t)0x03U)
00403 #define RTC_MONTH_APRIL                     ((uint8_t)0x04U)
00404 #define RTC_MONTH_MAY                       ((uint8_t)0x05U)
00405 #define RTC_MONTH_JUNE                      ((uint8_t)0x06U)
00406 #define RTC_MONTH_JULY                      ((uint8_t)0x07U)
00407 #define RTC_MONTH_AUGUST                    ((uint8_t)0x08U)
00408 #define RTC_MONTH_SEPTEMBER                 ((uint8_t)0x09U)
00409 #define RTC_MONTH_OCTOBER                   ((uint8_t)0x10U)
00410 #define RTC_MONTH_NOVEMBER                  ((uint8_t)0x11U)
00411 #define RTC_MONTH_DECEMBER                  ((uint8_t)0x12U)
00412 
00413 /**
00414   * @}
00415   */
00416 
00417 /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions
00418   * @{
00419   */
00420 #define RTC_WEEKDAY_MONDAY                  ((uint8_t)0x01U)
00421 #define RTC_WEEKDAY_TUESDAY                 ((uint8_t)0x02U)
00422 #define RTC_WEEKDAY_WEDNESDAY               ((uint8_t)0x03U)
00423 #define RTC_WEEKDAY_THURSDAY                ((uint8_t)0x04U)
00424 #define RTC_WEEKDAY_FRIDAY                  ((uint8_t)0x05U)
00425 #define RTC_WEEKDAY_SATURDAY                ((uint8_t)0x06U)
00426 #define RTC_WEEKDAY_SUNDAY                  ((uint8_t)0x07U)
00427 
00428 /**
00429   * @}
00430   */
00431 
00432 /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC AlarmDateWeekDay Definitions
00433   * @{
00434   */
00435 #define RTC_ALARMDATEWEEKDAYSEL_DATE        0x00000000u
00436 #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY     RTC_ALRMAR_WDSEL
00437 
00438 /**
00439   * @}
00440   */
00441 
00442 /** @defgroup RTC_AlarmMask_Definitions RTC AlarmMask Definitions
00443   * @{
00444   */
00445 #define RTC_ALARMMASK_NONE                  0x00000000u
00446 #define RTC_ALARMMASK_DATEWEEKDAY           RTC_ALRMAR_MSK4
00447 #define RTC_ALARMMASK_HOURS                 RTC_ALRMAR_MSK3
00448 #define RTC_ALARMMASK_MINUTES               RTC_ALRMAR_MSK2
00449 #define RTC_ALARMMASK_SECONDS               RTC_ALRMAR_MSK1
00450 #define RTC_ALARMMASK_ALL                   (RTC_ALARMMASK_DATEWEEKDAY | RTC_ALARMMASK_HOURS  | \
00451                                              RTC_ALARMMASK_MINUTES | RTC_ALARMMASK_SECONDS)
00452 
00453 /**
00454   * @}
00455   */
00456 
00457 /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions
00458   * @{
00459   */
00460 #define RTC_ALARM_A                         RTC_CR_ALRAE
00461 #define RTC_ALARM_B                         RTC_CR_ALRBE
00462 
00463 /**
00464   * @}
00465   */
00466 
00467 
00468 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions
00469   * @{
00470   */
00471 #define RTC_ALARMSUBSECONDMASK_ALL          0x00000000u                                                              /*!< All Alarm SS fields are masked.
00472                                                                                                                           There is no comparison on sub seconds
00473                                                                                                                           for Alarm */
00474 #define RTC_ALARMSUBSECONDMASK_SS14_1       RTC_ALRMASSR_MASKSS_0                                                    /*!< SS[14:1] are don't care in Alarm
00475                                                                                                                           comparison. Only SS[0] is compared.    */
00476 #define RTC_ALARMSUBSECONDMASK_SS14_2       RTC_ALRMASSR_MASKSS_1                                                    /*!< SS[14:2] are don't care in Alarm
00477                                                                                                                           comparison. Only SS[1:0] are compared  */
00478 #define RTC_ALARMSUBSECONDMASK_SS14_3       (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1)                          /*!< SS[14:3] are don't care in Alarm
00479                                                                                                                           comparison. Only SS[2:0] are compared  */
00480 #define RTC_ALARMSUBSECONDMASK_SS14_4       RTC_ALRMASSR_MASKSS_2                                                    /*!< SS[14:4] are don't care in Alarm
00481                                                                                                                           comparison. Only SS[3:0] are compared  */
00482 #define RTC_ALARMSUBSECONDMASK_SS14_5       (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2)                          /*!< SS[14:5] are don't care in Alarm
00483                                                                                                                           comparison. Only SS[4:0] are compared  */
00484 #define RTC_ALARMSUBSECONDMASK_SS14_6       (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)                          /*!< SS[14:6] are don't care in Alarm
00485                                                                                                                           comparison. Only SS[5:0] are compared  */
00486 #define RTC_ALARMSUBSECONDMASK_SS14_7       (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)  /*!< SS[14:7] are don't care in Alarm
00487                                                                                                                           comparison. Only SS[6:0] are compared  */
00488 #define RTC_ALARMSUBSECONDMASK_SS14_8       RTC_ALRMASSR_MASKSS_3                                                    /*!< SS[14:8] are don't care in Alarm
00489                                                                                                                           comparison. Only SS[7:0] are compared  */
00490 #define RTC_ALARMSUBSECONDMASK_SS14_9       (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_3)                          /*!< SS[14:9] are don't care in Alarm
00491                                                                                                                           comparison. Only SS[8:0] are compared  */
00492 #define RTC_ALARMSUBSECONDMASK_SS14_10      (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)                          /*!< SS[14:10] are don't care in Alarm
00493                                                                                                                           comparison. Only SS[9:0] are compared  */
00494 #define RTC_ALARMSUBSECONDMASK_SS14_11      (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)  /*!< SS[14:11] are don't care in Alarm
00495                                                                                                                           comparison. Only SS[10:0] are compared */
00496 #define RTC_ALARMSUBSECONDMASK_SS14_12      (RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)                          /*!< SS[14:12] are don't care in Alarm
00497                                                                                                                           comparison.Only SS[11:0] are compared  */
00498 #define RTC_ALARMSUBSECONDMASK_SS14_13      (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)  /*!< SS[14:13] are don't care in Alarm
00499                                                                                                                           comparison. Only SS[12:0] are compared */
00500 #define RTC_ALARMSUBSECONDMASK_SS14         (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)  /*!< SS[14] is don't care in Alarm
00501                                                                                                                           comparison.Only SS[13:0] are compared  */
00502 #define RTC_ALARMSUBSECONDMASK_NONE         RTC_ALRMASSR_MASKSS                                                      /*!< SS[14:0] are compared and must match
00503                                                                                                                           to activate alarm. */
00504 /**
00505   * @}
00506   */
00507 
00508 /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions
00509   * @{
00510   */
00511 #define RTC_IT_TS                           RTC_CR_TSIE        /*!< Enable Timestamp Interrupt    */
00512 #define RTC_IT_WUT                          RTC_CR_WUTIE       /*!< Enable Wakeup timer Interrupt */
00513 #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00514 #define RTC_IT_SSRU                         RTC_CR_SSRUIE      /*!< Enable SSR Underflow Interrupt */
00515 #endif
00516 #define RTC_IT_ALRA                         RTC_CR_ALRAIE      /*!< Enable Alarm A Interrupt      */
00517 #define RTC_IT_ALRB                         RTC_CR_ALRBIE      /*!< Enable Alarm B Interrupt      */
00518 /**
00519   * @}
00520   */
00521 
00522 #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00523 /** @defgroup RTC_Flag_Mask    RTC Flag Mask (5bits) describe in RTC_Flags_Definitions
00524   * @{
00525   */
00526 #define RTC_FLAG_MASK                       0x001Fu            /*!< RTC flags mask (5bits) */
00527 /**
00528   * @}
00529   */
00530 
00531 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions
00532   *        Elements values convention: 000000XX000YYYYYb
00533   *           - YYYYY  : Interrupt flag position in the XX register (5bits)
00534   *           - XX  : Interrupt status register (2bits)
00535   *                 - 01: ICSR register
00536   *                 - 10: SR or SCR or MISR or SMISR registers
00537   * @{
00538   */
00539 #define RTC_FLAG_RECALPF                    (0x00000100U | RTC_ICSR_RECALPF_Pos) /*!< Recalibration pending Flag */
00540 #define RTC_FLAG_INITF                      (0x00000100U | RTC_ICSR_INITF_Pos)   /*!< Initialization flag */
00541 #define RTC_FLAG_RSF                        (0x00000100U | RTC_ICSR_RSF_Pos)     /*!< Registers synchronization flag */
00542 #define RTC_FLAG_INITS                      (0x00000100U | RTC_ICSR_INITS_Pos)   /*!< Initialization status flag */
00543 #define RTC_FLAG_SHPF                       (0x00000100U | RTC_ICSR_SHPF_Pos)    /*!< Shift operation pending flag */
00544 #define RTC_FLAG_WUTWF                      (0x00000100U | RTC_ICSR_WUTWF_Pos)   /*!< Wakeup timer write flag */
00545 #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00546 #define RTC_FLAG_SSRUF                      (0x00000200U | RTC_SR_SSRUF_Pos)     /*!< SSR underflow flag */
00547 #endif
00548 #define RTC_FLAG_ITSF                       (0x00000200U | RTC_SR_ITSF_Pos)      /*!< Internal Time-stamp flag */
00549 #define RTC_FLAG_TSOVF                      (0x00000200U | RTC_SR_TSOVF_Pos)     /*!< Time-stamp overflow flag */
00550 #define RTC_FLAG_TSF                        (0x00000200U | RTC_SR_TSF_Pos)       /*!< Time-stamp flag */
00551 #define RTC_FLAG_WUTF                       (0x00000200U | RTC_SR_WUTF_Pos)      /*!< Wakeup timer flag */
00552 #define RTC_FLAG_ALRBF                      (0x00000200U | RTC_SR_ALRBF_Pos)     /*!< Alarm B flag */
00553 #define RTC_FLAG_ALRAF                      (0x00000200U | RTC_SR_ALRAF_Pos)     /*!< Alarm A flag */
00554 /**
00555   * @}
00556   */
00557 
00558 /** @defgroup RTC_Clear_Flags_Definitions RTC Clear Flags Definitions
00559   * @{
00560   */
00561 #if defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00562 #define RTC_CLEAR_SSRUF                     RTC_SCR_CSSRUF   /*!< Clear SSR underflow flag */
00563 #endif
00564 #define RTC_CLEAR_ITSF                      RTC_SCR_CITSF    /*!< Clear Internal Time-stamp flag */
00565 #define RTC_CLEAR_TSOVF                     RTC_SCR_CTSOVF   /*!< Clear Time-stamp overflow flag */
00566 #define RTC_CLEAR_TSF                       RTC_SCR_CTSF     /*!< Clear Time-stamp flag */
00567 #define RTC_CLEAR_WUTF                      RTC_SCR_CWUTF    /*!< Clear Wakeup timer flag */
00568 #define RTC_CLEAR_ALRBF                     RTC_SCR_CALRBF   /*!< Clear Alarm B flag */
00569 #define RTC_CLEAR_ALRAF                     RTC_SCR_CALRAF   /*!< Clear Alarm A flag */
00570 
00571 /**
00572   * @}
00573   */
00574 
00575 #else /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
00576 
00577 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions
00578   * @{
00579   */
00580 #define RTC_FLAG_RECALPF                    RTC_ISR_RECALPF
00581 #define RTC_FLAG_TSOVF                      RTC_ISR_TSOVF
00582 #define RTC_FLAG_TSF                        RTC_ISR_TSF
00583 #define RTC_FLAG_ITSF                       RTC_ISR_ITSF
00584 #define RTC_FLAG_WUTF                       RTC_ISR_WUTF
00585 #define RTC_FLAG_ALRBF                      RTC_ISR_ALRBF
00586 #define RTC_FLAG_ALRAF                      RTC_ISR_ALRAF
00587 #define RTC_FLAG_INITF                      RTC_ISR_INITF
00588 #define RTC_FLAG_RSF                        RTC_ISR_RSF
00589 #define RTC_FLAG_INITS                      RTC_ISR_INITS
00590 #define RTC_FLAG_SHPF                       RTC_ISR_SHPF
00591 #define RTC_FLAG_WUTWF                      RTC_ISR_WUTWF
00592 #define RTC_FLAG_ALRBWF                     RTC_ISR_ALRBWF
00593 #define RTC_FLAG_ALRAWF                     RTC_ISR_ALRAWF
00594 /**
00595   * @}
00596   */
00597 #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
00598 
00599 /**
00600   * @}
00601   */
00602 
00603 /* Exported macros -----------------------------------------------------------*/
00604 /** @defgroup RTC_Exported_Macros RTC Exported Macros
00605   * @{
00606   */
00607 
00608 /** @brief Reset RTC handle state
00609   * @param  __HANDLE__ RTC handle.
00610   * @retval None
00611   */
00612 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
00613 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{\
00614                                                       (__HANDLE__)->State = HAL_RTC_STATE_RESET;\
00615                                                       (__HANDLE__)->MspInitCallback = NULL;\
00616                                                       (__HANDLE__)->MspDeInitCallback = NULL;\
00617                                                      }while(0u)
00618 #else
00619 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
00620 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
00621 
00622 /**
00623   * @brief  Disable the write protection for RTC registers.
00624   * @param  __HANDLE__ specifies the RTC handle.
00625   * @retval None
00626   */
00627 #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__)             \
00628                         do{                                       \
00629                             (__HANDLE__)->Instance->WPR = 0xCAU;   \
00630                             (__HANDLE__)->Instance->WPR = 0x53U;   \
00631                           } while(0u)
00632 
00633 /**
00634   * @brief  Enable the write protection for RTC registers.
00635   * @param  __HANDLE__ specifies the RTC handle.
00636   * @retval None
00637   */
00638 #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__)              \
00639                         do{                                       \
00640                             (__HANDLE__)->Instance->WPR = 0xFFU;   \
00641                           } while(0u)
00642 
00643 /**
00644   * @brief  Add 1 hour (summer time change).
00645   * @note   This interface is deprecated.
00646   *         To manage Daylight Saving Time, please use HAL_RTC_DST_xxx functions
00647   * @param  __HANDLE__ specifies the RTC handle.
00648   * @param  __BKP__ Backup
00649   *         This parameter can be:
00650   *            @arg @ref RTC_STOREOPERATION_RESET
00651   *            @arg @ref RTC_STOREOPERATION_SET
00652   * @retval None
00653   */
00654 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_ADD1H(__HANDLE__, __BKP__)                         \
00655                         do {                                                              \
00656                             __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__);                \
00657                             SET_BIT((__HANDLE__)->Instance->CR, RTC_CR_ADD1H);            \
00658                             MODIFY_REG((__HANDLE__)->Instance->CR, RTC_CR_BKP , (__BKP__)); \
00659                             __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__);                 \
00660                         } while(0u);
00661 
00662 /**
00663   * @brief  Subtract 1 hour (winter time change).
00664   * @note   This interface is deprecated.
00665   *         To manage Daylight Saving Time, please use HAL_RTC_DST_xxx functions
00666   * @param  __HANDLE__ specifies the RTC handle.
00667   * @param  __BKP__ Backup
00668   *         This parameter can be:
00669   *            @arg @ref RTC_STOREOPERATION_RESET
00670   *            @arg @ref RTC_STOREOPERATION_SET
00671   * @retval None
00672   */
00673 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_SUB1H(__HANDLE__, __BKP__)                         \
00674                         do {                                                              \
00675                             __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__);                \
00676                             SET_BIT((__HANDLE__)->Instance->CR, RTC_CR_SUB1H);            \
00677                             MODIFY_REG((__HANDLE__)->Instance->CR, RTC_CR_BKP , (__BKP__)); \
00678                             __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__);                 \
00679                         } while(0u);
00680 
00681 /**
00682  * @brief  Enable the RTC ALARMA peripheral.
00683  * @param  __HANDLE__ specifies the RTC handle.
00684  * @retval None
00685  */
00686 #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__)  ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE))
00687 
00688 /**
00689   * @brief  Disable the RTC ALARMA peripheral.
00690   * @param  __HANDLE__ specifies the RTC handle.
00691   * @retval None
00692   */
00693 #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__)  ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE))
00694 
00695 /**
00696   * @brief  Enable the RTC ALARMB peripheral.
00697   * @param  __HANDLE__ specifies the RTC handle.
00698   * @retval None
00699   */
00700 #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__)   ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE))
00701 
00702 /**
00703   * @brief  Disable the RTC ALARMB peripheral.
00704   * @param  __HANDLE__ specifies the RTC handle.
00705   * @retval None
00706   */
00707 #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__)  ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE))
00708 
00709 /**
00710   * @brief  Enable the RTC Alarm interrupt.
00711   * @param  __HANDLE__ specifies the RTC handle.
00712   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
00713   *          This parameter can be any combination of the following values:
00714   *             @arg @ref RTC_IT_ALRA Alarm A interrupt
00715   *             @arg @ref RTC_IT_ALRB Alarm B interrupt
00716   * @retval None
00717   */
00718 #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__)   ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
00719 
00720 /**
00721   * @brief  Disable the RTC Alarm interrupt.
00722   * @param  __HANDLE__ specifies the RTC handle.
00723   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
00724   *         This parameter can be any combination of the following values:
00725   *            @arg @ref RTC_IT_ALRA Alarm A interrupt
00726   *            @arg @ref RTC_IT_ALRB Alarm B interrupt
00727   * @retval None
00728   */
00729 #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
00730 
00731 /**
00732   * @brief  Check whether the specified RTC Alarm interrupt has occurred or not.
00733   * @param  __HANDLE__ specifies the RTC handle.
00734   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
00735   *         This parameter can be:
00736   *            @arg @ref RTC_IT_ALRA Alarm A interrupt
00737   *            @arg @ref RTC_IT_ALRB Alarm B interrupt
00738   * @retval None
00739   */
00740 #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00741 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->MISR)& (__INTERRUPT__ >> 12)) != 0U)? 1U : 0U)
00742 #else
00743 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR)& (__INTERRUPT__ >> 4)) != 0U)? 1U : 0U)
00744 #endif
00745 /**
00746   * @brief  Check whether the specified RTC Alarm interrupt has been enabled or not.
00747   * @param  __HANDLE__ specifies the RTC handle.
00748   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
00749   *         This parameter can be:
00750   *            @arg @ref RTC_IT_ALRA Alarm A interrupt
00751   *            @arg @ref RTC_IT_ALRB Alarm B interrupt
00752   * @retval None
00753   */
00754 #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)     (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
00755 
00756 #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00757 /**
00758   * @brief  Get the selected RTC Alarm's flag status.
00759   * @param  __HANDLE__ specifies the RTC handle.
00760   * @param  __FLAG__ specifies the RTC Alarm Flag sources to check.
00761   *         This parameter can be:
00762   *            @arg @ref RTC_FLAG_ALRAF
00763   *            @arg @ref RTC_FLAG_ALRBF
00764   * @retval None
00765   */
00766 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__)   (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__)))
00767 
00768 #else /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
00769 
00770 /**
00771   * @brief  Get the selected RTC Alarm's flag status.
00772   * @param  __HANDLE__ specifies the RTC handle.
00773   * @param  __FLAG__ specifies the RTC Alarm Flag sources to check.
00774   *         This parameter can be:
00775   *            @arg @ref RTC_FLAG_ALRAF
00776   *            @arg @ref RTC_FLAG_ALRBF
00777   *            @arg @ref RTC_FLAG_ALRAWF
00778   *            @arg @ref RTC_FLAG_ALRBWF
00779   * @retval None
00780   */
00781 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__)  (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
00782 #endif /* #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) */
00783 
00784 /**
00785   * @brief  Clear the RTC Alarm's pending flags.
00786   * @param  __HANDLE__ specifies the RTC handle.
00787   * @param  __FLAG__ specifies the RTC Alarm Flag sources to clear.
00788   *          This parameter can be:
00789   *             @arg @ref RTC_FLAG_ALRAF
00790   *             @arg @ref RTC_FLAG_ALRBF
00791   * @retval None
00792   */
00793 #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00794 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__)   (((__FLAG__) == RTC_FLAG_ALRAF) ? (((__HANDLE__)->Instance->SCR = (RTC_CLEAR_ALRAF))) : \
00795                                                            ((__HANDLE__)->Instance->SCR = (RTC_CLEAR_ALRBF)))
00796 #else
00797 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__)  ((__HANDLE__)->Instance->ISR = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)))
00798 #endif
00799 
00800 /**
00801   * @brief  Enable interrupt on the RTC Alarm associated Exti line.
00802   * @retval None
00803   */
00804 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT()            (EXTI->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
00805 
00806 /**
00807   * @brief  Disable interrupt on the RTC Alarm associated Exti line.
00808   * @retval None
00809   */
00810 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT()           (EXTI->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
00811 
00812 /**
00813   * @brief  Enable event on the RTC Alarm associated Exti line.
00814   * @retval None.
00815   */
00816 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT()         (EXTI->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
00817 
00818 /**
00819   * @brief  Disable event on the RTC Alarm associated Exti line.
00820   * @retval None.
00821   */
00822 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT()         (EXTI->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
00823 
00824 /**
00825   * @brief  Enable falling edge trigger on the RTC Alarm associated Exti line.
00826   * @retval None
00827   */
00828 #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE()   (EXTI->FTSR1 |= RTC_EXTI_LINE_ALARM_EVENT)
00829 
00830 /**
00831   * @brief  Disable falling edge trigger on the RTC Alarm associated Exti line.
00832   * @retval None
00833   */
00834 #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE()  (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
00835 
00836 /**
00837   * @brief  Enable rising edge trigger on the RTC Alarm associated Exti line.
00838   * @retval None
00839   */
00840 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE()    (EXTI->RTSR1 |= RTC_EXTI_LINE_ALARM_EVENT)
00841 
00842 /**
00843   * @brief  Disable rising edge trigger on the RTC Alarm associated Exti line.
00844   * @retval None
00845   */
00846 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE()   (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
00847 
00848 /**
00849   * @brief  Enable rising & falling edge trigger on the RTC Alarm associated Exti line.
00850   * @retval None
00851   */
00852 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE()  do { \
00853                                                              __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE();  \
00854                                                              __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \
00855                                                            } while(0u)
00856 
00857 /**
00858   * @brief  Disable rising & falling edge trigger on the RTC Alarm associated Exti line.
00859   * @retval None
00860   */
00861 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
00862                                                              __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE();  \
00863                                                              __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \
00864                                                            } while(0u)
00865 
00866 /**
00867   * @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or not.
00868   * @retval Line Status.
00869   */
00870 #define __HAL_RTC_ALARM_EXTI_GET_FLAG()              (EXTI->PR1 & RTC_EXTI_LINE_ALARM_EVENT)
00871 
00872 /**
00873   * @brief Clear the RTC Alarm associated Exti line flag.
00874   * @retval None
00875   */
00876 #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG()            (EXTI->PR1 = RTC_EXTI_LINE_ALARM_EVENT)
00877 
00878 /**
00879   * @brief Generate a Software interrupt on RTC Alarm associated Exti line.
00880   * @retval None
00881   */
00882 #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT()         (EXTI->SWIER1 |= RTC_EXTI_LINE_ALARM_EVENT)
00883 
00884 /**
00885   * @}
00886   */
00887 
00888 /* Include RTC HAL Extended module */
00889 #include "stm32l4xx_hal_rtc_ex.h"
00890 
00891 /* Exported functions --------------------------------------------------------*/
00892 /** @defgroup RTC_Exported_Functions RTC Exported Functions
00893   * @{
00894   */
00895 
00896 /** @defgroup RTC_Exported_Functions_Group1 Initialization and de-initialization functions
00897   * @{
00898   */
00899 /* Initialization and de-initialization functions  ****************************/
00900 HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
00901 HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
00902 
00903 void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
00904 void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
00905 
00906 /* Callbacks Register/UnRegister functions  ***********************************/
00907 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
00908 HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback);
00909 HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID);
00910 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
00911 /**
00912   * @}
00913   */
00914 
00915 /** @defgroup RTC_Exported_Functions_Group2 RTC Time and Date functions
00916   * @{
00917   */
00918 /* RTC Time and Date functions ************************************************/
00919 HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
00920 HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
00921 HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
00922 HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
00923 void              HAL_RTC_DST_Add1Hour(RTC_HandleTypeDef *hrtc);
00924 void              HAL_RTC_DST_Sub1Hour(RTC_HandleTypeDef *hrtc);
00925 void              HAL_RTC_DST_SetStoreOperation(RTC_HandleTypeDef *hrtc);
00926 void              HAL_RTC_DST_ClearStoreOperation(RTC_HandleTypeDef *hrtc);
00927 uint32_t          HAL_RTC_DST_ReadStoreOperation(RTC_HandleTypeDef *hrtc);
00928 /**
00929   * @}
00930   */
00931 
00932 /** @defgroup RTC_Exported_Functions_Group3 RTC Alarm functions
00933   * @{
00934   */
00935 /* RTC Alarm functions ********************************************************/
00936 HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
00937 HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
00938 HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm);
00939 HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format);
00940 void              HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
00941 void              HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc);
00942 HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
00943 /**
00944   * @}
00945   */
00946 
00947 /** @defgroup  RTC_Exported_Functions_Group4 Peripheral Control functions
00948   * @{
00949   */
00950 /* Peripheral Control functions ***********************************************/
00951 HAL_StatusTypeDef   HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc);
00952 /**
00953   * @}
00954   */
00955 
00956 /** @defgroup RTC_Exported_Functions_Group5 Peripheral State functions
00957   * @{
00958   */
00959 /* Peripheral State functions *************************************************/
00960 HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc);
00961 /**
00962   * @}
00963   */
00964 
00965 /**
00966   * @}
00967   */
00968 
00969 /* Private types -------------------------------------------------------------*/
00970 /* Private variables ---------------------------------------------------------*/
00971 /* Private constants ---------------------------------------------------------*/
00972 /** @defgroup RTC_Private_Constants RTC Private Constants
00973   * @{
00974   */
00975 /* Masks Definition */
00976 #define RTC_TR_RESERVED_MASK                (RTC_TR_PM | RTC_TR_HT | RTC_TR_HU | \
00977                                             RTC_TR_MNT | RTC_TR_MNU| RTC_TR_ST | \
00978                                             RTC_TR_SU)
00979 
00980 #define RTC_DR_RESERVED_MASK                (RTC_DR_YT | RTC_DR_YU | RTC_DR_WDU | \
00981                                             RTC_DR_MT | RTC_DR_MU | RTC_DR_DT  | \
00982                                             RTC_DR_DU)
00983 
00984 #define RTC_INIT_MASK                       0xFFFFFFFFu
00985 #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
00986 #define RTC_RSF_MASK                        (~(RTC_ICSR_INIT | RTC_ICSR_RSF))
00987 #else
00988 #define RTC_RSF_MASK                        (~(RTC_ISR_INIT | RTC_ISR_RSF))
00989 #endif
00990 
00991 #define RTC_TIMEOUT_VALUE                   1000u
00992 
00993 #define RTC_EXTI_LINE_ALARM_EVENT           EXTI_IMR1_IM18  /*!< External interrupt line 18 Connected to the RTC Alarm event */
00994 
00995 /**
00996   * @}
00997   */
00998 
00999 /* Private macros ------------------------------------------------------------*/
01000 /** @defgroup RTC_Private_Macros RTC Private Macros
01001   * @{
01002   */
01003 
01004 /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters
01005   * @{
01006   */
01007 #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
01008 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
01009                                 ((OUTPUT) == RTC_OUTPUT_ALARMA)  || \
01010                                 ((OUTPUT) == RTC_OUTPUT_ALARMB)  || \
01011                                 ((OUTPUT) == RTC_OUTPUT_WAKEUP)  || \
01012                                 ((OUTPUT) == RTC_OUTPUT_TAMPER))
01013 #else
01014 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
01015                                ((OUTPUT) == RTC_OUTPUT_ALARMA)  || \
01016                                ((OUTPUT) == RTC_OUTPUT_ALARMB)  || \
01017                                ((OUTPUT) == RTC_OUTPUT_WAKEUP))
01018 #endif
01019 
01020 #define IS_RTC_HOUR_FORMAT(FORMAT)     (((FORMAT) == RTC_HOURFORMAT_12) || \
01021                                         ((FORMAT) == RTC_HOURFORMAT_24))
01022 
01023 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \
01024                                 ((POL) == RTC_OUTPUT_POLARITY_LOW))
01025 
01026 #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
01027                                   ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL))
01028 
01029 #if defined(STM32L412xx) || defined(STM32L422xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx)
01030 #define IS_RTC_OUTPUT_PULLUP(TYPE) (((TYPE) == RTC_OUTPUT_PULLUP_NONE) || \
01031                                     ((TYPE) == RTC_OUTPUT_PULLUP_ON))
01032 #endif
01033 
01034 #define IS_RTC_OUTPUT_REMAP(REMAP)   (((REMAP) == RTC_OUTPUT_REMAP_NONE) || \
01035                                       ((REMAP) == RTC_OUTPUT_REMAP_POS1))
01036 
01037 #define IS_RTC_HOURFORMAT12(PM)  (((PM) == RTC_HOURFORMAT12_AM) || \
01038                                   ((PM) == RTC_HOURFORMAT12_PM))
01039 
01040 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \
01041                                       ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \
01042                                       ((SAVE) == RTC_DAYLIGHTSAVING_NONE))
01043 
01044 #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \
01045                                            ((OPERATION) == RTC_STOREOPERATION_SET))
01046 
01047 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || \
01048                                ((FORMAT) == RTC_FORMAT_BCD))
01049 
01050 #define IS_RTC_YEAR(YEAR)              ((YEAR) <= 99u)
01051 
01052 #define IS_RTC_MONTH(MONTH)            (((MONTH) >= 1u) && ((MONTH) <= 12u))
01053 
01054 #define IS_RTC_DATE(DATE)              (((DATE) >= 1u) && ((DATE) <= 31u))
01055 
01056 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY)    || \
01057                                  ((WEEKDAY) == RTC_WEEKDAY_TUESDAY)   || \
01058                                  ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
01059                                  ((WEEKDAY) == RTC_WEEKDAY_THURSDAY)  || \
01060                                  ((WEEKDAY) == RTC_WEEKDAY_FRIDAY)    || \
01061                                  ((WEEKDAY) == RTC_WEEKDAY_SATURDAY)  || \
01062                                  ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
01063 
01064 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) >0u) && ((DATE) <= 31u))
01065 
01066 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY)    || \
01067                                                     ((WEEKDAY) == RTC_WEEKDAY_TUESDAY)   || \
01068                                                     ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
01069                                                     ((WEEKDAY) == RTC_WEEKDAY_THURSDAY)  || \
01070                                                     ((WEEKDAY) == RTC_WEEKDAY_FRIDAY)    || \
01071                                                     ((WEEKDAY) == RTC_WEEKDAY_SATURDAY)  || \
01072                                                     ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
01073 
01074 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
01075                                             ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
01076 
01077 #define IS_RTC_ALARM_MASK(MASK)  (((MASK) & ~(RTC_ALARMMASK_ALL)) == 0U)
01078 
01079 #define IS_RTC_ALARM(ALARM)      (((ALARM) == RTC_ALARM_A) || \
01080                                   ((ALARM) == RTC_ALARM_B))
01081 
01082 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= RTC_ALRMASSR_SS)
01083 
01084 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK)          (((MASK) == 0u) || \
01085                                                     (((MASK) >= RTC_ALARMSUBSECONDMASK_SS14_1) && ((MASK) <= RTC_ALARMSUBSECONDMASK_NONE)))
01086 
01087 #define IS_RTC_ASYNCH_PREDIV(PREDIV)   ((PREDIV) <= (RTC_PRER_PREDIV_A >> RTC_PRER_PREDIV_A_Pos))
01088 
01089 #define IS_RTC_SYNCH_PREDIV(PREDIV)    ((PREDIV) <= (RTC_PRER_PREDIV_S >> RTC_PRER_PREDIV_S_Pos))
01090 
01091 #define IS_RTC_HOUR12(HOUR)            (((HOUR) > 0u) && ((HOUR) <= 12u))
01092 
01093 #define IS_RTC_HOUR24(HOUR)            ((HOUR) <= 23u)
01094 
01095 #define IS_RTC_MINUTES(MINUTES)        ((MINUTES) <= 59u)
01096 
01097 #define IS_RTC_SECONDS(SECONDS)        ((SECONDS) <= 59u)
01098 
01099 /**
01100   * @}
01101   */
01102 
01103 /**
01104   * @}
01105   */
01106 
01107 /* Private functions -------------------------------------------------------------*/
01108 /** @defgroup RTC_Private_Functions RTC Private Functions
01109   * @{
01110   */
01111 HAL_StatusTypeDef  RTC_EnterInitMode(RTC_HandleTypeDef *hrtc);
01112 HAL_StatusTypeDef  RTC_ExitInitMode(RTC_HandleTypeDef *hrtc);
01113 uint8_t            RTC_ByteToBcd2(uint8_t Value);
01114 uint8_t            RTC_Bcd2ToByte(uint8_t Value);
01115 /**
01116   * @}
01117   */
01118 
01119 
01120 /**
01121   * @}
01122   */
01123 
01124 /**
01125   * @}
01126   */
01127 
01128 /**
01129   * @}
01130   */
01131 
01132 #ifdef __cplusplus
01133 }
01134 #endif
01135 
01136 #endif /* STM32L4xx_HAL_RTC_H */