Mercurial > public > ostc4
comparison Common/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rtc.h @ 128:c78bcbd5deda FlipDisplay
Added current STM32 standandard libraries in version independend folder structure
author | Ideenmodellierer |
---|---|
date | Sun, 17 Feb 2019 21:12:22 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
127:1369f8660eaa | 128:c78bcbd5deda |
---|---|
1 /** | |
2 ****************************************************************************** | |
3 * @file stm32f4xx_hal_rtc.h | |
4 * @author MCD Application Team | |
5 * @brief Header file of RTC HAL module. | |
6 ****************************************************************************** | |
7 * @attention | |
8 * | |
9 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> | |
10 * | |
11 * Redistribution and use in source and binary forms, with or without modification, | |
12 * are permitted provided that the following conditions are met: | |
13 * 1. Redistributions of source code must retain the above copyright notice, | |
14 * this list of conditions and the following disclaimer. | |
15 * 2. Redistributions in binary form must reproduce the above copyright notice, | |
16 * this list of conditions and the following disclaimer in the documentation | |
17 * and/or other materials provided with the distribution. | |
18 * 3. Neither the name of STMicroelectronics nor the names of its contributors | |
19 * may be used to endorse or promote products derived from this software | |
20 * without specific prior written permission. | |
21 * | |
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 * | |
33 ****************************************************************************** | |
34 */ | |
35 | |
36 /* Define to prevent recursive inclusion -------------------------------------*/ | |
37 #ifndef __STM32F4xx_HAL_RTC_H | |
38 #define __STM32F4xx_HAL_RTC_H | |
39 | |
40 #ifdef __cplusplus | |
41 extern "C" { | |
42 #endif | |
43 | |
44 /* Includes ------------------------------------------------------------------*/ | |
45 #include "stm32f4xx_hal_def.h" | |
46 | |
47 /** @addtogroup STM32F4xx_HAL_Driver | |
48 * @{ | |
49 */ | |
50 | |
51 /** @addtogroup RTC | |
52 * @{ | |
53 */ | |
54 | |
55 /* Exported types ------------------------------------------------------------*/ | |
56 /** @defgroup RTC_Exported_Types RTC Exported Types | |
57 * @{ | |
58 */ | |
59 | |
60 /** | |
61 * @brief HAL State structures definition | |
62 */ | |
63 typedef enum | |
64 { | |
65 HAL_RTC_STATE_RESET = 0x00U, /*!< RTC not yet initialized or disabled */ | |
66 HAL_RTC_STATE_READY = 0x01U, /*!< RTC initialized and ready for use */ | |
67 HAL_RTC_STATE_BUSY = 0x02U, /*!< RTC process is ongoing */ | |
68 HAL_RTC_STATE_TIMEOUT = 0x03U, /*!< RTC timeout state */ | |
69 HAL_RTC_STATE_ERROR = 0x04U /*!< RTC error state */ | |
70 }HAL_RTCStateTypeDef; | |
71 | |
72 /** | |
73 * @brief RTC Configuration Structure definition | |
74 */ | |
75 typedef struct | |
76 { | |
77 uint32_t HourFormat; /*!< Specifies the RTC Hour Format. | |
78 This parameter can be a value of @ref RTC_Hour_Formats */ | |
79 | |
80 uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value. | |
81 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */ | |
82 | |
83 uint32_t SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value. | |
84 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFFU */ | |
85 | |
86 uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC output. | |
87 This parameter can be a value of @ref RTC_Output_selection_Definitions */ | |
88 | |
89 uint32_t OutPutPolarity; /*!< Specifies the polarity of the output signal. | |
90 This parameter can be a value of @ref RTC_Output_Polarity_Definitions */ | |
91 | |
92 uint32_t OutPutType; /*!< Specifies the RTC Output Pin mode. | |
93 This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */ | |
94 }RTC_InitTypeDef; | |
95 | |
96 /** | |
97 * @brief RTC Time structure definition | |
98 */ | |
99 typedef struct | |
100 { | |
101 uint8_t Hours; /*!< Specifies the RTC Time Hour. | |
102 This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected. | |
103 This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */ | |
104 | |
105 uint8_t Minutes; /*!< Specifies the RTC Time Minutes. | |
106 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ | |
107 | |
108 uint8_t Seconds; /*!< Specifies the RTC Time Seconds. | |
109 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ | |
110 | |
111 uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time. | |
112 This parameter can be a value of @ref RTC_AM_PM_Definitions */ | |
113 | |
114 uint32_t SubSeconds; /*!< Specifies the RTC_SSR RTC Sub Second register content. | |
115 This parameter corresponds to a time unit range between [0-1] Second | |
116 with [1 Sec / SecondFraction +1] granularity */ | |
117 | |
118 uint32_t SecondFraction; /*!< Specifies the range or granularity of Sub Second register content | |
119 corresponding to Synchronous pre-scaler factor value (PREDIV_S) | |
120 This parameter corresponds to a time unit range between [0-1] Second | |
121 with [1 Sec / SecondFraction +1] granularity. | |
122 This field will be used only by HAL_RTC_GetTime function */ | |
123 | |
124 uint32_t DayLightSaving; /*!< Specifies DayLight Save Operation. | |
125 This parameter can be a value of @ref RTC_DayLightSaving_Definitions */ | |
126 | |
127 uint32_t StoreOperation; /*!< Specifies RTC_StoreOperation value to be written in the BCK bit | |
128 in CR register to store the operation. | |
129 This parameter can be a value of @ref RTC_StoreOperation_Definitions */ | |
130 }RTC_TimeTypeDef; | |
131 | |
132 /** | |
133 * @brief RTC Date structure definition | |
134 */ | |
135 typedef struct | |
136 { | |
137 uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay. | |
138 This parameter can be a value of @ref RTC_WeekDay_Definitions */ | |
139 | |
140 uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format). | |
141 This parameter can be a value of @ref RTC_Month_Date_Definitions */ | |
142 | |
143 uint8_t Date; /*!< Specifies the RTC Date. | |
144 This parameter must be a number between Min_Data = 1 and Max_Data = 31 */ | |
145 | |
146 uint8_t Year; /*!< Specifies the RTC Date Year. | |
147 This parameter must be a number between Min_Data = 0 and Max_Data = 99 */ | |
148 | |
149 }RTC_DateTypeDef; | |
150 | |
151 /** | |
152 * @brief RTC Alarm structure definition | |
153 */ | |
154 typedef struct | |
155 { | |
156 RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */ | |
157 | |
158 uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks. | |
159 This parameter can be a value of @ref RTC_AlarmMask_Definitions */ | |
160 | |
161 uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks. | |
162 This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */ | |
163 | |
164 uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay. | |
165 This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */ | |
166 | |
167 uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay. | |
168 If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range. | |
169 If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */ | |
170 | |
171 uint32_t Alarm; /*!< Specifies the alarm . | |
172 This parameter can be a value of @ref RTC_Alarms_Definitions */ | |
173 }RTC_AlarmTypeDef; | |
174 | |
175 /** | |
176 * @brief RTC Handle Structure definition | |
177 */ | |
178 typedef struct | |
179 { | |
180 RTC_TypeDef *Instance; /*!< Register base address */ | |
181 | |
182 RTC_InitTypeDef Init; /*!< RTC required parameters */ | |
183 | |
184 HAL_LockTypeDef Lock; /*!< RTC locking object */ | |
185 | |
186 __IO HAL_RTCStateTypeDef State; /*!< Time communication state */ | |
187 | |
188 }RTC_HandleTypeDef; | |
189 | |
190 /** | |
191 * @} | |
192 */ | |
193 | |
194 /* Exported constants --------------------------------------------------------*/ | |
195 /** @defgroup RTC_Exported_Constants RTC Exported Constants | |
196 * @{ | |
197 */ | |
198 | |
199 /** @defgroup RTC_Hour_Formats RTC Hour Formats | |
200 * @{ | |
201 */ | |
202 #define RTC_HOURFORMAT_24 0x00000000U | |
203 #define RTC_HOURFORMAT_12 0x00000040U | |
204 /** | |
205 * @} | |
206 */ | |
207 | |
208 /** @defgroup RTC_Output_selection_Definitions RTC Output Selection Definitions | |
209 * @{ | |
210 */ | |
211 #define RTC_OUTPUT_DISABLE 0x00000000U | |
212 #define RTC_OUTPUT_ALARMA 0x00200000U | |
213 #define RTC_OUTPUT_ALARMB 0x00400000U | |
214 #define RTC_OUTPUT_WAKEUP 0x00600000U | |
215 /** | |
216 * @} | |
217 */ | |
218 | |
219 /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions | |
220 * @{ | |
221 */ | |
222 #define RTC_OUTPUT_POLARITY_HIGH 0x00000000U | |
223 #define RTC_OUTPUT_POLARITY_LOW 0x00100000U | |
224 /** | |
225 * @} | |
226 */ | |
227 | |
228 /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT | |
229 * @{ | |
230 */ | |
231 #define RTC_OUTPUT_TYPE_OPENDRAIN 0x00000000U | |
232 #define RTC_OUTPUT_TYPE_PUSHPULL 0x00040000U | |
233 /** | |
234 * @} | |
235 */ | |
236 | |
237 /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions | |
238 * @{ | |
239 */ | |
240 #define RTC_HOURFORMAT12_AM ((uint8_t)0x00) | |
241 #define RTC_HOURFORMAT12_PM ((uint8_t)0x40) | |
242 /** | |
243 * @} | |
244 */ | |
245 | |
246 /** @defgroup RTC_DayLightSaving_Definitions RTC DayLight Saving Definitions | |
247 * @{ | |
248 */ | |
249 #define RTC_DAYLIGHTSAVING_SUB1H 0x00020000U | |
250 #define RTC_DAYLIGHTSAVING_ADD1H 0x00010000U | |
251 #define RTC_DAYLIGHTSAVING_NONE 0x00000000U | |
252 /** | |
253 * @} | |
254 */ | |
255 | |
256 /** @defgroup RTC_StoreOperation_Definitions RTC Store Operation Definitions | |
257 * @{ | |
258 */ | |
259 #define RTC_STOREOPERATION_RESET 0x00000000U | |
260 #define RTC_STOREOPERATION_SET 0x00040000U | |
261 /** | |
262 * @} | |
263 */ | |
264 | |
265 /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions | |
266 * @{ | |
267 */ | |
268 #define RTC_FORMAT_BIN 0x00000000U | |
269 #define RTC_FORMAT_BCD 0x00000001U | |
270 /** | |
271 * @} | |
272 */ | |
273 | |
274 /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions | |
275 * @{ | |
276 */ | |
277 /* Coded in BCD format */ | |
278 #define RTC_MONTH_JANUARY ((uint8_t)0x01) | |
279 #define RTC_MONTH_FEBRUARY ((uint8_t)0x02) | |
280 #define RTC_MONTH_MARCH ((uint8_t)0x03) | |
281 #define RTC_MONTH_APRIL ((uint8_t)0x04) | |
282 #define RTC_MONTH_MAY ((uint8_t)0x05) | |
283 #define RTC_MONTH_JUNE ((uint8_t)0x06) | |
284 #define RTC_MONTH_JULY ((uint8_t)0x07) | |
285 #define RTC_MONTH_AUGUST ((uint8_t)0x08) | |
286 #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09) | |
287 #define RTC_MONTH_OCTOBER ((uint8_t)0x10) | |
288 #define RTC_MONTH_NOVEMBER ((uint8_t)0x11) | |
289 #define RTC_MONTH_DECEMBER ((uint8_t)0x12) | |
290 /** | |
291 * @} | |
292 */ | |
293 | |
294 /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions | |
295 * @{ | |
296 */ | |
297 #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01) | |
298 #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02) | |
299 #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03) | |
300 #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04) | |
301 #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05) | |
302 #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06) | |
303 #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07) | |
304 /** | |
305 * @} | |
306 */ | |
307 | |
308 /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC Alarm Date WeekDay Definitions | |
309 * @{ | |
310 */ | |
311 #define RTC_ALARMDATEWEEKDAYSEL_DATE 0x00000000U | |
312 #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY 0x40000000U | |
313 /** | |
314 * @} | |
315 */ | |
316 | |
317 /** @defgroup RTC_AlarmMask_Definitions RTC Alarm Mask Definitions | |
318 * @{ | |
319 */ | |
320 #define RTC_ALARMMASK_NONE 0x00000000U | |
321 #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4 | |
322 #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3 | |
323 #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2 | |
324 #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1 | |
325 #define RTC_ALARMMASK_ALL 0x80808080U | |
326 /** | |
327 * @} | |
328 */ | |
329 | |
330 /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions | |
331 * @{ | |
332 */ | |
333 #define RTC_ALARM_A RTC_CR_ALRAE | |
334 #define RTC_ALARM_B RTC_CR_ALRBE | |
335 /** | |
336 * @} | |
337 */ | |
338 | |
339 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions | |
340 * @{ | |
341 */ | |
342 #define RTC_ALARMSUBSECONDMASK_ALL 0x00000000U /*!< All Alarm SS fields are masked. | |
343 There is no comparison on sub seconds | |
344 for Alarm */ | |
345 #define RTC_ALARMSUBSECONDMASK_SS14_1 0x01000000U /*!< SS[14:1] are don't care in Alarm | |
346 comparison. Only SS[0] is compared. */ | |
347 #define RTC_ALARMSUBSECONDMASK_SS14_2 0x02000000U /*!< SS[14:2] are don't care in Alarm | |
348 comparison. Only SS[1:0] are compared */ | |
349 #define RTC_ALARMSUBSECONDMASK_SS14_3 0x03000000U /*!< SS[14:3] are don't care in Alarm | |
350 comparison. Only SS[2:0] are compared */ | |
351 #define RTC_ALARMSUBSECONDMASK_SS14_4 0x04000000U /*!< SS[14:4] are don't care in Alarm | |
352 comparison. Only SS[3:0] are compared */ | |
353 #define RTC_ALARMSUBSECONDMASK_SS14_5 0x05000000U /*!< SS[14:5] are don't care in Alarm | |
354 comparison. Only SS[4:0] are compared */ | |
355 #define RTC_ALARMSUBSECONDMASK_SS14_6 0x06000000U /*!< SS[14:6] are don't care in Alarm | |
356 comparison. Only SS[5:0] are compared */ | |
357 #define RTC_ALARMSUBSECONDMASK_SS14_7 0x07000000U /*!< SS[14:7] are don't care in Alarm | |
358 comparison. Only SS[6:0] are compared */ | |
359 #define RTC_ALARMSUBSECONDMASK_SS14_8 0x08000000U /*!< SS[14:8] are don't care in Alarm | |
360 comparison. Only SS[7:0] are compared */ | |
361 #define RTC_ALARMSUBSECONDMASK_SS14_9 0x09000000U /*!< SS[14:9] are don't care in Alarm | |
362 comparison. Only SS[8:0] are compared */ | |
363 #define RTC_ALARMSUBSECONDMASK_SS14_10 0x0A000000U /*!< SS[14:10] are don't care in Alarm | |
364 comparison. Only SS[9:0] are compared */ | |
365 #define RTC_ALARMSUBSECONDMASK_SS14_11 0x0B000000U /*!< SS[14:11] are don't care in Alarm | |
366 comparison. Only SS[10:0] are compared */ | |
367 #define RTC_ALARMSUBSECONDMASK_SS14_12 0x0C000000U /*!< SS[14:12] are don't care in Alarm | |
368 comparison.Only SS[11:0] are compared */ | |
369 #define RTC_ALARMSUBSECONDMASK_SS14_13 0x0D000000U /*!< SS[14:13] are don't care in Alarm | |
370 comparison. Only SS[12:0] are compared */ | |
371 #define RTC_ALARMSUBSECONDMASK_SS14 0x0E000000U /*!< SS[14] is don't care in Alarm | |
372 comparison.Only SS[13:0] are compared */ | |
373 #define RTC_ALARMSUBSECONDMASK_NONE 0x0F000000U /*!< SS[14:0] are compared and must match | |
374 to activate alarm. */ | |
375 /** | |
376 * @} | |
377 */ | |
378 | |
379 /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions | |
380 * @{ | |
381 */ | |
382 #define RTC_IT_TS 0x00008000U | |
383 #define RTC_IT_WUT 0x00004000U | |
384 #define RTC_IT_ALRB 0x00002000U | |
385 #define RTC_IT_ALRA 0x00001000U | |
386 #define RTC_IT_TAMP 0x00000004U /* Used only to Enable the Tamper Interrupt */ | |
387 #define RTC_IT_TAMP1 0x00020000U | |
388 #define RTC_IT_TAMP2 0x00040000U | |
389 /** | |
390 * @} | |
391 */ | |
392 | |
393 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions | |
394 * @{ | |
395 */ | |
396 #define RTC_FLAG_RECALPF 0x00010000U | |
397 #define RTC_FLAG_TAMP2F 0x00004000U | |
398 #define RTC_FLAG_TAMP1F 0x00002000U | |
399 #define RTC_FLAG_TSOVF 0x00001000U | |
400 #define RTC_FLAG_TSF 0x00000800U | |
401 #define RTC_FLAG_WUTF 0x00000400U | |
402 #define RTC_FLAG_ALRBF 0x00000200U | |
403 #define RTC_FLAG_ALRAF 0x00000100U | |
404 #define RTC_FLAG_INITF 0x00000040U | |
405 #define RTC_FLAG_RSF 0x00000020U | |
406 #define RTC_FLAG_INITS 0x00000010U | |
407 #define RTC_FLAG_SHPF 0x00000008U | |
408 #define RTC_FLAG_WUTWF 0x00000004U | |
409 #define RTC_FLAG_ALRBWF 0x00000002U | |
410 #define RTC_FLAG_ALRAWF 0x00000001U | |
411 /** | |
412 * @} | |
413 */ | |
414 | |
415 /** | |
416 * @} | |
417 */ | |
418 | |
419 /* Exported macro ------------------------------------------------------------*/ | |
420 /** @defgroup RTC_Exported_Macros RTC Exported Macros | |
421 * @{ | |
422 */ | |
423 | |
424 /** @brief Reset RTC handle state | |
425 * @param __HANDLE__ specifies the RTC handle. | |
426 * @retval None | |
427 */ | |
428 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET) | |
429 | |
430 /** | |
431 * @brief Disable the write protection for RTC registers. | |
432 * @param __HANDLE__ specifies the RTC handle. | |
433 * @retval None | |
434 */ | |
435 #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \ | |
436 do{ \ | |
437 (__HANDLE__)->Instance->WPR = 0xCAU; \ | |
438 (__HANDLE__)->Instance->WPR = 0x53U; \ | |
439 } while(0U) | |
440 | |
441 /** | |
442 * @brief Enable the write protection for RTC registers. | |
443 * @param __HANDLE__ specifies the RTC handle. | |
444 * @retval None | |
445 */ | |
446 #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \ | |
447 do{ \ | |
448 (__HANDLE__)->Instance->WPR = 0xFFU; \ | |
449 } while(0U) | |
450 | |
451 /** | |
452 * @brief Enable the RTC ALARMA peripheral. | |
453 * @param __HANDLE__ specifies the RTC handle. | |
454 * @retval None | |
455 */ | |
456 #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE)) | |
457 | |
458 /** | |
459 * @brief Disable the RTC ALARMA peripheral. | |
460 * @param __HANDLE__ specifies the RTC handle. | |
461 * @retval None | |
462 */ | |
463 #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE)) | |
464 | |
465 /** | |
466 * @brief Enable the RTC ALARMB peripheral. | |
467 * @param __HANDLE__ specifies the RTC handle. | |
468 * @retval None | |
469 */ | |
470 #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE)) | |
471 | |
472 /** | |
473 * @brief Disable the RTC ALARMB peripheral. | |
474 * @param __HANDLE__ specifies the RTC handle. | |
475 * @retval None | |
476 */ | |
477 #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE)) | |
478 | |
479 /** | |
480 * @brief Enable the RTC Alarm interrupt. | |
481 * @param __HANDLE__ specifies the RTC handle. | |
482 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled. | |
483 * This parameter can be any combination of the following values: | |
484 * @arg RTC_IT_ALRA: Alarm A interrupt | |
485 * @arg RTC_IT_ALRB: Alarm B interrupt | |
486 * @retval None | |
487 */ | |
488 #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) | |
489 | |
490 /** | |
491 * @brief Disable the RTC Alarm interrupt. | |
492 * @param __HANDLE__ specifies the RTC handle. | |
493 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled. | |
494 * This parameter can be any combination of the following values: | |
495 * @arg RTC_IT_ALRA: Alarm A interrupt | |
496 * @arg RTC_IT_ALRB: Alarm B interrupt | |
497 * @retval None | |
498 */ | |
499 #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) | |
500 | |
501 /** | |
502 * @brief Check whether the specified RTC Alarm interrupt has occurred or not. | |
503 * @param __HANDLE__ specifies the RTC handle. | |
504 * @param __INTERRUPT__ specifies the RTC Alarm interrupt to check. | |
505 * This parameter can be: | |
506 * @arg RTC_IT_ALRA: Alarm A interrupt | |
507 * @arg RTC_IT_ALRB: Alarm B interrupt | |
508 * @retval None | |
509 */ | |
510 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR)& ((__INTERRUPT__)>> 4U)) != RESET)? SET : RESET) | |
511 | |
512 /** | |
513 * @brief Get the selected RTC Alarm's flag status. | |
514 * @param __HANDLE__ specifies the RTC handle. | |
515 * @param __FLAG__ specifies the RTC Alarm Flag to check. | |
516 * This parameter can be: | |
517 * @arg RTC_FLAG_ALRAF | |
518 * @arg RTC_FLAG_ALRBF | |
519 * @arg RTC_FLAG_ALRAWF | |
520 * @arg RTC_FLAG_ALRBWF | |
521 * @retval None | |
522 */ | |
523 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET) | |
524 | |
525 /** | |
526 * @brief Clear the RTC Alarm's pending flags. | |
527 * @param __HANDLE__ specifies the RTC handle. | |
528 * @param __FLAG__ specifies the RTC Alarm Flag sources to be enabled or disabled. | |
529 * This parameter can be: | |
530 * @arg RTC_FLAG_ALRAF | |
531 * @arg RTC_FLAG_ALRBF | |
532 * @retval None | |
533 */ | |
534 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)) | |
535 | |
536 | |
537 /** | |
538 * @brief Check whether the specified RTC Alarm interrupt has been enabled or not. | |
539 * @param __HANDLE__ specifies the RTC handle. | |
540 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check. | |
541 * This parameter can be: | |
542 * @arg RTC_IT_ALRA: Alarm A interrupt | |
543 * @arg RTC_IT_ALRB: Alarm B interrupt | |
544 * @retval None | |
545 */ | |
546 #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET) | |
547 | |
548 /** | |
549 * @brief Enable interrupt on the RTC Alarm associated Exti line. | |
550 * @retval None | |
551 */ | |
552 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_ALARM_EVENT) | |
553 | |
554 /** | |
555 * @brief Disable interrupt on the RTC Alarm associated Exti line. | |
556 * @retval None | |
557 */ | |
558 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_ALARM_EVENT)) | |
559 | |
560 /** | |
561 * @brief Enable event on the RTC Alarm associated Exti line. | |
562 * @retval None. | |
563 */ | |
564 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_ALARM_EVENT) | |
565 | |
566 /** | |
567 * @brief Disable event on the RTC Alarm associated Exti line. | |
568 * @retval None. | |
569 */ | |
570 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_ALARM_EVENT)) | |
571 | |
572 /** | |
573 * @brief Enable falling edge trigger on the RTC Alarm associated Exti line. | |
574 * @retval None. | |
575 */ | |
576 #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_ALARM_EVENT) | |
577 | |
578 /** | |
579 * @brief Disable falling edge trigger on the RTC Alarm associated Exti line. | |
580 * @retval None. | |
581 */ | |
582 #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT)) | |
583 | |
584 /** | |
585 * @brief Enable rising edge trigger on the RTC Alarm associated Exti line. | |
586 * @retval None. | |
587 */ | |
588 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_ALARM_EVENT) | |
589 | |
590 /** | |
591 * @brief Disable rising edge trigger on the RTC Alarm associated Exti line. | |
592 * @retval None. | |
593 */ | |
594 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT)) | |
595 | |
596 /** | |
597 * @brief Enable rising & falling edge trigger on the RTC Alarm associated Exti line. | |
598 * @retval None. | |
599 */ | |
600 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() do { __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \ | |
601 __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE();\ | |
602 } while(0U) | |
603 | |
604 /** | |
605 * @brief Disable rising & falling edge trigger on the RTC Alarm associated Exti line. | |
606 * @retval None. | |
607 */ | |
608 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE();\ | |
609 __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE();\ | |
610 } while(0U) | |
611 | |
612 /** | |
613 * @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or not. | |
614 * @retval Line Status. | |
615 */ | |
616 #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_ALARM_EVENT) | |
617 | |
618 /** | |
619 * @brief Clear the RTC Alarm associated Exti line flag. | |
620 * @retval None. | |
621 */ | |
622 #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_ALARM_EVENT) | |
623 | |
624 /** | |
625 * @brief Generate a Software interrupt on RTC Alarm associated Exti line. | |
626 * @retval None. | |
627 */ | |
628 #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_ALARM_EVENT) | |
629 /** | |
630 * @} | |
631 */ | |
632 | |
633 /* Include RTC HAL Extension module */ | |
634 #include "stm32f4xx_hal_rtc_ex.h" | |
635 | |
636 /* Exported functions --------------------------------------------------------*/ | |
637 /** @addtogroup RTC_Exported_Functions | |
638 * @{ | |
639 */ | |
640 | |
641 /** @addtogroup RTC_Exported_Functions_Group1 | |
642 * @{ | |
643 */ | |
644 /* Initialization and de-initialization functions ****************************/ | |
645 HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc); | |
646 HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc); | |
647 void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc); | |
648 void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc); | |
649 /** | |
650 * @} | |
651 */ | |
652 | |
653 /** @addtogroup RTC_Exported_Functions_Group2 | |
654 * @{ | |
655 */ | |
656 /* RTC Time and Date functions ************************************************/ | |
657 HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); | |
658 HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); | |
659 HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); | |
660 HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); | |
661 /** | |
662 * @} | |
663 */ | |
664 | |
665 /** @addtogroup RTC_Exported_Functions_Group3 | |
666 * @{ | |
667 */ | |
668 /* RTC Alarm functions ********************************************************/ | |
669 HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); | |
670 HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); | |
671 HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm); | |
672 HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format); | |
673 void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc); | |
674 HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); | |
675 void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc); | |
676 /** | |
677 * @} | |
678 */ | |
679 | |
680 /** @addtogroup RTC_Exported_Functions_Group4 | |
681 * @{ | |
682 */ | |
683 /* Peripheral Control functions ***********************************************/ | |
684 HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef* hrtc); | |
685 /** | |
686 * @} | |
687 */ | |
688 | |
689 /** @addtogroup RTC_Exported_Functions_Group5 | |
690 * @{ | |
691 */ | |
692 /* Peripheral State functions *************************************************/ | |
693 HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc); | |
694 /** | |
695 * @} | |
696 */ | |
697 | |
698 /** | |
699 * @} | |
700 */ | |
701 | |
702 /* Private types -------------------------------------------------------------*/ | |
703 /* Private variables ---------------------------------------------------------*/ | |
704 /* Private constants ---------------------------------------------------------*/ | |
705 /** @defgroup RTC_Private_Constants RTC Private Constants | |
706 * @{ | |
707 */ | |
708 /* Masks Definition */ | |
709 #define RTC_TR_RESERVED_MASK 0x007F7F7FU | |
710 #define RTC_DR_RESERVED_MASK 0x00FFFF3FU | |
711 #define RTC_INIT_MASK 0xFFFFFFFFU | |
712 #define RTC_RSF_MASK 0xFFFFFF5FU | |
713 #define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_TSOVF | RTC_FLAG_TSF | RTC_FLAG_WUTF | \ | |
714 RTC_FLAG_ALRBF | RTC_FLAG_ALRAF | RTC_FLAG_INITF | \ | |
715 RTC_FLAG_RSF | RTC_FLAG_INITS | RTC_FLAG_WUTWF | \ | |
716 RTC_FLAG_ALRBWF | RTC_FLAG_ALRAWF | RTC_FLAG_TAMP1F | \ | |
717 RTC_FLAG_RECALPF | RTC_FLAG_SHPF)) | |
718 | |
719 #define RTC_TIMEOUT_VALUE 1000 | |
720 | |
721 #define RTC_EXTI_LINE_ALARM_EVENT ((uint32_t)EXTI_IMR_MR17) /*!< External interrupt line 17 Connected to the RTC Alarm event */ | |
722 /** | |
723 * @} | |
724 */ | |
725 | |
726 /* Private macros ------------------------------------------------------------*/ | |
727 /** @defgroup RTC_Private_Macros RTC Private Macros | |
728 * @{ | |
729 */ | |
730 | |
731 /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters | |
732 * @{ | |
733 */ | |
734 #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \ | |
735 ((FORMAT) == RTC_HOURFORMAT_24)) | |
736 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \ | |
737 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \ | |
738 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \ | |
739 ((OUTPUT) == RTC_OUTPUT_WAKEUP)) | |
740 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \ | |
741 ((POL) == RTC_OUTPUT_POLARITY_LOW)) | |
742 #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \ | |
743 ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL)) | |
744 #define IS_RTC_HOUR12(HOUR) (((HOUR) > 0U) && ((HOUR) <= 12U)) | |
745 #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23U) | |
746 #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FU) | |
747 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FFFU) | |
748 #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59U) | |
749 #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59U) | |
750 | |
751 #define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || ((PM) == RTC_HOURFORMAT12_PM)) | |
752 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \ | |
753 ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \ | |
754 ((SAVE) == RTC_DAYLIGHTSAVING_NONE)) | |
755 #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \ | |
756 ((OPERATION) == RTC_STOREOPERATION_SET)) | |
757 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || ((FORMAT) == RTC_FORMAT_BCD)) | |
758 #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99U) | |
759 #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1U) && ((MONTH) <= 12U)) | |
760 #define IS_RTC_DATE(DATE) (((DATE) >= 1U) && ((DATE) <= 31U)) | |
761 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ | |
762 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ | |
763 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ | |
764 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ | |
765 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ | |
766 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ | |
767 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) | |
768 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0U) && ((DATE) <= 31U)) | |
769 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ | |
770 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ | |
771 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ | |
772 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ | |
773 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ | |
774 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ | |
775 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) | |
776 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \ | |
777 ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY)) | |
778 #define IS_RTC_ALARM_MASK(MASK) (((MASK) & 0x7F7F7F7FU) == (uint32_t)RESET) | |
779 #define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || ((ALARM) == RTC_ALARM_B)) | |
780 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= 0x00007FFFU) | |
781 | |
782 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == RTC_ALARMSUBSECONDMASK_ALL) || \ | |
783 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_1) || \ | |
784 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_2) || \ | |
785 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_3) || \ | |
786 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_4) || \ | |
787 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_5) || \ | |
788 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_6) || \ | |
789 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_7) || \ | |
790 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_8) || \ | |
791 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_9) || \ | |
792 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_10) || \ | |
793 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_11) || \ | |
794 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_12) || \ | |
795 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_13) || \ | |
796 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14) || \ | |
797 ((MASK) == RTC_ALARMSUBSECONDMASK_NONE)) | |
798 /** | |
799 * @} | |
800 */ | |
801 | |
802 /** | |
803 * @} | |
804 */ | |
805 | |
806 /* Private functions ---------------------------------------------------------*/ | |
807 /** @defgroup RTC_Private_Functions RTC Private Functions | |
808 * @{ | |
809 */ | |
810 HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef* hrtc); | |
811 uint8_t RTC_ByteToBcd2(uint8_t Value); | |
812 uint8_t RTC_Bcd2ToByte(uint8_t Value); | |
813 /** | |
814 * @} | |
815 */ | |
816 | |
817 /** | |
818 * @} | |
819 */ | |
820 | |
821 /** | |
822 * @} | |
823 */ | |
824 | |
825 #ifdef __cplusplus | |
826 } | |
827 #endif | |
828 | |
829 #endif /* __STM32F4xx_HAL_RTC_H */ | |
830 | |
831 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |