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