Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:36

0001 /**
0002   ******************************************************************************
0003   * @file    stm32h7xx_hal_rtc.h
0004   * @author  MCD Application Team
0005   * @brief   Header file of RTC HAL module.
0006   ******************************************************************************
0007   * @attention
0008   *
0009   * Copyright (c) 2017 STMicroelectronics.
0010   * All rights reserved.
0011   *
0012   * This software is licensed under terms that can be found in the LICENSE file
0013   * in the root directory of this software component.
0014   * If no LICENSE file comes with this software, it is provided AS-IS.
0015   *
0016   ******************************************************************************
0017   */
0018 
0019 /* Define to prevent recursive inclusion -------------------------------------*/
0020 #ifndef STM32H7xx_HAL_RTC_H
0021 #define STM32H7xx_HAL_RTC_H
0022 
0023 #ifdef __cplusplus
0024 extern "C" {
0025 #endif
0026 
0027 /* Includes ------------------------------------------------------------------*/
0028 #include "stm32h7xx_hal_def.h"
0029 
0030 /** @addtogroup STM32H7xx_HAL_Driver
0031   * @{
0032   */
0033 
0034 /** @defgroup RTC RTC
0035   * @ingroup RTEMSBSPsARMSTM32H7
0036   * @{
0037   */
0038 
0039 /* Exported types ------------------------------------------------------------*/
0040 /** @defgroup RTC_Exported_Types RTC Exported Types
0041   * @ingroup RTEMSBSPsARMSTM32H7
0042   * @{
0043   */
0044 
0045 /**
0046   * @brief  HAL State structures definition
0047   */
0048 typedef enum
0049 {
0050   HAL_RTC_STATE_RESET             = 0x00U,  /*!< RTC not yet initialized or disabled */
0051   HAL_RTC_STATE_READY             = 0x01U,  /*!< RTC initialized and ready for use   */
0052   HAL_RTC_STATE_BUSY              = 0x02U,  /*!< RTC process is ongoing              */
0053   HAL_RTC_STATE_TIMEOUT           = 0x03U,  /*!< RTC timeout state                   */
0054   HAL_RTC_STATE_ERROR             = 0x04U   /*!< RTC error state                     */
0055 
0056 } HAL_RTCStateTypeDef;
0057 
0058 /**
0059   * @brief  RTC Configuration Structure definition
0060   */
0061 typedef struct
0062 {
0063   uint32_t HourFormat;      /*!< Specifies the RTC Hour Format.
0064                                  This parameter can be a value of @ref RTC_Hour_Formats_Definitions */
0065 
0066   uint32_t AsynchPrediv;    /*!< Specifies the RTC Asynchronous Predivider value.
0067                                  This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */
0068 
0069   uint32_t SynchPrediv;     /*!< Specifies the RTC Synchronous Predivider value.
0070                                  This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF */
0071 
0072   uint32_t OutPut;          /*!< Specifies which signal will be routed to the RTC output.
0073                                  This parameter can be a value of @ref RTC_Output_selection_Definitions */
0074 
0075   uint32_t OutPutRemap;     /*!< Specifies the remap for RTC output.
0076                                  This parameter can be a value of @ref  RTC_Output_ALARM_OUT_Remap */
0077 
0078   uint32_t OutPutPolarity;  /*!< Specifies the polarity of the output signal.
0079                                  This parameter can be a value of @ref RTC_Output_Polarity_Definitions */
0080 
0081   uint32_t OutPutType;      /*!< Specifies the RTC Output Pin mode.
0082                                  This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */
0083 #if defined(TAMP)
0084   uint32_t OutPutPullUp;    /*!< Specifies the RTC Output Pull-Up mode.
0085                                  This parameter can be a value of @ref RTC_Output_PullUp_ALARM_OUT */
0086 #endif /* TAMP */
0087 } RTC_InitTypeDef;
0088 
0089 /**
0090   * @brief  RTC Time structure definition
0091   */
0092 typedef struct
0093 {
0094   uint8_t Hours;            /*!< Specifies the RTC Time Hour.
0095                                  This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected.
0096                                  This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */
0097 
0098   uint8_t Minutes;          /*!< Specifies the RTC Time Minutes.
0099                                  This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
0100 
0101   uint8_t Seconds;          /*!< Specifies the RTC Time Seconds.
0102                                  This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
0103 
0104   uint8_t TimeFormat;       /*!< Specifies the RTC AM/PM Time.
0105                                  This parameter can be a value of @ref RTC_AM_PM_Definitions */
0106 
0107   uint32_t SubSeconds;     /*!< Specifies the RTC_SSR RTC Sub Second register content.
0108                                  This parameter corresponds to a time unit range between [0-1] Second
0109                                  with [1 Sec / SecondFraction +1] granularity */
0110 
0111   uint32_t SecondFraction;  /*!< Specifies the range or granularity of Sub Second register content
0112                                  corresponding to Synchronous pre-scaler factor value (PREDIV_S)
0113                                  This parameter corresponds to a time unit range between [0-1] Second
0114                                  with [1 Sec / SecondFraction +1] granularity.
0115                                  This field will be used only by HAL_RTC_GetTime function */
0116 
0117   uint32_t DayLightSaving;  /*!< Specifies RTC_DayLightSaveOperation: the value of hour adjustment.
0118                                  This parameter can be a value of @ref RTC_DayLightSaving_Definitions */
0119 
0120   uint32_t StoreOperation;  /*!< Specifies RTC_StoreOperation value to be written in the BKP bit
0121                                  in CR register to store the operation.
0122                                  This parameter can be a value of @ref RTC_StoreOperation_Definitions */
0123 } RTC_TimeTypeDef;
0124 
0125 /**
0126   * @brief  RTC Date structure definition
0127   */
0128 typedef struct
0129 {
0130   uint8_t WeekDay;  /*!< Specifies the RTC Date WeekDay.
0131                          This parameter can be a value of @ref RTC_WeekDay_Definitions */
0132 
0133   uint8_t Month;    /*!< Specifies the RTC Date Month (in BCD format).
0134                          This parameter can be a value of @ref RTC_Month_Date_Definitions */
0135 
0136   uint8_t Date;     /*!< Specifies the RTC Date.
0137                          This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
0138 
0139   uint8_t Year;     /*!< Specifies the RTC Date Year.
0140                          This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
0141 
0142 } RTC_DateTypeDef;
0143 
0144 /**
0145   * @brief  RTC Alarm structure definition
0146   */
0147 typedef struct
0148 {
0149   RTC_TimeTypeDef AlarmTime;     /*!< Specifies the RTC Alarm Time members */
0150 
0151   uint32_t AlarmMask;            /*!< Specifies the RTC Alarm Masks.
0152                                       This parameter can be a value of @ref RTC_AlarmMask_Definitions */
0153 
0154   uint32_t AlarmSubSecondMask;   /*!< Specifies the RTC Alarm SubSeconds Masks.
0155                                       This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */
0156 
0157   uint32_t AlarmDateWeekDaySel;  /*!< Specifies the RTC Alarm is on Date or WeekDay.
0158                                      This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
0159 
0160   uint8_t AlarmDateWeekDay;      /*!< Specifies the RTC Alarm Date/WeekDay.
0161                                       If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range.
0162                                       If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */
0163 
0164   uint32_t Alarm;                /*!< Specifies the alarm .
0165                                       This parameter can be a value of @ref RTC_Alarms_Definitions */
0166 } RTC_AlarmTypeDef;
0167 
0168 /**
0169   * @brief  RTC Handle Structure definition
0170   */
0171 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
0172 typedef struct __RTC_HandleTypeDef
0173 #else
0174 typedef struct
0175 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
0176 {
0177   RTC_TypeDef               *Instance;  /*!< Register base address    */
0178 
0179   RTC_InitTypeDef           Init;       /*!< RTC required parameters  */
0180 
0181   HAL_LockTypeDef           Lock;       /*!< RTC locking object       */
0182 
0183   __IO HAL_RTCStateTypeDef  State;      /*!< Time communication state */
0184 
0185 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
0186   void (* AlarmAEventCallback)(struct __RTC_HandleTypeDef *hrtc);            /*!< RTC Alarm A Event callback         */
0187 
0188   void (* AlarmBEventCallback)(struct __RTC_HandleTypeDef *hrtc);            /*!< RTC Alarm B Event callback         */
0189 
0190   void (* TimeStampEventCallback)(struct __RTC_HandleTypeDef *hrtc);         /*!< RTC TimeStamp Event callback       */
0191 
0192   void (* WakeUpTimerEventCallback)(struct __RTC_HandleTypeDef *hrtc);       /*!< RTC WakeUpTimer Event callback     */
0193 
0194   void (* Tamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc);         /*!< RTC Tamper 1 Event callback        */
0195 
0196   void (* Tamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc);         /*!< RTC Tamper 2 Event callback        */
0197 
0198   void (* Tamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc);         /*!< RTC Tamper 3 Event callback        */
0199 
0200 #if defined(TAMP)
0201   void (* InternalTamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Internal Tamper 1 Event callback  */
0202 
0203   void (* InternalTamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Internal Tamper 2 Event callback  */
0204 
0205   void (* InternalTamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Internal Tamper 3 Event callback  */
0206 
0207   void (* InternalTamper4EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Internal Tamper 4 Event callback  */
0208 
0209   void (* InternalTamper5EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Internal Tamper 5 Event callback  */
0210 
0211   void (* InternalTamper6EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Internal Tamper 6 Event callback  */
0212 
0213   void (* InternalTamper8EventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Internal Tamper 8 Event callback  */
0214 #endif /* TAMP */
0215 
0216   void (* MspInitCallback)(struct __RTC_HandleTypeDef *hrtc);                /*!< RTC Msp Init callback              */
0217 
0218   void (* MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc);              /*!< RTC Msp DeInit callback            */
0219 
0220 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
0221 
0222 } RTC_HandleTypeDef;
0223 
0224 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
0225 /**
0226   * @brief  HAL RTC Callback ID enumeration definition
0227   */
0228 typedef enum
0229 {
0230   HAL_RTC_ALARM_A_EVENT_CB_ID           = 0u,    /*!< RTC Alarm A Event Callback ID      */
0231   HAL_RTC_ALARM_B_EVENT_CB_ID           = 1u,    /*!< RTC Alarm B Event Callback ID      */
0232   HAL_RTC_TIMESTAMP_EVENT_CB_ID         = 2u,    /*!< RTC TimeStamp Event Callback ID    */
0233   HAL_RTC_WAKEUPTIMER_EVENT_CB_ID       = 3u,    /*!< RTC WakeUp Timer Event Callback ID */
0234   HAL_RTC_TAMPER1_EVENT_CB_ID           = 4u,    /*!< RTC Tamper 1 Callback ID           */
0235   HAL_RTC_TAMPER2_EVENT_CB_ID           = 5u,    /*!< RTC Tamper 2 Callback ID           */
0236   HAL_RTC_TAMPER3_EVENT_CB_ID           = 6u,    /*!< RTC Tamper 3 Callback ID           */
0237 #if defined(TAMP)
0238   HAL_RTC_INTERNAL_TAMPER1_EVENT_CB_ID  = 12u,   /*!< RTC Internal Tamper 1 Callback ID  */
0239   HAL_RTC_INTERNAL_TAMPER2_EVENT_CB_ID  = 13u,   /*!< RTC Internal Tamper 2 Callback ID  */
0240   HAL_RTC_INTERNAL_TAMPER3_EVENT_CB_ID  = 14u,   /*!< RTC Internal Tamper 3 Callback ID  */
0241   HAL_RTC_INTERNAL_TAMPER4_EVENT_CB_ID  = 15u,   /*!< RTC Internal Tamper 4 Callback ID  */
0242   HAL_RTC_INTERNAL_TAMPER5_EVENT_CB_ID  = 16u,   /*!< RTC Internal Tamper 5 Callback ID  */
0243   HAL_RTC_INTERNAL_TAMPER6_EVENT_CB_ID  = 17u,   /*!< RTC Internal Tamper 6 Callback ID  */
0244   HAL_RTC_INTERNAL_TAMPER8_EVENT_CB_ID  = 19u,   /*!< RTC Internal Tamper 8 Callback ID  */
0245 #endif /* TAMP */
0246   HAL_RTC_MSPINIT_CB_ID                 = 20u,   /*!< RTC Msp Init callback ID           */
0247   HAL_RTC_MSPDEINIT_CB_ID               = 21u    /*!< RTC Msp DeInit callback ID         */
0248 } HAL_RTC_CallbackIDTypeDef;
0249 
0250 /**
0251   * @brief  HAL RTC Callback pointer definition
0252   */
0253 typedef  void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc);  /*!< pointer to an RTC callback function */
0254 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
0255 
0256 /**
0257   * @}
0258   */
0259 
0260 /* Exported constants --------------------------------------------------------*/
0261 /** @defgroup RTC_Exported_Constants RTC Exported Constants
0262   * @ingroup RTEMSBSPsARMSTM32H7
0263   * @{
0264   */
0265 
0266 /** @defgroup RTC_Hour_Formats_Definitions RTC Hour Formats Definitions
0267   * @ingroup RTEMSBSPsARMSTM32H7
0268   * @{
0269   */
0270 #define RTC_HOURFORMAT_24              0x00000000u
0271 #define RTC_HOURFORMAT_12              RTC_CR_FMT
0272 /**
0273   * @}
0274   */
0275 
0276 /** @defgroup RTC_Output_selection_Definitions RTC Output Selection Definitions
0277   * @ingroup RTEMSBSPsARMSTM32H7
0278   * @{
0279   */
0280 #define RTC_OUTPUT_DISABLE             0x00000000u
0281 #define RTC_OUTPUT_ALARMA              RTC_CR_OSEL_0
0282 #define RTC_OUTPUT_ALARMB              RTC_CR_OSEL_1
0283 #define RTC_OUTPUT_WAKEUP              RTC_CR_OSEL
0284 #if defined(TAMP)
0285 #define RTC_OUTPUT_TAMPER              RTC_CR_TAMPOE
0286 #endif /* TAMP */
0287 /**
0288   * @}
0289   */
0290 
0291 /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions
0292   * @ingroup RTEMSBSPsARMSTM32H7
0293   * @{
0294   */
0295 #define RTC_OUTPUT_POLARITY_HIGH       0x00000000u
0296 #define RTC_OUTPUT_POLARITY_LOW        RTC_CR_POL
0297 /**
0298   * @}
0299   */
0300 
0301 /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT
0302   * @ingroup RTEMSBSPsARMSTM32H7
0303   * @{
0304   */
0305 #if defined(TAMP)
0306 #define RTC_OUTPUT_TYPE_PUSHPULL       0x00000000u
0307 #define RTC_OUTPUT_TYPE_OPENDRAIN      RTC_CR_TAMPALRM_TYPE
0308 #define RTC_ALARM_OUTPUT_TYPE          RTC_CR_TAMPALRM_TYPE
0309 #else
0310 #define RTC_OUTPUT_TYPE_PUSHPULL       RTC_OR_ALARMOUTTYPE
0311 #define RTC_OUTPUT_TYPE_OPENDRAIN      0x00000000u
0312 #define RTC_ALARM_OUTPUT_TYPE          RTC_OR_ALARMOUTTYPE
0313 #endif /* TAMP */
0314 /**
0315   * @}
0316   */
0317 
0318 /** @defgroup RTC_Output_PullUp_ALARM_OUT RTC Output Pull-Up ALARM OUT
0319   * @ingroup RTEMSBSPsARMSTM32H7
0320   * @{
0321   */
0322 #if defined(TAMP)
0323 #define RTC_OUTPUT_PULLUP_NONE         0x00000000u
0324 #define RTC_OUTPUT_PULLUP_ON           RTC_CR_TAMPALRM_PU
0325 #endif /* TAMP */
0326 /**
0327   * @}
0328   */
0329 
0330 /** @defgroup RTC_Output_ALARM_OUT_Remap RTC Output ALARM OUT Remap
0331   * @ingroup RTEMSBSPsARMSTM32H7
0332   * @{
0333   */
0334 #if defined(TAMP)
0335 #define RTC_OUTPUT_REMAP_NONE          0x00000000u
0336 #define RTC_OUTPUT_REMAP_POS1          RTC_CR_OUT2EN
0337 #else
0338 #define RTC_OUTPUT_REMAP_NONE          0x00000000u
0339 #define RTC_OUTPUT_REMAP_POS1          RTC_OR_OUT_RMP
0340 #endif /* TAMP */
0341 /**
0342   * @}
0343   */
0344 
0345 /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions
0346   * @ingroup RTEMSBSPsARMSTM32H7
0347   * @{
0348   */
0349 #define RTC_HOURFORMAT12_AM            ((uint8_t)0x00)
0350 #define RTC_HOURFORMAT12_PM            ((uint8_t)0x01)
0351 /**
0352   * @}
0353   */
0354 
0355 /** @defgroup RTC_DayLightSaving_Definitions RTC DayLight Saving Definitions
0356   * @ingroup RTEMSBSPsARMSTM32H7
0357   * @{
0358   */
0359 #define RTC_DAYLIGHTSAVING_SUB1H       RTC_CR_SUB1H
0360 #define RTC_DAYLIGHTSAVING_ADD1H       RTC_CR_ADD1H
0361 #define RTC_DAYLIGHTSAVING_NONE        0x00000000u
0362 /**
0363   * @}
0364   */
0365 
0366 /** @defgroup RTC_StoreOperation_Definitions RTC Store Operation Definitions
0367   * @ingroup RTEMSBSPsARMSTM32H7
0368   * @{
0369   */
0370 #define RTC_STOREOPERATION_RESET        0x00000000u
0371 #define RTC_STOREOPERATION_SET          RTC_CR_BKP
0372 /**
0373   * @}
0374   */
0375 
0376 /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions
0377   * @ingroup RTEMSBSPsARMSTM32H7
0378   * @{
0379   */
0380 #define RTC_FORMAT_BIN                  0x00000000u
0381 #define RTC_FORMAT_BCD                  0x00000001u
0382 /**
0383   * @}
0384   */
0385 
0386 /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions (in BCD format)
0387   * @ingroup RTEMSBSPsARMSTM32H7
0388   * @{
0389   */
0390 #define RTC_MONTH_JANUARY                   ((uint8_t)0x01)
0391 #define RTC_MONTH_FEBRUARY                  ((uint8_t)0x02)
0392 #define RTC_MONTH_MARCH                     ((uint8_t)0x03)
0393 #define RTC_MONTH_APRIL                     ((uint8_t)0x04)
0394 #define RTC_MONTH_MAY                       ((uint8_t)0x05)
0395 #define RTC_MONTH_JUNE                      ((uint8_t)0x06)
0396 #define RTC_MONTH_JULY                      ((uint8_t)0x07)
0397 #define RTC_MONTH_AUGUST                    ((uint8_t)0x08)
0398 #define RTC_MONTH_SEPTEMBER                 ((uint8_t)0x09)
0399 #define RTC_MONTH_OCTOBER                   ((uint8_t)0x10)
0400 #define RTC_MONTH_NOVEMBER                  ((uint8_t)0x11)
0401 #define RTC_MONTH_DECEMBER                  ((uint8_t)0x12)
0402 
0403 /**
0404   * @}
0405   */
0406 
0407 /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions
0408   * @ingroup RTEMSBSPsARMSTM32H7
0409   * @{
0410   */
0411 #define RTC_WEEKDAY_MONDAY                  ((uint8_t)0x01)
0412 #define RTC_WEEKDAY_TUESDAY                 ((uint8_t)0x02)
0413 #define RTC_WEEKDAY_WEDNESDAY               ((uint8_t)0x03)
0414 #define RTC_WEEKDAY_THURSDAY                ((uint8_t)0x04)
0415 #define RTC_WEEKDAY_FRIDAY                  ((uint8_t)0x05)
0416 #define RTC_WEEKDAY_SATURDAY                ((uint8_t)0x06)
0417 #define RTC_WEEKDAY_SUNDAY                  ((uint8_t)0x07)
0418 
0419 /**
0420   * @}
0421   */
0422 
0423 /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC Alarm Date WeekDay Definitions
0424   * @ingroup RTEMSBSPsARMSTM32H7
0425   * @{
0426   */
0427 #define RTC_ALARMDATEWEEKDAYSEL_DATE      0x00000000u
0428 #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY   RTC_ALRMAR_WDSEL
0429 
0430 /**
0431   * @}
0432   */
0433 
0434 /** @defgroup RTC_AlarmMask_Definitions RTC Alarm Mask Definitions
0435   * @ingroup RTEMSBSPsARMSTM32H7
0436   * @{
0437   */
0438 #define RTC_ALARMMASK_NONE                0x00000000u
0439 #define RTC_ALARMMASK_DATEWEEKDAY         RTC_ALRMAR_MSK4
0440 #define RTC_ALARMMASK_HOURS               RTC_ALRMAR_MSK3
0441 #define RTC_ALARMMASK_MINUTES             RTC_ALRMAR_MSK2
0442 #define RTC_ALARMMASK_SECONDS             RTC_ALRMAR_MSK1
0443 #define RTC_ALARMMASK_ALL                 (RTC_ALARMMASK_DATEWEEKDAY | \
0444                                            RTC_ALARMMASK_HOURS       | \
0445                                            RTC_ALARMMASK_MINUTES     | \
0446                                            RTC_ALARMMASK_SECONDS)
0447 /**
0448   * @}
0449   */
0450 
0451 /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions
0452   * @ingroup RTEMSBSPsARMSTM32H7
0453   * @{
0454   */
0455 #define RTC_ALARM_A                       RTC_CR_ALRAE
0456 #define RTC_ALARM_B                       RTC_CR_ALRBE
0457 /**
0458   * @}
0459   */
0460 
0461 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions
0462   * @ingroup RTEMSBSPsARMSTM32H7
0463   * @{
0464   */
0465 /*!< All Alarm SS fields are masked. There is no comparison on sub seconds for Alarm */
0466 #define RTC_ALARMSUBSECONDMASK_ALL         0x00000000u
0467 /*!< SS[14:1] are don't care in Alarm comparison. Only SS[0] is compared.     */
0468 #define RTC_ALARMSUBSECONDMASK_SS14_1      RTC_ALRMASSR_MASKSS_0
0469 /*!< SS[14:2] are don't care in Alarm comparison. Only SS[1:0] are compared.  */
0470 #define RTC_ALARMSUBSECONDMASK_SS14_2      RTC_ALRMASSR_MASKSS_1
0471 /*!< SS[14:3] are don't care in Alarm comparison. Only SS[2:0] are compared.  */
0472 #define RTC_ALARMSUBSECONDMASK_SS14_3      (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1)
0473 /*!< SS[14:4] are don't care in Alarm comparison. Only SS[3:0] are compared.  */
0474 #define RTC_ALARMSUBSECONDMASK_SS14_4      RTC_ALRMASSR_MASKSS_2
0475 /*!< SS[14:5] are don't care in Alarm comparison. Only SS[4:0] are compared.  */
0476 #define RTC_ALARMSUBSECONDMASK_SS14_5      (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2)
0477 /*!< SS[14:6] are don't care in Alarm comparison. Only SS[5:0] are compared.  */
0478 #define RTC_ALARMSUBSECONDMASK_SS14_6      (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)
0479 /*!< SS[14:7] are don't care in Alarm comparison. Only SS[6:0] are compared.  */
0480 #define RTC_ALARMSUBSECONDMASK_SS14_7      (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)
0481 /*!< SS[14:8] are don't care in Alarm comparison. Only SS[7:0] are compared.  */
0482 #define RTC_ALARMSUBSECONDMASK_SS14_8      RTC_ALRMASSR_MASKSS_3
0483 /*!< SS[14:9] are don't care in Alarm comparison. Only SS[8:0] are compared.  */
0484 #define RTC_ALARMSUBSECONDMASK_SS14_9      (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_3)
0485 /*!< SS[14:10] are don't care in Alarm comparison. Only SS[9:0] are compared. */
0486 #define RTC_ALARMSUBSECONDMASK_SS14_10     (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)
0487 /*!< SS[14:11] are don't care in Alarm comparison. Only SS[10:0] are compared. */
0488 #define RTC_ALARMSUBSECONDMASK_SS14_11     (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)
0489 /*!< SS[14:12] are don't care in Alarm comparison. Only SS[11:0] are compared. */
0490 #define RTC_ALARMSUBSECONDMASK_SS14_12     (RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
0491 /*!< SS[14:13] are don't care in Alarm comparison. Only SS[12:0] are compared. */
0492 #define RTC_ALARMSUBSECONDMASK_SS14_13     (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
0493 /*!< SS[14] is don't care in Alarm comparison. Only SS[13:0] are compared. */
0494 #define RTC_ALARMSUBSECONDMASK_SS14        (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
0495 /*!< SS[14:0] are compared and must match to activate alarm. */
0496 #define RTC_ALARMSUBSECONDMASK_NONE        RTC_ALRMASSR_MASKSS
0497 
0498 /**
0499   * @}
0500   */
0501 
0502 /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions
0503   * @ingroup RTEMSBSPsARMSTM32H7
0504   * @{
0505   */
0506 #define RTC_IT_TS                         RTC_CR_TSIE         /*!< Enable Timestamp Interrupt               */
0507 #define RTC_IT_WUT                        RTC_CR_WUTIE        /*!< Enable Wakeup timer Interrupt            */
0508 #define RTC_IT_ALRA                       RTC_CR_ALRAIE       /*!< Enable Alarm A Interrupt                 */
0509 #define RTC_IT_ALRB                       RTC_CR_ALRBIE       /*!< Enable Alarm B Interrupt                 */
0510 /**
0511   * @}
0512   */
0513 
0514 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions
0515   * @ingroup RTEMSBSPsARMSTM32H7
0516   * @{
0517   */
0518 #if defined(TAMP)
0519 #define RTC_FLAG_RECALPF                  RTC_ICSR_RECALPF  /*!< Recalibration pending Flag */
0520 #define RTC_FLAG_INITF                    RTC_ICSR_INITF    /*!< Initialization pending flag */
0521 #define RTC_FLAG_RSF                      RTC_ICSR_RSF      /*!< Registers synchronization flag */
0522 #define RTC_FLAG_INITS                    RTC_ICSR_INITS    /*!< Initialization status flag */
0523 #define RTC_FLAG_SHPF                     RTC_ICSR_SHPF     /*!< Shift operation pending flag */
0524 #define RTC_FLAG_WUTWF                    RTC_ICSR_WUTWF    /*!< Wakeup timer write operation pending flag */
0525 #define RTC_FLAG_ALRBWF                   RTC_ICSR_ALRBWF   /*!< Alarm B write operation pending flag */
0526 #define RTC_FLAG_ALRAWF                   RTC_ICSR_ALRAWF   /*!< Alarm A write operation pending flag */
0527 #define RTC_FLAG_ITSF                     RTC_SR_ITSF       /*!< Internal Time-stamp flag */
0528 #define RTC_FLAG_TSOVF                    RTC_SR_TSOVF      /*!< Time-stamp overflow flag */
0529 #define RTC_FLAG_TSF                      RTC_SR_TSF        /*!< Time-stamp flag */
0530 #define RTC_FLAG_WUTF                     RTC_SR_WUTF       /*!< Wakeup timer flag */
0531 #define RTC_FLAG_ALRBF                    RTC_SR_ALRBF      /*!< Alarm B flag */
0532 #define RTC_FLAG_ALRAF                    RTC_SR_ALRAF      /*!< Alarm A flag */
0533 #else
0534 #define RTC_FLAG_RECALPF                  RTC_ISR_RECALPF
0535 #define RTC_FLAG_TSOVF                    RTC_ISR_TSOVF
0536 #define RTC_FLAG_TSF                      RTC_ISR_TSF
0537 #define RTC_FLAG_ITSF                     RTC_ISR_ITSF
0538 #define RTC_FLAG_WUTF                     RTC_ISR_WUTF
0539 #define RTC_FLAG_ALRBF                    RTC_ISR_ALRBF
0540 #define RTC_FLAG_ALRAF                    RTC_ISR_ALRAF
0541 #define RTC_FLAG_INITF                    RTC_ISR_INITF
0542 #define RTC_FLAG_RSF                      RTC_ISR_RSF
0543 #define RTC_FLAG_INITS                    RTC_ISR_INITS
0544 #define RTC_FLAG_SHPF                     RTC_ISR_SHPF
0545 #define RTC_FLAG_WUTWF                    RTC_ISR_WUTWF
0546 #define RTC_FLAG_ALRBWF                   RTC_ISR_ALRBWF
0547 #define RTC_FLAG_ALRAWF                   RTC_ISR_ALRAWF
0548 #endif /* TAMP */
0549 /**
0550   * @}
0551   */
0552 
0553 /** @defgroup RTC_Clear_Flags_Definitions RTC Clear Flags Definitions
0554   * @ingroup RTEMSBSPsARMSTM32H7
0555   * @{
0556   */
0557 #if defined(TAMP)
0558 #define RTC_CLEAR_ITSF                      RTC_SCR_CITSF    /*!< Clear Internal Time-stamp flag */
0559 #define RTC_CLEAR_TSOVF                     RTC_SCR_CTSOVF   /*!< Clear Time-stamp overflow flag */
0560 #define RTC_CLEAR_TSF                       RTC_SCR_CTSF     /*!< Clear Time-stamp flag */
0561 #define RTC_CLEAR_WUTF                      RTC_SCR_CWUTF    /*!< Clear Wakeup timer flag */
0562 #define RTC_CLEAR_ALRBF                     RTC_SCR_CALRBF   /*!< Clear Alarm B flag */
0563 #define RTC_CLEAR_ALRAF                     RTC_SCR_CALRAF   /*!< Clear Alarm A flag */
0564 #endif /* TAMP
0565  */
0566 /**
0567   * @}
0568   */
0569 
0570 /**
0571   * @}
0572   */
0573 
0574 /* Exported macros -----------------------------------------------------------*/
0575 /** @defgroup RTC_Exported_Macros RTC Exported Macros
0576   * @ingroup RTEMSBSPsARMSTM32H7
0577   * @{
0578   */
0579 
0580 /** @brief Reset RTC handle state
0581   * @param  __HANDLE__ RTC handle.
0582   * @retval None
0583   */
0584 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
0585 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{                                              \
0586                                                       (__HANDLE__)->State = HAL_RTC_STATE_RESET;  \
0587                                                       (__HANDLE__)->MspInitCallback = NULL;       \
0588                                                       (__HANDLE__)->MspDeInitCallback = NULL;     \
0589                                                      }while(0u)
0590 #else
0591 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
0592 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
0593 
0594 /**
0595   * @brief  Disable the write protection for RTC registers.
0596   * @param  __HANDLE__ specifies the RTC handle.
0597   * @retval None
0598   */
0599 #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__)              \
0600                         do{                                        \
0601                             (__HANDLE__)->Instance->WPR = 0xCAU;   \
0602                             (__HANDLE__)->Instance->WPR = 0x53U;   \
0603                           } while(0u)
0604 
0605 /**
0606   * @brief  Enable the write protection for RTC registers.
0607   * @param  __HANDLE__ specifies the RTC handle.
0608   * @retval None
0609   */
0610 #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__)               \
0611                         do{                                        \
0612                             (__HANDLE__)->Instance->WPR = 0xFFU;   \
0613                           } while(0u)
0614 
0615 /**
0616   * @brief  Check whether the RTC Calendar is initialized.
0617   * @param  __HANDLE__ specifies the RTC handle.
0618   * @retval None
0619   */
0620 #if defined(TAMP)
0621 #define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__)  (((((__HANDLE__)->Instance->ICSR) & (RTC_FLAG_INITS)) == RTC_FLAG_INITS) ? 1U : 0U)
0622 #else
0623 #define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__)  (((((__HANDLE__)->Instance->ISR)  & (RTC_FLAG_INITS)) == RTC_FLAG_INITS) ? 1U : 0U)
0624 #endif /* TAMP */
0625 
0626 /**
0627   * @brief  Add 1 hour (summer time change).
0628   * @param  __HANDLE__ specifies the RTC handle.
0629   * @param  __BKP__ Backup
0630   *         This parameter can be:
0631   *            @arg @ref RTC_STOREOPERATION_RESET
0632   *            @arg @ref RTC_STOREOPERATION_SET
0633   * @retval None
0634   */
0635 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_ADD1H(__HANDLE__, __BKP__)                           \
0636                         do {                                                                \
0637                             __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__);                  \
0638                             SET_BIT((__HANDLE__)->Instance->CR, RTC_CR_ADD1H);              \
0639                             MODIFY_REG((__HANDLE__)->Instance->CR, RTC_CR_BKP , (__BKP__)); \
0640                             __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__);                   \
0641                         } while(0u);
0642 
0643 /**
0644   * @brief  Subtract 1 hour (winter time change).
0645   * @param  __HANDLE__ specifies the RTC handle.
0646   * @param  __BKP__ Backup
0647   *         This parameter can be:
0648   *            @arg @ref RTC_STOREOPERATION_RESET
0649   *            @arg @ref RTC_STOREOPERATION_SET
0650   * @retval None
0651   */
0652 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_SUB1H(__HANDLE__, __BKP__)                           \
0653                         do {                                                                \
0654                             __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__);                  \
0655                             SET_BIT((__HANDLE__)->Instance->CR, RTC_CR_SUB1H);              \
0656                             MODIFY_REG((__HANDLE__)->Instance->CR, RTC_CR_BKP , (__BKP__)); \
0657                             __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__);                   \
0658                         } while(0u);
0659 
0660 /**
0661   * @brief  Enable the RTC ALARMA peripheral.
0662   * @param  __HANDLE__ specifies the RTC handle.
0663   * @retval None
0664   */
0665 #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__)                          ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE))
0666 
0667 /**
0668   * @brief  Disable the RTC ALARMA peripheral.
0669   * @param  __HANDLE__ specifies the RTC handle.
0670   * @retval None
0671   */
0672 #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__)                         ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE))
0673 
0674 /**
0675   * @brief  Enable the RTC ALARMB peripheral.
0676   * @param  __HANDLE__ specifies the RTC handle.
0677   * @retval None
0678   */
0679 #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__)                          ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE))
0680 
0681 /**
0682   * @brief  Disable the RTC ALARMB peripheral.
0683   * @param  __HANDLE__ specifies the RTC handle.
0684   * @retval None
0685   */
0686 #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__)                         ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE))
0687 
0688 /**
0689   * @brief  Enable the RTC Alarm interrupt.
0690   * @param  __HANDLE__ specifies the RTC handle.
0691   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
0692   *          This parameter can be any combination of the following values:
0693   *             @arg @ref RTC_IT_ALRA Alarm A interrupt
0694   *             @arg @ref RTC_IT_ALRB Alarm B interrupt
0695   * @retval None
0696   */
0697 #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__)         ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
0698 
0699 /**
0700   * @brief  Disable the RTC Alarm interrupt.
0701   * @param  __HANDLE__ specifies the RTC handle.
0702   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
0703   *         This parameter can be any combination of the following values:
0704   *            @arg @ref RTC_IT_ALRA Alarm A interrupt
0705   *            @arg @ref RTC_IT_ALRB Alarm B interrupt
0706   * @retval None
0707   */
0708 #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__)        ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
0709 
0710 /**
0711   * @brief  Check whether the specified RTC Alarm interrupt has occurred or not.
0712   * @param  __HANDLE__ specifies the RTC handle.
0713   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
0714   *         This parameter can be:
0715   *            @arg @ref RTC_IT_ALRA Alarm A interrupt
0716   *            @arg @ref RTC_IT_ALRB Alarm B interrupt
0717   * @retval None
0718   */
0719 #if defined(TAMP)
0720 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->MISR)& (__INTERRUPT__ >> 12)) != 0U)? 1U : 0U)
0721 #else
0722 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR)& (__INTERRUPT__ >> 4)) != 0U)? 1U : 0U)
0723 #endif /* TAMP */
0724 
0725 /**
0726   * @brief  Check whether the specified RTC Alarm interrupt has been enabled or not.
0727   * @param  __HANDLE__ specifies the RTC handle.
0728   * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
0729   *         This parameter can be:
0730   *            @arg @ref RTC_IT_ALRA Alarm A interrupt
0731   *            @arg @ref RTC_IT_ALRB Alarm B interrupt
0732   * @retval None
0733   */
0734 #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)     (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
0735 
0736 #if defined(TAMP)
0737 /**
0738   * @brief  Get the selected RTC Alarm's flag status.
0739   * @param  __HANDLE__ specifies the RTC handle.
0740   * @param  __FLAG__ specifies the RTC Alarm Flag sources to check.
0741   *         This parameter can be:
0742   *            @arg @ref RTC_FLAG_ALRAF
0743   *            @arg @ref RTC_FLAG_ALRBF
0744   * @retval None
0745   */
0746 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__)               (((((__HANDLE__)->Instance->SR)  & (__FLAG__)) != 0U) ? 1U : 0U)
0747 #else
0748 /**
0749   * @brief  Get the selected RTC Alarm's flag status.
0750   * @param  __HANDLE__ specifies the RTC handle.
0751   * @param  __FLAG__ specifies the RTC Alarm Flag sources to check.
0752   *         This parameter can be:
0753   *            @arg @ref RTC_FLAG_ALRAF
0754   *            @arg @ref RTC_FLAG_ALRBF
0755   *            @arg @ref RTC_FLAG_ALRAWF
0756   *            @arg @ref RTC_FLAG_ALRBWF
0757   * @retval None
0758   */
0759 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__)               (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
0760 #endif /* TAMP */
0761 
0762 /**
0763   * @brief  Clear the RTC Alarm's pending flags.
0764   * @param  __HANDLE__ specifies the RTC handle.
0765   * @param  __FLAG__ specifies the RTC Alarm Flag sources to clear.
0766   *          This parameter can be:
0767   *             @arg @ref RTC_FLAG_ALRAF
0768   *             @arg @ref RTC_FLAG_ALRBF
0769   * @retval None
0770   */
0771 #if defined(TAMP)
0772 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__)             ((__HANDLE__)->Instance->SCR = __FLAG__)
0773 #else
0774 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__)             ((__HANDLE__)->Instance->ISR = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)))
0775 #endif /* TAMP */
0776 
0777 
0778 /**
0779   * @brief  Enable interrupt on the RTC Alarm associated Exti line.
0780   * @retval None
0781   */
0782 #if defined(EXTI_D1)
0783 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT()            (EXTI_D1->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
0784 #else  /* EXTI */
0785 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT()            (EXTI->IMR1    |= RTC_EXTI_LINE_ALARM_EVENT)
0786 #endif /* EXTI_D1 */
0787 
0788 /**
0789   * @brief  Disable interrupt on the RTC Alarm associated Exti line.
0790   * @retval None
0791   */
0792 #if defined(EXTI_D1)
0793 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT()           (EXTI_D1->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
0794 #else  /* EXTI */
0795 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT()           (EXTI->IMR1    &= ~(RTC_EXTI_LINE_ALARM_EVENT))
0796 #endif /* EXTI_D1 */
0797 
0798 /**
0799   * @brief  Enable event on the RTC Alarm associated Exti line.
0800   * @retval None.
0801   */
0802 #if defined(EXTI_D1)
0803 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT()         (EXTI_D1->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
0804 #else  /* EXTI */
0805 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT()         (EXTI->EMR1    |= RTC_EXTI_LINE_ALARM_EVENT)
0806 #endif /* EXTI_D1 */
0807 
0808 /**
0809   * @brief  Disable event on the RTC Alarm associated Exti line.
0810   * @retval None.
0811   */
0812 #if defined(EXTI_D1)
0813 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT()         (EXTI_D1->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
0814 #else  /* EXTI */
0815 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT()         (EXTI->EMR1    &= ~(RTC_EXTI_LINE_ALARM_EVENT))
0816 #endif /* EXTI_D1 */
0817 
0818 #if defined(DUAL_CORE)
0819 /**
0820   * @brief  Enable interrupt on the RTC Alarm associated D2 Exti line.
0821   * @retval None
0822   */
0823 #define __HAL_RTC_ALARM_EXTID2_ENABLE_IT()          (EXTI_D2->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
0824 
0825 /**
0826   * @brief  Disable interrupt on the RTC Alarm associated D2 Exti line.
0827   * @retval None
0828   */
0829 #define __HAL_RTC_ALARM_EXTID2_DISABLE_IT()         (EXTI_D2->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
0830 
0831 /**
0832   * @brief  Enable event on the RTC Alarm associated D2 Exti line.
0833   * @retval None
0834   */
0835 #define __HAL_RTC_ALARM_EXTID2_ENABLE_EVENT()        (EXTI_D2->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT)
0836 
0837 /**
0838   * @brief  Disable event on the RTC Alarm associated D2 Exti line.
0839   * @retval None
0840   */
0841 #define __HAL_RTC_ALARM_EXTID2_DISABLE_EVENT()       (EXTI_D2->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
0842 
0843 #endif /* DUAL_CORE */
0844 /**
0845   * @brief  Enable falling edge trigger on the RTC Alarm associated Exti line.
0846   * @retval None
0847   */
0848 #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE()   (EXTI->FTSR1 |= RTC_EXTI_LINE_ALARM_EVENT)
0849 
0850 /**
0851   * @brief  Disable falling edge trigger on the RTC Alarm associated Exti line.
0852   * @retval None
0853   */
0854 #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE()  (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
0855 
0856 /**
0857   * @brief  Enable rising edge trigger on the RTC Alarm associated Exti line.
0858   * @retval None
0859   */
0860 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE()    (EXTI->RTSR1 |= RTC_EXTI_LINE_ALARM_EVENT)
0861 
0862 /**
0863   * @brief  Disable rising edge trigger on the RTC Alarm associated Exti line.
0864   * @retval None
0865   */
0866 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE()   (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT))
0867 
0868 /**
0869   * @brief  Enable rising & falling edge trigger on the RTC Alarm associated Exti line.
0870   * @retval None
0871   */
0872 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE()  do { \
0873                                                              __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE();  \
0874                                                              __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \
0875                                                            } while(0u)
0876 
0877 /**
0878   * @brief  Disable rising & falling edge trigger on the RTC Alarm associated Exti line.
0879   * @retval None
0880   */
0881 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
0882                                                              __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE();  \
0883                                                              __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \
0884                                                            } while(0u)
0885 
0886 /**
0887   * @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or not.
0888   * @retval Line Status.
0889   */
0890 #if defined(EXTI_D1)
0891 #define __HAL_RTC_ALARM_EXTI_GET_FLAG()              (EXTI_D1->PR1 & RTC_EXTI_LINE_ALARM_EVENT)
0892 #else  /* EXTI */
0893 #define __HAL_RTC_ALARM_EXTI_GET_FLAG()              (EXTI->PR1    & RTC_EXTI_LINE_ALARM_EVENT)
0894 #endif /* EXTI_D1 */
0895 
0896 /**
0897   * @brief Clear the RTC Alarm associated Exti line flag.
0898   * @retval None.
0899   */
0900 #if defined(EXTI_D1)
0901 #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG()            (EXTI_D1->PR1 = (RTC_EXTI_LINE_ALARM_EVENT))
0902 #else  /* EXTI */
0903 #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG()            (EXTI->PR1    = (RTC_EXTI_LINE_ALARM_EVENT))
0904 #endif /* EXTI_D1 */
0905 
0906 #if defined(DUAL_CORE)
0907 /**
0908   * @brief Check whether the RTC Alarm associated D2 Exti line interrupt flag is set or not.
0909   * @retval Line Status
0910   */
0911 #define __HAL_RTC_ALARM_EXTID2_GET_FLAG()            (EXTI_D2->PR1 & RTC_EXTI_LINE_ALARM_EVENT)
0912 
0913 /**
0914   * @brief Clear the RTC Alarm associated D2 Exti line flag.
0915   * @retval None
0916   */
0917 #define __HAL_RTC_ALARM_EXTID2_CLEAR_FLAG()          (EXTI_D2->PR1 = (RTC_EXTI_LINE_ALARM_EVENT))
0918 #endif /* DUAL_CORE */
0919 /**
0920   * @brief Generate a Software interrupt on RTC Alarm associated Exti line.
0921   * @retval None
0922   */
0923 #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT()         (EXTI->SWIER1 |= RTC_EXTI_LINE_ALARM_EVENT)
0924 
0925 /**
0926   * @}
0927   */
0928 
0929 /* Include RTC HAL Extended module */
0930 #include "stm32h7xx_hal_rtc_ex.h"
0931 
0932 /* Exported functions --------------------------------------------------------*/
0933 /** @defgroup RTC_Exported_Functions RTC Exported Functions
0934   * @ingroup RTEMSBSPsARMSTM32H7
0935   * @{
0936   */
0937 
0938 /** @defgroup RTC_Exported_Functions_Group1 Initialization and de-initialization functions
0939   * @ingroup RTEMSBSPsARMSTM32H7
0940   * @{
0941   */
0942 /* Initialization and de-initialization functions  ****************************/
0943 HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
0944 HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
0945 
0946 void              HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
0947 void              HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
0948 
0949 /* Callbacks Register/UnRegister functions  ***********************************/
0950 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
0951 HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback);
0952 HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID);
0953 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */
0954 /**
0955   * @}
0956   */
0957 
0958 /** @defgroup RTC_Exported_Functions_Group2 RTC Time and Date functions
0959   * @ingroup RTEMSBSPsARMSTM32H7
0960   * @{
0961   */
0962 /* RTC Time and Date functions ************************************************/
0963 HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
0964 HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
0965 HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
0966 HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
0967 /**
0968   * @}
0969   */
0970 
0971 /** @defgroup RTC_Exported_Functions_Group3 RTC Alarm functions
0972   * @ingroup RTEMSBSPsARMSTM32H7
0973   * @{
0974   */
0975 /* RTC Alarm functions ********************************************************/
0976 HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
0977 HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
0978 HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm);
0979 HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format);
0980 void              HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
0981 void              HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc);
0982 HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
0983 /**
0984   * @}
0985   */
0986 
0987 /** @defgroup  RTC_Exported_Functions_Group4 Peripheral Control functions
0988   * @ingroup RTEMSBSPsARMSTM32H7
0989   * @{
0990   */
0991 /* Peripheral Control functions ***********************************************/
0992 HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc);
0993 /**
0994   * @}
0995   */
0996 
0997 /** @defgroup RTC_Exported_Functions_Group5 Peripheral State functions
0998   * @ingroup RTEMSBSPsARMSTM32H7
0999   * @{
1000   */
1001 /* Peripheral State functions *************************************************/
1002 HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc);
1003 /**
1004   * @}
1005   */
1006 
1007 /**
1008   * @}
1009   */
1010 
1011 /* Private types -------------------------------------------------------------*/
1012 /* Private variables ---------------------------------------------------------*/
1013 /* Private constants ---------------------------------------------------------*/
1014 /** @defgroup RTC_Private_Constants RTC Private Constants
1015   * @ingroup RTEMSBSPsARMSTM32H7
1016   * @{
1017   */
1018 /* Masks Definition */
1019 #define RTC_TR_RESERVED_MASK    (RTC_TR_PM  | RTC_TR_HT | RTC_TR_HU | \
1020                                  RTC_TR_MNT | RTC_TR_MNU| RTC_TR_ST | \
1021                                  RTC_TR_SU)
1022 
1023 #define RTC_DR_RESERVED_MASK    (RTC_DR_YT | RTC_DR_YU | RTC_DR_WDU | \
1024                                  RTC_DR_MT | RTC_DR_MU | RTC_DR_DT  | \
1025                                  RTC_DR_DU)
1026 
1027 #define RTC_INIT_MASK           0xFFFFFFFFu
1028 
1029 #if defined(TAMP)
1030 #define RTC_ICSR_RESERVED_MASK              0x000100FFu
1031 #define RTC_RSF_MASK                        (~(RTC_ICSR_INIT | RTC_ICSR_RSF))
1032 #else
1033 #define RTC_ISR_RESERVED_MASK               0x0003FFFFu
1034 #define RTC_RSF_MASK                        (~(RTC_ISR_INIT | RTC_ISR_RSF))
1035 #endif /* TAMP */
1036 
1037 #define RTC_TIMEOUT_VALUE  1000u
1038 
1039 #define RTC_EXTI_LINE_ALARM_EVENT    EXTI_IMR1_IM17  /*!< External interrupt line 17 Connected to the RTC Alarm event */
1040 
1041 /**
1042   * @}
1043   */
1044 
1045 /* Private macros ------------------------------------------------------------*/
1046 /** @defgroup RTC_Private_Macros RTC Private Macros
1047   * @ingroup RTEMSBSPsARMSTM32H7
1048   * @{
1049   */
1050 
1051 /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters
1052   * @ingroup RTEMSBSPsARMSTM32H7
1053   * @{
1054   */
1055 
1056 #if defined(TAMP)
1057 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE)     || \
1058                                ((OUTPUT) == RTC_OUTPUT_ALARMA)      || \
1059                                ((OUTPUT) == RTC_OUTPUT_ALARMB)      || \
1060                                ((OUTPUT) == RTC_OUTPUT_WAKEUP)      || \
1061                                ((OUTPUT) == RTC_OUTPUT_TAMPER))
1062 #else
1063 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE)     || \
1064                                ((OUTPUT) == RTC_OUTPUT_ALARMA)      || \
1065                                ((OUTPUT) == RTC_OUTPUT_ALARMB)      || \
1066                                ((OUTPUT) == RTC_OUTPUT_WAKEUP))
1067 #endif /* TAMP */
1068 
1069 #define IS_RTC_HOUR_FORMAT(FORMAT)     (((FORMAT) == RTC_HOURFORMAT_12) || \
1070                                         ((FORMAT) == RTC_HOURFORMAT_24))
1071 
1072 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \
1073                                 ((POL) == RTC_OUTPUT_POLARITY_LOW))
1074 
1075 #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
1076                                   ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL))
1077 
1078 #if defined(TAMP)
1079 #define IS_RTC_OUTPUT_PULLUP(TYPE) (((TYPE) == RTC_OUTPUT_PULLUP_NONE) || \
1080                                     ((TYPE) == RTC_OUTPUT_PULLUP_ON))
1081 #endif /* TAMP */
1082 
1083 #define IS_RTC_OUTPUT_REMAP(REMAP)     (((REMAP) == RTC_OUTPUT_REMAP_NONE) || \
1084                                         ((REMAP) == RTC_OUTPUT_REMAP_POS1))
1085 
1086 #define IS_RTC_HOURFORMAT12(PM)  (((PM) == RTC_HOURFORMAT12_AM) || \
1087                                   ((PM) == RTC_HOURFORMAT12_PM))
1088 
1089 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \
1090                                       ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \
1091                                       ((SAVE) == RTC_DAYLIGHTSAVING_NONE))
1092 
1093 #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \
1094                                            ((OPERATION) == RTC_STOREOPERATION_SET))
1095 
1096 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || \
1097                                ((FORMAT) == RTC_FORMAT_BCD))
1098 
1099 #define IS_RTC_YEAR(YEAR)              ((YEAR)   <= 99u)
1100 
1101 #define IS_RTC_MONTH(MONTH)            (((MONTH) >= 1u) && ((MONTH) <= 12u))
1102 
1103 #define IS_RTC_DATE(DATE)              (((DATE)  >= 1u) && ((DATE)  <= 31u))
1104 
1105 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY)    || \
1106                                  ((WEEKDAY) == RTC_WEEKDAY_TUESDAY)   || \
1107                                  ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
1108                                  ((WEEKDAY) == RTC_WEEKDAY_THURSDAY)  || \
1109                                  ((WEEKDAY) == RTC_WEEKDAY_FRIDAY)    || \
1110                                  ((WEEKDAY) == RTC_WEEKDAY_SATURDAY)  || \
1111                                  ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
1112 
1113 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0u) && ((DATE) <= 31u))
1114 
1115 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY)    || \
1116                                                     ((WEEKDAY) == RTC_WEEKDAY_TUESDAY)   || \
1117                                                     ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
1118                                                     ((WEEKDAY) == RTC_WEEKDAY_THURSDAY)  || \
1119                                                     ((WEEKDAY) == RTC_WEEKDAY_FRIDAY)    || \
1120                                                     ((WEEKDAY) == RTC_WEEKDAY_SATURDAY)  || \
1121                                                     ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
1122 
1123 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
1124                                             ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
1125 
1126 #define IS_RTC_ALARM_MASK(MASK)  (((MASK) & ~(RTC_ALARMMASK_ALL)) == 0u)
1127 
1128 #define IS_RTC_ALARM(ALARM)      (((ALARM) == RTC_ALARM_A) || \
1129                                   ((ALARM) == RTC_ALARM_B))
1130 
1131 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= RTC_ALRMASSR_SS)
1132 
1133 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK)          (((MASK) == 0u) || \
1134                                                     (((MASK) >= RTC_ALARMSUBSECONDMASK_SS14_1) && ((MASK) <= RTC_ALARMSUBSECONDMASK_NONE)))
1135 
1136 #define IS_RTC_ASYNCH_PREDIV(PREDIV)   ((PREDIV) <= (RTC_PRER_PREDIV_A >> RTC_PRER_PREDIV_A_Pos))
1137 
1138 #define IS_RTC_SYNCH_PREDIV(PREDIV)    ((PREDIV) <= (RTC_PRER_PREDIV_S >> RTC_PRER_PREDIV_S_Pos))
1139 
1140 #define IS_RTC_HOUR12(HOUR)            (((HOUR) >  0u) && ((HOUR) <= 12u))
1141 
1142 #define IS_RTC_HOUR24(HOUR)            ((HOUR)    <= 23u)
1143 
1144 #define IS_RTC_MINUTES(MINUTES)        ((MINUTES) <= 59u)
1145 
1146 #define IS_RTC_SECONDS(SECONDS)        ((SECONDS) <= 59u)
1147 
1148 /**
1149   * @}
1150   */
1151 
1152 /**
1153   * @}
1154   */
1155 
1156 /* Private functions -------------------------------------------------------------*/
1157 /** @defgroup RTC_Private_Functions RTC Private Functions
1158   * @ingroup RTEMSBSPsARMSTM32H7
1159   * @{
1160   */
1161 HAL_StatusTypeDef  RTC_EnterInitMode(RTC_HandleTypeDef *hrtc);
1162 HAL_StatusTypeDef  RTC_ExitInitMode(RTC_HandleTypeDef *hrtc);
1163 uint8_t            RTC_ByteToBcd2(uint8_t Value);
1164 uint8_t            RTC_Bcd2ToByte(uint8_t Value);
1165 
1166 /**
1167   * @}
1168   */
1169 
1170 /**
1171   * @}
1172   */
1173 
1174 /**
1175   * @}
1176   */
1177 
1178 #ifdef __cplusplus
1179 }
1180 #endif
1181 
1182 #endif /* STM32H7xx_HAL_RTC_H */
1183