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