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