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