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