1 /** 2 ****************************************************************************** 3 * @file stm32g0xx_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) 2018 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 STM32G0xx_HAL_RTC_EX_H 21 #define STM32G0xx_HAL_RTC_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32g0xx_hal_def.h" 29 30 /** @addtogroup STM32G0xx_HAL_Driver 31 * @{ 32 */ 33 34 /** @defgroup RTCEx RTCEx 35 * @{ 36 */ 37 38 /* Exported types ------------------------------------------------------------*/ 39 /** @defgroup RTCEx_Exported_Types RTCEx Exported Types 40 * @{ 41 */ 42 43 /** @defgroup RTCEx_Tamper_structure_definition RTCEx Tamper structure definition 44 * @{ 45 */ 46 typedef struct 47 { 48 uint32_t Tamper; /*!< Specifies the Tamper Pin. 49 This parameter can be a value of @ref RTCEx_Tamper_Pins */ 50 51 uint32_t Trigger; /*!< Specifies the Tamper Trigger. 52 This parameter can be a value of @ref RTCEx_Tamper_Trigger */ 53 54 uint32_t NoErase; /*!< Specifies the Tamper no erase mode. 55 This parameter can be a value of @ref RTCEx_Tamper_EraseBackUp */ 56 57 uint32_t MaskFlag; /*!< Specifies the Tamper Flag masking. 58 This parameter can be a value of @ref RTCEx_Tamper_MaskFlag */ 59 60 uint32_t Filter; /*!< Specifies the TAMP Filter Tamper. 61 This parameter can be a value of @ref RTCEx_Tamper_Filter */ 62 63 uint32_t SamplingFrequency; /*!< Specifies the sampling frequency. 64 This parameter can be a value of @ref RTCEx_Tamper_Sampling_Frequencies */ 65 66 uint32_t PrechargeDuration; /*!< Specifies the Precharge Duration . 67 This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration */ 68 69 uint32_t TamperPullUp; /*!< Specifies the Tamper PullUp . 70 This parameter can be a value of @ref RTCEx_Tamper_Pull_UP */ 71 72 uint32_t TimeStampOnTamperDetection; /*!< Specifies the TimeStampOnTamperDetection. 73 This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection_Definitions */ 74 }RTC_TamperTypeDef; 75 /** 76 * @} 77 */ 78 79 80 /** @defgroup RTCEx_Internal_Tamper_structure_definition RTCEx Internal Tamper structure definition 81 * @{ 82 */ 83 typedef struct 84 { 85 uint32_t IntTamper; /*!< Specifies the Internal Tamper Pin. 86 This parameter can be a value of @ref RTCEx_Internal_Tamper_Pins */ 87 88 uint32_t TimeStampOnTamperDetection; /*!< Specifies the TimeStampOnTamperDetection. 89 This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection_Definitions */ 90 } RTC_InternalTamperTypeDef; 91 /** 92 * @} 93 */ 94 95 /** 96 * @} 97 */ 98 99 /* Exported constants --------------------------------------------------------*/ 100 /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants 101 * @{ 102 */ 103 104 /** @defgroup RTCEx_Time_Stamp_Edges_definitions RTCEx Time Stamp Edges definition 105 * @{ 106 */ 107 #define RTC_TIMESTAMPEDGE_RISING 0x00000000u 108 #define RTC_TIMESTAMPEDGE_FALLING RTC_CR_TSEDGE 109 /** 110 * @} 111 */ 112 113 /** @defgroup RTCEx_TimeStamp_Pin_Selections RTCEx TimeStamp Pin Selection 114 * @{ 115 */ 116 #define RTC_TIMESTAMPPIN_DEFAULT 0x00000000u 117 /** 118 * @} 119 */ 120 121 /** @defgroup RTCEx_Wakeup_Timer_Definitions RTCEx Wakeup Timer Definitions 122 * @{ 123 */ 124 #define RTC_WAKEUPCLOCK_RTCCLK_DIV16 0x00000000u 125 #define RTC_WAKEUPCLOCK_RTCCLK_DIV8 RTC_CR_WUCKSEL_0 126 #define RTC_WAKEUPCLOCK_RTCCLK_DIV4 RTC_CR_WUCKSEL_1 127 #define RTC_WAKEUPCLOCK_RTCCLK_DIV2 (RTC_CR_WUCKSEL_0 | RTC_CR_WUCKSEL_1) 128 #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS RTC_CR_WUCKSEL_2 129 #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_2) 130 /** 131 * @} 132 */ 133 134 /** @defgroup RTCEx_Smooth_calib_period_Definitions RTCEx Smooth calib period Definitions 135 * @{ 136 */ 137 #define RTC_SMOOTHCALIB_PERIOD_32SEC 0x00000000u /*!< If RTCCLK = 32768 Hz, Smooth calibation 138 period is 32s, else 2exp20 RTCCLK pulses */ 139 #define RTC_SMOOTHCALIB_PERIOD_16SEC RTC_CALR_CALW16 /*!< If RTCCLK = 32768 Hz, Smooth calibation 140 period is 16s, else 2exp19 RTCCLK pulses */ 141 #define RTC_SMOOTHCALIB_PERIOD_8SEC RTC_CALR_CALW8 /*!< If RTCCLK = 32768 Hz, Smooth calibation 142 period is 8s, else 2exp18 RTCCLK pulses */ 143 /** 144 * @} 145 */ 146 147 /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions RTCEx Smooth calib Plus pulses Definitions 148 * @{ 149 */ 150 #define RTC_SMOOTHCALIB_PLUSPULSES_SET RTC_CALR_CALP /*!< The number of RTCCLK pulses added 151 during a X -second window = Y - CALM[8:0] 152 with Y = 512, 256, 128 when X = 32, 16, 8 */ 153 #define RTC_SMOOTHCALIB_PLUSPULSES_RESET 0x00000000u /*!< The number of RTCCLK pulses subbstited 154 during a 32-second window = CALM[8:0] */ 155 156 /** 157 * @} 158 */ 159 /** @defgroup RTCEx_Calib_Output_selection_Definitions RTCEx Calib Output selection Definitions 160 * @{ 161 */ 162 #define RTC_CALIBOUTPUT_512HZ 0x00000000u 163 #define RTC_CALIBOUTPUT_1HZ RTC_CR_COSEL 164 165 /** 166 * @} 167 */ 168 169 170 /** @defgroup RTCEx_Add_1_Second_Parameter_Definition RTCEx Add 1 Second Parameter Definitions 171 * @{ 172 */ 173 #define RTC_SHIFTADD1S_RESET 0x00000000u 174 #define RTC_SHIFTADD1S_SET RTC_SHIFTR_ADD1S 175 /** 176 * @} 177 */ 178 179 /** @defgroup RTCEx_Tamper_Pins RTCEx Tamper Pins Definition 180 * @{ 181 */ 182 #define RTC_TAMPER_1 TAMP_CR1_TAMP1E 183 #define RTC_TAMPER_2 TAMP_CR1_TAMP2E 184 #if defined(TAMP_CR1_TAMP3E) 185 #define RTC_TAMPER_3 TAMP_CR1_TAMP3E 186 #define RTC_TAMPER_ALL (TAMP_CR1_TAMP1E | TAMP_CR1_TAMP2E | TAMP_CR1_TAMP3E) 187 #else 188 #define RTC_TAMPER_ALL (TAMP_CR1_TAMP1E | TAMP_CR1_TAMP2E) 189 #endif /* TAMP_CR1_TAMP3E */ 190 /** 191 * @} 192 */ 193 194 /** @defgroup RTCEx_Internal_Tamper_Pins RTCEx Internal Tamper Pins Definition 195 * @{ 196 */ 197 #define RTC_INT_TAMPER_3 TAMP_CR1_ITAMP3E 198 #define RTC_INT_TAMPER_4 TAMP_CR1_ITAMP4E 199 #define RTC_INT_TAMPER_5 TAMP_CR1_ITAMP5E 200 #define RTC_INT_TAMPER_6 TAMP_CR1_ITAMP6E 201 #define RTC_INT_TAMPER_ALL (TAMP_CR1_ITAMP3E | TAMP_CR1_ITAMP4E | \ 202 TAMP_CR1_ITAMP5E | TAMP_CR1_ITAMP6E) 203 /** 204 * @} 205 */ 206 207 /** @defgroup RTCEx_Tamper_Trigger RTCEx Tamper Trigger 208 * @{ 209 */ 210 #define RTC_TAMPERTRIGGER_RISINGEDGE 0x00u 211 #define RTC_TAMPERTRIGGER_FALLINGEDGE 0x01u 212 #define RTC_TAMPERTRIGGER_LOWLEVEL RTC_TAMPERTRIGGER_RISINGEDGE 213 #define RTC_TAMPERTRIGGER_HIGHLEVEL RTC_TAMPERTRIGGER_FALLINGEDGE 214 /** 215 * @} 216 */ 217 218 /** @defgroup RTCEx_Tamper_MaskFlag RTCEx Tamper MaskFlag 219 * @{ 220 */ 221 #define RTC_TAMPERMASK_FLAG_DISABLE 0x00u 222 #define RTC_TAMPERMASK_FLAG_ENABLE 0x01u 223 /** 224 * @} 225 */ 226 227 /** @defgroup RTCEx_Tamper_EraseBackUp RTCEx Tamper EraseBackUp 228 * @{ 229 */ 230 #define RTC_TAMPER_ERASE_BACKUP_ENABLE 0x00u 231 #define RTC_TAMPER_ERASE_BACKUP_DISABLE 0x01u 232 /** 233 * @} 234 */ 235 236 /** @defgroup RTCEx_Tamper_Filter RTCEx Tamper Filter 237 * @{ 238 */ 239 #define RTC_TAMPERFILTER_DISABLE 0x00000000U /*!< Tamper filter is disabled */ 240 #define RTC_TAMPERFILTER_2SAMPLE TAMP_FLTCR_TAMPFLT_0 /*!< Tamper is activated after 2 241 consecutive samples at the active level */ 242 #define RTC_TAMPERFILTER_4SAMPLE TAMP_FLTCR_TAMPFLT_1 /*!< Tamper is activated after 4 243 consecutive samples at the active level */ 244 #define RTC_TAMPERFILTER_8SAMPLE TAMP_FLTCR_TAMPFLT /*!< Tamper is activated after 8 245 consecutive samples at the active level */ 246 /** 247 * @} 248 */ 249 250 /** @defgroup RTCEx_Tamper_Sampling_Frequencies RTCEx Tamper Sampling Frequencies 251 * @{ 252 */ 253 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 0x00000000U /*!< Each of the tamper inputs are sampled 254 with a frequency = RTCCLK / 32768 */ 255 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 TAMP_FLTCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled 256 with a frequency = RTCCLK / 16384 */ 257 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 TAMP_FLTCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled 258 with a frequency = RTCCLK / 8192 */ 259 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled 260 with a frequency = RTCCLK / 4096 */ 261 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 TAMP_FLTCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled 262 with a frequency = RTCCLK / 2048 */ 263 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled 264 with a frequency = RTCCLK / 1024 */ 265 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 (TAMP_FLTCR_TAMPFREQ_1 | TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled 266 with a frequency = RTCCLK / 512 */ 267 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_1 | \ 268 TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled 269 with a frequency = RTCCLK / 256 */ 270 /** 271 * @} 272 */ 273 274 /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration RTCEx Tamper Pin Precharge Duration 275 * @{ 276 */ 277 #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK 0x00000000U /*!< Tamper pins are pre-charged before 278 sampling during 1 RTCCLK cycle */ 279 #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK TAMP_FLTCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before 280 sampling during 2 RTCCLK cycles */ 281 #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK TAMP_FLTCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before 282 sampling during 4 RTCCLK cycles */ 283 #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK (TAMP_FLTCR_TAMPPRCH_0 | TAMP_FLTCR_TAMPPRCH_1) /*!< Tamper pins are pre-charged before 284 sampling during 8 RTCCLK cycles */ 285 /** 286 * @} 287 */ 288 289 /** @defgroup RTCEx_Tamper_Pull_UP RTCEx Tamper Pull UP 290 * @{ 291 */ 292 #define RTC_TAMPER_PULLUP_ENABLE 0x00000000u /*!< Tamper pins are pre-charged before sampling */ 293 #define RTC_TAMPER_PULLUP_DISABLE TAMP_FLTCR_TAMPPUDIS /*!< Tamper pins pre-charge is disabled */ 294 /** 295 * @} 296 */ 297 298 /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection_Definitions RTCEx Tamper TimeStamp On Tamper Detection Definitions 299 * @{ 300 */ 301 #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE 0x00000000u /*!< TimeStamp on Tamper Detection event is not saved */ 302 #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE RTC_CR_TAMPTS /*!< TimeStamp on Tamper Detection event saved */ 303 /** 304 * @} 305 */ 306 307 308 /** @defgroup RTCEx_Internal_Tamper_Interrupt RTCEx Internal Tamper Interrupt 309 * @{ 310 */ 311 #define RTC_IT_TAMP1 TAMP_IER_TAMP1IE /*!< Tamper 1 Interrupt */ 312 #define RTC_IT_TAMP2 TAMP_IER_TAMP2IE /*!< Tamper 2 Interrupt */ 313 #if defined(TAMP_CR1_TAMP3E) 314 #define RTC_IT_TAMP3 TAMP_IER_TAMP3IE /*!< Tamper 3 Interrupt */ 315 #define RTC_IT_TAMPALL (TAMP_IER_TAMP1IE | TAMP_IER_TAMP2IE | TAMP_IER_TAMP3IE) 316 #else 317 #define RTC_IT_TAMPALL (TAMP_IER_TAMP1IE | TAMP_IER_TAMP2IE) 318 #endif /* TAMP_CR1_TAMP3E */ 319 320 #define RTC_IT_INT_TAMP3 TAMP_IER_ITAMP3IE 321 #define RTC_IT_INT_TAMP4 TAMP_IER_ITAMP4IE 322 #define RTC_IT_INT_TAMP5 TAMP_IER_ITAMP5IE 323 #define RTC_IT_INT_TAMP6 TAMP_IER_ITAMP6IE 324 #define RTC_IT_INT_TAMPALL (RTC_IT_INT_TAMP3 | RTC_IT_INT_TAMP4 | \ 325 RTC_IT_INT_TAMP5 | RTC_IT_INT_TAMP6) 326 /** 327 * @} 328 */ 329 330 /** @defgroup RTCEx_Flags RTCEx Flags 331 * @{ 332 */ 333 #define RTC_FLAG_TAMP1 TAMP_SR_TAMP1F 334 #define RTC_FLAG_TAMP2 TAMP_SR_TAMP2F 335 #if defined(TAMP_CR1_TAMP3E) 336 #define RTC_FLAG_TAMP3 TAMP_SR_TAMP3F 337 #define RTC_FLAG_TAMPALL (RTC_FLAG_TAMP1 | RTC_FLAG_TAMP2 | RTC_FLAG_TAMP3) 338 #else 339 #define RTC_FLAG_TAMPALL (RTC_FLAG_TAMP1 | RTC_FLAG_TAMP2) 340 #endif /* TAMP_CR1_TAMP3E */ 341 #define RTC_FLAG_INT_TAMP3 TAMP_SR_ITAMP3F 342 #define RTC_FLAG_INT_TAMP4 TAMP_SR_ITAMP4F 343 #define RTC_FLAG_INT_TAMP5 TAMP_SR_ITAMP5F 344 #define RTC_FLAG_INT_TAMP6 TAMP_SR_ITAMP6F 345 #define RTC_FLAG_INT_TAMPALL (RTC_FLAG_INT_TAMP3 | RTC_FLAG_INT_TAMP4 | \ 346 RTC_FLAG_INT_TAMP5 | RTC_FLAG_INT_TAMP6) 347 /** 348 * @} 349 */ 350 351 352 /** @defgroup RTCEx_Backup_Registers RTCEx Backup Registers Definition 353 * @{ 354 */ 355 #define RTC_BKP_NUMBER 0x00000005u 356 #define RTC_BKP_DR0 0x00000000u 357 #define RTC_BKP_DR1 0x00000001u 358 #define RTC_BKP_DR2 0x00000002u 359 #define RTC_BKP_DR3 0x00000003u 360 #define RTC_BKP_DR4 0x00000004u 361 /** 362 * @} 363 */ 364 365 /** 366 * @} 367 */ 368 369 /* Exported macros -----------------------------------------------------------*/ 370 /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros 371 * @{ 372 */ 373 374 /** @brief Clear the specified RTC pending flag. 375 * @param __HANDLE__ specifies the RTC Handle. 376 * @param __FLAG__ specifies the flag to check. 377 * This parameter can be any combination of the following values: 378 * @arg @ref RTC_CLEAR_ITSF Clear Internal Time-stamp flag 379 * @arg @ref RTC_CLEAR_TSOVF Clear Time-stamp overflow flag 380 * @arg @ref RTC_CLEAR_TSF Clear Time-stamp flag 381 * @arg @ref RTC_CLEAR_WUTF Clear Wakeup timer flag 382 * @arg @ref RTC_CLEAR_ALRBF Clear Alarm B flag 383 * @arg @ref RTC_CLEAR_ALRAF Clear Alarm A flag 384 * @retval None 385 */ 386 #define __HAL_RTC_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SCR |= (__FLAG__)) 387 388 /** @brief Check whether the specified RTC flag is set or not. 389 * @param __HANDLE__ specifies the RTC Handle. 390 * @param __FLAG__ specifies the flag to check. 391 * This parameter can be: 392 * @arg @ref RTC_FLAG_RECALPF Recalibration pending Flag 393 * @arg @ref RTC_FLAG_INITF Initialization flag 394 * @arg @ref RTC_FLAG_RSF Registers synchronization flag 395 * @arg @ref RTC_FLAG_INITS Initialization status flag 396 * @arg @ref RTC_FLAG_SHPF Shift operation pending flag 397 * @arg @ref RTC_FLAG_WUTWF Wakeup timer write flag 398 * @arg @ref RTC_FLAG_ALRBWF Alarm B write flag 399 * @arg @ref RTC_FLAG_ALRAWF Alarm A write flag 400 * @arg @ref RTC_FLAG_ITSF Internal Time-stamp flag 401 * @arg @ref RTC_FLAG_TSOVF Time-stamp overflow flag 402 * @arg @ref RTC_FLAG_TSF Time-stamp flag 403 * @arg @ref RTC_FLAG_WUTF Wakeup timer flag 404 * @arg @ref RTC_FLAG_ALRBF Alarm B flag 405 * @arg @ref RTC_FLAG_ALRAF Alarm A flag 406 * @retval None 407 */ 408 #define __HAL_RTC_GET_FLAG(__HANDLE__, __FLAG__) (((((__FLAG__)) >> 8U) == 1U) ? ((((__HANDLE__)->Instance->ICSR & (1U << (((uint16_t)(__FLAG__)) & RTC_FLAG_MASK))) != 0U) ? 1U : 0U) :\ 409 ((((__HANDLE__)->Instance->SR & (1U << (((uint16_t)(__FLAG__)) & RTC_FLAG_MASK))) != 0U) ? 1U : 0U)) 410 411 /* ---------------------------------WAKEUPTIMER---------------------------------*/ 412 /** @defgroup RTCEx_WakeUp_Timer RTC WakeUp Timer 413 * @{ 414 */ 415 /** 416 * @brief Enable the RTC WakeUp Timer peripheral. 417 * @param __HANDLE__ specifies the RTC handle. 418 * @retval None 419 */ 420 #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE)) 421 422 /** 423 * @brief Disable the RTC WakeUp Timer peripheral. 424 * @param __HANDLE__ specifies the RTC handle. 425 * @retval None 426 */ 427 #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE)) 428 429 /** 430 * @brief Enable the RTC WakeUpTimer interrupt. 431 * @param __HANDLE__ specifies the RTC handle. 432 * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be enabled. 433 * This parameter can be: 434 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 435 * @retval None 436 */ 437 #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) 438 439 /** 440 * @brief Disable the RTC WakeUpTimer interrupt. 441 * @param __HANDLE__ specifies the RTC handle. 442 * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be disabled. 443 * This parameter can be: 444 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 445 * @retval None 446 */ 447 #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) 448 449 /** 450 * @brief Check whether the specified RTC WakeUpTimer interrupt has occurred or not. 451 * @param __HANDLE__ specifies the RTC handle. 452 * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt to check. 453 * This parameter can be: 454 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 455 * @retval None 456 */ 457 #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->SR) & ((__INTERRUPT__)>> 12U)) != 0U) ? 1U : 0U) 458 459 /** 460 * @brief Check whether the specified RTC Wake Up timer interrupt has been enabled or not. 461 * @param __HANDLE__ specifies the RTC handle. 462 * @param __INTERRUPT__ specifies the RTC Wake Up timer interrupt sources to check. 463 * This parameter can be: 464 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 465 * @retval None 466 */ 467 #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U) 468 469 /** 470 * @brief Get the selected RTC WakeUpTimers flag status. 471 * @param __HANDLE__ specifies the RTC handle. 472 * @param __FLAG__ specifies the RTC WakeUpTimer Flag is pending or not. 473 * This parameter can be: 474 * @arg @ref RTC_FLAG_WUTF 475 * @arg @ref RTC_FLAG_WUTWF 476 * @retval None 477 */ 478 #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__))) 479 480 /** 481 * @brief Clear the RTC Wake Up timers pending flags. 482 * @param __HANDLE__ specifies the RTC handle. 483 * @param __FLAG__ specifies the RTC WakeUpTimer Flag to clear. 484 * This parameter can be: 485 * @arg @ref RTC_FLAG_WUTF 486 * @retval None 487 */ 488 #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_WUTF)) 489 490 /* WAKE-UP TIMER EXTI */ 491 /* ------------------ */ 492 /** 493 * @brief Enable interrupt on the RTC WakeUp Timer associated Exti line. 494 * @retval None 495 */ 496 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 497 498 /** 499 * @brief Disable interrupt on the RTC WakeUp Timer associated Exti line. 500 * @retval None 501 */ 502 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT)) 503 504 /** 505 * @brief Enable event on the RTC WakeUp Timer associated Exti line. 506 * @retval None. 507 */ 508 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 509 510 /** 511 * @brief Disable event on the RTC WakeUp Timer associated Exti line. 512 * @retval None. 513 */ 514 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT)) 515 516 /** 517 * @} 518 */ 519 520 /* ---------------------------------TIMESTAMP---------------------------------*/ 521 /** @defgroup RTCEx_Timestamp RTC Timestamp 522 * @{ 523 */ 524 /** 525 * @brief Enable the RTC TimeStamp peripheral. 526 * @param __HANDLE__ specifies the RTC handle. 527 * @retval None 528 */ 529 #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE)) 530 531 /** 532 * @brief Disable the RTC TimeStamp peripheral. 533 * @param __HANDLE__ specifies the RTC handle. 534 * @retval None 535 */ 536 #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE)) 537 538 /** 539 * @brief Enable the RTC TimeStamp interrupt. 540 * @param __HANDLE__ specifies the RTC handle. 541 * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be enabled. 542 * This parameter can be: 543 * @arg @ref RTC_IT_TS TimeStamp interrupt 544 * @retval None 545 */ 546 #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) 547 548 /** 549 * @brief Disable the RTC TimeStamp interrupt. 550 * @param __HANDLE__ specifies the RTC handle. 551 * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be disabled. 552 * This parameter can be: 553 * @arg @ref RTC_IT_TS TimeStamp interrupt 554 * @retval None 555 */ 556 #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) 557 558 /** 559 * @brief Check whether the specified RTC TimeStamp interrupt has occurred or not. 560 * @param __HANDLE__ specifies the RTC handle. 561 * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt to check. 562 * This parameter can be: 563 * @arg @ref RTC_IT_TS TimeStamp interrupt 564 * @retval None 565 */ 566 #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->SR) & ((__INTERRUPT__)>> 12U)) != 0U) ? 1U : 0U) 567 568 /** 569 * @brief Check whether the specified RTC Time Stamp interrupt has been enabled or not. 570 * @param __HANDLE__ specifies the RTC handle. 571 * @param __INTERRUPT__ specifies the RTC Time Stamp interrupt source to check. 572 * This parameter can be: 573 * @arg @ref RTC_IT_TS TimeStamp interrupt 574 * @retval None 575 */ 576 #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U) 577 578 /** 579 * @brief Get the selected RTC TimeStamps flag status. 580 * @param __HANDLE__ specifies the RTC handle. 581 * @param __FLAG__ specifies the RTC TimeStamp Flag is pending or not. 582 * This parameter can be: 583 * @arg @ref RTC_FLAG_TSF 584 * @arg @ref RTC_FLAG_TSOVF 585 * @retval None 586 */ 587 #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__),(__FLAG__))) 588 589 /** 590 * @brief Clear the RTC Time Stamps pending flags. 591 * @param __HANDLE__ specifies the RTC handle. 592 * @param __FLAG__ specifies the RTC TimeStamp Flag to clear. 593 * This parameter can be: 594 * @arg @ref RTC_FLAG_TSF 595 * @arg @ref RTC_FLAG_TSOVF 596 * @retval None 597 */ 598 #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_CLEAR_FLAG((__HANDLE__), (__FLAG__))) 599 600 /** 601 * @brief Enable interrupt on the RTC Timestamp associated Exti line. 602 * @retval None 603 */ 604 #define __HAL_RTC_TIMESTAMP_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_TIMESTAMP_EVENT) 605 606 /** 607 * @brief Disable interrupt on the RTC Timestamp associated Exti line. 608 * @retval None 609 */ 610 #define __HAL_RTC_TIMESTAMP_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_TIMESTAMP_EVENT)) 611 612 /** 613 * @brief Enable event on the RTC Timestamp associated Exti line. 614 * @retval None 615 */ 616 #define __HAL_RTC_TIMESTAMP_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_TIMESTAMP_EVENT) 617 618 /** 619 * @brief Disable event on the RTC Timestamp associated Exti line. 620 * @retval None 621 */ 622 #define __HAL_RTC_TIMESTAMP_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_TIMESTAMP_EVENT)) 623 624 /** 625 * @brief Enable the RTC internal TimeStamp peripheral. 626 * @param __HANDLE__ specifies the RTC handle. 627 * @retval None 628 */ 629 #define __HAL_RTC_INTERNAL_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ITSE)) 630 631 /** 632 * @brief Disable the RTC internal TimeStamp peripheral. 633 * @param __HANDLE__ specifies the RTC handle. 634 * @retval None 635 */ 636 #define __HAL_RTC_INTERNAL_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ITSE)) 637 638 /** 639 * @brief Get the selected RTC Internal Time Stamps flag status. 640 * @param __HANDLE__ specifies the RTC handle. 641 * @param __FLAG__ specifies the RTC Internal Time Stamp Flag is pending or not. 642 * This parameter can be: 643 * @arg @ref RTC_FLAG_ITSF 644 * @retval None 645 */ 646 #define __HAL_RTC_INTERNAL_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__),(__FLAG__))) 647 648 /** 649 * @brief Clear the RTC Internal Time Stamps pending flags. 650 * @param __HANDLE__ specifies the RTC handle. 651 * @param __FLAG__ specifies the RTC Internal Time Stamp Flag source to clear. 652 * This parameter can be: 653 * @arg @ref RTC_FLAG_ITSF 654 * @retval None 655 */ 656 #define __HAL_RTC_INTERNAL_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_ITSF)) 657 658 /** 659 * @brief Enable the RTC TimeStamp on Tamper detection. 660 * @param __HANDLE__ specifies the RTC handle. 661 * @retval None 662 */ 663 #define __HAL_RTC_TAMPTS_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TAMPTS)) 664 665 /** 666 * @brief Disable the RTC TimeStamp on Tamper detection. 667 * @param __HANDLE__ specifies the RTC handle. 668 * @retval None 669 */ 670 #define __HAL_RTC_TAMPTS_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TAMPTS)) 671 672 /** 673 * @brief Enable the RTC Tamper detection output. 674 * @param __HANDLE__ specifies the RTC handle. 675 * @retval None 676 */ 677 #define __HAL_RTC_TAMPOE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TAMPOE)) 678 679 /** 680 * @brief Disable the RTC Tamper detection output. 681 * @param __HANDLE__ specifies the RTC handle. 682 * @retval None 683 */ 684 #define __HAL_RTC_TAMPOE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TAMPOE)) 685 686 687 /** 688 * @} 689 */ 690 691 692 /* ------------------------------Calibration----------------------------------*/ 693 /** @defgroup RTCEx_Calibration RTC Calibration 694 * @{ 695 */ 696 697 /** 698 * @brief Enable the RTC calibration output. 699 * @param __HANDLE__ specifies the RTC handle. 700 * @retval None 701 */ 702 #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_COE)) 703 704 /** 705 * @brief Disable the calibration output. 706 * @param __HANDLE__ specifies the RTC handle. 707 * @retval None 708 */ 709 #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE)) 710 711 712 /** 713 * @brief Enable the clock reference detection. 714 * @param __HANDLE__ specifies the RTC handle. 715 * @retval None 716 */ 717 #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON)) 718 719 /** 720 * @brief Disable the clock reference detection. 721 * @param __HANDLE__ specifies the RTC handle. 722 * @retval None 723 */ 724 #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON)) 725 726 727 /** 728 * @brief Get the selected RTC shift operations flag status. 729 * @param __HANDLE__ specifies the RTC handle. 730 * @param __FLAG__ specifies the RTC shift operation Flag is pending or not. 731 * This parameter can be: 732 * @arg @ref RTC_FLAG_SHPF 733 * @retval None 734 */ 735 #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__))) 736 /** 737 * @} 738 */ 739 740 741 /* ------------------------------Tamper----------------------------------*/ 742 /** @defgroup RTCEx_Tamper RTCEx tamper 743 * @{ 744 */ 745 /** 746 * @brief Enable the TAMP Tamper input detection. 747 * @param __HANDLE__ specifies the RTC handle. 748 * @param __TAMPER__ specifies the RTC Tamper source to be enabled. 749 * This parameter can be any combination of the following values: 750 * @arg RTC_ALL_TAMPER: All tampers 751 * @arg RTC_TAMPER_1: Tamper1 752 * @arg RTC_TAMPER_2: Tamper2 753 * @arg RTC_TAMPER_3: Tamper3 (*) 754 * @retval None 755 */ 756 #define __HAL_RTC_TAMPER_ENABLE(__HANDLE__, __TAMPER__) (((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->CR1 |= (__TAMPER__)) 757 758 /** 759 * @brief Disable the TAMP Tamper input detection. 760 * @param __HANDLE__ specifies the TAMP handle. 761 * @param __TAMPER__ specifies the TAMP Tamper sources to be enabled. 762 * This parameter can be any combination of the following values: 763 * @arg RTC_ALL_TAMPER: All tampers 764 * @arg RTC_TAMPER_1: Tamper1 765 * @arg RTC_TAMPER_2: Tamper2 766 * @arg RTC_TAMPER_3: Tamper3 (*) 767 */ 768 #define __HAL_RTC_TAMPER_DISABLE(__HANDLE__, __TAMPER__) (((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->CR1 &= ~(__TAMPER__)) 769 770 771 /**************************************************************************************************/ 772 /** 773 * @brief Enable the TAMP Tamper interrupt. 774 * @param __HANDLE__ specifies the TAMP handle. 775 * @param __INTERRUPT__ specifies the TAMP Tamper interrupt sources to be enabled. 776 * This parameter can be any combination of the following values: 777 * @arg RTC_IT_TAMPALL: All tampers interrupts 778 * @arg RTC_IT_TAMP1: Tamper1 interrupt 779 * @arg RTC_IT_TAMP2: Tamper2 interrupt 780 * @arg RTC_IT_TAMP3: Tamper3 interrupt (*) 781 * @retval None 782 */ 783 #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->IER |= (__INTERRUPT__)) 784 785 /** 786 * @brief Disable the TAMP Tamper interrupt. 787 * @param __HANDLE__ specifies the TAMP handle. 788 * @param __INTERRUPT__ specifies the TAMP Tamper interrupt sources to be disabled. 789 * This parameter can be any combination of the following values: 790 * @arg RTC_IT_TAMPALL: All tampers interrupts 791 * @arg RTC_IT_TAMP1: Tamper1 interrupt 792 * @arg RTC_IT_TAMP2: Tamper2 interrupt 793 * @arg RTC_IT_TAMP3: Tamper3 interrupt (*) 794 * @retval None 795 */ 796 #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->IER &= ~(__INTERRUPT__)) 797 798 799 /**************************************************************************************************/ 800 /** 801 * @brief Check whether the specified TAMP Tamper interrupt has occurred or not. 802 * @param __HANDLE__ specifies the TAMP handle. 803 * @param __INTERRUPT__ specifies the TAMP Tamper interrupt to check. 804 * This parameter can be: 805 * @arg RTC_IT_TAMPALL: All tampers interrupts 806 * @arg RTC_IT_TAMP1: Tamper1 interrupt 807 * @arg RTC_IT_TAMP2: Tamper2 interrupt 808 * @arg RTC_IT_TAMP3: Tamper3 interrupt (*) 809 * @arg RTC_IT_INT_TAMP3: Internal Tamper3 interrupt 810 * @arg RTC_IT_INT_TAMP4: Internal Tamper4 interrupt 811 * @arg RTC_IT_INT_TAMP5: Internal Tamper5 interrupt 812 * @arg RTC_IT_INT_TAMP6: Internal Tamper6 interrupt 813 * @retval None 814 */ 815 #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) ((((((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->SR) & (__INTERRUPT__)) != 0U) ? 1U : 0U) 816 817 818 /** 819 * @brief Check whether the specified TAMP Tamper interrupt has been enabled or not. 820 * @param __HANDLE__ specifies the TAMP handle. 821 * @param __INTERRUPT__ specifies the TAMP Tamper interrupt source to check. 822 * This parameter can be: 823 * @arg RTC_IT_TAMPALL: All tampers interrupts 824 * @arg RTC_IT_TAMP1: Tamper1 interrupt 825 * @arg RTC_IT_TAMP2: Tamper2 interrupt 826 * @arg RTC_IT_TAMP3: Tamper3 interrupt (*) 827 * @arg RTC_IT_INT_TAMPALL: All internal tampers interrupts 828 * @arg RTC_IT_INT_TAMP3: Internal Tamper3 interrupt 829 * @arg RTC_IT_INT_TAMP4: Internal Tamper4 interrupt 830 * @arg RTC_IT_INT_TAMP5: Internal Tamper5 interrupt 831 * @arg RTC_IT_INT_TAMP6: Internal Tamper6 interrupt 832 * @retval None 833 */ 834 #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->IER) & (__INTERRUPT__)) != 0U) ? 1U : 0U) 835 836 837 /** 838 * @brief Get the selected TAMP Tampers flag status. 839 * @param __HANDLE__ specifies the TAMP handle. 840 * @param __FLAG__ specifies the TAMP Tamper Flag is pending or not. 841 * This parameter can be: 842 * @arg RTC_FLAG_TAMP1: Tamper1 flag 843 * @arg RTC_FLAG_TAMP2: Tamper2 flag 844 * @arg RTC_FLAG_TAMP3: Tamper3 flag (*) 845 * @arg RTC_FLAG_INT_TAMP3: Internal Tamper3 flag 846 * @arg RTC_FLAG_INT_TAMP4: Internal Tamper4 flag 847 * @arg RTC_FLAG_INT_TAMP5: Internal Tamper5 flag 848 * @arg RTC_FLAG_INT_TAMP6: Internal Tamper6 flag 849 * @retval None 850 */ 851 #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->SR) & (__FLAG__)) != 0U) 852 853 /** 854 * @brief Clear the TAMP Tampers pending flags. 855 * @param __HANDLE__ specifies the TAMP handle. 856 * @param __FLAG__ specifies the TAMP Tamper Flag to clear. 857 * This parameter can be: 858 * @arg RTC_FLAG_TAMPALL: All Tamper flags 859 * @arg RTC_FLAG_TAMP1: Tamper1 flag 860 * @arg RTC_FLAG_TAMP2: Tamper2 flag 861 * @arg RTC_FLAG_TAMP3: Tamper3 flag (*) 862 * @arg RTC_FLAG_INT_TAMP3: Internal Tamper3 flag 863 * @arg RTC_FLAG_INT_TAMP4: Internal Tamper4 flag 864 * @arg RTC_FLAG_INT_TAMP5: Internal Tamper5 flag 865 * @arg RTC_FLAG_INT_TAMP6: Internal Tamper6 flag 866 * @retval None 867 */ 868 #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((((TAMP_TypeDef *)((uint32_t)((__HANDLE__)->Instance) + (__HANDLE__)->TampOffset))->SCR) |= (__FLAG__)) 869 870 /** 871 * @brief Enable interrupt on the TAMP associated Exti line. 872 * @retval None 873 */ 874 #define __HAL_RTC_TAMPER_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_TAMPER_EVENT) 875 876 /** 877 * @brief Disable interrupt on the TAMP associated Exti line. 878 * @retval None 879 */ 880 #define __HAL_RTC_TAMPER_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_TAMPER_EVENT)) 881 882 /** 883 * @brief Enable event on the TAMP associated Exti line. 884 * @retval None 885 */ 886 #define __HAL_RTC_TAMPER_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_TAMPER_EVENT) 887 888 /** 889 * @brief Disable event on the TAMP associated Exti line. 890 * @retval None 891 */ 892 #define __HAL_RTC_TAMPER_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_TAMPER_EVENT)) 893 894 /** 895 * @} 896 */ 897 898 /** 899 * @} 900 */ 901 902 /* Exported functions --------------------------------------------------------*/ 903 /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions 904 * @{ 905 */ 906 907 /* RTC TimeStamp functions *****************************************/ 908 /** @defgroup RTCEx_Exported_Functions_Group1 Extended RTC TimeStamp functions 909 * @{ 910 */ 911 912 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin); 913 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin); 914 HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc); 915 HAL_StatusTypeDef HAL_RTCEx_SetInternalTimeStamp(RTC_HandleTypeDef *hrtc); 916 HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTimeStamp(RTC_HandleTypeDef *hrtc); 917 HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format); 918 919 void HAL_RTCEx_TimeStampIRQHandler(RTC_HandleTypeDef *hrtc); 920 HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 921 void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc); 922 /** 923 * @} 924 */ 925 926 927 /* RTC Wake-up functions ******************************************************/ 928 /** @defgroup RTCEx_Exported_Functions_Group2 Extended RTC Wake-up functions 929 * @{ 930 */ 931 932 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock); 933 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock); 934 HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc); 935 uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc); 936 void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc); 937 void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc); 938 HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 939 /** 940 * @} 941 */ 942 943 /* Extended Control functions ************************************************/ 944 /** @defgroup RTCEx_Exported_Functions_Group3 Extended Peripheral Control functions 945 * @{ 946 */ 947 948 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue); 949 HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS); 950 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput); 951 HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc); 952 HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc); 953 HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc); 954 HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc); 955 HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc); 956 /** 957 * @} 958 */ 959 960 /* Extended RTC features functions *******************************************/ 961 /** @defgroup RTCEx_Exported_Functions_Group4 Extended features functions 962 * @{ 963 */ 964 965 void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc); 966 HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 967 /** 968 * @} 969 */ 970 971 /** @defgroup RTCEx_Exported_Functions_Group5 Extended RTC Tamper functions 972 * @{ 973 */ 974 HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper); 975 HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper); 976 HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper); 977 HAL_StatusTypeDef HAL_RTCEx_PollForTamperEvent(RTC_HandleTypeDef *hrtc, uint32_t Tamper, uint32_t Timeout); 978 HAL_StatusTypeDef HAL_RTCEx_SetInternalTamper(RTC_HandleTypeDef *hrtc, RTC_InternalTamperTypeDef* sIntTamper); 979 HAL_StatusTypeDef HAL_RTCEx_SetInternalTamper_IT(RTC_HandleTypeDef *hrtc, RTC_InternalTamperTypeDef* sIntTamper); 980 HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTamper(RTC_HandleTypeDef *hrtc, uint32_t IntTamper); 981 HAL_StatusTypeDef HAL_RTCEx_PollForInternalTamperEvent(RTC_HandleTypeDef *hrtc, uint32_t IntTamper, uint32_t Timeout); 982 void HAL_RTCEx_TamperIRQHandler(RTC_HandleTypeDef *hrtc); 983 void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc); 984 void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc); 985 #if defined(TAMP_CR1_TAMP3E) 986 void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc); 987 #endif /* TAMP_CR1_TAMP3E */ 988 void HAL_RTCEx_InternalTamper3EventCallback(RTC_HandleTypeDef *hrtc); 989 void HAL_RTCEx_InternalTamper4EventCallback(RTC_HandleTypeDef *hrtc); 990 void HAL_RTCEx_InternalTamper5EventCallback(RTC_HandleTypeDef *hrtc); 991 void HAL_RTCEx_InternalTamper6EventCallback(RTC_HandleTypeDef *hrtc); 992 /** 993 * @} 994 */ 995 996 /** @defgroup RTCEx_Exported_Functions_Group6 Extended RTC Backup register functions 997 * @{ 998 */ 999 void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data); 1000 uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister); 1001 /** 1002 * @} 1003 */ 1004 1005 1006 /** 1007 * @} 1008 */ 1009 1010 /* Private types -------------------------------------------------------------*/ 1011 /* Private variables ---------------------------------------------------------*/ 1012 /* Private constants ---------------------------------------------------------*/ 1013 /** @defgroup RTCEx_Private_Constants RTCEx Private Constants 1014 * @{ 1015 */ 1016 #define RTC_EXTI_LINE_TIMESTAMP_EVENT EXTI_IMR1_IM19 /*!< External interrupt line 19 Connected to the RTC Time Stamp events */ 1017 #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT EXTI_IMR1_IM19 /*!< External interrupt line 19 Connected to the RTC Wakeup event */ 1018 #define RTC_EXTI_LINE_TAMPER_EVENT EXTI_IMR1_IM21 /*!< External interrupt line 19 Connected to the RTC tamper events*/ 1019 1020 /** 1021 * @} 1022 */ 1023 1024 /* Private macros ------------------------------------------------------------*/ 1025 /** @defgroup RTCEx_Private_Macros RTCEx Private Macros 1026 * @{ 1027 */ 1028 1029 /** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters 1030 * @{ 1031 */ 1032 #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \ 1033 ((EDGE) == RTC_TIMESTAMPEDGE_FALLING)) 1034 1035 1036 #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TIMESTAMPPIN_DEFAULT)) 1037 1038 1039 1040 #define IS_RTC_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \ 1041 ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE)) 1042 1043 #define IS_RTC_TAMPER_TAMPERDETECTIONOUTPUT(MODE) (((MODE) == RTC_TAMPERDETECTIONOUTPUT_ENABLE) || \ 1044 ((MODE) == RTC_TAMPERDETECTIONOUTPUT_DISABLE)) 1045 1046 1047 #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \ 1048 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \ 1049 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \ 1050 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \ 1051 ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \ 1052 ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS)) 1053 1054 #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= RTC_WUTR_WUT) 1055 1056 #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \ 1057 ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \ 1058 ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC)) 1059 1060 #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \ 1061 ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET)) 1062 1063 #define IS_RTC_TAMPER(__TAMPER__) ((((__TAMPER__) & RTC_TAMPER_ALL) != 0x00U) && \ 1064 (((__TAMPER__) & ~RTC_TAMPER_ALL) == 0x00U)) 1065 1066 #define IS_RTC_INTERNAL_TAMPER(__INT_TAMPER__) ((((__INT_TAMPER__) & RTC_INT_TAMPER_ALL) != 0x00U) && \ 1067 (((__INT_TAMPER__) & ~RTC_INT_TAMPER_ALL) == 0x00U)) 1068 1069 #define IS_RTC_TAMPER_TRIGGER(__TRIGGER__) (((__TRIGGER__) == RTC_TAMPERTRIGGER_RISINGEDGE) || \ 1070 ((__TRIGGER__) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \ 1071 ((__TRIGGER__) == RTC_TAMPERTRIGGER_LOWLEVEL) || \ 1072 ((__TRIGGER__) == RTC_TAMPERTRIGGER_HIGHLEVEL)) 1073 1074 #define IS_RTC_TAMPER_ERASE_MODE(__MODE__) (((__MODE__) == RTC_TAMPER_ERASE_BACKUP_ENABLE) || \ 1075 ((__MODE__) == RTC_TAMPER_ERASE_BACKUP_DISABLE)) 1076 1077 #define IS_RTC_TAMPER_MASKFLAG_STATE(__STATE__) (((__STATE__) == RTC_TAMPERMASK_FLAG_ENABLE) || \ 1078 ((__STATE__) == RTC_TAMPERMASK_FLAG_DISABLE)) 1079 1080 #define IS_RTC_TAMPER_FILTER(__FILTER__) (((__FILTER__) == RTC_TAMPERFILTER_DISABLE) || \ 1081 ((__FILTER__) == RTC_TAMPERFILTER_2SAMPLE) || \ 1082 ((__FILTER__) == RTC_TAMPERFILTER_4SAMPLE) || \ 1083 ((__FILTER__) == RTC_TAMPERFILTER_8SAMPLE)) 1084 1085 #define IS_RTC_TAMPER_SAMPLING_FREQ(__FREQ__) (((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \ 1086 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \ 1087 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \ 1088 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \ 1089 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \ 1090 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \ 1091 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \ 1092 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256)) 1093 1094 #define IS_RTC_TAMPER_PRECHARGE_DURATION(__DURATION__) (((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \ 1095 ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \ 1096 ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \ 1097 ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK)) 1098 1099 #define IS_RTC_TAMPER_PULLUP_STATE(__STATE__) (((__STATE__) == RTC_TAMPER_PULLUP_ENABLE) || \ 1100 ((__STATE__) == RTC_TAMPER_PULLUP_DISABLE)) 1101 1102 #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \ 1103 ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE)) 1104 1105 #define IS_RTC_BKP(__BKP__) ((__BKP__) < RTC_BKP_NUMBER) 1106 1107 1108 /** @defgroup RTCEx_Smooth_calib_Minus_pulses_Definitions RTCEx Smooth calib Minus pulses Definitions 1109 * @{ 1110 */ 1111 #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= RTC_CALR_CALM) 1112 /** 1113 * @} 1114 */ 1115 1116 1117 #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \ 1118 ((SEL) == RTC_SHIFTADD1S_SET)) 1119 1120 1121 1122 /** @defgroup RTCEx_Subtract_Fraction_Of_Second_Value RTCEx Subtract Fraction Of Second Value 1123 * @{ 1124 */ 1125 #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= RTC_SHIFTR_SUBFS) 1126 /** 1127 * @} 1128 */ 1129 #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \ 1130 ((OUTPUT) == RTC_CALIBOUTPUT_1HZ)) 1131 1132 /** 1133 * @} 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 /* STM32G0xx_HAL_RTC_EX_H */ 1155 1156