2 ******************************************************************************
\r
3 * @file stm32f4xx_rtc.h
\r
4 * @author MCD Application Team
\r
6 * @date 30-September-2011
\r
7 * @brief This file contains all the functions prototypes for the RTC firmware
\r
9 ******************************************************************************
\r
12 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
\r
13 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
\r
14 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
\r
15 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
\r
16 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
\r
17 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
\r
19 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
\r
20 ******************************************************************************
\r
23 /* Define to prevent recursive inclusion -------------------------------------*/
\r
24 #ifndef __STM32F4xx_RTC_H
\r
25 #define __STM32F4xx_RTC_H
\r
31 /* Includes ------------------------------------------------------------------*/
\r
32 #include "stm32f4xx.h"
\r
34 /** @addtogroup STM32F4xx_StdPeriph_Driver
\r
42 /* Exported types ------------------------------------------------------------*/
\r
45 * @brief RTC Init structures definition
\r
49 uint32_t RTC_HourFormat; /*!< Specifies the RTC Hour Format.
\r
50 This parameter can be a value of @ref RTC_Hour_Formats */
\r
52 uint32_t RTC_AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value.
\r
53 This parameter must be set to a value lower than 0x7F */
\r
55 uint32_t RTC_SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value.
\r
56 This parameter must be set to a value lower than 0x7FFF */
\r
60 * @brief RTC Time structure definition
\r
64 uint8_t RTC_Hours; /*!< Specifies the RTC Time Hour.
\r
65 This parameter must be set to a value in the 0-12 range
\r
66 if the RTC_HourFormat_12 is selected or 0-23 range if
\r
67 the RTC_HourFormat_24 is selected. */
\r
69 uint8_t RTC_Minutes; /*!< Specifies the RTC Time Minutes.
\r
70 This parameter must be set to a value in the 0-59 range. */
\r
72 uint8_t RTC_Seconds; /*!< Specifies the RTC Time Seconds.
\r
73 This parameter must be set to a value in the 0-59 range. */
\r
75 uint8_t RTC_H12; /*!< Specifies the RTC AM/PM Time.
\r
76 This parameter can be a value of @ref RTC_AM_PM_Definitions */
\r
80 * @brief RTC Date structure definition
\r
84 uint8_t RTC_WeekDay; /*!< Specifies the RTC Date WeekDay.
\r
85 This parameter can be a value of @ref RTC_WeekDay_Definitions */
\r
87 uint8_t RTC_Month; /*!< Specifies the RTC Date Month (in BCD format).
\r
88 This parameter can be a value of @ref RTC_Month_Date_Definitions */
\r
90 uint8_t RTC_Date; /*!< Specifies the RTC Date.
\r
91 This parameter must be set to a value in the 1-31 range. */
\r
93 uint8_t RTC_Year; /*!< Specifies the RTC Date Year.
\r
94 This parameter must be set to a value in the 0-99 range. */
\r
98 * @brief RTC Alarm structure definition
\r
102 RTC_TimeTypeDef RTC_AlarmTime; /*!< Specifies the RTC Alarm Time members. */
\r
104 uint32_t RTC_AlarmMask; /*!< Specifies the RTC Alarm Masks.
\r
105 This parameter can be a value of @ref RTC_AlarmMask_Definitions */
\r
107 uint32_t RTC_AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay.
\r
108 This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
\r
110 uint8_t RTC_AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay.
\r
111 If the Alarm Date is selected, this parameter
\r
112 must be set to a value in the 1-31 range.
\r
113 If the Alarm WeekDay is selected, this
\r
114 parameter can be a value of @ref RTC_WeekDay_Definitions */
\r
117 /* Exported constants --------------------------------------------------------*/
\r
119 /** @defgroup RTC_Exported_Constants
\r
124 /** @defgroup RTC_Hour_Formats
\r
127 #define RTC_HourFormat_24 ((uint32_t)0x00000000)
\r
128 #define RTC_HourFormat_12 ((uint32_t)0x00000040)
\r
129 #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HourFormat_12) || \
\r
130 ((FORMAT) == RTC_HourFormat_24))
\r
135 /** @defgroup RTC_Asynchronous_Predivider
\r
138 #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7F)
\r
145 /** @defgroup RTC_Synchronous_Predivider
\r
148 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FFF)
\r
154 /** @defgroup RTC_Time_Definitions
\r
157 #define IS_RTC_HOUR12(HOUR) (((HOUR) > 0) && ((HOUR) <= 12))
\r
158 #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23)
\r
159 #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59)
\r
160 #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59)
\r
166 /** @defgroup RTC_AM_PM_Definitions
\r
169 #define RTC_H12_AM ((uint8_t)0x00)
\r
170 #define RTC_H12_PM ((uint8_t)0x40)
\r
171 #define IS_RTC_H12(PM) (((PM) == RTC_H12_AM) || ((PM) == RTC_H12_PM))
\r
177 /** @defgroup RTC_Year_Date_Definitions
\r
180 #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99)
\r
186 /** @defgroup RTC_Month_Date_Definitions
\r
190 /* Coded in BCD format */
\r
191 #define RTC_Month_January ((uint8_t)0x01)
\r
192 #define RTC_Month_February ((uint8_t)0x02)
\r
193 #define RTC_Month_March ((uint8_t)0x03)
\r
194 #define RTC_Month_April ((uint8_t)0x04)
\r
195 #define RTC_Month_May ((uint8_t)0x05)
\r
196 #define RTC_Month_June ((uint8_t)0x06)
\r
197 #define RTC_Month_July ((uint8_t)0x07)
\r
198 #define RTC_Month_August ((uint8_t)0x08)
\r
199 #define RTC_Month_September ((uint8_t)0x09)
\r
200 #define RTC_Month_October ((uint8_t)0x10)
\r
201 #define RTC_Month_November ((uint8_t)0x11)
\r
202 #define RTC_Month_December ((uint8_t)0x12)
\r
203 #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1) && ((MONTH) <= 12))
\r
204 #define IS_RTC_DATE(DATE) (((DATE) >= 1) && ((DATE) <= 31))
\r
210 /** @defgroup RTC_WeekDay_Definitions
\r
214 #define RTC_Weekday_Monday ((uint8_t)0x01)
\r
215 #define RTC_Weekday_Tuesday ((uint8_t)0x02)
\r
216 #define RTC_Weekday_Wednesday ((uint8_t)0x03)
\r
217 #define RTC_Weekday_Thursday ((uint8_t)0x04)
\r
218 #define RTC_Weekday_Friday ((uint8_t)0x05)
\r
219 #define RTC_Weekday_Saturday ((uint8_t)0x06)
\r
220 #define RTC_Weekday_Sunday ((uint8_t)0x07)
\r
221 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \
\r
222 ((WEEKDAY) == RTC_Weekday_Tuesday) || \
\r
223 ((WEEKDAY) == RTC_Weekday_Wednesday) || \
\r
224 ((WEEKDAY) == RTC_Weekday_Thursday) || \
\r
225 ((WEEKDAY) == RTC_Weekday_Friday) || \
\r
226 ((WEEKDAY) == RTC_Weekday_Saturday) || \
\r
227 ((WEEKDAY) == RTC_Weekday_Sunday))
\r
233 /** @defgroup RTC_Alarm_Definitions
\r
236 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0) && ((DATE) <= 31))
\r
237 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \
\r
238 ((WEEKDAY) == RTC_Weekday_Tuesday) || \
\r
239 ((WEEKDAY) == RTC_Weekday_Wednesday) || \
\r
240 ((WEEKDAY) == RTC_Weekday_Thursday) || \
\r
241 ((WEEKDAY) == RTC_Weekday_Friday) || \
\r
242 ((WEEKDAY) == RTC_Weekday_Saturday) || \
\r
243 ((WEEKDAY) == RTC_Weekday_Sunday))
\r
250 /** @defgroup RTC_AlarmDateWeekDay_Definitions
\r
253 #define RTC_AlarmDateWeekDaySel_Date ((uint32_t)0x00000000)
\r
254 #define RTC_AlarmDateWeekDaySel_WeekDay ((uint32_t)0x40000000)
\r
256 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_AlarmDateWeekDaySel_Date) || \
\r
257 ((SEL) == RTC_AlarmDateWeekDaySel_WeekDay))
\r
264 /** @defgroup RTC_AlarmMask_Definitions
\r
267 #define RTC_AlarmMask_None ((uint32_t)0x00000000)
\r
268 #define RTC_AlarmMask_DateWeekDay ((uint32_t)0x80000000)
\r
269 #define RTC_AlarmMask_Hours ((uint32_t)0x00800000)
\r
270 #define RTC_AlarmMask_Minutes ((uint32_t)0x00008000)
\r
271 #define RTC_AlarmMask_Seconds ((uint32_t)0x00000080)
\r
272 #define RTC_AlarmMask_All ((uint32_t)0x80808080)
\r
273 #define IS_ALARM_MASK(MASK) (((MASK) & 0x7F7F7F7F) == (uint32_t)RESET)
\r
279 /** @defgroup RTC_Alarms_Definitions
\r
282 #define RTC_Alarm_A ((uint32_t)0x00000100)
\r
283 #define RTC_Alarm_B ((uint32_t)0x00000200)
\r
284 #define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_Alarm_A) || ((ALARM) == RTC_Alarm_B))
\r
285 #define IS_RTC_CMD_ALARM(ALARM) (((ALARM) & (RTC_Alarm_A | RTC_Alarm_B)) != (uint32_t)RESET)
\r
291 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions
\r
294 #define RTC_AlarmSubSecondMask_All ((uint32_t)0x00000000) /*!< All Alarm SS fields are masked.
\r
295 There is no comparison on sub seconds
\r
297 #define RTC_AlarmSubSecondMask_SS14_1 ((uint32_t)0x01000000) /*!< SS[14:1] are don't care in Alarm
\r
298 comparison. Only SS[0] is compared. */
\r
299 #define RTC_AlarmSubSecondMask_SS14_2 ((uint32_t)0x02000000) /*!< SS[14:2] are don't care in Alarm
\r
300 comparison. Only SS[1:0] are compared */
\r
301 #define RTC_AlarmSubSecondMask_SS14_3 ((uint32_t)0x03000000) /*!< SS[14:3] are don't care in Alarm
\r
302 comparison. Only SS[2:0] are compared */
\r
303 #define RTC_AlarmSubSecondMask_SS14_4 ((uint32_t)0x04000000) /*!< SS[14:4] are don't care in Alarm
\r
304 comparison. Only SS[3:0] are compared */
\r
305 #define RTC_AlarmSubSecondMask_SS14_5 ((uint32_t)0x05000000) /*!< SS[14:5] are don't care in Alarm
\r
306 comparison. Only SS[4:0] are compared */
\r
307 #define RTC_AlarmSubSecondMask_SS14_6 ((uint32_t)0x06000000) /*!< SS[14:6] are don't care in Alarm
\r
308 comparison. Only SS[5:0] are compared */
\r
309 #define RTC_AlarmSubSecondMask_SS14_7 ((uint32_t)0x07000000) /*!< SS[14:7] are don't care in Alarm
\r
310 comparison. Only SS[6:0] are compared */
\r
311 #define RTC_AlarmSubSecondMask_SS14_8 ((uint32_t)0x08000000) /*!< SS[14:8] are don't care in Alarm
\r
312 comparison. Only SS[7:0] are compared */
\r
313 #define RTC_AlarmSubSecondMask_SS14_9 ((uint32_t)0x09000000) /*!< SS[14:9] are don't care in Alarm
\r
314 comparison. Only SS[8:0] are compared */
\r
315 #define RTC_AlarmSubSecondMask_SS14_10 ((uint32_t)0x0A000000) /*!< SS[14:10] are don't care in Alarm
\r
316 comparison. Only SS[9:0] are compared */
\r
317 #define RTC_AlarmSubSecondMask_SS14_11 ((uint32_t)0x0B000000) /*!< SS[14:11] are don't care in Alarm
\r
318 comparison. Only SS[10:0] are compared */
\r
319 #define RTC_AlarmSubSecondMask_SS14_12 ((uint32_t)0x0C000000) /*!< SS[14:12] are don't care in Alarm
\r
320 comparison.Only SS[11:0] are compared */
\r
321 #define RTC_AlarmSubSecondMask_SS14_13 ((uint32_t)0x0D000000) /*!< SS[14:13] are don't care in Alarm
\r
322 comparison. Only SS[12:0] are compared */
\r
323 #define RTC_AlarmSubSecondMask_SS14 ((uint32_t)0x0E000000) /*!< SS[14] is don't care in Alarm
\r
324 comparison.Only SS[13:0] are compared */
\r
325 #define RTC_AlarmSubSecondMask_None ((uint32_t)0x0F000000) /*!< SS[14:0] are compared and must match
\r
326 to activate alarm. */
\r
327 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == RTC_AlarmSubSecondMask_All) || \
\r
328 ((MASK) == RTC_AlarmSubSecondMask_SS14_1) || \
\r
329 ((MASK) == RTC_AlarmSubSecondMask_SS14_2) || \
\r
330 ((MASK) == RTC_AlarmSubSecondMask_SS14_3) || \
\r
331 ((MASK) == RTC_AlarmSubSecondMask_SS14_4) || \
\r
332 ((MASK) == RTC_AlarmSubSecondMask_SS14_5) || \
\r
333 ((MASK) == RTC_AlarmSubSecondMask_SS14_6) || \
\r
334 ((MASK) == RTC_AlarmSubSecondMask_SS14_7) || \
\r
335 ((MASK) == RTC_AlarmSubSecondMask_SS14_8) || \
\r
336 ((MASK) == RTC_AlarmSubSecondMask_SS14_9) || \
\r
337 ((MASK) == RTC_AlarmSubSecondMask_SS14_10) || \
\r
338 ((MASK) == RTC_AlarmSubSecondMask_SS14_11) || \
\r
339 ((MASK) == RTC_AlarmSubSecondMask_SS14_12) || \
\r
340 ((MASK) == RTC_AlarmSubSecondMask_SS14_13) || \
\r
341 ((MASK) == RTC_AlarmSubSecondMask_SS14) || \
\r
342 ((MASK) == RTC_AlarmSubSecondMask_None))
\r
347 /** @defgroup RTC_Alarm_Sub_Seconds_Value
\r
351 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= 0x00007FFF)
\r
357 /** @defgroup RTC_Wakeup_Timer_Definitions
\r
360 #define RTC_WakeUpClock_RTCCLK_Div16 ((uint32_t)0x00000000)
\r
361 #define RTC_WakeUpClock_RTCCLK_Div8 ((uint32_t)0x00000001)
\r
362 #define RTC_WakeUpClock_RTCCLK_Div4 ((uint32_t)0x00000002)
\r
363 #define RTC_WakeUpClock_RTCCLK_Div2 ((uint32_t)0x00000003)
\r
364 #define RTC_WakeUpClock_CK_SPRE_16bits ((uint32_t)0x00000004)
\r
365 #define RTC_WakeUpClock_CK_SPRE_17bits ((uint32_t)0x00000006)
\r
366 #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WakeUpClock_RTCCLK_Div16) || \
\r
367 ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div8) || \
\r
368 ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div4) || \
\r
369 ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div2) || \
\r
370 ((CLOCK) == RTC_WakeUpClock_CK_SPRE_16bits) || \
\r
371 ((CLOCK) == RTC_WakeUpClock_CK_SPRE_17bits))
\r
372 #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= 0xFFFF)
\r
377 /** @defgroup RTC_Time_Stamp_Edges_definitions
\r
380 #define RTC_TimeStampEdge_Rising ((uint32_t)0x00000000)
\r
381 #define RTC_TimeStampEdge_Falling ((uint32_t)0x00000008)
\r
382 #define IS_RTC_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TimeStampEdge_Rising) || \
\r
383 ((EDGE) == RTC_TimeStampEdge_Falling))
\r
388 /** @defgroup RTC_Output_selection_Definitions
\r
391 #define RTC_Output_Disable ((uint32_t)0x00000000)
\r
392 #define RTC_Output_AlarmA ((uint32_t)0x00200000)
\r
393 #define RTC_Output_AlarmB ((uint32_t)0x00400000)
\r
394 #define RTC_Output_WakeUp ((uint32_t)0x00600000)
\r
396 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_Output_Disable) || \
\r
397 ((OUTPUT) == RTC_Output_AlarmA) || \
\r
398 ((OUTPUT) == RTC_Output_AlarmB) || \
\r
399 ((OUTPUT) == RTC_Output_WakeUp))
\r
405 /** @defgroup RTC_Output_Polarity_Definitions
\r
408 #define RTC_OutputPolarity_High ((uint32_t)0x00000000)
\r
409 #define RTC_OutputPolarity_Low ((uint32_t)0x00100000)
\r
410 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OutputPolarity_High) || \
\r
411 ((POL) == RTC_OutputPolarity_Low))
\r
417 /** @defgroup RTC_Digital_Calibration_Definitions
\r
420 #define RTC_CalibSign_Positive ((uint32_t)0x00000000)
\r
421 #define RTC_CalibSign_Negative ((uint32_t)0x00000080)
\r
422 #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CalibSign_Positive) || \
\r
423 ((SIGN) == RTC_CalibSign_Negative))
\r
424 #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20)
\r
430 /** @defgroup RTC_Calib_Output_selection_Definitions
\r
433 #define RTC_CalibOutput_512Hz ((uint32_t)0x00000000)
\r
434 #define RTC_CalibOutput_1Hz ((uint32_t)0x00080000)
\r
435 #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CalibOutput_512Hz) || \
\r
436 ((OUTPUT) == RTC_CalibOutput_1Hz))
\r
441 /** @defgroup RTC_Smooth_calib_period_Definitions
\r
444 #define RTC_SmoothCalibPeriod_32sec ((uint32_t)0x00000000) /*!< if RTCCLK = 32768 Hz, Smooth calibation
\r
445 period is 32s, else 2exp20 RTCCLK seconds */
\r
446 #define RTC_SmoothCalibPeriod_16sec ((uint32_t)0x00002000) /*!< if RTCCLK = 32768 Hz, Smooth calibation
\r
447 period is 16s, else 2exp19 RTCCLK seconds */
\r
448 #define RTC_SmoothCalibPeriod_8sec ((uint32_t)0x00004000) /*!< if RTCCLK = 32768 Hz, Smooth calibation
\r
449 period is 8s, else 2exp18 RTCCLK seconds */
\r
450 #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SmoothCalibPeriod_32sec) || \
\r
451 ((PERIOD) == RTC_SmoothCalibPeriod_16sec) || \
\r
452 ((PERIOD) == RTC_SmoothCalibPeriod_8sec))
\r
458 /** @defgroup RTC_Smooth_calib_Plus_pulses_Definitions
\r
461 #define RTC_SmoothCalibPlusPulses_Set ((uint32_t)0x00008000) /*!< The number of RTCCLK pulses added
\r
462 during a X -second window = Y - CALM[8:0].
\r
463 with Y = 512, 256, 128 when X = 32, 16, 8 */
\r
464 #define RTC_SmoothCalibPlusPulses_Reset ((uint32_t)0x00000000) /*!< The number of RTCCLK pulses subbstited
\r
465 during a 32-second window = CALM[8:0]. */
\r
466 #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SmoothCalibPlusPulses_Set) || \
\r
467 ((PLUS) == RTC_SmoothCalibPlusPulses_Reset))
\r
473 /** @defgroup RTC_Smooth_calib_Minus_pulses_Definitions
\r
476 #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= 0x000001FF)
\r
482 /** @defgroup RTC_DayLightSaving_Definitions
\r
485 #define RTC_DayLightSaving_SUB1H ((uint32_t)0x00020000)
\r
486 #define RTC_DayLightSaving_ADD1H ((uint32_t)0x00010000)
\r
487 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DayLightSaving_SUB1H) || \
\r
488 ((SAVE) == RTC_DayLightSaving_ADD1H))
\r
490 #define RTC_StoreOperation_Reset ((uint32_t)0x00000000)
\r
491 #define RTC_StoreOperation_Set ((uint32_t)0x00040000)
\r
492 #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_StoreOperation_Reset) || \
\r
493 ((OPERATION) == RTC_StoreOperation_Set))
\r
498 /** @defgroup RTC_Tamper_Trigger_Definitions
\r
501 #define RTC_TamperTrigger_RisingEdge ((uint32_t)0x00000000)
\r
502 #define RTC_TamperTrigger_FallingEdge ((uint32_t)0x00000001)
\r
503 #define RTC_TamperTrigger_LowLevel ((uint32_t)0x00000000)
\r
504 #define RTC_TamperTrigger_HighLevel ((uint32_t)0x00000001)
\r
505 #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TamperTrigger_RisingEdge) || \
\r
506 ((TRIGGER) == RTC_TamperTrigger_FallingEdge) || \
\r
507 ((TRIGGER) == RTC_TamperTrigger_LowLevel) || \
\r
508 ((TRIGGER) == RTC_TamperTrigger_HighLevel))
\r
514 /** @defgroup RTC_Tamper_Filter_Definitions
\r
517 #define RTC_TamperFilter_Disable ((uint32_t)0x00000000) /*!< Tamper filter is disabled */
\r
519 #define RTC_TamperFilter_2Sample ((uint32_t)0x00000800) /*!< Tamper is activated after 2
\r
520 consecutive samples at the active level */
\r
521 #define RTC_TamperFilter_4Sample ((uint32_t)0x00001000) /*!< Tamper is activated after 4
\r
522 consecutive samples at the active level */
\r
523 #define RTC_TamperFilter_8Sample ((uint32_t)0x00001800) /*!< Tamper is activated after 8
\r
524 consecutive samples at the active leve. */
\r
525 #define IS_RTC_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TamperFilter_Disable) || \
\r
526 ((FILTER) == RTC_TamperFilter_2Sample) || \
\r
527 ((FILTER) == RTC_TamperFilter_4Sample) || \
\r
528 ((FILTER) == RTC_TamperFilter_8Sample))
\r
533 /** @defgroup RTC_Tamper_Sampling_Frequencies_Definitions
\r
536 #define RTC_TamperSamplingFreq_RTCCLK_Div32768 ((uint32_t)0x00000000) /*!< Each of the tamper inputs are sampled
\r
537 with a frequency = RTCCLK / 32768 */
\r
538 #define RTC_TamperSamplingFreq_RTCCLK_Div16384 ((uint32_t)0x000000100) /*!< Each of the tamper inputs are sampled
\r
539 with a frequency = RTCCLK / 16384 */
\r
540 #define RTC_TamperSamplingFreq_RTCCLK_Div8192 ((uint32_t)0x00000200) /*!< Each of the tamper inputs are sampled
\r
541 with a frequency = RTCCLK / 8192 */
\r
542 #define RTC_TamperSamplingFreq_RTCCLK_Div4096 ((uint32_t)0x00000300) /*!< Each of the tamper inputs are sampled
\r
543 with a frequency = RTCCLK / 4096 */
\r
544 #define RTC_TamperSamplingFreq_RTCCLK_Div2048 ((uint32_t)0x00000400) /*!< Each of the tamper inputs are sampled
\r
545 with a frequency = RTCCLK / 2048 */
\r
546 #define RTC_TamperSamplingFreq_RTCCLK_Div1024 ((uint32_t)0x00000500) /*!< Each of the tamper inputs are sampled
\r
547 with a frequency = RTCCLK / 1024 */
\r
548 #define RTC_TamperSamplingFreq_RTCCLK_Div512 ((uint32_t)0x00000600) /*!< Each of the tamper inputs are sampled
\r
549 with a frequency = RTCCLK / 512 */
\r
550 #define RTC_TamperSamplingFreq_RTCCLK_Div256 ((uint32_t)0x00000700) /*!< Each of the tamper inputs are sampled
\r
551 with a frequency = RTCCLK / 256 */
\r
552 #define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div32768) || \
\r
553 ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div16384) || \
\r
554 ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div8192) || \
\r
555 ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div4096) || \
\r
556 ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div2048) || \
\r
557 ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div1024) || \
\r
558 ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div512) || \
\r
559 ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div256))
\r
565 /** @defgroup RTC_Tamper_Pin_Precharge_Duration_Definitions
\r
568 #define RTC_TamperPrechargeDuration_1RTCCLK ((uint32_t)0x00000000) /*!< Tamper pins are pre-charged before
\r
569 sampling during 1 RTCCLK cycle */
\r
570 #define RTC_TamperPrechargeDuration_2RTCCLK ((uint32_t)0x00002000) /*!< Tamper pins are pre-charged before
\r
571 sampling during 2 RTCCLK cycles */
\r
572 #define RTC_TamperPrechargeDuration_4RTCCLK ((uint32_t)0x00004000) /*!< Tamper pins are pre-charged before
\r
573 sampling during 4 RTCCLK cycles */
\r
574 #define RTC_TamperPrechargeDuration_8RTCCLK ((uint32_t)0x00006000) /*!< Tamper pins are pre-charged before
\r
575 sampling during 8 RTCCLK cycles */
\r
577 #define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TamperPrechargeDuration_1RTCCLK) || \
\r
578 ((DURATION) == RTC_TamperPrechargeDuration_2RTCCLK) || \
\r
579 ((DURATION) == RTC_TamperPrechargeDuration_4RTCCLK) || \
\r
580 ((DURATION) == RTC_TamperPrechargeDuration_8RTCCLK))
\r
585 /** @defgroup RTC_Tamper_Pins_Definitions
\r
588 #define RTC_Tamper_1 RTC_TAFCR_TAMP1E
\r
589 #define IS_RTC_TAMPER(TAMPER) (((TAMPER) == RTC_Tamper_1))
\r
595 /** @defgroup RTC_Tamper_Pin_Selection
\r
598 #define RTC_TamperPin_PC13 ((uint32_t)0x00000000)
\r
599 #define RTC_TamperPin_PI8 ((uint32_t)0x00010000)
\r
600 #define IS_RTC_TAMPER_PIN(PIN) (((PIN) == RTC_TamperPin_PC13) || \
\r
601 ((PIN) == RTC_TamperPin_PI8))
\r
606 /** @defgroup RTC_TimeStamp_Pin_Selection
\r
609 #define RTC_TimeStampPin_PC13 ((uint32_t)0x00000000)
\r
610 #define RTC_TimeStampPin_PI8 ((uint32_t)0x00020000)
\r
611 #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TimeStampPin_PC13) || \
\r
612 ((PIN) == RTC_TimeStampPin_PI8))
\r
617 /** @defgroup RTC_Output_Type_ALARM_OUT
\r
620 #define RTC_OutputType_OpenDrain ((uint32_t)0x00000000)
\r
621 #define RTC_OutputType_PushPull ((uint32_t)0x00040000)
\r
622 #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OutputType_OpenDrain) || \
\r
623 ((TYPE) == RTC_OutputType_PushPull))
\r
629 /** @defgroup RTC_Add_1_Second_Parameter_Definitions
\r
632 #define RTC_ShiftAdd1S_Reset ((uint32_t)0x00000000)
\r
633 #define RTC_ShiftAdd1S_Set ((uint32_t)0x80000000)
\r
634 #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_ShiftAdd1S_Reset) || \
\r
635 ((SEL) == RTC_ShiftAdd1S_Set))
\r
640 /** @defgroup RTC_Substract_Fraction_Of_Second_Value
\r
643 #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= 0x00007FFF)
\r
649 /** @defgroup RTC_Backup_Registers_Definitions
\r
653 #define RTC_BKP_DR0 ((uint32_t)0x00000000)
\r
654 #define RTC_BKP_DR1 ((uint32_t)0x00000001)
\r
655 #define RTC_BKP_DR2 ((uint32_t)0x00000002)
\r
656 #define RTC_BKP_DR3 ((uint32_t)0x00000003)
\r
657 #define RTC_BKP_DR4 ((uint32_t)0x00000004)
\r
658 #define RTC_BKP_DR5 ((uint32_t)0x00000005)
\r
659 #define RTC_BKP_DR6 ((uint32_t)0x00000006)
\r
660 #define RTC_BKP_DR7 ((uint32_t)0x00000007)
\r
661 #define RTC_BKP_DR8 ((uint32_t)0x00000008)
\r
662 #define RTC_BKP_DR9 ((uint32_t)0x00000009)
\r
663 #define RTC_BKP_DR10 ((uint32_t)0x0000000A)
\r
664 #define RTC_BKP_DR11 ((uint32_t)0x0000000B)
\r
665 #define RTC_BKP_DR12 ((uint32_t)0x0000000C)
\r
666 #define RTC_BKP_DR13 ((uint32_t)0x0000000D)
\r
667 #define RTC_BKP_DR14 ((uint32_t)0x0000000E)
\r
668 #define RTC_BKP_DR15 ((uint32_t)0x0000000F)
\r
669 #define RTC_BKP_DR16 ((uint32_t)0x00000010)
\r
670 #define RTC_BKP_DR17 ((uint32_t)0x00000011)
\r
671 #define RTC_BKP_DR18 ((uint32_t)0x00000012)
\r
672 #define RTC_BKP_DR19 ((uint32_t)0x00000013)
\r
673 #define IS_RTC_BKP(BKP) (((BKP) == RTC_BKP_DR0) || \
\r
674 ((BKP) == RTC_BKP_DR1) || \
\r
675 ((BKP) == RTC_BKP_DR2) || \
\r
676 ((BKP) == RTC_BKP_DR3) || \
\r
677 ((BKP) == RTC_BKP_DR4) || \
\r
678 ((BKP) == RTC_BKP_DR5) || \
\r
679 ((BKP) == RTC_BKP_DR6) || \
\r
680 ((BKP) == RTC_BKP_DR7) || \
\r
681 ((BKP) == RTC_BKP_DR8) || \
\r
682 ((BKP) == RTC_BKP_DR9) || \
\r
683 ((BKP) == RTC_BKP_DR10) || \
\r
684 ((BKP) == RTC_BKP_DR11) || \
\r
685 ((BKP) == RTC_BKP_DR12) || \
\r
686 ((BKP) == RTC_BKP_DR13) || \
\r
687 ((BKP) == RTC_BKP_DR14) || \
\r
688 ((BKP) == RTC_BKP_DR15) || \
\r
689 ((BKP) == RTC_BKP_DR16) || \
\r
690 ((BKP) == RTC_BKP_DR17) || \
\r
691 ((BKP) == RTC_BKP_DR18) || \
\r
692 ((BKP) == RTC_BKP_DR19))
\r
697 /** @defgroup RTC_Input_parameter_format_definitions
\r
700 #define RTC_Format_BIN ((uint32_t)0x000000000)
\r
701 #define RTC_Format_BCD ((uint32_t)0x000000001)
\r
702 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_Format_BIN) || ((FORMAT) == RTC_Format_BCD))
\r
708 /** @defgroup RTC_Flags_Definitions
\r
711 #define RTC_FLAG_RECALPF ((uint32_t)0x00010000)
\r
712 #define RTC_FLAG_TAMP1F ((uint32_t)0x00002000)
\r
713 #define RTC_FLAG_TSOVF ((uint32_t)0x00001000)
\r
714 #define RTC_FLAG_TSF ((uint32_t)0x00000800)
\r
715 #define RTC_FLAG_WUTF ((uint32_t)0x00000400)
\r
716 #define RTC_FLAG_ALRBF ((uint32_t)0x00000200)
\r
717 #define RTC_FLAG_ALRAF ((uint32_t)0x00000100)
\r
718 #define RTC_FLAG_INITF ((uint32_t)0x00000040)
\r
719 #define RTC_FLAG_RSF ((uint32_t)0x00000020)
\r
720 #define RTC_FLAG_INITS ((uint32_t)0x00000010)
\r
721 #define RTC_FLAG_SHPF ((uint32_t)0x00000008)
\r
722 #define RTC_FLAG_WUTWF ((uint32_t)0x00000004)
\r
723 #define RTC_FLAG_ALRBWF ((uint32_t)0x00000002)
\r
724 #define RTC_FLAG_ALRAWF ((uint32_t)0x00000001)
\r
725 #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_TSOVF) || ((FLAG) == RTC_FLAG_TSF) || \
\r
726 ((FLAG) == RTC_FLAG_WUTF) || ((FLAG) == RTC_FLAG_ALRBF) || \
\r
727 ((FLAG) == RTC_FLAG_ALRAF) || ((FLAG) == RTC_FLAG_INITF) || \
\r
728 ((FLAG) == RTC_FLAG_RSF) || ((FLAG) == RTC_FLAG_WUTWF) || \
\r
729 ((FLAG) == RTC_FLAG_ALRBWF) || ((FLAG) == RTC_FLAG_ALRAWF) || \
\r
730 ((FLAG) == RTC_FLAG_TAMP1F) || ((FLAG) == RTC_FLAG_RECALPF) || \
\r
731 ((FLAG) == RTC_FLAG_SHPF))
\r
732 #define IS_RTC_CLEAR_FLAG(FLAG) (((FLAG) != (uint32_t)RESET) && (((FLAG) & 0xFFFF00DF) == (uint32_t)RESET))
\r
737 /** @defgroup RTC_Interrupts_Definitions
\r
740 #define RTC_IT_TS ((uint32_t)0x00008000)
\r
741 #define RTC_IT_WUT ((uint32_t)0x00004000)
\r
742 #define RTC_IT_ALRB ((uint32_t)0x00002000)
\r
743 #define RTC_IT_ALRA ((uint32_t)0x00001000)
\r
744 #define RTC_IT_TAMP ((uint32_t)0x00000004) /* Used only to Enable the Tamper Interrupt */
\r
745 #define RTC_IT_TAMP1 ((uint32_t)0x00020000)
\r
747 #define IS_RTC_CONFIG_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFF0FFB) == (uint32_t)RESET))
\r
748 #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_TS) || ((IT) == RTC_IT_WUT) || \
\r
749 ((IT) == RTC_IT_ALRB) || ((IT) == RTC_IT_ALRA) || \
\r
750 ((IT) == RTC_IT_TAMP1))
\r
751 #define IS_RTC_CLEAR_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFD0FFF) == (uint32_t)RESET))
\r
757 /** @defgroup RTC_Legacy
\r
760 #define RTC_DigitalCalibConfig RTC_CoarseCalibConfig
\r
761 #define RTC_DigitalCalibCmd RTC_CoarseCalibCmd
\r
771 /* Exported macro ------------------------------------------------------------*/
\r
772 /* Exported functions --------------------------------------------------------*/
\r
774 /* Function used to set the RTC configuration to the default reset state *****/
\r
775 ErrorStatus RTC_DeInit(void);
\r
777 /* Initialization and Configuration functions *********************************/
\r
778 ErrorStatus RTC_Init(RTC_InitTypeDef* RTC_InitStruct);
\r
779 void RTC_StructInit(RTC_InitTypeDef* RTC_InitStruct);
\r
780 void RTC_WriteProtectionCmd(FunctionalState NewState);
\r
781 ErrorStatus RTC_EnterInitMode(void);
\r
782 void RTC_ExitInitMode(void);
\r
783 ErrorStatus RTC_WaitForSynchro(void);
\r
784 ErrorStatus RTC_RefClockCmd(FunctionalState NewState);
\r
785 void RTC_BypassShadowCmd(FunctionalState NewState);
\r
787 /* Time and Date configuration functions **************************************/
\r
788 ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct);
\r
789 void RTC_TimeStructInit(RTC_TimeTypeDef* RTC_TimeStruct);
\r
790 void RTC_GetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct);
\r
791 uint32_t RTC_GetSubSecond(void);
\r
792 ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct);
\r
793 void RTC_DateStructInit(RTC_DateTypeDef* RTC_DateStruct);
\r
794 void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct);
\r
796 /* Alarms (Alarm A and Alarm B) configuration functions **********************/
\r
797 void RTC_SetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct);
\r
798 void RTC_AlarmStructInit(RTC_AlarmTypeDef* RTC_AlarmStruct);
\r
799 void RTC_GetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct);
\r
800 ErrorStatus RTC_AlarmCmd(uint32_t RTC_Alarm, FunctionalState NewState);
\r
801 void RTC_AlarmSubSecondConfig(uint32_t RTC_Alarm, uint32_t RTC_AlarmSubSecondValue, uint32_t RTC_AlarmSubSecondMask);
\r
802 uint32_t RTC_GetAlarmSubSecond(uint32_t RTC_Alarm);
\r
804 /* WakeUp Timer configuration functions ***************************************/
\r
805 void RTC_WakeUpClockConfig(uint32_t RTC_WakeUpClock);
\r
806 void RTC_SetWakeUpCounter(uint32_t RTC_WakeUpCounter);
\r
807 uint32_t RTC_GetWakeUpCounter(void);
\r
808 ErrorStatus RTC_WakeUpCmd(FunctionalState NewState);
\r
810 /* Daylight Saving configuration functions ************************************/
\r
811 void RTC_DayLightSavingConfig(uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation);
\r
812 uint32_t RTC_GetStoreOperation(void);
\r
814 /* Output pin Configuration function ******************************************/
\r
815 void RTC_OutputConfig(uint32_t RTC_Output, uint32_t RTC_OutputPolarity);
\r
817 /* Digital Calibration configuration functions *********************************/
\r
818 ErrorStatus RTC_CoarseCalibConfig(uint32_t RTC_CalibSign, uint32_t Value);
\r
819 ErrorStatus RTC_CoarseCalibCmd(FunctionalState NewState);
\r
820 void RTC_CalibOutputCmd(FunctionalState NewState);
\r
821 void RTC_CalibOutputConfig(uint32_t RTC_CalibOutput);
\r
822 ErrorStatus RTC_SmoothCalibConfig(uint32_t RTC_SmoothCalibPeriod,
\r
823 uint32_t RTC_SmoothCalibPlusPulses,
\r
824 uint32_t RTC_SmouthCalibMinusPulsesValue);
\r
826 /* TimeStamp configuration functions ******************************************/
\r
827 void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState);
\r
828 void RTC_GetTimeStamp(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_StampTimeStruct,
\r
829 RTC_DateTypeDef* RTC_StampDateStruct);
\r
830 uint32_t RTC_GetTimeStampSubSecond(void);
\r
832 /* Tampers configuration functions ********************************************/
\r
833 void RTC_TamperTriggerConfig(uint32_t RTC_Tamper, uint32_t RTC_TamperTrigger);
\r
834 void RTC_TamperCmd(uint32_t RTC_Tamper, FunctionalState NewState);
\r
835 void RTC_TamperFilterConfig(uint32_t RTC_TamperFilter);
\r
836 void RTC_TamperSamplingFreqConfig(uint32_t RTC_TamperSamplingFreq);
\r
837 void RTC_TamperPinsPrechargeDuration(uint32_t RTC_TamperPrechargeDuration);
\r
838 void RTC_TimeStampOnTamperDetectionCmd(FunctionalState NewState);
\r
839 void RTC_TamperPullUpCmd(FunctionalState NewState);
\r
841 /* Backup Data Registers configuration functions ******************************/
\r
842 void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data);
\r
843 uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR);
\r
845 /* RTC Tamper and TimeStamp Pins Selection and Output Type Config configuration
\r
846 functions ******************************************************************/
\r
847 void RTC_TamperPinSelection(uint32_t RTC_TamperPin);
\r
848 void RTC_TimeStampPinSelection(uint32_t RTC_TimeStampPin);
\r
849 void RTC_OutputTypeConfig(uint32_t RTC_OutputType);
\r
851 /* RTC_Shift_control_synchonisation_functions *********************************/
\r
852 ErrorStatus RTC_SynchroShiftConfig(uint32_t RTC_ShiftAdd1S, uint32_t RTC_ShiftSubFS);
\r
854 /* Interrupts and flags management functions **********************************/
\r
855 void RTC_ITConfig(uint32_t RTC_IT, FunctionalState NewState);
\r
856 FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG);
\r
857 void RTC_ClearFlag(uint32_t RTC_FLAG);
\r
858 ITStatus RTC_GetITStatus(uint32_t RTC_IT);
\r
859 void RTC_ClearITPendingBit(uint32_t RTC_IT);
\r
865 #endif /*__STM32F4xx_RTC_H */
\r
875 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
\r