21 #ifndef __STM32F7xx_HAL_RTC_H
22 #define __STM32F7xx_HAL_RTC_H
65 uint32_t AsynchPrediv;
74 uint32_t OutPutPolarity;
100 uint32_t SecondFraction;
109 uint32_t DayLightSaving;
112 uint32_t StoreOperation;
146 uint32_t AlarmSubSecondMask;
149 uint32_t AlarmDateWeekDaySel;
152 uint8_t AlarmDateWeekDay;
163 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
164 typedef struct __RTC_HandleTypeDef
177 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
178 void (* AlarmAEventCallback) (
struct __RTC_HandleTypeDef * hrtc);
180 void (* AlarmBEventCallback) (
struct __RTC_HandleTypeDef * hrtc);
182 void (* TimeStampEventCallback) (
struct __RTC_HandleTypeDef * hrtc);
184 void (* WakeUpTimerEventCallback) (
struct __RTC_HandleTypeDef * hrtc);
186 void (* Tamper1EventCallback) (
struct __RTC_HandleTypeDef * hrtc);
188 void (* Tamper2EventCallback) (
struct __RTC_HandleTypeDef * hrtc);
190 void (* Tamper3EventCallback) (
struct __RTC_HandleTypeDef * hrtc);
192 void (* MspInitCallback) (
struct __RTC_HandleTypeDef * hrtc);
194 void (* MspDeInitCallback) (
struct __RTC_HandleTypeDef * hrtc);
200 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
206 HAL_RTC_ALARM_A_EVENT_CB_ID = 0x00u,
207 HAL_RTC_ALARM_B_EVENT_CB_ID = 0x01u,
208 HAL_RTC_TIMESTAMP_EVENT_CB_ID = 0x02u,
209 HAL_RTC_WAKEUPTIMER_EVENT_CB_ID = 0x03u,
210 HAL_RTC_TAMPER1_EVENT_CB_ID = 0x04u,
211 HAL_RTC_TAMPER2_EVENT_CB_ID = 0x05u,
212 HAL_RTC_TAMPER3_EVENT_CB_ID = 0x06u,
213 HAL_RTC_MSPINIT_CB_ID = 0x0Eu,
214 HAL_RTC_MSPDEINIT_CB_ID = 0x0Fu
215 }HAL_RTC_CallbackIDTypeDef;
235 #define RTC_HOURFORMAT_24 0x00000000U
236 #define RTC_HOURFORMAT_12 0x00000040U
245 #define RTC_OUTPUT_POLARITY_HIGH 0x00000000U
246 #define RTC_OUTPUT_POLARITY_LOW 0x00100000U
254 #define RTC_OUTPUT_TYPE_OPENDRAIN 0x00000000U
255 #define RTC_OUTPUT_TYPE_PUSHPULL RTC_OR_ALARMTYPE
263 #define RTC_HOURFORMAT12_AM ((uint8_t)0x00U)
264 #define RTC_HOURFORMAT12_PM ((uint8_t)0x40U)
272 #define RTC_DAYLIGHTSAVING_SUB1H 0x00020000U
273 #define RTC_DAYLIGHTSAVING_ADD1H 0x00010000U
274 #define RTC_DAYLIGHTSAVING_NONE 0x00000000U
282 #define RTC_STOREOPERATION_RESET 0x00000000U
283 #define RTC_STOREOPERATION_SET 0x00040000U
291 #define RTC_FORMAT_BIN 0x00000000U
292 #define RTC_FORMAT_BCD 0x00000001U
301 #define RTC_MONTH_JANUARY ((uint8_t)0x01U)
302 #define RTC_MONTH_FEBRUARY ((uint8_t)0x02U)
303 #define RTC_MONTH_MARCH ((uint8_t)0x03U)
304 #define RTC_MONTH_APRIL ((uint8_t)0x04U)
305 #define RTC_MONTH_MAY ((uint8_t)0x05U)
306 #define RTC_MONTH_JUNE ((uint8_t)0x06U)
307 #define RTC_MONTH_JULY ((uint8_t)0x07U)
308 #define RTC_MONTH_AUGUST ((uint8_t)0x08U)
309 #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09U)
310 #define RTC_MONTH_OCTOBER ((uint8_t)0x10U)
311 #define RTC_MONTH_NOVEMBER ((uint8_t)0x11U)
312 #define RTC_MONTH_DECEMBER ((uint8_t)0x12U)
320 #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01U)
321 #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02U)
322 #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03U)
323 #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04U)
324 #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05U)
325 #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06U)
326 #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07U)
334 #define RTC_ALARMDATEWEEKDAYSEL_DATE 0x00000000U
335 #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY 0x40000000U
343 #define RTC_ALARMMASK_NONE 0x00000000U
344 #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4
345 #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3
346 #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2
347 #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1
348 #define RTC_ALARMMASK_ALL 0x80808080U
356 #define RTC_ALARM_A RTC_CR_ALRAE
357 #define RTC_ALARM_B RTC_CR_ALRBE
365 #define RTC_ALARMSUBSECONDMASK_ALL 0x00000000U
368 #define RTC_ALARMSUBSECONDMASK_SS14_1 0x01000000U
370 #define RTC_ALARMSUBSECONDMASK_SS14_2 0x02000000U
372 #define RTC_ALARMSUBSECONDMASK_SS14_3 0x03000000U
374 #define RTC_ALARMSUBSECONDMASK_SS14_4 0x04000000U
376 #define RTC_ALARMSUBSECONDMASK_SS14_5 0x05000000U
378 #define RTC_ALARMSUBSECONDMASK_SS14_6 0x06000000U
380 #define RTC_ALARMSUBSECONDMASK_SS14_7 0x07000000U
382 #define RTC_ALARMSUBSECONDMASK_SS14_8 0x08000000U
384 #define RTC_ALARMSUBSECONDMASK_SS14_9 0x09000000U
386 #define RTC_ALARMSUBSECONDMASK_SS14_10 0x0A000000U
388 #define RTC_ALARMSUBSECONDMASK_SS14_11 0x0B000000U
390 #define RTC_ALARMSUBSECONDMASK_SS14_12 0x0C000000U
392 #define RTC_ALARMSUBSECONDMASK_SS14_13 0x0D000000U
394 #define RTC_ALARMSUBSECONDMASK_SS14 0x0E000000U
396 #define RTC_ALARMSUBSECONDMASK_NONE 0x0F000000U
405 #define RTC_IT_TS RTC_CR_TSIE
406 #define RTC_IT_WUT RTC_CR_WUTIE
407 #define RTC_IT_ALRA RTC_CR_ALRAIE
408 #define RTC_IT_ALRB RTC_CR_ALRBIE
409 #define RTC_IT_TAMP RTC_TAMPCR_TAMPIE
410 #define RTC_IT_TAMP1 RTC_TAMPCR_TAMP1IE
411 #define RTC_IT_TAMP2 RTC_TAMPCR_TAMP2IE
412 #define RTC_IT_TAMP3 RTC_TAMPCR_TAMP3IE
420 #define RTC_FLAG_RECALPF RTC_ISR_RECALPF
421 #define RTC_FLAG_TAMP3F RTC_ISR_TAMP3F
422 #define RTC_FLAG_TAMP2F RTC_ISR_TAMP2F
423 #define RTC_FLAG_TAMP1F RTC_ISR_TAMP1F
424 #define RTC_FLAG_TSOVF RTC_ISR_TSOVF
425 #define RTC_FLAG_TSF RTC_ISR_TSF
426 #define RTC_FLAG_ITSF RTC_ISR_ITSF
427 #define RTC_FLAG_WUTF RTC_ISR_WUTF
428 #define RTC_FLAG_ALRBF RTC_ISR_ALRBF
429 #define RTC_FLAG_ALRAF RTC_ISR_ALRAF
430 #define RTC_FLAG_INITF RTC_ISR_INITF
431 #define RTC_FLAG_RSF RTC_ISR_RSF
432 #define RTC_FLAG_INITS RTC_ISR_INITS
433 #define RTC_FLAG_SHPF RTC_ISR_SHPF
434 #define RTC_FLAG_WUTWF RTC_ISR_WUTWF
435 #define RTC_FLAG_ALRBWF RTC_ISR_ALRBWF
436 #define RTC_FLAG_ALRAWF RTC_ISR_ALRAWF
454 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
455 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{\
456 (__HANDLE__)->State = HAL_RTC_STATE_RESET;\
457 (__HANDLE__)->MspInitCallback = NULL;\
458 (__HANDLE__)->MspDeInitCallback = NULL;\
461 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
469 #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \
471 (__HANDLE__)->Instance->WPR = 0xCAU; \
472 (__HANDLE__)->Instance->WPR = 0x53U; \
480 #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \
482 (__HANDLE__)->Instance->WPR = 0xFFU; \
490 #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE))
497 #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE))
504 #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE))
511 #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE))
522 #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
533 #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
544 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) ((((((__HANDLE__)->Instance->ISR)& ((__INTERRUPT__)>> 4U)) & 0x0000FFFFU) != RESET)? SET : RESET)
557 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
568 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& 0x0000FFFFU)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
579 #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
585 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_ALARM_EVENT)
591 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
597 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_ALARM_EVENT)
603 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
609 #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_ALARM_EVENT)
615 #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
621 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_ALARM_EVENT)
627 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
633 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE();__HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE();
639 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE();__HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE();
645 #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_ALARM_EVENT)
651 #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_ALARM_EVENT)
657 #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_ALARM_EVENT)
680 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
744 #define RTC_TR_RESERVED_MASK 0x007F7F7FU
745 #define RTC_DR_RESERVED_MASK 0x00FFFF3FU
746 #define RTC_INIT_MASK 0xFFFFFFFFU
747 #define RTC_RSF_MASK 0xFFFFFF5FU
749 #define RTC_TIMEOUT_VALUE 1000U
751 #define RTC_EXTI_LINE_ALARM_EVENT EXTI_IMR_IM17
764 #define IS_RTC_HOUR_FORMAT(__FORMAT__) (((__FORMAT__) == RTC_HOURFORMAT_12) || \
765 ((__FORMAT__) == RTC_HOURFORMAT_24))
766 #define IS_RTC_OUTPUT_POL(__POL__) (((__POL__) == RTC_OUTPUT_POLARITY_HIGH) || \
767 ((__POL__) == RTC_OUTPUT_POLARITY_LOW))
768 #define IS_RTC_OUTPUT_TYPE(__TYPE__) (((__TYPE__) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
769 ((__TYPE__) == RTC_OUTPUT_TYPE_PUSHPULL))
770 #define IS_RTC_ASYNCH_PREDIV(__PREDIV__) ((__PREDIV__) <= 0x7FU)
771 #define IS_RTC_SYNCH_PREDIV(__PREDIV__) ((__PREDIV__) <= 0x7FFFU)
772 #define IS_RTC_HOUR12(__HOUR__) (((__HOUR__) > 0U) && ((__HOUR__) <= 12U))
773 #define IS_RTC_HOUR24(__HOUR__) ((__HOUR__) <= 23U)
774 #define IS_RTC_MINUTES(__MINUTES__) ((__MINUTES__) <= 59U)
775 #define IS_RTC_SECONDS(__SECONDS__) ((__SECONDS__) <= 59U)
776 #define IS_RTC_HOURFORMAT12(__PM__) (((__PM__) == RTC_HOURFORMAT12_AM) || ((__PM__) == RTC_HOURFORMAT12_PM))
777 #define IS_RTC_DAYLIGHT_SAVING(__SAVE__) (((__SAVE__) == RTC_DAYLIGHTSAVING_SUB1H) || \
778 ((__SAVE__) == RTC_DAYLIGHTSAVING_ADD1H) || \
779 ((__SAVE__) == RTC_DAYLIGHTSAVING_NONE))
780 #define IS_RTC_STORE_OPERATION(__OPERATION__) (((__OPERATION__) == RTC_STOREOPERATION_RESET) || \
781 ((__OPERATION__) == RTC_STOREOPERATION_SET))
782 #define IS_RTC_FORMAT(__FORMAT__) (((__FORMAT__) == RTC_FORMAT_BIN) || ((__FORMAT__) == RTC_FORMAT_BCD))
783 #define IS_RTC_YEAR(__YEAR__) ((__YEAR__) <= 99U)
784 #define IS_RTC_MONTH(__MONTH__) (((__MONTH__) >= 1U) && ((__MONTH__) <= 12U))
785 #define IS_RTC_DATE(__DATE__) (((__DATE__) >= 1U) && ((__DATE__) <= 31U))
786 #define IS_RTC_WEEKDAY(__WEEKDAY__) (((__WEEKDAY__) == RTC_WEEKDAY_MONDAY) || \
787 ((__WEEKDAY__) == RTC_WEEKDAY_TUESDAY) || \
788 ((__WEEKDAY__) == RTC_WEEKDAY_WEDNESDAY) || \
789 ((__WEEKDAY__) == RTC_WEEKDAY_THURSDAY) || \
790 ((__WEEKDAY__) == RTC_WEEKDAY_FRIDAY) || \
791 ((__WEEKDAY__) == RTC_WEEKDAY_SATURDAY) || \
792 ((__WEEKDAY__) == RTC_WEEKDAY_SUNDAY))
794 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(__DATE__) (((__DATE__) >0U) && ((__DATE__) <= 31U))
795 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(__WEEKDAY__) (((__WEEKDAY__) == RTC_WEEKDAY_MONDAY) || \
796 ((__WEEKDAY__) == RTC_WEEKDAY_TUESDAY) || \
797 ((__WEEKDAY__) == RTC_WEEKDAY_WEDNESDAY) || \
798 ((__WEEKDAY__) == RTC_WEEKDAY_THURSDAY) || \
799 ((__WEEKDAY__) == RTC_WEEKDAY_FRIDAY) || \
800 ((__WEEKDAY__) == RTC_WEEKDAY_SATURDAY) || \
801 ((__WEEKDAY__) == RTC_WEEKDAY_SUNDAY))
802 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
803 ((__SEL__) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
804 #define IS_RTC_ALARM_MASK(__MASK__) (((__MASK__) & 0x7F7F7F7FU) == (uint32_t)RESET)
805 #define IS_RTC_ALARM(__ALARM__) (((__ALARM__) == RTC_ALARM_A) || ((__ALARM__) == RTC_ALARM_B))
806 #define IS_RTC_ALARM_SUB_SECOND_VALUE(__VALUE__) ((__VALUE__) <= 0x00007FFFU)
807 #define IS_RTC_ALARM_SUB_SECOND_MASK(__MASK__) (((__MASK__) == RTC_ALARMSUBSECONDMASK_ALL) || \
808 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_1) || \
809 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_2) || \
810 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_3) || \
811 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_4) || \
812 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_5) || \
813 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_6) || \
814 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_7) || \
815 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_8) || \
816 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_9) || \
817 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_10) || \
818 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_11) || \
819 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_12) || \
820 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_13) || \
821 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14) || \
822 ((__MASK__) == RTC_ALARMSUBSECONDMASK_NONE))