1 /** 2 ****************************************************************************** 3 * @file stm32u0xx_hal_rtc_ex.h 4 * @author GPM Application Team 5 * @brief Header file of RTC HAL Extended module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2023 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 __STM32U0xx_HAL_RTC_EX_H 21 #define __STM32U0xx_HAL_RTC_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32u0xx_hal_def.h" 29 /** @addtogroup STM32U0xx_HAL_Driver 30 * @{ 31 */ 32 33 /** @defgroup RTCEx RTCEx 34 * @{ 35 */ 36 37 /* Exported types ------------------------------------------------------------*/ 38 /** @defgroup RTCEx_Exported_Types RTCEx Exported Types 39 * @{ 40 */ 41 42 /** @defgroup RTCEx_Tamper_structure_definition RTCEx Tamper structure definition 43 * @{ 44 */ 45 typedef struct 46 { 47 uint32_t Tamper; /*!< Specifies the Tamper Pin. 48 This parameter can be a value of @ref RTCEx_Tamper_Pins */ 49 50 uint32_t Trigger; /*!< Specifies the Tamper Trigger. 51 This parameter can be a value of @ref RTCEx_Tamper_Trigger */ 52 53 uint32_t NoErase; /*!< Specifies the Tamper no erase mode. 54 This parameter can be a value of @ref RTCEx_Tamper_EraseBackUp */ 55 56 uint32_t MaskFlag; /*!< Specifies the Tamper Flag masking. 57 This parameter can be a value of @ref RTCEx_Tamper_MaskFlag */ 58 59 uint32_t Filter; /*!< Specifies the TAMP Filter Tamper. 60 This parameter can be a value of @ref RTCEx_Tamper_Filter */ 61 62 uint32_t SamplingFrequency; /*!< Specifies the sampling frequency. 63 This parameter can be a value of @ref RTCEx_Tamper_Sampling_Frequencies */ 64 65 uint32_t PrechargeDuration; /*!< Specifies the Precharge Duration . 66 This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration */ 67 68 uint32_t TamperPullUp; /*!< Specifies the Tamper PullUp . 69 This parameter can be a value of @ref RTCEx_Tamper_Pull_UP */ 70 71 uint32_t TimeStampOnTamperDetection; /*!< Specifies the TimeStampOnTamperDetection. 72 This parameter can be a value of 73 @ref RTCEx_Tamper_TimeStampOnTamperDetection */ 74 } RTC_TamperTypeDef; 75 /** 76 * @} 77 */ 78 79 /** 80 * @} 81 */ 82 83 /** @defgroup RTCEx_Internal_Tamper_structure_definition RTCEx Internal Tamper structure definition 84 * @{ 85 */ 86 typedef struct 87 { 88 uint32_t IntTamper; /*!< Specifies the Internal Tamper Pin. 89 This parameter can be a value of @ref RTCEx_Internal_Tamper_Pins */ 90 91 uint32_t TimeStampOnTamperDetection; /*!< Specifies the TimeStampOnTamperDetection. 92 This parameter can be a value of 93 @ref RTCEx_Tamper_TimeStampOnTamperDetection */ 94 95 uint32_t NoErase; /*!< Specifies the internal Tamper no erase mode. 96 This parameter can be a value of @ref RTCEx_Tamper_EraseBackUp */ 97 } RTC_InternalTamperTypeDef; 98 /** 99 * @} 100 */ 101 102 /** 103 * @} 104 */ 105 106 /* Exported constants --------------------------------------------------------*/ 107 /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants 108 * @{ 109 */ 110 111 /** @defgroup RTCEx_Time_Stamp_Edges_definitions RTCEx Time Stamp Edges definition 112 * @{ 113 */ 114 #define RTC_TIMESTAMPEDGE_RISING 0x00000000U 115 #define RTC_TIMESTAMPEDGE_FALLING RTC_CR_TSEDGE 116 /** 117 * @} 118 */ 119 120 /** @defgroup RTCEx_TimeStamp_Pin_Selections RTCEx TimeStamp Pin Selection 121 * @{ 122 */ 123 #define RTC_TIMESTAMPPIN_DEFAULT 0x00000000U 124 /** 125 * @} 126 */ 127 128 /** @defgroup RTCEx_Wakeup_Timer_Definitions RTCEx Wakeup Timer Definitions 129 * @{ 130 */ 131 #define RTC_WAKEUPCLOCK_RTCCLK_DIV16 0x00000000U 132 #define RTC_WAKEUPCLOCK_RTCCLK_DIV8 RTC_CR_WUCKSEL_0 133 #define RTC_WAKEUPCLOCK_RTCCLK_DIV4 RTC_CR_WUCKSEL_1 134 #define RTC_WAKEUPCLOCK_RTCCLK_DIV2 (RTC_CR_WUCKSEL_0 | RTC_CR_WUCKSEL_1) 135 #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS RTC_CR_WUCKSEL_2 136 #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_2) 137 /** 138 * @} 139 */ 140 141 /** @defgroup RTCEx_Smooth_calib_period_Definitions RTCEx Smooth calib period Definitions 142 * @{ 143 */ 144 #define RTC_SMOOTHCALIB_PERIOD_32SEC 0x00000000U /*!< If RTCCLK = 32768 Hz, Smooth calibration 145 period is 32s, else 2exp20 RTCCLK pulses */ 146 #define RTC_SMOOTHCALIB_PERIOD_16SEC RTC_CALR_CALW16 /*!< If RTCCLK = 32768 Hz, Smooth calibration 147 period is 16s, else 2exp19 RTCCLK pulses */ 148 #define RTC_SMOOTHCALIB_PERIOD_8SEC RTC_CALR_CALW8 /*!< If RTCCLK = 32768 Hz, Smooth calibration 149 period is 8s, else 2exp18 RTCCLK pulses */ 150 /** 151 * @} 152 */ 153 154 /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions RTCEx Smooth calib Plus pulses Definitions 155 * @{ 156 */ 157 #define RTC_SMOOTHCALIB_PLUSPULSES_SET RTC_CALR_CALP /*!< The number of RTCCLK pulses added 158 during a X -second window = Y - CALM[8:0] 159 with Y = 512, 256, 128 when X = 32, 16, 8 */ 160 #define RTC_SMOOTHCALIB_PLUSPULSES_RESET 0x00000000U /*!< The number of RTCCLK pulses subbstited 161 during a 32-second window = CALM[8:0] */ 162 /** 163 * @} 164 */ 165 166 /** @defgroup RTCEx_Smooth_calib_low_power_Definitions RTCEx Smooth calib Low Power Definitions 167 * @{ 168 */ 169 #define RTC_LPCAL_SET RTC_CALR_LPCAL /*!< Calibration window is 220 ck_apre, 170 which is the required configuration for 171 ultra-low consumption mode. */ 172 #define RTC_LPCAL_RESET 0x00000000U /*!< Calibration window is 220 RTCCLK, 173 which is a high-consumption mode. 174 This mode should be set only when less 175 than 32s calibration window is required. */ 176 /** 177 * @} 178 */ 179 180 /** @defgroup RTCEx_Calib_Output_selection_Definitions RTCEx Calib Output selection Definitions 181 * @{ 182 */ 183 #define RTC_CALIBOUTPUT_512HZ 0x00000000U 184 #define RTC_CALIBOUTPUT_1HZ RTC_CR_COSEL 185 186 /** 187 * @} 188 */ 189 190 191 /** @defgroup RTCEx_Add_1_Second_Parameter_Definition RTCEx Add 1 Second Parameter Definitions 192 * @{ 193 */ 194 #define RTC_SHIFTADD1S_RESET 0x00000000U 195 #define RTC_SHIFTADD1S_SET RTC_SHIFTR_ADD1S 196 /** 197 * @} 198 */ 199 200 /** @defgroup RTCEx_Tamper_Pins RTCEx Tamper Pins Definition 201 * @{ 202 */ 203 #define RTC_TAMPER_1 TAMP_CR1_TAMP1E 204 #define RTC_TAMPER_2 TAMP_CR1_TAMP2E 205 #define RTC_TAMPER_3 TAMP_CR1_TAMP3E 206 #define RTC_TAMPER_4 TAMP_CR1_TAMP4E 207 #define RTC_TAMPER_5 TAMP_CR1_TAMP5E 208 #define RTC_TAMPER_ALL (RTC_TAMPER_1 | RTC_TAMPER_2 |\ 209 RTC_TAMPER_3 | RTC_TAMPER_4 |\ 210 RTC_TAMPER_5 ) 211 /** 212 * @} 213 */ 214 215 /** @defgroup RTCEx_Internal_Tamper_Pins RTCEx Internal Tamper Pins Definition 216 * @{ 217 */ 218 #define RTC_INT_TAMPER_3 TAMP_CR1_ITAMP3E 219 #define RTC_INT_TAMPER_4 TAMP_CR1_ITAMP4E 220 #define RTC_INT_TAMPER_5 TAMP_CR1_ITAMP5E 221 #define RTC_INT_TAMPER_6 TAMP_CR1_ITAMP6E 222 #define RTC_INT_TAMPER_ALL (RTC_INT_TAMPER_3 | RTC_INT_TAMPER_4 |\ 223 RTC_INT_TAMPER_5 | RTC_INT_TAMPER_6) 224 /** 225 * @} 226 */ 227 228 /** @defgroup RTCEx_Tamper_Trigger RTCEx Tamper Trigger 229 * @{ 230 */ 231 #define RTC_TAMPERTRIGGER_RISINGEDGE 0x00U /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */ 232 #define RTC_TAMPERTRIGGER_FALLINGEDGE 0x01U /*!< Warning : Filter must be RTC_TAMPERFILTER_DISABLE */ 233 #define RTC_TAMPERTRIGGER_LOWLEVEL 0x02U /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */ 234 #define RTC_TAMPERTRIGGER_HIGHLEVEL 0x03U /*!< Warning : Filter must not be RTC_TAMPERFILTER_DISABLE */ 235 /** 236 * @} 237 */ 238 239 /** @defgroup RTCEx_Tamper_MaskFlag RTCEx Tamper MaskFlag 240 * @{ 241 */ 242 #define RTC_TAMPERMASK_FLAG_DISABLE 0x00U 243 #define RTC_TAMPERMASK_FLAG_ENABLE 0x01U 244 /** 245 * @} 246 */ 247 248 /** @defgroup RTCEx_Tamper_EraseBackUp RTCEx Tamper EraseBackUp 249 * @{ 250 */ 251 #define RTC_TAMPER_ERASE_BACKUP_ENABLE 0x00U 252 #define RTC_TAMPER_ERASE_BACKUP_DISABLE 0x01U 253 /** 254 * @} 255 */ 256 257 /** @defgroup RTCEx_Tamper_Filter RTCEx Tamper Filter 258 * @{ 259 */ 260 #define RTC_TAMPERFILTER_DISABLE 0x00000000U /*!< Tamper filter is disabled */ 261 #define RTC_TAMPERFILTER_2SAMPLE TAMP_FLTCR_TAMPFLT_0 /*!< Tamper is activated after 2 262 consecutive samples at the active level */ 263 #define RTC_TAMPERFILTER_4SAMPLE TAMP_FLTCR_TAMPFLT_1 /*!< Tamper is activated after 4 264 consecutive samples at the active level */ 265 #define RTC_TAMPERFILTER_8SAMPLE TAMP_FLTCR_TAMPFLT /*!< Tamper is activated after 8 266 consecutive samples at the active level */ 267 /** 268 * @} 269 */ 270 271 /** @defgroup RTCEx_Tamper_Sampling_Frequencies RTCEx Tamper Sampling Frequencies 272 * @{ 273 */ 274 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 0x00000000U /*!< Each of the tamper inputs are sampled 275 with a frequency = RTCCLK / 32768 */ 276 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 TAMP_FLTCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled 277 with a frequency = RTCCLK / 16384 */ 278 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 TAMP_FLTCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled 279 with a frequency = RTCCLK / 8192 */ 280 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_1) /*!< Each of the tamper 281 inputs are sampled 282 with a frequency = 283 RTCCLK / 4096 */ 284 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 TAMP_FLTCR_TAMPFREQ_2 /*!< Each of the tamper 285 inputs are sampled 286 with a frequency = 287 RTCCLK / 2048 */ 288 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper 289 inputs are sampled 290 with a frequency = 291 RTCCLK / 1024 */ 292 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 (TAMP_FLTCR_TAMPFREQ_1 | TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper 293 inputs are sampled 294 with a frequency = 295 RTCCLK / 512 */ 296 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 (TAMP_FLTCR_TAMPFREQ_0 | TAMP_FLTCR_TAMPFREQ_1 | \ 297 TAMP_FLTCR_TAMPFREQ_2) /*!< Each of the tamper inputs are sampled 298 with a frequency = RTCCLK / 256 */ 299 /** 300 * @} 301 */ 302 303 /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration RTCEx Tamper Pin Precharge Duration 304 * @{ 305 */ 306 #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK 0x00000000U /*!< Tamper pins are pre-charged before 307 sampling during 1 RTCCLK cycle */ 308 #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK TAMP_FLTCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before 309 sampling during 2 RTCCLK cycles */ 310 #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK TAMP_FLTCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before 311 sampling during 4 RTCCLK cycles */ 312 #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK (TAMP_FLTCR_TAMPPRCH_0 | TAMP_FLTCR_TAMPPRCH_1) /*!< Tamper pins are 313 pre-charged before 314 sampling during 8 315 RTCCLK cycles */ 316 /** 317 * @} 318 */ 319 320 /** @defgroup RTCEx_Tamper_Pull_UP RTCEx Tamper Pull UP 321 * @{ 322 */ 323 #define RTC_TAMPER_PULLUP_ENABLE 0x00000000U /*!< Tamper pins are pre-charged before sampling */ 324 #define RTC_TAMPER_PULLUP_DISABLE TAMP_FLTCR_TAMPPUDIS /*!< Tamper pins pre-charge is disabled */ 325 /** 326 * @} 327 */ 328 329 /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection RTCEx Tamper TimeStamp On Tamper Detection Definitions 330 * @{ 331 */ 332 #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE 0x00000000U /*!< TimeStamp on Tamper Detection event is not saved */ 333 #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE RTC_CR_TAMPTS /*!< TimeStamp on Tamper Detection event saved */ 334 /** 335 * @} 336 */ 337 338 /** @defgroup RTCEx_Internal_Tamper_Interrupt RTCEx Internal Tamper Interrupt 339 * @{ 340 */ 341 #define RTC_IT_TAMP_1 TAMP_IER_TAMP1IE /*!< Tamper 1 Interrupt */ 342 #define RTC_IT_TAMP_2 TAMP_IER_TAMP2IE /*!< Tamper 2 Interrupt */ 343 #define RTC_IT_TAMP_3 TAMP_IER_TAMP3IE /*!< Tamper 3 Interrupt */ 344 #define RTC_IT_TAMP_4 TAMP_IER_TAMP4IE /*!< Tamper 4 Interrupt */ 345 #define RTC_IT_TAMP_5 TAMP_IER_TAMP5IE /*!< Tamper 5 Interrupt */ 346 #define RTC_IT_TAMP_ALL (RTC_IT_TAMP_1 | RTC_IT_TAMP_2 |\ 347 RTC_IT_TAMP_3 | RTC_IT_TAMP_4 |\ 348 RTC_IT_TAMP_5) 349 350 #define RTC_IT_INT_TAMP_3 TAMP_IER_ITAMP3IE /*!< Tamper 3 internal Interrupt */ 351 #define RTC_IT_INT_TAMP_4 TAMP_IER_ITAMP4IE /*!< Tamper 4 internal Interrupt */ 352 #define RTC_IT_INT_TAMP_5 TAMP_IER_ITAMP5IE /*!< Tamper 5 internal Interrupt */ 353 #define RTC_IT_INT_TAMP_6 TAMP_IER_ITAMP6IE /*!< Tamper 6 internal Interrupt */ 354 #define RTC_IT_INT_TAMP_ALL (RTC_IT_INT_TAMP_3 | RTC_IT_INT_TAMP_4 |\ 355 RTC_IT_INT_TAMP_5 | RTC_IT_INT_TAMP_6) 356 /** 357 * @} 358 */ 359 360 /** @defgroup RTCEx_Flags RTCEx Flags 361 * @{ 362 */ 363 #define RTC_FLAG_TAMP_1 TAMP_SR_TAMP1F 364 #define RTC_FLAG_TAMP_2 TAMP_SR_TAMP2F 365 #define RTC_FLAG_TAMP_3 TAMP_SR_TAMP3F 366 #define RTC_FLAG_TAMP_4 TAMP_SR_TAMP4F 367 #define RTC_FLAG_TAMP_5 TAMP_SR_TAMP5F 368 #define RTC_FLAG_TAMP_ALL (RTC_FLAG_TAMP_1 | RTC_FLAG_TAMP_2 | RTC_FLAG_TAMP_3 |\ 369 RTC_FLAG_TAMP_4 | RTC_FLAG_TAMP_5) 370 371 #define RTC_FLAG_INT_TAMP_3 TAMP_SR_ITAMP3F 372 #define RTC_FLAG_INT_TAMP_4 TAMP_SR_ITAMP4F 373 #define RTC_FLAG_INT_TAMP_5 TAMP_SR_ITAMP5F 374 #define RTC_FLAG_INT_TAMP_6 TAMP_SR_ITAMP6F 375 #define RTC_FLAG_INT_TAMP_ALL (RTC_FLAG_INT_TAMP_3 | RTC_FLAG_INT_TAMP_4 |\ 376 RTC_FLAG_INT_TAMP_5 | RTC_FLAG_INT_TAMP_6) 377 /** 378 * @} 379 */ 380 381 /** @defgroup RTCEx_Backup_Registers RTCEx Backup Registers Definition 382 * @{ 383 */ 384 #define RTC_BKP_NB 9u 385 #define RTC_BKP_NUMBER RTC_BKP_NB 386 #define RTC_BKP_DR0 0x00U 387 #define RTC_BKP_DR1 0x01U 388 #define RTC_BKP_DR2 0x02U 389 #define RTC_BKP_DR3 0x03U 390 #define RTC_BKP_DR4 0x04U 391 #define RTC_BKP_DR5 0x05U 392 #define RTC_BKP_DR6 0x06U 393 #define RTC_BKP_DR7 0x07U 394 #define RTC_BKP_DR8 0x08U 395 /** 396 * @} 397 */ 398 /** @defgroup RTCEx_Binary_Mode RTC Binary Mode (32-bit free-running counter configuration). 399 * Warning : It Should not be confused with the Binary format @ref RTC_Input_parameter_format_definitions. 400 * @{ 401 */ 402 #define RTC_BINARY_NONE 0x00000000U /*!< Free running BCD calendar mode (Binary mode disabled) */ 403 #define RTC_BINARY_ONLY RTC_ICSR_BIN_0 /*!< Free running Binary mode (BCD mode disabled) */ 404 #define RTC_BINARY_MIX RTC_ICSR_BIN_1 /*!< Free running BCD calendar and Binary modes */ 405 /** 406 * @} 407 */ 408 409 /** @defgroup RTCEx_Binary_mix_BCDU If Binary mode is RTC_BINARY_MIX, the BCD calendar second is incremented using the 410 SSR Least Significant Bits. 411 * @{ 412 */ 413 #define RTC_BINARY_MIX_BCDU_0 0x00000000U /*!< The 1s BCD calendar increment is generated each time SS[7:0] = 0 */ 414 #define RTC_BINARY_MIX_BCDU_1 (0x1UL << RTC_ICSR_BCDU_Pos) /*!< The 1s BCD calendar increment is generated each time SS[8:0] = 0 */ 415 #define RTC_BINARY_MIX_BCDU_2 (0x2UL << RTC_ICSR_BCDU_Pos) /*!< The 1s BCD calendar increment is generated each time SS[9:0] = 0 */ 416 #define RTC_BINARY_MIX_BCDU_3 (0x3UL << RTC_ICSR_BCDU_Pos) /*!< The 1s BCD calendar increment is generated each time SS[10:0] = 0 */ 417 #define RTC_BINARY_MIX_BCDU_4 (0x4UL << RTC_ICSR_BCDU_Pos) /*!< The 1s BCD calendar increment is generated each time SS[11:0] = 0 */ 418 #define RTC_BINARY_MIX_BCDU_5 (0x5UL << RTC_ICSR_BCDU_Pos) /*!< The 1s BCD calendar increment is generated each time SS[12:0] = 0 */ 419 #define RTC_BINARY_MIX_BCDU_6 (0x6UL << RTC_ICSR_BCDU_Pos) /*!< The 1s BCD calendar increment is generated each time SS[13:0] = 0 */ 420 #define RTC_BINARY_MIX_BCDU_7 (0x7UL << RTC_ICSR_BCDU_Pos) /*!< The 1s BCD calendar increment is generated each time SS[14:0] = 0 */ 421 /** 422 * @} 423 */ 424 425 /** @defgroup RTCEx_Alarm_Sub_Seconds_binary_Masks_Definitions RTC Alarm Sub Seconds with binary mode Masks Definitions 426 * @{ 427 */ 428 #define RTC_ALARMSUBSECONDBINMASK_ALL 0x00000000U /*!< All Alarm SS fields are masked. 429 There is no comparison on sub seconds 430 for Alarm */ 431 #define RTC_ALARMSUBSECONDBINMASK_SS31_1 (1UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:1] are don't care in Alarm 432 comparison.Only SS[0] is compared */ 433 #define RTC_ALARMSUBSECONDBINMASK_SS31_2 (2UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:2] are don't care in Alarm 434 comparison.Only SS[1:0] are compared */ 435 #define RTC_ALARMSUBSECONDBINMASK_SS31_3 (3UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:3] are don't care in Alarm 436 comparison.Only SS[2:0] are compared */ 437 #define RTC_ALARMSUBSECONDBINMASK_SS31_4 (4UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:4] are don't care in Alarm 438 comparison.Only SS[3:0] are compared */ 439 #define RTC_ALARMSUBSECONDBINMASK_SS31_5 (5UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:5] are don't care in Alarm 440 comparison.Only SS[4:0] are compared */ 441 #define RTC_ALARMSUBSECONDBINMASK_SS31_6 (6UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:6] are don't care in Alarm 442 comparison.Only SS[5:0] are compared */ 443 #define RTC_ALARMSUBSECONDBINMASK_SS31_7 (7UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:7] are don't care in Alarm 444 comparison.Only SS[6:0] are compared */ 445 #define RTC_ALARMSUBSECONDBINMASK_SS31_8 (8UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:8] are don't care in Alarm 446 comparison.Only SS[7:0] are compared */ 447 #define RTC_ALARMSUBSECONDBINMASK_SS31_9 (9UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:9] are don't care in Alarm 448 comparison.Only SS[8:0] are compared */ 449 #define RTC_ALARMSUBSECONDBINMASK_SS31_10 (10UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:10] are don't care in Alarm 450 comparison.Only SS[9:0] are compared */ 451 #define RTC_ALARMSUBSECONDBINMASK_SS31_11 (11UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:11] are don't care in Alarm 452 comparison.Only SS[10:0] are compared */ 453 #define RTC_ALARMSUBSECONDBINMASK_SS31_12 (12UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:12] are don't care in Alarm 454 comparison.Only SS[11:0] are compared */ 455 #define RTC_ALARMSUBSECONDBINMASK_SS31_13 (13UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:13] are don't care in Alarm 456 comparison.Only SS[12:0] are compared */ 457 #define RTC_ALARMSUBSECONDBINMASK_SS31_14 (14UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:14] are don't care in Alarm 458 comparison.Only SS[13:0] are compared */ 459 #define RTC_ALARMSUBSECONDBINMASK_SS31_15 (15UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:15] are don't care in Alarm 460 comparison.Only SS[14:0] are compared */ 461 #define RTC_ALARMSUBSECONDBINMASK_SS31_16 (16UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:16] are don't care in Alarm 462 comparison.Only SS[15:0] are compared */ 463 #define RTC_ALARMSUBSECONDBINMASK_SS31_17 (17UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:17] are don't care in Alarm 464 comparison.Only SS[16:0] are compared */ 465 #define RTC_ALARMSUBSECONDBINMASK_SS31_18 (18UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:18] are don't care in Alarm 466 comparison.Only SS[17:0] are compared */ 467 #define RTC_ALARMSUBSECONDBINMASK_SS31_19 (19UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:19] are don't care in Alarm 468 comparison.Only SS[18:0] are compared */ 469 #define RTC_ALARMSUBSECONDBINMASK_SS31_20 (20UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:20] are don't care in Alarm 470 comparison.Only SS[19:0] are compared */ 471 #define RTC_ALARMSUBSECONDBINMASK_SS31_21 (21UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:21] are don't care in Alarm 472 comparison.Only SS[20:0] are compared */ 473 #define RTC_ALARMSUBSECONDBINMASK_SS31_22 (22UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:22] are don't care in Alarm 474 comparison.Only SS[21:0] are compared */ 475 #define RTC_ALARMSUBSECONDBINMASK_SS31_23 (23UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:23] are don't care in Alarm 476 comparison.Only SS[22:0] are compared */ 477 #define RTC_ALARMSUBSECONDBINMASK_SS31_24 (24UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:24] are don't care in Alarm 478 comparison.Only SS[23:0] are compared */ 479 #define RTC_ALARMSUBSECONDBINMASK_SS31_25 (25UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:25] are don't care in Alarm 480 comparison.Only SS[24:0] are compared */ 481 #define RTC_ALARMSUBSECONDBINMASK_SS31_26 (26UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:26] are don't care in Alarm 482 comparison.Only SS[25:0] are compared */ 483 #define RTC_ALARMSUBSECONDBINMASK_SS31_27 (27UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:27] are don't care in Alarm 484 comparison.Only SS[26:0] are compared */ 485 #define RTC_ALARMSUBSECONDBINMASK_SS31_28 (28UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:28] are don't care in Alarm 486 comparison.Only SS[27:0] are compared */ 487 #define RTC_ALARMSUBSECONDBINMASK_SS31_29 (29UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:29] are don't care in Alarm 488 comparison.Only SS[28:0] are compared */ 489 #define RTC_ALARMSUBSECONDBINMASK_SS31_30 (30UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:30] are don't care in Alarm 490 comparison.Only SS[29:0] are compared */ 491 #define RTC_ALARMSUBSECONDBINMASK_SS31 (31UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31] is don't care in Alarm 492 comparison.Only SS[30:0] are compared */ 493 #define RTC_ALARMSUBSECONDBINMASK_NONE (32UL << RTC_ALRMASSR_MASKSS_Pos) /*!< SS[31:0] are compared and must 494 match to activate alarm.*/ 495 /** 496 * @} 497 */ 498 499 /** @defgroup RTCEx_Alarm_Sub_Seconds_binary_Clear_Definitions RTC Alarm Sub Seconds with binary mode auto clear 500 Definitions 501 * @{ 502 */ 503 #define RTC_ALARMSUBSECONDBIN_AUTOCLR_NO 0UL /*!< The synchronous Binary counter 504 (SS[31:0] in RTC_SSR) is free-running. */ 505 #define RTC_ALARMSUBSECONDBIN_AUTOCLR_YES RTC_ALRMASSR_SSCLR /*!< The synchronous Binary counter 506 (SS[31:0] in RTC_SSR) is running from 0xFFFFFFFF 507 to RTC_ALRMABINR -> SS[31:0] value and is 508 automatically reloaded with 0xFFFFFFFF 509 whenreaching RTC_ALRMABINR -> SS[31:0]. */ 510 /** 511 * @} 512 */ 513 514 /** 515 * @} 516 */ 517 518 /* Exported macros -----------------------------------------------------------*/ 519 /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros 520 * @{ 521 */ 522 523 /** @brief Clear the specified RTC pending flag. 524 * @param __HANDLE__ specifies the RTC Handle. 525 * @param __FLAG__ specifies the flag to check. 526 * This parameter can be any combination of the following values: 527 * @arg @ref RTC_CLEAR_ITSF Clear Internal Time-stamp flag 528 * @arg @ref RTC_CLEAR_TSOVF Clear Time-stamp overflow flag 529 * @arg @ref RTC_CLEAR_TSF Clear Time-stamp flag 530 * @arg @ref RTC_CLEAR_WUTF Clear Wakeup timer flag 531 * @arg @ref RTC_CLEAR_ALRBF Clear Alarm B flag 532 * @arg @ref RTC_CLEAR_ALRAF Clear Alarm A flag 533 * @arg @ref RTC_CLEAR_SSRUF Clear SSR underflow flag" 534 * @retval None 535 */ 536 #define __HAL_RTC_CLEAR_FLAG(__HANDLE__, __FLAG__) (RTC->SCR = (__FLAG__)) 537 538 /** @brief Check whether the specified RTC flag is set or not. 539 * @param __HANDLE__ specifies the RTC Handle. 540 * @param __FLAG__ specifies the flag to check. 541 * This parameter can be any combination of the following values: 542 * @arg @ref RTC_FLAG_RECALPF Recalibration pending Flag 543 * @arg @ref RTC_FLAG_INITF Initialization flag 544 * @arg @ref RTC_FLAG_RSF Registers synchronization flag 545 * @arg @ref RTC_FLAG_INITS Initialization status flag 546 * @arg @ref RTC_FLAG_SHPF Shift operation pending flag 547 * @arg @ref RTC_FLAG_WUTWF Wakeup timer write flag 548 * @arg @ref RTC_FLAG_ITSF Internal Time-stamp flag 549 * @arg @ref RTC_FLAG_TSOVF Time-stamp overflow flag 550 * @arg @ref RTC_FLAG_TSF Time-stamp flag 551 * @arg @ref RTC_FLAG_WUTF Wakeup timer flag 552 * @arg @ref RTC_FLAG_ALRBF Alarm B flag 553 * @arg @ref RTC_FLAG_ALRAF Alarm A flag 554 * @retval The state of __FLAG__ (TRUE or FALSE). 555 */ 556 #define __HAL_RTC_GET_FLAG(__HANDLE__, __FLAG__) \ 557 (((((__FLAG__)) >> 8U) == 1U) ? (RTC->ICSR & (1U << (((uint16_t)(__FLAG__)) & RTC_IT_MASK))) : \ 558 (RTC->SR & (1U << (((uint16_t)(__FLAG__)) & RTC_IT_MASK)))) 559 560 /* ---------------------------------WAKEUPTIMER---------------------------------*/ 561 /** @defgroup RTCEx_WakeUp_Timer RTC WakeUp Timer 562 * @{ 563 */ 564 /** 565 * @brief Enable the RTC WakeUp Timer peripheral. 566 * @param __HANDLE__ specifies the RTC handle. 567 * @retval None 568 */ 569 #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_WUTE)) 570 571 /** 572 * @brief Disable the RTC WakeUp Timer peripheral. 573 * @param __HANDLE__ specifies the RTC handle. 574 * @retval None 575 */ 576 #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_WUTE)) 577 578 /** 579 * @brief Enable the RTC WakeUpTimer interrupt. 580 * @param __HANDLE__ specifies the RTC handle. 581 * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be enabled. 582 * This parameter can be: 583 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 584 * @retval None 585 */ 586 #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR |= (__INTERRUPT__)) 587 588 /** 589 * @brief Disable the RTC WakeUpTimer interrupt. 590 * @param __HANDLE__ specifies the RTC handle. 591 * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt sources to be disabled. 592 * This parameter can be: 593 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 594 * @retval None 595 */ 596 #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR &= ~(__INTERRUPT__)) 597 598 599 /** 600 * @brief Check whether the specified RTC WakeUpTimer interrupt has occurred or not. 601 * @param __HANDLE__ specifies the RTC handle. 602 * @param __INTERRUPT__ specifies the RTC WakeUpTimer interrupt to check. 603 * This parameter can be: 604 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 605 * @retval The state of __FLAG__ (TRUE or FALSE). 606 */ 607 #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __INTERRUPT__) ((((RTC->MISR) &\ 608 ((__INTERRUPT__)>> 12U)) != 0UL) ? 1UL : 0UL) 609 /** 610 * @brief Check whether the specified RTC Wake Up timer interrupt has been enabled or not. 611 * @param __HANDLE__ specifies the RTC handle. 612 * @param __INTERRUPT__ specifies the RTC Wake Up timer interrupt sources to check. 613 * This parameter can be: 614 * @arg @ref RTC_IT_WUT WakeUpTimer interrupt 615 * @retval The state of __FLAG__ (TRUE or FALSE). 616 */ 617 #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((RTC->CR) &\ 618 (__INTERRUPT__)) != 0UL) ? 1UL : 0UL) 619 620 /** 621 * @brief Get the selected RTC WakeUpTimers flag status. 622 * @param __HANDLE__ specifies the RTC handle. 623 * @param __FLAG__ specifies the RTC WakeUpTimer Flag is pending or not. 624 * This parameter can be: 625 * @arg @ref RTC_FLAG_WUTF 626 * @arg @ref RTC_FLAG_WUTWF 627 * @retval The state of __FLAG__ (TRUE or FALSE). 628 */ 629 #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__))) 630 631 /** 632 * @brief Clear the RTC Wake Up timers pending flags. 633 * @param __HANDLE__ specifies the RTC handle. 634 * @param __FLAG__ specifies the RTC WakeUpTimer Flag to clear. 635 * This parameter can be: 636 * @arg @ref RTC_FLAG_WUTF 637 * @retval None 638 */ 639 #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_WUTF)) 640 641 /* WAKE-UP TIMER EXTI */ 642 /* ------------------ */ 643 /** 644 * @brief Enable interrupt on the RTC WakeUp Timer associated Exti line. 645 * @retval None 646 */ 647 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 648 649 /** 650 * @brief Disable interrupt on the RTC WakeUp Timer associated Exti line. 651 * @retval None 652 */ 653 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT)) 654 655 /** 656 * @brief Enable event on the RTC WakeUp Timer associated Exti line. 657 * @retval None 658 */ 659 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 660 661 /** 662 * @brief Disable event on the RTC WakeUp Timer associated Exti line. 663 * @retval None 664 */ 665 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT)) 666 667 /** 668 * @} 669 */ 670 671 672 /* ---------------------------------TIMESTAMP---------------------------------*/ 673 /** @defgroup RTCEx_Timestamp RTC Timestamp 674 * @{ 675 */ 676 /** 677 * @brief Enable the RTC TimeStamp peripheral. 678 * @param __HANDLE__ specifies the RTC handle. 679 * @retval None 680 */ 681 #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_TSE)) 682 683 /** 684 * @brief Disable the RTC TimeStamp peripheral. 685 * @param __HANDLE__ specifies the RTC handle. 686 * @retval None 687 */ 688 #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_TSE)) 689 690 /** 691 * @brief Enable the RTC TimeStamp interrupt. 692 * @param __HANDLE__ specifies the RTC handle. 693 * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be enabled. 694 * This parameter can be: 695 * @arg @ref RTC_IT_TS TimeStamp interrupt 696 * @retval None 697 */ 698 #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR |= (__INTERRUPT__)) 699 700 /** 701 * @brief Disable the RTC TimeStamp interrupt. 702 * @param __HANDLE__ specifies the RTC handle. 703 * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt source to be disabled. 704 * This parameter can be: 705 * @arg @ref RTC_IT_TS TimeStamp interrupt 706 * @retval None 707 */ 708 #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR &= ~(__INTERRUPT__)) 709 710 /** 711 * @brief Check whether the specified RTC TimeStamp interrupt has occurred or not. 712 * @param __HANDLE__ specifies the RTC handle. 713 * @param __INTERRUPT__ specifies the RTC TimeStamp interrupt to check. 714 * This parameter can be: 715 * @arg @ref RTC_IT_TS TimeStamp interrupt 716 * @retval The state of __FLAG__ (TRUE or FALSE). 717 */ 718 #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__) ((((RTC->MISR) &\ 719 ((__INTERRUPT__)>> 12U)) != 0U) ? 1UL : 0UL) 720 /** 721 * @brief Check whether the specified RTC Time Stamp interrupt has been enabled or not. 722 * @param __HANDLE__ specifies the RTC handle. 723 * @param __INTERRUPT__ specifies the RTC Time Stamp interrupt source to check. 724 * This parameter can be: 725 * @arg @ref RTC_IT_TS TimeStamp interrupt 726 * @retval The state of __FLAG__ (TRUE or FALSE). 727 */ 728 #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((RTC->CR) &\ 729 (__INTERRUPT__)) != 0U) ? 1UL : 0UL) 730 731 /** 732 * @brief Get the selected RTC TimeStamps flag status. 733 * @param __HANDLE__ specifies the RTC handle. 734 * @param __FLAG__ specifies the RTC TimeStamp Flag is pending or not. 735 * This parameter can be: 736 * @arg @ref RTC_FLAG_TSF 737 * @arg @ref RTC_FLAG_TSOVF 738 * @retval The state of __FLAG__ (TRUE or FALSE). 739 */ 740 #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__),(__FLAG__))) 741 742 /** 743 * @brief Clear the RTC Time Stamps pending flags. 744 * @param __HANDLE__ specifies the RTC handle. 745 * @param __FLAG__ specifies the RTC TimeStamp Flag to clear. 746 * This parameter can be: 747 * @arg @ref RTC_FLAG_TSF 748 * @arg @ref RTC_FLAG_TSOVF 749 * @retval None 750 */ 751 #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) \ 752 (((__FLAG__) == RTC_FLAG_TSF) ? (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_TSF)) : \ 753 (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_TSOVF))) 754 755 /** 756 * @brief Enable interrupt on the RTC Timestamp associated Exti line. 757 * @retval None 758 */ 759 #define __HAL_RTC_TIMESTAMP_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_TIMESTAMP_EVENT) 760 761 /** 762 * @brief Disable interrupt on the RTC Timestamp associated Exti line. 763 * @retval None 764 */ 765 #define __HAL_RTC_TIMESTAMP_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_TIMESTAMP_EVENT)) 766 767 /** 768 * @brief Enable event on the RTC Timestamp associated Exti line. 769 * @retval None 770 */ 771 #define __HAL_RTC_TIMESTAMP_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_TIMESTAMP_EVENT) 772 773 /** 774 * @brief Disable event on the RTC Timestamp associated Exti line. 775 * @retval None 776 */ 777 #define __HAL_RTC_TIMESTAMP_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_TIMESTAMP_EVENT)) 778 779 /** 780 * @brief Enable the RTC internal TimeStamp peripheral. 781 * @param __HANDLE__ specifies the RTC handle. 782 * @retval None 783 */ 784 #define __HAL_RTC_INTERNAL_TIMESTAMP_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_ITSE)) 785 786 /** 787 * @brief Disable the RTC internal TimeStamp peripheral. 788 * @param __HANDLE__ specifies the RTC handle. 789 * @retval None 790 */ 791 #define __HAL_RTC_INTERNAL_TIMESTAMP_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_ITSE)) 792 793 /** 794 * @brief Get the selected RTC Internal Time Stamps flag status. 795 * @param __HANDLE__ specifies the RTC handle. 796 * @param __FLAG__ specifies the RTC Internal Time Stamp Flag is pending or not. 797 * This parameter can be: 798 * @arg @ref RTC_FLAG_ITSF 799 * @retval None 800 */ 801 #define __HAL_RTC_INTERNAL_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__),(__FLAG__))) 802 803 /** 804 * @brief Clear the RTC Internal Time Stamps pending flags. 805 * @param __HANDLE__ specifies the RTC handle. 806 * @param __FLAG__ specifies the RTC Internal Time Stamp Flag source to clear. 807 * This parameter can be: 808 * @arg @ref RTC_FLAG_ITSF 809 * @retval None 810 */ 811 #define __HAL_RTC_INTERNAL_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) \ 812 (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_ITSF)) 813 814 /** 815 * @brief Enable the RTC TimeStamp on Tamper detection. 816 * @param __HANDLE__ specifies the RTC handle. 817 * @retval None 818 */ 819 #define __HAL_RTC_TAMPTS_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_TAMPTS)) 820 821 /** 822 * @brief Disable the RTC TimeStamp on Tamper detection. 823 * @param __HANDLE__ specifies the RTC handle. 824 * @retval None 825 */ 826 #define __HAL_RTC_TAMPTS_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_TAMPTS)) 827 828 /** 829 * @brief Enable the RTC Tamper detection output. 830 * @param __HANDLE__ specifies the RTC handle. 831 * @retval None 832 */ 833 #define __HAL_RTC_TAMPOE_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_TAMPOE)) 834 835 /** 836 * @brief Disable the RTC Tamper detection output. 837 * @param __HANDLE__ specifies the RTC handle. 838 * @retval None 839 */ 840 #define __HAL_RTC_TAMPOE_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_TAMPOE)) 841 842 843 /** 844 * @} 845 */ 846 847 848 /* ------------------------------Calibration----------------------------------*/ 849 /** @defgroup RTCEx_Calibration RTC Calibration 850 * @{ 851 */ 852 853 /** 854 * @brief Enable the RTC calibration output. 855 * @param __HANDLE__ specifies the RTC handle. 856 * @retval None 857 */ 858 #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_COE)) 859 860 /** 861 * @brief Disable the calibration output. 862 * @param __HANDLE__ specifies the RTC handle. 863 * @retval None 864 */ 865 #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_COE)) 866 867 868 /** 869 * @brief Enable the clock reference detection. 870 * @param __HANDLE__ specifies the RTC handle. 871 * @retval None 872 */ 873 #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__) (RTC->CR |= (RTC_CR_REFCKON)) 874 875 /** 876 * @brief Disable the clock reference detection. 877 * @param __HANDLE__ specifies the RTC handle. 878 * @retval None 879 */ 880 #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__) (RTC->CR &= ~(RTC_CR_REFCKON)) 881 882 883 /** 884 * @brief Get the selected RTC shift operations flag status. 885 * @param __HANDLE__ specifies the RTC handle. 886 * @param __FLAG__ specifies the RTC shift operation Flag is pending or not. 887 * This parameter can be: 888 * @arg @ref RTC_FLAG_SHPF 889 * @retval The state of __FLAG__ (TRUE or FALSE). 890 */ 891 #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__))) 892 /** 893 * @} 894 */ 895 896 897 /* ------------------------------Tamper----------------------------------*/ 898 /** @defgroup RTCEx_Tamper RTCEx tamper 899 * @{ 900 */ 901 /** 902 * @brief Enable the TAMP Tamper input detection. 903 * @param __HANDLE__ specifies the RTC handle. 904 * @param __TAMPER__ specifies the RTC Tamper source to be enabled. 905 * This parameter can be any combination of the following values: 906 * @arg RTC_TAMPER_ALL: All tampers 907 * @arg RTC_TAMPER_1: Tamper1 908 * @arg RTC_TAMPER_2: Tamper2 909 * @arg RTC_TAMPER_3: Tamper3 910 * @arg RTC_TAMPER_4: Tamper4 911 * @arg RTC_TAMPER_5: Tamper5 912 * @retval None 913 */ 914 #define __HAL_RTC_TAMPER_ENABLE(__HANDLE__, __TAMPER__) (TAMP->CR1 |= (__TAMPER__)) 915 916 /** 917 * @brief Disable the TAMP Tamper input detection. 918 * @param __HANDLE__ specifies the RTC handle. 919 * @param __TAMPER__ specifies the RTC Tamper sources to be enabled. 920 * This parameter can be any combination of the following values: 921 * @arg RTC_TAMPER_ALL: All tampers 922 * @arg RTC_TAMPER_1: Tamper1 923 * @arg RTC_TAMPER_2: Tamper2 924 * @arg RTC_TAMPER_3: Tamper3 925 * @arg RTC_TAMPER_4: Tamper4 926 * @arg RTC_TAMPER_5: Tamper5 927 */ 928 #define __HAL_RTC_TAMPER_DISABLE(__HANDLE__, __TAMPER__) (TAMP->CR1 &= ~(__TAMPER__)) 929 930 931 /**************************************************************************************************/ 932 /** 933 * @brief Enable the TAMP Tamper interrupt. 934 * @param __HANDLE__ specifies the RTC handle. 935 * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be enabled. 936 * This parameter can be any combination of the following values: 937 * @arg RTC_IT_TAMP_ALL: All tampers interrupts 938 * @arg RTC_IT_TAMP_1: Tamper1 interrupt 939 * @arg RTC_IT_TAMP_2: Tamper2 interrupt 940 * @arg RTC_IT_TAMP_3: Tamper3 interrupt 941 * @arg RTC_IT_TAMP_4: Tamper4 interrupt 942 * @arg RTC_IT_TAMP_5: Tamper5 interrupt 943 * @retval None 944 */ 945 #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) (TAMP->IER |= (__INTERRUPT__)) 946 947 /** 948 * @brief Disable the TAMP Tamper interrupt. 949 * @param __HANDLE__ specifies the RTC handle. 950 * @param __INTERRUPT__ specifies the RTC Tamper interrupt sources to be disabled. 951 * This parameter can be any combination of the following values: 952 * @arg RTC_IT_TAMP_ALL: All tampers interrupts 953 * @arg RTC_IT_TAMP_1: Tamper1 interrupt 954 * @arg RTC_IT_TAMP_2: Tamper2 interrupt 955 * @arg RTC_IT_TAMP_3: Tamper3 interrupt 956 * @arg RTC_IT_TAMP_4: Tamper4 interrupt 957 * @arg RTC_IT_TAMP_5: Tamper5 interrupt 958 * @retval None 959 */ 960 #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) (TAMP->IER &= ~(__INTERRUPT__)) 961 962 963 /**************************************************************************************************/ 964 /** 965 * @brief Check whether the specified RTC Tamper interrupt has occurred or not. 966 * @param __HANDLE__ specifies the RTC handle. 967 * @param __INTERRUPT__ specifies the RTC Tamper interrupt to check. 968 * This parameter can be: 969 * @arg RTC_IT_TAMP_ALL: All tampers interrupts 970 * @arg RTC_IT_TAMP_1: Tamper1 interrupt 971 * @arg RTC_IT_TAMP_2: Tamper2 interrupt 972 * @arg RTC_IT_TAMP_3: Tamper3 interrupt 973 * @arg RTC_IT_TAMP_4: Tamper4 interrupt 974 * @arg RTC_IT_TAMP_5: Tamper5 interrupt 975 * @arg RTC_IT_INT_TAMP_ALL: All Internal Tamper interrupts 976 * @arg RTC_IT_INT_TAMP_3: Internal Tamper3 interrupt 977 * @arg RTC_IT_INT_TAMP_4: Internal Tamper4 interrupt 978 * @arg RTC_IT_INT_TAMP_5: Internal Tamper5 interrupt 979 * @arg RTC_IT_INT_TAMP_6: Internal Tamper6 interrupt 980 * @retval The state of __FLAG__ (TRUE or FALSE). 981 */ 982 #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) ((((TAMP->MISR) & (__INTERRUPT__)) != 0U) ? 1UL : 0UL) 983 984 985 /** 986 * @brief Check whether the specified RTC Tamper interrupt has been enabled or not. 987 * @param __HANDLE__ specifies the RTC handle. 988 * @param __INTERRUPT__ specifies the RTC Tamper interrupt source to check. 989 * This parameter can be: 990 * @arg RTC_IT_TAMP_ALL: All tampers interrupts 991 * @arg RTC_IT_TAMP_1: Tamper1 interrupt 992 * @arg RTC_IT_TAMP_2: Tamper2 interrupt 993 * @arg RTC_IT_TAMP_3: Tamper3 interrupt 994 * @arg RTC_IT_TAMP_4: Tamper4 interrupt 995 * @arg RTC_IT_TAMP_5: Tamper5 interrupt 996 * @arg RTC_IT_INT_TAMP_ALL: All internal tampers interrupts 997 * @arg RTC_IT_INT_TAMP_3: Internal Tamper3 interrupt 998 * @arg RTC_IT_INT_TAMP_4: Internal Tamper4 interrupt 999 * @arg RTC_IT_INT_TAMP_5: Internal Tamper5 interrupt 1000 * @arg RTC_IT_INT_TAMP_6: Internal Tamper6 interrupt 1001 * @retval The state of __FLAG__ (TRUE or FALSE). 1002 */ 1003 #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((TAMP->IER) &\ 1004 (__INTERRUPT__)) != 0U) ? 1UL : 0UL) 1005 1006 1007 /** 1008 * @brief Get the selected RTC Tampers flag status. 1009 * @param __HANDLE__ specifies the RTC handle. 1010 * @param __FLAG__ specifies the RTC Tamper Flag is pending or not. 1011 * This parameter can be: 1012 * @arg RTC_FLAG_TAMP_ALL: All tampers flag 1013 * @arg RTC_FLAG_TAMP_1: Tamper1 flag 1014 * @arg RTC_FLAG_TAMP_2: Tamper2 flag 1015 * @arg RTC_FLAG_TAMP_3: Tamper3 flag 1016 * @arg RTC_FLAG_TAMP_4: Tamper4 flag 1017 * @arg RTC_FLAG_TAMP_5: Tamper5 flag 1018 * @arg RTC_FLAG_INT_TAMP_3: Internal Tamper3 flag 1019 * @arg RTC_FLAG_INT_TAMP_4: Internal Tamper4 flag 1020 * @arg RTC_FLAG_INT_TAMP_5: Internal Tamper5 flag 1021 * @arg RTC_FLAG_INT_TAMP_6: Internal Tamper6 flag 1022 * @retval The state of __FLAG__ (TRUE or FALSE). 1023 */ 1024 #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((TAMP->SR) & (__FLAG__)) != 0U) 1025 1026 /** 1027 * @brief Clear the RTC Tamper's pending flags. 1028 * @param __HANDLE__ specifies the RTC handle. 1029 * @param __FLAG__ specifies the RTC Tamper Flag to clear. 1030 * This parameter can be: 1031 * @arg RTC_FLAG_TAMP_ALL: All tampers flag 1032 * @arg RTC_FLAG_TAMP_1: Tamper1 flag 1033 * @arg RTC_FLAG_TAMP_2: Tamper2 flag 1034 * @arg RTC_FLAG_TAMP_3: Tamper3 flag 1035 * @arg RTC_FLAG_TAMP_4: Tamper4 flag 1036 * @arg RTC_FLAG_TAMP_5: Tamper5 flag 1037 * @arg RTC_FLAG_TAMP_6: Tamper6 flag 1038 * @arg RTC_FLAG_TAMP_7: Tamper7 flag 1039 * @arg RTC_FLAG_TAMP_8: Tamper8 flag 1040 * @arg RTC_FLAG_INT_TAMP_ALL: All Internal Tamper flags 1041 * @arg RTC_FLAG_INT_TAMP_1: Internal Tamper1 flag 1042 * @arg RTC_FLAG_INT_TAMP_2: Internal Tamper2 flag 1043 * @arg RTC_FLAG_INT_TAMP_3: Internal Tamper3 flag 1044 * @arg RTC_FLAG_INT_TAMP_5: Internal Tamper5 flag 1045 * @arg RTC_FLAG_INT_TAMP_6: Internal Tamper6 flag 1046 * @arg RTC_FLAG_INT_TAMP_7: Internal Tamper7 flag 1047 * @arg RTC_FLAG_INT_TAMP_8: Internal Tamper8 flag 1048 * @arg RTC_FLAG_INT_TAMP_9: Internal Tamper9 flag 1049 * @arg RTC_FLAG_INT_TAMP_11: Internal Tamper11 flag 1050 * @retval None 1051 */ 1052 #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((TAMP->SCR) = (__FLAG__)) 1053 1054 /** 1055 * @brief Enable interrupt on the RTC tamper associated Exti line. 1056 * @retval None 1057 */ 1058 #define __HAL_RTC_TAMPER_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_TAMPER_EVENT) 1059 1060 /** 1061 * @brief Disable interrupt on the RTC tamper associated Exti line. 1062 * @retval None 1063 */ 1064 #define __HAL_RTC_TAMPER_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_TAMPER_EVENT)) 1065 1066 /** 1067 * @brief Enable event on the RTC tamper associated Exti line. 1068 * @retval None 1069 */ 1070 #define __HAL_RTC_TAMPER_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_TAMPER_EVENT) 1071 1072 /** 1073 * @brief Disable event on the RTC tamper associated Exti line. 1074 * @retval None 1075 */ 1076 #define __HAL_RTC_TAMPER_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_TAMPER_EVENT)) 1077 1078 /** 1079 * @} 1080 */ 1081 1082 /* --------------------------------- SSR Underflow ---------------------------------*/ 1083 /** @defgroup RTCEx_SSR_Underflow RTC SSR Underflow 1084 * @{ 1085 */ 1086 1087 /** 1088 * @brief Enable the RTC SSRU interrupt. 1089 * @param __HANDLE__ specifies the RTC handle. 1090 * @param __INTERRUPT__ specifies the RTC SSRU interrupt sources to be enabled. 1091 * This parameter can be: 1092 * @arg @ref RTC_IT_SSRU SSRU interrupt 1093 * @retval None 1094 */ 1095 #define __HAL_RTC_SSRU_ENABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR |= (__INTERRUPT__)) 1096 1097 /** 1098 * @brief Disable the RTC SSRU interrupt. 1099 * @param __HANDLE__ specifies the RTC handle. 1100 * @param __INTERRUPT__ specifies the RTC SSRU interrupt sources to be disabled. 1101 * This parameter can be: 1102 * @arg @ref RTC_IT_SSRU SSRU interrupt 1103 * @retval None 1104 */ 1105 #define __HAL_RTC_SSRU_DISABLE_IT(__HANDLE__, __INTERRUPT__) (RTC->CR &= ~(__INTERRUPT__)) 1106 1107 1108 /** 1109 * @brief Check whether the specified RTC SSRU interrupt has occurred or not. 1110 * @param __HANDLE__ specifies the RTC handle. 1111 * @param __INTERRUPT__ specifies the RTC SSRU interrupt to check. 1112 * This parameter can be: 1113 * @arg @ref RTC_IT_SSRU SSRU interrupt 1114 * @retval The state of __FLAG__ (TRUE or FALSE). 1115 */ 1116 #define __HAL_RTC_SSRU_GET_IT(__HANDLE__, __INTERRUPT__) (((RTC->MISR) & ((__INTERRUPT__) >> 1) != 0U) ? 1U : 0U) 1117 /** 1118 * @brief Check whether the specified RTC Wake Up timer interrupt has been enabled or not. 1119 * @param __HANDLE__ specifies the RTC handle. 1120 * @param __INTERRUPT__ specifies the RTC Wake Up timer interrupt sources to check. 1121 * This parameter can be: 1122 * @arg @ref RTC_IT_SSRU SSRU interrupt 1123 * @retval The state of __FLAG__ (TRUE or FALSE). 1124 */ 1125 #define __HAL_RTC_SSRU_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((RTC->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U) 1126 1127 /** 1128 * @brief Get the selected RTC SSRU's flag status. 1129 * @param __HANDLE__ specifies the RTC handle. 1130 * @param __FLAG__ specifies the RTC SSRU Flag is pending or not. 1131 * This parameter can be: 1132 * @arg @ref RTC_FLAG_SSRUF 1133 * @retval The state of __FLAG__ (TRUE or FALSE). 1134 */ 1135 #define __HAL_RTC_SSRU_GET_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_GET_FLAG((__HANDLE__), (__FLAG__))) 1136 1137 /** 1138 * @brief Clear the RTC Wake Up timer's pending flags. 1139 * @param __HANDLE__ specifies the RTC handle. 1140 * @param __FLAG__ specifies the RTC SSRU Flag to clear. 1141 * This parameter can be: 1142 * @arg @ref RTC_FLAG_SSRUF 1143 * @retval None 1144 */ 1145 #define __HAL_RTC_SSRU_CLEAR_FLAG(__HANDLE__, __FLAG__) (__HAL_RTC_CLEAR_FLAG((__HANDLE__), RTC_CLEAR_SSRUF)) 1146 1147 /* WAKE-UP TIMER EXTI */ 1148 /* ------------------ */ 1149 /** 1150 * @brief Enable interrupt on the RTC SSR Underflow associated Exti line. 1151 * @retval None 1152 */ 1153 #define __HAL_RTC_SSRU_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_SSRU_EVENT) 1154 1155 /** 1156 * @brief Disable interrupt on the RTC SSR Underflow associated Exti line. 1157 * @retval None 1158 */ 1159 #define __HAL_RTC_SSRU_EXTI_DISABLE_IT() (EXTI->C1IMR1 &= ~(RTC_EXTI_LINE_SSRU_EVENT)) 1160 1161 /** 1162 * @brief Enable event on the RTC SSR Underflow associated Exti line. 1163 * @retval None 1164 */ 1165 #define __HAL_RTC_SSRU_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_SSRU_EVENT) 1166 1167 /** 1168 * @brief Disable event on the RTC SSR Underflow associated Exti line. 1169 * @retval None 1170 */ 1171 #define __HAL_RTC_SSRU_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_SSRU_EVENT)) 1172 1173 /** 1174 * @} 1175 */ 1176 1177 /** 1178 * @} 1179 */ 1180 1181 /* Exported functions --------------------------------------------------------*/ 1182 /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions 1183 * @{ 1184 */ 1185 1186 /* RTC TimeStamp functions *****************************************/ 1187 /** @defgroup RTCEx_Exported_Functions_Group1 Extended RTC TimeStamp functions 1188 * @{ 1189 */ 1190 1191 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin); 1192 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin); 1193 HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc); 1194 HAL_StatusTypeDef HAL_RTCEx_SetInternalTimeStamp(RTC_HandleTypeDef *hrtc); 1195 HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTimeStamp(RTC_HandleTypeDef *hrtc); 1196 HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(const RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, 1197 RTC_DateTypeDef *sTimeStampDate, uint32_t Format); 1198 void HAL_RTCEx_TimeStampIRQHandler(RTC_HandleTypeDef *hrtc); 1199 HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 1200 void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc); 1201 /** 1202 * @} 1203 */ 1204 1205 1206 /* RTC Wake-up functions ******************************************************/ 1207 /** @defgroup RTCEx_Exported_Functions_Group2 Extended RTC Wake-up functions 1208 * @{ 1209 */ 1210 1211 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock); 1212 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock, 1213 uint32_t WakeUpAutoClr); 1214 HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc); 1215 uint32_t HAL_RTCEx_GetWakeUpTimer(const RTC_HandleTypeDef *hrtc); 1216 void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc); 1217 void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc); 1218 HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 1219 /** 1220 * @} 1221 */ 1222 1223 /* Extended Control functions ************************************************/ 1224 /** @defgroup RTCEx_Exported_Functions_Group3 Extended Peripheral Control functions 1225 * @{ 1226 */ 1227 1228 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, 1229 uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue); 1230 HAL_StatusTypeDef HAL_RTCEx_SetLowPowerCalib(RTC_HandleTypeDef *hrtc, uint32_t LowPowerCalib); 1231 HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS); 1232 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput); 1233 HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc); 1234 HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc); 1235 HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc); 1236 HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc); 1237 HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc); 1238 HAL_StatusTypeDef HAL_RTCEx_SetSSRU_IT(RTC_HandleTypeDef *hrtc); 1239 HAL_StatusTypeDef HAL_RTCEx_DeactivateSSRU(RTC_HandleTypeDef *hrtc); 1240 void HAL_RTCEx_SSRUIRQHandler(RTC_HandleTypeDef *hrtc); 1241 void HAL_RTCEx_SSRUEventCallback(RTC_HandleTypeDef *hrtc); 1242 /** 1243 * @} 1244 */ 1245 1246 /* Extended RTC features functions *******************************************/ 1247 /** @defgroup RTCEx_Exported_Functions_Group4 Extended features functions 1248 * @{ 1249 */ 1250 1251 void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc); 1252 HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 1253 /** 1254 * @} 1255 */ 1256 1257 /** @defgroup RTCEx_Exported_Functions_Group5 Extended RTC Tamper functions 1258 * @{ 1259 */ 1260 HAL_StatusTypeDef HAL_RTCEx_SetTamper(const RTC_HandleTypeDef *hrtc, const RTC_TamperTypeDef *sTamper); 1261 HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(const RTC_HandleTypeDef *hrtc, const RTC_TamperTypeDef *sTamper); 1262 HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(const RTC_HandleTypeDef *hrtc, uint32_t Tamper); 1263 HAL_StatusTypeDef HAL_RTCEx_PollForTamperEvent(RTC_HandleTypeDef *hrtc, uint32_t Tamper, uint32_t Timeout); 1264 HAL_StatusTypeDef HAL_RTCEx_SetInternalTamper(const RTC_HandleTypeDef *hrtc, 1265 const RTC_InternalTamperTypeDef *sIntTamper); 1266 HAL_StatusTypeDef HAL_RTCEx_SetInternalTamper_IT(const RTC_HandleTypeDef *hrtc, 1267 const RTC_InternalTamperTypeDef *sIntTamper); 1268 HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTamper(const RTC_HandleTypeDef *hrtc, uint32_t IntTamper); 1269 HAL_StatusTypeDef HAL_RTCEx_PollForInternalTamperEvent(RTC_HandleTypeDef *hrtc, uint32_t IntTamper, uint32_t Timeout); 1270 void HAL_RTCEx_TamperIRQHandler(RTC_HandleTypeDef *hrtc); 1271 void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc); 1272 void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc); 1273 void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc); 1274 void HAL_RTCEx_Tamper4EventCallback(RTC_HandleTypeDef *hrtc); 1275 void HAL_RTCEx_Tamper5EventCallback(RTC_HandleTypeDef *hrtc); 1276 void HAL_RTCEx_InternalTamper3EventCallback(RTC_HandleTypeDef *hrtc); 1277 void HAL_RTCEx_InternalTamper4EventCallback(RTC_HandleTypeDef *hrtc); 1278 void HAL_RTCEx_InternalTamper5EventCallback(RTC_HandleTypeDef *hrtc); 1279 void HAL_RTCEx_InternalTamper6EventCallback(RTC_HandleTypeDef *hrtc); 1280 /** 1281 * @} 1282 */ 1283 1284 /** @defgroup RTCEx_Exported_Functions_Group6 Extended RTC Backup register functions 1285 * @{ 1286 */ 1287 void HAL_RTCEx_BKUPWrite(const RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data); 1288 uint32_t HAL_RTCEx_BKUPRead(const RTC_HandleTypeDef *hrtc, uint32_t BackupRegister); 1289 void HAL_RTCEx_BKUPErase(const RTC_HandleTypeDef *hrtc); 1290 /** 1291 * @} 1292 */ 1293 1294 /** 1295 * @} 1296 */ 1297 1298 /* Private types -------------------------------------------------------------*/ 1299 /* Private variables ---------------------------------------------------------*/ 1300 /* Private constants ---------------------------------------------------------*/ 1301 /** @defgroup RTCEx_Private_Constants RTCEx Private Constants 1302 * @{ 1303 */ 1304 #define RTC_EXTI_LINE_ALARM_EVENT EXTI_IMR1_IM28 /*!< External interrupt line 28 Connected to the RTC Alarm event */ 1305 #define RTC_EXTI_LINE_TIMESTAMP_EVENT EXTI_IMR1_IM28 /*!< External interrupt line 28 Connected to the RTC Time Stamp events */ 1306 #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT EXTI_IMR1_IM28 /*!< External interrupt line 28 Connected to the RTC Wakeup event */ 1307 #define RTC_EXTI_LINE_TAMPER_EVENT EXTI_IMR1_IM29 /*!< External interrupt line 29 Connected to the RTC tamper events */ 1308 #define RTC_EXTI_LINE_SSRU_EVENT EXTI_IMR1_IM28 /*!< External interrupt line 28 Connected to the RTC SSR Underflow event */ 1309 /** 1310 * @} 1311 */ 1312 1313 /* Private macros ------------------------------------------------------------*/ 1314 /** @defgroup RTCEx_Private_Macros RTCEx Private Macros 1315 * @{ 1316 */ 1317 1318 /** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters 1319 * @{ 1320 */ 1321 #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \ 1322 ((EDGE) == RTC_TIMESTAMPEDGE_FALLING)) 1323 1324 1325 #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TIMESTAMPPIN_DEFAULT)) 1326 1327 1328 #define IS_RTC_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \ 1329 ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE)) 1330 1331 #define IS_RTC_TAMPER_TAMPERDETECTIONOUTPUT(MODE) (((MODE) == RTC_TAMPERDETECTIONOUTPUT_ENABLE) || \ 1332 ((MODE) == RTC_TAMPERDETECTIONOUTPUT_DISABLE)) 1333 1334 #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \ 1335 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \ 1336 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \ 1337 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \ 1338 ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \ 1339 ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS)) 1340 1341 #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= RTC_WUTR_WUT) 1342 1343 #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \ 1344 ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \ 1345 ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC)) 1346 1347 #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \ 1348 ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET)) 1349 1350 #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= RTC_CALR_CALM) 1351 1352 #define IS_RTC_LOW_POWER_CALIB(LPCAL) (((LPCAL) == RTC_LPCAL_SET) || \ 1353 ((LPCAL) == RTC_LPCAL_RESET)) 1354 1355 1356 #define IS_RTC_TAMPER(__TAMPER__) ((((__TAMPER__) & RTC_TAMPER_ALL) != 0x00U) && \ 1357 (((__TAMPER__) & ~RTC_TAMPER_ALL) == 0x00U)) 1358 1359 #define IS_RTC_INTERNAL_TAMPER(__INT_TAMPER__) ((((__INT_TAMPER__) & RTC_INT_TAMPER_ALL) != 0x00U) && \ 1360 (((__INT_TAMPER__) & ~RTC_INT_TAMPER_ALL) == 0x00U)) 1361 1362 #define IS_RTC_TAMPER_TRIGGER(__TRIGGER__) (((__TRIGGER__) == RTC_TAMPERTRIGGER_RISINGEDGE) || \ 1363 ((__TRIGGER__) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \ 1364 ((__TRIGGER__) == RTC_TAMPERTRIGGER_LOWLEVEL) || \ 1365 ((__TRIGGER__) == RTC_TAMPERTRIGGER_HIGHLEVEL)) 1366 1367 #define IS_RTC_TAMPER_ERASE_MODE(__MODE__) (((__MODE__) == RTC_TAMPER_ERASE_BACKUP_ENABLE) || \ 1368 ((__MODE__) == RTC_TAMPER_ERASE_BACKUP_DISABLE)) 1369 1370 #define IS_RTC_TAMPER_MASKFLAG_STATE(__STATE__) (((__STATE__) == RTC_TAMPERMASK_FLAG_ENABLE) || \ 1371 ((__STATE__) == RTC_TAMPERMASK_FLAG_DISABLE)) 1372 1373 #define IS_RTC_TAMPER_FILTER(__FILTER__) (((__FILTER__) == RTC_TAMPERFILTER_DISABLE) || \ 1374 ((__FILTER__) == RTC_TAMPERFILTER_2SAMPLE) || \ 1375 ((__FILTER__) == RTC_TAMPERFILTER_4SAMPLE) || \ 1376 ((__FILTER__) == RTC_TAMPERFILTER_8SAMPLE)) 1377 1378 #define IS_RTC_TAMPER_SAMPLING_FREQ(__FREQ__) (((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \ 1379 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \ 1380 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \ 1381 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \ 1382 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \ 1383 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \ 1384 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \ 1385 ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256)) 1386 1387 #define IS_RTC_TAMPER_PRECHARGE_DURATION(__DURATION__) (((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \ 1388 ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \ 1389 ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \ 1390 ((__DURATION__) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK)) 1391 1392 #define IS_RTC_TAMPER_PULLUP_STATE(__STATE__) (((__STATE__) == RTC_TAMPER_PULLUP_ENABLE) || \ 1393 ((__STATE__) == RTC_TAMPER_PULLUP_DISABLE)) 1394 1395 #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) \ 1396 (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \ 1397 ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE)) 1398 1399 #define IS_RTC_BKP(__BKP__) ((__BKP__) < RTC_BKP_NUMBER) 1400 1401 #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \ 1402 ((SEL) == RTC_SHIFTADD1S_SET)) 1403 1404 #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= RTC_SHIFTR_SUBFS) 1405 1406 #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \ 1407 ((OUTPUT) == RTC_CALIBOUTPUT_1HZ)) 1408 1409 1410 #define IS_RTC_BINARY_MODE(MODE) (((MODE) == RTC_BINARY_NONE) || \ 1411 ((MODE) == RTC_BINARY_ONLY) || \ 1412 ((MODE) == RTC_BINARY_MIX )) 1413 1414 #define IS_RTC_BINARY_MIX_BCDU(BDCU) (((BDCU) == RTC_BINARY_MIX_BCDU_0) || \ 1415 ((BDCU) == RTC_BINARY_MIX_BCDU_1) || \ 1416 ((BDCU) == RTC_BINARY_MIX_BCDU_2) || \ 1417 ((BDCU) == RTC_BINARY_MIX_BCDU_3) || \ 1418 ((BDCU) == RTC_BINARY_MIX_BCDU_4) || \ 1419 ((BDCU) == RTC_BINARY_MIX_BCDU_5) || \ 1420 ((BDCU) == RTC_BINARY_MIX_BCDU_6) || \ 1421 ((BDCU) == RTC_BINARY_MIX_BCDU_7)) 1422 1423 #define IS_RTC_ALARM_SUB_SECOND_BINARY_MASK(MASK) (((MASK) == 0u) || \ 1424 (((MASK) >= RTC_ALARMSUBSECONDBINMASK_SS31_1) && \ 1425 ((MASK) <= RTC_ALARMSUBSECONDBINMASK_NONE))) 1426 1427 #define IS_RTC_ALARMSUBSECONDBIN_AUTOCLR(SEL) (((SEL) == RTC_ALARMSUBSECONDBIN_AUTOCLR_NO) || \ 1428 ((SEL) == RTC_ALARMSUBSECONDBIN_AUTOCLR_YES)) 1429 /** 1430 * @} 1431 */ 1432 1433 /** 1434 * @} 1435 */ 1436 1437 /** 1438 * @} 1439 */ 1440 1441 /** 1442 * @} 1443 */ 1444 1445 #ifdef __cplusplus 1446 } 1447 #endif 1448 1449 #endif /* __STM32U0xx_HAL_RTC_EX_H */ 1450