]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F1/stm32f1xx_hal_rtc_ex.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F1 / stm32f1xx_hal_rtc_ex.h
1 /**
2 ******************************************************************************
3 * @file stm32f1xx_hal_rtc_ex.h
4 * @author MCD Application Team
5 * @version V1.0.0
6 * @date 15-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 __STM32F1xx_HAL_RTC_EX_H
40 #define __STM32F1xx_HAL_RTC_EX_H
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f1xx_hal_def.h"
48
49 /** @addtogroup STM32F1xx_HAL_Driver
50 * @{
51 */
52
53 /** @addtogroup RTCEx
54 * @{
55 */
56
57 /** @addtogroup RTCEx_Private_Macros
58 * @{
59 */
60
61 /** @defgroup RTCEx_Alias_For_Legacy Alias define maintained for legacy
62 * @{
63 */
64 #define HAL_RTCEx_TamperTimeStampIRQHandler HAL_RTCEx_TamperIRQHandler
65
66 /**
67 * @}
68 */
69
70 /** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters
71 * @{
72 */
73 #define IS_RTC_TAMPER(__TAMPER__) ((__TAMPER__) == RTC_TAMPER_1)
74
75 #define IS_RTC_TAMPER_TRIGGER(__TRIGGER__) (((__TRIGGER__) == RTC_TAMPERTRIGGER_LOWLEVEL) || \
76 ((__TRIGGER__) == RTC_TAMPERTRIGGER_HIGHLEVEL))
77
78 #if RTC_BKP_NUMBER > 10
79 #define IS_RTC_BKP(BKP) (((BKP) <= (uint32_t) RTC_BKP_DR10) || (((BKP) >= (uint32_t) RTC_BKP_DR11) && ((BKP) <= (uint32_t) RTC_BKP_DR42)))
80 #else
81 #define IS_RTC_BKP(BKP) ((BKP) <= (uint32_t) RTC_BKP_NUMBER)
82 #endif
83 #define IS_RTC_SMOOTH_CALIB_MINUS(__VALUE__) ((__VALUE__) <= 0x0000007F)
84
85 /**
86 * @}
87 */
88
89 /**
90 * @}
91 */
92
93 /* Exported types ------------------------------------------------------------*/
94 /** @defgroup RTCEx_Exported_Types RTCEx Exported Types
95 * @{
96 */
97 /**
98 * @brief RTC Tamper structure definition
99 */
100 typedef struct
101 {
102 uint32_t Tamper; /*!< Specifies the Tamper Pin.
103 This parameter can be a value of @ref RTCEx_Tamper_Pins_Definitions */
104
105 uint32_t Trigger; /*!< Specifies the Tamper Trigger.
106 This parameter can be a value of @ref RTCEx_Tamper_Trigger_Definitions */
107
108 }RTC_TamperTypeDef;
109
110 /**
111 * @}
112 */
113
114 /* Exported constants --------------------------------------------------------*/
115 /** @defgroup RTCEx_Exported_Constants RTCEx Exported Constants
116 * @{
117 */
118
119 /** @defgroup RTCEx_Tamper_Pins_Definitions Tamper Pins Definitions
120 * @{
121 */
122 #define RTC_TAMPER_1 BKP_CR_TPE /*!< Select tamper to be enabled (mainly for legacy purposes) */
123
124 /**
125 * @}
126 */
127
128 /** @defgroup RTCEx_Tamper_Trigger_Definitions Tamper Trigger Definitions
129 * @{
130 */
131 #define RTC_TAMPERTRIGGER_LOWLEVEL BKP_CR_TPAL /*!< A high level on the TAMPER pin resets all data backup registers (if TPE bit is set) */
132 #define RTC_TAMPERTRIGGER_HIGHLEVEL ((uint32_t)0x00000000) /*!< A low level on the TAMPER pin resets all data backup registers (if TPE bit is set) */
133
134 /**
135 * @}
136 */
137
138 /** @defgroup RTCEx_Backup_Registers_Definitions Backup Registers Definitions
139 * @{
140 */
141 #if RTC_BKP_NUMBER > 0
142 #define RTC_BKP_DR1 ((uint32_t)0x00000001)
143 #define RTC_BKP_DR2 ((uint32_t)0x00000002)
144 #define RTC_BKP_DR3 ((uint32_t)0x00000003)
145 #define RTC_BKP_DR4 ((uint32_t)0x00000004)
146 #define RTC_BKP_DR5 ((uint32_t)0x00000005)
147 #define RTC_BKP_DR6 ((uint32_t)0x00000006)
148 #define RTC_BKP_DR7 ((uint32_t)0x00000007)
149 #define RTC_BKP_DR8 ((uint32_t)0x00000008)
150 #define RTC_BKP_DR9 ((uint32_t)0x00000009)
151 #define RTC_BKP_DR10 ((uint32_t)0x0000000A)
152 #endif /* RTC_BKP_NUMBER > 0 */
153
154 #if RTC_BKP_NUMBER > 10
155 #define RTC_BKP_DR11 ((uint32_t)0x00000010)
156 #define RTC_BKP_DR12 ((uint32_t)0x00000011)
157 #define RTC_BKP_DR13 ((uint32_t)0x00000012)
158 #define RTC_BKP_DR14 ((uint32_t)0x00000013)
159 #define RTC_BKP_DR15 ((uint32_t)0x00000014)
160 #define RTC_BKP_DR16 ((uint32_t)0x00000015)
161 #define RTC_BKP_DR17 ((uint32_t)0x00000016)
162 #define RTC_BKP_DR18 ((uint32_t)0x00000017)
163 #define RTC_BKP_DR19 ((uint32_t)0x00000018)
164 #define RTC_BKP_DR20 ((uint32_t)0x00000019)
165 #define RTC_BKP_DR21 ((uint32_t)0x0000001A)
166 #define RTC_BKP_DR22 ((uint32_t)0x0000001B)
167 #define RTC_BKP_DR23 ((uint32_t)0x0000001C)
168 #define RTC_BKP_DR24 ((uint32_t)0x0000001D)
169 #define RTC_BKP_DR25 ((uint32_t)0x0000001E)
170 #define RTC_BKP_DR26 ((uint32_t)0x0000001F)
171 #define RTC_BKP_DR27 ((uint32_t)0x00000020)
172 #define RTC_BKP_DR28 ((uint32_t)0x00000021)
173 #define RTC_BKP_DR29 ((uint32_t)0x00000022)
174 #define RTC_BKP_DR30 ((uint32_t)0x00000023)
175 #define RTC_BKP_DR31 ((uint32_t)0x00000024)
176 #define RTC_BKP_DR32 ((uint32_t)0x00000025)
177 #define RTC_BKP_DR33 ((uint32_t)0x00000026)
178 #define RTC_BKP_DR34 ((uint32_t)0x00000027)
179 #define RTC_BKP_DR35 ((uint32_t)0x00000028)
180 #define RTC_BKP_DR36 ((uint32_t)0x00000029)
181 #define RTC_BKP_DR37 ((uint32_t)0x0000002A)
182 #define RTC_BKP_DR38 ((uint32_t)0x0000002B)
183 #define RTC_BKP_DR39 ((uint32_t)0x0000002C)
184 #define RTC_BKP_DR40 ((uint32_t)0x0000002D)
185 #define RTC_BKP_DR41 ((uint32_t)0x0000002E)
186 #define RTC_BKP_DR42 ((uint32_t)0x0000002F)
187 #endif /* RTC_BKP_NUMBER > 10 */
188
189 /**
190 * @}
191 */
192
193 /**
194 * @}
195 */
196
197 /* Exported macro ------------------------------------------------------------*/
198 /** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros
199 * @{
200 */
201
202 /**
203 * @brief Enable the RTC Tamper interrupt.
204 * @param __HANDLE__: specifies the RTC handle.
205 * @param __INTERRUPT__: specifies the RTC Tamper interrupt sources to be enabled
206 * This parameter can be any combination of the following values:
207 * @arg RTC_IT_TAMP1: Tamper A interrupt
208 * @retval None
209 */
210 #define __HAL_RTC_TAMPER_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT(BKP->CSR, (__INTERRUPT__))
211
212 /**
213 * @brief Disable the RTC Tamper interrupt.
214 * @param __HANDLE__: specifies the RTC handle.
215 * @param __INTERRUPT__: specifies the RTC Tamper interrupt sources to be disabled.
216 * This parameter can be any combination of the following values:
217 * @arg RTC_IT_TAMP1: Tamper A interrupt
218 * @retval None
219 */
220 #define __HAL_RTC_TAMPER_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT(BKP->CSR, (__INTERRUPT__))
221
222 /**
223 * @brief Check whether the specified RTC Tamper interrupt has been enabled or not.
224 * @param __HANDLE__: specifies the RTC handle.
225 * @param __INTERRUPT__: specifies the RTC Tamper interrupt sources to be checked.
226 * This parameter can be:
227 * @arg RTC_IT_TAMP1
228 * @retval None
229 */
230 #define __HAL_RTC_TAMPER_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((BKP->CSR) & ((__INTERRUPT__))) != RESET)? SET : RESET)
231
232 /**
233 * @brief Get the selected RTC Tamper's flag status.
234 * @param __HANDLE__: specifies the RTC handle.
235 * @param __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled.
236 * This parameter can be:
237 * @arg RTC_FLAG_TAMP1F
238 * @retval None
239 */
240 #define __HAL_RTC_TAMPER_GET_FLAG(__HANDLE__, __FLAG__) ((((BKP->CSR) & (__FLAG__)) != RESET)? SET : RESET)
241
242 /**
243 * @brief Get the selected RTC Tamper's flag status.
244 * @param __HANDLE__: specifies the RTC handle.
245 * @param __INTERRUPT__: specifies the RTC Tamper interrupt sources to be checked.
246 * This parameter can be:
247 * @arg RTC_IT_TAMP1
248 * @retval None
249 */
250 #define __HAL_RTC_TAMPER_GET_IT(__HANDLE__, __INTERRUPT__) ((((BKP->CSR) & (BKP_CSR_TEF)) != RESET)? SET : RESET)
251
252 /**
253 * @brief Clear the RTC Tamper's pending flags.
254 * @param __HANDLE__: specifies the RTC handle.
255 * @param __FLAG__: specifies the RTC Tamper Flag sources to be enabled or disabled.
256 * This parameter can be:
257 * @arg RTC_FLAG_TAMP1F
258 * @retval None
259 */
260 #define __HAL_RTC_TAMPER_CLEAR_FLAG(__HANDLE__, __FLAG__) SET_BIT(BKP->CSR, BKP_CSR_CTE | BKP_CSR_CTI)
261
262 /**
263 * @brief Enable the RTC Second interrupt.
264 * @param __HANDLE__: specifies the RTC handle.
265 * @param __INTERRUPT__: specifies the RTC Second interrupt sources to be enabled
266 * This parameter can be any combination of the following values:
267 * @arg RTC_IT_SEC: Second A interrupt
268 * @retval None
269 */
270 #define __HAL_RTC_SECOND_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__))
271
272 /**
273 * @brief Disable the RTC Second interrupt.
274 * @param __HANDLE__: specifies the RTC handle.
275 * @param __INTERRUPT__: specifies the RTC Second interrupt sources to be disabled.
276 * This parameter can be any combination of the following values:
277 * @arg RTC_IT_SEC: Second A interrupt
278 * @retval None
279 */
280 #define __HAL_RTC_SECOND_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__))
281
282 /**
283 * @brief Check whether the specified RTC Second interrupt has occurred or not.
284 * @param __HANDLE__: specifies the RTC handle.
285 * @param __INTERRUPT__: specifies the RTC Second interrupt sources to be enabled or disabled.
286 * This parameter can be:
287 * @arg RTC_IT_SEC: Second A interrupt
288 * @retval None
289 */
290 #define __HAL_RTC_SECOND_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((__HANDLE__)->Instance->CRH)& ((__INTERRUPT__)))) != RESET)? SET : RESET)
291
292 /**
293 * @brief Get the selected RTC Second's flag status.
294 * @param __HANDLE__: specifies the RTC handle.
295 * @param __FLAG__: specifies the RTC Second Flag sources to be enabled or disabled.
296 * This parameter can be:
297 * @arg RTC_FLAG_SEC
298 * @retval None
299 */
300 #define __HAL_RTC_SECOND_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->CRL) & (__FLAG__)) != RESET)? SET : RESET)
301
302 /**
303 * @brief Clear the RTC Second's pending flags.
304 * @param __HANDLE__: specifies the RTC handle.
305 * @param __FLAG__: specifies the RTC Second Flag sources to be enabled or disabled.
306 * This parameter can be:
307 * @arg RTC_FLAG_SEC
308 * @retval None
309 */
310 #define __HAL_RTC_SECOND_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CRL) = ~(__FLAG__)
311
312 /**
313 * @brief Enable the RTC Overflow interrupt.
314 * @param __HANDLE__: specifies the RTC handle.
315 * @param __INTERRUPT__: specifies the RTC Overflow interrupt sources to be enabled
316 * This parameter can be any combination of the following values:
317 * @arg RTC_IT_OW: Overflow A interrupt
318 * @retval None
319 */
320 #define __HAL_RTC_OVERFLOW_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__))
321
322 /**
323 * @brief Disable the RTC Overflow interrupt.
324 * @param __HANDLE__: specifies the RTC handle.
325 * @param __INTERRUPT__: specifies the RTC Overflow interrupt sources to be disabled.
326 * This parameter can be any combination of the following values:
327 * @arg RTC_IT_OW: Overflow A interrupt
328 * @retval None
329 */
330 #define __HAL_RTC_OVERFLOW_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__))
331
332 /**
333 * @brief Check whether the specified RTC Overflow interrupt has occurred or not.
334 * @param __HANDLE__: specifies the RTC handle.
335 * @param __INTERRUPT__: specifies the RTC Overflow interrupt sources to be enabled or disabled.
336 * This parameter can be:
337 * @arg RTC_IT_OW: Overflow A interrupt
338 * @retval None
339 */
340 #define __HAL_RTC_OVERFLOW_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((__HANDLE__)->Instance->CRH)& ((__INTERRUPT__))) ) != RESET)? SET : RESET)
341
342 /**
343 * @brief Get the selected RTC Overflow's flag status.
344 * @param __HANDLE__: specifies the RTC handle.
345 * @param __FLAG__: specifies the RTC Overflow Flag sources to be enabled or disabled.
346 * This parameter can be:
347 * @arg RTC_FLAG_OW
348 * @retval None
349 */
350 #define __HAL_RTC_OVERFLOW_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->CRL) & (__FLAG__)) != RESET)? SET : RESET)
351
352 /**
353 * @brief Clear the RTC Overflow's pending flags.
354 * @param __HANDLE__: specifies the RTC handle.
355 * @param __FLAG__: specifies the RTC Overflow Flag sources to be enabled or disabled.
356 * This parameter can be:
357 * @arg RTC_FLAG_OW
358 * @retval None
359 */
360 #define __HAL_RTC_OVERFLOW_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CRL) = ~(__FLAG__)
361
362 /**
363 * @}
364 */
365
366 /* Exported functions --------------------------------------------------------*/
367 /** @addtogroup RTCEx_Exported_Functions
368 * @{
369 */
370
371 /* RTC Tamper functions *****************************************/
372 /** @addtogroup RTCEx_Exported_Functions_Group1
373 * @{
374 */
375 HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
376 HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper);
377 HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper);
378 void HAL_RTCEx_TamperIRQHandler(RTC_HandleTypeDef *hrtc);
379 void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc);
380 HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
381
382 /**
383 * @}
384 */
385
386 /* RTC Second functions *****************************************/
387 /** @addtogroup RTCEx_Exported_Functions_Group2
388 * @{
389 */
390 HAL_StatusTypeDef HAL_RTCEx_SetSecond_IT(RTC_HandleTypeDef *hrtc);
391 HAL_StatusTypeDef HAL_RTCEx_DeactivateSecond(RTC_HandleTypeDef *hrtc);
392 void HAL_RTCEx_RTCIRQHandler(RTC_HandleTypeDef* hrtc);
393 void HAL_RTCEx_RTCEventCallback(RTC_HandleTypeDef *hrtc);
394 void HAL_RTCEx_RTCEventErrorCallback(RTC_HandleTypeDef *hrtc);
395
396 /**
397 * @}
398 */
399
400 /* Extension Control functions ************************************************/
401 /** @addtogroup RTCEx_Exported_Functions_Group3
402 * @{
403 */
404 void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data);
405 uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister);
406
407 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef* hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmouthCalibMinusPulsesValue);
408 /**
409 * @}
410 */
411
412 /**
413 * @}
414 */
415
416 /**
417 * @}
418 */
419
420 /**
421 * @}
422 */
423
424 #ifdef __cplusplus
425 }
426 #endif
427
428 #endif /* __STM32F1xx_HAL_RTC_EX_H */
429
430 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Imprint / Impressum