]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/stm32f4xx_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_STM32F4 / stm32f4xx_hal_rtc_ex.h
1 /**
2   ******************************************************************************
3   * @file    stm32f4xx_hal_rtc_ex.h
4   * @author  MCD Application Team
5   * @version V1.1.0
6   * @date    19-June-2014
7   * @brief   Header file of RTC HAL Extension module.
8   ******************************************************************************
9   * @attention
10   *
11   * <h2><center>&copy; COPYRIGHT(c) 2014 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 __STM32F4xx_HAL_RTC_EX_H
40 #define __STM32F4xx_HAL_RTC_EX_H
41
42 #ifdef __cplusplus
43  extern "C" {
44 #endif
45
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f4xx_hal_def.h"
48
49 /** @addtogroup STM32F4xx_HAL_Driver
50   * @{
51   */
52
53 /** @addtogroup RTCEx
54   * @{
55   */ 
56
57 /* Exported types ------------------------------------------------------------*/ 
58
59 /** 
60   * @brief  RTC Tamper structure definition  
61   */
62 typedef struct 
63 {
64   uint32_t Tamper;                      /*!< Specifies the Tamper Pin.
65                                              This parameter can be a value of @ref  RTCEx_Tamper_Pins_Definitions */
66   
67   uint32_t PinSelection;                /*!< Specifies the Tamper Pin.
68                                              This parameter can be a value of @ref  RTCEx_Tamper_Pins_Selection */                                        
69                                              
70   uint32_t Trigger;                     /*!< Specifies the Tamper Trigger.
71                                              This parameter can be a value of @ref  RTCEx_Tamper_Trigger_Definitions */
72
73   uint32_t Filter;                      /*!< Specifies the RTC Filter Tamper.
74                                              This parameter can be a value of @ref RTCEx_Tamper_Filter_Definitions */
75   
76   uint32_t SamplingFrequency;           /*!< Specifies the sampling frequency.
77                                              This parameter can be a value of @ref RTCEx_Tamper_Sampling_Frequencies_Definitions */
78                                       
79   uint32_t PrechargeDuration;           /*!< Specifies the Precharge Duration .
80                                              This parameter can be a value of @ref RTCEx_Tamper_Pin_Precharge_Duration_Definitions */ 
81  
82   uint32_t TamperPullUp;                /*!< Specifies the Tamper PullUp .
83                                              This parameter can be a value of @ref RTCEx_Tamper_Pull_UP_Definitions */           
84  
85   uint32_t TimeStampOnTamperDetection;  /*!< Specifies the TimeStampOnTamperDetection.
86                                              This parameter can be a value of @ref RTCEx_Tamper_TimeStampOnTamperDetection_Definitions */                      
87 }RTC_TamperTypeDef;
88
89 /* Exported constants --------------------------------------------------------*/
90 /** @defgroup RTCEx_Exported_Constants
91   * @{
92   */ 
93
94 /** @defgroup RTCEx_Backup_Registers_Definitions 
95   * @{
96   */
97 #define RTC_BKP_DR0                       ((uint32_t)0x00000000)
98 #define RTC_BKP_DR1                       ((uint32_t)0x00000001)
99 #define RTC_BKP_DR2                       ((uint32_t)0x00000002)
100 #define RTC_BKP_DR3                       ((uint32_t)0x00000003)
101 #define RTC_BKP_DR4                       ((uint32_t)0x00000004)
102 #define RTC_BKP_DR5                       ((uint32_t)0x00000005)
103 #define RTC_BKP_DR6                       ((uint32_t)0x00000006)
104 #define RTC_BKP_DR7                       ((uint32_t)0x00000007)
105 #define RTC_BKP_DR8                       ((uint32_t)0x00000008)
106 #define RTC_BKP_DR9                       ((uint32_t)0x00000009)
107 #define RTC_BKP_DR10                      ((uint32_t)0x0000000A)
108 #define RTC_BKP_DR11                      ((uint32_t)0x0000000B)
109 #define RTC_BKP_DR12                      ((uint32_t)0x0000000C)
110 #define RTC_BKP_DR13                      ((uint32_t)0x0000000D)
111 #define RTC_BKP_DR14                      ((uint32_t)0x0000000E)
112 #define RTC_BKP_DR15                      ((uint32_t)0x0000000F)
113 #define RTC_BKP_DR16                      ((uint32_t)0x00000010)
114 #define RTC_BKP_DR17                      ((uint32_t)0x00000011)
115 #define RTC_BKP_DR18                      ((uint32_t)0x00000012)
116 #define RTC_BKP_DR19                      ((uint32_t)0x00000013)
117
118 #define IS_RTC_BKP(BKP)                   (((BKP) == RTC_BKP_DR0)  || \
119                                            ((BKP) == RTC_BKP_DR1)  || \
120                                            ((BKP) == RTC_BKP_DR2)  || \
121                                            ((BKP) == RTC_BKP_DR3)  || \
122                                            ((BKP) == RTC_BKP_DR4)  || \
123                                            ((BKP) == RTC_BKP_DR5)  || \
124                                            ((BKP) == RTC_BKP_DR6)  || \
125                                            ((BKP) == RTC_BKP_DR7)  || \
126                                            ((BKP) == RTC_BKP_DR8)  || \
127                                            ((BKP) == RTC_BKP_DR9)  || \
128                                            ((BKP) == RTC_BKP_DR10) || \
129                                            ((BKP) == RTC_BKP_DR11) || \
130                                            ((BKP) == RTC_BKP_DR12) || \
131                                            ((BKP) == RTC_BKP_DR13) || \
132                                            ((BKP) == RTC_BKP_DR14) || \
133                                            ((BKP) == RTC_BKP_DR15) || \
134                                            ((BKP) == RTC_BKP_DR16) || \
135                                            ((BKP) == RTC_BKP_DR17) || \
136                                            ((BKP) == RTC_BKP_DR18) || \
137                                            ((BKP) == RTC_BKP_DR19))
138 /**
139   * @}
140   */ 
141
142 /** @defgroup RTCEx_Time_Stamp_Edges_definitions 
143   * @{
144   */ 
145 #define RTC_TIMESTAMPEDGE_RISING          ((uint32_t)0x00000000)
146 #define RTC_TIMESTAMPEDGE_FALLING         ((uint32_t)0x00000008)
147
148 #define IS_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TIMESTAMPEDGE_RISING) || \
149                                  ((EDGE) == RTC_TIMESTAMPEDGE_FALLING))
150 /**
151   * @}
152   */
153   
154 /** @defgroup RTCEx_Tamper_Pins_Definitions 
155   * @{
156   */ 
157 #define RTC_TAMPER_1                    RTC_TAFCR_TAMP1E
158 #define RTC_TAMPER_2                    RTC_TAFCR_TAMP2E
159
160 #define IS_TAMPER(TAMPER) ((((TAMPER) & (uint32_t)0xFFFFFFF6) == 0x00) && ((TAMPER) != (uint32_t)RESET))
161 /**
162   * @}
163   */
164
165 /** @defgroup RTCEx_Tamper_Pins_Selection 
166   * @{
167   */ 
168 #define RTC_TAMPERPIN_PC13                 ((uint32_t)0x00000000)
169 #define RTC_TAMPERPIN_PI8                  ((uint32_t)0x00010000)
170
171 #define IS_RTC_TAMPER_PIN(PIN) (((PIN) == RTC_TAMPERPIN_PC13) || \
172                                 ((PIN) == RTC_TAMPERPIN_PI8))
173 /**
174   * @}
175   */ 
176
177 /** @defgroup RTCEx_TimeStamp_Pin_Selection 
178   * @{
179   */ 
180 #define RTC_TIMESTAMPPIN_PC13              ((uint32_t)0x00000000)
181 #define RTC_TIMESTAMPPIN_PI8               ((uint32_t)0x00020000)
182
183 #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TIMESTAMPPIN_PC13) || \
184                                    ((PIN) == RTC_TIMESTAMPPIN_PI8))
185 /**
186   * @}
187   */ 
188
189 /** @defgroup RTCEx_Tamper_Trigger_Definitions 
190   * @{
191   */ 
192 #define RTC_TAMPERTRIGGER_RISINGEDGE       ((uint32_t)0x00000000)
193 #define RTC_TAMPERTRIGGER_FALLINGEDGE      ((uint32_t)0x00000002)
194 #define RTC_TAMPERTRIGGER_LOWLEVEL         RTC_TAMPERTRIGGER_RISINGEDGE
195 #define RTC_TAMPERTRIGGER_HIGHLEVEL        RTC_TAMPERTRIGGER_FALLINGEDGE
196
197 #define IS_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TAMPERTRIGGER_RISINGEDGE) || \
198                                         ((TRIGGER) == RTC_TAMPERTRIGGER_FALLINGEDGE) || \
199                                         ((TRIGGER) == RTC_TAMPERTRIGGER_LOWLEVEL) || \
200                                         ((TRIGGER) == RTC_TAMPERTRIGGER_HIGHLEVEL)) 
201
202 /**
203   * @}
204   */  
205
206 /** @defgroup RTCEx_Tamper_Filter_Definitions 
207   * @{
208   */ 
209 #define RTC_TAMPERFILTER_DISABLE   ((uint32_t)0x00000000)  /*!< Tamper filter is disabled */
210
211 #define RTC_TAMPERFILTER_2SAMPLE   ((uint32_t)0x00000800)  /*!< Tamper is activated after 2 
212                                                                 consecutive samples at the active level */
213 #define RTC_TAMPERFILTER_4SAMPLE   ((uint32_t)0x00001000)  /*!< Tamper is activated after 4 
214                                                                 consecutive samples at the active level */
215 #define RTC_TAMPERFILTER_8SAMPLE   ((uint32_t)0x00001800)  /*!< Tamper is activated after 8 
216                                                                 consecutive samples at the active leve. */
217
218 #define IS_TAMPER_FILTER(FILTER)  (((FILTER) == RTC_TAMPERFILTER_DISABLE) || \
219                                    ((FILTER) == RTC_TAMPERFILTER_2SAMPLE) || \
220                                    ((FILTER) == RTC_TAMPERFILTER_4SAMPLE) || \
221                                    ((FILTER) == RTC_TAMPERFILTER_8SAMPLE))
222 /**
223   * @}
224   */
225
226 /** @defgroup RTCEx_Tamper_Sampling_Frequencies_Definitions 
227   * @{
228   */ 
229 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768  ((uint32_t)0x00000000)  /*!< Each of the tamper inputs are sampled
230                                                                              with a frequency =  RTCCLK / 32768 */
231 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384  ((uint32_t)0x00000100)  /*!< Each of the tamper inputs are sampled
232                                                                              with a frequency =  RTCCLK / 16384 */
233 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192   ((uint32_t)0x00000200)  /*!< Each of the tamper inputs are sampled
234                                                                              with a frequency =  RTCCLK / 8192  */
235 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096   ((uint32_t)0x00000300)  /*!< Each of the tamper inputs are sampled
236                                                                              with a frequency =  RTCCLK / 4096  */
237 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048   ((uint32_t)0x00000400)  /*!< Each of the tamper inputs are sampled
238                                                                              with a frequency =  RTCCLK / 2048  */
239 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024   ((uint32_t)0x00000500)  /*!< Each of the tamper inputs are sampled
240                                                                              with a frequency =  RTCCLK / 1024  */
241 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512    ((uint32_t)0x00000600)  /*!< Each of the tamper inputs are sampled
242                                                                              with a frequency =  RTCCLK / 512   */
243 #define RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256    ((uint32_t)0x00000700)  /*!< Each of the tamper inputs are sampled
244                                                                              with a frequency =  RTCCLK / 256   */
245
246 #define IS_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768)|| \
247                                        ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384)|| \
248                                        ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192) || \
249                                        ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096) || \
250                                        ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048) || \
251                                        ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024) || \
252                                        ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV512)  || \
253                                        ((FREQ) == RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256))
254 /**
255   * @}
256   */
257
258 /** @defgroup RTCEx_Tamper_Pin_Precharge_Duration_Definitions 
259   * @{
260   */ 
261 #define RTC_TAMPERPRECHARGEDURATION_1RTCCLK ((uint32_t)0x00000000)  /*!< Tamper pins are pre-charged before 
262                                                                          sampling during 1 RTCCLK cycle */
263 #define RTC_TAMPERPRECHARGEDURATION_2RTCCLK ((uint32_t)0x00002000)  /*!< Tamper pins are pre-charged before 
264                                                                          sampling during 2 RTCCLK cycles */
265 #define RTC_TAMPERPRECHARGEDURATION_4RTCCLK ((uint32_t)0x00004000)  /*!< Tamper pins are pre-charged before 
266                                                                          sampling during 4 RTCCLK cycles */
267 #define RTC_TAMPERPRECHARGEDURATION_8RTCCLK ((uint32_t)0x00006000)  /*!< Tamper pins are pre-charged before 
268                                                                          sampling during 8 RTCCLK cycles */
269
270 #define IS_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TAMPERPRECHARGEDURATION_1RTCCLK) || \
271                                                 ((DURATION) == RTC_TAMPERPRECHARGEDURATION_2RTCCLK) || \
272                                                 ((DURATION) == RTC_TAMPERPRECHARGEDURATION_4RTCCLK) || \
273                                                 ((DURATION) == RTC_TAMPERPRECHARGEDURATION_8RTCCLK))
274 /**
275   * @}
276   */
277   
278 /** @defgroup RTCEx_Tamper_TimeStampOnTamperDetection_Definitions 
279   * @{
280   */ 
281 #define RTC_TIMESTAMPONTAMPERDETECTION_ENABLE  ((uint32_t)RTC_TAFCR_TAMPTS)  /*!< TimeStamp on Tamper Detection event saved        */
282 #define RTC_TIMESTAMPONTAMPERDETECTION_DISABLE ((uint32_t)0x00000000)        /*!< TimeStamp on Tamper Detection event is not saved */
283                                                                          
284 #define IS_TAMPER_TIMESTAMPONTAMPER_DETECTION(DETECTION) (((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_ENABLE) || \
285                                                           ((DETECTION) == RTC_TIMESTAMPONTAMPERDETECTION_DISABLE))
286 /**
287   * @}
288   */
289   
290 /** @defgroup  RTCEx_Tamper_Pull_UP_Definitions
291   * @{
292   */ 
293 #define RTC_TAMPER_PULLUP_ENABLE  ((uint32_t)0x00000000)            /*!< TimeStamp on Tamper Detection event saved        */
294 #define RTC_TAMPER_PULLUP_DISABLE ((uint32_t)RTC_TAFCR_TAMPPUDIS)   /*!< TimeStamp on Tamper Detection event is not saved */
295                                                                          
296 #define IS_TAMPER_PULLUP_STATE(STATE) (((STATE) == RTC_TAMPER_PULLUP_ENABLE) || \
297                                        ((STATE) == RTC_TAMPER_PULLUP_DISABLE))
298 /**
299   * @}
300   */
301
302 /** @defgroup RTCEx_Wakeup_Timer_Definitions 
303   * @{
304   */ 
305 #define RTC_WAKEUPCLOCK_RTCCLK_DIV16        ((uint32_t)0x00000000)
306 #define RTC_WAKEUPCLOCK_RTCCLK_DIV8         ((uint32_t)0x00000001)
307 #define RTC_WAKEUPCLOCK_RTCCLK_DIV4         ((uint32_t)0x00000002)
308 #define RTC_WAKEUPCLOCK_RTCCLK_DIV2         ((uint32_t)0x00000003)
309 #define RTC_WAKEUPCLOCK_CK_SPRE_16BITS      ((uint32_t)0x00000004)
310 #define RTC_WAKEUPCLOCK_CK_SPRE_17BITS      ((uint32_t)0x00000006)
311
312 #define IS_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV16)       || \
313                                     ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV8)    || \
314                                     ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV4)    || \
315                                     ((CLOCK) == RTC_WAKEUPCLOCK_RTCCLK_DIV2)    || \
316                                     ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_16BITS) || \
317                                     ((CLOCK) == RTC_WAKEUPCLOCK_CK_SPRE_17BITS))
318
319 #define IS_WAKEUP_COUNTER(COUNTER)  ((COUNTER) <= 0xFFFF)
320 /**
321   * @}
322   */ 
323
324 /** @defgroup RTCEx_Digital_Calibration_Definitions 
325   * @{
326   */ 
327 #define RTC_CALIBSIGN_POSITIVE            ((uint32_t)0x00000000) 
328 #define RTC_CALIBSIGN_NEGATIVE            ((uint32_t)0x00000080)
329
330 #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CALIBSIGN_POSITIVE) || \
331                                  ((SIGN) == RTC_CALIBSIGN_NEGATIVE))
332
333 #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20)
334 /**
335   * @}
336   */
337
338 /** @defgroup RTCEx_Smooth_calib_period_Definitions 
339   * @{
340   */ 
341 #define RTC_SMOOTHCALIB_PERIOD_32SEC   ((uint32_t)0x00000000)  /*!< If RTCCLK = 32768 Hz, Smooth calibation
342                                                                     period is 32s,  else 2exp20 RTCCLK seconds */
343 #define RTC_SMOOTHCALIB_PERIOD_16SEC   ((uint32_t)0x00002000)  /*!< If RTCCLK = 32768 Hz, Smooth calibation 
344                                                                     period is 16s, else 2exp19 RTCCLK seconds */
345 #define RTC_SMOOTHCALIB_PERIOD_8SEC    ((uint32_t)0x00004000)  /*!< If RTCCLK = 32768 Hz, Smooth calibation 
346                                                                     period is 8s, else 2exp18 RTCCLK seconds */
347
348 #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SMOOTHCALIB_PERIOD_32SEC) || \
349                                             ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_16SEC) || \
350                                             ((PERIOD) == RTC_SMOOTHCALIB_PERIOD_8SEC))                                         
351 /**
352   * @}
353   */ 
354
355 /** @defgroup RTCEx_Smooth_calib_Plus_pulses_Definitions 
356   * @{
357   */ 
358 #define RTC_SMOOTHCALIB_PLUSPULSES_SET    ((uint32_t)0x00008000)  /*!< The number of RTCCLK pulses added  
359                                                                        during a X -second window = Y - CALM[8:0] 
360                                                                        with Y = 512, 256, 128 when X = 32, 16, 8 */
361 #define RTC_SMOOTHCALIB_PLUSPULSES_RESET  ((uint32_t)0x00000000)  /*!< The number of RTCCLK pulses subbstited
362                                                                        during a 32-second window = CALM[8:0] */
363
364 #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_SET) || \
365                                         ((PLUS) == RTC_SMOOTHCALIB_PLUSPULSES_RESET))
366 /**
367   * @}
368   */ 
369
370 /** @defgroup RTCEx_Smooth_calib_Minus_pulses_Definitions 
371   * @{
372   */ 
373 #define  IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= 0x000001FF)
374 /**
375   * @}
376   */
377
378 /** @defgroup RTCEx_Add_1_Second_Parameter_Definitions
379   * @{
380   */ 
381 #define RTC_SHIFTADD1S_RESET      ((uint32_t)0x00000000)
382 #define RTC_SHIFTADD1S_SET        ((uint32_t)0x80000000)
383
384 #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_SHIFTADD1S_RESET) || \
385                                  ((SEL) == RTC_SHIFTADD1S_SET))
386 /**
387   * @}
388   */ 
389
390 /** @defgroup RTCEx_Substract_Fraction_Of_Second_Value
391   * @{
392   */ 
393 #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= 0x00007FFF)
394 /**
395   * @}
396   */
397
398  /** @defgroup RTCEx_Calib_Output_selection_Definitions 
399   * @{
400   */ 
401 #define RTC_CALIBOUTPUT_512HZ            ((uint32_t)0x00000000) 
402 #define RTC_CALIBOUTPUT_1HZ              ((uint32_t)0x00080000)
403
404 #define IS_RTC_CALIB_OUTPUT(OUTPUT)  (((OUTPUT) == RTC_CALIBOUTPUT_512HZ) || \
405                                       ((OUTPUT) == RTC_CALIBOUTPUT_1HZ))
406 /**
407   * @}
408   */ 
409
410 /**
411   * @}
412   */ 
413   
414 /* Exported macro ------------------------------------------------------------*/
415
416 /**
417   * @brief  Enable the RTC WakeUp Timer peripheral.
418   * @param  __HANDLE__: specifies the RTC handle.
419   * @retval None
420   */
421 #define __HAL_RTC_WAKEUPTIMER_ENABLE(__HANDLE__)                      ((__HANDLE__)->Instance->CR |= (RTC_CR_WUTE))
422
423 /**
424   * @brief  Enable the RTC TimeStamp peripheral.
425   * @param  __HANDLE__: specifies the RTC handle.
426   * @retval None
427   */
428 #define __HAL_RTC_TIMESTAMP_ENABLE(__HANDLE__)                        ((__HANDLE__)->Instance->CR |= (RTC_CR_TSE))
429
430 /**
431   * @brief  Disable the RTC WakeUp Timer peripheral.
432   * @param  __HANDLE__: specifies the RTC handle.
433   * @retval None
434   */
435 #define __HAL_RTC_WAKEUPTIMER_DISABLE(__HANDLE__)                     ((__HANDLE__)->Instance->CR &= ~(RTC_CR_WUTE))
436
437 /**
438   * @brief  Disable the RTC TimeStamp peripheral.
439   * @param  __HANDLE__: specifies the RTC handle.
440   * @retval None
441   */
442 #define __HAL_RTC_TIMESTAMP_DISABLE(__HANDLE__)                       ((__HANDLE__)->Instance->CR &= ~(RTC_CR_TSE))
443
444 /**
445   * @brief  Enable the Coarse calibration process.
446   * @param  __HANDLE__: specifies the RTC handle.
447   * @retval None
448   */
449 #define __HAL_RTC_COARSE_CALIB_ENABLE(__HANDLE__)                       ((__HANDLE__)->Instance->CR |= (RTC_CR_DCE))
450
451 /**
452   * @brief  Disable the Coarse calibration process.
453   * @param  __HANDLE__: specifies the RTC handle.
454   * @retval None
455   */
456 #define __HAL_RTC_COARSE_CALIB_DISABLE(__HANDLE__)                      ((__HANDLE__)->Instance->CR &= ~(RTC_CR_DCE))
457
458 /**
459   * @brief  Enable the RTC calibration output.
460   * @param  __HANDLE__: specifies the RTC handle.
461   * @retval None
462   */
463 #define __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(__HANDLE__)                 ((__HANDLE__)->Instance->CR |= (RTC_CR_COE))
464
465 /**
466   * @brief  Disable the calibration output.
467   * @param  __HANDLE__: specifies the RTC handle.
468   * @retval None
469   */
470 #define __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(__HANDLE__)                ((__HANDLE__)->Instance->CR &= ~(RTC_CR_COE))
471
472 /**
473   * @brief  Enable the clock reference detection.
474   * @param  __HANDLE__: specifies the RTC handle.
475   * @retval None
476   */
477 #define __HAL_RTC_CLOCKREF_DETECTION_ENABLE(__HANDLE__)                 ((__HANDLE__)->Instance->CR |= (RTC_CR_REFCKON))
478
479 /**
480   * @brief  Disable the clock reference detection.
481   * @param  __HANDLE__: specifies the RTC handle.
482   * @retval None
483   */
484 #define __HAL_RTC_CLOCKREF_DETECTION_DISABLE(__HANDLE__)                ((__HANDLE__)->Instance->CR &= ~(RTC_CR_REFCKON))
485
486 /**
487   * @brief  Enable the RTC TimeStamp interrupt.
488   * @param  __HANDLE__: specifies the RTC handle.
489   * @param  __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled. 
490   *         This parameter can be:
491   *            @arg RTC_IT_TS: TimeStamp interrupt
492   * @retval None
493   */
494 #define __HAL_RTC_TIMESTAMP_ENABLE_IT(__HANDLE__, __INTERRUPT__)      ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
495
496 /**
497   * @brief  Enable the RTC WakeUpTimer interrupt.
498   * @param  __HANDLE__: specifies the RTC handle.
499   * @param  __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled. 
500   *         This parameter can be:
501   *            @arg RTC_IT_WUT: WakeUpTimer A interrupt
502   * @retval None
503   */
504 #define __HAL_RTC_WAKEUPTIMER_ENABLE_IT(__HANDLE__, __INTERRUPT__)    ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
505
506 /**
507   * @brief  Disable the RTC TimeStamp interrupt.
508   * @param  __HANDLE__: specifies the RTC handle.
509   * @param  __INTERRUPT__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled. 
510   *         This parameter can be:
511   *            @arg RTC_IT_TS: TimeStamp interrupt
512   * @retval None
513   */
514 #define __HAL_RTC_TIMESTAMP_DISABLE_IT(__HANDLE__, __INTERRUPT__)     ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
515
516 /**
517   * @brief  Disable the RTC WakeUpTimer interrupt.
518   * @param  __HANDLE__: specifies the RTC handle.
519   * @param  __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled. 
520   *         This parameter can be:
521   *            @arg RTC_IT_WUT: WakeUpTimer A interrupt
522   * @retval None
523   */
524 #define __HAL_RTC_WAKEUPTIMER_DISABLE_IT(__HANDLE__, __INTERRUPT__)   ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
525
526 /**
527   * @brief  Check whether the specified RTC Tamper interrupt has occurred or not.
528   * @param  __HANDLE__: specifies the RTC handle.
529   * @param  __FLAG__: specifies the RTC Tamper interrupt sources to be enabled or disabled.
530   *         This parameter can be:
531   *            @arg  RTC_IT_TAMP1  
532   * @retval None
533   */
534 #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __FLAG__)                 (((((__HANDLE__)->Instance->ISR) & ((__FLAG__)>> 4)) != RESET)? SET : RESET)
535
536 /**
537   * @brief  Check whether the specified RTC WakeUpTimer interrupt has occurred or not.
538   * @param  __HANDLE__: specifies the RTC handle.
539   * @param  __FLAG__: specifies the RTC WakeUpTimer interrupt sources to be enabled or disabled.
540   *         This parameter can be:
541   *            @arg RTC_IT_WUT:  WakeUpTimer A interrupt
542   * @retval None
543   */
544 #define __HAL_RTC_WAKEUPTIMER_GET_IT(__HANDLE__, __FLAG__)            (((((__HANDLE__)->Instance->ISR) & ((__FLAG__)>> 4)) != RESET)? SET : RESET)
545
546 /**
547   * @brief  Check whether the specified RTC TimeStamp interrupt has occurred or not.
548   * @param  __HANDLE__: specifies the RTC handle.
549   * @param  __FLAG__: specifies the RTC TimeStamp interrupt sources to be enabled or disabled.
550   *         This parameter can be:
551   *            @arg RTC_IT_TS: TimeStamp interrupt
552   * @retval None
553   */
554 #define __HAL_RTC_TIMESTAMP_GET_IT(__HANDLE__, __FLAG__)              (((((__HANDLE__)->Instance->ISR) & ((__FLAG__)>> 4)) != RESET)? SET : RESET)
555
556 /**
557   * @brief  Get the selected RTC TimeStamp's flag status.
558   * @param  __HANDLE__: specifies the RTC handle.
559   * @param  __FLAG__: specifies the RTC TimeStamp Flag sources to be enabled or disabled.
560   *         This parameter can be:
561   *            @arg RTC_FLAG_TSF   
562   *            @arg RTC_FLAG_TSOVF     
563   * @retval None
564   */
565 #define __HAL_RTC_TIMESTAMP_GET_FLAG(__HANDLE__, __FLAG__)            (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
566
567 /**
568   * @brief  Get the selected RTC WakeUpTimer's flag status.
569   * @param  __HANDLE__: specifies the RTC handle.
570   * @param  __FLAG__: specifies the RTC WakeUpTimer Flag sources to be enabled or disabled.
571   *          This parameter can be:
572   *             @arg RTC_FLAG_WUTF   
573   *             @arg RTC_FLAG_WUTWF     
574   * @retval None
575   */
576 #define __HAL_RTC_WAKEUPTIMER_GET_FLAG(__HANDLE__, __FLAG__)          (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
577
578 /**
579   * @brief  Get the selected RTC Tamper's flag status.
580   * @param  __HANDLE__: specifies the RTC handle.
581   * @param  __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled.
582   *          This parameter can be:
583   *             @arg RTC_FLAG_TAMP1F      
584   * @retval None
585   */
586 #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__)               (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
587
588 /**
589   * @brief  Get the selected RTC shift operation's flag status.
590   * @param  __HANDLE__: specifies the RTC handle.
591   * @param  __FLAG__: specifies the RTC shift operation Flag is pending or not.
592   *          This parameter can be:
593   *             @arg RTC_FLAG_SHPF   
594   * @retval None
595   */
596 #define __HAL_RTC_SHIFT_GET_FLAG(__HANDLE__, __FLAG__)                (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
597
598 /**
599   * @brief  Clear the RTC Time Stamp's pending flags.
600   * @param  __HANDLE__: specifies the RTC handle.
601   * @param  __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled.
602   *          This parameter can be:
603   *             @arg RTC_FLAG_TSF  
604   * @retval None
605   */
606 #define __HAL_RTC_TIMESTAMP_CLEAR_FLAG(__HANDLE__, __FLAG__)              ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& 0x0000FFFF)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
607
608 /**
609   * @brief  Clear the RTC Tamper's pending flags.
610   * @param  __HANDLE__: specifies the RTC handle.
611   * @param  __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled.
612   *          This parameter can be:
613   *             @arg RTC_FLAG_TAMP1F  
614   * @retval None
615   */
616 #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__)                 ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& 0x0000FFFF)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
617
618 /**
619   * @brief  Clear the RTC Wake Up timer's pending flags.
620   * @param  __HANDLE__: specifies the RTC handle.
621   * @param  __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled.
622   *         This parameter can be:
623   *            @arg RTC_FLAG_WUTF   
624   * @retval None
625   */
626 #define __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(__HANDLE__, __FLAG__)            ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& 0x0000FFFF)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)) 
627
628 /* Exported functions --------------------------------------------------------*/
629
630 /* RTC TimeStamp and Tamper functions *****************************************/
631 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
632 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);
633 HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc);
634 HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format);
635
636 HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
637 HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
638 HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper);
639 void              HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc);
640
641 void       HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc);
642 void       HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc);
643 void       HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc);
644 HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
645 HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
646 HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
647
648 /* RTC Wake-up functions ******************************************************/
649 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
650 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock);
651 uint32_t          HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc);
652 uint32_t          HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc);
653 void              HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc);
654 void       HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc);
655 HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
656
657 /* Extension Control functions ************************************************/
658 void              HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data);
659 uint32_t          HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister);
660
661 HAL_StatusTypeDef HAL_RTCEx_SetCoarseCalib(RTC_HandleTypeDef *hrtc, uint32_t CalibSign, uint32_t Value);
662 HAL_StatusTypeDef HAL_RTCEx_DeactivateCoarseCalib(RTC_HandleTypeDef *hrtc);
663 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmouthCalibMinusPulsesValue);
664 HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS);
665 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput);
666 HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc);
667 HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc);
668 HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc);
669 HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc);
670 HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc);
671
672 /* Extension RTC features functions *******************************************/
673 void       HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc); 
674 HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
675
676
677 /**
678   * @}
679   */ 
680
681 /**
682   * @}
683   */ 
684   
685 #ifdef __cplusplus
686 }
687 #endif
688
689 #endif /* __STM32F4xx_HAL_RTC_EX_H */
690
691 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/