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