2 ******************************************************************************
3 * @file stm32f3xx_hal_rtc.h
4 * @author MCD Application Team
7 * @brief Header file of RTC HAL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
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.
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.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F3xx_HAL_RTC_H
40 #define __STM32F3xx_HAL_RTC_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f3xx_hal_def.h"
49 /** @addtogroup STM32F3xx_HAL_Driver
53 /** @addtogroup RTC RTC HAL module driver
57 /* Exported types ------------------------------------------------------------*/
58 /** @defgroup RTC_Exported_Types RTC Exported Types
63 * @brief HAL State structures definition
67 HAL_RTC_STATE_RESET = 0x00, /*!< RTC not yet initialized or disabled */
68 HAL_RTC_STATE_READY = 0x01, /*!< RTC initialized and ready for use */
69 HAL_RTC_STATE_BUSY = 0x02, /*!< RTC process is ongoing */
70 HAL_RTC_STATE_TIMEOUT = 0x03, /*!< RTC timeout state */
71 HAL_RTC_STATE_ERROR = 0x04 /*!< RTC error state */
76 * @brief RTC Configuration Structure definition
80 uint32_t HourFormat; /*!< Specifies the RTC Hour Format.
81 This parameter can be a value of @ref RTC_Hour_Formats */
83 uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value.
84 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */
86 uint32_t SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value.
87 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF */
89 uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC output.
90 This parameter can be a value of @ref RTCEx_Output_selection_Definitions */
92 uint32_t OutPutPolarity; /*!< Specifies the polarity of the output signal.
93 This parameter can be a value of @ref RTC_Output_Polarity_Definitions */
95 uint32_t OutPutType; /*!< Specifies the RTC Output Pin mode.
96 This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */
100 * @brief RTC Time structure definition
104 uint8_t Hours; /*!< Specifies the RTC Time Hour.
105 This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected.
106 This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */
108 uint8_t Minutes; /*!< Specifies the RTC Time Minutes.
109 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
111 uint8_t Seconds; /*!< Specifies the RTC Time Seconds.
112 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
114 uint32_t SubSeconds; /*!< Specifies the RTC Time SubSeconds.
115 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
117 uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time.
118 This parameter can be a value of @ref RTC_AM_PM_Definitions */
120 uint32_t DayLightSaving; /*!< Specifies RTC_DayLightSaveOperation: the value of hour adjustment.
121 This parameter can be a value of @ref RTC_DayLightSaving_Definitions */
123 uint32_t StoreOperation; /*!< Specifies RTC_StoreOperation value to be written in the BCK bit
124 in CR register to store the operation.
125 This parameter can be a value of @ref RTC_StoreOperation_Definitions */
129 * @brief RTC Date structure definition
133 uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay.
134 This parameter can be a value of @ref RTC_WeekDay_Definitions */
136 uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format).
137 This parameter can be a value of @ref RTC_Month_Date_Definitions */
139 uint8_t Date; /*!< Specifies the RTC Date.
140 This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
142 uint8_t Year; /*!< Specifies the RTC Date Year.
143 This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
148 * @brief RTC Alarm structure definition
152 RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */
154 uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks.
155 This parameter can be a value of @ref RTC_AlarmMask_Definitions */
157 uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks.
158 This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */
160 uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay.
161 This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
163 uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay.
164 If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range.
165 If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */
167 uint32_t Alarm; /*!< Specifies the alarm .
168 This parameter can be a value of @ref RTC_Alarms_Definitions */
172 * @brief Time Handle Structure definition
176 RTC_TypeDef *Instance; /*!< Register base address */
178 RTC_InitTypeDef Init; /*!< RTC required parameters */
180 HAL_LockTypeDef Lock; /*!< RTC locking object */
182 __IO HAL_RTCStateTypeDef State; /*!< Time communication state */
189 /* Exported constants --------------------------------------------------------*/
190 /** @defgroup RTC_Exported_Constants RTC Exported Constants
194 /** @defgroup RTC_Mask_Definition RTC Mask Definition
197 /* Masks Definition */
198 #define RTC_TR_RESERVED_MASK ((uint32_t)0x007F7F7F)
199 #define RTC_DR_RESERVED_MASK ((uint32_t)0x00FFFF3F)
200 #define RTC_INIT_MASK ((uint32_t)0xFFFFFFFF)
201 #define RTC_RSF_MASK ((uint32_t)0xFFFFFF5F)
202 #define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_TSOVF | RTC_FLAG_TSF | RTC_FLAG_WUTF | \
203 RTC_FLAG_ALRBF | RTC_FLAG_ALRAF | RTC_FLAG_INITF | \
204 RTC_FLAG_RSF | RTC_FLAG_INITS | RTC_FLAG_WUTWF | \
205 RTC_FLAG_ALRBWF | RTC_FLAG_ALRAWF | RTC_FLAG_TAMP1F | \
206 RTC_FLAG_RECALPF | RTC_FLAG_SHPF))
208 #define RTC_TIMEOUT_VALUE 1000
213 /** @defgroup RTC_Hour_Formats RTC Hour Formats
216 #define RTC_HOURFORMAT_24 ((uint32_t)0x00000000)
217 #define RTC_HOURFORMAT_12 ((uint32_t)0x00000040)
219 #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \
220 ((FORMAT) == RTC_HOURFORMAT_24))
225 /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions
228 #define RTC_OUTPUT_POLARITY_HIGH ((uint32_t)0x00000000)
229 #define RTC_OUTPUT_POLARITY_LOW ((uint32_t)0x00100000)
231 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \
232 ((POL) == RTC_OUTPUT_POLARITY_LOW))
237 /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT
240 #define RTC_OUTPUT_TYPE_OPENDRAIN ((uint32_t)0x00000000)
241 #define RTC_OUTPUT_TYPE_PUSHPULL ((uint32_t)0x00040000)
243 #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
244 ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL))
250 /** @defgroup RTC_Asynchronous_Predivider RTC Asynchronous Predivider
253 #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= (uint32_t)0x7F)
258 /** @defgroup RTC_Synchronous_Predivider RTC Synchronous Predivider
261 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= (uint32_t)0x7FFF)
266 /** @defgroup RTC_Time_Definitions RTC Time Definitions
269 #define IS_RTC_HOUR12(HOUR) (((HOUR) > (uint32_t)0) && ((HOUR) <= (uint32_t)12))
270 #define IS_RTC_HOUR24(HOUR) ((HOUR) <= (uint32_t)23)
271 #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= (uint32_t)59)
272 #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= (uint32_t)59)
277 /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions
280 #define RTC_HOURFORMAT12_AM ((uint8_t)0x00)
281 #define RTC_HOURFORMAT12_PM ((uint8_t)0x40)
283 #define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || ((PM) == RTC_HOURFORMAT12_PM))
288 /** @defgroup RTC_DayLightSaving_Definitions RTC DayLightSaving Definitions
291 #define RTC_DAYLIGHTSAVING_SUB1H ((uint32_t)0x00020000)
292 #define RTC_DAYLIGHTSAVING_ADD1H ((uint32_t)0x00010000)
293 #define RTC_DAYLIGHTSAVING_NONE ((uint32_t)0x00000000)
295 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \
296 ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \
297 ((SAVE) == RTC_DAYLIGHTSAVING_NONE))
302 /** @defgroup RTC_StoreOperation_Definitions RTC StoreOperation Definitions
305 #define RTC_STOREOPERATION_RESET ((uint32_t)0x00000000)
306 #define RTC_STOREOPERATION_SET ((uint32_t)0x00040000)
308 #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \
309 ((OPERATION) == RTC_STOREOPERATION_SET))
314 /** @defgroup RTC_Input_parameter_format_definitions RTC Input parameter format definitions
317 #define FORMAT_BIN ((uint32_t)0x000000000)
318 #define FORMAT_BCD ((uint32_t)0x000000001)
320 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == FORMAT_BIN) || ((FORMAT) == FORMAT_BCD))
325 /** @defgroup RTC_Year_Date_Definitions RTC Year Date Definitions
328 #define IS_RTC_YEAR(YEAR) ((YEAR) <= (uint32_t)99)
333 /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions
337 /* Coded in BCD format */
338 #define RTC_MONTH_JANUARY ((uint8_t)0x01)
339 #define RTC_MONTH_FEBRUARY ((uint8_t)0x02)
340 #define RTC_MONTH_MARCH ((uint8_t)0x03)
341 #define RTC_MONTH_APRIL ((uint8_t)0x04)
342 #define RTC_MONTH_MAY ((uint8_t)0x05)
343 #define RTC_MONTH_JUNE ((uint8_t)0x06)
344 #define RTC_MONTH_JULY ((uint8_t)0x07)
345 #define RTC_MONTH_AUGUST ((uint8_t)0x08)
346 #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09)
347 #define RTC_MONTH_OCTOBER ((uint8_t)0x10)
348 #define RTC_MONTH_NOVEMBER ((uint8_t)0x11)
349 #define RTC_MONTH_DECEMBER ((uint8_t)0x12)
351 #define IS_RTC_MONTH(MONTH) (((MONTH) >= (uint32_t)1) && ((MONTH) <= (uint32_t)12))
352 #define IS_RTC_DATE(DATE) (((DATE) >= (uint32_t)1) && ((DATE) <= (uint32_t)31))
357 /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions
360 #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01)
361 #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02)
362 #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03)
363 #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04)
364 #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05)
365 #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06)
366 #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07)
368 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
369 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
370 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
371 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
372 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
373 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
374 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
379 /** @defgroup RTC_Alarm_Definitions RTC Alarm Definitions
382 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) >(uint32_t) 0) && ((DATE) <= (uint32_t)31))
383 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
384 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
385 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
386 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
387 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
388 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
389 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
394 /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC AlarmDateWeekDay Definitions
397 #define RTC_ALARMDATEWEEKDAYSEL_DATE ((uint32_t)0x00000000)
398 #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY ((uint32_t)0x40000000)
400 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
401 ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
406 /** @defgroup RTC_AlarmMask_Definitions RTC AlarmMask Definitions
409 #define RTC_ALARMMASK_NONE ((uint32_t)0x00000000)
410 #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4
411 #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3
412 #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2
413 #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1
414 #define RTC_ALARMMASK_ALL ((uint32_t)0x80808080)
416 #define IS_ALARM_MASK(MASK) (((MASK) & 0x7F7F7F7F) == (uint32_t)RESET)
421 /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions
424 #define RTC_ALARM_A RTC_CR_ALRAE
425 #define RTC_ALARM_B RTC_CR_ALRBE
427 #define IS_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || ((ALARM) == RTC_ALARM_B))
432 /** @defgroup RTC_Alarm_Sub_Seconds_Value RTC Alarm Sub Seconds Value
435 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= (uint32_t)0x00007FFF)
440 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions
443 #define RTC_ALARMSUBSECONDMASK_ALL ((uint32_t)0x00000000) /*!< All Alarm SS fields are masked.
444 There is no comparison on sub seconds
446 #define RTC_ALARMSUBSECONDMASK_SS14_1 ((uint32_t)0x01000000) /*!< SS[14:1] are don't care in Alarm
447 comparison. Only SS[0] is compared. */
448 #define RTC_ALARMSUBSECONDMASK_SS14_2 ((uint32_t)0x02000000) /*!< SS[14:2] are don't care in Alarm
449 comparison. Only SS[1:0] are compared */
450 #define RTC_ALARMSUBSECONDMASK_SS14_3 ((uint32_t)0x03000000) /*!< SS[14:3] are don't care in Alarm
451 comparison. Only SS[2:0] are compared */
452 #define RTC_ALARMSUBSECONDMASK_SS14_4 ((uint32_t)0x04000000) /*!< SS[14:4] are don't care in Alarm
453 comparison. Only SS[3:0] are compared */
454 #define RTC_ALARMSUBSECONDMASK_SS14_5 ((uint32_t)0x05000000) /*!< SS[14:5] are don't care in Alarm
455 comparison. Only SS[4:0] are compared */
456 #define RTC_ALARMSUBSECONDMASK_SS14_6 ((uint32_t)0x06000000) /*!< SS[14:6] are don't care in Alarm
457 comparison. Only SS[5:0] are compared */
458 #define RTC_ALARMSUBSECONDMASK_SS14_7 ((uint32_t)0x07000000) /*!< SS[14:7] are don't care in Alarm
459 comparison. Only SS[6:0] are compared */
460 #define RTC_ALARMSUBSECONDMASK_SS14_8 ((uint32_t)0x08000000) /*!< SS[14:8] are don't care in Alarm
461 comparison. Only SS[7:0] are compared */
462 #define RTC_ALARMSUBSECONDMASK_SS14_9 ((uint32_t)0x09000000) /*!< SS[14:9] are don't care in Alarm
463 comparison. Only SS[8:0] are compared */
464 #define RTC_ALARMSUBSECONDMASK_SS14_10 ((uint32_t)0x0A000000) /*!< SS[14:10] are don't care in Alarm
465 comparison. Only SS[9:0] are compared */
466 #define RTC_ALARMSUBSECONDMASK_SS14_11 ((uint32_t)0x0B000000) /*!< SS[14:11] are don't care in Alarm
467 comparison. Only SS[10:0] are compared */
468 #define RTC_ALARMSUBSECONDMASK_SS14_12 ((uint32_t)0x0C000000) /*!< SS[14:12] are don't care in Alarm
469 comparison.Only SS[11:0] are compared */
470 #define RTC_ALARMSUBSECONDMASK_SS14_13 ((uint32_t)0x0D000000) /*!< SS[14:13] are don't care in Alarm
471 comparison. Only SS[12:0] are compared */
472 #define RTC_ALARMSUBSECONDMASK_SS14 ((uint32_t)0x0E000000) /*!< SS[14] is don't care in Alarm
473 comparison.Only SS[13:0] are compared */
474 #define RTC_ALARMSUBSECONDMASK_None ((uint32_t)0x0F000000) /*!< SS[14:0] are compared and must match
475 to activate alarm. */
477 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == RTC_ALARMSUBSECONDMASK_ALL) || \
478 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_1) || \
479 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_2) || \
480 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_3) || \
481 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_4) || \
482 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_5) || \
483 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_6) || \
484 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_7) || \
485 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_8) || \
486 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_9) || \
487 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_10) || \
488 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_11) || \
489 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_12) || \
490 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_13) || \
491 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14) || \
492 ((MASK) == RTC_ALARMSUBSECONDMASK_None))
497 /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions
500 #define RTC_IT_TS ((uint32_t)0x00008000)
501 #define RTC_IT_WUT ((uint32_t)0x00004000)
502 #define RTC_IT_ALRB ((uint32_t)0x00002000)
503 #define RTC_IT_ALRA ((uint32_t)0x00001000)
504 #define RTC_IT_TAMP ((uint32_t)0x00000004) /* Used only to Enable the Tamper Interrupt */
505 #define RTC_IT_TAMP1 ((uint32_t)0x00020000)
506 #define RTC_IT_TAMP2 ((uint32_t)0x00040000)
507 #define RTC_IT_TAMP3 ((uint32_t)0x00080000)
512 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions
515 #define RTC_FLAG_RECALPF ((uint32_t)0x00010000)
516 #define RTC_FLAG_TAMP3F ((uint32_t)0x00008000)
517 #define RTC_FLAG_TAMP2F ((uint32_t)0x00004000)
518 #define RTC_FLAG_TAMP1F ((uint32_t)0x00002000)
519 #define RTC_FLAG_TSOVF ((uint32_t)0x00001000)
520 #define RTC_FLAG_TSF ((uint32_t)0x00000800)
521 #define RTC_FLAG_WUTF ((uint32_t)0x00000400)
522 #define RTC_FLAG_ALRBF ((uint32_t)0x00000200)
523 #define RTC_FLAG_ALRAF ((uint32_t)0x00000100)
524 #define RTC_FLAG_INITF ((uint32_t)0x00000040)
525 #define RTC_FLAG_RSF ((uint32_t)0x00000020)
526 #define RTC_FLAG_INITS ((uint32_t)0x00000010)
527 #define RTC_FLAG_SHPF ((uint32_t)0x00000008)
528 #define RTC_FLAG_WUTWF ((uint32_t)0x00000004)
529 #define RTC_FLAG_ALRBWF ((uint32_t)0x00000002)
530 #define RTC_FLAG_ALRAWF ((uint32_t)0x00000001)
539 /* Exported macros -----------------------------------------------------------*/
540 /** @defgroup RTC_Exported_Macros RTC Exported Macros
544 /** @brief Reset RTC handle state
545 * @param __HANDLE__: RTC handle.
548 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
551 * @brief Disable the write protection for RTC registers.
552 * @param __HANDLE__: specifies the RTC handle.
555 #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \
557 (__HANDLE__)->Instance->WPR = 0xCA; \
558 (__HANDLE__)->Instance->WPR = 0x53; \
562 * @brief Enable the write protection for RTC registers.
563 * @param __HANDLE__: specifies the RTC handle.
566 #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \
568 (__HANDLE__)->Instance->WPR = 0xFF; \
572 * @brief Enable the RTC ALARMA peripheral.
573 * @param __HANDLE__: specifies the RTC handle.
576 #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE))
579 * @brief Disable the RTC ALARMA peripheral.
580 * @param __HANDLE__: specifies the RTC handle.
583 #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE))
586 * @brief Enable the RTC ALARMB peripheral.
587 * @param __HANDLE__: specifies the RTC handle.
590 #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE))
593 * @brief Disable the RTC ALARMB peripheral.
594 * @param __HANDLE__: specifies the RTC handle.
597 #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE))
600 * @brief Enable the RTC Alarm interrupt.
601 * @param __HANDLE__: specifies the RTC handle.
602 * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
603 * This parameter can be any combination of the following values:
604 * @arg RTC_IT_ALRA: Alarm A interrupt
605 * @arg RTC_IT_ALRB: Alarm B interrupt
608 #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
611 * @brief Disable the RTC Alarm interrupt.
612 * @param __HANDLE__: specifies the RTC handle.
613 * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
614 * This parameter can be any combination of the following values:
615 * @arg RTC_IT_ALRA: Alarm A interrupt
616 * @arg RTC_IT_ALRB: Alarm B interrupt
619 #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
622 * @brief Check whether the specified RTC Alarm interrupt has occurred or not.
623 * @param __HANDLE__: specifies the RTC handle.
624 * @param __FLAG__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
625 * This parameter can be:
626 * @arg RTC_IT_ALRA: Alarm A interrupt
627 * @arg RTC_IT_ALRB: Alarm B interrupt
630 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __FLAG__) ((((((__HANDLE__)->Instance->ISR)& ((__FLAG__)>> 4)) & 0x0000FFFF) != RESET)? SET : RESET)
633 * @brief Get the selected RTC Alarm's flag status.
634 * @param __HANDLE__: specifies the RTC handle.
635 * @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled.
636 * This parameter can be:
637 * @arg RTC_FLAG_ALRAF
638 * @arg RTC_FLAG_ALRBF
639 * @arg RTC_FLAG_ALRAWF
640 * @arg RTC_FLAG_ALRBWF
643 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
646 * @brief Clear the RTC Alarm's pending flags.
647 * @param __HANDLE__: specifies the RTC handle.
648 * @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled.
649 * This parameter can be:
650 * @arg RTC_FLAG_ALRAF
651 * @arg RTC_FLAG_ALRBF
654 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& 0x0000FFFF)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
657 #define RTC_EXTI_LINE_ALARM_EVENT ((uint32_t)0x00020000) /*!< External interrupt line 17 Connected to the RTC Alarm event */
658 #define RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT ((uint32_t)0x00080000) /*!< External interrupt line 19 Connected to the RTC Tamper and Time Stamp events */
659 #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT ((uint32_t)0x00100000) /*!< External interrupt line 20 Connected to the RTC Wakeup event */
662 * @brief Enable the RTC Exti line.
663 * @param __EXTILINE__: specifies the RTC Exti sources to be enabled or disabled.
664 * This parameter can be:
665 * @arg RTC_EXTI_LINE_ALARM_EVENT
666 * @arg RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT
667 * @arg RTC_EXTI_LINE_WAKEUPTIMER_EVENT
670 #define __HAL_RTC_EXTI_ENABLE_IT(__EXTILINE__) (EXTI->IMR |= (__EXTILINE__))
672 /* alias define maintained for legacy */
673 #define __HAL_RTC_ENABLE_IT __HAL_RTC_EXTI_ENABLE_IT
676 * @brief Disable the RTC Exti line.
677 * @param __EXTILINE__: specifies the RTC Exti sources to be enabled or disabled.
678 * This parameter can be:
679 * @arg RTC_EXTI_LINE_ALARM_EVENT
680 * @arg RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT
681 * @arg RTC_EXTI_LINE_WAKEUPTIMER_EVENT
684 #define __HAL_RTC_EXTI_DISABLE_IT(__EXTILINE__) (EXTI->IMR &= ~(__EXTILINE__))
686 /* alias define maintained for legacy */
687 #define __HAL_RTC_DISABLE_IT __HAL_RTC_EXTI_DISABLE_IT
690 * @brief Generates a Software interrupt on selected EXTI line.
691 * @param __EXTILINE__: specifies the RTC Exti sources to be enabled or disabled.
692 * This parameter can be:
693 * @arg RTC_EXTI_LINE_ALARM_EVENT
694 * @arg RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT
695 * @arg RTC_EXTI_LINE_WAKEUPTIMER_EVENT
698 #define __HAL_RTC_EXTI_GENERATE_SWIT(__EXTILINE__) (EXTI->SWIER |= (__EXTILINE__))
701 * @brief Clear the RTC Exti flags.
702 * @param __FLAG__: specifies the RTC Exti sources to be enabled or disabled.
703 * This parameter can be:
704 * @arg RTC_EXTI_LINE_ALARM_EVENT
705 * @arg RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT
706 * @arg RTC_EXTI_LINE_WAKEUPTIMER_EVENT
709 #define __HAL_RTC_EXTI_CLEAR_FLAG(__FLAG__) (EXTI->PR = (__FLAG__))
711 /* alias define maintained for legacy */
712 #define __HAL_RTC_CLEAR_FLAG __HAL_RTC_EXTI_CLEAR_FLAG
718 /* Include RTC HAL Extended module */
719 #include "stm32f3xx_hal_rtc_ex.h"
721 /* Exported functions --------------------------------------------------------*/
722 /** @addtogroup RTC_Exported_Functions RTC Exported Functions
726 /** @addtogroup RTC_Exported_Functions_Group1 Initialization and de-initialization functions
730 /* Initialization and de-initialization functions ****************************/
731 HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
732 HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
733 void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
734 void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
739 /** @addtogroup RTC_Exported_Functions_Group2 RTC Time and Date functions
743 /* RTC Time and Date functions ************************************************/
744 HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
745 HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
746 HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
747 HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
752 /** @addtogroup RTC_Exported_Functions_Group3 RTC Alarm functions
755 /* RTC Alarm functions ********************************************************/
756 HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
757 HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
758 HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm);
759 HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format);
760 void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
761 HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
762 void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc);
767 /** @addtogroup RTC_Exported_Functions_Group4 Peripheral Control functions
770 /* Peripheral Control functions ***********************************************/
771 HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef* hrtc);
776 /** @addtogroup RTC_Exported_Functions_Group5 Peripheral State functions
779 /* Peripheral State functions *************************************************/
780 HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc);
789 /** @addtogroup RTC_Private_Functions
792 HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef* hrtc);
793 uint8_t RTC_ByteToBcd2(uint8_t Value);
794 uint8_t RTC_Bcd2ToByte(uint8_t Value);
811 #endif /* __STM32F3xx_HAL_RTC_H */
813 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/