1 /** 2 ****************************************************************************** 3 * @file stm32l1xx_hal_rtc_ex.h 4 * @author MCD Application Team 5 * @brief Header file of RTC HAL Extension module. 6 ****************************************************************************** 7 * @attention 8 * 9 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 10 * 11 * Redistribution and use in source and binary forms, with or without modification, 12 * are permitted provided that the following conditions are met: 13 * 1. Redistributions of source code must retain the above copyright notice, 14 * this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright notice, 16 * this list of conditions and the following disclaimer in the documentation 17 * and/or other materials provided with the distribution. 18 * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * 33 ****************************************************************************** 34 */ 35 36 /* Define to prevent recursive inclusion -------------------------------------*/ 37 #ifndef __STM32L1xx_HAL_RTC_EX_H 38 #define __STM32L1xx_HAL_RTC_EX_H 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /* Includes ------------------------------------------------------------------*/ 45 #include "stm32l1xx_hal_def.h" 46 47 /** @addtogroup STM32L1xx_HAL_Driver 48 * @{ 49 */ 50 51 /** @addtogroup RTCEx 52 * @{ 53 */ 54 55 /* Exported types ------------------------------------------------------------*/ 56 /** @defgroup RTCEx_Exported_Types RTCEx Exported Types 57 * @{ 58 */ 59 60 /** 61 * @brief RTC Tamper structure definition 62 */ 63 typedef struct 64 { 65 uint32_t Tamper; /*!< Specifies the Tamper Pin. 66 This parameter can be a value of @ref RTCEx_Tamper_Pins_Definitions */ 67 68 uint32_t Trigger; /*!< Specifies the Tamper Trigger. 69 This parameter can be a value of @ref RTCEx_Tamper_Trigger_Definitions */ 70 71 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 72 uint32_t Filter; /*!< Specifies the RTC Filter Tamper. 73 This parameter can be a value of @ref RTCEx_Tamper_Filter_Definitions */ 74 75 uint32_t SamplingFrequency; /*!< Specifies the sampling frequency. 76 This parameter can be a value of @ref RTCEx_Tamper_Sampling_Frequencies_Definitions */ 77 78 uint32_t PrechargeDuration; /*!< Specifies the Precharge Duration . 79 This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration_Definitions */ 80 81 uint32_t TamperPullUp; /*!< Specifies the Tamper PullUp . 82 This parameter can be a value of @ref RTCEx_Tamper_Pull_Up_Definitions */ 83 84 uint32_t TimeStampOnTamperDetection; /*!< Specifies the TimeStampOnTamperDetection. 85 This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection_Definitions */ 86 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 87 }RTC_TamperTypeDef; 88 89 /** 90 * @brief RTC Time structure definition 91 */ 92 typedef struct 93 { 94 uint8_t Hours; /*!< Specifies the RTC Time Hour. 95 This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected 96 This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */ 97 98 uint8_t Minutes; /*!< Specifies the RTC Time Minutes. 99 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ 100 101 uint8_t Seconds; /*!< Specifies the RTC Time Seconds. 102 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ 103 104 uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time. 105 This parameter can be a value of @ref RTC_AM_PM_Definitions */ 106 107 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 108 uint32_t SubSeconds; /*!< Specifies the RTC_SSR RTC Sub Second register content. 109 This parameter corresponds to a time unit range between [0-1] Second 110 with [1 Sec / SecondFraction +1] granularity */ 111 112 uint32_t SecondFraction; /*!< Specifies the range or granularity of Sub Second register content 113 corresponding to Synchronous pre-scaler factor value (PREDIV_S) 114 This parameter corresponds to a time unit range between [0-1] Second 115 with [1 Sec / SecondFraction +1] granularity. 116 This field will be used only by HAL_RTC_GetTime function */ 117 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 118 119 uint32_t DayLightSaving; /*!< Specifies RTC_DayLightSaveOperation: the value of hour adjustment. 120 This parameter can be a value of @ref RTC_DayLightSaving_Definitions */ 121 122 uint32_t StoreOperation; /*!< Specifies RTC_StoreOperation value to be written in the BKP bit 123 in CR register to store the operation. 124 This parameter can be a value of @ref RTC_StoreOperation_Definitions */ 125 }RTC_TimeTypeDef; 126 127 /** 128 * @brief RTC Alarm structure definition 129 */ 130 typedef struct 131 { 132 RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */ 133 134 uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks. 135 This parameter can be a value of @ref RTC_AlarmMask_Definitions */ 136 137 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 138 uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks. 139 This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */ 140 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 141 142 uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay. 143 This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */ 144 145 uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay. 146 If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range. 147 If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */ 148 149 uint32_t Alarm; /*!< Specifies the alarm . 150 This parameter can be a value of @ref RTC_Alarms_Definitions */ 151 }RTC_AlarmTypeDef; 152 /** 153 * @} 154 */ 155 156 /* Exported constants --------------------------------------------------------*/ 157 /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants 158 * @{ 159 */ 160 161 /** @defgroup RTC_Masks_Definitions Masks Definitions 162 * @{ 163 */ 164 #define RTC_TR_RESERVED_MASK (0x007F7F7FU) 165 #define RTC_DR_RESERVED_MASK (0x00FFFF3FU) 166 #define RTC_INIT_MASK (0xFFFFFFFFU) 167 #define RTC_RSF_MASK (0xFFFFFF5FU) 168 169 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 170 #define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_ALRAWF | RTC_FLAG_ALRBWF | RTC_FLAG_WUTWF | \ 171 RTC_FLAG_SHPF | RTC_FLAG_INITS | RTC_FLAG_RSF | \ 172 RTC_FLAG_INITF | RTC_FLAG_ALRAF | RTC_FLAG_ALRBF | \ 173 RTC_FLAG_WUTF | RTC_FLAG_TSF | RTC_FLAG_TSOVF | \ 174 RTC_FLAG_TAMP1F | RTC_FLAG_TAMP2F | RTC_FLAG_TAMP3F | \ 175 RTC_FLAG_RECALPF)) 176 #else 177 #define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_ALRAWF | RTC_FLAG_ALRBWF | RTC_FLAG_WUTWF | \ 178 RTC_FLAG_SHPF | RTC_FLAG_INITS | RTC_FLAG_RSF | \ 179 RTC_FLAG_INITF | RTC_FLAG_ALRAF | RTC_FLAG_ALRBF | \ 180 RTC_FLAG_WUTF | RTC_FLAG_TSF | RTC_FLAG_TSOVF | \ 181 RTC_FLAG_TAMP1F | \ 182 RTC_FLAG_RECALPF)) 183 184 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 185 /** 186 * @} 187 */ 188 189 /** @defgroup RTC_Synchronous_Predivider Synchronous Predivider 190 * @{ 191 */ 192 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 193 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FFFU) 194 #elif defined(STM32L100xB) || defined (STM32L151xB) || defined (STM32L152xB) 195 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x1FFFU) 196 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 197 /** 198 * @} 199 */ 200 201 /** @defgroup RTC_Interrupts_Definitions Interrupts Definitions 202 * @{ 203 */ 204 #define RTC_IT_TS ((uint32_t)RTC_CR_TSIE) 205 #define RTC_IT_WUT ((uint32_t)RTC_CR_WUTIE) 206 #define RTC_IT_ALRB ((uint32_t)RTC_CR_ALRBIE) 207 #define RTC_IT_ALRA ((uint32_t)RTC_CR_ALRAIE) 208 #define RTC_IT_TAMP1 ((uint32_t)(RTC_TAFCR_TAMPIE | RTC_TAFCR_TAMP1E)) 209 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 210 #define RTC_IT_TAMP2 ((uint32_t)(RTC_TAFCR_TAMPIE | RTC_TAFCR_TAMP2E)) 211 #define RTC_IT_TAMP3 ((uint32_t)(RTC_TAFCR_TAMPIE | RTC_TAFCR_TAMP3E)) 212 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 213 /** 214 * @} 215 */ 216 217 /** @defgroup RTC_Flags_Definitions Flags Definitions 218 * @{ 219 */ 220 #define RTC_FLAG_RECALPF ((uint32_t)RTC_ISR_RECALPF) 221 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 222 #define RTC_FLAG_TAMP3F ((uint32_t)RTC_ISR_TAMP3F) 223 #define RTC_FLAG_TAMP2F ((uint32_t)RTC_ISR_TAMP2F) 224 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 225 #define RTC_FLAG_TAMP1F ((uint32_t)RTC_ISR_TAMP1F) 226 #define RTC_FLAG_TSOVF ((uint32_t)RTC_ISR_TSOVF) 227 #define RTC_FLAG_TSF ((uint32_t)RTC_ISR_TSF) 228 #define RTC_FLAG_WUTF ((uint32_t)RTC_ISR_WUTF) 229 #define RTC_FLAG_ALRBF ((uint32_t)RTC_ISR_ALRBF) 230 #define RTC_FLAG_ALRAF ((uint32_t)RTC_ISR_ALRAF) 231 #define RTC_FLAG_INITF ((uint32_t)RTC_ISR_INITF) 232 #define RTC_FLAG_RSF ((uint32_t)RTC_ISR_RSF) 233 #define RTC_FLAG_INITS ((uint32_t)RTC_ISR_INITS) 234 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 235 #define RTC_FLAG_SHPF ((uint32_t)RTC_ISR_SHPF) 236 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 237 #define RTC_FLAG_WUTWF ((uint32_t)RTC_ISR_WUTWF) 238 #define RTC_FLAG_ALRBWF ((uint32_t)RTC_ISR_ALRBWF) 239 #define RTC_FLAG_ALRAWF ((uint32_t)RTC_ISR_ALRAWF) 240 /** 241 * @} 242 */ 243 244 /** @defgroup RTCEx_Output_selection_Definitions Output selection Definitions 245 * @{ 246 */ 247 #define RTC_OUTPUT_DISABLE (0x00000000U) 248 #define RTC_OUTPUT_ALARMA (0x00200000U) 249 #define RTC_OUTPUT_ALARMB (0x00400000U) 250 #define RTC_OUTPUT_WAKEUP (0x00600000U) 251 252 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \ 253 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \ 254 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \ 255 ((OUTPUT) == RTC_OUTPUT_WAKEUP)) 256 /** 257 * @} 258 */ 259 260 /** @defgroup RTCEx_Backup_Registers_Definitions Backup Registers Definitions 261 * @{ 262 */ 263 #if RTC_BKP_NUMBER > 0 264 #define RTC_BKP_DR0 (0x00000000U) 265 #define RTC_BKP_DR1 (0x00000001U) 266 #define RTC_BKP_DR2 (0x00000002U) 267 #define RTC_BKP_DR3 (0x00000003U) 268 #define RTC_BKP_DR4 (0x00000004U) 269 #endif /* RTC_BKP_NUMBER > 0 */ 270 271 #if RTC_BKP_NUMBER > 5 272 #define RTC_BKP_DR5 (0x00000005U) 273 #define RTC_BKP_DR6 (0x00000006U) 274 #define RTC_BKP_DR7 (0x00000007U) 275 #define RTC_BKP_DR8 (0x00000008U) 276 #define RTC_BKP_DR9 (0x00000009U) 277 #define RTC_BKP_DR10 (0x0000000AU) 278 #define RTC_BKP_DR11 (0x0000000BU) 279 #define RTC_BKP_DR12 (0x0000000CU) 280 #define RTC_BKP_DR13 (0x0000000DU) 281 #define RTC_BKP_DR14 (0x0000000EU) 282 #define RTC_BKP_DR15 (0x0000000FU) 283 #define RTC_BKP_DR16 (0x00000010U) 284 #define RTC_BKP_DR17 (0x00000011U) 285 #define RTC_BKP_DR18 (0x00000012U) 286 #define RTC_BKP_DR19 (0x00000013U) 287 #endif /* RTC_BKP_NUMBER > 5 */ 288 289 #if RTC_BKP_NUMBER > 20 290 #define RTC_BKP_DR20 (0x00000014U) 291 #define RTC_BKP_DR21 (0x00000015U) 292 #define RTC_BKP_DR22 (0x00000016U) 293 #define RTC_BKP_DR23 (0x00000017U) 294 #define RTC_BKP_DR24 (0x00000018U) 295 #define RTC_BKP_DR25 (0x00000019U) 296 #define RTC_BKP_DR26 (0x0000001AU) 297 #define RTC_BKP_DR27 (0x0000001BU) 298 #define RTC_BKP_DR28 (0x0000001CU) 299 #define RTC_BKP_DR29 (0x0000001DU) 300 #define RTC_BKP_DR30 (0x0000001EU) 301 #define RTC_BKP_DR31 (0x0000001FU) 302 #endif /* RTC_BKP_NUMBER > 20 */ 303 304 #define IS_RTC_BKP(BKP) ((BKP) < (uint32_t) RTC_BKP_NUMBER) 305 /** 306 * @} 307 */ 308 309 /** @defgroup RTCEx_Time_Stamp_Edges_Definitions Time Stamp Edges Definitions 310 * @{ 311 */ 312 #define RTC_TIMESTAMPEDGE_RISING (0x00000000U) 313 #define RTC_TIMESTAMPEDGE_FALLING (0x00000008U) 314 315 #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \ 316 ((EDGE) == RTC_TIMESTAMPEDGE_FALLING)) 317 /** 318 * @} 319 */ 320 321 /** @defgroup RTCEx_Tamper_Pins_Definitions Tamper Pins Definitions 322 * @{ 323 */ 324 #define RTC_TAMPER_1 RTC_TAFCR_TAMP1E 325 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 326 #define RTC_TAMPER_2 RTC_TAFCR_TAMP2E 327 #define RTC_TAMPER_3 RTC_TAFCR_TAMP3E 328 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 329 330 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 331 #define IS_RTC_TAMPER(TAMPER) (((~(RTC_TAMPER_1|RTC_TAMPER_2|RTC_TAMPER_3) & (TAMPER)) == (uint32_t)RESET) && ((TAMPER) != (uint32_t)RESET)) 332 #else 333 #define IS_RTC_TAMPER(TAMPER) ((TAMPER) == RTC_TAMPER_1) 334 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 335 /** 336 * @} 337 */ 338 339 /** @defgroup RTCEx_Tamper_Trigger_Definitions Tamper Trigger Definitions 340 * @{ 341 */ 342 #define RTC_TAMPERTRIGGER_RISINGEDGE (0x00000000U) 343 #define RTC_TAMPERTRIGGER_FALLINGEDGE (0x00000002U) 344 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 345 #define RTC_TAMPERTRIGGER_LOWLEVEL RTC_TAMPERTRIGGER_RISINGEDGE 346 #define RTC_TAMPERTRIGGER_HIGHLEVEL RTC_TAMPERTRIGGER_FALLINGEDGE 347 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 348 349 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 350 #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) || \ 351 ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \ 352 ((TRIGGER) == RTC_TAMPERTRIGGER_LOWLEVEL) || \ 353 ((TRIGGER) == RTC_TAMPERTRIGGER_HIGHLEVEL)) 354 #elif defined(STM32L100xB) || defined (STM32L151xB) || defined (STM32L152xB) 355 #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) || \ 356 ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE)) 357 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 358 /** 359 * @} 360 */ 361 362 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 363 /** @defgroup RTCEx_Tamper_Filter_Definitions Tamper Filter Definitions 364 * @{ 365 */ 366 #define RTC_TAMPERFILTER_DISABLE (0x00000000U) /*!< Tamper filter is disabled */ 367 368 #define RTC_TAMPERFILTER_2SAMPLE (0x00000800U) /*!< Tamper is activated after 2 369 consecutive samples at the active level */ 370 #define RTC_TAMPERFILTER_4SAMPLE (0x00001000U) /*!< Tamper is activated after 4 371 consecutive samples at the active level */ 372 #define RTC_TAMPERFILTER_8SAMPLE (0x00001800U) /*!< Tamper is activated after 8 373 consecutive samples at the active level. */ 374 375 #define IS_RTC_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TAMPERFILTER_DISABLE) || \ 376 ((FILTER) == RTC_TAMPERFILTER_2SAMPLE) || \ 377 ((FILTER) == RTC_TAMPERFILTER_4SAMPLE) || \ 378 ((FILTER) == RTC_TAMPERFILTER_8SAMPLE)) 379 /** 380 * @} 381 */ 382 383 /** @defgroup RTCEx_Tamper_Sampling_Frequencies_Definitions Tamper Sampling Frequencies 384 * @{ 385 */ 386 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 (0x00000000U) /*!< Each of the tamper inputs are sampled 387 with a frequency = RTCCLK / 32768 */ 388 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 (0x00000100U) /*!< Each of the tamper inputs are sampled 389 with a frequency = RTCCLK / 16384 */ 390 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 (0x00000200U) /*!< Each of the tamper inputs are sampled 391 with a frequency = RTCCLK / 8192 */ 392 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 (0x00000300U) /*!< Each of the tamper inputs are sampled 393 with a frequency = RTCCLK / 4096 */ 394 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 (0x00000400U) /*!< Each of the tamper inputs are sampled 395 with a frequency = RTCCLK / 2048 */ 396 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 (0x00000500U) /*!< Each of the tamper inputs are sampled 397 with a frequency = RTCCLK / 1024 */ 398 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 (0x00000600U) /*!< Each of the tamper inputs are sampled 399 with a frequency = RTCCLK / 512 */ 400 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 (0x00000700U) /*!< Each of the tamper inputs are sampled 401 with a frequency = RTCCLK / 256 */ 402 403 #define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \ 404 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \ 405 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \ 406 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \ 407 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \ 408 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \ 409 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \ 410 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256)) 411 /** 412 * @} 413 */ 414 415 /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration_Definitions Tamper Pin Precharge Duration 416 * @{ 417 */ 418 #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK (0x00000000U) /*!< Tamper pins are pre-charged before 419 sampling during 1 RTCCLK cycle */ 420 #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK (0x00002000U) /*!< Tamper pins are pre-charged before 421 sampling during 2 RTCCLK cycles */ 422 #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK (0x00004000U) /*!< Tamper pins are pre-charged before 423 sampling during 4 RTCCLK cycles */ 424 #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK (0x00006000U) /*!< Tamper pins are pre-charged before 425 sampling during 8 RTCCLK cycles */ 426 427 #define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \ 428 ((DURATION) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \ 429 ((DURATION) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \ 430 ((DURATION) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK)) 431 /** 432 * @} 433 */ 434 435 /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection_Definitions TimeStampOnTamperDetection Definitions 436 * @{ 437 */ 438 #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE ((uint32_t)RTC_TAFCR_TAMPTS) /*!< TimeStamp on Tamper Detection event saved */ 439 #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE (0x00000000U) /*!< TimeStamp on Tamper Detection event is not saved */ 440 441 #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \ 442 ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE)) 443 /** 444 * @} 445 */ 446 447 /** @defgroup RTCEx_Tamper_Pull_Up_Definitions Tamper Pull-Up Definitions 448 * @{ 449 */ 450 #define RTC_TAMPER_PULLUP_ENABLE (0x00000000U) /*!< TimeStamp on Tamper Detection event saved */ 451 #define RTC_TAMPER_PULLUP_DISABLE (RTC_TAFCR_TAMPPUDIS) /*!< TimeStamp on Tamper Detection event is not saved */ 452 453 #define IS_RTC_TAMPER_PULLUP_STATE(STATE) (((STATE) == RTC_TAMPER_PULLUP_ENABLE) || \ 454 ((STATE) == RTC_TAMPER_PULLUP_DISABLE)) 455 /** 456 * @} 457 */ 458 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 459 460 /** @defgroup RTCEx_Wakeup_Timer_Definitions Wakeup Timer Definitions 461 * @{ 462 */ 463 #define RTC_WAKEUPCLOCK_RTCCLK_DIV16 (0x00000000U) 464 #define RTC_WAKEUPCLOCK_RTCCLK_DIV8 (0x00000001U) 465 #define RTC_WAKEUPCLOCK_RTCCLK_DIV4 (0x00000002U) 466 #define RTC_WAKEUPCLOCK_RTCCLK_DIV2 (0x00000003U) 467 #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS (0x00000004U) 468 #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS (0x00000006U) 469 470 #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \ 471 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \ 472 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \ 473 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \ 474 ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \ 475 ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS)) 476 477 #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= 0xFFFF) 478 /** 479 * @} 480 */ 481 482 /** @defgroup RTCEx_Digital_Calibration_Definitions Digital Calibration Definitions 483 * @{ 484 */ 485 #define RTC_CALIBSIGN_POSITIVE (0x00000000U) 486 #define RTC_CALIBSIGN_NEGATIVE (0x00000080U) 487 488 #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CALIBSIGN_POSITIVE) || \ 489 ((SIGN) == RTC_CALIBSIGN_NEGATIVE)) 490 491 #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20) 492 /** 493 * @} 494 */ 495 496 /** @defgroup RTCEx_Smooth_Calib_Period_Definitions Smooth Calib Period Definitions 497 * @{ 498 */ 499 #define RTC_SMOOTHCALIB_PERIOD_32SEC (0x00000000U) /*!< If RTCCLK = 32768 Hz, Smooth calibation 500 period is 32s, else 2exp20 RTCCLK seconds */ 501 #define RTC_SMOOTHCALIB_PERIOD_16SEC (0x00002000U) /*!< If RTCCLK = 32768 Hz, Smooth calibation 502 period is 16s, else 2exp19 RTCCLK seconds */ 503 #define RTC_SMOOTHCALIB_PERIOD_8SEC (0x00004000U) /*!< If RTCCLK = 32768 Hz, Smooth calibation 504 period is 8s, else 2exp18 RTCCLK seconds */ 505 506 #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \ 507 ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \ 508 ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC)) 509 /** 510 * @} 511 */ 512 513 /** @defgroup RTCEx_Smooth_Calib_Plus_Pulses_Definitions Smooth Calib Plus Pulses Definitions 514 * @{ 515 */ 516 #define RTC_SMOOTHCALIB_PLUSPULSES_SET (0x00008000U) /*!< The number of RTCCLK pulses added 517 during a X -second window = Y - CALM[8:0] 518 with Y = 512, 256, 128 when X = 32, 16, 8 */ 519 #define RTC_SMOOTHCALIB_PLUSPULSES_RESET (0x00000000U) /*!< The number of RTCCLK pulses subbstited 520 during a 32-second window = CALM[8:0] */ 521 522 #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \ 523 ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET)) 524 /** 525 * @} 526 */ 527 528 /** @defgroup RTCEx_Smooth_Calib_Minus_Pulses_Definitions Smooth Calib Minus Pulses Definitions 529 * @{ 530 */ 531 #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= 0x000001FFU) 532 /** 533 * @} 534 */ 535 536 /** @defgroup RTCEx_Add_1_Second_Parameter_Definitions Add 1 Second Parameter Definitions 537 * @{ 538 */ 539 #define RTC_SHIFTADD1S_RESET (0x00000000U) 540 #define RTC_SHIFTADD1S_SET (0x80000000U) 541 542 #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \ 543 ((SEL) == RTC_SHIFTADD1S_SET)) 544 /** 545 * @} 546 */ 547 548 /** @defgroup RTCEx_Substract_Fraction_Of_Second_Value Substract Fraction Of Second Value 549 * @{ 550 */ 551 #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= 0x00007FFFU) 552 /** 553 * @} 554 */ 555 556 /** @defgroup RTCEx_Calib_Output_Selection_Definitions Calib Output Selection Definitions 557 * @{ 558 */ 559 #define RTC_CALIBOUTPUT_512HZ (0x00000000U) 560 #define RTC_CALIBOUTPUT_1HZ (0x00080000U) 561 562 #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \ 563 ((OUTPUT) == RTC_CALIBOUTPUT_1HZ)) 564 /** 565 * @} 566 */ 567 568 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 569 /** @defgroup RTC_Alarm_Sub_Seconds_Value Alarm Sub Seconds Value 570 * @{ 571 */ 572 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= 0x00007FFFU) 573 /** 574 * @} 575 */ 576 577 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions Alarm Sub Seconds Masks Definitions 578 * @{ 579 */ 580 #define RTC_ALARMSUBSECONDMASK_ALL (0x00000000U) /*!< All Alarm SS fields are masked. 581 There is no comparison on sub seconds 582 for Alarm */ 583 #define RTC_ALARMSUBSECONDMASK_SS14_1 (0x01000000U) /*!< SS[14:1] are don't care in Alarm 584 comparison. Only SS[0] is compared. */ 585 #define RTC_ALARMSUBSECONDMASK_SS14_2 (0x02000000U) /*!< SS[14:2] are don't care in Alarm 586 comparison. Only SS[1:0] are compared */ 587 #define RTC_ALARMSUBSECONDMASK_SS14_3 (0x03000000U) /*!< SS[14:3] are don't care in Alarm 588 comparison. Only SS[2:0] are compared */ 589 #define RTC_ALARMSUBSECONDMASK_SS14_4 (0x04000000U) /*!< SS[14:4] are don't care in Alarm 590 comparison. Only SS[3:0] are compared */ 591 #define RTC_ALARMSUBSECONDMASK_SS14_5 (0x05000000U) /*!< SS[14:5] are don't care in Alarm 592 comparison. Only SS[4:0] are compared */ 593 #define RTC_ALARMSUBSECONDMASK_SS14_6 (0x06000000U) /*!< SS[14:6] are don't care in Alarm 594 comparison. Only SS[5:0] are compared */ 595 #define RTC_ALARMSUBSECONDMASK_SS14_7 (0x07000000U) /*!< SS[14:7] are don't care in Alarm 596 comparison. Only SS[6:0] are compared */ 597 #define RTC_ALARMSUBSECONDMASK_SS14_8 (0x08000000U) /*!< SS[14:8] are don't care in Alarm 598 comparison. Only SS[7:0] are compared */ 599 #define RTC_ALARMSUBSECONDMASK_SS14_9 (0x09000000U) /*!< SS[14:9] are don't care in Alarm 600 comparison. Only SS[8:0] are compared */ 601 #define RTC_ALARMSUBSECONDMASK_SS14_10 (0x0A000000U) /*!< SS[14:10] are don't care in Alarm 602 comparison. Only SS[9:0] are compared */ 603 #define RTC_ALARMSUBSECONDMASK_SS14_11 (0x0B000000U) /*!< SS[14:11] are don't care in Alarm 604 comparison. Only SS[10:0] are compared */ 605 #define RTC_ALARMSUBSECONDMASK_SS14_12 (0x0C000000U) /*!< SS[14:12] are don't care in Alarm 606 comparison.Only SS[11:0] are compared */ 607 #define RTC_ALARMSUBSECONDMASK_SS14_13 (0x0D000000U) /*!< SS[14:13] are don't care in Alarm 608 comparison. Only SS[12:0] are compared */ 609 #define RTC_ALARMSUBSECONDMASK_SS14 (0x0E000000U) /*!< SS[14] is don't care in Alarm 610 comparison.Only SS[13:0] are compared */ 611 #define RTC_ALARMSUBSECONDMASK_NONE (0x0F000000U) /*!< SS[14:0] are compared and must match 612 to activate alarm. */ 613 614 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == RTC_ALARMSUBSECONDMASK_ALL) || \ 615 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_1) || \ 616 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_2) || \ 617 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_3) || \ 618 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_4) || \ 619 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_5) || \ 620 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_6) || \ 621 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_7) || \ 622 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_8) || \ 623 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_9) || \ 624 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_10) || \ 625 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_11) || \ 626 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_12) || \ 627 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_13) || \ 628 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14) || \ 629 ((MASK) == RTC_ALARMSUBSECONDMASK_NONE)) 630 /** 631 * @} 632 */ 633 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 634 635 /** 636 * @} 637 */ 638 639 /* Exported macro ------------------------------------------------------------*/ 640 /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros 641 * @{ 642 */ 643 644 /** 645 * @brief Enable the RTC WakeUp Timer peripheral. 646 * @param __HANDLE__: specifies the RTC handle. 647 * @retval None 648 */ 649 #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE)) 650 651 /** 652 * @brief Enable the RTC TimeStamp peripheral. 653 * @param __HANDLE__: specifies the RTC handle. 654 * @retval None 655 */ 656 #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE)) 657 658 /** 659 * @brief Disable the RTC WakeUp Timer peripheral. 660 * @param __HANDLE__: specifies the RTC handle. 661 * @retval None 662 */ 663 #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE)) 664 665 /** 666 * @brief Disable the RTC TimeStamp peripheral. 667 * @param __HANDLE__: specifies the RTC handle. 668 * @retval None 669 */ 670 #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE)) 671 672 /** 673 * @brief Enable the Coarse calibration process. 674 * @param __HANDLE__: specifies the RTC handle. 675 * @retval None 676 */ 677 #define __HAL_RTC_COARSE_CALIB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_DCE)) 678 679 /** 680 * @brief Disable the Coarse calibration process. 681 * @param __HANDLE__: specifies the RTC handle. 682 * @retval None 683 */ 684 #define __HAL_RTC_COARSE_CALIB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_DCE)) 685 686 /** 687 * @brief Enable the RTC calibration output. 688 * @param __HANDLE__: specifies the RTC handle. 689 * @retval None 690 */ 691 #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_COE)) 692 693 /** 694 * @brief Disable the calibration output. 695 * @param __HANDLE__: specifies the RTC handle. 696 * @retval None 697 */ 698 #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE)) 699 700 /** 701 * @brief Enable the clock reference detection. 702 * @param __HANDLE__: specifies the RTC handle. 703 * @retval None 704 */ 705 #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON)) 706 707 /** 708 * @brief Disable the clock reference detection. 709 * @param __HANDLE__: specifies the RTC handle. 710 * @retval None 711 */ 712 #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON)) 713 714 /** 715 * @brief Enable the RTC TimeStamp interrupt. 716 * @param __HANDLE__: specifies the RTC handle. 717 * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled. 718 * This parameter can be: 719 * @arg RTC_IT_TS: TimeStamp interrupt 720 * @retval None 721 */ 722 #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) 723 724 /** 725 * @brief Enable the RTC WakeUpTimer interrupt. 726 * @param __HANDLE__: specifies the RTC handle. 727 * @param __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled. 728 * This parameter can be: 729 * @arg RTC_IT_WUT: WakeUpTimer A interrupt 730 * @retval None 731 */ 732 #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) 733 734 /** 735 * @brief Disable the RTC TimeStamp interrupt. 736 * @param __HANDLE__: specifies the RTC handle. 737 * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled. 738 * This parameter can be: 739 * @arg RTC_IT_TS: TimeStamp interrupt 740 * @retval None 741 */ 742 #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) 743 744 /** 745 * @brief Disable the RTC WakeUpTimer interrupt. 746 * @param __HANDLE__: specifies the RTC handle. 747 * @param __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled. 748 * This parameter can be: 749 * @arg RTC_IT_WUT: WakeUpTimer A interrupt 750 * @retval None 751 */ 752 #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) 753 754 /** 755 * @brief Enable the RTC Tamper1 input detection. 756 * @param __HANDLE__: specifies the RTC handle. 757 * @retval None 758 */ 759 #define __HAL_RTC_TAMPER1_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->TAFCR, RTC_TAFCR_TAMP1E) 760 761 /** 762 * @brief Disable the RTC Tamper1 input detection. 763 * @param __HANDLE__: specifies the RTC handle. 764 * @retval None 765 */ 766 #define __HAL_RTC_TAMPER1_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->TAFCR, RTC_TAFCR_TAMP1E) 767 768 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC)\ 769 || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA)\ 770 || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA)\ 771 || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 772 /** 773 * @brief Enable the RTC Tamper2 input detection. 774 * @param __HANDLE__: specifies the RTC handle. 775 * @retval None 776 */ 777 #define __HAL_RTC_TAMPER2_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->TAFCR, RTC_TAFCR_TAMP2E) 778 779 /** 780 * @brief Disable the RTC Tamper2 input detection. 781 * @param __HANDLE__: specifies the RTC handle. 782 * @retval None 783 */ 784 #define __HAL_RTC_TAMPER2_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->TAFCR, RTC_TAFCR_TAMP2E) 785 786 /** 787 * @brief Enable the RTC Tamper3 input detection. 788 * @param __HANDLE__: specifies the RTC handle. 789 * @retval None 790 */ 791 #define __HAL_RTC_TAMPER3_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->TAFCR, RTC_TAFCR_TAMP3E) 792 793 /** 794 * @brief Disable the RTC Tamper3 input detection. 795 * @param __HANDLE__: specifies the RTC handle. 796 * @retval None 797 */ 798 #define __HAL_RTC_TAMPER3_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->TAFCR, RTC_TAFCR_TAMP3E) 799 800 801 /** 802 * @brief Check whether the specified RTC Tamper interrupt has occurred or not. 803 * @param __HANDLE__: specifies the RTC handle. 804 * @param __INTERRUPT__: specifies the RTC Tamper interrupt to check. 805 * This parameter can be: 806 * @arg RTC_IT_TAMP1: Tamper1 interrupt 807 * @arg RTC_IT_TAMP2: Tamper2 interrupt 808 * @arg RTC_IT_TAMP3: Tamper3 interrupt 809 * @retval None 810 */ 811 #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) (((__INTERRUPT__) == RTC_IT_TAMP1) ? (((((__HANDLE__)->Instance->ISR) & RTC_ISR_TAMP1F) != RESET) ? SET : RESET) : \ 812 ((__INTERRUPT__) == RTC_IT_TAMP2) ? (((((__HANDLE__)->Instance->ISR) & RTC_ISR_TAMP2F) != RESET) ? SET : RESET) : \ 813 (((((__HANDLE__)->Instance->ISR) & RTC_ISR_TAMP3F) != RESET) ? SET : RESET)) 814 #else 815 /** 816 * @brief Check whether the specified RTC Tamper interrupt has occurred or not. 817 * @param __HANDLE__: specifies the RTC handle. 818 * @param __INTERRUPT__: specifies the RTC Tamper interrupt to check. 819 * This parameter can be: 820 * @arg RTC_IT_TAMP1: Tamper1 interrupt 821 * @retval None 822 */ 823 #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & RTC_ISR_TAMP1F) != RESET) ? SET : RESET) 824 825 #endif 826 827 /** 828 * @brief Enable the RTC Tamper interrupt. 829 * @param __HANDLE__: specifies the RTC handle. 830 * @param __INTERRUPT__: specifies the RTC Tamper interrupt sources to be enabled 831 * This parameter can be any combination of the following values: 832 * @arg RTC_IT_TAMP1: Tamper1 interrupt 833 * @arg RTC_IT_TAMP2: Tamper2 interrupt (*) 834 * @arg RTC_IT_TAMP3: Tamper3 interrupt (*) 835 * @note (*) Available only on devices STM32L100xBA, STM32L151xBA, STM32L152xBA, STM32L100xC, 836 * STM32L151xC, STM32L152xC, STM32L162xC, STM32L151xCA, STM32L151xD, STM32L152xCA, 837 * STM32L152xD, STM32L162xCA, STM32L162xD, STM32L151xE, STM32L152xE, STM32L162xE 838 * STM32L151xDX, STM32L152xDX, STM32L162xDX 839 * @retval None 840 */ 841 #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT(((__HANDLE__)->Instance->TAFCR), RTC_TAFCR_TAMPIE) 842 843 /** 844 * @brief Disable the RTC Tamper interrupt. 845 * @param __HANDLE__: specifies the RTC handle. 846 * @param __INTERRUPT__: specifies the RTC Tamper interrupt sources to be disabled. 847 * This parameter can be any combination of the following values: 848 * @arg RTC_IT_TAMP1: Tamper1 interrupt 849 * @arg RTC_IT_TAMP2: Tamper2 interrupt (*) 850 * @arg RTC_IT_TAMP3: Tamper3 interrupt (*) 851 * @note (*) Available only on devices STM32L100xBA, STM32L151xBA, STM32L152xBA, STM32L100xC, 852 * STM32L151xC, STM32L152xC, STM32L162xC, STM32L151xCA, STM32L151xD, STM32L152xCA, 853 * STM32L152xD, STM32L162xCA, STM32L162xD, STM32L151xE, STM32L152xE, STM32L162xE 854 * STM32L151xDX, STM32L152xDX, STM32L162xDX 855 * @retval None 856 */ 857 #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT(((__HANDLE__)->Instance->TAFCR), RTC_TAFCR_TAMPIE) 858 859 /** 860 * @brief Check whether the specified RTC Tamper interrupt has been enabled or not. 861 * @param __HANDLE__: specifies the RTC handle. 862 * @param __INTERRUPT__: specifies the RTC Tamper interrupt source to check. 863 * This parameter can be: 864 * @arg RTC_IT_TAMP1: Tamper1 interrupt 865 * @arg RTC_IT_TAMP2: Tamper2 interrupt (*) 866 * @arg RTC_IT_TAMP3: Tamper3 interrupt (*) 867 * @note (*) Available only on devices STM32L100xBA, STM32L151xBA, STM32L152xBA, STM32L100xC, 868 * STM32L151xC, STM32L152xC, STM32L162xC, STM32L151xCA, STM32L151xD, STM32L152xCA, 869 * STM32L152xD, STM32L162xCA, STM32L162xD, STM32L151xE, STM32L152xE, STM32L162xE 870 * STM32L151xDX, STM32L152xDX, STM32L162xDX 871 * @retval None 872 */ 873 #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->TAFCR) & RTC_TAFCR_TAMPIE) != RESET) ? SET : RESET) 874 875 /** 876 * @brief Check whether the specified RTC WakeUpTimer interrupt has occurred or not. 877 * @param __HANDLE__: specifies the RTC handle. 878 * @param __FLAG__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled. 879 * This parameter can be: 880 * @arg RTC_IT_WUT: WakeUpTimer A interrupt 881 * @retval None 882 */ 883 #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & ((__FLAG__)>> 4)) != RESET)? SET : RESET) 884 885 /** 886 * @brief Check whether the specified RTC Wake Up timer interrupt has been enabled or not. 887 * @param __HANDLE__: specifies the RTC handle. 888 * @param __INTERRUPT__: specifies the RTC Wake Up timer interrupt sources to check. 889 * This parameter can be: 890 * @arg RTC_IT_WUT: WakeUpTimer interrupt 891 * @retval None 892 */ 893 #define __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET) 894 895 /** 896 * @brief Check whether the specified RTC TimeStamp interrupt has occurred or not. 897 * @param __HANDLE__: specifies the RTC handle. 898 * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled. 899 * This parameter can be: 900 * @arg RTC_IT_TS: TimeStamp interrupt 901 * @retval None 902 */ 903 #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__)>> 4)) != RESET)? SET : RESET) 904 905 /** 906 * @brief Check whether the specified RTC Time Stamp interrupt has been enabled or not. 907 * @param __HANDLE__: specifies the RTC handle. 908 * @param __INTERRUPT__: specifies the RTC Time Stamp interrupt source to check. 909 * This parameter can be: 910 * @arg RTC_IT_TS: TimeStamp interrupt 911 * @retval None 912 */ 913 #define __HAL_RTC_TIMESTAMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET) 914 915 /** 916 * @brief Get the selected RTC TimeStamp's flag status. 917 * @param __HANDLE__: specifies the RTC handle. 918 * @param __FLAG__: specifies the RTC TimeStamp Flag sources to be enabled or disabled. 919 * This parameter can be: 920 * @arg RTC_FLAG_TSF 921 * @arg RTC_FLAG_TSOVF 922 * @retval None 923 */ 924 #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET) 925 926 /** 927 * @brief Get the selected RTC WakeUpTimer's flag status. 928 * @param __HANDLE__: specifies the RTC handle. 929 * @param __FLAG__: specifies the RTC WakeUpTimer Flag sources to be enabled or disabled. 930 * This parameter can be: 931 * @arg RTC_FLAG_WUTF 932 * @arg RTC_FLAG_WUTWF 933 * @retval None 934 */ 935 #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET) 936 937 /** 938 * @brief Get the selected RTC Tamper's flag status. 939 * @param __HANDLE__: specifies the RTC handle. 940 * @param __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled. 941 * This parameter can be: 942 * @arg RTC_FLAG_TAMP1F 943 * @arg RTC_FLAG_TAMP2F (*) 944 * @arg RTC_FLAG_TAMP3F (*) 945 * @note (*) Available only on devices STM32L100xBA, STM32L151xBA, STM32L152xBA, STM32L100xC, 946 * STM32L151xC, STM32L152xC, STM32L162xC, STM32L151xCA, STM32L151xD, STM32L152xCA, 947 * STM32L152xD, STM32L162xCA, STM32L162xD, STM32L151xE, STM32L152xE, STM32L162xE 948 * STM32L151xDX, STM32L152xDX, STM32L162xDX 949 * @retval None 950 */ 951 #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET) 952 953 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC)\ 954 || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA)\ 955 || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA)\ 956 || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 957 /** 958 * @brief Get the selected RTC shift operation's flag status. 959 * @param __HANDLE__: specifies the RTC handle. 960 * @param __FLAG__: specifies the RTC shift operation Flag is pending or not. 961 * This parameter can be: 962 * @arg RTC_FLAG_SHPF 963 * @retval None 964 */ 965 #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET) 966 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 967 968 /** 969 * @brief Clear the RTC Time Stamp's pending flags. 970 * @param __HANDLE__: specifies the RTC handle. 971 * @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled. 972 * This parameter can be: 973 * @arg RTC_FLAG_TSF 974 * @retval None 975 */ 976 #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)) 977 978 /** 979 * @brief Clear the RTC Tamper's pending flags. 980 * @param __HANDLE__: specifies the RTC handle. 981 * @param __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled. 982 * This parameter can be: 983 * @arg RTC_FLAG_TAMP1F 984 * @arg RTC_FLAG_TAMP2F (*) 985 * @arg RTC_FLAG_TAMP3F (*) 986 * @note (*) Available only on devices STM32L100xBA, STM32L151xBA, STM32L152xBA, STM32L100xC, 987 * STM32L151xC, STM32L152xC, STM32L162xC, STM32L151xCA, STM32L151xD, STM32L152xCA, 988 * STM32L152xD, STM32L162xCA, STM32L162xD, STM32L151xE, STM32L152xE, STM32L162xE 989 * STM32L151xDX, STM32L152xDX, STM32L162xDX 990 * @retval None 991 */ 992 #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)) 993 994 /** 995 * @brief Clear the RTC Wake Up timer's pending flags. 996 * @param __HANDLE__: specifies the RTC handle. 997 * @param __FLAG__: specifies the RTC WakeUpTimer Flag to clear. 998 * This parameter can be: 999 * @arg RTC_FLAG_WUTF 1000 * @retval None 1001 */ 1002 #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)) 1003 1004 /** 1005 * @brief Enable interrupt on the RTC WakeUp Timer associated Exti line. 1006 * @retval None 1007 */ 1008 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 1009 1010 /** 1011 * @brief Disable interrupt on the RTC WakeUp Timer associated Exti line. 1012 * @retval None 1013 */ 1014 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT)) 1015 1016 /** 1017 * @brief Enable event on the RTC WakeUp Timer associated Exti line. 1018 * @retval None. 1019 */ 1020 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 1021 1022 /** 1023 * @brief Disable event on the RTC WakeUp Timer associated Exti line. 1024 * @retval None. 1025 */ 1026 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT)) 1027 1028 /** 1029 * @brief Enable falling edge trigger on the RTC WakeUp Timer associated Exti line. 1030 * @retval None. 1031 */ 1032 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 1033 1034 /** 1035 * @brief Disable falling edge trigger on the RTC WakeUp Timer associated Exti line. 1036 * @retval None. 1037 */ 1038 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT)) 1039 1040 /** 1041 * @brief Enable rising edge trigger on the RTC WakeUp Timer associated Exti line. 1042 * @retval None. 1043 */ 1044 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 1045 1046 /** 1047 * @brief Disable rising edge trigger on the RTC WakeUp Timer associated Exti line. 1048 * @retval None. 1049 */ 1050 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT)) 1051 1052 /** 1053 * @brief Enable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line. 1054 * @retval None. 1055 */ 1056 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() do { __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE();__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE(); } while(0); 1057 1058 /** 1059 * @brief Disable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line. 1060 * This parameter can be: 1061 * @retval None. 1062 */ 1063 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() do { __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE();__HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE(); } while(0); 1064 1065 /** 1066 * @brief Check whether the RTC WakeUp Timer associated Exti line interrupt flag is set or not. 1067 * @retval Line Status. 1068 */ 1069 #define __HAL_RTC_WAKEUPTIMER_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 1070 1071 /** 1072 * @brief Clear the RTC WakeUp Timer associated Exti line flag. 1073 * @retval None. 1074 */ 1075 #define __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 1076 1077 /** 1078 * @brief Generate a Software interrupt on the RTC WakeUp Timer associated Exti line. 1079 * @retval None. 1080 */ 1081 #define __HAL_RTC_WAKEUPTIMER_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT) 1082 1083 /** 1084 * @brief Enable interrupt on the RTC Tamper and Timestamp associated Exti line. 1085 * @retval None 1086 */ 1087 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 1088 1089 /** 1090 * @brief Disable interrupt on the RTC Tamper and Timestamp associated Exti line. 1091 * @retval None 1092 */ 1093 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)) 1094 1095 /** 1096 * @brief Enable event on the RTC Tamper and Timestamp associated Exti line. 1097 * @retval None. 1098 */ 1099 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 1100 1101 /** 1102 * @brief Disable event on the RTC Tamper and Timestamp associated Exti line. 1103 * @retval None. 1104 */ 1105 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)) 1106 1107 /** 1108 * @brief Enable falling edge trigger on the RTC Tamper and Timestamp associated Exti line. 1109 * @retval None. 1110 */ 1111 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 1112 1113 /** 1114 * @brief Disable falling edge trigger on the RTC Tamper and Timestamp associated Exti line. 1115 * @retval None. 1116 */ 1117 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)) 1118 1119 /** 1120 * @brief Enable rising edge trigger on the RTC Tamper and Timestamp associated Exti line. 1121 * @retval None. 1122 */ 1123 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 1124 1125 /** 1126 * @brief Disable rising edge trigger on the RTC Tamper and Timestamp associated Exti line. 1127 * @retval None. 1128 */ 1129 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)) 1130 1131 /** 1132 * @brief Enable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line. 1133 * @retval None. 1134 */ 1135 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_FALLING_EDGE() do { __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE();__HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE(); } while(0); 1136 1137 /** 1138 * @brief Disable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line. 1139 * This parameter can be: 1140 * @retval None. 1141 */ 1142 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_FALLING_EDGE() do { __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE();__HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE(); } while(0); 1143 1144 /** 1145 * @brief Check whether the RTC Tamper and Timestamp associated Exti line interrupt flag is set or not. 1146 * @retval Line Status. 1147 */ 1148 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 1149 1150 /** 1151 * @brief Clear the RTC Tamper and Timestamp associated Exti line flag. 1152 * @retval None. 1153 */ 1154 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 1155 1156 /** 1157 * @brief Generate a Software interrupt on the RTC Tamper and Timestamp associated Exti line 1158 * @retval None. 1159 */ 1160 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT) 1161 1162 /** 1163 * @} 1164 */ 1165 1166 /* Exported functions --------------------------------------------------------*/ 1167 /** @addtogroup RTCEx_Exported_Functions 1168 * @{ 1169 */ 1170 1171 /* RTC TimeStamp and Tamper functions *****************************************/ 1172 /** @addtogroup RTCEx_Exported_Functions_Group4 1173 * @{ 1174 */ 1175 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge); 1176 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge); 1177 HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc); 1178 HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format); 1179 1180 HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper); 1181 HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper); 1182 HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper); 1183 void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc); 1184 1185 void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc); 1186 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 1187 void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc); 1188 void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc); 1189 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 1190 void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc); 1191 HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 1192 HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 1193 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 1194 HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 1195 HAL_StatusTypeDef HAL_RTCEx_PollForTamper3Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 1196 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 1197 /** 1198 * @} 1199 */ 1200 1201 /* RTC Wake-up functions ******************************************************/ 1202 /** @addtogroup RTCEx_Exported_Functions_Group5 1203 * @{ 1204 */ 1205 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock); 1206 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock); 1207 uint32_t HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc); 1208 uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc); 1209 void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc); 1210 void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc); 1211 HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 1212 /** 1213 * @} 1214 */ 1215 1216 /* Extension Control functions ************************************************/ 1217 /** @addtogroup RTCEx_Exported_Functions_Group7 1218 * @{ 1219 */ 1220 void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data); 1221 uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister); 1222 1223 HAL_StatusTypeDef HAL_RTCEx_SetCoarseCalib(RTC_HandleTypeDef *hrtc, uint32_t CalibSign, uint32_t Value); 1224 HAL_StatusTypeDef HAL_RTCEx_DeactivateCoarseCalib(RTC_HandleTypeDef *hrtc); 1225 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX) 1226 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue); 1227 HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS); 1228 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput); 1229 #else 1230 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc); 1231 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */ 1232 HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc); 1233 HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc); 1234 HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc); 1235 HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc); 1236 HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc); 1237 /** 1238 * @} 1239 */ 1240 1241 /* Extension RTC features functions *******************************************/ 1242 /** @addtogroup RTCEx_Exported_Functions_Group8 1243 * @{ 1244 */ 1245 void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc); 1246 HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 1247 /** 1248 * @} 1249 */ 1250 1251 /** 1252 * @} 1253 */ 1254 1255 /* Private types -------------------------------------------------------------*/ 1256 /* Private variables ---------------------------------------------------------*/ 1257 /* Private constants ---------------------------------------------------------*/ 1258 /** @defgroup RTCEx_Private_Constants RTCEx Private Constants 1259 * @{ 1260 */ 1261 #define RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT (0x00080000U) /*!< External interrupt line 19 Connected to the RTC Tamper and Time Stamp events */ 1262 #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT (0x00100000U) /*!< External interrupt line 20 Connected to the RTC Wakeup event */ 1263 1264 /** 1265 * @} 1266 */ 1267 1268 /* Private macros ------------------------------------------------------------*/ 1269 /** @defgroup RTCEx_Private_Macros RTCEx Private Macros 1270 * @{ 1271 */ 1272 1273 /** 1274 * @} 1275 */ 1276 1277 /** 1278 * @} 1279 */ 1280 1281 /** 1282 * @} 1283 */ 1284 1285 #ifdef __cplusplus 1286 } 1287 #endif 1288 1289 #endif /* __STM32L1xx_HAL_RTC_EX_H */ 1290 1291 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 1292