1 /** 2 ****************************************************************************** 3 * @file stm32f4xx_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) 2017 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 STM32F4xx_HAL_RTC_EX_H 21 #define STM32F4xx_HAL_RTC_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 29 #include "stm32f4xx_hal_def.h" 30 31 /** @addtogroup STM32F4xx_HAL_Driver 32 * @{ 33 */ 34 35 /** @addtogroup RTCEx 36 * @{ 37 */ 38 39 /* Exported types ------------------------------------------------------------*/ 40 41 /** @defgroup RTCEx_Exported_Types RTCEx Exported Types 42 * @{ 43 */ 44 45 /** 46 * @brief RTC Tamper structure definition 47 */ 48 typedef struct 49 { 50 uint32_t Tamper; /*!< Specifies the Tamper Pin. 51 This parameter can be a value of @ref RTCEx_Tamper_Pin_Definitions */ 52 53 uint32_t PinSelection; /*!< Specifies the Tamper Pin. 54 This parameter can be a value of @ref RTCEx_Tamper_Pin_Selection */ 55 56 uint32_t Trigger; /*!< Specifies the Tamper Trigger. 57 This parameter can be a value of @ref RTCEx_Tamper_Trigger_Definitions */ 58 59 uint32_t Filter; /*!< Specifies the RTC Filter Tamper. 60 This parameter can be a value of @ref RTCEx_Tamper_Filter_Definitions */ 61 62 uint32_t SamplingFrequency; /*!< Specifies the sampling frequency. 63 This parameter can be a value of @ref RTCEx_Tamper_Sampling_Frequencies_Definitions */ 64 65 uint32_t PrechargeDuration; /*!< Specifies the Precharge Duration . 66 This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration_Definitions */ 67 68 uint32_t TamperPullUp; /*!< Specifies the Tamper PullUp . 69 This parameter can be a value of @ref RTCEx_Tamper_Pull_Up_Definitions */ 70 71 uint32_t TimeStampOnTamperDetection; /*!< Specifies the TimeStampOnTamperDetection. 72 This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection_Definitions */ 73 } RTC_TamperTypeDef; 74 /** 75 * @} 76 */ 77 78 /* Exported constants --------------------------------------------------------*/ 79 80 /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants 81 * @{ 82 */ 83 84 /** @defgroup RTCEx_Backup_Registers_Definitions RTCEx Backup Registers Definitions 85 * @{ 86 */ 87 #define RTC_BKP_DR0 0x00000000U 88 #define RTC_BKP_DR1 0x00000001U 89 #define RTC_BKP_DR2 0x00000002U 90 #define RTC_BKP_DR3 0x00000003U 91 #define RTC_BKP_DR4 0x00000004U 92 #define RTC_BKP_DR5 0x00000005U 93 #define RTC_BKP_DR6 0x00000006U 94 #define RTC_BKP_DR7 0x00000007U 95 #define RTC_BKP_DR8 0x00000008U 96 #define RTC_BKP_DR9 0x00000009U 97 #define RTC_BKP_DR10 0x0000000AU 98 #define RTC_BKP_DR11 0x0000000BU 99 #define RTC_BKP_DR12 0x0000000CU 100 #define RTC_BKP_DR13 0x0000000DU 101 #define RTC_BKP_DR14 0x0000000EU 102 #define RTC_BKP_DR15 0x0000000FU 103 #define RTC_BKP_DR16 0x00000010U 104 #define RTC_BKP_DR17 0x00000011U 105 #define RTC_BKP_DR18 0x00000012U 106 #define RTC_BKP_DR19 0x00000013U 107 /** 108 * @} 109 */ 110 111 /** @defgroup RTCEx_Timestamp_Edges_Definitions RTCEx Timestamp Edges Definitions 112 * @{ 113 */ 114 #define RTC_TIMESTAMPEDGE_RISING 0x00000000U 115 #define RTC_TIMESTAMPEDGE_FALLING RTC_CR_TSEDGE 116 /** 117 * @} 118 */ 119 120 /** @defgroup RTCEx_Timestamp_Pin_Selection RTC Timestamp Pin Selection 121 * @{ 122 */ 123 #define RTC_TIMESTAMPPIN_DEFAULT 0x00000000U 124 #if defined(RTC_AF2_SUPPORT) 125 #define RTC_TIMESTAMPPIN_POS1 RTC_TAFCR_TSINSEL 126 #endif /* RTC_AF2_SUPPORT */ 127 /** 128 * @} 129 */ 130 131 /** @defgroup RTCEx_Tamper_Pin_Definitions RTCEx Tamper Pins Definitions 132 * @{ 133 */ 134 #define RTC_TAMPER_1 RTC_TAFCR_TAMP1E 135 #if defined(RTC_TAMPER2_SUPPORT) 136 #define RTC_TAMPER_2 RTC_TAFCR_TAMP2E 137 #endif /* RTC_TAMPER2_SUPPORT */ 138 /** 139 * @} 140 */ 141 142 /** @defgroup RTCEx_Tamper_Pin_Selection RTC tamper Pins Selection 143 * @{ 144 */ 145 #define RTC_TAMPERPIN_DEFAULT 0x00000000U 146 #if defined(RTC_AF2_SUPPORT) 147 #define RTC_TAMPERPIN_POS1 RTC_TAFCR_TAMP1INSEL 148 #endif /* RTC_AF2_SUPPORT */ 149 /** 150 * @} 151 */ 152 153 /** @defgroup RTCEx_Tamper_Interrupt_Definitions RTCEx Tamper Interrupt Definitions 154 * @{ 155 */ 156 #define RTC_IT_TAMP RTC_TAFCR_TAMPIE /*!< Enable global Tamper Interrupt */ 157 /** 158 * @} 159 */ 160 161 /** @defgroup RTCEx_Tamper_Trigger_Definitions RTCEx Tamper Triggers Definitions 162 * @{ 163 */ 164 #define RTC_TAMPERTRIGGER_RISINGEDGE 0x00000000U 165 #define RTC_TAMPERTRIGGER_FALLINGEDGE RTC_TAFCR_TAMP1TRG 166 #define RTC_TAMPERTRIGGER_LOWLEVEL RTC_TAMPERTRIGGER_RISINGEDGE 167 #define RTC_TAMPERTRIGGER_HIGHLEVEL RTC_TAMPERTRIGGER_FALLINGEDGE 168 /** 169 * @} 170 */ 171 172 /** @defgroup RTCEx_Tamper_Filter_Definitions RTCEx Tamper Filter Definitions 173 * @{ 174 */ 175 #define RTC_TAMPERFILTER_DISABLE 0x00000000U /*!< Tamper filter is disabled */ 176 177 #define RTC_TAMPERFILTER_2SAMPLE RTC_TAFCR_TAMPFLT_0 /*!< Tamper is activated after 2 178 consecutive samples at the active level */ 179 #define RTC_TAMPERFILTER_4SAMPLE RTC_TAFCR_TAMPFLT_1 /*!< Tamper is activated after 4 180 consecutive samples at the active level */ 181 #define RTC_TAMPERFILTER_8SAMPLE RTC_TAFCR_TAMPFLT /*!< Tamper is activated after 8 182 consecutive samples at the active level */ 183 #define RTC_TAMPERFILTER_MASK RTC_TAFCR_TAMPFLT /*!< Masking all bits except those of 184 field TAMPFLT */ 185 /** 186 * @} 187 */ 188 189 /** @defgroup RTCEx_Tamper_Sampling_Frequencies_Definitions RTCEx Tamper Sampling Frequencies Definitions 190 * @{ 191 */ 192 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 0x00000000U /*!< Each of the tamper inputs are sampled 193 with a frequency = RTCCLK / 32768 */ 194 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 RTC_TAFCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled 195 with a frequency = RTCCLK / 16384 */ 196 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 RTC_TAFCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled 197 with a frequency = RTCCLK / 8192 */ 198 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 (RTC_TAFCR_TAMPFREQ_0 | RTC_TAFCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled 199 with a frequency = RTCCLK / 4096 */ 200 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 RTC_TAFCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled 201 with a frequency = RTCCLK / 2048 */ 202 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 (RTC_TAFCR_TAMPFREQ_0 | RTC_TAFCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled 203 with a frequency = RTCCLK / 1024 */ 204 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 (RTC_TAFCR_TAMPFREQ_1 | RTC_TAFCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled 205 with a frequency = RTCCLK / 512 */ 206 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 RTC_TAFCR_TAMPFREQ /*!< Each of the tamper inputs are sampled 207 with a frequency = RTCCLK / 256 */ 208 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_MASK RTC_TAFCR_TAMPFREQ /*!< Masking all bits except those of 209 field TAMPFREQ */ 210 /** 211 * @} 212 */ 213 214 /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration_Definitions RTCEx Tamper Pin Precharge Duration Definitions 215 * @{ 216 */ 217 #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK 0x00000000U /*!< Tamper pins are pre-charged before 218 sampling during 1 RTCCLK cycle */ 219 #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK RTC_TAFCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before 220 sampling during 2 RTCCLK cycles */ 221 #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK RTC_TAFCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before 222 sampling during 4 RTCCLK cycles */ 223 #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK RTC_TAFCR_TAMPPRCH /*!< Tamper pins are pre-charged before 224 sampling during 8 RTCCLK cycles */ 225 #define RTC_TAMPERPRECHARGEDURATION_MASK RTC_TAFCR_TAMPPRCH /*!< Masking all bits except those of 226 field TAMPPRCH */ 227 /** 228 * @} 229 */ 230 231 /** @defgroup RTCEx_Tamper_Pull_Up_Definitions RTCEx Tamper Pull Up Definitions 232 * @{ 233 */ 234 #define RTC_TAMPER_PULLUP_ENABLE 0x00000000U /*!< Tamper pins are pre-charged before sampling */ 235 #define RTC_TAMPER_PULLUP_DISABLE RTC_TAFCR_TAMPPUDIS /*!< Tamper pins are not pre-charged before sampling */ 236 #define RTC_TAMPER_PULLUP_MASK RTC_TAFCR_TAMPPUDIS /*!< Masking all bits except bit TAMPPUDIS */ 237 /** 238 * @} 239 */ 240 241 /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection_Definitions RTCEx Tamper TimeStamp On Tamper Detection Definitions 242 * @{ 243 */ 244 #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE RTC_TAFCR_TAMPTS /*!< TimeStamp on Tamper Detection event saved */ 245 #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE 0x00000000U /*!< TimeStamp on Tamper Detection event is not saved */ 246 #define RTC_TIMESTAMPONTAMPERDETECTION_MASK RTC_TAFCR_TAMPTS /*!< Masking all bits except bit TAMPTS */ 247 /** 248 * @} 249 */ 250 251 /** @defgroup RTCEx_Wakeup_Timer_Definitions RTCEx Wakeup Timer Definitions 252 * @{ 253 */ 254 #define RTC_WAKEUPCLOCK_RTCCLK_DIV16 0x00000000U 255 #define RTC_WAKEUPCLOCK_RTCCLK_DIV8 RTC_CR_WUCKSEL_0 256 #define RTC_WAKEUPCLOCK_RTCCLK_DIV4 RTC_CR_WUCKSEL_1 257 #define RTC_WAKEUPCLOCK_RTCCLK_DIV2 (RTC_CR_WUCKSEL_0 | RTC_CR_WUCKSEL_1) 258 #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS RTC_CR_WUCKSEL_2 259 #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_2) 260 /** 261 * @} 262 */ 263 264 /** @defgroup RTCEx_Coarse_Calibration_Definitions RTCEx Coarse Calib Definitions 265 * @{ 266 */ 267 #define RTC_CALIBSIGN_POSITIVE 0x00000000U 268 #define RTC_CALIBSIGN_NEGATIVE RTC_CALIBR_DCS 269 /** 270 * @} 271 */ 272 273 /** @defgroup RTCEx_Smooth_calib_period_Definitions RTCEx Smooth Calib Period Definitions 274 * @{ 275 */ 276 #define RTC_SMOOTHCALIB_PERIOD_32SEC 0x00000000U /*!< If RTCCLK = 32768 Hz, smooth calibration 277 period is 32s, otherwise 2^20 RTCCLK pulses */ 278 #define RTC_SMOOTHCALIB_PERIOD_16SEC RTC_CALR_CALW16 /*!< If RTCCLK = 32768 Hz, smooth calibration 279 period is 16s, otherwise 2^19 RTCCLK pulses */ 280 #define RTC_SMOOTHCALIB_PERIOD_8SEC RTC_CALR_CALW8 /*!< If RTCCLK = 32768 Hz, smooth calibration 281 period is 8s, otherwise 2^18 RTCCLK pulses */ 282 /** 283 * @} 284 */ 285 286 /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions RTCEx Smooth Calib Plus Pulses Definitions 287 * @{ 288 */ 289 #define RTC_SMOOTHCALIB_PLUSPULSES_SET RTC_CALR_CALP /*!< The number of RTCCLK pulses added 290 during a X -second window = Y - CALM[8:0] 291 with Y = 512, 256, 128 when X = 32, 16, 8 */ 292 #define RTC_SMOOTHCALIB_PLUSPULSES_RESET 0x00000000U /*!< The number of RTCCLK pulses subbstited 293 during a 32-second window = CALM[8:0] */ 294 /** 295 * @} 296 */ 297 298 /** @defgroup RTCEx_Add_1_Second_Parameter_Definitions RTCEx Add 1 Second Parameter Definitions 299 * @{ 300 */ 301 #define RTC_SHIFTADD1S_RESET 0x00000000U 302 #define RTC_SHIFTADD1S_SET RTC_SHIFTR_ADD1S 303 /** 304 * @} 305 */ 306 307 /** @defgroup RTCEx_Calib_Output_selection_Definitions RTCEx Calib Output Selection Definitions 308 * @{ 309 */ 310 #define RTC_CALIBOUTPUT_512HZ 0x00000000U 311 #define RTC_CALIBOUTPUT_1HZ RTC_CR_COSEL 312 /** 313 * @} 314 */ 315 316 /** 317 * @} 318 */ 319 320 /* Exported macros -----------------------------------------------------------*/ 321 322 /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros 323 * @{ 324 */ 325 326 /* ---------------------------------WAKEUPTIMER-------------------------------*/ 327 328 /** @defgroup RTCEx_WakeUp_Timer RTCEx WakeUp Timer 329 * @{ 330 */ 331 332 /** 333 * @brief Enable the RTC WakeUp Timer peripheral. 334 * @param __HANDLE__ specifies the RTC handle. 335 * @retval None 336 */ 337 #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE)) 338 339 /** 340 * @brief Disable the RTC Wakeup Timer peripheral. 341 * @param __HANDLE__ specifies the RTC handle. 342 * @retval None 343 */ 344 #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE)) 345 346 /** 347 * @brief Enable the RTC Wakeup Timer interrupt. 348 * @param __HANDLE__ specifies the RTC handle. 349 * @param __INTERRUPT__ specifies the RTC Wakeup Timer interrupt sources to be enabled or disabled. 350 * This parameter can be: 351 * @arg RTC_IT_WUT: Wakeup Timer interrupt 352 * @retval None 353 */ 354 #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) 355 356 /** 357 * @brief Disable the RTC Wakeup Timer interrupt. 358 * @param __HANDLE__ specifies the RTC handle. 359 * @param __INTERRUPT__ specifies the RTC Wakeup Timer interrupt sources to be enabled or disabled. 360 * This parameter can be: 361 * @arg RTC_IT_WUT: Wakeup Timer interrupt 362 * @retval None 363 */ 364 #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) 365 366 /** 367 * @brief Check whether the specified RTC Wakeup Timer interrupt has occurred or not. 368 * @param __HANDLE__ specifies the RTC handle. 369 * @param __INTERRUPT__ specifies the RTC Wakeup Timer interrupt to check. 370 * This parameter can be: 371 * @arg RTC_IT_WUT: Wakeup Timer interrupt 372 * @retval None 373 */ 374 #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__) >> 4U)) != 0U) ? 1U : 0U) 375 376 /** 377 * @brief Check whether the specified RTC Wakeup timer interrupt has been enabled or not. 378 * @param __HANDLE__ specifies the RTC handle. 379 * @param __INTERRUPT__ specifies the RTC Wakeup timer interrupt sources to check. 380 * This parameter can be: 381 * @arg RTC_IT_WUT: WakeUpTimer interrupt 382 * @retval None 383 */ 384 #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U) 385 386 /** 387 * @brief Get the selected RTC Wakeup Timer's flag status. 388 * @param __HANDLE__ specifies the RTC handle. 389 * @param __FLAG__ specifies the RTC Wakeup Timer flag to check. 390 * This parameter can be: 391 * @arg RTC_FLAG_WUTF: Wakeup Timer interrupt flag 392 * @arg RTC_FLAG_WUTWF: Wakeup Timer 'write allowed' flag 393 * @retval None 394 */ 395 #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U)? 1U : 0U) 396 397 /** 398 * @brief Clear the RTC Wakeup timer's pending flags. 399 * @param __HANDLE__ specifies the RTC handle. 400 * @param __FLAG__ specifies the RTC Wakeup Timer Flag to clear. 401 * This parameter can be: 402 * @arg RTC_FLAG_WUTF: Wakeup Timer interrupt Flag 403 * @retval None 404 */ 405 #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)) 406 407 /** 408 * @brief Enable interrupt on the RTC Wakeup Timer associated EXTI line. 409 * @retval None 410 */ 411 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 412 413 /** 414 * @brief Disable interrupt on the RTC Wakeup Timer associated EXTI line. 415 * @retval None 416 */ 417 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR &= ~RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 418 419 /** 420 * @brief Enable event on the RTC Wakeup Timer associated EXTI line. 421 * @retval None. 422 */ 423 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 424 425 /** 426 * @brief Disable event on the RTC Wakeup Timer associated EXTI line. 427 * @retval None. 428 */ 429 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 430 431 /** 432 * @brief Enable falling edge trigger on the RTC Wakeup Timer associated EXTI line. 433 * @retval None. 434 */ 435 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 436 437 /** 438 * @brief Disable falling edge trigger on the RTC Wakeup Timer associated EXTI line. 439 * @retval None. 440 */ 441 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 442 443 /** 444 * @brief Enable rising edge trigger on the RTC Wakeup Timer associated EXTI line. 445 * @retval None. 446 */ 447 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 448 449 /** 450 * @brief Disable rising edge trigger on the RTC Wakeup Timer associated EXTI line. 451 * @retval None. 452 */ 453 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 454 455 /** 456 * @brief Enable rising & falling edge trigger on the RTC Wakeup Timer associated EXTI line. 457 * @retval None. 458 */ 459 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ 460 __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE(); \ 461 __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE(); \ 462 } while(0U) 463 464 /** 465 * @brief Disable rising & falling edge trigger on the RTC Wakeup Timer associated EXTI line. 466 * This parameter can be: 467 * @retval None. 468 */ 469 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ 470 __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE(); \ 471 __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE(); \ 472 } while(0U) 473 474 /** 475 * @brief Check whether the RTC Wakeup Timer associated EXTI line interrupt flag is set or not. 476 * @retval Line Status. 477 */ 478 #define __HAL_RTC_WAKEUPTIMER_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 479 480 /** 481 * @brief Clear the RTC Wakeup Timer associated EXTI line flag. 482 * @retval None. 483 */ 484 #define __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 485 486 /** 487 * @brief Generate a Software interrupt on the RTC Wakeup Timer associated EXTI line. 488 * @retval None. 489 */ 490 #define __HAL_RTC_WAKEUPTIMER_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 491 492 /** 493 * @} 494 */ 495 496 /* ---------------------------------TIMESTAMP---------------------------------*/ 497 498 /** @defgroup RTCEx_Timestamp RTCEx Timestamp 499 * @{ 500 */ 501 502 /** 503 * @brief Enable the RTC Timestamp peripheral. 504 * @param __HANDLE__ specifies the RTC handle. 505 * @retval None 506 */ 507 #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE)) 508 509 /** 510 * @brief Disable the RTC Timestamp peripheral. 511 * @param __HANDLE__ specifies the RTC handle. 512 * @retval None 513 */ 514 #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE)) 515 516 /** 517 * @brief Enable the RTC Timestamp interrupt. 518 * @param __HANDLE__ specifies the RTC handle. 519 * @param __INTERRUPT__ specifies the RTC Timestamp interrupt sources to be enabled or disabled. 520 * This parameter can be: 521 * @arg RTC_IT_TS: TimeStamp interrupt 522 * @retval None 523 */ 524 #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) 525 526 /** 527 * @brief Disable the RTC Timestamp interrupt. 528 * @param __HANDLE__ specifies the RTC handle. 529 * @param __INTERRUPT__ specifies the RTC Timestamp interrupt sources to be enabled or disabled. 530 * This parameter can be: 531 * @arg RTC_IT_TS: TimeStamp interrupt 532 * @retval None 533 */ 534 #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) 535 536 /** 537 * @brief Check whether the specified RTC Timestamp interrupt has occurred or not. 538 * @param __HANDLE__ specifies the RTC handle. 539 * @param __INTERRUPT__ specifies the RTC Timestamp interrupt to check. 540 * This parameter can be: 541 * @arg RTC_IT_TS: TimeStamp interrupt 542 * @retval None 543 */ 544 #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__) >> 4U)) != 0U) ? 1U : 0U) 545 546 /** 547 * @brief Check whether the specified RTC Timestamp interrupt has been enabled or not. 548 * @param __HANDLE__ specifies the RTC handle. 549 * @param __INTERRUPT__ specifies the RTC Timestamp interrupt source to check. 550 * This parameter can be: 551 * @arg RTC_IT_TS: TimeStamp interrupt 552 * @retval None 553 */ 554 #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U) 555 556 /** 557 * @brief Get the selected RTC Timestamp's flag status. 558 * @param __HANDLE__ specifies the RTC handle. 559 * @param __FLAG__ specifies the RTC Timestamp flag to check. 560 * This parameter can be: 561 * @arg RTC_FLAG_TSF: Timestamp interrupt flag 562 * @arg RTC_FLAG_TSOVF: Timestamp overflow flag 563 * @retval None 564 */ 565 #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U)? 1U : 0U) 566 567 /** 568 * @brief Clear the RTC Timestamp's pending flags. 569 * @param __HANDLE__ specifies the RTC handle. 570 * @param __FLAG__ specifies the RTC Timestamp flag to clear. 571 * This parameter can be: 572 * @arg RTC_FLAG_TSF: Timestamp interrupt flag 573 * @arg RTC_FLAG_TSOVF: Timestamp overflow flag 574 * @retval None 575 */ 576 #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)) 577 578 /** 579 * @} 580 */ 581 582 /* ---------------------------------TAMPER------------------------------------*/ 583 584 /** @defgroup RTCEx_Tamper RTCEx Tamper 585 * @{ 586 */ 587 588 /** 589 * @brief Enable the RTC Tamper1 input detection. 590 * @param __HANDLE__ specifies the RTC handle. 591 * @retval None 592 */ 593 #define __HAL_RTC_TAMPER1_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAFCR |= (RTC_TAFCR_TAMP1E)) 594 595 /** 596 * @brief Disable the RTC Tamper1 input detection. 597 * @param __HANDLE__ specifies the RTC handle. 598 * @retval None 599 */ 600 #define __HAL_RTC_TAMPER1_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAFCR &= ~(RTC_TAFCR_TAMP1E)) 601 602 #if defined(RTC_TAMPER2_SUPPORT) 603 /** 604 * @brief Enable the RTC Tamper2 input detection. 605 * @param __HANDLE__ specifies the RTC handle. 606 * @retval None 607 */ 608 #define __HAL_RTC_TAMPER2_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->TAFCR |= (RTC_TAFCR_TAMP2E)) 609 610 /** 611 * @brief Disable the RTC Tamper2 input detection. 612 * @param __HANDLE__ specifies the RTC handle. 613 * @retval None 614 */ 615 #define __HAL_RTC_TAMPER2_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->TAFCR &= ~(RTC_TAFCR_TAMP2E)) 616 #endif /* RTC_TAMPER2_SUPPORT */ 617 618 /** 619 * @brief Enable the RTC Tamper interrupt. 620 * @param __HANDLE__ specifies the RTC handle. 621 * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be enabled. 622 * This parameter can be any combination of the following values: 623 * @arg RTC_IT_TAMP: Tamper global interrupt 624 * @retval None 625 */ 626 #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAFCR |= (__INTERRUPT__)) 627 628 /** 629 * @brief Disable the RTC Tamper interrupt. 630 * @param __HANDLE__ specifies the RTC handle. 631 * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be disabled. 632 * This parameter can be any combination of the following values: 633 * @arg RTC_IT_TAMP: Tamper global interrupt 634 * @retval None 635 */ 636 #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->TAFCR &= ~(__INTERRUPT__)) 637 638 /** 639 * @brief Check whether the specified RTC Tamper interrupt has occurred or not. 640 * @param __HANDLE__ specifies the RTC handle. 641 * @param __INTERRUPT__ specifies the RTC Tamper interrupt to check. 642 * This parameter can be: 643 * @arg RTC_IT_TAMP1: Tamper 1 interrupt 644 * @arg RTC_IT_TAMP2: Tamper 2 interrupt 645 * @note RTC_IT_TAMP2 is not applicable to all devices. 646 * @retval None 647 */ 648 #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__) >> 4U)) != 0U) ? 1U : 0U) 649 650 /** 651 * @brief Check whether the specified RTC Tamper interrupt has been enabled or not. 652 * @param __HANDLE__ specifies the RTC handle. 653 * @param __INTERRUPT__ specifies the RTC Tamper interrupt source to check. 654 * This parameter can be: 655 * @arg RTC_IT_TAMP: Tamper global interrupt 656 * @retval None 657 */ 658 #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->TAFCR) & (__INTERRUPT__)) != 0U) ? 1U : 0U) 659 660 /** 661 * @brief Get the selected RTC Tamper's flag status. 662 * @param __HANDLE__ specifies the RTC handle. 663 * @param __FLAG__ specifies the RTC Tamper flag to be checked. 664 * This parameter can be: 665 * @arg RTC_FLAG_TAMP1F: Tamper 1 interrupt flag 666 * @arg RTC_FLAG_TAMP2F: Tamper 2 interrupt flag 667 * @note RTC_FLAG_TAMP2F is not applicable to all devices. 668 * @retval None 669 */ 670 #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U)? 1U : 0U) 671 672 /** 673 * @brief Clear the RTC Tamper's pending flags. 674 * @param __HANDLE__ specifies the RTC handle. 675 * @param __FLAG__ specifies the RTC Tamper Flag to clear. 676 * This parameter can be: 677 * @arg RTC_FLAG_TAMP1F: Tamper 1 interrupt flag 678 * @arg RTC_FLAG_TAMP2F: Tamper 2 interrupt flag 679 * @note RTC_FLAG_TAMP2F is not applicable to all devices. 680 * @retval None 681 */ 682 #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)) 683 /** 684 * @} 685 */ 686 687 /* --------------------------TAMPER/TIMESTAMP---------------------------------*/ 688 /** @defgroup RTCEx_Tamper_Timestamp EXTI RTC Tamper Timestamp EXTI 689 * @{ 690 */ 691 692 /** 693 * @brief Enable interrupt on the RTC Tamper and Timestamp associated EXTI line. 694 * @retval None 695 */ 696 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 697 698 /** 699 * @brief Disable interrupt on the RTC Tamper and Timestamp associated EXTI line. 700 * @retval None 701 */ 702 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_IT() (EXTI->IMR &= ~RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 703 704 /** 705 * @brief Enable event on the RTC Tamper and Timestamp associated EXTI line. 706 * @retval None. 707 */ 708 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 709 710 /** 711 * @brief Disable event on the RTC Tamper and Timestamp associated EXTI line. 712 * @retval None. 713 */ 714 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 715 716 /** 717 * @brief Enable falling edge trigger on the RTC Tamper and Timestamp associated EXTI line. 718 * @retval None. 719 */ 720 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 721 722 /** 723 * @brief Disable falling edge trigger on the RTC Tamper and Timestamp associated EXTI line. 724 * @retval None. 725 */ 726 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 727 728 /** 729 * @brief Enable rising edge trigger on the RTC Tamper and Timestamp associated EXTI line. 730 * @retval None. 731 */ 732 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 733 734 /** 735 * @brief Disable rising edge trigger on the RTC Tamper and Timestamp associated EXTI line. 736 * @retval None. 737 */ 738 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 739 740 /** 741 * @brief Enable rising & falling edge trigger on the RTC Tamper and Timestamp associated EXTI line. 742 * @retval None. 743 */ 744 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ 745 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE(); \ 746 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE(); \ 747 } while(0U) 748 749 /** 750 * @brief Disable rising & falling edge trigger on the RTC Tamper and Timestamp associated EXTI line. 751 * This parameter can be: 752 * @retval None. 753 */ 754 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ 755 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE(); \ 756 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE(); \ 757 } while(0U) 758 759 /** 760 * @brief Check whether the RTC Tamper and Timestamp associated EXTI line interrupt flag is set or not. 761 * @retval Line Status. 762 */ 763 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 764 765 /** 766 * @brief Clear the RTC Tamper and Timestamp associated EXTI line flag. 767 * @retval None. 768 */ 769 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 770 771 /** 772 * @brief Generate a Software interrupt on the RTC Tamper and Timestamp associated EXTI line 773 * @retval None. 774 */ 775 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 776 /** 777 * @} 778 */ 779 780 /* ------------------------------CALIBRATION----------------------------------*/ 781 782 /** @defgroup RTCEx_Calibration RTCEx Calibration 783 * @{ 784 */ 785 786 /** 787 * @brief Enable the Coarse calibration process. 788 * @param __HANDLE__ specifies the RTC handle. 789 * @retval None 790 */ 791 #define __HAL_RTC_COARSE_CALIB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_DCE)) 792 793 /** 794 * @brief Disable the Coarse calibration process. 795 * @param __HANDLE__ specifies the RTC handle. 796 * @retval None 797 */ 798 #define __HAL_RTC_COARSE_CALIB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_DCE)) 799 800 /** 801 * @brief Enable the RTC calibration output. 802 * @param __HANDLE__ specifies the RTC handle. 803 * @retval None 804 */ 805 #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_COE)) 806 807 /** 808 * @brief Disable the calibration output. 809 * @param __HANDLE__ specifies the RTC handle. 810 * @retval None 811 */ 812 #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE)) 813 814 /** 815 * @brief Enable the clock reference detection. 816 * @param __HANDLE__ specifies the RTC handle. 817 * @retval None 818 */ 819 #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON)) 820 821 /** 822 * @brief Disable the clock reference detection. 823 * @param __HANDLE__ specifies the RTC handle. 824 * @retval None 825 */ 826 #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON)) 827 828 /** 829 * @brief Get the selected RTC shift operation's flag status. 830 * @param __HANDLE__ specifies the RTC handle. 831 * @param __FLAG__ specifies the RTC shift operation Flag is pending or not. 832 * This parameter can be: 833 * @arg RTC_FLAG_SHPF: Shift pending flag 834 * @retval None 835 */ 836 #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U)? 1U : 0U) 837 /** 838 * @} 839 */ 840 841 /** 842 * @} 843 */ 844 845 /* Exported functions --------------------------------------------------------*/ 846 847 /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions 848 * @{ 849 */ 850 851 /** @addtogroup RTCEx_Exported_Functions_Group1 852 * @{ 853 */ 854 /* RTC Timestamp and Tamper functions *****************************************/ 855 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t RTC_TimeStampEdge, uint32_t RTC_TimeStampPin); 856 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t RTC_TimeStampEdge, uint32_t RTC_TimeStampPin); 857 HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc); 858 HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format); 859 860 HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper); 861 HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper); 862 HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper); 863 void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc); 864 865 void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc); 866 #if defined(RTC_TAMPER2_SUPPORT) 867 void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc); 868 #endif /* RTC_TAMPER2_SUPPORT */ 869 void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc); 870 HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 871 HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 872 #if defined(RTC_TAMPER2_SUPPORT) 873 HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 874 #endif /* RTC_TAMPER2_SUPPORT */ 875 /** 876 * @} 877 */ 878 879 /** @addtogroup RTCEx_Exported_Functions_Group2 880 * @{ 881 */ 882 /* RTC Wakeup functions ******************************************************/ 883 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock); 884 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock); 885 HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc); 886 uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc); 887 void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc); 888 void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc); 889 HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 890 /** 891 * @} 892 */ 893 894 /** @addtogroup RTCEx_Exported_Functions_Group3 895 * @{ 896 */ 897 /* Extended Control functions ************************************************/ 898 void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data); 899 uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister); 900 901 HAL_StatusTypeDef HAL_RTCEx_SetCoarseCalib(RTC_HandleTypeDef *hrtc, uint32_t CalibSign, uint32_t Value); 902 HAL_StatusTypeDef HAL_RTCEx_DeactivateCoarseCalib(RTC_HandleTypeDef *hrtc); 903 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue); 904 HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS); 905 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput); 906 HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc); 907 HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc); 908 HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc); 909 HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc); 910 HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc); 911 /** 912 * @} 913 */ 914 915 /** @addtogroup RTCEx_Exported_Functions_Group4 916 * @{ 917 */ 918 /* Extended RTC features functions *******************************************/ 919 void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc); 920 HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 921 /** 922 * @} 923 */ 924 925 /** 926 * @} 927 */ 928 929 /* Private types -------------------------------------------------------------*/ 930 /* Private variables ---------------------------------------------------------*/ 931 /* Private constants ---------------------------------------------------------*/ 932 933 /** @defgroup RTCEx_Private_Constants RTCEx Private Constants 934 * @{ 935 */ 936 #define RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT EXTI_IMR_MR21 /*!< External interrupt line 21 Connected to the RTC Tamper and Timestamp event */ 937 #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT EXTI_IMR_MR22 /*!< External interrupt line 22 Connected to the RTC Wakeup event */ 938 /** 939 * @} 940 */ 941 942 /** @defgroup RTCEx_Private_Constants RTCEx Private Constants 943 * @{ 944 */ 945 /* Masks Definition */ 946 #if defined(RTC_TAMPER2_SUPPORT) 947 #define RTC_TAMPER_ENABLE_BITS_MASK ((uint32_t) (RTC_TAMPER_1 | \ 948 RTC_TAMPER_2)) 949 950 #define RTC_TAMPER_FLAGS_MASK ((uint32_t) (RTC_FLAG_TAMP1F | \ 951 RTC_FLAG_TAMP2F)) 952 #else /* RTC_TAMPER2_SUPPORT */ 953 #define RTC_TAMPER_ENABLE_BITS_MASK RTC_TAMPER_1 954 955 #define RTC_TAMPER_FLAGS_MASK RTC_FLAG_TAMP1F 956 #endif /* RTC_TAMPER2_SUPPORT */ 957 /** 958 * @} 959 */ 960 961 /* Private macros ------------------------------------------------------------*/ 962 963 /** @defgroup RTCEx_Private_Macros RTCEx Private Macros 964 * @{ 965 */ 966 967 /** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters 968 * @{ 969 */ 970 #define IS_RTC_BKP(BKP) ((BKP) < (uint32_t) RTC_BKP_NUMBER) 971 972 #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \ 973 ((EDGE) == RTC_TIMESTAMPEDGE_FALLING)) 974 975 #define IS_RTC_TAMPER(TAMPER) ((((TAMPER) & ((uint32_t)~RTC_TAMPER_ENABLE_BITS_MASK)) == 0x00U) && ((TAMPER) != 0U)) 976 977 #if defined(RTC_AF2_SUPPORT) 978 #define IS_RTC_TAMPER_PIN(PIN) (((PIN) == RTC_TAMPERPIN_DEFAULT) || \ 979 ((PIN) == RTC_TAMPERPIN_POS1)) 980 #else /* RTC_AF2_SUPPORT */ 981 #define IS_RTC_TAMPER_PIN(PIN) ((PIN) == RTC_TAMPERPIN_DEFAULT) 982 #endif /* RTC_AF2_SUPPORT */ 983 984 #if defined(RTC_AF2_SUPPORT) 985 #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TIMESTAMPPIN_DEFAULT) || \ 986 ((PIN) == RTC_TIMESTAMPPIN_POS1)) 987 #else /* RTC_AF2_SUPPORT */ 988 #define IS_RTC_TIMESTAMP_PIN(PIN) ((PIN) == RTC_TIMESTAMPPIN_DEFAULT) 989 #endif /* RTC_AF2_SUPPORT */ 990 991 #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) || \ 992 ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \ 993 ((TRIGGER) == RTC_TAMPERTRIGGER_LOWLEVEL) || \ 994 ((TRIGGER) == RTC_TAMPERTRIGGER_HIGHLEVEL)) 995 996 #define IS_RTC_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TAMPERFILTER_DISABLE) || \ 997 ((FILTER) == RTC_TAMPERFILTER_2SAMPLE) || \ 998 ((FILTER) == RTC_TAMPERFILTER_4SAMPLE) || \ 999 ((FILTER) == RTC_TAMPERFILTER_8SAMPLE)) 1000 1001 #define IS_RTC_TAMPER_FILTER_CONFIG_CORRECT(FILTER, TRIGGER) \ 1002 ( ( ((FILTER) != RTC_TAMPERFILTER_DISABLE) \ 1003 && ( ((TRIGGER) == RTC_TAMPERTRIGGER_LOWLEVEL) \ 1004 || ((TRIGGER) == RTC_TAMPERTRIGGER_HIGHLEVEL))) \ 1005 || ( ((FILTER) == RTC_TAMPERFILTER_DISABLE) \ 1006 && ( ((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) \ 1007 || ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE)))) 1008 1009 #define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \ 1010 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \ 1011 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \ 1012 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \ 1013 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \ 1014 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \ 1015 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \ 1016 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256)) 1017 1018 #define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \ 1019 ((DURATION) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \ 1020 ((DURATION) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \ 1021 ((DURATION) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK)) 1022 1023 #define IS_RTC_TAMPER_PULLUP_STATE(STATE) (((STATE) == RTC_TAMPER_PULLUP_ENABLE) || \ 1024 ((STATE) == RTC_TAMPER_PULLUP_DISABLE)) 1025 1026 #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \ 1027 ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE)) 1028 1029 #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \ 1030 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \ 1031 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \ 1032 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \ 1033 ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \ 1034 ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS)) 1035 1036 #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= RTC_WUTR_WUT) 1037 1038 #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CALIBSIGN_POSITIVE) || \ 1039 ((SIGN) == RTC_CALIBSIGN_NEGATIVE)) 1040 1041 #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20U) 1042 1043 #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \ 1044 ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \ 1045 ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC)) 1046 1047 #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \ 1048 ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET)) 1049 1050 #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= RTC_CALR_CALM) 1051 1052 #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \ 1053 ((SEL) == RTC_SHIFTADD1S_SET)) 1054 1055 #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= RTC_SHIFTR_SUBFS) 1056 1057 #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \ 1058 ((OUTPUT) == RTC_CALIBOUTPUT_1HZ)) 1059 /** 1060 * @} 1061 */ 1062 1063 /** 1064 * @} 1065 */ 1066 1067 /** 1068 * @} 1069 */ 1070 1071 /** 1072 * @} 1073 */ 1074 1075 #ifdef __cplusplus 1076 } 1077 #endif 1078 1079 #endif /* STM32F4xx_HAL_RTC_EX_H */ 1080