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