1 /** 2 ****************************************************************************** 3 * @file stm32h5xx_hal_rtc.h 4 * @author MCD Application Team 5 * @brief Header file of RTC HAL module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2023 STMicroelectronics. 10 * All rights reserved. 11 * 12 * This software component is licensed by ST under BSD 3-Clause license, 13 * the "License"; You may not use this file except in compliance with the 14 * License. You may obtain a copy of the License at: 15 * opensource.org/licenses/BSD-3-Clause 16 * 17 ****************************************************************************** 18 */ 19 20 /* Define to prevent recursive inclusion -------------------------------------*/ 21 #ifndef STM32H5xx_HAL_RTC_H 22 #define STM32H5xx_HAL_RTC_H 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 /* Includes ------------------------------------------------------------------*/ 29 #include "stm32h5xx_hal_def.h" 30 31 /** @addtogroup STM32H5xx_HAL_Driver 32 * @{ 33 */ 34 35 /** @defgroup RTC RTC 36 * @{ 37 */ 38 39 /* Exported types ------------------------------------------------------------*/ 40 /** @defgroup RTC_Exported_Types RTC Exported Types 41 * @{ 42 */ 43 44 /** 45 * @brief HAL State structures definition 46 */ 47 typedef enum 48 { 49 HAL_RTC_STATE_RESET = 0x00U, /*!< RTC not yet initialized or disabled */ 50 HAL_RTC_STATE_READY = 0x01U, /*!< RTC initialized and ready for use */ 51 HAL_RTC_STATE_BUSY = 0x02U, /*!< RTC process is ongoing */ 52 HAL_RTC_STATE_TIMEOUT = 0x03U, /*!< RTC timeout state */ 53 HAL_RTC_STATE_ERROR = 0x04U /*!< RTC error state */ 54 55 } HAL_RTCStateTypeDef; 56 57 /** 58 * @brief RTC Configuration Structure definition 59 */ 60 typedef struct 61 { 62 uint32_t HourFormat; /*!< Specifies the RTC Hour Format. 63 This parameter can be a value of @ref RTC_Hour_Formats */ 64 65 uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value. 66 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */ 67 68 uint32_t SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value. 69 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF */ 70 71 uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC output. 72 This parameter can be a value of @ref RTCEx_Output_selection_Definitions */ 73 74 uint32_t OutPutRemap; /*!< Specifies the remap for RTC output. 75 This parameter can be a value of @ref RTC_Output_ALARM_OUT_Remap */ 76 77 uint32_t OutPutPolarity; /*!< Specifies the polarity of the output signal. 78 This parameter can be a value of @ref RTC_Output_Polarity_Definitions */ 79 80 uint32_t OutPutType; /*!< Specifies the RTC Output Pin mode. 81 This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */ 82 83 uint32_t OutPutPullUp; /*!< Specifies the RTC Output Pull-Up mode. 84 This parameter can be a value of @ref RTC_Output_PullUp_ALARM_OUT */ 85 86 uint32_t BinMode; /*!< Specifies the RTC binary mode. 87 This parameter can be a value of @ref RTCEx_Binary_Mode */ 88 89 uint32_t BinMixBcdU; /*!< Specifies the BCD calendar update if and only if BinMode = RTC_BINARY_MIX. 90 This parameter can be a value of @ref RTCEx_Binary_mix_BCDU */ 91 } RTC_InitTypeDef; 92 93 /** 94 * @brief RTC Time structure definition 95 */ 96 typedef struct 97 { 98 uint8_t Hours; /*!< Specifies the RTC Time Hour. 99 This parameter must be a number between: 100 Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected. 101 This parameter must be a number between: 102 Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */ 103 104 uint8_t Minutes; /*!< Specifies the RTC Time Minutes. 105 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ 106 107 uint8_t Seconds; /*!< Specifies the RTC Time Seconds. 108 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ 109 110 uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time. 111 This parameter can be a value of @ref RTC_AM_PM_Definitions */ 112 113 uint32_t SubSeconds; /*!< Specifies the RTC_SSR RTC Sub Second register content. 114 This field is not used by HAL_RTC_SetTime. 115 If the free running 32 bit counter is not activated (mode binary none) 116 - This parameter corresponds to a time unit range 117 between [0-1] Second with [1 Sec / SecondFraction +1] granularity 118 else 119 - This parameter corresponds to the free running 32 bit counter. */ 120 121 uint32_t SecondFraction; /*!< Specifies the range or granularity of Sub Second register content 122 corresponding to Synchronous pre-scaler factor value (PREDIV_S) 123 This parameter corresponds to a time unit range between [0-1] Second 124 with [1 Sec / SecondFraction +1] granularity. 125 This field will be used only by HAL_RTC_GetTime function */ 126 127 uint32_t DayLightSaving; /*!< This interface is deprecated. 128 To manage Daylight Saving Time, please use HAL_RTC_DST_xxx functions */ 129 130 uint32_t StoreOperation; /*!< This interface is deprecated. 131 To manage Daylight Saving Time, please use HAL_RTC_DST_xxx functions */ 132 } RTC_TimeTypeDef; 133 134 /** 135 * @brief RTC Date structure definition 136 */ 137 typedef struct 138 { 139 uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay. 140 This parameter can be a value of @ref RTC_WeekDay_Definitions */ 141 142 uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format). 143 This parameter can be a value of @ref RTC_Month_Date_Definitions */ 144 145 uint8_t Date; /*!< Specifies the RTC Date. 146 This parameter must be a number between Min_Data = 1 and Max_Data = 31 */ 147 148 uint8_t Year; /*!< Specifies the RTC Date Year. 149 This parameter must be a number between Min_Data = 0 and Max_Data = 99 */ 150 } RTC_DateTypeDef; 151 152 /** 153 * @brief RTC Alarm structure definition 154 */ 155 typedef struct 156 { 157 RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */ 158 159 uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks. 160 This parameter can be a value of @ref RTC_AlarmMask_Definitions */ 161 162 uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks. 163 if Binary mode is RTC_BINARY_ONLY or is RTC_BINARY_MIX 164 This parameter can be a value of 165 @ref RTCEx_Alarm_Sub_Seconds_binary_Masks_Definitions 166 else if Binary mode is RTC_BINARY_NONE 167 This parameter can be a value of 168 @ref RTC_Alarm_Sub_Seconds_BCD_Masks_Definitions */ 169 170 uint32_t BinaryAutoClr; /*!< Clear synchronously counter (RTC_SSR) on binary alarm. 171 RTC_ALARMSUBSECONDBIN_AUTOCLR_YES must only be used if Binary mode 172 is RTC_BINARY_ONLY 173 This parameter can be a value of 174 @ref RTCEx_Alarm_Sub_Seconds_binary_Clear_Definitions */ 175 176 uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay. 177 This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */ 178 179 uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay. 180 If the Alarm Date is selected, this parameter must be set to a value 181 in the 1-31 range. 182 If the Alarm WeekDay is selected, this parameter can be a value of 183 @ref RTC_WeekDay_Definitions */ 184 185 uint32_t FlagAutoClr; /*!< Specifies the alarm trigger generation. This feature is meaningful 186 to avoid any RTC software execution after configuration. 187 This parameter can be a value of @ref RTC_ALARM_Flag_AutoClear_Definitions */ 188 189 uint32_t Alarm; /*!< Specifies the alarm. 190 This parameter can be a value of @ref RTC_Alarms_Definitions */ 191 } RTC_AlarmTypeDef; 192 193 /** 194 * @brief RTC Handle Structure definition 195 */ 196 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) 197 typedef struct __RTC_HandleTypeDef 198 #else 199 typedef struct 200 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */ 201 { 202 RTC_TypeDef *Instance; /*!< Legacy register base address. Not used anymore, the driver directly uses cmsis base address */ 203 204 RTC_InitTypeDef Init; /*!< RTC required parameters */ 205 206 HAL_LockTypeDef Lock; /*!< RTC locking object */ 207 208 __IO HAL_RTCStateTypeDef State; /*!< Time communication state */ 209 210 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) 211 void (* AlarmAEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm A Event callback */ 212 void (* AlarmBEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm B Event callback */ 213 void (* TimeStampEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC TimeStamp Event callback */ 214 void (* WakeUpTimerEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC WakeUpTimer Event callback */ 215 void (* SSRUEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC SSRU Event callback */ 216 void (* Tamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 1 Event callback */ 217 void (* Tamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 2 Event callback */ 218 void (* Tamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 3 Event callback */ 219 void (* Tamper4EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 4 Event callback */ 220 void (* Tamper5EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 5 Event callback */ 221 void (* Tamper6EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 6 Event callback */ 222 void (* Tamper7EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 7 Event callback */ 223 void (* Tamper8EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 8 Event callback */ 224 void (* InternalTamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 1 Event callback */ 225 void (* InternalTamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 2 Event callback */ 226 void (* InternalTamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 3 Event callback */ 227 void (* InternalTamper4EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 4 Event callback */ 228 void (* InternalTamper5EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 5 Event callback */ 229 void (* InternalTamper6EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 6 Event callback */ 230 void (* InternalTamper7EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 7 Event callback */ 231 void (* InternalTamper8EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 8 Event callback */ 232 void (* InternalTamper9EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 9 Event callback */ 233 void (* InternalTamper11EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 11 Event callback */ 234 void (* InternalTamper12EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 12 Event callback */ 235 void (* InternalTamper13EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 13 Event callback */ 236 void (* InternalTamper15EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 15 Event callback */ 237 void (* MspInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp Init callback */ 238 void (* MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp DeInit callback */ 239 240 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */ 241 242 } RTC_HandleTypeDef; 243 244 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) 245 /** 246 * @brief HAL RTC Callback ID enumeration definition 247 */ 248 typedef enum 249 { 250 HAL_RTC_ALARM_A_EVENT_CB_ID = 0U, /*!< RTC Alarm A Event Callback ID */ 251 HAL_RTC_ALARM_B_EVENT_CB_ID = 1U, /*!< RTC Alarm B Event Callback ID */ 252 HAL_RTC_TIMESTAMP_EVENT_CB_ID = 2U, /*!< RTC TimeStamp Event Callback ID */ 253 HAL_RTC_WAKEUPTIMER_EVENT_CB_ID = 3U, /*!< RTC WakeUp Timer Event Callback ID */ 254 HAL_RTC_SSRU_EVENT_CB_ID = 4U, /*!< RTC SSRU Event Callback ID */ 255 HAL_RTC_TAMPER1_EVENT_CB_ID = 5U, /*!< RTC Tamper 1 Callback ID */ 256 HAL_RTC_TAMPER2_EVENT_CB_ID = 6U, /*!< RTC Tamper 2 Callback ID */ 257 HAL_RTC_TAMPER3_EVENT_CB_ID = 7U, /*!< RTC Tamper 3 Callback ID */ 258 HAL_RTC_TAMPER4_EVENT_CB_ID = 8U, /*!< RTC Tamper 4 Callback ID */ 259 HAL_RTC_TAMPER5_EVENT_CB_ID = 9U, /*!< RTC Tamper 5 Callback ID */ 260 HAL_RTC_TAMPER6_EVENT_CB_ID = 10U, /*!< RTC Tamper 6 Callback ID */ 261 HAL_RTC_TAMPER7_EVENT_CB_ID = 11U, /*!< RTC Tamper 7 Callback ID */ 262 HAL_RTC_TAMPER8_EVENT_CB_ID = 12U, /*!< RTC Tamper 8 Callback ID */ 263 HAL_RTC_INTERNAL_TAMPER1_EVENT_CB_ID = 13U, /*!< RTC Internal Tamper 1 Callback ID */ 264 HAL_RTC_INTERNAL_TAMPER2_EVENT_CB_ID = 14U, /*!< RTC Internal Tamper 2 Callback ID */ 265 HAL_RTC_INTERNAL_TAMPER3_EVENT_CB_ID = 15U, /*!< RTC Internal Tamper 3 Callback ID */ 266 HAL_RTC_INTERNAL_TAMPER4_EVENT_CB_ID = 16U, /*!< RTC Internal Tamper 4 Callback ID */ 267 HAL_RTC_INTERNAL_TAMPER5_EVENT_CB_ID = 17U, /*!< RTC Internal Tamper 5 Callback ID */ 268 HAL_RTC_INTERNAL_TAMPER6_EVENT_CB_ID = 18U, /*!< RTC Internal Tamper 6 Callback ID */ 269 HAL_RTC_INTERNAL_TAMPER7_EVENT_CB_ID = 19U, /*!< RTC Internal Tamper 7 Callback ID */ 270 HAL_RTC_INTERNAL_TAMPER8_EVENT_CB_ID = 20U, /*!< RTC Internal Tamper 8 Callback ID */ 271 HAL_RTC_INTERNAL_TAMPER9_EVENT_CB_ID = 21U, /*!< RTC Internal Tamper 9 Callback ID */ 272 HAL_RTC_INTERNAL_TAMPER11_EVENT_CB_ID = 22U, /*!< RTC Internal Tamper 11 Callback ID */ 273 HAL_RTC_INTERNAL_TAMPER12_EVENT_CB_ID = 23U, /*!< RTC Internal Tamper 12 Callback ID */ 274 HAL_RTC_INTERNAL_TAMPER13_EVENT_CB_ID = 24U, /*!< RTC Internal Tamper 13 Callback ID */ 275 HAL_RTC_INTERNAL_TAMPER15_EVENT_CB_ID = 25U, /*!< RTC Internal Tamper 15 Callback ID */ 276 HAL_RTC_MSPINIT_CB_ID = 26U, /*!< RTC Msp Init callback ID */ 277 HAL_RTC_MSPDEINIT_CB_ID = 27U /*!< RTC Msp DeInit callback ID */ 278 } HAL_RTC_CallbackIDTypeDef; 279 280 /** 281 * @brief HAL RTC Callback pointer definition 282 */ 283 typedef void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc); /*!< pointer to an RTC callback function */ 284 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ 285 286 /** 287 * @} 288 */ 289 290 /* Exported constants --------------------------------------------------------*/ 291 /** @defgroup RTC_Exported_Constants RTC Exported Constants 292 * @{ 293 */ 294 295 /** @defgroup RTC_Hour_Formats RTC Hour Formats 296 * @{ 297 */ 298 #define RTC_HOURFORMAT_24 0x00000000u 299 #define RTC_HOURFORMAT_12 RTC_CR_FMT 300 /** 301 * @} 302 */ 303 304 /** @defgroup RTCEx_Output_selection_Definitions RTCEx Output Selection Definition 305 * @{ 306 */ 307 #define RTC_OUTPUT_DISABLE 0x00000000u 308 #define RTC_OUTPUT_ALARMA RTC_CR_OSEL_0 309 #define RTC_OUTPUT_ALARMB RTC_CR_OSEL_1 310 #define RTC_OUTPUT_WAKEUP RTC_CR_OSEL 311 #define RTC_OUTPUT_TAMPER RTC_CR_TAMPOE 312 /** 313 * @} 314 */ 315 316 /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions 317 * @{ 318 */ 319 #define RTC_OUTPUT_POLARITY_HIGH 0x00000000u 320 #define RTC_OUTPUT_POLARITY_LOW RTC_CR_POL 321 /** 322 * @} 323 */ 324 325 /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT 326 * @{ 327 */ 328 #define RTC_OUTPUT_TYPE_PUSHPULL 0x00000000u 329 #define RTC_OUTPUT_TYPE_OPENDRAIN RTC_CR_TAMPALRM_TYPE 330 /** 331 * @} 332 */ 333 334 /** @defgroup RTC_Output_PullUp_ALARM_OUT RTC Output Pull-Up ALARM OUT 335 * @{ 336 */ 337 #define RTC_OUTPUT_PULLUP_NONE 0x00000000u 338 #define RTC_OUTPUT_PULLUP_ON RTC_CR_TAMPALRM_PU 339 /** 340 * @} 341 */ 342 343 #if defined(RTC_CR_OUT2EN) 344 /** @defgroup RTC_Output_ALARM_OUT_Remap RTC Output ALARM OUT Remap 345 * @{ 346 */ 347 #define RTC_OUTPUT_REMAP_NONE 0x00000000u 348 #define RTC_OUTPUT_REMAP_POS1 RTC_CR_OUT2EN 349 /** 350 * @} 351 */ 352 #endif /* RTC_CR_OUT2EN */ 353 354 /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions 355 * @{ 356 */ 357 #define RTC_HOURFORMAT12_AM 0x0u 358 #define RTC_HOURFORMAT12_PM 0x1u 359 /** 360 * @} 361 */ 362 363 /** @defgroup RTC_DayLightSaving_Definitions RTC DayLightSaving Definitions 364 * @{ 365 */ 366 #define RTC_DAYLIGHTSAVING_SUB1H RTC_CR_SUB1H 367 #define RTC_DAYLIGHTSAVING_ADD1H RTC_CR_ADD1H 368 #define RTC_DAYLIGHTSAVING_NONE 0x00000000u 369 /** 370 * @} 371 */ 372 373 /** @defgroup RTC_StoreOperation_Definitions RTC StoreOperation Definitions 374 * @{ 375 */ 376 #define RTC_STOREOPERATION_RESET 0x00000000u 377 #define RTC_STOREOPERATION_SET RTC_CR_BKP 378 /** 379 * @} 380 */ 381 382 /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions 383 * @{ 384 */ 385 #define RTC_FORMAT_BIN 0x00000000u 386 #define RTC_FORMAT_BCD 0x00000001u 387 /** 388 * @} 389 */ 390 391 /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions 392 * @{ 393 */ 394 395 /* Coded in BCD format */ 396 #define RTC_MONTH_JANUARY ((uint8_t)0x01U) 397 #define RTC_MONTH_FEBRUARY ((uint8_t)0x02U) 398 #define RTC_MONTH_MARCH ((uint8_t)0x03U) 399 #define RTC_MONTH_APRIL ((uint8_t)0x04U) 400 #define RTC_MONTH_MAY ((uint8_t)0x05U) 401 #define RTC_MONTH_JUNE ((uint8_t)0x06U) 402 #define RTC_MONTH_JULY ((uint8_t)0x07U) 403 #define RTC_MONTH_AUGUST ((uint8_t)0x08U) 404 #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09U) 405 #define RTC_MONTH_OCTOBER ((uint8_t)0x10U) 406 #define RTC_MONTH_NOVEMBER ((uint8_t)0x11U) 407 #define RTC_MONTH_DECEMBER ((uint8_t)0x12U) 408 409 /** 410 * @} 411 */ 412 413 /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions 414 * @{ 415 */ 416 #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01U) 417 #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02U) 418 #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03U) 419 #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04U) 420 #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05U) 421 #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06U) 422 #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07U) 423 424 /** 425 * @} 426 */ 427 428 /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC AlarmDateWeekDay Definitions 429 * @{ 430 */ 431 #define RTC_ALARMDATEWEEKDAYSEL_DATE 0x00000000u 432 #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL 433 434 /** 435 * @} 436 */ 437 438 /** @defgroup RTC_AlarmMask_Definitions RTC AlarmMask Definitions 439 * @{ 440 */ 441 #define RTC_ALARMMASK_NONE 0x00000000u 442 #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4 443 #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3 444 #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2 445 #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1 446 #define RTC_ALARMMASK_ALL (RTC_ALARMMASK_DATEWEEKDAY | RTC_ALARMMASK_HOURS | \ 447 RTC_ALARMMASK_MINUTES | RTC_ALARMMASK_SECONDS) 448 449 /** 450 * @} 451 */ 452 453 /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions 454 * @{ 455 */ 456 #define RTC_ALARM_A RTC_CR_ALRAE 457 #define RTC_ALARM_B RTC_CR_ALRBE 458 459 /** 460 * @} 461 */ 462 /** @defgroup RTC_ALARM_Flag_AutoClear_Definitions RTC Alarms Flag Auto Clear Definitions 463 * @{ 464 */ 465 #define ALARM_FLAG_AUTOCLR_ENABLE 0x00000001u 466 #define ALARM_FLAG_AUTOCLR_DISABLE 0x00000000u 467 /** 468 * @} 469 */ 470 471 /** @defgroup RTC_Alarm_Sub_Seconds_BCD_Masks_Definitions RTC Alarm Sub Seconds BCD Masks Definitions 472 * In BCD mode (BIN=00) the overflow bits of the synchronous counter (bits 31:15) are never compared. 473 * @{ 474 */ 475 #define RTC_ALARMSUBSECONDMASK_ALL 0x00000000u /*!< All Alarm SS fields are masked. There is no comparison on sub seconds for Alarm */ 476 #define RTC_ALARMSUBSECONDMASK_SS14_1 RTC_ALRMASSR_MASKSS_0 /*!< SS[14:1] not used in Alarmcomparison. Only SS[0] is compared */ 477 #define RTC_ALARMSUBSECONDMASK_SS14_2 RTC_ALRMASSR_MASKSS_1 /*!< SS[14:2] not used in Alarm comparison. Only SS[1:0] are compared */ 478 #define RTC_ALARMSUBSECONDMASK_SS14_3 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1) /*!< SS[14:3] not used in Alarm comparison. Only SS[2:0] are compared */ 479 #define RTC_ALARMSUBSECONDMASK_SS14_4 RTC_ALRMASSR_MASKSS_2 /*!< SS[14:4] not used in Alarm comparison. Only SS[3:0] are compared */ 480 #define RTC_ALARMSUBSECONDMASK_SS14_5 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2) /*!< SS[14:5] not used in Alarm comparison. Only SS[4:0] are compared */ 481 #define RTC_ALARMSUBSECONDMASK_SS14_6 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2) /*!< SS[14:6] not used in Alarm comparison. Only SS[5:0] are compared */ 482 #define RTC_ALARMSUBSECONDMASK_SS14_7 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2) /*!< SS[14:7] not used in Alarm comparison. Only SS[6:0] are compared */ 483 #define RTC_ALARMSUBSECONDMASK_SS14_8 RTC_ALRMASSR_MASKSS_3 /*!< SS[14:8] not used in Alarm comparison. Only SS[7:0] are compared */ 484 #define RTC_ALARMSUBSECONDMASK_SS14_9 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_3) /*!< SS[14:9] not used in Alarm comparison. Only SS[8:0] are compared */ 485 #define RTC_ALARMSUBSECONDMASK_SS14_10 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3) /*!< SS[14:10] not used in Alarm comparison. Only SS[9:0] are compared */ 486 #define RTC_ALARMSUBSECONDMASK_SS14_11 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3) /*!< SS[14:11] not used in Alarm comparison. Only SS[10:0] are compared */ 487 #define RTC_ALARMSUBSECONDMASK_SS14_12 (RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3) /*!< SS[14:12] not used in Alarm comparison.Only SS[11:0] are compared */ 488 #define RTC_ALARMSUBSECONDMASK_SS14_13 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3) /*!< SS[14:13] not used in Alarm comparison. Only SS[12:0] are compared */ 489 #define RTC_ALARMSUBSECONDMASK_SS14 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3) /*!< SS[14] not used in Alarm comparison. Only SS[13:0] are compared */ 490 #define RTC_ALARMSUBSECONDMASK_NONE RTC_ALRMASSR_MASKSS /*!< SS[14:0] are compared and must match to activate alarm */ 491 /** 492 * @} 493 */ 494 495 /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions 496 * @{ 497 */ 498 #define RTC_IT_TS RTC_CR_TSIE /*!< Enable Timestamp Interrupt */ 499 #define RTC_IT_WUT RTC_CR_WUTIE /*!< Enable Wakeup timer Interrupt */ 500 #define RTC_IT_SSRU RTC_CR_SSRUIE /*!< Enable SSR Underflow Interrupt */ 501 #define RTC_IT_ALRA RTC_CR_ALRAIE /*!< Enable Alarm A Interrupt */ 502 #define RTC_IT_ALRB RTC_CR_ALRBIE /*!< Enable Alarm B Interrupt */ 503 /** 504 * @} 505 */ 506 507 /** @defgroup RTC_Flag_Mask RTC Flag Mask (5bits) describe in RTC_Flags_Definitions 508 * @{ 509 */ 510 #define RTC_FLAG_MASK 0x001Fu /*!< RTC flags mask (5bits) */ 511 /** 512 * @} 513 */ 514 515 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions 516 * Elements values convention: 000000XX000YYYYYb 517 * - YYYYY : Interrupt flag position in the XX register (5bits) 518 * - XX : Interrupt status register (2bits) 519 * - 01: ICSR register 520 * - 10: SR or SCR or MISR or SMISR registers 521 * @{ 522 */ 523 #define RTC_FLAG_RECALPF (0x00000100U | RTC_ICSR_RECALPF_Pos) /*!< Recalibration pending flag */ 524 #define RTC_FLAG_INITF (0x00000100U | RTC_ICSR_INITF_Pos) /*!< Initialization flag */ 525 #define RTC_FLAG_RSF (0x00000100U | RTC_ICSR_RSF_Pos) /*!< Registers synchronization flag */ 526 #define RTC_FLAG_INITS (0x00000100U | RTC_ICSR_INITS_Pos) /*!< Initialization status flag */ 527 #define RTC_FLAG_SHPF (0x00000100U | RTC_ICSR_SHPF_Pos) /*!< Shift operation pending flag */ 528 #define RTC_FLAG_WUTWF (0x00000100U | RTC_ICSR_WUTWF_Pos) /*!< Wakeup timer write flag */ 529 #define RTC_FLAG_SSRUF (0x00000200U | RTC_SR_SSRUF_Pos) /*!< Clear SSR underflow flag */ 530 #define RTC_FLAG_ITSF (0x00000200U | RTC_SR_ITSF_Pos) /*!< Clear Internal Time-stamp flag */ 531 #define RTC_FLAG_TSOVF (0x00000200U | RTC_SR_TSOVF_Pos) /*!< Clear Time-stamp overflow flag */ 532 #define RTC_FLAG_TSF (0x00000200U | RTC_SR_TSF_Pos) /*!< Clear Time-stamp flag */ 533 #define RTC_FLAG_WUTF (0x00000200U | RTC_SR_WUTF_Pos) /*!< Clear Wakeup timer flag */ 534 #define RTC_FLAG_ALRBF (0x00000200U | RTC_SR_ALRBF_Pos) /*!< Clear Alarm B flag */ 535 #define RTC_FLAG_ALRAF (0x00000200U | RTC_SR_ALRAF_Pos) /*!< Clear Alarm A flag */ 536 /** 537 * @} 538 */ 539 540 /** @defgroup RTC_Clear_Flags_Definitions RTC Clear Flags Definitions 541 * @{ 542 */ 543 #define RTC_CLEAR_SSRUF RTC_SCR_CSSRUF /*!< Clear SSR underflow flag */ 544 #define RTC_CLEAR_ITSF RTC_SCR_CITSF /*!< Clear Internal Time-stamp flag */ 545 #define RTC_CLEAR_TSOVF RTC_SCR_CTSOVF /*!< Clear Time-stamp overflow flag */ 546 #define RTC_CLEAR_TSF RTC_SCR_CTSF /*!< Clear Time-stamp flag */ 547 #define RTC_CLEAR_WUTF RTC_SCR_CWUTF /*!< Clear Wakeup timer flag */ 548 #define RTC_CLEAR_ALRBF RTC_SCR_CALRBF /*!< Clear Alarm B flag */ 549 #define RTC_CLEAR_ALRAF RTC_SCR_CALRAF /*!< Clear Alarm A flag */ 550 /** 551 * @} 552 */ 553 554 /** 555 * @} 556 */ 557 558 /* Exported macros -----------------------------------------------------------*/ 559 /** @defgroup RTC_Exported_Macros RTC Exported Macros 560 * @{ 561 */ 562 563 /** @brief Reset RTC handle state 564 * @param __HANDLE__ RTC handle. 565 * @retval None 566 */ 567 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) 568 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{\ 569 (__HANDLE__)->State = HAL_RTC_STATE_RESET;\ 570 (__HANDLE__)->MspInitCallback = NULL;\ 571 (__HANDLE__)->MspDeInitCallback = NULL;\ 572 }while(0) 573 #else 574 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET) 575 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ 576 577 /** 578 * @brief Disable the write protection for RTC registers. 579 * @param __HANDLE__ specifies the RTC handle. 580 * @retval None 581 */ 582 #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \ 583 do{ \ 584 RTC->WPR = 0xCAU; \ 585 RTC->WPR = 0x53U; \ 586 } while(0U) 587 588 /** 589 * @brief Enable the write protection for RTC registers. 590 * @param __HANDLE__ specifies the RTC handle. 591 * @retval None 592 */ 593 #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \ 594 do{ \ 595 RTC->WPR = 0xFFU; \ 596 } while(0U) 597 598 /** 599 * @brief Add 1 hour (summer time change). 600 * @note This interface is deprecated. 601 * To manage Daylight Saving Time, please use HAL_RTC_DST_xxx functions 602 * @param __HANDLE__ specifies the RTC handle. 603 * @param __BKP__ Backup 604 * This parameter can be: 605 * @arg @ref RTC_STOREOPERATION_RESET 606 * @arg @ref RTC_STOREOPERATION_SET 607 * @retval None 608 */ 609 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_ADD1H(__HANDLE__, __BKP__) \ 610 do { \ 611 __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__); \ 612 SET_BIT(RTC->CR, RTC_CR_ADD1H); \ 613 MODIFY_REG(RTC->CR, RTC_CR_BKP , (__BKP__)); \ 614 __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__); \ 615 } while(0); 616 617 /** 618 * @brief Subtract 1 hour (winter time change). 619 * @note This interface is deprecated. 620 * To manage Daylight Saving Time, please use HAL_RTC_DST_xxx functions 621 * @param __HANDLE__ specifies the RTC handle. 622 * @param __BKP__ Backup 623 * This parameter can be: 624 * @arg @ref RTC_STOREOPERATION_RESET 625 * @arg @ref RTC_STOREOPERATION_SET 626 * @retval None 627 */ 628 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_SUB1H(__HANDLE__, __BKP__) \ 629 do { \ 630 __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__); \ 631 SET_BIT(RTC->CR, RTC_CR_SUB1H); \ 632 MODIFY_REG(RTC->CR, RTC_CR_BKP , (__BKP__)); \ 633 __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__); \ 634 } while(0); 635 636 /** 637 * @brief Enable the RTC ALARMA peripheral. 638 * @param __HANDLE__ specifies the RTC handle. 639 * @retval None 640 */ 641 #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_ALRAE)) 642 643 /** 644 * @brief Disable the RTC ALARMA peripheral. 645 * @param __HANDLE__ specifies the RTC handle. 646 * @retval None 647 */ 648 #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_ALRAE)) 649 650 /** 651 * @brief Enable the RTC ALARMB peripheral. 652 * @param __HANDLE__ specifies the RTC handle. 653 * @retval None 654 */ 655 #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_ALRBE)) 656 657 /** 658 * @brief Disable the RTC ALARMB peripheral. 659 * @param __HANDLE__ specifies the RTC handle. 660 * @retval None 661 */ 662 #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_ALRBE)) 663 664 /** 665 * @brief Enable the RTC Alarm interrupt. 666 * @param __HANDLE__ specifies the RTC handle. 667 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled. 668 * This parameter can be any combination of the following values: 669 * @arg @ref RTC_IT_ALRA Alarm A interrupt 670 * @arg @ref RTC_IT_ALRB Alarm B interrupt 671 * @retval None 672 */ 673 #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR |= (__INTERRUPT__)) 674 675 /** 676 * @brief Disable the RTC Alarm interrupt. 677 * @param __HANDLE__ specifies the RTC handle. 678 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled. 679 * This parameter can be any combination of the following values: 680 * @arg @ref RTC_IT_ALRA Alarm A interrupt 681 * @arg @ref RTC_IT_ALRB Alarm B interrupt 682 * @retval None 683 */ 684 #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR &= ~(__INTERRUPT__)) 685 686 /** 687 * @brief Check whether the specified RTC Alarm interrupt has occurred or not. 688 * @param __HANDLE__ specifies the RTC handle. 689 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check. 690 * This parameter can be: 691 * @arg @ref RTC_IT_ALRA Alarm A interrupt 692 * @arg @ref RTC_IT_ALRB Alarm B interrupt 693 * @retval None 694 */ 695 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) ((((RTC->MISR)& ((__INTERRUPT__)>> 12U)) != 0U) \ 696 ? 1UL : 0UL) 697 698 /** 699 * @brief Check whether the specified RTC Alarm interrupt has been enabled or not. 700 * @param __HANDLE__ specifies the RTC handle. 701 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check. 702 * This parameter can be: 703 * @arg @ref RTC_IT_ALRA Alarm A interrupt 704 * @arg @ref RTC_IT_ALRB Alarm B interrupt 705 * @retval None 706 */ 707 #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((RTC->CR) & (__INTERRUPT__)) != 0U) \ 708 ? 1UL : 0UL) 709 710 /** 711 * @brief Get the selected RTC Alarms flag status. 712 * @param __HANDLE__ specifies the RTC handle. 713 * @param __FLAG__ specifies the RTC Alarm Flag sources to check. 714 * This parameter can be: 715 * @arg @ref RTC_FLAG_ALRAF 716 * @arg @ref RTC_FLAG_ALRBF 717 * @retval None 718 */ 719 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__))) 720 721 /** 722 * @brief Clear the RTC Alarms pending flags. 723 * @param __HANDLE__ specifies the RTC handle. 724 * @param __FLAG__ specifies the RTC Alarm Flag sources to clear. 725 * This parameter can be: 726 * @arg @ref RTC_FLAG_ALRAF 727 * @arg @ref RTC_FLAG_ALRBF 728 * @retval None 729 */ 730 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__FLAG__) == RTC_FLAG_ALRAF) \ 731 ? ((RTC->SCR = (RTC_CLEAR_ALRAF))) :\ 732 (RTC->SCR = (RTC_CLEAR_ALRBF))) 733 734 /** 735 * @brief Check whether if the RTC Calendar is initialized. 736 * @param __HANDLE__ specifies the RTC handle. 737 * @retval None 738 */ 739 #define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__) ((((RTC->ICSR) & (RTC_ICSR_INITS)) == RTC_ICSR_INITS) ? 1U : 0U) 740 741 /** 742 * @} 743 */ 744 745 /* Include RTC HAL Extended module */ 746 #include "stm32h5xx_hal_rtc_ex.h" 747 748 /* Exported functions --------------------------------------------------------*/ 749 /** @defgroup RTC_Exported_Functions RTC Exported Functions 750 * @{ 751 */ 752 753 /** @defgroup RTC_Exported_Functions_Group1 Initialization and de-initialization functions 754 * @{ 755 */ 756 /* Initialization and de-initialization functions ****************************/ 757 HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc); 758 HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc); 759 760 void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc); 761 void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc); 762 763 /* Callbacks Register/UnRegister functions ***********************************/ 764 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) 765 HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, 766 pRTC_CallbackTypeDef pCallback); 767 HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID); 768 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ 769 770 /** 771 * @} 772 */ 773 774 /** @defgroup RTC_Exported_Functions_Group2 RTC Time and Date functions 775 * @{ 776 */ 777 /* RTC Time and Date functions ************************************************/ 778 HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); 779 HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); 780 HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); 781 HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); 782 void HAL_RTC_DST_Add1Hour(RTC_HandleTypeDef *hrtc); 783 void HAL_RTC_DST_Sub1Hour(RTC_HandleTypeDef *hrtc); 784 void HAL_RTC_DST_SetStoreOperation(RTC_HandleTypeDef *hrtc); 785 void HAL_RTC_DST_ClearStoreOperation(RTC_HandleTypeDef *hrtc); 786 uint32_t HAL_RTC_DST_ReadStoreOperation(RTC_HandleTypeDef *hrtc); 787 /** 788 * @} 789 */ 790 791 /** @defgroup RTC_Exported_Functions_Group3 RTC Alarm functions 792 * @{ 793 */ 794 /* RTC Alarm functions ********************************************************/ 795 HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); 796 HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); 797 HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm); 798 HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format); 799 void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc); 800 HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 801 void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc); 802 803 /** 804 * @} 805 */ 806 807 /** @defgroup RTC_Exported_Functions_Group4 Peripheral Control functions 808 * @{ 809 */ 810 /* Peripheral Control functions ***********************************************/ 811 HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc); 812 /** 813 * @} 814 */ 815 816 /** @defgroup RTC_Exported_Functions_Group5 Peripheral State functions 817 * @{ 818 */ 819 /* Peripheral State functions *************************************************/ 820 HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc); 821 /** 822 * @} 823 */ 824 825 /** 826 * @} 827 */ 828 829 /* Private types -------------------------------------------------------------*/ 830 /* Private variables ---------------------------------------------------------*/ 831 /* Private constants ---------------------------------------------------------*/ 832 /** @defgroup RTC_Private_Constants RTC Private Constants 833 * @{ 834 */ 835 /* Masks Definition */ 836 #define RTC_TR_RESERVED_MASK (RTC_TR_PM | RTC_TR_HT | RTC_TR_HU | \ 837 RTC_TR_MNT | RTC_TR_MNU| RTC_TR_ST | \ 838 RTC_TR_SU) 839 #define RTC_DR_RESERVED_MASK (RTC_DR_YT | RTC_DR_YU | RTC_DR_WDU | \ 840 RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | \ 841 RTC_DR_DU) 842 #define RTC_INIT_MASK 0xFFFFFFFFu 843 #define RTC_RSF_MASK (~(RTC_ICSR_INIT | RTC_ICSR_RSF)) 844 845 #define RTC_TIMEOUT_VALUE 1000u 846 847 /** 848 * @} 849 */ 850 851 /* Private macros ------------------------------------------------------------*/ 852 /** @defgroup RTC_Private_Macros RTC Private Macros 853 * @{ 854 */ 855 856 /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters 857 * @{ 858 */ 859 #if defined(RTC_CR_OSEL) 860 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \ 861 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \ 862 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \ 863 ((OUTPUT) == RTC_OUTPUT_WAKEUP) || \ 864 ((OUTPUT) == RTC_OUTPUT_TAMPER)) 865 #endif /* RTC_CR_OSEL */ 866 867 #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \ 868 ((FORMAT) == RTC_HOURFORMAT_24)) 869 870 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \ 871 ((POL) == RTC_OUTPUT_POLARITY_LOW)) 872 873 #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \ 874 ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL)) 875 876 #define IS_RTC_OUTPUT_PULLUP(TYPE) (((TYPE) == RTC_OUTPUT_PULLUP_NONE) || \ 877 ((TYPE) == RTC_OUTPUT_PULLUP_ON)) 878 879 #if defined(RTC_CR_OUT2EN) 880 #define IS_RTC_OUTPUT_REMAP(REMAP) (((REMAP) == RTC_OUTPUT_REMAP_NONE) || \ 881 ((REMAP) == RTC_OUTPUT_REMAP_POS1)) 882 #endif /* RTC_CR_OUT2EN */ 883 884 #define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || \ 885 ((PM) == RTC_HOURFORMAT12_PM)) 886 887 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \ 888 ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \ 889 ((SAVE) == RTC_DAYLIGHTSAVING_NONE)) 890 891 #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \ 892 ((OPERATION) == RTC_STOREOPERATION_SET)) 893 894 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || \ 895 ((FORMAT) == RTC_FORMAT_BCD)) 896 897 #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99u) 898 899 #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1u) && ((MONTH) <= 12u)) 900 901 #define IS_RTC_DATE(DATE) (((DATE) >= 1u) && ((DATE) <= 31u)) 902 903 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ 904 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ 905 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ 906 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ 907 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ 908 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ 909 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) 910 911 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) >0u) && ((DATE) <= 31u)) 912 913 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ 914 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ 915 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ 916 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ 917 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ 918 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ 919 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) 920 921 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \ 922 ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY)) 923 924 #define IS_RTC_ALARM_MASK(MASK) (((MASK) & ~(RTC_ALARMMASK_ALL)) == 0UL) 925 926 #define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || \ 927 ((ALARM) == RTC_ALARM_B)) 928 929 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= RTC_ALRMASSR_SS) 930 931 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == 0UL) || \ 932 (((MASK) >= RTC_ALARMSUBSECONDMASK_SS14_1) && \ 933 ((MASK) <= RTC_ALARMSUBSECONDMASK_NONE))) 934 935 #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= (RTC_PRER_PREDIV_A >> RTC_PRER_PREDIV_A_Pos)) 936 937 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= (RTC_PRER_PREDIV_S >> RTC_PRER_PREDIV_S_Pos)) 938 939 #define IS_RTC_HOUR12(HOUR) (((HOUR) > 0u) && ((HOUR) <= 12u)) 940 941 #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23u) 942 943 #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59u) 944 945 #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59u) 946 947 /** 948 * @} 949 */ 950 951 /** 952 * @} 953 */ 954 955 /* Private functions -------------------------------------------------------------*/ 956 /** @defgroup RTC_Private_Functions RTC Private Functions 957 * @{ 958 */ 959 HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef *hrtc); 960 HAL_StatusTypeDef RTC_ExitInitMode(RTC_HandleTypeDef *hrtc); 961 uint8_t RTC_ByteToBcd2(uint8_t Value); 962 uint8_t RTC_Bcd2ToByte(uint8_t Value); 963 /** 964 * @} 965 */ 966 967 /** 968 * @} 969 */ 970 971 /** 972 * @} 973 */ 974 975 #ifdef __cplusplus 976 } 977 #endif 978 979 #endif /* STM32H5xx_HAL_RTC_H */ 980 981