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