1 /** 2 ****************************************************************************** 3 * @file stm32l5xx_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 STM32L5xx_HAL_RTC_EX_H 21 #define STM32L5xx_HAL_RTC_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32l5xx_hal_def.h" 29 30 /** @addtogroup STM32L5xx_HAL_Driver 31 * @{ 32 */ 33 34 /** @defgroup 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_Active_Seed_Size Seed size Definitions 81 * @{ 82 */ 83 #define RTC_ATAMP_SEED_NB_UINT32 4U 84 /** 85 * @} 86 */ 87 88 89 /** @defgroup RTCEx_ActiveTamper_structures_definition RTCEx Active Tamper structures definitions 90 * @{ 91 */ 92 typedef struct 93 { 94 uint32_t Enable; /*!< Specifies the Tamper input is active. 95 This parameter can be a value of @ref RTCEx_ActiveTamper_Enable */ 96 97 uint32_t Interrupt; /*!< Specifies the interrupt mode 98 This parameter can be a value of @ref RTCEx_ActiveTamper_Interrupt */ 99 100 uint32_t Output; /*!< Specifies the TAMP output to be compared with. 101 The same output can be used for several tamper inputs. 102 This parameter can be a value of @ref RTCEx_ActiveTamper_Sel */ 103 104 uint32_t NoErase; /*!< Specifies the Tamper no erase mode. 105 This parameter can be a value of @ref RTCEx_Tamper_EraseBackUp */ 106 107 uint32_t MaskFlag; /*!< Specifies the Tamper Flag masking. 108 This parameter can be a value of @ref RTCEx_Tamper_MaskFlag */ 109 110 } RTC_ATampInputTypeDef; 111 112 113 typedef struct 114 { 115 uint32_t ActiveFilter; /*!< Specifies the Active tamper filter enable. 116 This parameter can be a value of @ref RTCEx_ActiveTamper_Filter */ 117 118 uint32_t ActiveAsyncPrescaler; /*!< Specifies the Active Tamper asynchronous Prescaler clock. 119 This parameter can be a value of @ref RTCEx_ActiveTamper_Async_prescaler */ 120 121 uint32_t TimeStampOnTamperDetection; /*!< Specifies the timeStamp on tamper detection. 122 This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection */ 123 124 uint32_t ActiveOutputChangePeriod; /*!< Specifies the Active Tamper output change period. 125 This parameter can be a value from 0 to 7. */ 126 127 uint32_t Seed[RTC_ATAMP_SEED_NB_UINT32]; 128 /*!< Specifies the RNG Seed value. 129 This parameter is an array of value from 0 to 0xFFFFFFFF. */ 130 131 RTC_ATampInputTypeDef TampInput[RTC_TAMP_NB]; 132 /*!< Specifies configuration of all active tampers. 133 The index of TampInput[RTC_TAMP_NB] can be a value of RTCEx_ActiveTamper_Sel */ 134 } RTC_ActiveTampersTypeDef; 135 /** 136 * @} 137 */ 138 139 /** @defgroup RTCEx_Internal_Tamper_structure_definition RTCEx Internal Tamper structure definition 140 * @{ 141 */ 142 typedef struct 143 { 144 uint32_t IntTamper; /*!< Specifies the Internal Tamper Pin. 145 This parameter can be a value of @ref RTCEx_Internal_Tamper_Pins */ 146 147 uint32_t TimeStampOnTamperDetection; /*!< Specifies the TimeStampOnTamperDetection. 148 This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection */ 149 150 uint32_t NoErase; /*!< Specifies the internal Tamper no erase mode. 151 This parameter can be a value of @ref RTCEx_Tamper_EraseBackUp */ 152 153 } RTC_InternalTamperTypeDef; 154 /** 155 * @} 156 */ 157 158 /** @defgroup RTCEx_Secure_State_structure_definition RTCEx Secure structure definition 159 * @{ 160 */ 161 typedef struct 162 { 163 uint32_t rtcSecureFull; /*!< Specifies If the RTC is fully secure or not 164 This parameter can be a value of @ref RTCEx_RTC_Secure_Full */ 165 uint32_t rtcNonSecureFeatures; /*!< Specifies the non-secure features. 166 This parameter is only relevant if RTC is not fully secure (rtcSecureFull == RTC_SECURE_FULL_NO). 167 This parameter can be a combination of @ref RTCEx_RTC_NonSecure_Features. */ 168 169 uint32_t tampSecureFull; /*!< Specifies If the TAMP is fully secure or not 170 This parameter can be a value of @ref RTCEx_TAMP_Secure_Full */ 171 172 uint32_t backupRegisterStartZone2; /*!< Specifies the backup register start zone 2 173 Zone 1 : read secure write secure. 174 Zone 2 : read non-secure write secure. 175 This parameter can be RTC_BKP_DRx where x can be from 0 to 31 to specify the register. 176 Warning : this parameter is shared with RTC_PrivilegeStateTypeDef. */ 177 178 uint32_t backupRegisterStartZone3; /*!< Specifies the backup register start zone 3 179 Zone 3 : read non-secure write non-secure 180 This parameter can be RTC_BKP_DRx where x can be from 0 to 31 to specify the register. 181 Warning : this parameter is shared with RTC_PrivilegeStateTypeDef. */ 182 183 } RTC_SecureStateTypeDef ; 184 /** 185 * @} 186 */ 187 188 /** @defgroup RTCEx_Privilege_State_structure_definition RTCEx Privilege structure definition 189 * @{ 190 */ 191 typedef struct 192 { 193 uint32_t rtcPrivilegeFull; /*!< Specifies If the RTC is fully privileged or not. 194 This parameter can be a value of @ref RTCEx_RTC_Privilege_Full. */ 195 196 uint32_t rtcPrivilegeFeatures; /*!< Specifies the privileged features. 197 This parameter is only relevant if RTC is not fully privileged (rtcPrivilegeFull == RTC_PRIVILEGE_FULL_NO). 198 This parameter can be a combination of @ref RTCEx_RTC_Privilege_Features. */ 199 200 uint32_t tampPrivilegeFull; /*!< Specifies If the TAMP is fully privileged or not. 201 This parameter can be a value of @ref RTCEx_TAMP_Privilege_Full. */ 202 203 uint32_t backupRegisterPrivZone; /*!< Specifies backup register zone to be privileged. 204 This parameter can be a combination of @ref RTCEx_Backup_Reg_Privilege_zone. 205 Warning : this parameter is writable in secure mode or if trustzone is disabled. */ 206 207 208 uint32_t backupRegisterStartZone2; /*!< Specifies the backup register start zone 2. 209 Zone 1 : read secure write secure. 210 Zone 2 : read non-secure write secure. 211 This parameter can be RTC_BKP_DRx where x can be from 0 to 31 to specify the register . 212 Warning : this parameter is writable in secure mode or if trustzone is disabled. 213 Warning : this parameter is shared with RTC_SecureStateTypeDef */ 214 215 uint32_t backupRegisterStartZone3; /*!< Specifies the backup register start zone 3. 216 Zone 3 : read non-secure write non-secure. 217 This parameter can be RTC_BKP_DRx where x can be from 0 to 31 to specify the register. 218 Warning : this parameter is writable in secure mode or if trustzone is disabled. 219 Warning : this parameter is shared with RTC_SecureStateTypeDef. */ 220 221 } RTC_PrivilegeStateTypeDef; 222 /** 223 * @} 224 */ 225 226 /** 227 * @} 228 */ 229 230 /* Exported constants --------------------------------------------------------*/ 231 /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants 232 * @{ 233 */ 234 235 /** @defgroup RTCEx_Time_Stamp_Edges_definitions RTCEx Time Stamp Edges definition 236 * @{ 237 */ 238 #define RTC_TIMESTAMPEDGE_RISING 0x00000000u 239 #define RTC_TIMESTAMPEDGE_FALLING RTC_CR_TSEDGE 240 /** 241 * @} 242 */ 243 244 /** @defgroup RTCEx_TimeStamp_Pin_Selections RTCEx TimeStamp Pin Selection 245 * @{ 246 */ 247 #define RTC_TIMESTAMPPIN_DEFAULT 0x00000000u 248 /** 249 * @} 250 */ 251 252 /** @defgroup RTCEx_Wakeup_Timer_Definitions RTCEx Wakeup Timer Definitions 253 * @{ 254 */ 255 #define RTC_WAKEUPCLOCK_RTCCLK_DIV16 0x00000000u 256 #define RTC_WAKEUPCLOCK_RTCCLK_DIV8 RTC_CR_WUCKSEL_0 257 #define RTC_WAKEUPCLOCK_RTCCLK_DIV4 RTC_CR_WUCKSEL_1 258 #define RTC_WAKEUPCLOCK_RTCCLK_DIV2 (RTC_CR_WUCKSEL_0 | RTC_CR_WUCKSEL_1) 259 #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS RTC_CR_WUCKSEL_2 260 #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_2) 261 /** 262 * @} 263 */ 264 265 /** @defgroup RTCEx_Smooth_calib_period_Definitions RTCEx Smooth calib period Definitions 266 * @{ 267 */ 268 #define RTC_SMOOTHCALIB_PERIOD_32SEC 0x00000000u /*!< If RTCCLK = 32768 Hz, Smooth calibration 269 period is 32s, else 2exp20 RTCCLK pulses */ 270 #define RTC_SMOOTHCALIB_PERIOD_16SEC RTC_CALR_CALW16 /*!< If RTCCLK = 32768 Hz, Smooth calibration 271 period is 16s, else 2exp19 RTCCLK pulses */ 272 #define RTC_SMOOTHCALIB_PERIOD_8SEC RTC_CALR_CALW8 /*!< If RTCCLK = 32768 Hz, Smooth calibration 273 period is 8s, else 2exp18 RTCCLK pulses */ 274 /** 275 * @} 276 */ 277 278 /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions RTCEx Smooth calib Plus pulses Definitions 279 * @{ 280 */ 281 #define RTC_SMOOTHCALIB_PLUSPULSES_SET RTC_CALR_CALP /*!< The number of RTCCLK pulses added 282 during a X -second window = Y - CALM[8:0] 283 with Y = 512, 256, 128 when X = 32, 16, 8 */ 284 #define RTC_SMOOTHCALIB_PLUSPULSES_RESET 0x00000000u /*!< The number of RTCCLK pulses subbstited 285 during a 32-second window = CALM[8:0] */ 286 /** 287 * @} 288 */ 289 290 /** @defgroup RTCEx_Smooth_calib_low_power_Definitions RTCEx Smooth calib Low Power Definitions 291 * @{ 292 */ 293 #define RTC_LPCAL_SET RTC_CALR_LPCAL /*!< Calibration window is 220 ck_apre, 294 which is the required configuration for 295 ultra-low consumption mode. */ 296 #define RTC_LPCAL_RESET 0x00000000u /*!< Calibration window is 220 RTCCLK, 297 which is a high-consumption mode. 298 This mode should be set only when less 299 than 32s calibration window is required. */ 300 /** 301 * @} 302 */ 303 304 /** @defgroup RTCEx_Calib_Output_selection_Definitions RTCEx Calib Output selection Definitions 305 * @{ 306 */ 307 #define RTC_CALIBOUTPUT_512HZ 0x00000000u 308 #define RTC_CALIBOUTPUT_1HZ RTC_CR_COSEL 309 310 /** 311 * @} 312 */ 313 314 315 /** @defgroup RTCEx_Add_1_Second_Parameter_Definition RTCEx Add 1 Second Parameter Definitions 316 * @{ 317 */ 318 #define RTC_SHIFTADD1S_RESET 0x00000000u 319 #define RTC_SHIFTADD1S_SET RTC_SHIFTR_ADD1S 320 /** 321 * @} 322 */ 323 324 /** @defgroup RTCEx_Tamper_Pins RTCEx Tamper Pins Definition 325 * @{ 326 */ 327 #define RTC_TAMPER_1 TAMP_CR1_TAMP1E 328 #define RTC_TAMPER_2 TAMP_CR1_TAMP2E 329 #if (RTC_TAMP_NB == 3) 330 #define RTC_TAMPER_3 TAMP_CR1_TAMP3E 331 #define RTC_TAMPER_ALL (RTC_TAMPER_1 | RTC_TAMPER_2 | RTC_TAMPER_3 ) 332 #elif (RTC_TAMP_NB == 8) 333 #define RTC_TAMPER_3 TAMP_CR1_TAMP3E 334 #define RTC_TAMPER_4 TAMP_CR1_TAMP4E 335 #define RTC_TAMPER_5 TAMP_CR1_TAMP5E 336 #define RTC_TAMPER_6 TAMP_CR1_TAMP6E 337 #define RTC_TAMPER_7 TAMP_CR1_TAMP7E 338 #define RTC_TAMPER_8 TAMP_CR1_TAMP8E 339 #define RTC_TAMPER_ALL (RTC_TAMPER_1 | RTC_TAMPER_2 |\ 340 RTC_TAMPER_3 | RTC_TAMPER_4 |\ 341 RTC_TAMPER_5 | RTC_TAMPER_6 |\ 342 RTC_TAMPER_7 | RTC_TAMPER_8 ) 343 #else 344 #define RTC_TAMPER_ALL (RTC_TAMPER_1 | RTC_TAMPER_2) 345 #endif /* RTC_TAMP_NB */ 346 /** 347 * @} 348 */ 349 350 /** @defgroup RTCEx_Internal_Tamper_Pins RTCEx Internal Tamper Pins Definition 351 * @{ 352 */ 353 #define RTC_INT_TAMPER_1 TAMP_CR1_ITAMP1E 354 #define RTC_INT_TAMPER_2 TAMP_CR1_ITAMP2E 355 #define RTC_INT_TAMPER_3 TAMP_CR1_ITAMP3E 356 #define RTC_INT_TAMPER_5 TAMP_CR1_ITAMP5E 357 #define RTC_INT_TAMPER_8 TAMP_CR1_ITAMP8E 358 #define RTC_INT_TAMPER_ALL (RTC_INT_TAMPER_1 | RTC_INT_TAMPER_2 |\ 359 RTC_INT_TAMPER_3 | RTC_INT_TAMPER_5 |\ 360 RTC_INT_TAMPER_8) 361 /** 362 * @} 363 */ 364 365 /** @defgroup RTCEx_Tamper_Trigger RTCEx Tamper Trigger 366 * @{ 367 */ 368 #define RTC_TAMPERTRIGGER_RISINGEDGE 0x00u /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */ 369 #define RTC_TAMPERTRIGGER_FALLINGEDGE 0x01u /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */ 370 #define RTC_TAMPERTRIGGER_LOWLEVEL 0x02u /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */ 371 #define RTC_TAMPERTRIGGER_HIGHLEVEL 0x03u /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */ 372 /** 373 * @} 374 */ 375 376 /** @defgroup RTCEx_Tamper_MaskFlag RTCEx Tamper MaskFlag 377 * @{ 378 */ 379 #define RTC_TAMPERMASK_FLAG_DISABLE 0x00u 380 #define RTC_TAMPERMASK_FLAG_ENABLE 0x01u 381 /** 382 * @} 383 */ 384 385 386 /** @defgroup RTCEx_Tamper_Maskable_nb RTCEx Tampers maskable number 387 * @{ 388 */ 389 #define RTC_TAMPER_MASKABLE_NB 3u 390 391 /** 392 * @} 393 */ 394 395 /** @defgroup RTCEx_Tamper_EraseBackUp RTCEx Tamper EraseBackUp 396 * @{ 397 */ 398 #define RTC_TAMPER_ERASE_BACKUP_ENABLE 0x00u 399 #define RTC_TAMPER_ERASE_BACKUP_DISABLE 0x01u 400 /** 401 * @} 402 */ 403 404 /** @defgroup RTCEx_Tamper_Filter RTCEx Tamper Filter 405 * @{ 406 */ 407 #define RTC_TAMPERFILTER_DISABLE 0x00000000U /*!< Tamper filter is disabled */ 408 #define RTC_TAMPERFILTER_2SAMPLE TAMP_FLTCR_TAMPFLT_0 /*!< Tamper is activated after 2 409 consecutive samples at the active level */ 410 #define RTC_TAMPERFILTER_4SAMPLE TAMP_FLTCR_TAMPFLT_1 /*!< Tamper is activated after 4 411 consecutive samples at the active level */ 412 #define RTC_TAMPERFILTER_8SAMPLE TAMP_FLTCR_TAMPFLT /*!< Tamper is activated after 8 413 consecutive samples at the active level */ 414 /** 415 * @} 416 */ 417 418 /** @defgroup RTCEx_Tamper_Sampling_Frequencies RTCEx Tamper Sampling Frequencies 419 * @{ 420 */ 421 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 0x00000000U /*!< Each of the tamper inputs are sampled 422 with a frequency = RTCCLK / 32768 */ 423 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 TAMP_FLTCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled 424 with a frequency = RTCCLK / 16384 */ 425 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 TAMP_FLTCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled 426 with a frequency = RTCCLK / 8192 */ 427 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled 428 with a frequency = RTCCLK / 4096 */ 429 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 TAMP_FLTCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled 430 with a frequency = RTCCLK / 2048 */ 431 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled 432 with a frequency = RTCCLK / 1024 */ 433 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 (TAMP_FLTCR_TAMPFREQ_1 | TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled 434 with a frequency = RTCCLK / 512 */ 435 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_1 | \ 436 TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled 437 with a frequency = RTCCLK / 256 */ 438 /** 439 * @} 440 */ 441 442 /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration RTCEx Tamper Pin Precharge Duration 443 * @{ 444 */ 445 #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK 0x00000000U /*!< Tamper pins are pre-charged before 446 sampling during 1 RTCCLK cycle */ 447 #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK TAMP_FLTCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before 448 sampling during 2 RTCCLK cycles */ 449 #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK TAMP_FLTCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before 450 sampling during 4 RTCCLK cycles */ 451 #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK (TAMP_FLTCR_TAMPPRCH_0 | TAMP_FLTCR_TAMPPRCH_1) /*!< Tamper pins are pre-charged before 452 sampling during 8 RTCCLK cycles */ 453 /** 454 * @} 455 */ 456 457 /** @defgroup RTCEx_Tamper_Pull_UP RTCEx Tamper Pull UP 458 * @{ 459 */ 460 #define RTC_TAMPER_PULLUP_ENABLE 0x00000000u /*!< Tamper pins are pre-charged before sampling */ 461 #define RTC_TAMPER_PULLUP_DISABLE TAMP_FLTCR_TAMPPUDIS /*!< Tamper pins pre-charge is disabled */ 462 /** 463 * @} 464 */ 465 466 /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection RTCEx Tamper TimeStamp On Tamper Detection Definitions 467 * @{ 468 */ 469 #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE 0x00000000u /*!< TimeStamp on Tamper Detection event is not saved */ 470 #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE RTC_CR_TAMPTS /*!< TimeStamp on Tamper Detection event saved */ 471 /** 472 * @} 473 */ 474 475 /** @defgroup RTCEx_Internal_Tamper_Interrupt RTCEx Internal Tamper Interrupt 476 * @{ 477 */ 478 #define RTC_IT_TAMP_1 TAMP_IER_TAMP1IE /*!< Tamper 1 Interrupt */ 479 #define RTC_IT_TAMP_2 TAMP_IER_TAMP2IE /*!< Tamper 2 Interrupt */ 480 #define RTC_IT_TAMP_3 TAMP_IER_TAMP3IE /*!< Tamper 3 Interrupt */ 481 #define RTC_IT_TAMP_4 TAMP_IER_TAMP4IE /*!< Tamper 4 Interrupt */ 482 #define RTC_IT_TAMP_5 TAMP_IER_TAMP5IE /*!< Tamper 5 Interrupt */ 483 #define RTC_IT_TAMP_6 TAMP_IER_TAMP6IE /*!< Tamper 6 Interrupt */ 484 #define RTC_IT_TAMP_7 TAMP_IER_TAMP7IE /*!< Tamper 7 Interrupt */ 485 #define RTC_IT_TAMP_8 TAMP_IER_TAMP8IE /*!< Tamper 8 Interrupt */ 486 #define RTC_IT_TAMP_ALL (RTC_IT_TAMP_1 | RTC_IT_TAMP_2 |\ 487 RTC_IT_TAMP_3 | RTC_IT_TAMP_4 |\ 488 RTC_IT_TAMP_5 | RTC_IT_TAMP_6 |\ 489 RTC_IT_TAMP_7 | RTC_IT_TAMP_8 ) 490 491 #define RTC_IT_INT_TAMP_1 TAMP_IER_ITAMP1IE /*!< Tamper 1 internal Interrupt */ 492 #define RTC_IT_INT_TAMP_2 TAMP_IER_ITAMP2IE /*!< Tamper 2 internal Interrupt */ 493 #define RTC_IT_INT_TAMP_3 TAMP_IER_ITAMP3IE /*!< Tamper 3 internal Interrupt */ 494 #define RTC_IT_INT_TAMP_5 TAMP_IER_ITAMP5IE /*!< Tamper 5 internal Interrupt */ 495 #define RTC_IT_INT_TAMP_8 TAMP_IER_ITAMP8IE /*!< Tamper 8 internal Interrupt */ 496 497 #define RTC_IT_INT_TAMP_ALL (RTC_IT_INT_TAMP_1 | RTC_IT_INT_TAMP_2 |\ 498 RTC_IT_INT_TAMP_3 | RTC_IT_INT_TAMP_5 |\ 499 RTC_IT_INT_TAMP_8 ) 500 /** 501 * @} 502 */ 503 504 /** @defgroup RTCEx_Flags RTCEx Flags 505 * @{ 506 */ 507 #define RTC_FLAG_TAMP_1 TAMP_SR_TAMP1F 508 #define RTC_FLAG_TAMP_2 TAMP_SR_TAMP2F 509 #define RTC_FLAG_TAMP_3 TAMP_SR_TAMP3F 510 #define RTC_FLAG_TAMP_4 TAMP_SR_TAMP4F 511 #define RTC_FLAG_TAMP_5 TAMP_SR_TAMP5F 512 #define RTC_FLAG_TAMP_6 TAMP_SR_TAMP6F 513 #define RTC_FLAG_TAMP_7 TAMP_SR_TAMP7F 514 #define RTC_FLAG_TAMP_8 TAMP_SR_TAMP8F 515 #define RTC_FLAG_TAMP_ALL (RTC_FLAG_TAMP_1 | RTC_FLAG_TAMP_2 | RTC_FLAG_TAMP_3 |\ 516 RTC_FLAG_TAMP_4 | RTC_FLAG_TAMP_5 | RTC_FLAG_TAMP_6 |\ 517 RTC_FLAG_TAMP_7 | RTC_FLAG_TAMP_8) 518 519 520 #define RTC_FLAG_INT_TAMP_1 TAMP_SR_ITAMP1F 521 #define RTC_FLAG_INT_TAMP_2 TAMP_SR_ITAMP2F 522 #define RTC_FLAG_INT_TAMP_3 TAMP_SR_ITAMP3F 523 #define RTC_FLAG_INT_TAMP_5 TAMP_SR_ITAMP5F 524 #define RTC_FLAG_INT_TAMP_8 TAMP_SR_ITAMP8F 525 #define RTC_FLAG_INT_TAMP_ALL (RTC_FLAG_INT_TAMP_1 | RTC_FLAG_INT_TAMP2 |\ 526 RTC_FLAG_INT_TAMP_3 | RTC_FLAG_INT_TAMP5 |\ 527 RTC_FLAG_INT_TAMP_8) 528 /** 529 * @} 530 */ 531 532 533 /** @defgroup RTCEx_ActiveTamper_Enable RTCEx_ActiveTamper_Enable Definitions 534 * @{ 535 */ 536 #define RTC_ATAMP_ENABLE 1u 537 #define RTC_ATAMP_DISABLE 0u 538 /** 539 * @} 540 */ 541 542 /** @defgroup RTCEx_ActiveTamper_Interrupt RTCEx_ActiveTamper_Interrupt Definitions 543 * @{ 544 */ 545 #define RTC_ATAMP_INTERRUPT_ENABLE 1u 546 #define RTC_ATAMP_INTERRUPT_DISABLE 0u 547 /** 548 * @} 549 */ 550 551 /** @defgroup RTCEx_ActiveTamper_Filter RTCEx_ActiveTamper_Filter Definitions 552 * @{ 553 */ 554 #define RTC_ATAMP_FILTER_ENABLE TAMP_ATCR1_FLTEN 555 #define RTC_ATAMP_FILTER_DISABLE 0u 556 /** 557 * @} 558 */ 559 560 /** @defgroup RTCEx_ActiveTamper_Async_prescaler RTCEx Active_Tamper_Asynchronous_Prescaler clock Definitions 561 * @{ 562 */ 563 #define RTC_ATAMP_ASYNCPRES_RTCCLK 0u /*!< RTCCLK */ 564 #define RTC_ATAMP_ASYNCPRES_RTCCLK_2 TAMP_ATCR1_ATCKSEL_0 /*!< RTCCLK/2 */ 565 #define RTC_ATAMP_ASYNCPRES_RTCCLK_4 TAMP_ATCR1_ATCKSEL_1 /*!< RTCCLK/4 */ 566 #define RTC_ATAMP_ASYNCPRES_RTCCLK_8 (TAMP_ATCR1_ATCKSEL_1 | TAMP_ATCR1_ATCKSEL_0) /*!< RTCCLK/8 */ 567 #define RTC_ATAMP_ASYNCPRES_RTCCLK_16 TAMP_ATCR1_ATCKSEL_2 /*!< RTCCLK/16 */ 568 #define RTC_ATAMP_ASYNCPRES_RTCCLK_32 (TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_0) /*!< RTCCLK/32 */ 569 #define RTC_ATAMP_ASYNCPRES_RTCCLK_64 (TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_1) /*!< RTCCLK/64 */ 570 #define RTC_ATAMP_ASYNCPRES_RTCCLK_128 (TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_1 | TAMP_ATCR1_ATCKSEL_0) /*!< RTCCLK/128 */ 571 /** 572 * @} 573 */ 574 575 /** @defgroup RTCEx_ActiveTamper_Sel RTCEx Active Tamper selection Definition 576 * @{ 577 */ 578 #define RTC_ATAMP_1 0u /*!< Tamper 1 */ 579 #define RTC_ATAMP_2 1u /*!< Tamper 2 */ 580 #define RTC_ATAMP_3 2u /*!< Tamper 3 */ 581 #define RTC_ATAMP_4 3u /*!< Tamper 4 */ 582 #define RTC_ATAMP_5 4u /*!< Tamper 5 */ 583 #define RTC_ATAMP_6 5u /*!< Tamper 6 */ 584 #define RTC_ATAMP_7 6u /*!< Tamper 7 */ 585 #define RTC_ATAMP_8 7u /*!< Tamper 8 */ 586 /** 587 * @} 588 */ 589 590 591 /** @defgroup RTCEx_MonotonicCounter_Instance RTCEx Monotonic Counter Instance Definition 592 * @{ 593 */ 594 #define RTC_MONOTONIC_COUNTER_1 0u /*!< Monotonic counter 1 */ 595 /** 596 * @} 597 */ 598 599 600 /** @defgroup RTCEx_Backup_Registers RTCEx Backup Registers Definition 601 * @{ 602 */ 603 #define RTC_BKP_NUMBER RTC_BACKUP_NB 604 #define RTC_BKP_DR0 0x00u 605 #define RTC_BKP_DR1 0x01u 606 #define RTC_BKP_DR2 0x02u 607 #define RTC_BKP_DR3 0x03u 608 #define RTC_BKP_DR4 0x04u 609 #define RTC_BKP_DR5 0x05u 610 #define RTC_BKP_DR6 0x06u 611 #define RTC_BKP_DR7 0x07u 612 #define RTC_BKP_DR8 0x08u 613 #define RTC_BKP_DR9 0x09u 614 #define RTC_BKP_DR10 0x0Au 615 #define RTC_BKP_DR11 0x0Bu 616 #define RTC_BKP_DR12 0x0Cu 617 #define RTC_BKP_DR13 0x0Du 618 #define RTC_BKP_DR14 0x0Eu 619 #define RTC_BKP_DR15 0x0Fu 620 #define RTC_BKP_DR16 0x10u 621 #define RTC_BKP_DR17 0x11u 622 #define RTC_BKP_DR18 0x12u 623 #define RTC_BKP_DR19 0x13u 624 #define RTC_BKP_DR20 0x14u 625 #define RTC_BKP_DR21 0x15u 626 #define RTC_BKP_DR22 0x16u 627 #define RTC_BKP_DR23 0x17u 628 #define RTC_BKP_DR24 0x18u 629 #define RTC_BKP_DR25 0x19u 630 #define RTC_BKP_DR26 0x1Au 631 #define RTC_BKP_DR27 0x1Bu 632 #define RTC_BKP_DR28 0x1Cu 633 #define RTC_BKP_DR29 0x1Du 634 #define RTC_BKP_DR30 0x1Eu 635 #define RTC_BKP_DR31 0x1Fu 636 /** 637 * @} 638 */ 639 640 641 /** @defgroup RTCEx_RTC_Secure_Full RTCEx Secure Definition 642 * @{ 643 */ 644 #define RTC_SECURE_FULL_YES 0u /*!< RTC full secure */ 645 #define RTC_SECURE_FULL_NO RTC_SMCR_DECPROT /*!< RTC is not full secure, features can be non-secure. See RTC_LL_EC_NONSECURE_RTC_FEATURE */ 646 /** 647 * @} 648 */ 649 650 /** @defgroup RTCEx_RTC_NonSecure_Features RTCEx Secure Features Definition 651 * @{ 652 */ 653 #define RTC_NONSECURE_FEATURE_NONE 0u 654 #define RTC_NONSECURE_FEATURE_INIT RTC_SMCR_INITDPROT /*!< Initialization */ 655 #define RTC_NONSECURE_FEATURE_CAL RTC_SMCR_CALDPROT /*!< Calibration */ 656 #define RTC_NONSECURE_FEATURE_TS RTC_SMCR_TSDPROT /*!< Time stamp */ 657 #define RTC_NONSECURE_FEATURE_WUT RTC_SMCR_WUTDPROT /*!< Wake up timer */ 658 #define RTC_NONSECURE_FEATURE_ALRA RTC_SMCR_ALRADPROT /*!< Alarm A */ 659 #define RTC_NONSECURE_FEATURE_ALRB RTC_SMCR_ALRBDPROT /*!< Alarm B */ 660 #define RTC_NONSECURE_FEATURE_ALL (RTC_SMCR_INITDPROT | RTC_SMCR_CALDPROT | \ 661 RTC_SMCR_TSDPROT | RTC_SMCR_WUTDPROT | \ 662 RTC_SMCR_ALRADPROT | RTC_SMCR_ALRBDPROT) 663 /** 664 * @} 665 */ 666 667 /** @defgroup RTCEx_TAMP_Secure_Full RTCEx TAMP Secure 668 * @{ 669 */ 670 #define TAMP_SECURE_FULL_YES 0u /*!< TAMPER full secure */ 671 #define TAMP_SECURE_FULL_NO TAMP_SMCR_TAMPDPROT /*!< TAMPER is not secure */ 672 /** 673 * @} 674 */ 675 676 677 /** @defgroup RTCEx_RTC_Privilege_Full RTCEx Privilege Features 678 * @{ 679 */ 680 #define RTC_PRIVILEGE_FULL_YES RTC_PRIVCR_PRIV 681 #define RTC_PRIVILEGE_FULL_NO 0u 682 /** 683 * @} 684 */ 685 686 /** @defgroup RTCEx_RTC_Privilege_Features RTCEx Privilege Features Definition 687 * @{ 688 */ 689 #define RTC_PRIVILEGE_FEATURE_NONE 0u 690 #define RTC_PRIVILEGE_FEATURE_INIT RTC_PRIVCR_INITPRIV /*!< Initialization */ 691 #define RTC_PRIVILEGE_FEATURE_CAL RTC_PRIVCR_CALPRIV /*!< Calibration */ 692 #define RTC_PRIVILEGE_FEATURE_TS RTC_PRIVCR_TSPRIV /*!< Time stamp */ 693 #define RTC_PRIVILEGE_FEATURE_WUT RTC_PRIVCR_WUTPRIV /*!< Wake up timer */ 694 #define RTC_PRIVILEGE_FEATURE_ALRA RTC_PRIVCR_ALRAPRIV /*!< Alarm A */ 695 #define RTC_PRIVILEGE_FEATURE_ALRB RTC_PRIVCR_ALRBPRIV /*!< Alarm B */ 696 #define RTC_PRIVILEGE_FEATURE_ALL (RTC_PRIVCR_INITPRIV | RTC_PRIVCR_CALPRIV | \ 697 RTC_PRIVCR_TSPRIV | RTC_PRIVCR_WUTPRIV | \ 698 RTC_PRIVCR_ALRAPRIV | RTC_PRIVCR_ALRBPRIV) 699 /** 700 * @} 701 */ 702 703 /** @defgroup RTCEx_TAMP_Privilege_Full RTCEx TAMP security Definition 704 * @{ 705 */ 706 #define TAMP_PRIVILEGE_FULL_YES TAMP_PRIVCR_TAMPPRIV 707 #define TAMP_PRIVILEGE_FULL_NO 0u 708 /** 709 * @} 710 */ 711 712 /** @defgroup RTCEx_Backup_Reg_Privilege_zone RTCEx Privilege Backup register privilege zone Definition 713 * @{ 714 */ 715 #define RTC_PRIVILEGE_BKUP_ZONE_NONE 0u 716 #define RTC_PRIVILEGE_BKUP_ZONE_1 TAMP_PRIVCR_BKPRWPRIV 717 #define RTC_PRIVILEGE_BKUP_ZONE_2 TAMP_PRIVCR_BKPWPRIV 718 #define RTC_PRIVILEGE_BKUP_ZONE_ALL (RTC_PRIVILEGE_BKUP_ZONE_1 | RTC_PRIVILEGE_BKUP_ZONE_2) 719 /** 720 * @} 721 */ 722 723 /** 724 * @} 725 */ 726 727 /* Exported macros -----------------------------------------------------------*/ 728 /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros 729 * @{ 730 */ 731 732 /** @brief Clear the specified RTC pending flag. 733 * @param __HANDLE__ specifies the RTC Handle. 734 * @param __FLAG__ specifies the flag to check. 735 * This parameter can be any combination of the following values: 736 * @arg @ref RTC_CLEAR_ITSF Clear Internal Time-stamp flag 737 * @arg @ref RTC_CLEAR_TSOVF Clear Time-stamp overflow flag 738 * @arg @ref RTC_CLEAR_TSF Clear Time-stamp flag 739 * @arg @ref RTC_CLEAR_WUTF Clear Wakeup timer flag 740 * @arg @ref RTC_CLEAR_ALRBF Clear Alarm B flag 741 * @arg @ref RTC_CLEAR_ALRAF Clear Alarm A flag 742 * @retval None 743 */ 744 #define __HAL_RTC_CLEAR_FLAG(__HANDLE__, __FLAG__) (RTC->SCR = (__FLAG__)) 745 746 /** @brief Check whether the specified RTC flag is set or not. 747 * @param __HANDLE__ specifies the RTC Handle. 748 * @param __FLAG__ specifies the flag to check. 749 * This parameter can be any combination of the following values: 750 * @arg @ref RTC_FLAG_RECALPF Recalibration pending Flag 751 * @arg @ref RTC_FLAG_INITF Initialization flag 752 * @arg @ref RTC_FLAG_RSF Registers synchronization flag 753 * @arg @ref RTC_FLAG_INITS Initialization status flag 754 * @arg @ref RTC_FLAG_SHPF Shift operation pending flag 755 * @arg @ref RTC_FLAG_WUTWF Wakeup timer write flag 756 * @arg @ref RTC_FLAG_ITSF Internal Time-stamp flag 757 * @arg @ref RTC_FLAG_TSOVF Time-stamp overflow flag 758 * @arg @ref RTC_FLAG_TSF Time-stamp flag 759 * @arg @ref RTC_FLAG_WUTF Wakeup timer flag 760 * @arg @ref RTC_FLAG_ALRBF Alarm B flag 761 * @arg @ref RTC_FLAG_ALRAF Alarm A flag 762 * @retval None 763 */ 764 #define __HAL_RTC_GET_FLAG(__HANDLE__, __FLAG__) (((((__FLAG__)) >> 8U) == 1U) ? (RTC->ICSR & (1U << (((uint16_t)(__FLAG__)) & RTC_FLAG_MASK))) : \ 765 (RTC->SR & (1U << (((uint16_t)(__FLAG__)) & RTC_FLAG_MASK)))) 766 767 /* ---------------------------------WAKEUPTIMER---------------------------------*/ 768 /** @defgroup RTCEx_WakeUp_Timer RTC WakeUp Timer 769 * @{ 770 */ 771 /** 772 * @brief Enable the RTC WakeUp Timer peripheral. 773 * @param __HANDLE__ specifies the RTC handle. 774 * @retval None 775 */ 776 #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_WUTE)) 777 778 /** 779 * @brief Disable the RTC WakeUp Timer peripheral. 780 * @param __HANDLE__ specifies the RTC handle. 781 * @retval None 782 */ 783 #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_WUTE)) 784 785 /** 786 * @brief Enable the RTC WakeUpTimer interrupt. 787 * @param __HANDLE__ specifies the RTC handle. 788 * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be enabled. 789 * This parameter can be: 790 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 791 * @retval None 792 */ 793 #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR |= (__INTERRUPT__)) 794 795 /** 796 * @brief Disable the RTC WakeUpTimer interrupt. 797 * @param __HANDLE__ specifies the RTC handle. 798 * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be disabled. 799 * This parameter can be: 800 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 801 * @retval None 802 */ 803 #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR &= ~(__INTERRUPT__)) 804 805 806 /** 807 * @brief Check whether the specified RTC WakeUpTimer interrupt has occurred or not. 808 * @param __HANDLE__ specifies the RTC handle. 809 * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt to check. 810 * This parameter can be: 811 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 812 * @retval None 813 */ 814 #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __INTERRUPT__) ((((RTC->MISR) & ((__INTERRUPT__)>> 12U)) != 0UL) ? 1UL : 0UL) 815 /** 816 * @brief Check whether the specified RTC Wake Up timer interrupt has been enabled or not. 817 * @param __HANDLE__ specifies the RTC handle. 818 * @param __INTERRUPT__ specifies the RTC Wake Up timer interrupt sources to check. 819 * This parameter can be: 820 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 821 * @retval None 822 */ 823 #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((RTC->CR) & (__INTERRUPT__)) != 0UL) ? 1UL : 0UL) 824 825 /** 826 * @brief Get the selected RTC WakeUpTimers flag status. 827 * @param __HANDLE__ specifies the RTC handle. 828 * @param __FLAG__ specifies the RTC WakeUpTimer Flag is pending or not. 829 * This parameter can be: 830 * @arg @ref RTC_FLAG_WUTF 831 * @arg @ref RTC_FLAG_WUTWF 832 * @retval None 833 */ 834 #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__))) 835 836 /** 837 * @brief Clear the RTC Wake Up timers pending flags. 838 * @param __HANDLE__ specifies the RTC handle. 839 * @param __FLAG__ specifies the RTC WakeUpTimer Flag to clear. 840 * This parameter can be: 841 * @arg @ref RTC_FLAG_WUTF 842 * @retval None 843 */ 844 #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_WUTF)) 845 846 /* WAKE-UP TIMER EXTI */ 847 /* ------------------ */ 848 /** 849 * @brief Enable interrupt on the RTC WakeUp Timer associated Exti line. 850 * @retval None 851 */ 852 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 853 854 /** 855 * @brief Disable interrupt on the RTC WakeUp Timer associated Exti line. 856 * @retval None 857 */ 858 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT)) 859 860 /** 861 * @brief Enable event on the RTC WakeUp Timer associated Exti line. 862 * @retval None 863 */ 864 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 865 866 /** 867 * @brief Disable event on the RTC WakeUp Timer associated Exti line. 868 * @retval None 869 */ 870 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT)) 871 872 /** 873 * @} 874 */ 875 876 877 878 879 880 /* ---------------------------------TIMESTAMP---------------------------------*/ 881 /** @defgroup RTCEx_Timestamp RTC Timestamp 882 * @{ 883 */ 884 /** 885 * @brief Enable the RTC TimeStamp peripheral. 886 * @param __HANDLE__ specifies the RTC handle. 887 * @retval None 888 */ 889 #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_TSE)) 890 891 /** 892 * @brief Disable the RTC TimeStamp peripheral. 893 * @param __HANDLE__ specifies the RTC handle. 894 * @retval None 895 */ 896 #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_TSE)) 897 898 /** 899 * @brief Enable the RTC TimeStamp interrupt. 900 * @param __HANDLE__ specifies the RTC handle. 901 * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be enabled. 902 * This parameter can be: 903 * @arg @ref RTC_IT_TS TimeStamp interrupt 904 * @retval None 905 */ 906 #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR |= (__INTERRUPT__)) 907 908 /** 909 * @brief Disable the RTC TimeStamp interrupt. 910 * @param __HANDLE__ specifies the RTC handle. 911 * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be disabled. 912 * This parameter can be: 913 * @arg @ref RTC_IT_TS TimeStamp interrupt 914 * @retval None 915 */ 916 #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR &= ~(__INTERRUPT__)) 917 918 /** 919 * @brief Check whether the specified RTC TimeStamp interrupt has occurred or not. 920 * @param __HANDLE__ specifies the RTC handle. 921 * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt to check. 922 * This parameter can be: 923 * @arg @ref RTC_IT_TS TimeStamp interrupt 924 * @retval None 925 */ 926 #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__) ((((RTC->MISR) & ((__INTERRUPT__)>> 12U)) != 0U) ? 1UL : 0UL) 927 /** 928 * @brief Check whether the specified RTC Time Stamp interrupt has been enabled or not. 929 * @param __HANDLE__ specifies the RTC handle. 930 * @param __INTERRUPT__ specifies the RTC Time Stamp interrupt source to check. 931 * This parameter can be: 932 * @arg @ref RTC_IT_TS TimeStamp interrupt 933 * @retval None 934 */ 935 #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((RTC->CR) & (__INTERRUPT__)) != 0U) ? 1UL : 0UL) 936 937 /** 938 * @brief Get the selected RTC TimeStamps flag status. 939 * @param __HANDLE__ specifies the RTC handle. 940 * @param __FLAG__ specifies the RTC TimeStamp Flag is pending or not. 941 * This parameter can be: 942 * @arg @ref RTC_FLAG_TSF 943 * @arg @ref RTC_FLAG_TSOVF 944 * @retval None 945 */ 946 #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__),(__FLAG__))) 947 948 /** 949 * @brief Clear the RTC Time Stamps pending flags. 950 * @param __HANDLE__ specifies the RTC handle. 951 * @param __FLAG__ specifies the RTC TimeStamp Flag to clear. 952 * This parameter can be: 953 * @arg @ref RTC_FLAG_TSF 954 * @arg @ref RTC_FLAG_TSOVF 955 * @retval None 956 */ 957 #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_CLEAR_FLAG((__HANDLE__), (__FLAG__))) 958 959 /** 960 * @brief Enable interrupt on the RTC Timestamp associated Exti line. 961 * @retval None 962 */ 963 #define __HAL_RTC_TIMESTAMP_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_TIMESTAMP_EVENT) 964 965 /** 966 * @brief Disable interrupt on the RTC Timestamp associated Exti line. 967 * @retval None 968 */ 969 #define __HAL_RTC_TIMESTAMP_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_TIMESTAMP_EVENT)) 970 971 /** 972 * @brief Enable event on the RTC Timestamp associated Exti line. 973 * @retval None 974 */ 975 #define __HAL_RTC_TIMESTAMP_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_TIMESTAMP_EVENT) 976 977 /** 978 * @brief Disable event on the RTC Timestamp associated Exti line. 979 * @retval None 980 */ 981 #define __HAL_RTC_TIMESTAMP_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_TIMESTAMP_EVENT)) 982 983 /** 984 * @brief Enable the RTC internal TimeStamp peripheral. 985 * @param __HANDLE__ specifies the RTC handle. 986 * @retval None 987 */ 988 #define __HAL_RTC_INTERNAL_TIMESTAMP_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_ITSE)) 989 990 /** 991 * @brief Disable the RTC internal TimeStamp peripheral. 992 * @param __HANDLE__ specifies the RTC handle. 993 * @retval None 994 */ 995 #define __HAL_RTC_INTERNAL_TIMESTAMP_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_ITSE)) 996 997 /** 998 * @brief Get the selected RTC Internal Time Stamps flag status. 999 * @param __HANDLE__ specifies the RTC handle. 1000 * @param __FLAG__ specifies the RTC Internal Time Stamp Flag is pending or not. 1001 * This parameter can be: 1002 * @arg @ref RTC_FLAG_ITSF 1003 * @retval None 1004 */ 1005 #define __HAL_RTC_INTERNAL_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__),(__FLAG__))) 1006 1007 /** 1008 * @brief Clear the RTC Internal Time Stamps pending flags. 1009 * @param __HANDLE__ specifies the RTC handle. 1010 * @param __FLAG__ specifies the RTC Internal Time Stamp Flag source to clear. 1011 * This parameter can be: 1012 * @arg @ref RTC_FLAG_ITSF 1013 * @retval None 1014 */ 1015 #define __HAL_RTC_INTERNAL_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_ITSF)) 1016 1017 /** 1018 * @brief Enable the RTC TimeStamp on Tamper detection. 1019 * @param __HANDLE__ specifies the RTC handle. 1020 * @retval None 1021 */ 1022 #define __HAL_RTC_TAMPTS_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_TAMPTS)) 1023 1024 /** 1025 * @brief Disable the RTC TimeStamp on Tamper detection. 1026 * @param __HANDLE__ specifies the RTC handle. 1027 * @retval None 1028 */ 1029 #define __HAL_RTC_TAMPTS_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_TAMPTS)) 1030 1031 /** 1032 * @brief Enable the RTC Tamper detection output. 1033 * @param __HANDLE__ specifies the RTC handle. 1034 * @retval None 1035 */ 1036 #define __HAL_RTC_TAMPOE_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_TAMPOE)) 1037 1038 /** 1039 * @brief Disable the RTC Tamper detection output. 1040 * @param __HANDLE__ specifies the RTC handle. 1041 * @retval None 1042 */ 1043 #define __HAL_RTC_TAMPOE_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_TAMPOE)) 1044 1045 1046 /** 1047 * @} 1048 */ 1049 1050 1051 /* ------------------------------Calibration----------------------------------*/ 1052 /** @defgroup RTCEx_Calibration RTC Calibration 1053 * @{ 1054 */ 1055 1056 /** 1057 * @brief Enable the RTC calibration output. 1058 * @param __HANDLE__ specifies the RTC handle. 1059 * @retval None 1060 */ 1061 #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_COE)) 1062 1063 /** 1064 * @brief Disable the calibration output. 1065 * @param __HANDLE__ specifies the RTC handle. 1066 * @retval None 1067 */ 1068 #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_COE)) 1069 1070 1071 /** 1072 * @brief Enable the clock reference detection. 1073 * @param __HANDLE__ specifies the RTC handle. 1074 * @retval None 1075 */ 1076 #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_REFCKON)) 1077 1078 /** 1079 * @brief Disable the clock reference detection. 1080 * @param __HANDLE__ specifies the RTC handle. 1081 * @retval None 1082 */ 1083 #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_REFCKON)) 1084 1085 1086 /** 1087 * @brief Get the selected RTC shift operations flag status. 1088 * @param __HANDLE__ specifies the RTC handle. 1089 * @param __FLAG__ specifies the RTC shift operation Flag is pending or not. 1090 * This parameter can be: 1091 * @arg @ref RTC_FLAG_SHPF 1092 * @retval None 1093 */ 1094 #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__))) 1095 /** 1096 * @} 1097 */ 1098 1099 1100 /* ------------------------------Tamper----------------------------------*/ 1101 /** @defgroup RTCEx_Tamper RTCEx tamper 1102 * @{ 1103 */ 1104 /** 1105 * @brief Enable the TAMP Tamper input detection. 1106 * @param __HANDLE__ specifies the RTC handle. 1107 * @param __TAMPER__ specifies the RTC Tamper source to be enabled. 1108 * This parameter can be any combination of the following values: 1109 * @arg RTC_TAMPER_ALL: All tampers 1110 * @arg RTC_TAMPER_1: Tamper1 1111 * @arg RTC_TAMPER_2: Tamper2 1112 * @arg RTC_TAMPER_3: Tamper3 1113 * @arg RTC_TAMPER_4: Tamper4 1114 * @arg RTC_TAMPER_5: Tamper5 1115 * @arg RTC_TAMPER_6: Tamper6 1116 * @arg RTC_TAMPER_7: Tamper7 1117 * @arg RTC_TAMPER_8: Tamper8 1118 * @arg RTC_IT_INT_TAMP_ALL: All internal tampers interrupts 1119 * @arg RTC_IT_INT_TAMP_1: Internal Tamper1 interrupt 1120 * @arg RTC_IT_INT_TAMP_2: Internal Tamper2 interrupt 1121 * @arg RTC_IT_INT_TAMP_3: Internal Tamper3 interrupt 1122 * @arg RTC_IT_INT_TAMP_5: Internal Tamper5 interrupt 1123 * @arg RTC_IT_INT_TAMP_8: Internal Tamper8 interrupt 1124 * @retval None 1125 */ 1126 #define __HAL_RTC_TAMPER_ENABLE(__HANDLE__, __TAMPER__) (TAMP->CR1 |= (__TAMPER__)) 1127 1128 /** 1129 * @brief Disable the TAMP Tamper input detection. 1130 * @param __HANDLE__ specifies the RTC handle. 1131 * @param __TAMPER__ specifies the RTC Tamper sources to be enabled. 1132 * This parameter can be any combination of the following values: 1133 * @arg RTC_TAMPER_ALL: All tampers 1134 * @arg RTC_TAMPER_1: Tamper1 1135 * @arg RTC_TAMPER_2: Tamper2 1136 * @arg RTC_TAMPER_3: Tamper3 1137 * @arg RTC_TAMPER_4: Tamper4 1138 * @arg RTC_TAMPER_5: Tamper5 1139 * @arg RTC_TAMPER_6: Tamper6 1140 * @arg RTC_TAMPER_7: Tamper7 1141 * @arg RTC_TAMPER_8: Tamper8 1142 * @arg RTC_IT_INT_TAMP_ALL: All internal tampers interrupts 1143 * @arg RTC_IT_INT_TAMP_1: Internal Tamper1 interrupt 1144 * @arg RTC_IT_INT_TAMP_2: Internal Tamper2 interrupt 1145 * @arg RTC_IT_INT_TAMP_3: Internal Tamper3 interrupt 1146 * @arg RTC_IT_INT_TAMP_5: Internal Tamper5 interrupt 1147 * @arg RTC_IT_INT_TAMP_8: Internal Tamper8 interrupt 1148 */ 1149 #define __HAL_RTC_TAMPER_DISABLE(__HANDLE__, __TAMPER__) (TAMP->CR1 &= ~(__TAMPER__)) 1150 1151 1152 /**************************************************************************************************/ 1153 /** 1154 * @brief Enable the TAMP Tamper interrupt. 1155 * @param __HANDLE__ specifies the RTC handle. 1156 * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be enabled. 1157 * This parameter can be any combination of the following values: 1158 * @arg RTC_IT_TAMP_ALL: All tampers interrupts 1159 * @arg RTC_IT_TAMP_1: Tamper1 interrupt 1160 * @arg RTC_IT_TAMP_2: Tamper2 interrupt 1161 * @arg RTC_IT_TAMP_3: Tamper3 interrupt 1162 * @arg RTC_IT_TAMP_4: Tamper4 interrupt 1163 * @arg RTC_IT_TAMP_5: Tamper5 interrupt 1164 * @arg RTC_IT_TAMP_6: Tamper6 interrupt 1165 * @arg RTC_IT_TAMP_7: Tamper7 interrupt 1166 * @arg RTC_IT_TAMP_8: Tamper8 interrupt 1167 * @arg RTC_IT_INT_TAMP_ALL: All internal tampers interrupts 1168 * @arg RTC_IT_INT_TAMP_1: Internal Tamper1 interrupt 1169 * @arg RTC_IT_INT_TAMP_2: Internal Tamper2 interrupt 1170 * @arg RTC_IT_INT_TAMP_3: Internal Tamper3 interrupt 1171 * @arg RTC_IT_INT_TAMP_5: Internal Tamper5 interrupt 1172 * @arg RTC_IT_INT_TAMP_8: Internal Tamper8 interrupt 1173 * @retval None 1174 */ 1175 #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) (TAMP->IER |= (__INTERRUPT__)) 1176 1177 /** 1178 * @brief Disable the TAMP Tamper interrupt. 1179 * @param __HANDLE__ specifies the RTC handle. 1180 * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be disabled. 1181 * This parameter can be any combination of the following values: 1182 * @arg RTC_IT_TAMP_ALL: All tampers interrupts 1183 * @arg RTC_IT_TAMP_1: Tamper1 interrupt 1184 * @arg RTC_IT_TAMP_2: Tamper2 interrupt 1185 * @arg RTC_IT_TAMP_3: Tamper3 interrupt 1186 * @arg RTC_IT_TAMP_4: Tamper4 interrupt 1187 * @arg RTC_IT_TAMP_5: Tamper5 interrupt 1188 * @arg RTC_IT_TAMP_6: Tamper6 interrupt 1189 * @arg RTC_IT_TAMP_7: Tamper7 interrupt 1190 * @arg RTC_IT_TAMP_8: Tamper8 interrupt 1191 * @arg RTC_IT_INT_TAMP_ALL: All internal tampers interrupts 1192 * @arg RTC_IT_INT_TAMP_1: Internal Tamper1 interrupt 1193 * @arg RTC_IT_INT_TAMP_2: Internal Tamper2 interrupt 1194 * @arg RTC_IT_INT_TAMP_3: Internal Tamper3 interrupt 1195 * @arg RTC_IT_INT_TAMP_5: Internal Tamper5 interrupt 1196 * @arg RTC_IT_INT_TAMP_8: Internal Tamper8 interrupt 1197 * @retval None 1198 */ 1199 #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) (TAMP->IER &= ~(__INTERRUPT__)) 1200 1201 1202 /**************************************************************************************************/ 1203 /** 1204 * @brief Check whether the specified RTC Tamper interrupt has occurred or not. 1205 * @param __HANDLE__ specifies the RTC handle. 1206 * @param __INTERRUPT__ specifies the RTC Tamper interrupt to check. 1207 * This parameter can be: 1208 * @arg RTC_IT_TAMP_ALL: All tampers interrupts 1209 * @arg RTC_IT_TAMP_1: Tamper1 interrupt 1210 * @arg RTC_IT_TAMP_2: Tamper2 interrupt 1211 * @arg RTC_IT_TAMP_3: Tamper3 interrupt 1212 * @arg RTC_IT_TAMP_4: Tamper4 interrupt 1213 * @arg RTC_IT_TAMP_5: Tamper5 interrupt 1214 * @arg RTC_IT_TAMP_6: Tamper6 interrupt 1215 * @arg RTC_IT_TAMP_7: Tamper7 interrupt 1216 * @arg RTC_IT_TAMP_8: Tamper8 interrupt 1217 * @arg RTC_IT_INT_TAMP_ALL: All Internal Tamper interrupts 1218 * @arg RTC_IT_INT_TAMP_1: Internal Tamper1 interrupt 1219 * @arg RTC_IT_INT_TAMP_2: Internal Tamper2 interrupt 1220 * @arg RTC_IT_INT_TAMP_3: Internal Tamper3 interrupt 1221 * @arg RTC_IT_INT_TAMP_5: Internal Tamper5 interrupt 1222 * @arg RTC_IT_INT_TAMP_8: Internal Tamper8 interrupt 1223 * @retval None 1224 */ 1225 #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) ((((TAMP->MISR) & (__INTERRUPT__)) != 0U) ? 1UL : 0UL) 1226 1227 1228 /** 1229 * @brief Check whether the specified RTC Tamper interrupt has been enabled or not. 1230 * @param __HANDLE__ specifies the RTC handle. 1231 * @param __INTERRUPT__ specifies the RTC Tamper interrupt source to check. 1232 * This parameter can be: 1233 * @arg RTC_IT_TAMP_ALL: All tampers interrupts 1234 * @arg RTC_IT_TAMP_1: Tamper1 interrupt 1235 * @arg RTC_IT_TAMP_2: Tamper2 interrupt 1236 * @arg RTC_IT_TAMP_3: Tamper3 interrupt 1237 * @arg RTC_IT_TAMP_4: Tamper4 interrupt 1238 * @arg RTC_IT_TAMP_5: Tamper5 interrupt 1239 * @arg RTC_IT_TAMP_6: Tamper6 interrupt 1240 * @arg RTC_IT_TAMP_7: Tamper7 interrupt 1241 * @arg RTC_IT_TAMP_8: Tamper8 interrupt 1242 * @arg RTC_IT_INT_TAMP_ALL: All internal tampers interrupts 1243 * @arg RTC_IT_INT_TAMP_1: Internal Tamper1 interrupt 1244 * @arg RTC_IT_INT_TAMP_2: Internal Tamper2 interrupt 1245 * @arg RTC_IT_INT_TAMP_3: Internal Tamper3 interrupt 1246 * @arg RTC_IT_INT_TAMP_5: Internal Tamper5 interrupt 1247 * @arg RTC_IT_INT_TAMP_8: Internal Tamper8 interrupt 1248 * @retval None 1249 */ 1250 #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((TAMP->IER) & (__INTERRUPT__)) != 0U) ? 1UL : 0UL) 1251 1252 1253 /** 1254 * @brief Get the selected RTC Tampers flag status. 1255 * @param __HANDLE__ specifies the RTC handle. 1256 * @param __FLAG__ specifies the RTC Tamper Flag is pending or not. 1257 * This parameter can be: 1258 * @arg RTC_FLAG_TAMP_ALL: All tampers flag 1259 * @arg RTC_FLAG_TAMP_1: Tamper1 flag 1260 * @arg RTC_FLAG_TAMP_2: Tamper2 flag 1261 * @arg RTC_FLAG_TAMP_3: Tamper3 flag 1262 * @arg RTC_FLAG_TAMP_4: Tamper4 flag 1263 * @arg RTC_FLAG_TAMP_5: Tamper5 flag 1264 * @arg RTC_FLAG_TAMP_6: Tamper6 flag 1265 * @arg RTC_FLAG_TAMP_7: Tamper7 flag 1266 * @arg RTC_FLAG_TAMP_8: Tamper8 flag 1267 * @arg RTC_FLAG_INT_TAMP_1: Internal Tamper1 flag 1268 * @arg RTC_FLAG_INT_TAMP_2: Internal Tamper2 flag 1269 * @arg RTC_FLAG_INT_TAMP_3: Internal Tamper3 flag 1270 * @arg RTC_FLAG_INT_TAMP_5: Internal Tamper5 flag 1271 * @arg RTC_FLAG_INT_TAMP_8: Internal Tamper8 flag 1272 * @retval None 1273 */ 1274 #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((TAMP->SR) & (__FLAG__)) != 0U) 1275 1276 /** 1277 * @brief Clear the RTC Tamper's pending flags. 1278 * @param __HANDLE__ specifies the RTC handle. 1279 * @param __FLAG__ specifies the RTC Tamper Flag to clear. 1280 * This parameter can be: 1281 * @arg RTC_FLAG_TAMP_ALL: All tampers flag 1282 * @arg RTC_FLAG_TAMP_1: Tamper1 flag 1283 * @arg RTC_FLAG_TAMP_2: Tamper2 flag 1284 * @arg RTC_FLAG_TAMP_3: Tamper3 flag 1285 * @arg RTC_FLAG_TAMP_4: Tamper4 flag 1286 * @arg RTC_FLAG_TAMP_5: Tamper5 flag 1287 * @arg RTC_FLAG_TAMP_6: Tamper6 flag 1288 * @arg RTC_FLAG_TAMP_7: Tamper7 flag 1289 * @arg RTC_FLAG_TAMP_8: Tamper8 flag 1290 * @arg RTC_FLAG_INT_TAMP_ALL: All Internal Tamper flags 1291 * @arg RTC_FLAG_INT_TAMP_1: Internal Tamper1 flag 1292 * @arg RTC_FLAG_INT_TAMP_2: Internal Tamper2 flag 1293 * @arg RTC_FLAG_INT_TAMP_3: Internal Tamper3 flag 1294 * @arg RTC_FLAG_INT_TAMP_5: Internal Tamper5 flag 1295 * @arg RTC_FLAG_INT_TAMP_8: Internal Tamper8 flag 1296 * @retval None 1297 */ 1298 #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((TAMP->SCR) = (__FLAG__)) 1299 1300 /** 1301 * @brief Enable interrupt on the RTC tamper associated Exti line. 1302 * @retval None 1303 */ 1304 #define __HAL_RTC_TAMPER_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_TAMPER_EVENT) 1305 1306 /** 1307 * @brief Disable interrupt on the RTC tamper associated Exti line. 1308 * @retval None 1309 */ 1310 #define __HAL_RTC_TAMPER_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_TAMPER_EVENT)) 1311 1312 /** 1313 * @brief Enable event on the RTC tamper associated Exti line. 1314 * @retval None 1315 */ 1316 #define __HAL_RTC_TAMPER_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_TAMPER_EVENT) 1317 1318 /** 1319 * @brief Disable event on the RTC tamper associated Exti line. 1320 * @retval None 1321 */ 1322 #define __HAL_RTC_TAMPER_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_TAMPER_EVENT)) 1323 1324 /** 1325 * @} 1326 */ 1327 1328 /** 1329 * @} 1330 */ 1331 1332 /* Exported functions --------------------------------------------------------*/ 1333 /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions 1334 * @{ 1335 */ 1336 1337 /* RTC TimeStamp functions *****************************************/ 1338 /** @defgroup RTCEx_Exported_Functions_Group1 Extended RTC TimeStamp functions 1339 * @{ 1340 */ 1341 1342 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin); 1343 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin); 1344 HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc); 1345 HAL_StatusTypeDef HAL_RTCEx_SetInternalTimeStamp(RTC_HandleTypeDef *hrtc); 1346 HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTimeStamp(RTC_HandleTypeDef *hrtc); 1347 HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format); 1348 void HAL_RTCEx_TimeStampIRQHandler(RTC_HandleTypeDef *hrtc); 1349 HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 1350 void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc); 1351 /** 1352 * @} 1353 */ 1354 1355 1356 /* RTC Wake-up functions ******************************************************/ 1357 /** @defgroup RTCEx_Exported_Functions_Group2 Extended RTC Wake-up functions 1358 * @{ 1359 */ 1360 1361 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock); 1362 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock, uint32_t WakeUpAutoClr); 1363 HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc); 1364 uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc); 1365 void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc); 1366 void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc); 1367 HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 1368 /** 1369 * @} 1370 */ 1371 1372 /* Extended Control functions ************************************************/ 1373 /** @defgroup RTCEx_Exported_Functions_Group3 Extended Peripheral Control functions 1374 * @{ 1375 */ 1376 1377 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue); 1378 HAL_StatusTypeDef HAL_RTCEx_SetLowPowerCalib(RTC_HandleTypeDef *hrtc, uint32_t LowPowerCalib); 1379 HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS); 1380 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput); 1381 HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc); 1382 HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc); 1383 HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc); 1384 HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc); 1385 HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc); 1386 HAL_StatusTypeDef HAL_RTCEx_MonotonicCounterIncrement(RTC_HandleTypeDef *hrtc, uint32_t Instance); 1387 HAL_StatusTypeDef HAL_RTCEx_MonotonicCounterGet(RTC_HandleTypeDef *hrtc, uint32_t Instance, uint32_t *Value); 1388 /** 1389 * @} 1390 */ 1391 1392 /* Extended RTC features functions *******************************************/ 1393 /** @defgroup RTCEx_Exported_Functions_Group4 Extended features functions 1394 * @{ 1395 */ 1396 1397 void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc); 1398 HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 1399 /** 1400 * @} 1401 */ 1402 1403 /** @defgroup RTCEx_Exported_Functions_Group5 Extended RTC Tamper functions 1404 * @{ 1405 */ 1406 HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper); 1407 HAL_StatusTypeDef HAL_RTCEx_SetActiveTampers(RTC_HandleTypeDef *hrtc, RTC_ActiveTampersTypeDef *sAllTamper); 1408 HAL_StatusTypeDef HAL_RTCEx_SetActiveSeed(RTC_HandleTypeDef *hrtc, uint32_t *pSeed); 1409 HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper); 1410 HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper); 1411 HAL_StatusTypeDef HAL_RTCEx_DeactivateActiveTampers(RTC_HandleTypeDef *hrtc); 1412 HAL_StatusTypeDef HAL_RTCEx_PollForTamperEvent(RTC_HandleTypeDef *hrtc, uint32_t Tamper, uint32_t Timeout); 1413 HAL_StatusTypeDef HAL_RTCEx_SetInternalTamper(RTC_HandleTypeDef *hrtc, RTC_InternalTamperTypeDef *sIntTamper); 1414 HAL_StatusTypeDef HAL_RTCEx_SetInternalTamper_IT(RTC_HandleTypeDef *hrtc, RTC_InternalTamperTypeDef *sIntTamper); 1415 HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTamper(RTC_HandleTypeDef *hrtc, uint32_t IntTamper); 1416 HAL_StatusTypeDef HAL_RTCEx_PollForInternalTamperEvent(RTC_HandleTypeDef *hrtc, uint32_t IntTamper, uint32_t Timeout); 1417 void HAL_RTCEx_TamperIRQHandler(RTC_HandleTypeDef *hrtc); 1418 void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc); 1419 void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc); 1420 void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc); 1421 void HAL_RTCEx_Tamper4EventCallback(RTC_HandleTypeDef *hrtc); 1422 void HAL_RTCEx_Tamper5EventCallback(RTC_HandleTypeDef *hrtc); 1423 void HAL_RTCEx_Tamper6EventCallback(RTC_HandleTypeDef *hrtc); 1424 void HAL_RTCEx_Tamper7EventCallback(RTC_HandleTypeDef *hrtc); 1425 void HAL_RTCEx_Tamper8EventCallback(RTC_HandleTypeDef *hrtc); 1426 void HAL_RTCEx_InternalTamper1EventCallback(RTC_HandleTypeDef *hrtc); 1427 void HAL_RTCEx_InternalTamper2EventCallback(RTC_HandleTypeDef *hrtc); 1428 void HAL_RTCEx_InternalTamper3EventCallback(RTC_HandleTypeDef *hrtc); 1429 void HAL_RTCEx_InternalTamper5EventCallback(RTC_HandleTypeDef *hrtc); 1430 void HAL_RTCEx_InternalTamper8EventCallback(RTC_HandleTypeDef *hrtc); 1431 void HAL_RTCEx_EnableTemperatureMonitoring(RTC_HandleTypeDef *hrtc); 1432 void HAL_RTCEx_DisableTemperatureMonitoring(RTC_HandleTypeDef *hrtc); 1433 void HAL_RTCEx_EnableVoltageMonitoring(RTC_HandleTypeDef *hrtc); 1434 void HAL_RTCEx_DisableVoltageMonitoring(RTC_HandleTypeDef *hrtc); 1435 void HAL_RTCEx_EnableWUTMonitoring(RTC_HandleTypeDef *hrtc); 1436 void HAL_RTCEx_DisableWUTMonitoring(RTC_HandleTypeDef *hrtc); 1437 /** 1438 * @} 1439 */ 1440 1441 /** @defgroup RTCEx_Exported_Functions_Group6 Extended RTC Backup register functions 1442 * @{ 1443 */ 1444 void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data); 1445 uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister); 1446 /** 1447 * @} 1448 */ 1449 1450 /** @defgroup RTCEx_Exported_Functions_Group7 Extended RTC secure functions 1451 * @{ 1452 */ 1453 HAL_StatusTypeDef HAL_RTCEx_SecureModeGet(RTC_HandleTypeDef *hrtc, RTC_SecureStateTypeDef *secureState); 1454 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) 1455 HAL_StatusTypeDef HAL_RTCEx_SecureModeSet(RTC_HandleTypeDef *hrtc, RTC_SecureStateTypeDef *secureState); 1456 #endif /* #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ 1457 /** 1458 * @} 1459 */ 1460 1461 /** @defgroup RTCEx_Exported_Functions_Group8 Extended RTC privilege functions 1462 * @{ 1463 */ 1464 HAL_StatusTypeDef HAL_RTCEx_PrivilegeModeSet(RTC_HandleTypeDef *hrtc, RTC_PrivilegeStateTypeDef *privilegeState); 1465 HAL_StatusTypeDef HAL_RTCEx_PrivilegeModeGet(RTC_HandleTypeDef *hrtc, RTC_PrivilegeStateTypeDef *privilegeState); 1466 /** 1467 * @} 1468 */ 1469 1470 /** 1471 * @} 1472 */ 1473 1474 /* Private types -------------------------------------------------------------*/ 1475 /* Private variables ---------------------------------------------------------*/ 1476 /* Private constants ---------------------------------------------------------*/ 1477 /** @defgroup RTCEx_Private_Constants RTCEx Private Constants 1478 * @{ 1479 */ 1480 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) 1481 #define RTC_EXTI_LINE_ALARM_EVENT EXTI_IMR1_IM18 /*!< External interrupt line 18 Connected to the RTC Alarm event */ 1482 #define RTC_EXTI_LINE_TIMESTAMP_EVENT EXTI_IMR1_IM18 /*!< External interrupt line 18 Connected to the RTC Time Stamp events */ 1483 #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT EXTI_IMR1_IM18 /*!< External interrupt line 18 Connected to the RTC Wakeup event */ 1484 #define RTC_EXTI_LINE_TAMPER_EVENT EXTI_IMR1_IM20 /*!< External interrupt line 20 Connected to the RTC tamper events */ 1485 #else /* #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ 1486 #define RTC_EXTI_LINE_ALARM_EVENT EXTI_IMR1_IM17 /*!< External interrupt line 17 Connected to the RTC Alarm event */ 1487 #define RTC_EXTI_LINE_TIMESTAMP_EVENT EXTI_IMR1_IM17 /*!< External interrupt line 17 Connected to the RTC Time Stamp events */ 1488 #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT EXTI_IMR1_IM17 /*!< External interrupt line 17 Connected to the RTC Wakeup event */ 1489 #define RTC_EXTI_LINE_TAMPER_EVENT EXTI_IMR1_IM19 /*!< External interrupt line 19 Connected to the RTC tamper events */ 1490 #endif /* #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ 1491 /** 1492 * @} 1493 */ 1494 1495 /* Private macros ------------------------------------------------------------*/ 1496 /** @defgroup RTCEx_Private_Macros RTCEx Private Macros 1497 * @{ 1498 */ 1499 1500 /** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters 1501 * @{ 1502 */ 1503 #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \ 1504 ((EDGE) == RTC_TIMESTAMPEDGE_FALLING)) 1505 1506 1507 #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TIMESTAMPPIN_DEFAULT)) 1508 1509 1510 1511 #define IS_RTC_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \ 1512 ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE)) 1513 1514 #define IS_RTC_TAMPER_TAMPERDETECTIONOUTPUT(MODE) (((MODE) == RTC_TAMPERDETECTIONOUTPUT_ENABLE) || \ 1515 ((MODE) == RTC_TAMPERDETECTIONOUTPUT_DISABLE)) 1516 1517 #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \ 1518 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \ 1519 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \ 1520 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \ 1521 ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \ 1522 ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS)) 1523 1524 #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= RTC_WUTR_WUT) 1525 1526 #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \ 1527 ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \ 1528 ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC)) 1529 1530 #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \ 1531 ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET)) 1532 1533 #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= RTC_CALR_CALM) 1534 1535 #define IS_RTC_LOW_POWER_CALIB(LPCAL) (((LPCAL) == RTC_LPCAL_SET) || \ 1536 ((LPCAL) == RTC_LPCAL_RESET)) 1537 1538 1539 #define IS_RTC_TAMPER(__TAMPER__) ((((__TAMPER__) & RTC_TAMPER_ALL) != 0x00U) && \ 1540 (((__TAMPER__) & ~RTC_TAMPER_ALL) == 0x00U)) 1541 1542 #define IS_RTC_INTERNAL_TAMPER(__INT_TAMPER__) ((((__INT_TAMPER__) & RTC_INT_TAMPER_ALL) != 0x00U) && \ 1543 (((__INT_TAMPER__) & ~RTC_INT_TAMPER_ALL) == 0x00U)) 1544 1545 #define IS_RTC_TAMPER_TRIGGER(__TRIGGER__) (((__TRIGGER__) == RTC_TAMPERTRIGGER_RISINGEDGE) || \ 1546 ((__TRIGGER__) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \ 1547 ((__TRIGGER__) == RTC_TAMPERTRIGGER_LOWLEVEL) || \ 1548 ((__TRIGGER__) == RTC_TAMPERTRIGGER_HIGHLEVEL)) 1549 1550 #define IS_RTC_TAMPER_ERASE_MODE(__MODE__) (((__MODE__) == RTC_TAMPER_ERASE_BACKUP_ENABLE) || \ 1551 ((__MODE__) == RTC_TAMPER_ERASE_BACKUP_DISABLE)) 1552 1553 #define IS_RTC_TAMPER_MASKFLAG_STATE(__STATE__) (((__STATE__) == RTC_TAMPERMASK_FLAG_ENABLE) || \ 1554 ((__STATE__) == RTC_TAMPERMASK_FLAG_DISABLE)) 1555 1556 #define IS_RTC_TAMPER_FILTER(__FILTER__) (((__FILTER__) == RTC_TAMPERFILTER_DISABLE) || \ 1557 ((__FILTER__) == RTC_TAMPERFILTER_2SAMPLE) || \ 1558 ((__FILTER__) == RTC_TAMPERFILTER_4SAMPLE) || \ 1559 ((__FILTER__) == RTC_TAMPERFILTER_8SAMPLE)) 1560 1561 #define IS_RTC_TAMPER_SAMPLING_FREQ(__FREQ__) (((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \ 1562 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \ 1563 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \ 1564 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \ 1565 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \ 1566 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \ 1567 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \ 1568 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256)) 1569 1570 #define IS_RTC_TAMPER_PRECHARGE_DURATION(__DURATION__) (((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \ 1571 ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \ 1572 ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \ 1573 ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK)) 1574 1575 #define IS_RTC_TAMPER_PULLUP_STATE(__STATE__) (((__STATE__) == RTC_TAMPER_PULLUP_ENABLE) || \ 1576 ((__STATE__) == RTC_TAMPER_PULLUP_DISABLE)) 1577 1578 #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \ 1579 ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE)) 1580 1581 #define IS_RTC_BKP(__BKP__) ((__BKP__) < RTC_BKP_NUMBER) 1582 1583 #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \ 1584 ((SEL) == RTC_SHIFTADD1S_SET)) 1585 1586 #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= RTC_SHIFTR_SUBFS) 1587 1588 #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \ 1589 ((OUTPUT) == RTC_CALIBOUTPUT_1HZ)) 1590 1591 #define IS_RTC_SECURE_FULL(__STATE__) (((__STATE__) == RTC_SECURE_FULL_YES) || \ 1592 ((__STATE__) == RTC_SECURE_FULL_NO)) 1593 1594 #define IS_RTC_NONSECURE_FEATURES(__FEATURES__) (((__FEATURES__) & ~RTC_NONSECURE_FEATURE_ALL) == 0u) 1595 1596 #define IS_TAMP_SECURE_FULL(__STATE__) (((__STATE__) == TAMP_SECURE_FULL_YES) || \ 1597 ((__STATE__) == TAMP_SECURE_FULL_NO)) 1598 1599 #define IS_RTC_PRIVILEGE_FULL(__STATE__) (((__STATE__) == RTC_PRIVILEGE_FULL_YES) || \ 1600 ((__STATE__) == RTC_PRIVILEGE_FULL_NO)) 1601 1602 #define IS_RTC_PRIVILEGE_FEATURES(__FEATURES__) (((__FEATURES__) & ~RTC_PRIVILEGE_FEATURE_ALL) == 0u) 1603 1604 #define IS_TAMP_PRIVILEGE_FULL(__STATE__) (((__STATE__) == TAMP_PRIVILEGE_FULL_YES) || \ 1605 ((__STATE__) == TAMP_PRIVILEGE_FULL_NO)) 1606 1607 #define IS_RTC_PRIVILEGE_BKUP_ZONE(__ZONES__) (((__ZONES__) & ~RTC_PRIVILEGE_BKUP_ZONE_ALL) == 0u) 1608 1609 /** 1610 * @} 1611 */ 1612 1613 /** 1614 * @} 1615 */ 1616 1617 /** 1618 * @} 1619 */ 1620 1621 /** 1622 * @} 1623 */ 1624 1625 #ifdef __cplusplus 1626 } 1627 #endif 1628 1629 #endif /* STM32L5xx_HAL_RTC_EX_H */ 1630 1631