2 ******************************************************************************
3 * @file stm32l1xx_hal_rtc_ex.h
4 * @author MCD Application Team
6 * @date 5-September-2014
7 * @brief Header file of RTC HAL Extension module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32L1xx_HAL_RTC_EX_H
40 #define __STM32L1xx_HAL_RTC_EX_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32l1xx_hal_def.h"
49 /** @addtogroup STM32L1xx_HAL_Driver
57 /* Exported types ------------------------------------------------------------*/
58 /** @defgroup RTCEx_Exported_Types RTCEx Exported Types
63 * @brief RTC Tamper structure definition
67 uint32_t Tamper
; /*!< Specifies the Tamper Pin.
68 This parameter can be a value of @ref RTCEx_Tamper_Pins_Definitions */
70 uint32_t Trigger
; /*!< Specifies the Tamper Trigger.
71 This parameter can be a value of @ref RTCEx_Tamper_Trigger_Definitions */
73 #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 (STM32L152xE) || defined (STM32L162xE)
74 uint32_t Filter
; /*!< Specifies the RTC Filter Tamper.
75 This parameter can be a value of @ref RTCEx_Tamper_Filter_Definitions */
77 uint32_t SamplingFrequency
; /*!< Specifies the sampling frequency.
78 This parameter can be a value of @ref RTCEx_Tamper_Sampling_Frequencies_Definitions */
80 uint32_t PrechargeDuration
; /*!< Specifies the Precharge Duration .
81 This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration_Definitions */
83 uint32_t TamperPullUp
; /*!< Specifies the Tamper PullUp .
84 This parameter can be a value of @ref RTCEx_Tamper_Pull_Up_Definitions */
86 uint32_t TimeStampOnTamperDetection
; /*!< Specifies the TimeStampOnTamperDetection.
87 This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection_Definitions */
88 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
92 * @brief RTC Time structure definition
96 uint8_t Hours
; /*!< Specifies the RTC Time Hour.
97 This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected
98 This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */
100 uint8_t Minutes
; /*!< Specifies the RTC Time Minutes.
101 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
103 uint8_t Seconds
; /*!< Specifies the RTC Time Seconds.
104 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
106 #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 (STM32L152xE) || defined (STM32L162xE)
107 uint32_t SubSeconds
; /*!< Specifies the RTC Time SubSeconds.
108 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
109 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
111 uint8_t TimeFormat
; /*!< Specifies the RTC AM/PM Time.
112 This parameter can be a value of @ref RTC_AM_PM_Definitions */
114 uint32_t DayLightSaving
; /*!< Specifies RTC_DayLightSaveOperation: the value of hour adjustment.
115 This parameter can be a value of @ref RTC_DayLightSaving_Definitions */
117 uint32_t StoreOperation
; /*!< Specifies RTC_StoreOperation value to be written in the BCK bit
118 in CR register to store the operation.
119 This parameter can be a value of @ref RTC_StoreOperation_Definitions */
123 * @brief RTC Alarm structure definition
127 RTC_TimeTypeDef AlarmTime
; /*!< Specifies the RTC Alarm Time members */
129 uint32_t AlarmMask
; /*!< Specifies the RTC Alarm Masks.
130 This parameter can be a value of @ref RTC_AlarmMask_Definitions */
132 #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 (STM32L152xE) || defined (STM32L162xE)
133 uint32_t AlarmSubSecondMask
; /*!< Specifies the RTC Alarm SubSeconds Masks.
134 This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */
135 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
137 uint32_t AlarmDateWeekDaySel
; /*!< Specifies the RTC Alarm is on Date or WeekDay.
138 This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
140 uint8_t AlarmDateWeekDay
; /*!< Specifies the RTC Alarm Date/WeekDay.
141 If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range.
142 If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */
144 uint32_t Alarm
; /*!< Specifies the alarm .
145 This parameter can be a value of @ref RTC_Alarms_Definitions */
151 /* Exported constants --------------------------------------------------------*/
152 /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants
156 /** @defgroup RTC_Masks_Definitions Masks Definitions
159 #define RTC_TR_RESERVED_MASK ((uint32_t)0x007F7F7F)
160 #define RTC_DR_RESERVED_MASK ((uint32_t)0x00FFFF3F)
161 #define RTC_INIT_MASK ((uint32_t)0xFFFFFFFF)
162 #define RTC_RSF_MASK ((uint32_t)0xFFFFFF5F)
164 #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 (STM32L152xE) || defined (STM32L162xE)
165 #define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_ALRAWF | RTC_FLAG_ALRBWF | RTC_FLAG_WUTWF | \
166 RTC_FLAG_SHPF | RTC_FLAG_INITS | RTC_FLAG_RSF | \
167 RTC_FLAG_INITF | RTC_FLAG_ALRAF | RTC_FLAG_ALRBF | \
168 RTC_FLAG_WUTF | RTC_FLAG_TSF | RTC_FLAG_TSOVF | \
169 RTC_FLAG_TAMP1F | RTC_FLAG_TAMP2F | RTC_FLAG_TAMP3F | \
172 #define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_ALRAWF | RTC_FLAG_ALRBWF | RTC_FLAG_WUTWF | \
173 RTC_FLAG_SHPF | RTC_FLAG_INITS | RTC_FLAG_RSF | \
174 RTC_FLAG_INITF | RTC_FLAG_ALRAF | RTC_FLAG_ALRBF | \
175 RTC_FLAG_WUTF | RTC_FLAG_TSF | RTC_FLAG_TSOVF | \
179 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
184 /** @defgroup RTC_Synchronous_Predivider Synchronous Predivider
187 #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 (STM32L152xE) || defined (STM32L162xE)
188 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= (uint32_t)0x7FFF)
189 #elif defined(STM32L100xB) || defined (STM32L151xB) || defined (STM32L152xB)
190 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= (uint32_t)0x1FFF)
191 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
196 /** @defgroup RTC_Interrupts_Definitions Interrupts Definitions
199 #define RTC_IT_TS ((uint32_t)0x00008000)
200 #define RTC_IT_WUT ((uint32_t)0x00004000)
201 #define RTC_IT_ALRB ((uint32_t)0x00002000)
202 #define RTC_IT_ALRA ((uint32_t)0x00001000)
203 #define RTC_IT_TAMP1 ((uint32_t)0x00020000)
204 #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 (STM32L152xE) || defined (STM32L162xE)
205 #define RTC_IT_TAMP2 ((uint32_t)0x00040000)
206 #define RTC_IT_TAMP3 ((uint32_t)0x00080000)
207 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
212 /** @defgroup RTC_Flags_Definitions Flags Definitions
215 #define RTC_FLAG_RECALPF ((uint32_t)0x00010000)
216 #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 (STM32L152xE) || defined (STM32L162xE)
217 #define RTC_FLAG_TAMP3F ((uint32_t)0x00008000)
218 #define RTC_FLAG_TAMP2F ((uint32_t)0x00004000)
219 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
220 #define RTC_FLAG_TAMP1F ((uint32_t)0x00002000)
221 #define RTC_FLAG_TSOVF ((uint32_t)0x00001000)
222 #define RTC_FLAG_TSF ((uint32_t)0x00000800)
223 #define RTC_FLAG_WUTF ((uint32_t)0x00000400)
224 #define RTC_FLAG_ALRBF ((uint32_t)0x00000200)
225 #define RTC_FLAG_ALRAF ((uint32_t)0x00000100)
226 #define RTC_FLAG_INITF ((uint32_t)0x00000040)
227 #define RTC_FLAG_RSF ((uint32_t)0x00000020)
228 #define RTC_FLAG_INITS ((uint32_t)0x00000010)
229 #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 (STM32L152xE) || defined (STM32L162xE)
230 #define RTC_FLAG_SHPF ((uint32_t)0x00000008)
231 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
232 #define RTC_FLAG_WUTWF ((uint32_t)0x00000004)
233 #define RTC_FLAG_ALRBWF ((uint32_t)0x00000002)
234 #define RTC_FLAG_ALRAWF ((uint32_t)0x00000001)
239 /** @defgroup RTCEx_Output_selection_Definitions Output selection Definitions
242 #define RTC_OUTPUT_DISABLE ((uint32_t)0x00000000)
243 #define RTC_OUTPUT_ALARMA ((uint32_t)0x00200000)
244 #define RTC_OUTPUT_ALARMB ((uint32_t)0x00400000)
245 #define RTC_OUTPUT_WAKEUP ((uint32_t)0x00600000)
247 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
248 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \
249 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \
250 ((OUTPUT) == RTC_OUTPUT_WAKEUP))
255 /** @defgroup RTCEx_Backup_Registers_Definitions Backup Registers Definitions
258 #if RTC_BKP_NUMBER > 0
259 #define RTC_BKP_DR0 ((uint32_t)0x00000000)
260 #define RTC_BKP_DR1 ((uint32_t)0x00000001)
261 #define RTC_BKP_DR2 ((uint32_t)0x00000002)
262 #define RTC_BKP_DR3 ((uint32_t)0x00000003)
263 #define RTC_BKP_DR4 ((uint32_t)0x00000004)
264 #endif /* RTC_BKP_NUMBER > 0 */
266 #if RTC_BKP_NUMBER > 5
267 #define RTC_BKP_DR5 ((uint32_t)0x00000005)
268 #define RTC_BKP_DR6 ((uint32_t)0x00000006)
269 #define RTC_BKP_DR7 ((uint32_t)0x00000007)
270 #define RTC_BKP_DR8 ((uint32_t)0x00000008)
271 #define RTC_BKP_DR9 ((uint32_t)0x00000009)
272 #define RTC_BKP_DR10 ((uint32_t)0x0000000A)
273 #define RTC_BKP_DR11 ((uint32_t)0x0000000B)
274 #define RTC_BKP_DR12 ((uint32_t)0x0000000C)
275 #define RTC_BKP_DR13 ((uint32_t)0x0000000D)
276 #define RTC_BKP_DR14 ((uint32_t)0x0000000E)
277 #define RTC_BKP_DR15 ((uint32_t)0x0000000F)
278 #define RTC_BKP_DR16 ((uint32_t)0x00000010)
279 #define RTC_BKP_DR17 ((uint32_t)0x00000011)
280 #define RTC_BKP_DR18 ((uint32_t)0x00000012)
281 #define RTC_BKP_DR19 ((uint32_t)0x00000013)
282 #endif /* RTC_BKP_NUMBER > 5 */
284 #if RTC_BKP_NUMBER > 20
285 #define RTC_BKP_DR20 ((uint32_t)0x00000014)
286 #define RTC_BKP_DR21 ((uint32_t)0x00000015)
287 #define RTC_BKP_DR22 ((uint32_t)0x00000016)
288 #define RTC_BKP_DR23 ((uint32_t)0x00000017)
289 #define RTC_BKP_DR24 ((uint32_t)0x00000018)
290 #define RTC_BKP_DR25 ((uint32_t)0x00000019)
291 #define RTC_BKP_DR26 ((uint32_t)0x0000001A)
292 #define RTC_BKP_DR27 ((uint32_t)0x0000001B)
293 #define RTC_BKP_DR28 ((uint32_t)0x0000001C)
294 #define RTC_BKP_DR29 ((uint32_t)0x0000001D)
295 #define RTC_BKP_DR30 ((uint32_t)0x0000001E)
296 #define RTC_BKP_DR31 ((uint32_t)0x0000001F)
297 #endif /* RTC_BKP_NUMBER > 20 */
299 #define IS_RTC_BKP(BKP) ((BKP) < (uint32_t) RTC_BKP_NUMBER)
304 /** @defgroup RTCEx_Time_Stamp_Edges_Definitions Time Stamp Edges Definitions
307 #define RTC_TIMESTAMPEDGE_RISING ((uint32_t)0x00000000)
308 #define RTC_TIMESTAMPEDGE_FALLING ((uint32_t)0x00000008)
310 #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \
311 ((EDGE) == RTC_TIMESTAMPEDGE_FALLING))
316 /** @defgroup RTCEx_Tamper_Pins_Definitions Tamper Pins Definitions
319 #define RTC_TAMPER_1 RTC_TAFCR_TAMP1E
320 #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 (STM32L152xE) || defined (STM32L162xE)
321 #define RTC_TAMPER_2 RTC_TAFCR_TAMP2E
322 #define RTC_TAMPER_3 RTC_TAFCR_TAMP3E
323 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
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 (STM32L152xE) || defined (STM32L162xE)
326 #define IS_TAMPER(TAMPER) (((~(RTC_TAMPER_1|RTC_TAMPER_2|RTC_TAMPER_3) & (TAMPER)) == (uint32_t)RESET) && ((TAMPER) != (uint32_t)RESET))
328 #define IS_TAMPER(TAMPER) ((TAMPER) == RTC_TAMPER_1)
329 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
334 /** @defgroup RTCEx_Tamper_Trigger_Definitions Tamper Trigger Definitions
337 #define RTC_TAMPERTRIGGER_RISINGEDGE ((uint32_t)0x00000000)
338 #define RTC_TAMPERTRIGGER_FALLINGEDGE ((uint32_t)0x00000002)
339 #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 (STM32L152xE) || defined (STM32L162xE)
340 #define RTC_TAMPERTRIGGER_LOWLEVEL RTC_TAMPERTRIGGER_RISINGEDGE
341 #define RTC_TAMPERTRIGGER_HIGHLEVEL RTC_TAMPERTRIGGER_FALLINGEDGE
342 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
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 (STM32L152xE) || defined (STM32L162xE)
345 #define IS_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) || \
346 ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \
347 ((TRIGGER) == RTC_TAMPERTRIGGER_LOWLEVEL) || \
348 ((TRIGGER) == RTC_TAMPERTRIGGER_HIGHLEVEL))
349 #elif defined(STM32L100xB) || defined (STM32L151xB) || defined (STM32L152xB)
350 #define IS_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) || \
351 ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE))
352 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
357 #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 (STM32L152xE) || defined (STM32L162xE)
358 /** @defgroup RTCEx_Tamper_Filter_Definitions Tamper Filter Definitions
361 #define RTC_TAMPERFILTER_DISABLE ((uint32_t)0x00000000) /*!< Tamper filter is disabled */
363 #define RTC_TAMPERFILTER_2SAMPLE ((uint32_t)0x00000800) /*!< Tamper is activated after 2
364 consecutive samples at the active level */
365 #define RTC_TAMPERFILTER_4SAMPLE ((uint32_t)0x00001000) /*!< Tamper is activated after 4
366 consecutive samples at the active level */
367 #define RTC_TAMPERFILTER_8SAMPLE ((uint32_t)0x00001800) /*!< Tamper is activated after 8
368 consecutive samples at the active level. */
370 #define IS_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TAMPERFILTER_DISABLE) || \
371 ((FILTER) == RTC_TAMPERFILTER_2SAMPLE) || \
372 ((FILTER) == RTC_TAMPERFILTER_4SAMPLE) || \
373 ((FILTER) == RTC_TAMPERFILTER_8SAMPLE))
378 /** @defgroup RTCEx_Tamper_Sampling_Frequencies_Definitions Tamper Sampling Frequencies
381 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 ((uint32_t)0x00000000) /*!< Each of the tamper inputs are sampled
382 with a frequency = RTCCLK / 32768 */
383 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 ((uint32_t)0x00000100) /*!< Each of the tamper inputs are sampled
384 with a frequency = RTCCLK / 16384 */
385 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 ((uint32_t)0x00000200) /*!< Each of the tamper inputs are sampled
386 with a frequency = RTCCLK / 8192 */
387 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 ((uint32_t)0x00000300) /*!< Each of the tamper inputs are sampled
388 with a frequency = RTCCLK / 4096 */
389 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 ((uint32_t)0x00000400) /*!< Each of the tamper inputs are sampled
390 with a frequency = RTCCLK / 2048 */
391 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 ((uint32_t)0x00000500) /*!< Each of the tamper inputs are sampled
392 with a frequency = RTCCLK / 1024 */
393 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512 ((uint32_t)0x00000600) /*!< Each of the tamper inputs are sampled
394 with a frequency = RTCCLK / 512 */
395 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256 ((uint32_t)0x00000700) /*!< Each of the tamper inputs are sampled
396 with a frequency = RTCCLK / 256 */
398 #define IS_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \
399 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \
400 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \
401 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \
402 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \
403 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \
404 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512) || \
405 ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256))
410 /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration_Definitions Tamper Pin Precharge Duration
413 #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK ((uint32_t)0x00000000) /*!< Tamper pins are pre-charged before
414 sampling during 1 RTCCLK cycle */
415 #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK ((uint32_t)0x00002000) /*!< Tamper pins are pre-charged before
416 sampling during 2 RTCCLK cycles */
417 #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK ((uint32_t)0x00004000) /*!< Tamper pins are pre-charged before
418 sampling during 4 RTCCLK cycles */
419 #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK ((uint32_t)0x00006000) /*!< Tamper pins are pre-charged before
420 sampling during 8 RTCCLK cycles */
422 #define IS_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \
423 ((DURATION) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \
424 ((DURATION) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \
425 ((DURATION) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK))
430 /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection_Definitions TimeStampOnTamperDetection Definitions
433 #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE ((uint32_t)RTC_TAFCR_TAMPTS) /*!< TimeStamp on Tamper Detection event saved */
434 #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE ((uint32_t)0x00000000) /*!< TimeStamp on Tamper Detection event is not saved */
436 #define IS_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \
437 ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
442 /** @defgroup RTCEx_Tamper_Pull_Up_Definitions Tamper Pull-Up Definitions
445 #define RTC_TAMPER_PULLUP_ENABLE ((uint32_t)0x00000000) /*!< TimeStamp on Tamper Detection event saved */
446 #define RTC_TAMPER_PULLUP_DISABLE ((uint32_t)RTC_TAFCR_TAMPPUDIS) /*!< TimeStamp on Tamper Detection event is not saved */
448 #define IS_TAMPER_PULLUP_STATE(STATE) (((STATE) == RTC_TAMPER_PULLUP_ENABLE) || \
449 ((STATE) == RTC_TAMPER_PULLUP_DISABLE))
453 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
455 /** @defgroup RTCEx_Wakeup_Timer_Definitions Wakeup Timer Definitions
458 #define RTC_WAKEUPCLOCK_RTCCLK_DIV16 ((uint32_t)0x00000000)
459 #define RTC_WAKEUPCLOCK_RTCCLK_DIV8 ((uint32_t)0x00000001)
460 #define RTC_WAKEUPCLOCK_RTCCLK_DIV4 ((uint32_t)0x00000002)
461 #define RTC_WAKEUPCLOCK_RTCCLK_DIV2 ((uint32_t)0x00000003)
462 #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS ((uint32_t)0x00000004)
463 #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS ((uint32_t)0x00000006)
465 #define IS_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16) || \
466 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8) || \
467 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4) || \
468 ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2) || \
469 ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \
470 ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS))
472 #define IS_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= 0xFFFF)
477 /** @defgroup RTCEx_Digital_Calibration_Definitions Digital Calibration Definitions
480 #define RTC_CALIBSIGN_POSITIVE ((uint32_t)0x00000000)
481 #define RTC_CALIBSIGN_NEGATIVE ((uint32_t)0x00000080)
483 #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CALIBSIGN_POSITIVE) || \
484 ((SIGN) == RTC_CALIBSIGN_NEGATIVE))
486 #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20)
491 /** @defgroup RTCEx_Smooth_Calib_Period_Definitions Smooth Calib Period Definitions
494 #define RTC_SMOOTHCALIB_PERIOD_32SEC ((uint32_t)0x00000000) /*!< If RTCCLK = 32768 Hz, Smooth calibation
495 period is 32s, else 2exp20 RTCCLK seconds */
496 #define RTC_SMOOTHCALIB_PERIOD_16SEC ((uint32_t)0x00002000) /*!< If RTCCLK = 32768 Hz, Smooth calibation
497 period is 16s, else 2exp19 RTCCLK seconds */
498 #define RTC_SMOOTHCALIB_PERIOD_8SEC ((uint32_t)0x00004000) /*!< If RTCCLK = 32768 Hz, Smooth calibation
499 period is 8s, else 2exp18 RTCCLK seconds */
501 #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \
502 ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \
503 ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC))
508 /** @defgroup RTCEx_Smooth_Calib_Plus_Pulses_Definitions Smooth Calib Plus Pulses Definitions
511 #define RTC_SMOOTHCALIB_PLUSPULSES_SET ((uint32_t)0x00008000) /*!< The number of RTCCLK pulses added
512 during a X -second window = Y - CALM[8:0]
513 with Y = 512, 256, 128 when X = 32, 16, 8 */
514 #define RTC_SMOOTHCALIB_PLUSPULSES_RESET ((uint32_t)0x00000000) /*!< The number of RTCCLK pulses subbstited
515 during a 32-second window = CALM[8:0] */
517 #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \
518 ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET))
523 /** @defgroup RTCEx_Smooth_Calib_Minus_Pulses_Definitions Smooth Calib Minus Pulses Definitions
526 #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= 0x000001FF)
531 /** @defgroup RTCEx_Add_1_Second_Parameter_Definitions Add 1 Second Parameter Definitions
534 #define RTC_SHIFTADD1S_RESET ((uint32_t)0x00000000)
535 #define RTC_SHIFTADD1S_SET ((uint32_t)0x80000000)
537 #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \
538 ((SEL) == RTC_SHIFTADD1S_SET))
543 /** @defgroup RTCEx_Substract_Fraction_Of_Second_Value Substract Fraction Of Second Value
546 #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= 0x00007FFF)
551 /** @defgroup RTCEx_Calib_Output_Selection_Definitions Calib Output Selection Definitions
554 #define RTC_CALIBOUTPUT_512HZ ((uint32_t)0x00000000)
555 #define RTC_CALIBOUTPUT_1HZ ((uint32_t)0x00080000)
557 #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \
558 ((OUTPUT) == RTC_CALIBOUTPUT_1HZ))
563 #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 (STM32L152xE) || defined (STM32L162xE)
564 /** @defgroup RTC_Alarm_Sub_Seconds_Value Alarm Sub Seconds Value
567 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= (uint32_t)0x00007FFF)
572 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions Alarm Sub Seconds Masks Definitions
575 #define RTC_ALARMSUBSECONDMASK_ALL ((uint32_t)0x00000000) /*!< All Alarm SS fields are masked.
576 There is no comparison on sub seconds
578 #define RTC_ALARMSUBSECONDMASK_SS14_1 ((uint32_t)0x01000000) /*!< SS[14:1] are don't care in Alarm
579 comparison. Only SS[0] is compared. */
580 #define RTC_ALARMSUBSECONDMASK_SS14_2 ((uint32_t)0x02000000) /*!< SS[14:2] are don't care in Alarm
581 comparison. Only SS[1:0] are compared */
582 #define RTC_ALARMSUBSECONDMASK_SS14_3 ((uint32_t)0x03000000) /*!< SS[14:3] are don't care in Alarm
583 comparison. Only SS[2:0] are compared */
584 #define RTC_ALARMSUBSECONDMASK_SS14_4 ((uint32_t)0x04000000) /*!< SS[14:4] are don't care in Alarm
585 comparison. Only SS[3:0] are compared */
586 #define RTC_ALARMSUBSECONDMASK_SS14_5 ((uint32_t)0x05000000) /*!< SS[14:5] are don't care in Alarm
587 comparison. Only SS[4:0] are compared */
588 #define RTC_ALARMSUBSECONDMASK_SS14_6 ((uint32_t)0x06000000) /*!< SS[14:6] are don't care in Alarm
589 comparison. Only SS[5:0] are compared */
590 #define RTC_ALARMSUBSECONDMASK_SS14_7 ((uint32_t)0x07000000) /*!< SS[14:7] are don't care in Alarm
591 comparison. Only SS[6:0] are compared */
592 #define RTC_ALARMSUBSECONDMASK_SS14_8 ((uint32_t)0x08000000) /*!< SS[14:8] are don't care in Alarm
593 comparison. Only SS[7:0] are compared */
594 #define RTC_ALARMSUBSECONDMASK_SS14_9 ((uint32_t)0x09000000) /*!< SS[14:9] are don't care in Alarm
595 comparison. Only SS[8:0] are compared */
596 #define RTC_ALARMSUBSECONDMASK_SS14_10 ((uint32_t)0x0A000000) /*!< SS[14:10] are don't care in Alarm
597 comparison. Only SS[9:0] are compared */
598 #define RTC_ALARMSUBSECONDMASK_SS14_11 ((uint32_t)0x0B000000) /*!< SS[14:11] are don't care in Alarm
599 comparison. Only SS[10:0] are compared */
600 #define RTC_ALARMSUBSECONDMASK_SS14_12 ((uint32_t)0x0C000000) /*!< SS[14:12] are don't care in Alarm
601 comparison.Only SS[11:0] are compared */
602 #define RTC_ALARMSUBSECONDMASK_SS14_13 ((uint32_t)0x0D000000) /*!< SS[14:13] are don't care in Alarm
603 comparison. Only SS[12:0] are compared */
604 #define RTC_ALARMSUBSECONDMASK_SS14 ((uint32_t)0x0E000000) /*!< SS[14] is don't care in Alarm
605 comparison.Only SS[13:0] are compared */
606 #define RTC_ALARMSUBSECONDMASK_NONE ((uint32_t)0x0F000000) /*!< SS[14:0] are compared and must match
607 to activate alarm. */
609 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == RTC_ALARMSUBSECONDMASK_ALL) || \
610 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_1) || \
611 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_2) || \
612 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_3) || \
613 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_4) || \
614 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_5) || \
615 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_6) || \
616 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_7) || \
617 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_8) || \
618 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_9) || \
619 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_10) || \
620 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_11) || \
621 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_12) || \
622 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_13) || \
623 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14) || \
624 ((MASK) == RTC_ALARMSUBSECONDMASK_NONE))
628 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
634 /* Exported macro ------------------------------------------------------------*/
635 /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros
640 * @brief Enable the RTC WakeUp Timer peripheral.
641 * @param __HANDLE__: specifies the RTC handle.
644 #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE))
647 * @brief Enable the RTC TimeStamp peripheral.
648 * @param __HANDLE__: specifies the RTC handle.
651 #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE))
654 * @brief Disable the RTC WakeUp Timer peripheral.
655 * @param __HANDLE__: specifies the RTC handle.
658 #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE))
661 * @brief Disable the RTC TimeStamp peripheral.
662 * @param __HANDLE__: specifies the RTC handle.
665 #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE))
668 * @brief Enable the Coarse calibration process.
669 * @param __HANDLE__: specifies the RTC handle.
672 #define __HAL_RTC_COARSE_CALIB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_DCE))
675 * @brief Disable the Coarse calibration process.
676 * @param __HANDLE__: specifies the RTC handle.
679 #define __HAL_RTC_COARSE_CALIB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_DCE))
682 * @brief Enable the RTC calibration output.
683 * @param __HANDLE__: specifies the RTC handle.
686 #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_COE))
689 * @brief Disable the calibration output.
690 * @param __HANDLE__: specifies the RTC handle.
693 #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE))
696 * @brief Enable the clock reference detection.
697 * @param __HANDLE__: specifies the RTC handle.
700 #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON))
703 * @brief Disable the clock reference detection.
704 * @param __HANDLE__: specifies the RTC handle.
707 #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON))
710 * @brief Enable the RTC TimeStamp interrupt.
711 * @param __HANDLE__: specifies the RTC handle.
712 * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled.
713 * This parameter can be:
714 * @arg RTC_IT_TS: TimeStamp interrupt
717 #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
720 * @brief Enable the RTC WakeUpTimer interrupt.
721 * @param __HANDLE__: specifies the RTC handle.
722 * @param __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
723 * This parameter can be:
724 * @arg RTC_IT_WUT: WakeUpTimer A interrupt
727 #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
730 * @brief Disable the RTC TimeStamp interrupt.
731 * @param __HANDLE__: specifies the RTC handle.
732 * @param __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled.
733 * This parameter can be:
734 * @arg RTC_IT_TS: TimeStamp interrupt
737 #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
740 * @brief Disable the RTC WakeUpTimer interrupt.
741 * @param __HANDLE__: specifies the RTC handle.
742 * @param __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
743 * This parameter can be:
744 * @arg RTC_IT_WUT: WakeUpTimer A interrupt
747 #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
749 #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 (STM32L152xE) || defined (STM32L162xE)
751 * @brief Check whether the specified RTC Tamper interrupt has occurred or not.
752 * @param __HANDLE__: specifies the RTC handle.
753 * @param __FLAG__: specifies the RTC Tamper interrupt sources to be enabled or disabled.
754 * This parameter can be:
762 * @brief Check whether the specified RTC Tamper interrupt has occurred or not.
763 * @param __HANDLE__: specifies the RTC handle.
764 * @param __FLAG__: specifies the RTC Tamper interrupt sources to be enabled or disabled.
765 * This parameter can be:
770 #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & ((__FLAG__)>> 4)) != RESET)? SET : RESET)
773 * @brief Check whether the specified RTC WakeUpTimer interrupt has occurred or not.
774 * @param __HANDLE__: specifies the RTC handle.
775 * @param __FLAG__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
776 * This parameter can be:
777 * @arg RTC_IT_WUT: WakeUpTimer A interrupt
780 #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & ((__FLAG__)>> 4)) != RESET)? SET : RESET)
783 * @brief Check whether the specified RTC TimeStamp interrupt has occurred or not.
784 * @param __HANDLE__: specifies the RTC handle.
785 * @param __FLAG__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled.
786 * This parameter can be:
787 * @arg RTC_IT_TS: TimeStamp interrupt
790 #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & ((__FLAG__)>> 4)) != RESET)? SET : RESET)
793 * @brief Get the selected RTC TimeStamp's flag status.
794 * @param __HANDLE__: specifies the RTC handle.
795 * @param __FLAG__: specifies the RTC TimeStamp Flag sources to be enabled or disabled.
796 * This parameter can be:
798 * @arg RTC_FLAG_TSOVF
801 #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
804 * @brief Get the selected RTC WakeUpTimer's flag status.
805 * @param __HANDLE__: specifies the RTC handle.
806 * @param __FLAG__: specifies the RTC WakeUpTimer Flag sources to be enabled or disabled.
807 * This parameter can be:
809 * @arg RTC_FLAG_WUTWF
812 #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
815 * @brief Get the selected RTC Tamper's flag status.
816 * @param __HANDLE__: specifies the RTC handle.
817 * @param __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled.
818 * This parameter can be:
819 * @arg RTC_FLAG_TAMP1F
822 #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
824 #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 (STM32L152xE) || defined (STM32L162xE)
826 * @brief Get the selected RTC shift operation's flag status.
827 * @param __HANDLE__: specifies the RTC handle.
828 * @param __FLAG__: specifies the RTC shift operation Flag is pending or not.
829 * This parameter can be:
833 #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
834 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
837 * @brief Clear the RTC Time Stamp's pending flags.
838 * @param __HANDLE__: specifies the RTC handle.
839 * @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled.
840 * This parameter can be:
844 #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& 0x0000FFFF)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
847 * @brief Clear the RTC Tamper's pending flags.
848 * @param __HANDLE__: specifies the RTC handle.
849 * @param __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled.
850 * This parameter can be:
851 * @arg RTC_FLAG_TAMP1F
854 #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& 0x0000FFFF)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
857 * @brief Clear the RTC Wake Up timer's pending flags.
858 * @param __HANDLE__: specifies the RTC handle.
859 * @param __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled.
860 * This parameter can be:
864 #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& 0x0000FFFF)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
870 /* Exported functions --------------------------------------------------------*/
871 /** @addtogroup RTCEx_Exported_Functions
875 /* RTC TimeStamp and Tamper functions *****************************************/
876 /** @addtogroup RTCEx_Exported_Functions_Group4
879 HAL_StatusTypeDef
HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef
*hrtc
, uint32_t TimeStampEdge
);
880 HAL_StatusTypeDef
HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef
*hrtc
, uint32_t TimeStampEdge
);
881 HAL_StatusTypeDef
HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef
*hrtc
);
882 HAL_StatusTypeDef
HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef
*hrtc
, RTC_TimeTypeDef
*sTimeStamp
, RTC_DateTypeDef
*sTimeStampDate
, uint32_t Format
);
884 HAL_StatusTypeDef
HAL_RTCEx_SetTamper(RTC_HandleTypeDef
*hrtc
, RTC_TamperTypeDef
* sTamper
);
885 HAL_StatusTypeDef
HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef
*hrtc
, RTC_TamperTypeDef
* sTamper
);
886 HAL_StatusTypeDef
HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef
*hrtc
, uint32_t Tamper
);
887 void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef
*hrtc
);
889 void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef
*hrtc
);
890 #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 (STM32L152xE) || defined (STM32L162xE)
891 void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef
*hrtc
);
892 void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef
*hrtc
);
893 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
894 void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef
*hrtc
);
895 HAL_StatusTypeDef
HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef
*hrtc
, uint32_t Timeout
);
896 HAL_StatusTypeDef
HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef
*hrtc
, uint32_t Timeout
);
897 #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 (STM32L152xE) || defined (STM32L162xE)
898 HAL_StatusTypeDef
HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef
*hrtc
, uint32_t Timeout
);
899 HAL_StatusTypeDef
HAL_RTCEx_PollForTamper3Event(RTC_HandleTypeDef
*hrtc
, uint32_t Timeout
);
900 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
905 /* RTC Wake-up functions ******************************************************/
906 /** @addtogroup RTCEx_Exported_Functions_Group5
909 HAL_StatusTypeDef
HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef
*hrtc
, uint32_t WakeUpCounter
, uint32_t WakeUpClock
);
910 HAL_StatusTypeDef
HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef
*hrtc
, uint32_t WakeUpCounter
, uint32_t WakeUpClock
);
911 uint32_t HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef
*hrtc
);
912 uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef
*hrtc
);
913 void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef
*hrtc
);
914 void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef
*hrtc
);
915 HAL_StatusTypeDef
HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef
*hrtc
, uint32_t Timeout
);
920 /* Extension Control functions ************************************************/
921 /** @addtogroup RTCEx_Exported_Functions_Group7
924 void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef
*hrtc
, uint32_t BackupRegister
, uint32_t Data
);
925 uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef
*hrtc
, uint32_t BackupRegister
);
927 HAL_StatusTypeDef
HAL_RTCEx_SetCoarseCalib(RTC_HandleTypeDef
*hrtc
, uint32_t CalibSign
, uint32_t Value
);
928 HAL_StatusTypeDef
HAL_RTCEx_DeactivateCoarseCalib(RTC_HandleTypeDef
*hrtc
);
929 #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 (STM32L152xE) || defined (STM32L162xE)
930 HAL_StatusTypeDef
HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef
*hrtc
, uint32_t SmoothCalibPeriod
, uint32_t SmoothCalibPlusPulses
, uint32_t SmouthCalibMinusPulsesValue
);
931 HAL_StatusTypeDef
HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef
*hrtc
, uint32_t ShiftAdd1S
, uint32_t ShiftSubFS
);
932 HAL_StatusTypeDef
HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef
*hrtc
, uint32_t CalibOutput
);
934 HAL_StatusTypeDef
HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef
*hrtc
);
935 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE */
936 HAL_StatusTypeDef
HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef
*hrtc
);
937 HAL_StatusTypeDef
HAL_RTCEx_SetRefClock(RTC_HandleTypeDef
*hrtc
);
938 HAL_StatusTypeDef
HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef
*hrtc
);
939 HAL_StatusTypeDef
HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef
*hrtc
);
940 HAL_StatusTypeDef
HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef
*hrtc
);
945 /* Extension RTC features functions *******************************************/
946 /** @addtogroup RTCEx_Exported_Functions_Group8
949 void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef
*hrtc
);
950 HAL_StatusTypeDef
HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef
*hrtc
, uint32_t Timeout
);
971 #endif /* __STM32L1xx_HAL_RTC_EX_H */
973 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/