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