1 /** 2 ****************************************************************************** 3 * @file stm32g4xx_hal_rtc_ex.h 4 * @author MCD Application Team 5 * @brief Header file of RTC HAL Extended 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 STM32G4xx_HAL_RTC_EX_H 21 #define STM32G4xx_HAL_RTC_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32g4xx_hal_def.h" 29 30 /** @addtogroup STM32G4xx_HAL_Driver 31 * @{ 32 */ 33 34 /** @defgroup RTCEx RTCEx 35 * @{ 36 */ 37 38 /* Exported types ------------------------------------------------------------*/ 39 /** @defgroup RTCEx_Exported_Types RTCEx Exported Types 40 * @{ 41 */ 42 43 /** @defgroup RTCEx_Tamper_structure_definition RTCEx Tamper structure definition 44 * @{ 45 */ 46 typedef struct 47 { 48 uint32_t Tamper; /*!< Specifies the Tamper Pin. 49 This parameter can be a value of @ref RTCEx_Tamper_Pins */ 50 51 uint32_t Trigger; /*!< Specifies the Tamper Trigger. 52 This parameter can be a value of @ref RTCEx_Tamper_Trigger */ 53 54 uint32_t NoErase; /*!< Specifies the Tamper no erase mode. 55 This parameter can be a value of @ref RTCEx_Tamper_EraseBackUp */ 56 57 uint32_t MaskFlag; /*!< Specifies the Tamper Flag masking. 58 This parameter can be a value of @ref RTCEx_Tamper_MaskFlag */ 59 60 uint32_t Filter; /*!< Specifies the TAMP Filter Tamper. 61 This parameter can be a value of @ref RTCEx_Tamper_Filter */ 62 63 uint32_t SamplingFrequency; /*!< Specifies the sampling frequency. 64 This parameter can be a value of @ref RTCEx_Tamper_Sampling_Frequencies */ 65 66 uint32_t PrechargeDuration; /*!< Specifies the Precharge Duration . 67 This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration */ 68 69 uint32_t TamperPullUp; /*!< Specifies the Tamper PullUp . 70 This parameter can be a value of @ref RTCEx_Tamper_Pull_UP */ 71 72 uint32_t TimeStampOnTamperDetection; /*!< Specifies the TimeStampOnTamperDetection. 73 This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection */ 74 } RTC_TamperTypeDef; 75 /** 76 * @} 77 */ 78 79 80 /** @defgroup RTCEx_Internal_Tamper_structure_definition RTCEx Internal Tamper structure definition 81 * @{ 82 */ 83 typedef struct 84 { 85 uint32_t IntTamper; /*!< Specifies the Internal Tamper Pin. 86 This parameter can be a value of @ref RTCEx_Internal_Tamper_Pins */ 87 88 uint32_t TimeStampOnTamperDetection; /*!< Specifies the TimeStampOnTamperDetection. 89 This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection */ 90 } RTC_InternalTamperTypeDef; 91 /** 92 * @} 93 */ 94 95 /** 96 * @} 97 */ 98 99 /* Exported constants --------------------------------------------------------*/ 100 /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants 101 * @{ 102 */ 103 104 /** @defgroup RTCEx_Time_Stamp_Edges_definitions RTCEx Time Stamp Edges definition 105 * @{ 106 */ 107 #define RTC_TIMESTAMPEDGE_RISING 0x00000000U 108 #define RTC_TIMESTAMPEDGE_FALLING RTC_CR_TSEDGE 109 /** 110 * @} 111 */ 112 113 /** @defgroup RTCEx_TimeStamp_Pin_Selections RTCEx TimeStamp Pin Selection 114 * @{ 115 */ 116 #define RTC_TIMESTAMPPIN_DEFAULT 0x00000000U 117 /** 118 * @} 119 */ 120 121 /** @defgroup RTCEx_Wakeup_Timer_Definitions RTCEx Wakeup Timer Definitions 122 * @{ 123 */ 124 #define RTC_WAKEUPCLOCK_RTCCLK_DIV16 0x00000000U 125 #define RTC_WAKEUPCLOCK_RTCCLK_DIV8 RTC_CR_WUCKSEL_0 126 #define RTC_WAKEUPCLOCK_RTCCLK_DIV4 RTC_CR_WUCKSEL_1 127 #define RTC_WAKEUPCLOCK_RTCCLK_DIV2 (RTC_CR_WUCKSEL_0 | RTC_CR_WUCKSEL_1) 128 #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS RTC_CR_WUCKSEL_2 129 #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_2) 130 /** 131 * @} 132 */ 133 134 /** @defgroup RTCEx_Smooth_calib_period_Definitions RTCEx Smooth calib period Definitions 135 * @{ 136 */ 137 #define RTC_SMOOTHCALIB_PERIOD_32SEC 0x00000000U /*!< If RTCCLK = 32768 Hz, Smooth calibration 138 period is 32s, else 2exp20 RTCCLK pulses */ 139 #define RTC_SMOOTHCALIB_PERIOD_16SEC RTC_CALR_CALW16 /*!< If RTCCLK = 32768 Hz, Smooth calibration 140 period is 16s, else 2exp19 RTCCLK pulses */ 141 #define RTC_SMOOTHCALIB_PERIOD_8SEC RTC_CALR_CALW8 /*!< If RTCCLK = 32768 Hz, Smooth calibration 142 period is 8s, else 2exp18 RTCCLK pulses */ 143 /** 144 * @} 145 */ 146 147 /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions RTCEx Smooth calib Plus pulses Definitions 148 * @{ 149 */ 150 #define RTC_SMOOTHCALIB_PLUSPULSES_SET RTC_CALR_CALP /*!< The number of RTCCLK pulses added 151 during a X -second window = Y - CALM[8:0] 152 with Y = 512, 256, 128 when X = 32, 16, 8 */ 153 #define RTC_SMOOTHCALIB_PLUSPULSES_RESET 0x00000000U /*!< The number of RTCCLK pulses subbstited 154 during a 32-second window = CALM[8:0] */ 155 156 /** 157 * @} 158 */ 159 160 /** @defgroup RTCEx_Calib_Output_selection_Definitions RTCEx Calib Output selection Definitions 161 * @{ 162 */ 163 #define RTC_CALIBOUTPUT_512HZ 0x00000000U 164 #define RTC_CALIBOUTPUT_1HZ RTC_CR_COSEL 165 166 /** 167 * @} 168 */ 169 170 171 /** @defgroup RTCEx_Add_1_Second_Parameter_Definition RTCEx Add 1 Second Parameter Definitions 172 * @{ 173 */ 174 #define RTC_SHIFTADD1S_RESET 0x00000000U 175 #define RTC_SHIFTADD1S_SET RTC_SHIFTR_ADD1S 176 /** 177 * @} 178 */ 179 180 /** @defgroup RTCEx_Tamper_Pins RTCEx Tamper Pins Definition 181 * @{ 182 */ 183 #define RTC_TAMPER_1 TAMP_CR1_TAMP1E 184 #define RTC_TAMPER_2 TAMP_CR1_TAMP2E 185 #if (RTC_TAMP_NB == 3) 186 #define RTC_TAMPER_3 TAMP_CR1_TAMP3E 187 #define RTC_TAMPER_ALL (RTC_TAMPER_1 | RTC_TAMPER_2 | RTC_TAMPER_3 ) 188 #elif (RTC_TAMP_NB == 8) 189 #define RTC_TAMPER_3 TAMP_CR1_TAMP3E 190 #define RTC_TAMPER_4 TAMP_CR1_TAMP4E 191 #define RTC_TAMPER_5 TAMP_CR1_TAMP5E 192 #define RTC_TAMPER_6 TAMP_CR1_TAMP6E 193 #define RTC_TAMPER_7 TAMP_CR1_TAMP7E 194 #define RTC_TAMPER_8 TAMP_CR1_TAMP8E 195 #define RTC_TAMPER_ALL (RTC_TAMPER_1 | RTC_TAMPER_2 |\ 196 RTC_TAMPER_3 | RTC_TAMPER_4 |\ 197 RTC_TAMPER_5 | RTC_TAMPER_6 |\ 198 RTC_TAMPER_7 | RTC_TAMPER_8 ) 199 #else 200 #define RTC_TAMPER_ALL (RTC_TAMPER_1 | RTC_TAMPER_2) 201 #endif /* RTC_TAMP_NB */ 202 /** 203 * @} 204 */ 205 206 /** @defgroup RTCEx_Internal_Tamper_Pins RTCEx Internal Tamper Pins Definition 207 * @{ 208 */ 209 #if defined (RTC_TAMP_INT_1_SUPPORT) 210 #define RTC_INT_TAMPER_1 TAMP_CR1_ITAMP1E 211 #else 212 #define RTC_INT_TAMPER_1 0U 213 #endif /* RTC_TAMP_INT_1_SUPPORT */ 214 #if defined (RTC_TAMP_INT_2_SUPPORT) 215 #define RTC_INT_TAMPER_2 TAMP_CR1_ITAMP2E 216 #else 217 #define RTC_INT_TAMPER_2 0U 218 #endif /* RTC_TAMP_INT_2_SUPPORT */ 219 #define RTC_INT_TAMPER_3 TAMP_CR1_ITAMP3E 220 #define RTC_INT_TAMPER_4 TAMP_CR1_ITAMP4E 221 #define RTC_INT_TAMPER_5 TAMP_CR1_ITAMP5E 222 #if defined (RTC_TAMP_INT_6_SUPPORT) 223 #define RTC_INT_TAMPER_6 TAMP_CR1_ITAMP6E 224 #else 225 #define RTC_INT_TAMPER_6 0U 226 #endif /* RTC_TAMP_INT_6_SUPPORT */ 227 #if defined (RTC_TAMP_INT_7_SUPPORT) 228 #define RTC_INT_TAMPER_7 TAMP_CR1_ITAMP7E 229 #else 230 #define RTC_INT_TAMPER_7 0U 231 #endif /* RTC_TAMP_INT_7_SUPPORT */ 232 #if defined (RTC_TAMP_INT_8_SUPPORT) 233 #define RTC_INT_TAMPER_8 TAMP_CR1_ITAMP8E 234 #else 235 #define RTC_INT_TAMPER_8 0U 236 #endif /* RTC_TAMP_INT_8_SUPPORT */ 237 238 #define RTC_INT_TAMPER_ALL ( RTC_INT_TAMPER_1 | RTC_INT_TAMPER_2 |\ 239 RTC_INT_TAMPER_3 | RTC_INT_TAMPER_4 |\ 240 RTC_INT_TAMPER_5 | RTC_INT_TAMPER_6 |\ 241 RTC_INT_TAMPER_7 | RTC_INT_TAMPER_8 ) 242 /** 243 * @} 244 */ 245 246 /** @defgroup RTCEx_Tamper_Trigger RTCEx Tamper Trigger 247 * @{ 248 */ 249 #define RTC_TAMPERTRIGGER_RISINGEDGE 0x00U /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */ 250 #define RTC_TAMPERTRIGGER_FALLINGEDGE 0x01U /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */ 251 #define RTC_TAMPERTRIGGER_LOWLEVEL 0x02U /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */ 252 #define RTC_TAMPERTRIGGER_HIGHLEVEL 0x03U /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */ 253 /** 254 * @} 255 */ 256 257 /** @defgroup RTCEx_Tamper_MaskFlag RTCEx Tamper MaskFlag 258 * @{ 259 */ 260 #define RTC_TAMPERMASK_FLAG_DISABLE 0x00U 261 #define RTC_TAMPERMASK_FLAG_ENABLE 0x01U 262 /** 263 * @} 264 */ 265 266 /** @defgroup RTCEx_Tamper_EraseBackUp RTCEx Tamper EraseBackUp 267 * @{ 268 */ 269 #define RTC_TAMPER_ERASE_BACKUP_ENABLE 0x00U 270 #define RTC_TAMPER_ERASE_BACKUP_DISABLE 0x01U 271 /** 272 * @} 273 */ 274 275 /** @defgroup RTCEx_Tamper_Filter RTCEx Tamper Filter 276 * @{ 277 */ 278 #define RTC_TAMPERFILTER_DISABLE 0x00000000U /*!< Tamper filter is disabled */ 279 #define RTC_TAMPERFILTER_2SAMPLE TAMP_FLTCR_TAMPFLT_0 /*!< Tamper is activated after 2 280 consecutive samples at the active level */ 281 #define RTC_TAMPERFILTER_4SAMPLE TAMP_FLTCR_TAMPFLT_1 /*!< Tamper is activated after 4 282 consecutive samples at the active level */ 283 #define RTC_TAMPERFILTER_8SAMPLE TAMP_FLTCR_TAMPFLT /*!< Tamper is activated after 8 284 consecutive samples at the active level */ 285 /** 286 * @} 287 */ 288 289 /** @defgroup RTCEx_Tamper_Sampling_Frequencies RTCEx Tamper Sampling Frequencies 290 * @{ 291 */ 292 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 0x00000000U /*!< Each of the tamper inputs are sampled 293 with a frequency = RTCCLK / 32768 */ 294 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 TAMP_FLTCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled 295 with a frequency = RTCCLK / 16384 */ 296 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 TAMP_FLTCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled 297 with a frequency = RTCCLK / 8192 */ 298 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled 299 with a frequency = RTCCLK / 4096 */ 300 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 TAMP_FLTCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled 301 with a frequency = RTCCLK / 2048 */ 302 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled 303 with a frequency = RTCCLK / 1024 */ 304 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 (TAMP_FLTCR_TAMPFREQ_1 | TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled 305 with a frequency = RTCCLK / 512 */ 306 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_1 | \ 307 TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled 308 with a frequency = RTCCLK / 256 */ 309 /** 310 * @} 311 */ 312 313 /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration RTCEx Tamper Pin Precharge Duration 314 * @{ 315 */ 316 #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK 0x00000000U /*!< Tamper pins are pre-charged before 317 sampling during 1 RTCCLK cycle */ 318 #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK TAMP_FLTCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before 319 sampling during 2 RTCCLK cycles */ 320 #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK TAMP_FLTCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before 321 sampling during 4 RTCCLK cycles */ 322 #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK (TAMP_FLTCR_TAMPPRCH_0 | TAMP_FLTCR_TAMPPRCH_1) /*!< Tamper pins are pre-charged before 323 sampling during 8 RTCCLK cycles */ 324 /** 325 * @} 326 */ 327 328 /** @defgroup RTCEx_Tamper_Pull_UP RTCEx Tamper Pull UP 329 * @{ 330 */ 331 #define RTC_TAMPER_PULLUP_ENABLE 0x00000000U /*!< Tamper pins are pre-charged before sampling */ 332 #define RTC_TAMPER_PULLUP_DISABLE TAMP_FLTCR_TAMPPUDIS /*!< Tamper pins pre-charge is disabled */ 333 /** 334 * @} 335 */ 336 337 /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection RTCEx Tamper TimeStamp On Tamper Detection 338 * @{ 339 */ 340 #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE 0x00000000U /*!< TimeStamp on Tamper Detection event is not saved */ 341 #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE RTC_CR_TAMPTS /*!< TimeStamp on Tamper Detection event saved */ 342 /** 343 * @} 344 */ 345 346 /** @defgroup RTCEx_Internal_Tamper_Interrupt RTCEx Internal Tamper Interrupt 347 * @{ 348 */ 349 #define RTC_IT_TAMP_1 TAMP_IER_TAMP1IE /*!< Tamper 1 Interrupt */ 350 #define RTC_IT_TAMP_2 TAMP_IER_TAMP2IE /*!< Tamper 2 Interrupt */ 351 #if (RTC_TAMP_NB == 3) 352 #define RTC_IT_TAMP_3 TAMP_IER_TAMP3IE /*!< Tamper 3 Interrupt */ 353 #define RTC_IT_TAMP_ALL (RTC_IT_TAMP_1 | RTC_IT_TAMP_2 | RTC_IT_TAMP_3 ) 354 #elif (RTC_TAMP_NB == 8) 355 #define RTC_IT_TAMP_3 TAMP_IER_TAMP3IE /*!< Tamper 3 Interrupt */ 356 #define RTC_IT_TAMP_4 TAMP_IER_TAMP4IE /*!< Tamper 4 Interrupt */ 357 #define RTC_IT_TAMP_5 TAMP_IER_TAMP5IE /*!< Tamper 5 Interrupt */ 358 #define RTC_IT_TAMP_6 TAMP_IER_TAMP6IE /*!< Tamper 6 Interrupt */ 359 #define RTC_IT_TAMP_7 TAMP_IER_TAMP7IE /*!< Tamper 7 Interrupt */ 360 #define RTC_IT_TAMP_8 TAMP_IER_TAMP8IE /*!< Tamper 8 Interrupt */ 361 #define RTC_IT_TAMP_ALL (RTC_IT_TAMP_1 | RTC_IT_TAMP_2 |\ 362 RTC_IT_TAMP_3 | RTC_IT_TAMP_4 |\ 363 RTC_IT_TAMP_5 | RTC_IT_TAMP_6 |\ 364 RTC_IT_TAMP_7 | RTC_IT_TAMP_8 ) 365 #else 366 #define RTC_IT_TAMP_ALL (RTC_IT_TAMP_1 | RTC_IT_TAMP_2) 367 #endif /* RTC_TAMP_NB */ 368 369 #if defined (RTC_TAMP_INT_1_SUPPORT) 370 #define RTC_IT_INT_TAMP_1 TAMP_IER_ITAMP1IE /*!< Tamper 1 internal Interrupt */ 371 #else 372 #define RTC_IT_INT_TAMP_1 0U 373 #endif /* RTC_TAMP_INT_1_SUPPORT */ 374 #if defined (RTC_TAMP_INT_2_SUPPORT) 375 #define RTC_IT_INT_TAMP_2 TAMP_IER_ITAMP2IE /*!< Tamper 2 internal Interrupt */ 376 #else 377 #define RTC_IT_INT_TAMP_2 0U 378 #endif /* RTC_TAMP_INT_2_SUPPORT */ 379 #define RTC_IT_INT_TAMP_3 TAMP_IER_ITAMP3IE /*!< Tamper 3 internal Interrupt */ 380 #define RTC_IT_INT_TAMP_4 TAMP_IER_ITAMP4IE /*!< Tamper 4 internal Interrupt */ 381 #define RTC_IT_INT_TAMP_5 TAMP_IER_ITAMP5IE /*!< Tamper 5 internal Interrupt */ 382 #if defined (RTC_TAMP_INT_6_SUPPORT) 383 #define RTC_IT_INT_TAMP_6 TAMP_IER_ITAMP6IE /*!< Tamper 6 internal Interrupt */ 384 #else 385 #define RTC_IT_INT_TAMP_6 0U 386 #endif /* RTC_TAMP_INT_6_SUPPORT */ 387 #if defined (RTC_TAMP_INT_7_SUPPORT) 388 #define RTC_IT_INT_TAMP_7 TAMP_IER_ITAMP7IE /*!< Tamper 7 internal Interrupt */ 389 #else 390 #define RTC_IT_INT_TAMP_7 0U 391 #endif /* RTC_TAMP_INT_7_SUPPORT */ 392 #if defined (RTC_TAMP_INT_8_SUPPORT) 393 #define RTC_IT_INT_TAMP_8 TAMP_IER_ITAMP8IE /*!< Tamper 8 internal Interrupt */ 394 #else 395 #define RTC_IT_INT_TAMP_8 0U 396 #endif /* RTC_TAMP_INT_8_SUPPORT */ 397 398 #define RTC_IT_INT_TAMP_ALL (RTC_IT_INT_TAMP_1 | RTC_IT_INT_TAMP_2 |\ 399 RTC_IT_INT_TAMP_3 | RTC_IT_INT_TAMP_4 |\ 400 RTC_IT_INT_TAMP_5 | RTC_IT_INT_TAMP_6 |\ 401 RTC_IT_INT_TAMP_7 | RTC_IT_INT_TAMP_8 ) 402 /** 403 * @} 404 */ 405 406 /** @defgroup RTCEx_Flags RTCEx Flags 407 * @{ 408 */ 409 410 #define RTC_FLAG_TAMP_1 TAMP_SR_TAMP1F 411 #define RTC_FLAG_TAMP_2 TAMP_SR_TAMP2F 412 #if (RTC_TAMP_NB == 3) 413 #define RTC_FLAG_TAMP_3 TAMP_SR_TAMP3F 414 #define RTC_FLAG_TAMP_ALL (RTC_FLAG_TAMP_1 | RTC_FLAG_TAMP_2 | RTC_FLAG_TAMP_3) 415 #elif (RTC_TAMP_NB == 8) 416 #define RTC_FLAG_TAMP_3 TAMP_SR_TAMP3F 417 #define RTC_FLAG_TAMP_4 TAMP_SR_TAMP4F 418 #define RTC_FLAG_TAMP_5 TAMP_SR_TAMP5F 419 #define RTC_FLAG_TAMP_6 TAMP_SR_TAMP6F 420 #define RTC_FLAG_TAMP_7 TAMP_SR_TAMP7F 421 #define RTC_FLAG_TAMP_8 TAMP_SR_TAMP8F 422 #define RTC_FLAG_TAMP_ALL (RTC_FLAG_TAMP_1 | RTC_FLAG_TAMP_2 | RTC_FLAG_TAMP_3 |\ 423 RTC_FLAG_TAMP_4 | RTC_FLAG_TAMP_5 |\ 424 RTC_FLAG_TAMP_6 | RTC_FLAG_TAMP_7 | RTC_FLAG_TAMP_8) 425 426 #else 427 #define RTC_FLAG_TAMP_ALL (RTC_FLAG_TAMP_1 | RTC_FLAG_TAMP_2) 428 #endif /* RTC_TAMP_NB */ 429 430 #if defined (RTC_TAMP_INT_1_SUPPORT) 431 #define RTC_FLAG_INT_TAMP_1 TAMP_SR_ITAMP1F /*!< Tamper 1 Interrupt flag */ 432 #else 433 #define RTC_FLAG_INT_TAMP_1 0U 434 #endif /* RTC_TAMP_INT_1_SUPPORT */ 435 #if defined (RTC_TAMP_INT_2_SUPPORT) 436 #define RTC_FLAG_INT_TAMP_2 TAMP_SR_ITAMP2F /*!< Tamper 2 Interrupt flag */ 437 #else 438 #define RTC_FLAG_INT_TAMP_2 0U 439 #endif /* RTC_TAMP_INT_2_SUPPORT */ 440 #define RTC_FLAG_INT_TAMP_3 TAMP_SR_ITAMP3F /*!< Tamper 3 Interrupt flag */ 441 #define RTC_FLAG_INT_TAMP_4 TAMP_SR_ITAMP4F /*!< Tamper 4 Interrupt flag */ 442 #define RTC_FLAG_INT_TAMP_5 TAMP_SR_ITAMP5F /*!< Tamper 5 Interrupt flag */ 443 #if defined (RTC_TAMP_INT_6_SUPPORT) 444 #define RTC_FLAG_INT_TAMP_6 TAMP_SR_ITAMP6F /*!< Tamper 6 Interrupt flag */ 445 #else 446 #define RTC_FLAG_INT_TAMP_6 0U 447 #endif /* RTC_TAMP_INT_6_SUPPORT */ 448 #if defined (RTC_TAMP_INT_7_SUPPORT) 449 #define RTC_FLAG_INT_TAMP_7 TAMP_SR_ITAMP7F /*!< Tamper 7 Interrupt flag */ 450 #else 451 #define RTC_FLAG_INT_TAMP_7 0U 452 #endif /* RTC_TAMP_INT_7_SUPPORT */ 453 #if defined (RTC_TAMP_INT_8_SUPPORT) 454 #define RTC_FLAG_INT_TAMP_8 TAMP_SR_ITAMP8F /*!< Tamper 8 Interrupt flag */ 455 #else 456 #define RTC_FLAG_INT_TAMP_8 0U 457 #endif /* RTC_TAMP_INT_8_SUPPORT */ 458 #define RTC_FLAG_INT_TAMP_ALL (RTC_FLAG_INT_TAMP_1 | RTC_FLAG_INT_TAMP_2 |\ 459 RTC_FLAG_INT_TAMP_3 | RTC_FLAG_INT_TAMP_4 |\ 460 RTC_FLAG_INT_TAMP_5 | RTC_FLAG_INT_TAMP_6 |\ 461 RTC_FLAG_INT_TAMP_7 | RTC_FLAG_INT_TAMP_8) 462 /** 463 * @} 464 */ 465 466 467 /** @defgroup RTCEx_Backup_Registers RTCEx Backup Registers Definition 468 * @{ 469 */ 470 #define RTC_BKP_NUMBER RTC_BACKUP_NB 471 #if (RTC_BACKUP_NB == 5) 472 #define RTC_BKP_DR0 0x00000000U 473 #define RTC_BKP_DR1 0x00000001U 474 #define RTC_BKP_DR2 0x00000002U 475 #define RTC_BKP_DR3 0x00000003U 476 #define RTC_BKP_DR4 0x00000004U 477 #elif (RTC_BACKUP_NB == 16) 478 #define RTC_BKP_DR0 0x00U 479 #define RTC_BKP_DR1 0x01U 480 #define RTC_BKP_DR2 0x02U 481 #define RTC_BKP_DR3 0x03U 482 #define RTC_BKP_DR4 0x04U 483 #define RTC_BKP_DR5 0x05U 484 #define RTC_BKP_DR6 0x06U 485 #define RTC_BKP_DR7 0x07U 486 #define RTC_BKP_DR8 0x08U 487 #define RTC_BKP_DR9 0x09U 488 #define RTC_BKP_DR10 0x0AU 489 #define RTC_BKP_DR11 0x0BU 490 #define RTC_BKP_DR12 0x0CU 491 #define RTC_BKP_DR13 0x0DU 492 #define RTC_BKP_DR14 0x0EU 493 #define RTC_BKP_DR15 0x0FU 494 #elif (RTC_BACKUP_NB == 32) 495 #define RTC_BKP_DR0 0x00U 496 #define RTC_BKP_DR1 0x01U 497 #define RTC_BKP_DR2 0x02U 498 #define RTC_BKP_DR3 0x03U 499 #define RTC_BKP_DR4 0x04U 500 #define RTC_BKP_DR5 0x05U 501 #define RTC_BKP_DR6 0x06U 502 #define RTC_BKP_DR7 0x07U 503 #define RTC_BKP_DR8 0x08U 504 #define RTC_BKP_DR9 0x09U 505 #define RTC_BKP_DR10 0x0AU 506 #define RTC_BKP_DR11 0x0BU 507 #define RTC_BKP_DR12 0x0CU 508 #define RTC_BKP_DR13 0x0DU 509 #define RTC_BKP_DR14 0x0EU 510 #define RTC_BKP_DR15 0x0FU 511 #define RTC_BKP_DR16 0x10U 512 #define RTC_BKP_DR17 0x11U 513 #define RTC_BKP_DR18 0x12U 514 #define RTC_BKP_DR19 0x13U 515 #define RTC_BKP_DR20 0x14U 516 #define RTC_BKP_DR21 0x15U 517 #define RTC_BKP_DR22 0x16U 518 #define RTC_BKP_DR23 0x17U 519 #define RTC_BKP_DR24 0x18U 520 #define RTC_BKP_DR25 0x19U 521 #define RTC_BKP_DR26 0x1AU 522 #define RTC_BKP_DR27 0x1BU 523 #define RTC_BKP_DR28 0x1CU 524 #define RTC_BKP_DR29 0x1DU 525 #define RTC_BKP_DR30 0x1EU 526 #define RTC_BKP_DR31 0x1FU 527 #else 528 #error "no RTC Backup Registers Definition" 529 #endif /* RTC_BKP_NUMBER */ 530 /** 531 * @} 532 */ 533 534 /** 535 * @} 536 */ 537 538 /* Exported macros -----------------------------------------------------------*/ 539 /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros 540 * @{ 541 */ 542 543 /** @brief Clear the specified RTC pending flag. 544 * @param __HANDLE__ specifies the RTC Handle. 545 * @param __FLAG__ specifies the flag to check. 546 * This parameter can be any combination of the following values: 547 * @arg @ref RTC_CLEAR_ITSF Clear Internal Time-stamp flag 548 * @arg @ref RTC_CLEAR_TSOVF Clear Time-stamp overflow flag 549 * @arg @ref RTC_CLEAR_TSF Clear Time-stamp flag 550 * @arg @ref RTC_CLEAR_WUTF Clear Wakeup timer flag 551 * @arg @ref RTC_CLEAR_ALRBF Clear Alarm B flag 552 * @arg @ref RTC_CLEAR_ALRAF Clear Alarm A flag 553 * @retval None 554 */ 555 #define __HAL_RTC_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SCR = (__FLAG__)) 556 557 558 /** @brief Check whether the specified RTC flag is set or not. 559 * @param __HANDLE__ specifies the RTC Handle. 560 * @param __FLAG__ specifies the flag to check. 561 * This parameter can be any combination of the following values: 562 * @arg @ref RTC_FLAG_RECALPF Recalibration pending Flag 563 * @arg @ref RTC_FLAG_INITF Initialization flag 564 * @arg @ref RTC_FLAG_RSF Registers synchronization flag 565 * @arg @ref RTC_FLAG_INITS Initialization status flag 566 * @arg @ref RTC_FLAG_SHPF Shift operation pending flag 567 * @arg @ref RTC_FLAG_WUTWF Wakeup timer write flag 568 * @arg @ref RTC_FLAG_ALRBWF Alarm B write flag 569 * @arg @ref RTC_FLAG_ALRAWF Alarm A write flag 570 * @arg @ref RTC_FLAG_ITSF Internal Time-stamp flag 571 * @arg @ref RTC_FLAG_TSOVF Time-stamp overflow flag 572 * @arg @ref RTC_FLAG_TSF Time-stamp flag 573 * @arg @ref RTC_FLAG_WUTF Wakeup timer flag 574 * @arg @ref RTC_FLAG_ALRBF Alarm B flag 575 * @arg @ref RTC_FLAG_ALRAF Alarm A flag 576 * @retval None 577 */ 578 #define __HAL_RTC_GET_FLAG(__HANDLE__, __FLAG__) (((((__FLAG__)) >> 8U) == 1U) ? ((__HANDLE__)->Instance->ICSR & (1U << (((uint16_t)(__FLAG__)) & RTC_FLAG_MASK))) : \ 579 ((__HANDLE__)->Instance->SR & (1U << (((uint16_t)(__FLAG__)) & RTC_FLAG_MASK)))) 580 581 /* ---------------------------------WAKEUPTIMER---------------------------------*/ 582 /** @defgroup RTCEx_WakeUp_Timer RTC WakeUp Timer 583 * @{ 584 */ 585 /** 586 * @brief Enable the RTC WakeUp Timer peripheral. 587 * @param __HANDLE__ specifies the RTC handle. 588 * @retval None 589 */ 590 #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE)) 591 592 /** 593 * @brief Disable the RTC WakeUp Timer peripheral. 594 * @param __HANDLE__ specifies the RTC handle. 595 * @retval None 596 */ 597 #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE)) 598 599 /** 600 * @brief Enable the RTC WakeUpTimer interrupt. 601 * @param __HANDLE__ specifies the RTC handle. 602 * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be enabled. 603 * This parameter can be: 604 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 605 * @retval None 606 */ 607 #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) 608 609 /** 610 * @brief Disable the RTC WakeUpTimer interrupt. 611 * @param __HANDLE__ specifies the RTC handle. 612 * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be disabled. 613 * This parameter can be: 614 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 615 * @retval None 616 */ 617 #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) 618 619 620 /** 621 * @brief Check whether the specified RTC WakeUpTimer interrupt has occurred or not. 622 * @param __HANDLE__ specifies the RTC handle. 623 * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt to check. 624 * This parameter can be: 625 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 626 * @retval None 627 */ 628 #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->MISR)\ 629 & ((__INTERRUPT__)>> 12U)) != 0UL) ? 1UL : 0UL) 630 /** 631 * @brief Check whether the specified RTC Wake Up timer interrupt has been enabled or not. 632 * @param __HANDLE__ specifies the RTC handle. 633 * @param __INTERRUPT__ specifies the RTC Wake Up timer interrupt sources to check. 634 * This parameter can be: 635 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 636 * @retval None 637 */ 638 #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR)\ 639 & (__INTERRUPT__)) != 0UL) ? 1UL : 0UL) 640 641 /** 642 * @brief Get the selected RTC WakeUpTimers flag status. 643 * @param __HANDLE__ specifies the RTC handle. 644 * @param __FLAG__ specifies the RTC WakeUpTimer Flag is pending or not. 645 * This parameter can be: 646 * @arg @ref RTC_FLAG_WUTF 647 * @arg @ref RTC_FLAG_WUTWF 648 * @retval None 649 */ 650 #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__))) 651 652 /** 653 * @brief Clear the RTC Wake Up timers pending flags. 654 * @param __HANDLE__ specifies the RTC handle. 655 * @param __FLAG__ specifies the RTC WakeUpTimer Flag to clear. 656 * This parameter can be: 657 * @arg @ref RTC_FLAG_WUTF 658 * @retval None 659 */ 660 #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_WUTF)) 661 662 /* WAKE-UP TIMER EXTI */ 663 /* ------------------ */ 664 /** 665 * @brief Enable interrupt on the RTC WakeUp Timer associated Exti line. 666 * @retval None 667 */ 668 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 669 670 /** 671 * @brief Disable interrupt on the RTC WakeUp Timer associated Exti line. 672 * @retval None 673 */ 674 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT)) 675 676 /** 677 * @brief set the rising edge for interrupt on the RTC WakeUp Timer associated Exti line. 678 * @retval None 679 */ 680 #define __HAL_RTC_WAKEUPTIMER_EXTI_RISING_IT() (EXTI->RTSR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 681 682 /** 683 * @brief set the falling edge for interrupt on the RTC WakeUp Timer associated Exti line. 684 * @retval None 685 */ 686 #define __HAL_RTC_WAKEUPTIMER_EXTI_FALLING_IT() (EXTI->FTSR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 687 688 /** 689 * @brief Clear the interrupt on the RTC WakeUp Timer associated Exti line. 690 * @retval None 691 */ 692 #define __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_IT() (EXTI->PR1 = RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 693 694 /** 695 * @brief Clear the interrupt on the RTC WakeUp Timer associated Exti line. 696 * @retval None 697 */ 698 #define __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI->PR1 = RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 699 700 /** 701 * @brief Enable event on the RTC WakeUp Timer associated Exti line. 702 * @retval None. 703 */ 704 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 705 706 /** 707 * @brief Disable event on the RTC WakeUp Timer associated Exti line. 708 * @retval None. 709 */ 710 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT)) 711 712 /** 713 * @} 714 */ 715 716 /* ---------------------------------TIMESTAMP---------------------------------*/ 717 /** @defgroup RTCEx_Timestamp RTC Timestamp 718 * @{ 719 */ 720 /** 721 * @brief Enable the RTC TimeStamp peripheral. 722 * @param __HANDLE__ specifies the RTC handle. 723 * @retval None 724 */ 725 #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE)) 726 727 /** 728 * @brief Disable the RTC TimeStamp peripheral. 729 * @param __HANDLE__ specifies the RTC handle. 730 * @retval None 731 */ 732 #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE)) 733 734 /** 735 * @brief Enable the RTC TimeStamp interrupt. 736 * @param __HANDLE__ specifies the RTC handle. 737 * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be enabled. 738 * This parameter can be: 739 * @arg @ref RTC_IT_TS TimeStamp interrupt 740 * @retval None 741 */ 742 #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) 743 744 /** 745 * @brief Disable the RTC TimeStamp interrupt. 746 * @param __HANDLE__ specifies the RTC handle. 747 * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be disabled. 748 * This parameter can be: 749 * @arg @ref RTC_IT_TS TimeStamp interrupt 750 * @retval None 751 */ 752 #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) 753 754 /** 755 * @brief Check whether the specified RTC TimeStamp interrupt has occurred or not. 756 * @param __HANDLE__ specifies the RTC handle. 757 * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt to check. 758 * This parameter can be: 759 * @arg @ref RTC_IT_TS TimeStamp interrupt 760 * @retval None 761 */ 762 #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->MISR)\ 763 & ((__INTERRUPT__)>> 12U)) != 0U) ? 1UL : 0UL) 764 /** 765 * @brief Check whether the specified RTC Time Stamp interrupt has been enabled or not. 766 * @param __HANDLE__ specifies the RTC handle. 767 * @param __INTERRUPT__ specifies the RTC Time Stamp interrupt source to check. 768 * This parameter can be: 769 * @arg @ref RTC_IT_TS TimeStamp interrupt 770 * @retval None 771 */ 772 #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR)\ 773 & (__INTERRUPT__)) != 0U) ? 1UL : 0UL) 774 775 /** 776 * @brief Get the selected RTC TimeStamps flag status. 777 * @param __HANDLE__ specifies the RTC handle. 778 * @param __FLAG__ specifies the RTC TimeStamp Flag is pending or not. 779 * This parameter can be: 780 * @arg @ref RTC_FLAG_TSF 781 * @arg @ref RTC_FLAG_TSOVF 782 * @retval None 783 */ 784 #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__),(__FLAG__))) 785 786 /** 787 * @brief Clear the RTC Time Stamps pending flags. 788 * @param __HANDLE__ specifies the RTC handle. 789 * @param __FLAG__ specifies the RTC TimeStamp Flag to clear. 790 * This parameter can be: 791 * @arg @ref RTC_FLAG_TSF 792 * @arg @ref RTC_FLAG_TSOVF 793 * @retval None 794 */ 795 #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_CLEAR_FLAG((__HANDLE__), (__FLAG__))) 796 797 /* TIMESTAMP TIMER EXTI */ 798 /* -------------------- */ 799 800 /** 801 * @brief Enable interrupt on the RTC Timestamp associated Exti line. 802 * @retval None 803 */ 804 #define __HAL_RTC_TIMESTAMP_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_TIMESTAMP_EVENT) 805 806 /** 807 * @brief Disable interrupt on the RTC Timestamp associated Exti line. 808 * @retval None 809 */ 810 #define __HAL_RTC_TIMESTAMP_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_TIMESTAMP_EVENT)) 811 812 /** 813 * @brief set the rising edge for interrupt on the RTC WakeUp Timer associated Exti line. 814 * @retval None 815 */ 816 #define __HAL_RTC_TIMESTAMP_EXTI_RISING_IT() (EXTI->RTSR1 |= RTC_EXTI_LINE_TIMESTAMP_EVENT) 817 818 /** 819 * @brief set the falling edge for interrupt on the RTC WakeUp Timer associated Exti line. 820 * @retval None 821 */ 822 #define __HAL_RTC_TIMESTAMP_EXTI_FALLING_IT() (EXTI->FSTR1 |= RTC_EXTI_LINE_TIMESTAMP_EVENT) 823 824 /** 825 * @brief Clear the interrupt on the RTC WakeUp Timer associated Exti line. 826 * @retval None 827 */ 828 #define __HAL_RTC_TIMESTAMP_EXTI_CLEAR_IT() (EXTI->PR1 = RTC_EXTI_LINE_TIMESTAMP_EVENT) 829 830 /** 831 * @brief Clear the interrupt on the RTC Timestamp associated Exti line. 832 * @retval None 833 */ 834 #define __HAL_RTC_TIMESTAMP_EXTI_CLEAR_FLAG() (EXTI->PR1 = RTC_EXTI_LINE_TIMESTAMP_EVENT) 835 836 /** 837 * @brief Enable event on the RTC Timestamp associated Exti line. 838 * @retval None 839 */ 840 #define __HAL_RTC_TIMESTAMP_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_TIMESTAMP_EVENT) 841 842 /** 843 * @brief Disable event on the RTC Timestamp associated Exti line. 844 * @retval None 845 */ 846 #define __HAL_RTC_TIMESTAMP_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_TIMESTAMP_EVENT)) 847 848 /** 849 * @brief Enable the RTC internal TimeStamp peripheral. 850 * @param __HANDLE__ specifies the RTC handle. 851 * @retval None 852 */ 853 #define __HAL_RTC_INTERNAL_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ITSE)) 854 855 /** 856 * @brief Disable the RTC internal TimeStamp peripheral. 857 * @param __HANDLE__ specifies the RTC handle. 858 * @retval None 859 */ 860 #define __HAL_RTC_INTERNAL_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ITSE)) 861 862 /** 863 * @brief Get the selected RTC Internal Time Stamps flag status. 864 * @param __HANDLE__ specifies the RTC handle. 865 * @param __FLAG__ specifies the RTC Internal Time Stamp Flag is pending or not. 866 * This parameter can be: 867 * @arg @ref RTC_FLAG_ITSF 868 * @retval None 869 */ 870 #define __HAL_RTC_INTERNAL_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__),(__FLAG__))) 871 872 /** 873 * @brief Clear the RTC Internal Time Stamps pending flags. 874 * @param __HANDLE__ specifies the RTC handle. 875 * @param __FLAG__ specifies the RTC Internal Time Stamp Flag source to clear. 876 * This parameter can be: 877 * @arg @ref RTC_FLAG_ITSF 878 * @retval None 879 */ 880 #define __HAL_RTC_INTERNAL_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_ITSF)) 881 882 /** 883 * @brief Enable the RTC TimeStamp on Tamper detection. 884 * @param __HANDLE__ specifies the RTC handle. 885 * @retval None 886 */ 887 #define __HAL_RTC_TAMPTS_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TAMPTS)) 888 889 /** 890 * @brief Disable the RTC TimeStamp on Tamper detection. 891 * @param __HANDLE__ specifies the RTC handle. 892 * @retval None 893 */ 894 #define __HAL_RTC_TAMPTS_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TAMPTS)) 895 896 /** 897 * @brief Enable the RTC Tamper detection output. 898 * @param __HANDLE__ specifies the RTC handle. 899 * @retval None 900 */ 901 #define __HAL_RTC_TAMPOE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TAMPOE)) 902 903 /** 904 * @brief Disable the RTC Tamper detection output. 905 * @param __HANDLE__ specifies the RTC handle. 906 * @retval None 907 */ 908 #define __HAL_RTC_TAMPOE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TAMPOE)) 909 910 911 /** 912 * @} 913 */ 914 915 916 /* ------------------------------Calibration----------------------------------*/ 917 /** @defgroup RTCEx_Calibration RTC Calibration 918 * @{ 919 */ 920 921 /** 922 * @brief Enable the RTC calibration output. 923 * @param __HANDLE__ specifies the RTC handle. 924 * @retval None 925 */ 926 #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_COE)) 927 928 /** 929 * @brief Disable the calibration output. 930 * @param __HANDLE__ specifies the RTC handle. 931 * @retval None 932 */ 933 #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE)) 934 935 936 /** 937 * @brief Enable the clock reference detection. 938 * @param __HANDLE__ specifies the RTC handle. 939 * @retval None 940 */ 941 #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON)) 942 943 /** 944 * @brief Disable the clock reference detection. 945 * @param __HANDLE__ specifies the RTC handle. 946 * @retval None 947 */ 948 #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON)) 949 950 951 /** 952 * @brief Get the selected RTC shift operations flag status. 953 * @param __HANDLE__ specifies the RTC handle. 954 * @param __FLAG__ specifies the RTC shift operation Flag is pending or not. 955 * This parameter can be: 956 * @arg @ref RTC_FLAG_SHPF 957 * @retval None 958 */ 959 #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__))) 960 /** 961 * @} 962 */ 963 964 965 /* ------------------------------Tamper----------------------------------*/ 966 /** @defgroup RTCEx_Tamper RTCEx tamper 967 * @{ 968 */ 969 /** 970 * @brief Enable the TAMP Tamper input detection. 971 * @param __HANDLE__ specifies the RTC handle. 972 * @param __TAMPER__ specifies the RTC Tamper source to be enabled. 973 * This parameter can be any combination of the following values: 974 * @arg RTC_TAMPER_ALL: All tampers 975 * @arg RTC_TAMPER_1: Tamper1 976 * @arg RTC_TAMPER_2: Tamper2 977 * @retval None 978 */ 979 #define __HAL_RTC_TAMPER_ENABLE(__HANDLE__, __TAMPER__) (TAMP->CR1 |= (__TAMPER__)) 980 981 /** 982 * @brief Disable the TAMP Tamper input detection. 983 * @param __HANDLE__ specifies the RTC handle. 984 * @param __TAMPER__ specifies the RTC Tamper sources to be enabled. 985 * This parameter can be any combination of the following values: 986 * @arg RTC_TAMPER_ALL: All tampers 987 * @arg RTC_TAMPER_1: Tamper1 988 * @arg RTC_TAMPER_2: Tamper2 989 */ 990 #define __HAL_RTC_TAMPER_DISABLE(__HANDLE__, __TAMPER__) (TAMP->CR1 &= ~(__TAMPER__)) 991 992 993 /**************************************************************************************************/ 994 /** 995 * @brief Enable the TAMP Tamper interrupt. 996 * @param __HANDLE__ specifies the RTC handle. 997 * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be enabled. 998 * This parameter can be any combination of the following values: 999 * @arg RTC_IT_TAMP_ALL: All tampers interrupts 1000 * @arg RTC_IT_TAMP_1: Tamper1 interrupt 1001 * @arg RTC_IT_TAMP_2: Tamper2 interrupt 1002 * @retval None 1003 */ 1004 #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) (TAMP->IER |= (__INTERRUPT__)) 1005 1006 1007 /** 1008 * @brief Disable the TAMP Tamper interrupt. 1009 * @param __HANDLE__ specifies the RTC handle. 1010 * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be disabled. 1011 * This parameter can be any combination of the following values: 1012 * @arg RTC_IT_TAMP_ALL: All tampers interrupts 1013 * @arg RTC_IT_TAMP_1: Tamper1 interrupt 1014 * @arg RTC_IT_TAMP_2: Tamper2 interrupt 1015 * @retval None 1016 */ 1017 #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) (TAMP->IER &= ~(__INTERRUPT__)) 1018 1019 1020 /**************************************************************************************************/ 1021 /** 1022 * @brief Check whether the specified TAMP Tamper interrupt has occurred or not. 1023 * @param __HANDLE__ specifies the RTC handle. 1024 * @param __INTERRUPT__ specifies the RTC Tamper interrupt to check. 1025 * This parameter can be: 1026 * @arg RTC_IT_TAMP_ALL: All tampers interrupts 1027 * @arg RTC_IT_TAMP_1: Tamper1 interrupt 1028 * @arg RTC_IT_TAMP_2: Tamper2 interrupt 1029 * @retval None 1030 */ 1031 #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) ((((TAMP->MISR)\ 1032 & (__INTERRUPT__)) != 0UL) ? 1UL : 0UL) 1033 1034 1035 /** 1036 * @brief Check whether the specified TAMP Tamper interrupt has been enabled or not. 1037 * @param __HANDLE__ specifies the RTC handle. 1038 * @param __INTERRUPT__ specifies the RTC Tamper interrupt source to check. 1039 * This parameter can be: 1040 * @arg RTC_IT_TAMP_ALL: All tampers interrupts 1041 * @arg RTC_IT_TAMP_1: Tamper1 interrupt 1042 * @arg RTC_IT_TAMP_2: Tamper2 interrupt 1043 * @retval None 1044 */ 1045 #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((TAMP->IER)\ 1046 & (__INTERRUPT__)) != 0UL) ? 1UL : 0UL) 1047 1048 1049 /** 1050 * @brief Get the selected TAMP Tampers flag status. 1051 * @param __HANDLE__ specifies the RTC handle. 1052 * @param __FLAG__ specifies the RTC Tamper Flag is pending or not. 1053 * This parameter can be: 1054 * @arg RTC_FLAG_TAMP_ALL: All tampers flag 1055 * @arg RTC_FLAG_TAMP_1: Tamper1 flag 1056 * @arg RTC_FLAG_TAMP_2: Tamper2 flag 1057 * @retval None 1058 */ 1059 #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((TAMP->SR) & (__FLAG__)) != 0UL) 1060 1061 1062 /** 1063 * @brief Clear the TAMP Tampers pending flags. 1064 * @param __HANDLE__ specifies the RTC handle. 1065 * @param __FLAG__ specifies the RTC Tamper Flag to clear. 1066 * This parameter can be: 1067 * @arg RTC_FLAG_TAMP_ALL: All tampers flag 1068 * @arg RTC_FLAG_TAMP_1: Tamper1 flag 1069 * @arg RTC_FLAG_TAMP_2: Tamper2 flag 1070 * @retval None 1071 */ 1072 #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((TAMP->SCR) = (__FLAG__)) 1073 1074 1075 /** 1076 * @brief Enable interrupt on the RTC Tamper associated Exti line. 1077 * @retval None 1078 */ 1079 #define __HAL_RTC_TAMPER_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_TAMPER_EVENT) 1080 1081 1082 /** 1083 * @brief Disable interrupt on the RTC Tamper associated Exti line. 1084 * @retval None 1085 */ 1086 #define __HAL_RTC_TAMPER_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_TAMPER_EVENT)) 1087 1088 1089 /** 1090 * @brief Enable interrupt on the RTC WakeUp Timer associated Exti line. 1091 * @retval None 1092 */ 1093 #define __HAL_RTC_TAMPER_EXTI_RISING_IT() (EXTI->RTSR1 |= RTC_EXTI_LINE_TAMPER_EVENT) 1094 1095 1096 /** 1097 * @brief Enable interrupt on the RTC WakeUp Timer associated Exti line. 1098 * @retval None 1099 */ 1100 #define __HAL_RTC_TAMPER_EXTI_FALLING_IT() (EXTI->FSTR1 |= RTC_EXTI_LINE_TAMPER_EVENT) 1101 1102 1103 /** 1104 * @brief Clear the interrupt on the RTC WakeUp Timer associated Exti line. 1105 * @retval None 1106 */ 1107 #define __HAL_RTC_TAMPER_EXTI_CLEAR_IT() (EXTI->PR1 = RTC_EXTI_LINE_TAMPER_EVENT) 1108 1109 1110 /** 1111 * @brief Enable event on the RTC Tamper associated Exti line. 1112 * @retval None 1113 */ 1114 #define __HAL_RTC_TAMPER_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_TAMPER_EVENT) 1115 1116 1117 /** 1118 * @brief Disable event on the RTC Tamper associated Exti line. 1119 * @retval None 1120 */ 1121 #define __HAL_RTC_TAMPER_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_TAMPER_EVENT)) 1122 1123 1124 /** 1125 * @} 1126 */ 1127 1128 /** 1129 * @} 1130 */ 1131 1132 /* Exported functions --------------------------------------------------------*/ 1133 /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions 1134 * @{ 1135 */ 1136 1137 /* RTC TimeStamp functions *****************************************/ 1138 /** @defgroup RTCEx_Exported_Functions_Group1 Extended RTC TimeStamp functions 1139 * @{ 1140 */ 1141 1142 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin); 1143 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin); 1144 HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc); 1145 HAL_StatusTypeDef HAL_RTCEx_SetInternalTimeStamp(RTC_HandleTypeDef *hrtc); 1146 HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTimeStamp(RTC_HandleTypeDef *hrtc); 1147 HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, 1148 RTC_DateTypeDef *sTimeStampDate, uint32_t Format); 1149 void HAL_RTCEx_TimeStampIRQHandler(RTC_HandleTypeDef *hrtc); 1150 HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 1151 void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc); 1152 /** 1153 * @} 1154 */ 1155 1156 1157 /* RTC Wake-up functions ******************************************************/ 1158 /** @defgroup RTCEx_Exported_Functions_Group2 Extended RTC Wake-up functions 1159 * @{ 1160 */ 1161 1162 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock); 1163 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock); 1164 HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc); 1165 uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc); 1166 void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc); 1167 void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc); 1168 HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 1169 /** 1170 * @} 1171 */ 1172 1173 /* Extended Control functions ************************************************/ 1174 /** @defgroup RTCEx_Exported_Functions_Group3 Extended Peripheral Control functions 1175 * @{ 1176 */ 1177 1178 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, 1179 uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue); 1180 HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS); 1181 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput); 1182 HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc); 1183 HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc); 1184 HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc); 1185 HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc); 1186 HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc); 1187 /** 1188 * @} 1189 */ 1190 1191 /* Extended RTC features functions *******************************************/ 1192 /** @defgroup RTCEx_Exported_Functions_Group4 Extended features functions 1193 * @{ 1194 */ 1195 1196 void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc); 1197 HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 1198 /** 1199 * @} 1200 */ 1201 1202 /** @defgroup RTCEx_Exported_Functions_Group5 Extended RTC Tamper functions 1203 * @{ 1204 */ 1205 HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper); 1206 HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper); 1207 HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper); 1208 HAL_StatusTypeDef HAL_RTCEx_PollForTamperEvent(RTC_HandleTypeDef *hrtc, uint32_t Tamper, uint32_t Timeout); 1209 HAL_StatusTypeDef HAL_RTCEx_SetInternalTamper(RTC_HandleTypeDef *hrtc, RTC_InternalTamperTypeDef *sIntTamper); 1210 HAL_StatusTypeDef HAL_RTCEx_SetInternalTamper_IT(RTC_HandleTypeDef *hrtc, RTC_InternalTamperTypeDef *sIntTamper); 1211 HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTamper(RTC_HandleTypeDef *hrtc, uint32_t IntTamper); 1212 HAL_StatusTypeDef HAL_RTCEx_PollForInternalTamperEvent(RTC_HandleTypeDef *hrtc, uint32_t IntTamper, uint32_t Timeout); 1213 void HAL_RTCEx_TamperIRQHandler(RTC_HandleTypeDef *hrtc); 1214 void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc); 1215 void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc); 1216 #if (RTC_TAMP_NB == 3) 1217 void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc); 1218 #endif /* RTC_TAMP_NB */ 1219 1220 #ifdef RTC_TAMP_INT_1_SUPPORT 1221 void HAL_RTCEx_InternalTamper1EventCallback(RTC_HandleTypeDef *hrtc); 1222 #endif /* RTC_TAMP_INT_1_SUPPORT */ 1223 #ifdef RTC_TAMP_INT_2_SUPPORT 1224 void HAL_RTCEx_InternalTamper2EventCallback(RTC_HandleTypeDef *hrtc); 1225 #endif /* RTC_TAMP_INT_2_SUPPORT */ 1226 void HAL_RTCEx_InternalTamper3EventCallback(RTC_HandleTypeDef *hrtc); 1227 void HAL_RTCEx_InternalTamper4EventCallback(RTC_HandleTypeDef *hrtc); 1228 void HAL_RTCEx_InternalTamper5EventCallback(RTC_HandleTypeDef *hrtc); 1229 #ifdef RTC_TAMP_INT_6_SUPPORT 1230 void HAL_RTCEx_InternalTamper6EventCallback(RTC_HandleTypeDef *hrtc); 1231 #endif /* RTC_TAMP_INT_6_SUPPORT */ 1232 #ifdef RTC_TAMP_INT_7_SUPPORT 1233 void HAL_RTCEx_InternalTamper7EventCallback(RTC_HandleTypeDef *hrtc); 1234 #endif /* RTC_TAMP_INT_7_SUPPORT */ 1235 /** 1236 * @} 1237 */ 1238 1239 /** @defgroup RTCEx_Exported_Functions_Group6 Extended RTC Backup register functions 1240 * @{ 1241 */ 1242 void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data); 1243 uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister); 1244 1245 /** 1246 * @} 1247 */ 1248 1249 1250 /** 1251 * @} 1252 */ 1253 1254 /* Private types -------------------------------------------------------------*/ 1255 /* Private variables ---------------------------------------------------------*/ 1256 /* Private constants ---------------------------------------------------------*/ 1257 /** @defgroup RTCEx_Private_Constants RTCEx Private Constants 1258 * @{ 1259 */ 1260 #define RTC_EXTI_LINE_ALARM_EVENT EXTI_IMR1_IM17 /*!< External interrupt line 17 Connected to the RTC Alarm event */ 1261 #define RTC_EXTI_LINE_TIMESTAMP_EVENT EXTI_IMR1_IM19 /*!< External interrupt line 19 Connected to the RTC tamper/Time Stamp/CSS_LSE events */ 1262 #define RTC_EXTI_LINE_TAMPER_EVENT EXTI_IMR1_IM19 /*!< External interrupt line 19 Connected to the RTC tamper/Time Stamp/CSS_LSE events */ 1263 #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT EXTI_IMR1_IM20 /*!< External interrupt line 20 Connected to the RTC Wakeup event */ 1264 /** 1265 * @} 1266 */ 1267 1268 /* Private macros ------------------------------------------------------------*/ 1269 /** @defgroup RTCEx_Private_Macros RTCEx Private Macros 1270 * @{ 1271 */ 1272 1273 /** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters 1274 * @{ 1275 */ 1276 #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \ 1277 ((EDGE) == RTC_TIMESTAMPEDGE_FALLING)) 1278 1279 1280 #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TIMESTAMPPIN_DEFAULT)) 1281 1282 1283 1284 #define IS_RTC_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \ 1285 ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE)) 1286 1287 #define IS_RTC_TAMPER_TAMPERDETECTIONOUTPUT(MODE) (((MODE) == RTC_TAMPERDETECTIONOUTPUT_ENABLE) || \ 1288 ((MODE) == RTC_TAMPERDETECTIONOUTPUT_DISABLE)) 1289 1290 1291 #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \ 1292 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \ 1293 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \ 1294 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \ 1295 ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \ 1296 ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS)) 1297 1298 #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= RTC_WUTR_WUT) 1299 1300 #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \ 1301 ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \ 1302 ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC)) 1303 1304 #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \ 1305 ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET)) 1306 1307 #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= RTC_CALR_CALM) 1308 1309 #define IS_RTC_LOW_POWER_CALIB(LPCAL) (((LPCAL) == RTC_LPCAL_SET) || \ 1310 ((LPCAL) == RTC_LPCAL_RESET)) 1311 1312 #define IS_RTC_TAMPER(__TAMPER__) ((((__TAMPER__) & RTC_TAMPER_ALL) != 0x00U) && \ 1313 (((__TAMPER__) & ~RTC_TAMPER_ALL) == 0x00U)) 1314 1315 #define IS_RTC_INTERNAL_TAMPER(__INT_TAMPER__) ((((__INT_TAMPER__) & RTC_INT_TAMPER_ALL) != 0x00U) && \ 1316 (((__INT_TAMPER__) & ~RTC_INT_TAMPER_ALL) == 0x00U)) 1317 1318 #define IS_RTC_TAMPER_TRIGGER(__TRIGGER__) (((__TRIGGER__) == RTC_TAMPERTRIGGER_RISINGEDGE) || \ 1319 ((__TRIGGER__) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \ 1320 ((__TRIGGER__) == RTC_TAMPERTRIGGER_LOWLEVEL) || \ 1321 ((__TRIGGER__) == RTC_TAMPERTRIGGER_HIGHLEVEL)) 1322 1323 #define IS_RTC_TAMPER_ERASE_MODE(__MODE__) (((__MODE__) == RTC_TAMPER_ERASE_BACKUP_ENABLE) || \ 1324 ((__MODE__) == RTC_TAMPER_ERASE_BACKUP_DISABLE)) 1325 1326 #define IS_RTC_TAMPER_MASKFLAG_STATE(__STATE__) (((__STATE__) == RTC_TAMPERMASK_FLAG_ENABLE) || \ 1327 ((__STATE__) == RTC_TAMPERMASK_FLAG_DISABLE)) 1328 1329 #define IS_RTC_TAMPER_FILTER(__FILTER__) (((__FILTER__) == RTC_TAMPERFILTER_DISABLE) || \ 1330 ((__FILTER__) == RTC_TAMPERFILTER_2SAMPLE) || \ 1331 ((__FILTER__) == RTC_TAMPERFILTER_4SAMPLE) || \ 1332 ((__FILTER__) == RTC_TAMPERFILTER_8SAMPLE)) 1333 1334 #define IS_RTC_TAMPER_SAMPLING_FREQ(__FREQ__) (((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \ 1335 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \ 1336 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \ 1337 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \ 1338 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \ 1339 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \ 1340 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \ 1341 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256)) 1342 1343 #define IS_RTC_TAMPER_PRECHARGE_DURATION(__DURATION__) (((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \ 1344 ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \ 1345 ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \ 1346 ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK)) 1347 1348 #define IS_RTC_TAMPER_PULLUP_STATE(__STATE__) (((__STATE__) == RTC_TAMPER_PULLUP_ENABLE) || \ 1349 ((__STATE__) == RTC_TAMPER_PULLUP_DISABLE)) 1350 1351 #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \ 1352 ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE)) 1353 1354 #define IS_RTC_BKP(__BKP__) ((__BKP__) < RTC_BKP_NUMBER) 1355 1356 #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \ 1357 ((SEL) == RTC_SHIFTADD1S_SET)) 1358 1359 #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= RTC_SHIFTR_SUBFS) 1360 1361 #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \ 1362 ((OUTPUT) == RTC_CALIBOUTPUT_1HZ)) 1363 /** 1364 * @} 1365 */ 1366 1367 /** 1368 * @} 1369 */ 1370 1371 /** 1372 * @} 1373 */ 1374 1375 /** 1376 * @} 1377 */ 1378 1379 #ifdef __cplusplus 1380 } 1381 #endif 1382 1383 #endif /* STM32G4xx_HAL_RTC_EX_H */ 1384