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