30 #ifndef __STM32F2xx_RTC_H
31 #define __STM32F2xx_RTC_H
38 #include "stm32f2xx.h"
55 uint32_t RTC_HourFormat;
58 uint32_t RTC_AsynchPrediv;
61 uint32_t RTC_SynchPrediv;
110 uint32_t RTC_AlarmMask;
113 uint32_t RTC_AlarmDateWeekDaySel;
116 uint8_t RTC_AlarmDateWeekDay;
133 #define RTC_HourFormat_24 ((uint32_t)0x00000000)
134 #define RTC_HourFormat_12 ((uint32_t)0x00000040)
135 #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HourFormat_12) || \
136 ((FORMAT) == RTC_HourFormat_24))
144 #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7F)
154 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x1FFF)
163 #define IS_RTC_HOUR12(HOUR) (((HOUR) > 0) && ((HOUR) <= 12))
164 #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23)
165 #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59)
166 #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59)
175 #define RTC_H12_AM ((uint8_t)0x00)
176 #define RTC_H12_PM ((uint8_t)0x40)
177 #define IS_RTC_H12(PM) (((PM) == RTC_H12_AM) || ((PM) == RTC_H12_PM))
186 #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99)
197 #define RTC_Month_January ((uint8_t)0x01)
198 #define RTC_Month_February ((uint8_t)0x02)
199 #define RTC_Month_March ((uint8_t)0x03)
200 #define RTC_Month_April ((uint8_t)0x04)
201 #define RTC_Month_May ((uint8_t)0x05)
202 #define RTC_Month_June ((uint8_t)0x06)
203 #define RTC_Month_July ((uint8_t)0x07)
204 #define RTC_Month_August ((uint8_t)0x08)
205 #define RTC_Month_September ((uint8_t)0x09)
206 #define RTC_Month_October ((uint8_t)0x10)
207 #define RTC_Month_November ((uint8_t)0x11)
208 #define RTC_Month_December ((uint8_t)0x12)
209 #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1) && ((MONTH) <= 12))
210 #define IS_RTC_DATE(DATE) (((DATE) >= 1) && ((DATE) <= 31))
220 #define RTC_Weekday_Monday ((uint8_t)0x01)
221 #define RTC_Weekday_Tuesday ((uint8_t)0x02)
222 #define RTC_Weekday_Wednesday ((uint8_t)0x03)
223 #define RTC_Weekday_Thursday ((uint8_t)0x04)
224 #define RTC_Weekday_Friday ((uint8_t)0x05)
225 #define RTC_Weekday_Saturday ((uint8_t)0x06)
226 #define RTC_Weekday_Sunday ((uint8_t)0x07)
227 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \
228 ((WEEKDAY) == RTC_Weekday_Tuesday) || \
229 ((WEEKDAY) == RTC_Weekday_Wednesday) || \
230 ((WEEKDAY) == RTC_Weekday_Thursday) || \
231 ((WEEKDAY) == RTC_Weekday_Friday) || \
232 ((WEEKDAY) == RTC_Weekday_Saturday) || \
233 ((WEEKDAY) == RTC_Weekday_Sunday))
242 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0) && ((DATE) <= 31))
243 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \
244 ((WEEKDAY) == RTC_Weekday_Tuesday) || \
245 ((WEEKDAY) == RTC_Weekday_Wednesday) || \
246 ((WEEKDAY) == RTC_Weekday_Thursday) || \
247 ((WEEKDAY) == RTC_Weekday_Friday) || \
248 ((WEEKDAY) == RTC_Weekday_Saturday) || \
249 ((WEEKDAY) == RTC_Weekday_Sunday))
259 #define RTC_AlarmDateWeekDaySel_Date ((uint32_t)0x00000000)
260 #define RTC_AlarmDateWeekDaySel_WeekDay ((uint32_t)0x40000000)
262 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_AlarmDateWeekDaySel_Date) || \
263 ((SEL) == RTC_AlarmDateWeekDaySel_WeekDay))
273 #define RTC_AlarmMask_None ((uint32_t)0x00000000)
274 #define RTC_AlarmMask_DateWeekDay ((uint32_t)0x80000000)
275 #define RTC_AlarmMask_Hours ((uint32_t)0x00800000)
276 #define RTC_AlarmMask_Minutes ((uint32_t)0x00008000)
277 #define RTC_AlarmMask_Seconds ((uint32_t)0x00000080)
278 #define RTC_AlarmMask_All ((uint32_t)0x80808080)
279 #define IS_ALARM_MASK(MASK) (((MASK) & 0x7F7F7F7F) == (uint32_t)RESET)
288 #define RTC_Alarm_A ((uint32_t)0x00000100)
289 #define RTC_Alarm_B ((uint32_t)0x00000200)
290 #define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_Alarm_A) || ((ALARM) == RTC_Alarm_B))
291 #define IS_RTC_CMD_ALARM(ALARM) (((ALARM) & (RTC_Alarm_A | RTC_Alarm_B)) != (uint32_t)RESET)
300 #define RTC_WakeUpClock_RTCCLK_Div16 ((uint32_t)0x00000000)
301 #define RTC_WakeUpClock_RTCCLK_Div8 ((uint32_t)0x00000001)
302 #define RTC_WakeUpClock_RTCCLK_Div4 ((uint32_t)0x00000002)
303 #define RTC_WakeUpClock_RTCCLK_Div2 ((uint32_t)0x00000003)
304 #define RTC_WakeUpClock_CK_SPRE_16bits ((uint32_t)0x00000004)
305 #define RTC_WakeUpClock_CK_SPRE_17bits ((uint32_t)0x00000006)
306 #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WakeUpClock_RTCCLK_Div16) || \
307 ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div8) || \
308 ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div4) || \
309 ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div2) || \
310 ((CLOCK) == RTC_WakeUpClock_CK_SPRE_16bits) || \
311 ((CLOCK) == RTC_WakeUpClock_CK_SPRE_17bits))
312 #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= 0xFFFF)
320 #define RTC_TimeStampEdge_Rising ((uint32_t)0x00000000)
321 #define RTC_TimeStampEdge_Falling ((uint32_t)0x00000008)
322 #define IS_RTC_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TimeStampEdge_Rising) || \
323 ((EDGE) == RTC_TimeStampEdge_Falling))
331 #define RTC_Output_Disable ((uint32_t)0x00000000)
332 #define RTC_Output_AlarmA ((uint32_t)0x00200000)
333 #define RTC_Output_AlarmB ((uint32_t)0x00400000)
334 #define RTC_Output_WakeUp ((uint32_t)0x00600000)
336 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_Output_Disable) || \
337 ((OUTPUT) == RTC_Output_AlarmA) || \
338 ((OUTPUT) == RTC_Output_AlarmB) || \
339 ((OUTPUT) == RTC_Output_WakeUp))
348 #define RTC_OutputPolarity_High ((uint32_t)0x00000000)
349 #define RTC_OutputPolarity_Low ((uint32_t)0x00100000)
350 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OutputPolarity_High) || \
351 ((POL) == RTC_OutputPolarity_Low))
360 #define RTC_CalibSign_Positive ((uint32_t)0x00000000)
361 #define RTC_CalibSign_Negative ((uint32_t)0x00000080)
362 #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CalibSign_Positive) || \
363 ((SIGN) == RTC_CalibSign_Negative))
364 #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20)
374 #define RTC_DayLightSaving_SUB1H ((uint32_t)0x00020000)
375 #define RTC_DayLightSaving_ADD1H ((uint32_t)0x00010000)
376 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DayLightSaving_SUB1H) || \
377 ((SAVE) == RTC_DayLightSaving_ADD1H))
379 #define RTC_StoreOperation_Reset ((uint32_t)0x00000000)
380 #define RTC_StoreOperation_Set ((uint32_t)0x00040000)
381 #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_StoreOperation_Reset) || \
382 ((OPERATION) == RTC_StoreOperation_Set))
390 #define RTC_TamperTrigger_RisingEdge ((uint32_t)0x00000000)
391 #define RTC_TamperTrigger_FallingEdge ((uint32_t)0x00000001)
392 #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TamperTrigger_RisingEdge) || \
393 ((TRIGGER) == RTC_TamperTrigger_FallingEdge))
402 #define RTC_Tamper_1 RTC_TAFCR_TAMP1E
403 #define IS_RTC_TAMPER(TAMPER) (((TAMPER) == RTC_Tamper_1))
412 #define RTC_TamperPin_PC13 ((uint32_t)0x00000000)
413 #define RTC_TamperPin_PI8 ((uint32_t)0x00010000)
414 #define IS_RTC_TAMPER_PIN(PIN) (((PIN) == RTC_TamperPin_PC13) || \
415 ((PIN) == RTC_TamperPin_PI8))
423 #define RTC_TimeStampPin_PC13 ((uint32_t)0x00000000)
424 #define RTC_TimeStampPin_PI8 ((uint32_t)0x00020000)
425 #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TimeStampPin_PC13) || \
426 ((PIN) == RTC_TimeStampPin_PI8))
434 #define RTC_OutputType_OpenDrain ((uint32_t)0x00000000)
435 #define RTC_OutputType_PushPull ((uint32_t)0x00040000)
436 #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OutputType_OpenDrain) || \
437 ((TYPE) == RTC_OutputType_PushPull))
447 #define RTC_BKP_DR0 ((uint32_t)0x00000000)
448 #define RTC_BKP_DR1 ((uint32_t)0x00000001)
449 #define RTC_BKP_DR2 ((uint32_t)0x00000002)
450 #define RTC_BKP_DR3 ((uint32_t)0x00000003)
451 #define RTC_BKP_DR4 ((uint32_t)0x00000004)
452 #define RTC_BKP_DR5 ((uint32_t)0x00000005)
453 #define RTC_BKP_DR6 ((uint32_t)0x00000006)
454 #define RTC_BKP_DR7 ((uint32_t)0x00000007)
455 #define RTC_BKP_DR8 ((uint32_t)0x00000008)
456 #define RTC_BKP_DR9 ((uint32_t)0x00000009)
457 #define RTC_BKP_DR10 ((uint32_t)0x0000000A)
458 #define RTC_BKP_DR11 ((uint32_t)0x0000000B)
459 #define RTC_BKP_DR12 ((uint32_t)0x0000000C)
460 #define RTC_BKP_DR13 ((uint32_t)0x0000000D)
461 #define RTC_BKP_DR14 ((uint32_t)0x0000000E)
462 #define RTC_BKP_DR15 ((uint32_t)0x0000000F)
463 #define RTC_BKP_DR16 ((uint32_t)0x00000010)
464 #define RTC_BKP_DR17 ((uint32_t)0x00000011)
465 #define RTC_BKP_DR18 ((uint32_t)0x00000012)
466 #define RTC_BKP_DR19 ((uint32_t)0x00000013)
467 #define IS_RTC_BKP(BKP) (((BKP) == RTC_BKP_DR0) || \
468 ((BKP) == RTC_BKP_DR1) || \
469 ((BKP) == RTC_BKP_DR2) || \
470 ((BKP) == RTC_BKP_DR3) || \
471 ((BKP) == RTC_BKP_DR4) || \
472 ((BKP) == RTC_BKP_DR5) || \
473 ((BKP) == RTC_BKP_DR6) || \
474 ((BKP) == RTC_BKP_DR7) || \
475 ((BKP) == RTC_BKP_DR8) || \
476 ((BKP) == RTC_BKP_DR9) || \
477 ((BKP) == RTC_BKP_DR10) || \
478 ((BKP) == RTC_BKP_DR11) || \
479 ((BKP) == RTC_BKP_DR12) || \
480 ((BKP) == RTC_BKP_DR13) || \
481 ((BKP) == RTC_BKP_DR14) || \
482 ((BKP) == RTC_BKP_DR15) || \
483 ((BKP) == RTC_BKP_DR16) || \
484 ((BKP) == RTC_BKP_DR17) || \
485 ((BKP) == RTC_BKP_DR18) || \
486 ((BKP) == RTC_BKP_DR19))
494 #define RTC_Format_BIN ((uint32_t)0x000000000)
495 #define RTC_Format_BCD ((uint32_t)0x000000001)
496 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_Format_BIN) || ((FORMAT) == RTC_Format_BCD))
505 #define RTC_FLAG_TAMP1F ((uint32_t)0x00002000)
506 #define RTC_FLAG_TSOVF ((uint32_t)0x00001000)
507 #define RTC_FLAG_TSF ((uint32_t)0x00000800)
508 #define RTC_FLAG_WUTF ((uint32_t)0x00000400)
509 #define RTC_FLAG_ALRBF ((uint32_t)0x00000200)
510 #define RTC_FLAG_ALRAF ((uint32_t)0x00000100)
511 #define RTC_FLAG_INITF ((uint32_t)0x00000040)
512 #define RTC_FLAG_RSF ((uint32_t)0x00000020)
513 #define RTC_FLAG_INITS ((uint32_t)0x00000010)
514 #define RTC_FLAG_WUTWF ((uint32_t)0x00000004)
515 #define RTC_FLAG_ALRBWF ((uint32_t)0x00000002)
516 #define RTC_FLAG_ALRAWF ((uint32_t)0x00000001)
517 #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_TSOVF) || ((FLAG) == RTC_FLAG_TSF) || \
518 ((FLAG) == RTC_FLAG_WUTF) || ((FLAG) == RTC_FLAG_ALRBF) || \
519 ((FLAG) == RTC_FLAG_ALRAF) || ((FLAG) == RTC_FLAG_INITF) || \
520 ((FLAG) == RTC_FLAG_RSF) || ((FLAG) == RTC_FLAG_WUTWF) || \
521 ((FLAG) == RTC_FLAG_ALRBWF) || ((FLAG) == RTC_FLAG_ALRAWF) || \
522 ((FLAG) == RTC_FLAG_TAMP1F))
523 #define IS_RTC_CLEAR_FLAG(FLAG) (((FLAG) != (uint32_t)RESET) && (((FLAG) & 0xFFFFC0DF) == (uint32_t)RESET))
532 #define RTC_IT_TS ((uint32_t)0x00008000)
533 #define RTC_IT_WUT ((uint32_t)0x00004000)
534 #define RTC_IT_ALRB ((uint32_t)0x00002000)
535 #define RTC_IT_ALRA ((uint32_t)0x00001000)
536 #define RTC_IT_TAMP ((uint32_t)0x00000004)
537 #define RTC_IT_TAMP1 ((uint32_t)0x00020000)
539 #define IS_RTC_CONFIG_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFF0FFB) == (uint32_t)RESET))
540 #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_TS) || ((IT) == RTC_IT_WUT) || \
541 ((IT) == RTC_IT_ALRB) || ((IT) == RTC_IT_ALRA) || \
542 ((IT) == RTC_IT_TAMP1))
543 #define IS_RTC_CLEAR_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFD0FFF) == (uint32_t)RESET))
552 #define RTC_DigitalCalibConfig RTC_CoarseCalibConfig
553 #define RTC_DigitalCalibCmd RTC_CoarseCalibCmd
590 ErrorStatus
RTC_AlarmCmd(uint32_t RTC_Alarm, FunctionalState NewState);
611 void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState);
617 void RTC_TamperCmd(uint32_t RTC_Tamper, FunctionalState NewState);
630 void RTC_ITConfig(uint32_t RTC_IT, FunctionalState NewState);