]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32L0/stm32l0xx_hal_rtc_ex.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32L0 / stm32l0xx_hal_rtc_ex.h
1 /**
2   ******************************************************************************
3   * @file    stm32l0xx_hal_rtc_ex.h
4   * @author  MCD Application Team
5   * @version V1.2.0
6   * @date    06-February-2015
7   * @brief   Header file of RTC HAL Extended module.
8   ******************************************************************************
9   * @attention
10   *
11   * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
12   *
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.
23   *
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.
34   *
35   ******************************************************************************
36   */ 
37
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32L0xx_HAL_RTC_EX_H
40 #define __STM32L0xx_HAL_RTC_EX_H
41
42 #ifdef __cplusplus
43  extern "C" {
44 #endif
45
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32l0xx_hal_def.h"
48
49 /** @addtogroup STM32L0xx_HAL_Driver
50   * @{
51   */
52
53 /** @defgroup RTCEx RTCEx
54   * @{
55   */
56
57 /* Exported types ------------------------------------------------------------*/ 
58
59 /** @defgroup RTCEx_Exported_Types RTC Extended Exported Types
60   * @{
61   */
62
63 /**
64   * @brief  RTC Tamper structure definition
65   */
66 typedef struct
67 {
68   uint32_t Tamper;                      /*!< Specifies the Tamper Pin.
69                                              This parameter can be a value of @ref  RTCEx_Tamper_Pins_Definitions */
70
71   uint32_t Interrupt;                   /*!< Specifies the Tamper Interrupt.
72                                              This parameter can be a value of @ref  RTCEx_Tamper_Interrupt_Definitions */
73
74   uint32_t Trigger;                     /*!< Specifies the Tamper Trigger.
75                                              This parameter can be a value of @ref  RTCEx_Tamper_Trigger_Definitions */
76
77   uint32_t NoErase;                     /*!< Specifies the Tamper no erase mode.
78                                              This parameter can be a value of @ref  RTCEx_Tamper_EraseBackUp_Definitions */
79
80   uint32_t MaskFlag;                     /*!< Specifies the Tamper Flag masking.
81                                              This parameter can be a value of @ref RTCEx_Tamper_MaskFlag_Definitions   */
82
83   uint32_t Filter;                      /*!< Specifies the RTC Filter Tamper.
84                                              This parameter can be a value of @ref RTCEx_Tamper_Filter_Definitions */
85
86   uint32_t SamplingFrequency;           /*!< Specifies the sampling frequency.
87                                              This parameter can be a value of @ref RTCEx_Tamper_Sampling_Frequencies_Definitions */
88
89   uint32_t PrechargeDuration;           /*!< Specifies the Precharge Duration .
90                                              This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration_Definitions */
91
92   uint32_t TamperPullUp;                /*!< Specifies the Tamper PullUp .
93                                              This parameter can be a value of @ref RTCEx_Tamper_Pull_UP_Definitions */
94
95   uint32_t TimeStampOnTamperDetection;  /*!< Specifies the TimeStampOnTamperDetection.
96                                              This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection_Definitions */
97 }RTC_TamperTypeDef;
98 /**
99   * @}
100   */
101
102 /* Exported constants --------------------------------------------------------*/
103 /** @defgroup RTCEx_Exported_Constants RTC Extended Exported Constants
104   * @{
105   */
106
107
108 /** @defgroup RTCEx_Interrupts_Definitions RTC Extended Interrupts Definitions
109   * @{
110   */
111 #if defined (STM32L083xx) || defined (STM32L082xx) || defined (STM32L081xx) || \
112   defined (STM32L073xx) || defined (STM32L072xx) || defined (STM32L071xx)
113     
114 #define RTC_IT_TAMP3                      RTC_TAMPCR_TAMP3IE
115     
116 #endif /* (STM32L083xx) || (STM32L082xx) || (STM32L081xx) ||
117     * (STM32L073xx) || (STM32L072xx) || (STM32L071xx)
118     */
119 /**
120   * @}
121   */
122
123     
124 /** @defgroup RTCEx_Flags_Definitions RTC Extended Flags Definitions
125   * @{
126   */
127 #if defined (STM32L083xx) || defined (STM32L082xx) || defined (STM32L081xx) || \
128     defined (STM32L073xx) || defined (STM32L072xx) || defined (STM32L071xx)
129       
130 #define RTC_FLAG_TAMP3F                    RTC_ISR_TAMP3F
131       
132 #endif /* (STM32L083xx) || (STM32L082xx) || (STM32L081xx) ||
133         * (STM32L073xx) || (STM32L072xx) || (STM32L071xx)
134       */
135       
136 /**
137   * @}
138   */    
139       
140 /** @defgroup RTCEx_Backup_Registers_Definitions RTC Extended Backup Registers Definition
141   * @{
142   */
143 #define RTC_BKP_DR0                       ((uint32_t)0x00000000)
144 #define RTC_BKP_DR1                       ((uint32_t)0x00000001)
145 #define RTC_BKP_DR2                       ((uint32_t)0x00000002)
146 #define RTC_BKP_DR3                       ((uint32_t)0x00000003)
147 #define RTC_BKP_DR4                       ((uint32_t)0x00000004)
148
149 #define IS_RTC_BKP(__BKP__)               (((__BKP__) == RTC_BKP_DR0) || \
150                                            ((__BKP__) == RTC_BKP_DR1) || \
151                                            ((__BKP__) == RTC_BKP_DR2) || \
152                                            ((__BKP__) == RTC_BKP_DR3) || \
153                                            ((__BKP__) == RTC_BKP_DR4))
154 /**
155   * @}
156   */
157   
158 /** @defgroup RTC_Mask_Definition RTC Mask Definition
159   * @{
160   */
161   
162 /* Masks Definition */
163
164 #if defined (STM32L083xx) || defined (STM32L082xx) || defined (STM32L081xx) || \
165     defined (STM32L073xx) || defined (STM32L072xx) || defined (STM32L071xx)
166
167 #define RTC_FLAGS_MASK          ((uint32_t) (RTC_FLAG_RECALPF | RTC_FLAG_TAMP3F | RTC_FLAG_TAMP2F | \
168                                              RTC_FLAG_TAMP1F| RTC_FLAG_TSOVF | RTC_FLAG_TSF       | \
169                                              RTC_FLAG_WUTF | RTC_FLAG_ALRBF | RTC_FLAG_ALRAF      | \
170                                              RTC_FLAG_INIT | RTC_FLAG_INITF | RTC_FLAG_RSF        | \
171                                              RTC_FLAG_INITS | RTC_FLAG_SHPF | RTC_FLAG_WUTWF      | \
172                                              RTC_FLAG_ALRBWF | RTC_FLAG_ALRAWF))
173
174 #define RTC_TAMPCR_TAMPXE     ((uint32_t) (RTC_TAMPCR_TAMP3E | RTC_TAMPCR_TAMP2E | RTC_TAMPCR_TAMP1E))
175
176 #else
177
178 #define RTC_FLAGS_MASK          ((uint32_t) (RTC_FLAG_RECALPF | RTC_FLAG_TAMP2F | RTC_FLAG_TAMP1F| \
179                                              RTC_FLAG_TSOVF | RTC_FLAG_TSF | RTC_FLAG_WUTF       | \
180                                              RTC_FLAG_ALRBF | RTC_FLAG_ALRAF | RTC_FLAG_INIT     | \
181                                              RTC_FLAG_INITF | RTC_FLAG_RSF | RTC_FLAG_INITS      | \
182                                              RTC_FLAG_SHPF | RTC_FLAG_WUTWF |RTC_FLAG_ALRBWF     | \
183                                              RTC_FLAG_ALRAWF))
184
185 #define RTC_TAMPCR_TAMPXE     ((uint32_t) (RTC_TAMPCR_TAMP2E | RTC_TAMPCR_TAMP1E))
186
187 #endif /* (STM32L083xx) || (STM32L082xx) || (STM32L081xx) ||
188         * (STM32L073xx) || (STM32L072xx) || (STM32L071xx)
189         */
190 /**
191   * @}
192   */
193   
194 /** @defgroup RTCEx_Time_Stamp_Edges_definitions RTC Extended Time Stamp Edges definition
195   * @{
196   */ 
197 #define RTC_TIMESTAMPEDGE_RISING        ((uint32_t)0x00000000)
198 #define RTC_TIMESTAMPEDGE_FALLING       RTC_CR_TSEDGE
199
200 #define IS_TIMESTAMP_EDGE(__EDGE__)     (((__EDGE__) == RTC_TIMESTAMPEDGE_RISING) || \
201                                          ((__EDGE__) == RTC_TIMESTAMPEDGE_FALLING))
202 /**
203   * @}
204   */
205
206 /** @defgroup RTCEx_Tamper_Pins_Definitions RTC Extended Tamper Pins Definition
207   * @{
208   */
209
210 #define RTC_TAMPER_1                    RTC_TAMPCR_TAMP1E
211 #define RTC_TAMPER_2                    RTC_TAMPCR_TAMP2E
212
213 #if defined (STM32L083xx) || defined (STM32L082xx) || defined (STM32L081xx) || \
214     defined (STM32L073xx) || defined (STM32L072xx) || defined (STM32L071xx)
215
216 #define RTC_TAMPER_3                    RTC_TAMPCR_TAMP3E
217
218 #endif /* (STM32L083xx) || (STM32L082xx) || (STM32L081xx) ||
219         * (STM32L073xx) || (STM32L072xx) || (STM32L071xx)
220         */
221
222 #define  IS_RTC_TAMPER(__TAMPER__) ((((__TAMPER__) & ((uint32_t)(0xFFFFFFFF ^ RTC_TAMPCR_TAMPXE))) == 0x00) && ((__TAMPER__) != (uint32_t)RESET))
223
224 /**
225   * @}
226   */
227
228
229 /** @defgroup RTCEx_Tamper_Interrupt_Definitions RTC Extended Tamper Interrupt Definitions
230   * @{
231   */
232
233 #define RTC_TAMPER1_INTERRUPT                RTC_TAMPCR_TAMP1IE
234 #define RTC_TAMPER2_INTERRUPT                RTC_TAMPCR_TAMP2IE
235 #define RTC_ALL_TAMPER_INTERRUPT             RTC_TAMPCR_TAMPIE
236
237 #if defined (STM32L083xx) || defined (STM32L082xx) || defined (STM32L081xx) || \
238     defined (STM32L073xx) || defined (STM32L072xx) || defined (STM32L071xx)
239
240 #define RTC_TAMPER3_INTERRUPT                RTC_TAMPCR_TAMP3IE
241 #define IS_RTC_TAMPER_INTERRUPT(__INTERRUPT__)  (((__INTERRUPT__) == RTC_TAMPER1_INTERRUPT)    || \
242                                                  ((__INTERRUPT__) == RTC_TAMPER2_INTERRUPT)    || \
243                                                  ((__INTERRUPT__) == RTC_TAMPER3_INTERRUPT)    || \
244                                                  ((__INTERRUPT__) == RTC_ALL_TAMPER_INTERRUPT ))
245
246 #else
247
248 #define IS_RTC_TAMPER_INTERRUPT(__INTERRUPT__) (((__INTERRUPT__) == RTC_TAMPER1_INTERRUPT)  || \
249                                                 ((__INTERRUPT__) == RTC_TAMPER2_INTERRUPT)  || \
250                                                 ((__INTERRUPT__) == RTC_ALL_TAMPER_INTERRUPT ))
251
252 #endif /* (STM32L083xx) || (STM32L082xx) || (STM32L081xx) ||
253         * (STM32L073xx) || (STM32L072xx) || (STM32L071xx)
254         */
255
256 /**
257   * @}
258   */
259
260 /** @defgroup RTCEx_TimeStamp_Pin_Selections RTC Extended TimeStamp Pin Selection
261   * @{
262   */
263 #define RTC_TIMESTAMPPIN_PC13              ((uint32_t)0x00000000)
264
265 #define IS_RTC_TIMESTAMP_PIN(__PIN__) (((__PIN__) == RTC_TIMESTAMPPIN_PC13))
266 /**
267   * @}
268   */
269
270 /** @defgroup RTCEx_Tamper_Trigger_Definitions RTC Extended Tamper Trigger Definition
271   * @{
272   */
273 #define RTC_TAMPERTRIGGER_RISINGEDGE       ((uint32_t)0x00000000)
274 #define RTC_TAMPERTRIGGER_FALLINGEDGE      RTC_TAMPCR_TAMP1TRG
275 #define RTC_TAMPERTRIGGER_LOWLEVEL         RTC_TAMPERTRIGGER_RISINGEDGE
276 #define RTC_TAMPERTRIGGER_HIGHLEVEL        RTC_TAMPERTRIGGER_FALLINGEDGE
277
278 #define  IS_RTC_TAMPER_TRIGGER(__TRIGGER__) (((__TRIGGER__) == RTC_TAMPERTRIGGER_RISINGEDGE)  || \
279                                         ((__TRIGGER__) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \
280                                         ((__TRIGGER__) == RTC_TAMPERTRIGGER_LOWLEVEL)    || \
281                                         ((__TRIGGER__) == RTC_TAMPERTRIGGER_HIGHLEVEL))
282
283 /**
284   * @}
285   */
286
287 /** @defgroup RTCEx_Tamper_EraseBackUp_Definitions RTC Extended Tamper EraseBackUp Definitions
288 * @{
289 */
290 #define RTC_TAMPER_ERASE_BACKUP_ENABLE               ((uint32_t)0x00000000)
291 #define RTC_TAMPER_ERASE_BACKUP_DISABLE              RTC_TAMPCR_TAMP1NOERASE
292
293 #define IS_RTC_TAMPER_ERASE_MODE(__MODE__)              (((__MODE__) == RTC_TAMPER_ERASE_BACKUP_ENABLE) || \
294                                                      ((__MODE__) == RTC_TAMPER_ERASE_BACKUP_DISABLE))
295 /**
296   * @}
297   */
298
299 /** @defgroup RTCEx_Tamper_MaskFlag_Definitions RTC Extended Tamper MaskFlag Definitions
300 * @{
301 */
302 #define RTC_TAMPERMASK_FLAG_DISABLE               ((uint32_t)0x00000000)
303 #define RTC_TAMPERMASK_FLAG_ENABLE                  RTC_TAMPCR_TAMP1MF
304
305 #define IS_RTC_TAMPER_MASKFLAG_STATE(__STATE__)        (((__STATE__) == RTC_TAMPERMASK_FLAG_ENABLE ) || \
306                                                     ((__STATE__) == RTC_TAMPERMASK_FLAG_DISABLE))
307 /**
308   * @}
309   */
310
311 /** @defgroup RTCEx_Tamper_Filter_Definitions RTC Extended Tamper Filter Definitions
312   * @{
313   */
314 #define RTC_TAMPERFILTER_DISABLE   ((uint32_t)0x00000000)  /*!< Tamper filter is disabled */
315
316 #define RTC_TAMPERFILTER_2SAMPLE   RTC_TAMPCR_TAMPFLT_0    /*!< Tamper is activated after 2
317                                                                 consecutive samples at the active level */
318 #define RTC_TAMPERFILTER_4SAMPLE   RTC_TAMPCR_TAMPFLT_1    /*!< Tamper is activated after 4
319                                                                 consecutive samples at the active level */
320 #define RTC_TAMPERFILTER_8SAMPLE   RTC_TAMPCR_TAMPFLT      /*!< Tamper is activated after 8
321                                                                 consecutive samples at the active leve. */
322
323 #define IS_RTC_TAMPER_FILTER(__FILTER__)  (((__FILTER__) == RTC_TAMPERFILTER_DISABLE) || \
324                                        ((__FILTER__) == RTC_TAMPERFILTER_2SAMPLE) || \
325                                        ((__FILTER__) == RTC_TAMPERFILTER_4SAMPLE) || \
326                                        ((__FILTER__) == RTC_TAMPERFILTER_8SAMPLE))
327 /**
328   * @}
329   */
330
331 /** @defgroup RTCEx_Tamper_Sampling_Frequencies_Definitions RTC Extended Tamper Sampling Frequencies Definitions
332   * @{
333   */
334 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768  ((uint32_t)0x00000000)                                         /*!< Each of the tamper inputs are sampled
335                                                                                                                     with a frequency =  RTCCLK / 32768 */
336 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384  RTC_TAMPCR_TAMPFREQ_0                                          /*!< Each of the tamper inputs are sampled
337                                                                                                                     with a frequency =  RTCCLK / 16384 */
338 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192   RTC_TAMPCR_TAMPFREQ_1                                          /*!< Each of the tamper inputs are sampled
339                                                                                                                     with a frequency =  RTCCLK / 8192  */
340 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096   ((uint32_t) (RTC_TAMPCR_TAMPFREQ_0 | RTC_TAMPCR_TAMPFREQ_1))   /*!< Each of the tamper inputs are sampled
341                                                                                                                     with a frequency =  RTCCLK / 4096  */
342 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048   RTC_TAMPCR_TAMPFREQ_2                                          /*!< Each of the tamper inputs are sampled
343                                                                                                                     with a frequency =  RTCCLK / 2048  */
344 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024   ((uint32_t) (RTC_TAMPCR_TAMPFREQ_0 | RTC_TAMPCR_TAMPFREQ_2))   /*!< Each of the tamper inputs are sampled
345                                                                                                                     with a frequency =  RTCCLK / 1024  */
346 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512    ((uint32_t) (RTC_TAMPCR_TAMPFREQ_1 | RTC_TAMPCR_TAMPFREQ_2))   /*!< Each of the tamper inputs are sampled
347                                                                                                                     with a frequency =  RTCCLK / 512   */
348 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256    ((uint32_t) (RTC_TAMPCR_TAMPFREQ_0 | RTC_TAMPCR_TAMPFREQ_1 | \
349                                                  RTC_TAMPCR_TAMPFREQ_2))                                       /*!< Each of the tamper inputs are sampled
350                                                                                                                     with a frequency =  RTCCLK / 256   */
351
352 #define IS_RTC_TAMPER_SAMPLING_FREQ(__FREQ__) (((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \
353                                            ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \
354                                            ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \
355                                            ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \
356                                            ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \
357                                            ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \
358                                            ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512)  || \
359                                            ((__FREQ__) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256))
360 /**
361   * @}
362   */
363
364 /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration_Definitions RTC Extended Tamper Pin Precharge Duration Definitions
365   * @{
366   */
367 #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK  ((uint32_t)0x00000000)                                     /*!< Tamper pins are pre-charged before
368                                                                                                             sampling during 1 RTCCLK cycle  */
369 #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK  RTC_TAMPCR_TAMPPRCH_0                                      /*!< Tamper pins are pre-charged before
370                                                                                                              sampling during 2 RTCCLK cycles */
371 #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK  RTC_TAMPCR_TAMPPRCH_1                                      /*!< Tamper pins are pre-charged before
372                                                                                                              sampling during 4 RTCCLK cycles */
373 #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK ((uint32_t)(RTC_TAMPCR_TAMPPRCH_0 | RTC_TAMPCR_TAMPPRCH_1)) /*!< Tamper pins are pre-charged before
374                                                                                                              sampling during 8 RTCCLK cycles */
375
376 #define IS_RTC_TAMPER_PRECHARGE_DURATION(__DURATION_) (((__DURATION_) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \
377                                                    ((__DURATION_) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \
378                                                    ((__DURATION_) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \
379                                                    ((__DURATION_) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK))
380 /**
381   * @}
382   */
383
384 /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection_Definitions RTC Extended Tamper TimeStampOnTamperDetection Definitions
385   * @{
386   */
387 #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE  RTC_TAMPCR_TAMPTS       /*!< TimeStamp on Tamper Detection event saved        */
388 #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE ((uint32_t)0x00000000)  /*!< TimeStamp on Tamper Detection event is not saved */
389
390 #define IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(__DETECTION__) (((__DETECTION__) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \
391                                                               ((__DETECTION__) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
392 /**
393   * @}
394   */
395
396 /** @defgroup RTCEx_Tamper_Pull_UP_Definitions RTC Extended Tamper Pull UP Definitions
397   * @{
398   */
399 #define RTC_TAMPER_PULLUP_ENABLE  ((uint32_t)0x00000000)  /*!< Tamper pins are pre-charged before sampling */
400 #define RTC_TAMPER_PULLUP_DISABLE  RTC_TAMPCR_TAMPPUDIS   /*!< Tamper pins pre-charge is disabled          */
401
402 #define IS_RTC_TAMPER_PULLUP_STATE(__STATE__) (((__STATE__) == RTC_TAMPER_PULLUP_ENABLE) || \
403                                            ((__STATE__) == RTC_TAMPER_PULLUP_DISABLE))
404 /**
405   * @}
406   */
407
408 /** @defgroup RTCEx_Wakeup_Timer_Definitions RTC Extended Wakeup Timer Definitions
409   * @{
410   */
411 #define RTC_WAKEUPCLOCK_RTCCLK_DIV16        ((uint32_t)0x00000000)
412 #define RTC_WAKEUPCLOCK_RTCCLK_DIV8         RTC_CR_WUCKSEL_0
413 #define RTC_WAKEUPCLOCK_RTCCLK_DIV4         RTC_CR_WUCKSEL_1
414 #define RTC_WAKEUPCLOCK_RTCCLK_DIV2         ((uint32_t) (RTC_CR_WUCKSEL_0 | RTC_CR_WUCKSEL_1))
415 #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS      RTC_CR_WUCKSEL_2
416 #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS      ((uint32_t) (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_2))
417
418 #define IS_RTC_WAKEUP_CLOCK(__CLOCK__) (((__CLOCK__) == RTC_WAKEUPCLOCK_RTCCLK_DIV16)   || \
419                                     ((__CLOCK__) == RTC_WAKEUPCLOCK_RTCCLK_DIV8)    || \
420                                     ((__CLOCK__) == RTC_WAKEUPCLOCK_RTCCLK_DIV4)    || \
421                                     ((__CLOCK__) == RTC_WAKEUPCLOCK_RTCCLK_DIV2)    || \
422                                     ((__CLOCK__) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \
423                                     ((__CLOCK__) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS))
424
425 #define IS_RTC_WAKEUP_COUNTER(__COUNTER__)  ((__COUNTER__) <= RTC_WUTR_WUT)
426 /**
427   * @}
428   */
429
430 /** @defgroup RTCEx_Smooth_calib_period_Definitions RTC Extended Smooth calib period Definitions
431   * @{
432   */
433 #define RTC_SMOOTHCALIB_PERIOD_32SEC   ((uint32_t)0x00000000)  /*!< If RTCCLK = 32768 Hz, Smooth calibation
434                                                                     period is 32s,  else 2exp20 RTCCLK pulses */
435 #define RTC_SMOOTHCALIB_PERIOD_16SEC   RTC_CAL_CALW16          /*!< If RTCCLK = 32768 Hz, Smooth calibation
436                                                                     period is 16s, else 2exp19 RTCCLK pulses */
437 #define RTC_SMOOTHCALIB_PERIOD_8SEC    RTC_CAL_CALW8           /*!< If RTCCLK = 32768 Hz, Smooth calibation
438                                                                     period is 8s, else 2exp18 RTCCLK pulses */
439
440 #define IS_RTC_SMOOTH_CALIB_PERIOD(__PERIOD__) (((__PERIOD__) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \
441                                                 ((__PERIOD__) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \
442                                                 ((__PERIOD__) == RTC_SMOOTHCALIB_PERIOD_8SEC))
443 /**
444   * @}
445   */
446
447 /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions RTC Extended Smooth calib Plus pulses Definitions
448   * @{
449   */
450 #define RTC_SMOOTHCALIB_PLUSPULSES_SET    RTC_CAL_CALP            /*!< The number of RTCCLK pulses added
451                                                                        during a X -second window = Y - CALM[8:0]
452                                                                        with Y = 512, 256, 128 when X = 32, 16, 8 */
453 #define RTC_SMOOTHCALIB_PLUSPULSES_RESET  ((uint32_t)0x00000000)  /*!< The number of RTCCLK pulses subbstited
454                                                                        during a 32-second window = CALM[8:0] */
455
456 #define IS_RTC_SMOOTH_CALIB_PLUS(__PLUS__) (((__PLUS__) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \
457                                             ((__PLUS__) == RTC_SMOOTHCALIB_PLUSPULSES_RESET))
458 /**
459   * @}
460   */
461
462 /** @defgroup RTCEx_Smooth_calib_Minus_pulses_Definitions RTC Extended Smooth calib Minus pulses Definitions
463   * @{
464   */
465 #define  IS_RTC_SMOOTH_CALIB_MINUS(__VALUE__) ((__VALUE__) <= RTC_CAL_CALM)
466 /**
467   * @}
468   */
469
470 /** @defgroup RTCEx_Add_1_Second_Parameter_Definition RTC Extended Add 1 Second Parameter Definitions
471   * @{
472   */
473 #define RTC_SHIFTADD1S_RESET      ((uint32_t)0x00000000)
474 #define RTC_SHIFTADD1S_SET        RTC_SHIFTR_ADD1S
475
476 #define IS_RTC_SHIFT_ADD1S(__SEL__) (((__SEL__) == RTC_SHIFTADD1S_RESET) || \
477                                      ((__SEL__) == RTC_SHIFTADD1S_SET))
478 /**
479   * @}
480   */
481
482 /** @defgroup RTCEx_Substract_Fraction_Of_Second_Value RTC Extended Substract Fraction Of Second Value
483   * @{
484   */
485 #define IS_RTC_SHIFT_SUBFS(__FS__) ((__FS__) <= RTC_SHIFTR_SUBFS)
486 /**
487   * @}
488   */
489
490  /** @defgroup RTCEx_Calib_Output_selection_Definitions RTC Extended Calib Output selection Definitions
491   * @{
492   */
493 #define RTC_CALIBOUTPUT_512HZ            ((uint32_t)0x00000000)
494 #define RTC_CALIBOUTPUT_1HZ              RTC_CR_COSEL
495
496 #define IS_RTC_CALIB_OUTPUT(__OUTPUT__)  (((__OUTPUT__) == RTC_CALIBOUTPUT_512HZ) || \
497                                           ((__OUTPUT__) == RTC_CALIBOUTPUT_1HZ))
498 /**
499   * @}
500   */
501
502 /**
503   * @}
504   */
505
506 /* Exported macro ------------------------------------------------------------*/
507 /** @defgroup RTCEx_Exported_Macros RTC Extended Exported Macros
508   * @{
509   */
510
511 /**
512   * @brief  Enable the RTC WakeUp Timer peripheral.
513   * @param  __HANDLE__: specifies the RTC handle.
514   * @retval None
515   */
516 #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__)                      ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE))
517
518 /**
519   * @brief  Enable the RTC TimeStamp peripheral.
520   * @param  __HANDLE__: specifies the RTC handle.
521   * @retval None
522   */
523 #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__)                        ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE))
524
525 /**
526   * @brief  Disable the RTC WakeUp Timer peripheral.
527   * @param  __HANDLE__: specifies the RTC handle.
528   * @retval None
529   */
530 #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__)                     ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE))
531
532 /**
533   * @brief  Disable the RTC TimeStamp peripheral.
534   * @param  __HANDLE__: specifies the RTC handle.
535   * @retval None
536   */
537 #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__)                       ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE))
538
539 /**
540   * @brief  Enable the RTC calibration output.
541   * @param  __HANDLE__: specifies the RTC handle.
542   * @retval None
543   */
544 #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__)               ((__HANDLE__)->Instance->CR |= (RTC_CR_COE))
545
546 /**
547   * @brief  Disable the calibration output.
548   * @param  __HANDLE__: specifies the RTC handle.
549   * @retval None
550   */
551 #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__)              ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE))
552
553 /**
554   * @brief  Enable the clock reference detection.
555   * @param  __HANDLE__: specifies the RTC handle.
556   * @retval None
557   */
558 #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__)               ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON))
559
560 /**
561   * @brief  Disable the clock reference detection.
562   * @param  __HANDLE__: specifies the RTC handle.
563   * @retval None
564   */
565 #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__)              ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON))
566
567 /**
568   * @brief  Enable the RTC TimeStamp interrupt.
569   * @param  __HANDLE__: specifies the RTC handle.
570   * @param  __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled.
571   *         This parameter can be:
572   *            @arg RTC_IT_TS: TimeStamp interrupt
573   * @retval None
574   */
575 #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__)      ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
576
577 /**
578   * @brief  Enable the RTC WakeUpTimer interrupt.
579   * @param  __HANDLE__: specifies the RTC handle.
580   * @param  __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
581   *         This parameter can be:
582   *            @arg RTC_IT_WUT: WakeUpTimer A interrupt
583   * @retval None
584   */
585 #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__)    ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
586
587 /**
588   * @brief  Disable the RTC TimeStamp interrupt.
589   * @param  __HANDLE__: specifies the RTC handle.
590   * @param  __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled. 
591   *         This parameter can be:
592   *            @arg RTC_IT_TS: TimeStamp interrupt
593   * @retval None
594   */
595 #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__)     ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
596
597 /**
598   * @brief  Disable the RTC WakeUpTimer interrupt.
599   * @param  __HANDLE__: specifies the RTC handle.
600   * @param  __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
601   *         This parameter can be:
602   *            @arg RTC_IT_WUT: WakeUpTimer A interrupt
603   * @retval None
604   */
605 #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__)   ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
606
607 /**
608   * @brief  Check whether the specified RTC Tamper interrupt has occurred or not.
609   * @param  __HANDLE__: specifies the RTC handle.
610   * @param  __FLAG__: specifies the RTC Tamper interrupt sources to be enabled or disabled.
611   *         This parameter can be:
612   *            @arg  RTC_IT_TAMP1
613   * @retval None
614   */
615 #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __FLAG__)                 (((((__HANDLE__)->Instance->ISR) & ((__FLAG__)>> 4)) != RESET)? SET : RESET)
616
617 /**
618   * @brief  Check whether the specified RTC WakeUpTimer interrupt has occurred or not.
619   * @param  __HANDLE__: specifies the RTC handle.
620   * @param  __FLAG__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
621   *         This parameter can be:
622   *            @arg RTC_IT_WUT:  WakeUpTimer A interrupt
623   * @retval None
624   */
625 #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __FLAG__)            (((((__HANDLE__)->Instance->ISR) & ((__FLAG__)>> 4)) != RESET)? SET : RESET)
626
627 /**
628   * @brief  Check whether the specified RTC TimeStamp interrupt has occurred or not.
629   * @param  __HANDLE__: specifies the RTC handle.
630   * @param  __FLAG__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled.
631   *         This parameter can be:
632   *            @arg RTC_IT_TS: TimeStamp interrupt
633   * @retval None
634   */
635 #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __FLAG__)              (((((__HANDLE__)->Instance->ISR) & ((__FLAG__)>> 4)) != RESET)? SET : RESET)
636
637 /**
638   * @brief  Get the selected RTC TimeStamp's flag status.
639   * @param  __HANDLE__: specifies the RTC handle.
640   * @param  __FLAG__: specifies the RTC TimeStamp Flag sources to be enabled or disabled.
641   *         This parameter can be:
642   *            @arg RTC_FLAG_TSF
643   *            @arg RTC_FLAG_TSOVF
644   * @retval None
645   */
646 #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__)            (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
647
648 /**
649   * @brief  Get the selected RTC WakeUpTimer's flag status.
650   * @param  __HANDLE__: specifies the RTC handle.
651   * @param  __FLAG__: specifies the RTC WakeUpTimer Flag sources to be enabled or disabled.
652   *          This parameter can be:
653   *             @arg RTC_FLAG_WUTF
654   *             @arg RTC_FLAG_WUTWF
655   * @retval None
656   */
657 #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__)          (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
658
659 /**
660   * @brief  Get the selected RTC Tamper's flag status.
661   * @param  __HANDLE__: specifies the RTC handle.
662   * @param  __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled.
663   *          This parameter can be:
664   *             @arg RTC_FLAG_TAMP1F
665   * @retval None
666   */
667 #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__)               (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
668
669 /**
670   * @brief  Get the selected RTC shift operation's flag status.
671   * @param  __HANDLE__: specifies the RTC handle.
672   * @param  __FLAG__: specifies the RTC shift operation Flag is pending or not.
673   *          This parameter can be:
674   *             @arg RTC_FLAG_SHPF
675   * @retval None
676   */
677 #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__)                (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
678
679 /**
680   * @brief  Clear the RTC Time Stamp's pending flags.
681   * @param  __HANDLE__: specifies the RTC handle.
682   * @param  __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled.
683   *          This parameter can be:
684   *             @arg RTC_FLAG_TSF
685   * @retval None
686   */
687 #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__)          ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& RTC_FLAGS_MASK)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
688
689 /**
690   * @brief  Clear the RTC Tamper's pending flags.
691   * @param  __HANDLE__: specifies the RTC handle.
692   * @param  __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled.
693   *          This parameter can be:
694   *             @arg RTC_FLAG_TAMP1F
695   * @retval None
696   */
697 #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__)             ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& RTC_FLAGS_MASK)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
698
699 /**
700   * @brief  Clear the RTC Wake Up timer's pending flags.
701   * @param  __HANDLE__: specifies the RTC handle.
702   * @param  __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled.
703   *         This parameter can be:
704   *            @arg RTC_FLAG_WUTF
705   * @retval None
706   */
707 #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__)        ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& RTC_FLAGS_MASK)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
708
709 /* WAKE-UP TIMER EXTI */
710 /* ------------------ */
711 /**
712   * @brief  Enable interrupt on the RTC WakeUp Timer associated Exti line.
713   * @retval None
714   */
715 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT()       (EXTI->IMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
716
717 /**
718   * @brief  Disable interrupt on the RTC WakeUp Timer associated Exti line.
719   * @retval None
720   */
721 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT()      (EXTI->IMR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
722
723 /**
724   * @brief  Enable event on the RTC WakeUp Timer associated Exti line.
725   * @retval None.
726   */
727 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT()    (EXTI->EMR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
728
729 /**
730   * @brief  Disable event on the RTC WakeUp Timer associated Exti line.
731   * @retval None.
732   */
733 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVENT()   (EXTI->EMR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
734
735 /**
736   * @brief  Enable falling edge trigger on the RTC WakeUp Timer associated Exti line. 
737   * @retval None.
738   */
739 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE()   (EXTI->FTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
740
741 /**
742   * @brief  Disable falling edge trigger on the RTC WakeUp Timer associated Exti line.
743   * @retval None.
744   */
745 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE()  (EXTI->FTSR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
746
747 /**
748   * @brief  Enable rising edge trigger on the RTC WakeUp Timer associated Exti line.
749   * @retval None.
750   */
751 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE()    (EXTI->RTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
752
753 /**
754   * @brief  Disable rising edge trigger on the RTC WakeUp Timer associated Exti line.
755   * @retval None.
756   */
757 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE()   (EXTI->RTSR &= ~(RTC_EXTI_LINE_WAKEUPTIMER_EVENT))
758
759 /**
760   * @brief  Enable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line.
761   * @retval None.
762   */
763 #define __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_FALLING_EDGE() __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE();__HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLING_EDGE();
764
765 /**
766   * @brief  Disable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line.
767   * This parameter can be:
768   * @retval None.
769   */
770 #define __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_FALLING_EDGE() __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISING_EDGE();__HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLING_EDGE();
771
772 /**
773   * @brief Check whether the RTC WakeUp Timer associated Exti line interrupt flag is set or not.
774   * @retval Line Status.
775   */
776 #define __HAL_RTC_WAKEUPTIMER_EXTI_GET_FLAG()              (EXTI->PR & RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
777
778 /**
779   * @brief Clear the RTC WakeUp Timer associated Exti line flag.
780   * @retval None.
781   */
782 #define __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG()            (EXTI->PR = RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
783
784 /**
785   * @brief Generate a Software interrupt on the RTC WakeUp Timer associated Exti line.
786   * @retval None.
787   */
788 #define __HAL_RTC_WAKEUPTIMER_EXTI_GENERATE_SWIT()         (EXTI->SWIER |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
789
790
791 /* TAMPER TIMESTAMP EXTI */
792 /* --------------------- */
793 /**
794   * @brief  Enable interrupt on the RTC Tamper and Timestamp associated Exti line.
795   * @retval None
796   */
797 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT()        (EXTI->IMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
798
799 /**
800   * @brief  Disable interrupt on the RTC Tamper and Timestamp associated Exti line.
801   * @retval None
802   */
803 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_IT()       (EXTI->IMR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
804
805 /**
806   * @brief  Enable event on the RTC Tamper and Timestamp associated Exti line.
807   * @retval None.
808   */
809 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_EVENT()    (EXTI->EMR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
810
811 /**
812   * @brief  Disable event on the RTC Tamper and Timestamp associated Exti line.
813   * @retval None.
814   */
815 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_EVENT()   (EXTI->EMR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
816
817 /**
818   * @brief  Enable falling edge trigger on the RTC Tamper and Timestamp associated Exti line. 
819   * @retval None.
820   */
821 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE()   (EXTI->FTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
822
823 /**
824   * @brief  Disable falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
825   * @retval None.
826   */
827 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE()  (EXTI->FTSR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
828
829 /**
830   * @brief  Enable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
831   * @retval None.
832   */
833 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE()    (EXTI->RTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
834
835 /**
836   * @brief  Disable rising edge trigger on the RTC Tamper and Timestamp associated Exti line.
837   * @retval None.
838   */
839 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE()   (EXTI->RTSR &= ~(RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT))
840
841 /**
842   * @brief  Enable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
843   * @retval None.
844   */
845 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_FALLING_EDGE() __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE();__HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_FALLING_EDGE();
846
847 /**
848   * @brief  Disable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line.
849   * This parameter can be:
850   * @retval None.
851   */
852 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_FALLING_EDGE() __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_RISING_EDGE();__HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_FALLING_EDGE();
853
854 /**
855   * @brief Check whether the RTC Tamper and Timestamp associated Exti line interrupt flag is set or not.
856   * @retval Line Status.
857   */
858 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GET_FLAG()         (EXTI->PR & RTC_EXTI_LINE_WAKEUPTIMER_EVENT)
859
860 /**
861   * @brief Clear the RTC Tamper and Timestamp associated Exti line flag.
862   * @retval None.
863   */
864 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG()       (EXTI->PR = RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
865
866 /**
867   * @brief Generate a Software interrupt on the RTC Tamper and Timestamp associated Exti line
868   * @retval None.
869   */
870 #define __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GENERATE_SWIT()    (EXTI->SWIER |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT)
871
872
873 /**
874   * @}
875   */
876
877 /* Exported functions --------------------------------------------------------*/
878 /** @defgroup RTCEx_Exported_Functions RTC Extended Exported Functions
879   * @{
880   */
881
882 /** @defgroup RTCEx_Exported_Functions_Group1 Extended RTC TimeStamp and Tamper functions
883  * @{
884  */ 
885
886 /* RTC TimeStamp and Tamper functions *****************************************/
887 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
888 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
889 HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc);
890 HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format);
891
892 HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
893 HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
894 HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper);
895 void              HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc);
896
897 void              HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc);
898 void              HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc);
899
900 #if defined (STM32L083xx) || defined (STM32L082xx) || defined (STM32L081xx) || \
901     defined (STM32L073xx) || defined (STM32L072xx) || defined (STM32L071xx)
902
903 void              HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc);
904
905 #endif /* (STM32L083xx) || (STM32L082xx) || (STM32L081xx) ||
906         * (STM32L073xx) || (STM32L072xx) || (STM32L071xx)
907         */
908
909 void              HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc);
910 HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
911 HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
912 HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
913
914 #if defined (STM32L083xx) || defined (STM32L082xx) || defined (STM32L081xx) || \
915     defined (STM32L073xx) || defined (STM32L072xx) || defined (STM32L071xx)
916
917 HAL_StatusTypeDef HAL_RTCEx_PollForTamper3Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
918
919 #endif /* (STM32L083xx) || (STM32L082xx) || (STM32L081xx) ||
920     * (STM32L073xx) || (STM32L072xx) || (STM32L071xx)
921     */
922
923 /**
924   * @}
925   */
926
927 /** @defgroup RTCEx_Exported_Functions_Group2 Extended RTC Wake-up functions
928  * @{
929  */ 
930
931 /* RTC Wake-up functions ******************************************************/
932 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
933 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
934 uint32_t HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc);
935 uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc);
936 void              HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc);
937 void              HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc);
938 HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
939 /**
940   * @}
941   */
942
943 /** @defgroup RTCEx_Exported_Functions_Group3 Extended Peripheral Control functions
944  * @{
945  */ 
946
947 /* Extended Control functions ************************************************/
948 void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data);
949 uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister);
950
951 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmouthCalibMinusPulsesValue);
952 HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS);
953 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput);
954 HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc);
955 HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc);
956 HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc);
957 HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc);
958 HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc);
959 /**
960   * @}
961   */
962
963 /* Extended RTC features functions *******************************************/
964 /** @defgroup RTCEx_Exported_Functions_Group4 Extended features functions
965  * @{
966  */ 
967 void              HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc); 
968 HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
969
970 /**
971   * @}
972   */
973
974 /**
975   * @}
976   */
977
978 /**
979   * @}
980   */
981
982 /**
983   * @}
984   */
985
986 #ifdef __cplusplus
987 }
988 #endif
989
990 #endif /* __STM32L0xx_HAL_RTC_EX_H */
991
992 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
993