STM32F4xx HAL Documentation
Hardware Abstraction Layer for STM32F4 familiy
Loading...
Searching...
No Matches
stm32f4xx_hal_rtc.c
Go to the documentation of this file.
1
184/* Includes ------------------------------------------------------------------*/
185#include "stm32f4xx_hal.h"
186
196#ifdef HAL_RTC_MODULE_ENABLED
197
198/* Private typedef -----------------------------------------------------------*/
199/* Private define ------------------------------------------------------------*/
200/* Private macro -------------------------------------------------------------*/
201/* Private variables ---------------------------------------------------------*/
202/* Private function prototypes -----------------------------------------------*/
203/* Exported functions --------------------------------------------------------*/
204
250{
252
253 /* Check RTC handler validity */
254 if (hrtc == NULL)
255 {
256 return HAL_ERROR;
257 }
258
259 /* Check the parameters */
260 assert_param(IS_RTC_ALL_INSTANCE(hrtc->Instance));
267
268#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
269 if (hrtc->State == HAL_RTC_STATE_RESET)
270 {
271 /* Allocate lock resource and initialize it */
272 hrtc->Lock = HAL_UNLOCKED;
273
274 hrtc->AlarmAEventCallback = HAL_RTC_AlarmAEventCallback; /* Legacy weak AlarmAEventCallback */
275 hrtc->AlarmBEventCallback = HAL_RTCEx_AlarmBEventCallback; /* Legacy weak AlarmBEventCallback */
276 hrtc->TimeStampEventCallback = HAL_RTCEx_TimeStampEventCallback; /* Legacy weak TimeStampEventCallback */
277 hrtc->WakeUpTimerEventCallback = HAL_RTCEx_WakeUpTimerEventCallback; /* Legacy weak WakeUpTimerEventCallback */
278 hrtc->Tamper1EventCallback = HAL_RTCEx_Tamper1EventCallback; /* Legacy weak Tamper1EventCallback */
279#if defined(RTC_TAMPER2_SUPPORT)
280 hrtc->Tamper2EventCallback = HAL_RTCEx_Tamper2EventCallback; /* Legacy weak Tamper2EventCallback */
281#endif /* RTC_TAMPER2_SUPPORT */
282
283 if (hrtc->MspInitCallback == NULL)
284 {
285 hrtc->MspInitCallback = HAL_RTC_MspInit;
286 }
287 /* Init the low level hardware */
288 hrtc->MspInitCallback(hrtc);
289
290 if (hrtc->MspDeInitCallback == NULL)
291 {
292 hrtc->MspDeInitCallback = HAL_RTC_MspDeInit;
293 }
294 }
295#else /* USE_HAL_RTC_REGISTER_CALLBACKS */
296 if (hrtc->State == HAL_RTC_STATE_RESET)
297 {
298 /* Allocate lock resource and initialize it */
299 hrtc->Lock = HAL_UNLOCKED;
300
301 /* Initialize RTC MSP */
302 HAL_RTC_MspInit(hrtc);
303 }
304#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
305
306 /* Set RTC state */
308
309 /* Check whether the calendar needs to be initialized */
310 if (__HAL_RTC_IS_CALENDAR_INITIALIZED(hrtc) == 0U)
311 {
312 /* Disable the write protection for RTC registers */
314
315 /* Enter Initialization mode */
316 status = RTC_EnterInitMode(hrtc);
317
318 if (status == HAL_OK)
319 {
320 /* Clear RTC_CR FMT, OSEL and POL Bits */
321 hrtc->Instance->CR &= ((uint32_t)~(RTC_CR_FMT | RTC_CR_OSEL | RTC_CR_POL));
322 /* Set RTC_CR register */
323 hrtc->Instance->CR |= (uint32_t)(hrtc->Init.HourFormat | hrtc->Init.OutPut | hrtc->Init.OutPutPolarity);
324
325 /* Configure the RTC PRER */
326 hrtc->Instance->PRER = (uint32_t)(hrtc->Init.SynchPrediv);
327 hrtc->Instance->PRER |= (uint32_t)(hrtc->Init.AsynchPrediv << RTC_PRER_PREDIV_A_Pos);
328
329 /* Exit Initialization mode */
330 status = RTC_ExitInitMode(hrtc);
331 }
332
333 if (status == HAL_OK)
334 {
335 hrtc->Instance->TAFCR &= (uint32_t)~RTC_OUTPUT_TYPE_PUSHPULL;
336 hrtc->Instance->TAFCR |= (uint32_t)(hrtc->Init.OutPutType);
337 }
338
339 /* Enable the write protection for RTC registers */
341 }
342 else
343 {
344 /* The calendar is already initialized */
345 status = HAL_OK;
346 }
347
348 if (status == HAL_OK)
349 {
351 }
352
353 return status;
354}
355
364{
366
367 /* Check the parameters */
368 assert_param(IS_RTC_ALL_INSTANCE(hrtc->Instance));
369
370 /* Set RTC state */
372
373 /* Disable the write protection for RTC registers */
375
376 /* Enter Initialization mode */
377 status = RTC_EnterInitMode(hrtc);
378
379 if (status == HAL_OK)
380 {
381 /* Reset RTC registers */
382 hrtc->Instance->TR = 0x00000000U;
383 hrtc->Instance->DR = (RTC_DR_WDU_0 | RTC_DR_MU_0 | RTC_DR_DU_0);
384 hrtc->Instance->CR &= 0x00000000U;
385 hrtc->Instance->WUTR = RTC_WUTR_WUT;
386 hrtc->Instance->PRER = (uint32_t)(RTC_PRER_PREDIV_A | 0x000000FFU);
387 hrtc->Instance->CALIBR = 0x00000000U;
388 hrtc->Instance->ALRMAR = 0x00000000U;
389 hrtc->Instance->ALRMBR = 0x00000000U;
390 hrtc->Instance->CALR = 0x00000000U;
391 hrtc->Instance->SHIFTR = 0x00000000U;
392 hrtc->Instance->ALRMASSR = 0x00000000U;
393 hrtc->Instance->ALRMBSSR = 0x00000000U;
394
395 /* Exit Initialization mode */
396 status = RTC_ExitInitMode(hrtc);
397 }
398
399 /* Enable the write protection for RTC registers */
401
402 if (status == HAL_OK)
403 {
404 /* Reset Tamper and alternate functions configuration register */
405 hrtc->Instance->TAFCR = 0x00000000U;
406
407#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
408 if (hrtc->MspDeInitCallback == NULL)
409 {
410 hrtc->MspDeInitCallback = HAL_RTC_MspDeInit;
411 }
412
413 /* DeInit the low level hardware: CLOCK, NVIC.*/
414 hrtc->MspDeInitCallback(hrtc);
415#else /* USE_HAL_RTC_REGISTER_CALLBACKS */
416 /* De-Initialize RTC MSP */
417 HAL_RTC_MspDeInit(hrtc);
418#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
419
421 }
422
423 /* Release Lock */
424 __HAL_UNLOCK(hrtc);
425
426 return status;
427}
428
429#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
449HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback)
450{
451 HAL_StatusTypeDef status = HAL_OK;
452
453 if (pCallback == NULL)
454 {
455 return HAL_ERROR;
456 }
457
458 /* Process locked */
459 __HAL_LOCK(hrtc);
460
461 if (HAL_RTC_STATE_READY == hrtc->State)
462 {
463 switch (CallbackID)
464 {
465 case HAL_RTC_ALARM_A_EVENT_CB_ID :
466 hrtc->AlarmAEventCallback = pCallback;
467 break;
468
469 case HAL_RTC_ALARM_B_EVENT_CB_ID :
470 hrtc->AlarmBEventCallback = pCallback;
471 break;
472
473 case HAL_RTC_TIMESTAMP_EVENT_CB_ID :
474 hrtc->TimeStampEventCallback = pCallback;
475 break;
476
477 case HAL_RTC_WAKEUPTIMER_EVENT_CB_ID :
478 hrtc->WakeUpTimerEventCallback = pCallback;
479 break;
480
481 case HAL_RTC_TAMPER1_EVENT_CB_ID :
482 hrtc->Tamper1EventCallback = pCallback;
483 break;
484
485#if defined(RTC_TAMPER2_SUPPORT)
486 case HAL_RTC_TAMPER2_EVENT_CB_ID :
487 hrtc->Tamper2EventCallback = pCallback;
488 break;
489#endif /* RTC_TAMPER2_SUPPORT */
490
491 case HAL_RTC_MSPINIT_CB_ID :
492 hrtc->MspInitCallback = pCallback;
493 break;
494
495 case HAL_RTC_MSPDEINIT_CB_ID :
496 hrtc->MspDeInitCallback = pCallback;
497 break;
498
499 default :
500 /* Return error status */
501 status = HAL_ERROR;
502 break;
503 }
504 }
505 else if (HAL_RTC_STATE_RESET == hrtc->State)
506 {
507 switch (CallbackID)
508 {
509 case HAL_RTC_MSPINIT_CB_ID :
510 hrtc->MspInitCallback = pCallback;
511 break;
512
513 case HAL_RTC_MSPDEINIT_CB_ID :
514 hrtc->MspDeInitCallback = pCallback;
515 break;
516
517 default :
518 /* Return error status */
519 status = HAL_ERROR;
520 break;
521 }
522 }
523 else
524 {
525 /* Return error status */
526 status = HAL_ERROR;
527 }
528
529 /* Release Lock */
530 __HAL_UNLOCK(hrtc);
531
532 return status;
533}
534
553HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID)
554{
555 HAL_StatusTypeDef status = HAL_OK;
556
557 /* Process locked */
558 __HAL_LOCK(hrtc);
559
560 if (HAL_RTC_STATE_READY == hrtc->State)
561 {
562 switch (CallbackID)
563 {
564 case HAL_RTC_ALARM_A_EVENT_CB_ID :
565 hrtc->AlarmAEventCallback = HAL_RTC_AlarmAEventCallback; /* Legacy weak AlarmAEventCallback */
566 break;
567
568 case HAL_RTC_ALARM_B_EVENT_CB_ID :
569 hrtc->AlarmBEventCallback = HAL_RTCEx_AlarmBEventCallback; /* Legacy weak AlarmBEventCallback */
570 break;
571
572 case HAL_RTC_TIMESTAMP_EVENT_CB_ID :
573 hrtc->TimeStampEventCallback = HAL_RTCEx_TimeStampEventCallback; /* Legacy weak TimeStampEventCallback */
574 break;
575
576 case HAL_RTC_WAKEUPTIMER_EVENT_CB_ID :
577 hrtc->WakeUpTimerEventCallback = HAL_RTCEx_WakeUpTimerEventCallback; /* Legacy weak WakeUpTimerEventCallback */
578 break;
579
580 case HAL_RTC_TAMPER1_EVENT_CB_ID :
581 hrtc->Tamper1EventCallback = HAL_RTCEx_Tamper1EventCallback; /* Legacy weak Tamper1EventCallback */
582 break;
583
584#if defined(RTC_TAMPER2_SUPPORT)
585 case HAL_RTC_TAMPER2_EVENT_CB_ID :
586 hrtc->Tamper2EventCallback = HAL_RTCEx_Tamper2EventCallback; /* Legacy weak Tamper2EventCallback */
587 break;
588#endif /* RTC_TAMPER2_SUPPORT */
589
590 case HAL_RTC_MSPINIT_CB_ID :
591 hrtc->MspInitCallback = HAL_RTC_MspInit;
592 break;
593
594 case HAL_RTC_MSPDEINIT_CB_ID :
595 hrtc->MspDeInitCallback = HAL_RTC_MspDeInit;
596 break;
597
598 default :
599 /* Return error status */
600 status = HAL_ERROR;
601 break;
602 }
603 }
604 else if (HAL_RTC_STATE_RESET == hrtc->State)
605 {
606 switch (CallbackID)
607 {
608 case HAL_RTC_MSPINIT_CB_ID :
609 hrtc->MspInitCallback = HAL_RTC_MspInit;
610 break;
611
612 case HAL_RTC_MSPDEINIT_CB_ID :
613 hrtc->MspDeInitCallback = HAL_RTC_MspDeInit;
614 break;
615
616 default :
617 /* Return error status */
618 status = HAL_ERROR;
619 break;
620 }
621 }
622 else
623 {
624 /* Return error status */
625 status = HAL_ERROR;
626 }
627
628 /* Release Lock */
629 __HAL_UNLOCK(hrtc);
630
631 return status;
632}
633#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
634
642{
643 /* Prevent unused argument(s) compilation warning */
644 UNUSED(hrtc);
645
646 /* NOTE: This function should not be modified, when the callback is needed,
647 the HAL_RTC_MspInit could be implemented in the user file
648 */
649}
650
658{
659 /* Prevent unused argument(s) compilation warning */
660 UNUSED(hrtc);
661
662 /* NOTE: This function should not be modified, when the callback is needed,
663 the HAL_RTC_MspDeInit could be implemented in the user file
664 */
665}
666
699{
700 uint32_t tmpreg = 0U;
701 HAL_StatusTypeDef status;
702
703 /* Check the parameters */
707
708 /* Process Locked */
709 __HAL_LOCK(hrtc);
710
712
713 if (Format == RTC_FORMAT_BIN)
714 {
715 if ((hrtc->Instance->CR & RTC_CR_FMT) != 0U)
716 {
719 }
720 else
721 {
722 sTime->TimeFormat = 0x00U;
724 }
727
728 tmpreg = (uint32_t)(( (uint32_t)RTC_ByteToBcd2(sTime->Hours) << RTC_TR_HU_Pos) | \
729 ( (uint32_t)RTC_ByteToBcd2(sTime->Minutes) << RTC_TR_MNU_Pos) | \
730 ( (uint32_t)RTC_ByteToBcd2(sTime->Seconds)) | \
731 (((uint32_t)sTime->TimeFormat) << RTC_TR_PM_Pos));
732 }
733 else
734 {
735 if ((hrtc->Instance->CR & RTC_CR_FMT) != 0U)
736 {
739 }
740 else
741 {
742 sTime->TimeFormat = 0x00U;
744 }
747 tmpreg = (((uint32_t)(sTime->Hours) << RTC_TR_HU_Pos) | \
748 ((uint32_t)(sTime->Minutes) << RTC_TR_MNU_Pos) | \
749 ((uint32_t) sTime->Seconds) | \
750 ((uint32_t)(sTime->TimeFormat) << RTC_TR_PM_Pos));
751 }
752
753 /* Disable the write protection for RTC registers */
755
756 /* Enter Initialization mode */
757 status = RTC_EnterInitMode(hrtc);
758
759 if (status == HAL_OK)
760 {
761 /* Set the RTC_TR register */
762 hrtc->Instance->TR = (uint32_t)(tmpreg & RTC_TR_RESERVED_MASK);
763
764 /* Clear the bits to be configured (Deprecated. Use HAL_RTC_DST_xxx functions instead) */
765 hrtc->Instance->CR &= (uint32_t)~RTC_CR_BKP;
766
767 /* Configure the RTC_CR register (Deprecated. Use HAL_RTC_DST_xxx functions instead) */
768 hrtc->Instance->CR |= (uint32_t)(sTime->DayLightSaving | sTime->StoreOperation);
769
770 /* Exit Initialization mode */
771 status = RTC_ExitInitMode(hrtc);
772 }
773
774 if (status == HAL_OK)
775 {
777 }
778
779 /* Enable the write protection for RTC registers */
781
782 /* Process Unlocked */
783 __HAL_UNLOCK(hrtc);
784
785 return status;
786}
787
813{
814 uint32_t tmpreg = 0U;
815
816 /* Check the parameters */
818
819 /* Get subseconds value from the corresponding register */
820 sTime->SubSeconds = (uint32_t)(hrtc->Instance->SSR);
821
822 /* Get SecondFraction structure field from the corresponding register field*/
823 sTime->SecondFraction = (uint32_t)(hrtc->Instance->PRER & RTC_PRER_PREDIV_S);
824
825 /* Get the TR register */
826 tmpreg = (uint32_t)(hrtc->Instance->TR & RTC_TR_RESERVED_MASK);
827
828 /* Fill the structure fields with the read parameters */
829 sTime->Hours = (uint8_t)((tmpreg & (RTC_TR_HT | RTC_TR_HU)) >> RTC_TR_HU_Pos);
830 sTime->Minutes = (uint8_t)((tmpreg & (RTC_TR_MNT | RTC_TR_MNU)) >> RTC_TR_MNU_Pos);
831 sTime->Seconds = (uint8_t)( tmpreg & (RTC_TR_ST | RTC_TR_SU));
832 sTime->TimeFormat = (uint8_t)((tmpreg & (RTC_TR_PM)) >> RTC_TR_PM_Pos);
833
834 /* Check the input parameters format */
835 if (Format == RTC_FORMAT_BIN)
836 {
837 /* Convert the time structure parameters to Binary format */
838 sTime->Hours = (uint8_t)RTC_Bcd2ToByte(sTime->Hours);
839 sTime->Minutes = (uint8_t)RTC_Bcd2ToByte(sTime->Minutes);
840 sTime->Seconds = (uint8_t)RTC_Bcd2ToByte(sTime->Seconds);
841 }
842
843 return HAL_OK;
844}
845
858{
859 uint32_t datetmpreg = 0U;
860 HAL_StatusTypeDef status;
861
862 /* Check the parameters */
864
865 /* Process Locked */
866 __HAL_LOCK(hrtc);
867
869
870 if ((Format == RTC_FORMAT_BIN) && ((sDate->Month & 0x10U) == 0x10U))
871 {
872 sDate->Month = (uint8_t)((sDate->Month & (uint8_t)~(0x10U)) + (uint8_t)0x0AU);
873 }
874
876
877 if (Format == RTC_FORMAT_BIN)
878 {
882
883 datetmpreg = (((uint32_t)RTC_ByteToBcd2(sDate->Year) << RTC_DR_YU_Pos) | \
884 ((uint32_t)RTC_ByteToBcd2(sDate->Month) << RTC_DR_MU_Pos) | \
885 ((uint32_t)RTC_ByteToBcd2(sDate->Date)) | \
886 ((uint32_t)sDate->WeekDay << RTC_DR_WDU_Pos));
887 }
888 else
889 {
893
894 datetmpreg = ((((uint32_t)sDate->Year) << RTC_DR_YU_Pos) | \
895 (((uint32_t)sDate->Month) << RTC_DR_MU_Pos) | \
896 ((uint32_t) sDate->Date) | \
897 (((uint32_t)sDate->WeekDay) << RTC_DR_WDU_Pos));
898 }
899
900 /* Disable the write protection for RTC registers */
902
903 /* Enter Initialization mode */
904 status = RTC_EnterInitMode(hrtc);
905
906 if (status == HAL_OK)
907 {
908 /* Set the RTC_DR register */
909 hrtc->Instance->DR = (uint32_t)(datetmpreg & RTC_DR_RESERVED_MASK);
910
911 /* Exit Initialization mode */
912 status = RTC_ExitInitMode(hrtc);
913 }
914
915 if (status == HAL_OK)
916 {
918 }
919
920 /* Enable the write protection for RTC registers */
922
923 /* Process Unlocked */
924 __HAL_UNLOCK(hrtc);
925
926 return status;
927}
928
947{
948 uint32_t datetmpreg = 0U;
949
950 /* Check the parameters */
952
953 /* Get the DR register */
954 datetmpreg = (uint32_t)(hrtc->Instance->DR & RTC_DR_RESERVED_MASK);
955
956 /* Fill the structure fields with the read parameters */
957 sDate->Year = (uint8_t)((datetmpreg & (RTC_DR_YT | RTC_DR_YU)) >> RTC_DR_YU_Pos);
958 sDate->Month = (uint8_t)((datetmpreg & (RTC_DR_MT | RTC_DR_MU)) >> RTC_DR_MU_Pos);
959 sDate->Date = (uint8_t) (datetmpreg & (RTC_DR_DT | RTC_DR_DU));
960 sDate->WeekDay = (uint8_t)((datetmpreg & (RTC_DR_WDU)) >> RTC_DR_WDU_Pos);
961
962 /* Check the input parameters format */
963 if (Format == RTC_FORMAT_BIN)
964 {
965 /* Convert the date structure parameters to Binary format */
966 sDate->Year = (uint8_t)RTC_Bcd2ToByte(sDate->Year);
967 sDate->Month = (uint8_t)RTC_Bcd2ToByte(sDate->Month);
968 sDate->Date = (uint8_t)RTC_Bcd2ToByte(sDate->Date);
969 }
970 return HAL_OK;
971}
972
1005{
1006 uint32_t tickstart = 0U;
1007 uint32_t tmpreg = 0U;
1008 uint32_t subsecondtmpreg = 0U;
1009
1010 /* Check the parameters */
1011 assert_param(IS_RTC_FORMAT(Format));
1017
1018 /* Process Locked */
1019 __HAL_LOCK(hrtc);
1020
1021 /* Change RTC state to BUSY */
1022 hrtc->State = HAL_RTC_STATE_BUSY;
1023
1024 /* Check the data format (binary or BCD) and store the Alarm time and date
1025 configuration accordingly */
1026 if (Format == RTC_FORMAT_BIN)
1027 {
1028 if ((hrtc->Instance->CR & RTC_CR_FMT) != 0U)
1029 {
1032 }
1033 else
1034 {
1035 sAlarm->AlarmTime.TimeFormat = 0x00U;
1037 }
1040
1042 {
1044 }
1045 else
1046 {
1048 }
1049
1050 tmpreg = (((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Hours) << RTC_ALRMAR_HU_Pos) | \
1051 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Minutes) << RTC_ALRMAR_MNU_Pos) | \
1052 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Seconds)) | \
1053 ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << RTC_TR_PM_Pos) | \
1054 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmDateWeekDay) << RTC_ALRMAR_DU_Pos) | \
1055 ((uint32_t)sAlarm->AlarmDateWeekDaySel) | \
1056 ((uint32_t)sAlarm->AlarmMask));
1057 }
1058 else
1059 {
1060 if ((hrtc->Instance->CR & RTC_CR_FMT) != 0U)
1061 {
1064 }
1065 else
1066 {
1067 sAlarm->AlarmTime.TimeFormat = 0x00U;
1069 }
1070
1073
1075 {
1077 }
1078 else
1079 {
1081 }
1082
1083 tmpreg = (((uint32_t)(sAlarm->AlarmTime.Hours) << RTC_ALRMAR_HU_Pos) | \
1084 ((uint32_t)(sAlarm->AlarmTime.Minutes) << RTC_ALRMAR_MNU_Pos) | \
1085 ((uint32_t) sAlarm->AlarmTime.Seconds) | \
1086 ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << RTC_TR_PM_Pos) | \
1087 ((uint32_t)(sAlarm->AlarmDateWeekDay) << RTC_ALRMAR_DU_Pos) | \
1088 ((uint32_t) sAlarm->AlarmDateWeekDaySel) | \
1089 ((uint32_t) sAlarm->AlarmMask));
1090 }
1091
1092 /* Store the Alarm subseconds configuration */
1093 subsecondtmpreg = (uint32_t)((uint32_t)(sAlarm->AlarmTime.SubSeconds) | \
1094 (uint32_t)(sAlarm->AlarmSubSecondMask));
1095
1096 /* Disable the write protection for RTC registers */
1098
1099 /* Configure the Alarm register */
1100 if (sAlarm->Alarm == RTC_ALARM_A)
1101 {
1102 /* Disable the Alarm A */
1104
1105 /* In case interrupt mode is used, the interrupt source must be disabled */
1107
1108 /* Clear the Alarm flag */
1110
1111 /* Get tick */
1112 tickstart = HAL_GetTick();
1113
1114 /* Wait till RTC ALRAWF flag is set and if timeout is reached exit */
1115 while (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAWF) == 0U)
1116 {
1117 if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
1118 {
1119 /* Enable the write protection for RTC registers */
1121
1123
1124 /* Process Unlocked */
1125 __HAL_UNLOCK(hrtc);
1126
1127 return HAL_TIMEOUT;
1128 }
1129 }
1130
1131 hrtc->Instance->ALRMAR = (uint32_t)tmpreg;
1132 /* Configure the Alarm A Subseconds register */
1133 hrtc->Instance->ALRMASSR = subsecondtmpreg;
1134 /* Configure the Alarm state: Enable Alarm */
1136 }
1137 else
1138 {
1139 /* Disable the Alarm B */
1141
1142 /* In case interrupt mode is used, the interrupt source must be disabled */
1144
1145 /* Clear the Alarm flag */
1147
1148 /* Get tick */
1149 tickstart = HAL_GetTick();
1150
1151 /* Wait till RTC ALRBWF flag is set and if timeout is reached exit */
1152 while (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBWF) == 0U)
1153 {
1154 if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
1155 {
1156 /* Enable the write protection for RTC registers */
1158
1160
1161 /* Process Unlocked */
1162 __HAL_UNLOCK(hrtc);
1163
1164 return HAL_TIMEOUT;
1165 }
1166 }
1167
1168 hrtc->Instance->ALRMBR = (uint32_t)tmpreg;
1169 /* Configure the Alarm B Subseconds register */
1170 hrtc->Instance->ALRMBSSR = subsecondtmpreg;
1171 /* Configure the Alarm state: Enable Alarm */
1173 }
1174
1175 /* Enable the write protection for RTC registers */
1177
1178 /* Change RTC state back to READY */
1179 hrtc->State = HAL_RTC_STATE_READY;
1180
1181 /* Process Unlocked */
1182 __HAL_UNLOCK(hrtc);
1183
1184 return HAL_OK;
1185}
1186
1202{
1203 __IO uint32_t count = RTC_TIMEOUT_VALUE * (SystemCoreClock / 32U / 1000U);
1204 uint32_t tmpreg = 0U;
1205 uint32_t subsecondtmpreg = 0U;
1206
1207 /* Check the parameters */
1208 assert_param(IS_RTC_FORMAT(Format));
1214
1215 /* Process Locked */
1216 __HAL_LOCK(hrtc);
1217
1218 /* Change RTC state to BUSY */
1219 hrtc->State = HAL_RTC_STATE_BUSY;
1220
1221 /* Check the data format (binary or BCD) and store the Alarm time and date
1222 configuration accordingly */
1223 if (Format == RTC_FORMAT_BIN)
1224 {
1225 if ((hrtc->Instance->CR & RTC_CR_FMT) != 0U)
1226 {
1229 }
1230 else
1231 {
1232 sAlarm->AlarmTime.TimeFormat = 0x00U;
1234 }
1237
1239 {
1241 }
1242 else
1243 {
1245 }
1246
1247 tmpreg = (((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Hours) << RTC_ALRMAR_HU_Pos) | \
1248 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Minutes) << RTC_ALRMAR_MNU_Pos) | \
1249 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Seconds)) | \
1250 ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << RTC_TR_PM_Pos) | \
1251 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmDateWeekDay) << RTC_ALRMAR_DU_Pos) | \
1252 ((uint32_t)sAlarm->AlarmDateWeekDaySel) | \
1253 ((uint32_t)sAlarm->AlarmMask));
1254 }
1255 else
1256 {
1257 if ((hrtc->Instance->CR & RTC_CR_FMT) != 0U)
1258 {
1261 }
1262 else
1263 {
1264 sAlarm->AlarmTime.TimeFormat = 0x00U;
1266 }
1267
1270
1272 {
1274 }
1275 else
1276 {
1278 }
1279
1280 tmpreg = (((uint32_t)(sAlarm->AlarmTime.Hours) << RTC_ALRMAR_HU_Pos) | \
1281 ((uint32_t)(sAlarm->AlarmTime.Minutes) << RTC_ALRMAR_MNU_Pos) | \
1282 ((uint32_t) sAlarm->AlarmTime.Seconds) | \
1283 ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << RTC_TR_PM_Pos) | \
1284 ((uint32_t)(sAlarm->AlarmDateWeekDay) << RTC_ALRMAR_DU_Pos) | \
1285 ((uint32_t) sAlarm->AlarmDateWeekDaySel) | \
1286 ((uint32_t) sAlarm->AlarmMask));
1287 }
1288
1289 /* Store the Alarm subseconds configuration */
1290 subsecondtmpreg = (uint32_t)((uint32_t)(sAlarm->AlarmTime.SubSeconds) | \
1291 (uint32_t)(sAlarm->AlarmSubSecondMask));
1292
1293 /* Disable the write protection for RTC registers */
1295
1296 /* Configure the Alarm register */
1297 if (sAlarm->Alarm == RTC_ALARM_A)
1298 {
1299 /* Disable the Alarm A */
1301
1302 /* Clear the Alarm flag */
1304
1305 /* Wait till RTC ALRAWF flag is set and if timeout is reached exit */
1306 do
1307 {
1308 count = count - 1U;
1309 if (count == 0U)
1310 {
1311 /* Enable the write protection for RTC registers */
1313
1315
1316 /* Process Unlocked */
1317 __HAL_UNLOCK(hrtc);
1318
1319 return HAL_TIMEOUT;
1320 }
1321 } while (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAWF) == 0U);
1322
1323 hrtc->Instance->ALRMAR = (uint32_t)tmpreg;
1324 /* Configure the Alarm A Subseconds register */
1325 hrtc->Instance->ALRMASSR = subsecondtmpreg;
1326 /* Configure the Alarm state: Enable Alarm */
1328 /* Configure the Alarm interrupt */
1330 }
1331 else
1332 {
1333 /* Disable the Alarm B */
1335
1336 /* Clear the Alarm flag */
1338
1339 /* Reload the counter */
1340 count = RTC_TIMEOUT_VALUE * (SystemCoreClock / 32U / 1000U);
1341
1342 /* Wait till RTC ALRBWF flag is set and if timeout is reached exit */
1343 do
1344 {
1345 count = count - 1U;
1346 if (count == 0U)
1347 {
1348 /* Enable the write protection for RTC registers */
1350
1352
1353 /* Process Unlocked */
1354 __HAL_UNLOCK(hrtc);
1355
1356 return HAL_TIMEOUT;
1357 }
1358 } while (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBWF) == 0U);
1359
1360 hrtc->Instance->ALRMBR = (uint32_t)tmpreg;
1361 /* Configure the Alarm B Subseconds register */
1362 hrtc->Instance->ALRMBSSR = subsecondtmpreg;
1363 /* Configure the Alarm state: Enable Alarm */
1365 /* Configure the Alarm interrupt */
1367 }
1368
1369 /* RTC Alarm Interrupt Configuration: EXTI configuration */
1372
1373 /* Enable the write protection for RTC registers */
1375
1376 /* Change RTC state back to READY */
1377 hrtc->State = HAL_RTC_STATE_READY;
1378
1379 /* Process Unlocked */
1380 __HAL_UNLOCK(hrtc);
1381
1382 return HAL_OK;
1383}
1384
1396{
1397 uint32_t tickstart = 0U;
1398
1399 /* Check the parameters */
1400 assert_param(IS_RTC_ALARM(Alarm));
1401
1402 /* Process Locked */
1403 __HAL_LOCK(hrtc);
1404
1405 hrtc->State = HAL_RTC_STATE_BUSY;
1406
1407 /* Disable the write protection for RTC registers */
1409
1410 if (Alarm == RTC_ALARM_A)
1411 {
1412 /* Disable Alarm A */
1414
1415 /* In case interrupt mode is used, the interrupt source must be disabled */
1417
1418 /* Get tick */
1419 tickstart = HAL_GetTick();
1420
1421 /* Wait till RTC ALRxWF flag is set and if timeout is reached exit */
1422 while (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAWF) == 0U)
1423 {
1424 if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
1425 {
1426 /* Enable the write protection for RTC registers */
1428
1430
1431 /* Process Unlocked */
1432 __HAL_UNLOCK(hrtc);
1433
1434 return HAL_TIMEOUT;
1435 }
1436 }
1437 }
1438 else
1439 {
1440 /* Disable Alarm B */
1442
1443 /* In case interrupt mode is used, the interrupt source must be disabled */
1445
1446 /* Get tick */
1447 tickstart = HAL_GetTick();
1448
1449 /* Wait till RTC ALRxWF flag is set and if timeout is reached exit */
1450 while (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBWF) == 0U)
1451 {
1452 if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
1453 {
1454 /* Enable the write protection for RTC registers */
1456
1458
1459 /* Process Unlocked */
1460 __HAL_UNLOCK(hrtc);
1461
1462 return HAL_TIMEOUT;
1463 }
1464 }
1465 }
1466
1467 /* Enable the write protection for RTC registers */
1469
1470 hrtc->State = HAL_RTC_STATE_READY;
1471
1472 /* Process Unlocked */
1473 __HAL_UNLOCK(hrtc);
1474
1475 return HAL_OK;
1476}
1477
1493HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format)
1494{
1495 uint32_t tmpreg = 0U;
1496 uint32_t subsecondtmpreg = 0U;
1497
1498 /* Check the parameters */
1499 assert_param(IS_RTC_FORMAT(Format));
1500 assert_param(IS_RTC_ALARM(Alarm));
1501
1502 if (Alarm == RTC_ALARM_A)
1503 {
1504 sAlarm->Alarm = RTC_ALARM_A;
1505
1506 tmpreg = (uint32_t)(hrtc->Instance->ALRMAR);
1507 subsecondtmpreg = (uint32_t)((hrtc->Instance->ALRMASSR) & RTC_ALRMASSR_SS);
1508 }
1509 else
1510 {
1511 sAlarm->Alarm = RTC_ALARM_B;
1512
1513 tmpreg = (uint32_t)(hrtc->Instance->ALRMBR);
1514 subsecondtmpreg = (uint32_t)((hrtc->Instance->ALRMBSSR) & RTC_ALRMBSSR_SS);
1515 }
1516
1517 /* Fill the structure with the read parameters */
1518 sAlarm->AlarmTime.Hours = (uint8_t) ((tmpreg & (RTC_ALRMAR_HT | RTC_ALRMAR_HU)) >> RTC_ALRMAR_HU_Pos);
1519 sAlarm->AlarmTime.Minutes = (uint8_t) ((tmpreg & (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU)) >> RTC_ALRMAR_MNU_Pos);
1520 sAlarm->AlarmTime.Seconds = (uint8_t) ( tmpreg & (RTC_ALRMAR_ST | RTC_ALRMAR_SU));
1521 sAlarm->AlarmTime.TimeFormat = (uint8_t) ((tmpreg & RTC_ALRMAR_PM) >> RTC_TR_PM_Pos);
1522 sAlarm->AlarmTime.SubSeconds = (uint32_t) subsecondtmpreg;
1523 sAlarm->AlarmDateWeekDay = (uint8_t) ((tmpreg & (RTC_ALRMAR_DT | RTC_ALRMAR_DU)) >> RTC_ALRMAR_DU_Pos);
1524 sAlarm->AlarmDateWeekDaySel = (uint32_t) (tmpreg & RTC_ALRMAR_WDSEL);
1525 sAlarm->AlarmMask = (uint32_t) (tmpreg & RTC_ALARMMASK_ALL);
1526
1527 if (Format == RTC_FORMAT_BIN)
1528 {
1529 sAlarm->AlarmTime.Hours = RTC_Bcd2ToByte(sAlarm->AlarmTime.Hours);
1533 }
1534
1535 return HAL_OK;
1536}
1537
1545{
1546 /* Clear the EXTI's line Flag for RTC Alarm */
1548
1549 /* Get the Alarm A interrupt source enable status */
1551 {
1552 /* Get the pending status of the Alarm A Interrupt */
1554 {
1555 /* Clear the Alarm A interrupt pending bit */
1557
1558 /* Alarm A callback */
1559#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
1560 hrtc->AlarmAEventCallback(hrtc);
1561#else
1563#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
1564 }
1565 }
1566
1567 /* Get the Alarm B interrupt source enable status */
1569 {
1570 /* Get the pending status of the Alarm B Interrupt */
1572 {
1573 /* Clear the Alarm B interrupt pending bit */
1575
1576 /* Alarm B callback */
1577#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
1578 hrtc->AlarmBEventCallback(hrtc);
1579#else
1581#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
1582 }
1583 }
1584
1585 /* Change RTC state */
1586 hrtc->State = HAL_RTC_STATE_READY;
1587}
1588
1596{
1597 /* Prevent unused argument(s) compilation warning */
1598 UNUSED(hrtc);
1599
1600 /* NOTE: This function should not be modified, when the callback is needed,
1601 the HAL_RTC_AlarmAEventCallback could be implemented in the user file
1602 */
1603}
1604
1613{
1614 uint32_t tickstart = 0U;
1615
1616 /* Get tick */
1617 tickstart = HAL_GetTick();
1618
1619 /* Wait till RTC ALRAF flag is set and if timeout is reached exit */
1620 while (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAF) == 0U)
1621 {
1622 if (Timeout != HAL_MAX_DELAY)
1623 {
1624 if ((Timeout == 0U) || ((HAL_GetTick() - tickstart) > Timeout))
1625 {
1627 return HAL_TIMEOUT;
1628 }
1629 }
1630 }
1631
1632 /* Clear the Alarm flag */
1634
1635 /* Change RTC state */
1636 hrtc->State = HAL_RTC_STATE_READY;
1637
1638 return HAL_OK;
1639}
1640
1677{
1678 uint32_t tickstart = 0U;
1679
1680 /* Clear RSF flag, keep reserved bits at reset values (setting other flags has no effect) */
1681 hrtc->Instance->ISR = ((uint32_t)(RTC_RSF_MASK & RTC_ISR_RESERVED_MASK));
1682
1683 /* Get tick */
1684 tickstart = HAL_GetTick();
1685
1686 /* Wait the registers to be synchronised */
1687 while ((hrtc->Instance->ISR & RTC_ISR_RSF) == 0U)
1688 {
1689 if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
1690 {
1691 return HAL_TIMEOUT;
1692 }
1693 }
1694
1695 return HAL_OK;
1696}
1697
1706{
1708 SET_BIT(hrtc->Instance->CR, RTC_CR_ADD1H);
1710}
1711
1720{
1722 SET_BIT(hrtc->Instance->CR, RTC_CR_SUB1H);
1724}
1725
1734{
1736 SET_BIT(hrtc->Instance->CR, RTC_CR_BKP);
1738}
1739
1747{
1749 CLEAR_BIT(hrtc->Instance->CR, RTC_CR_BKP);
1751}
1752
1759{
1760 return READ_BIT(hrtc->Instance->CR, RTC_CR_BKP);
1761}
1762
1788{
1789 return hrtc->State;
1790}
1791
1814{
1815 uint32_t tickstart = 0U;
1816 HAL_StatusTypeDef status = HAL_OK;
1817
1818 /* Check that Initialization mode is not already set */
1819 if (READ_BIT(hrtc->Instance->ISR, RTC_ISR_INITF) == 0U)
1820 {
1821 /* Set INIT bit to enter Initialization mode */
1822 SET_BIT(hrtc->Instance->ISR, RTC_ISR_INIT);
1823
1824 /* Get tick */
1825 tickstart = HAL_GetTick();
1826
1827 /* Wait till RTC is in INIT state and if timeout is reached exit */
1828 while ((READ_BIT(hrtc->Instance->ISR, RTC_ISR_INITF) == 0U) && (status != HAL_ERROR))
1829 {
1830 if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
1831 {
1832 /* Set RTC state */
1833 hrtc->State = HAL_RTC_STATE_ERROR;
1834 status = HAL_ERROR;
1835 }
1836 }
1837 }
1838
1839 return status;
1840}
1841
1849{
1850 HAL_StatusTypeDef status = HAL_OK;
1851
1852 /* Clear INIT bit to exit Initialization mode */
1853 CLEAR_BIT(hrtc->Instance->ISR, RTC_ISR_INIT);
1854
1855 /* If CR_BYPSHAD bit = 0, wait for synchro */
1856 if (READ_BIT(hrtc->Instance->CR, RTC_CR_BYPSHAD) == 0U)
1857 {
1858 if (HAL_RTC_WaitForSynchro(hrtc) != HAL_OK)
1859 {
1860 /* Set RTC state */
1861 hrtc->State = HAL_RTC_STATE_ERROR;
1862 status = HAL_ERROR;
1863 }
1864 }
1865
1866 return status;
1867}
1868
1874uint8_t RTC_ByteToBcd2(uint8_t number)
1875{
1876 uint32_t bcdhigh = 0U;
1877
1878 while (number >= 10U)
1879 {
1880 bcdhigh++;
1881 number -= 10U;
1882 }
1883
1884 return ((uint8_t)(bcdhigh << 4U) | number);
1885}
1886
1892uint8_t RTC_Bcd2ToByte(uint8_t number)
1893{
1894 uint32_t tens = 0U;
1895 tens = (((uint32_t)number & 0xF0U) >> 4U) * 10U;
1896 return (uint8_t)(tens + ((uint32_t)number & 0x0FU));
1897}
1898
1903#endif /* HAL_RTC_MODULE_ENABLED */
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc)
Timestamp callback.
void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc)
Tamper 1 callback.
void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc)
Wakeup Timer callback.
void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc)
Alarm B callback.
#define RTC_ALARMDATEWEEKDAYSEL_DATE
#define RTC_ALARMMASK_ALL
#define RTC_ALARM_B
#define RTC_ALARM_A
HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc)
DeInitializes the RTC peripheral.
void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc)
DeInitializes the RTC MSP.
HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc)
Initializes the RTC peripheral.
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
Initializes the RTC MSP.
HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format)
Gets RTC current date.
HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format)
Sets RTC current date.
HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format)
Gets RTC current time.
HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format)
Sets RTC current time.
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
Alarm A callback.
HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm)
Deactivates the specified RTC Alarm.
HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format)
Gets the RTC Alarm value and masks.
HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format)
Sets the specified RTC Alarm with Interrupt.
void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc)
Handles Alarm interrupt request.
HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
Handles Alarm A Polling request.
HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format)
Sets the specified RTC Alarm.
void HAL_RTC_DST_Add1Hour(RTC_HandleTypeDef *hrtc)
Daylight Saving Time, adds one hour to the calendar in one single operation without going through the...
HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc)
Waits until the RTC Time and Date registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock.
void HAL_RTC_DST_Sub1Hour(RTC_HandleTypeDef *hrtc)
Daylight Saving Time, subtracts one hour from the calendar in one single operation without going thro...
uint32_t HAL_RTC_DST_ReadStoreOperation(RTC_HandleTypeDef *hrtc)
Daylight Saving Time, reads the store operation bit.
void HAL_RTC_DST_ClearStoreOperation(RTC_HandleTypeDef *hrtc)
Daylight Saving Time, clears the store operation bit.
void HAL_RTC_DST_SetStoreOperation(RTC_HandleTypeDef *hrtc)
Daylight Saving Time, sets the store operation bit.
HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc)
Returns the RTC state.
#define __HAL_RTC_ALARMB_DISABLE(__HANDLE__)
Disable the RTC ALARMB peripheral.
#define __HAL_RTC_ALARM_EXTI_ENABLE_IT()
Enable interrupt on the RTC Alarm associated EXTI line.
#define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG()
Clear the RTC Alarm associated EXTI line flag.
#define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)
Check whether the specified RTC Alarm interrupt has been enabled or not.
#define __HAL_RTC_ALARMA_DISABLE(__HANDLE__)
Disable the RTC ALARMA peripheral.
#define __HAL_RTC_ALARMA_ENABLE(__HANDLE__)
Enable the RTC ALARMA peripheral.
#define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__)
Clear the RTC Alarm's pending flags.
#define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE()
Enable rising edge trigger on the RTC Alarm associated EXTI line.
#define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__)
Enable the write protection for RTC registers.
#define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__)
Get the selected RTC Alarm's flag status.
#define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__)
Enable the RTC Alarm interrupt.
#define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__)
Check whether the RTC Calendar is initialized.
#define __HAL_RTC_ALARMB_ENABLE(__HANDLE__)
Enable the RTC ALARMB peripheral.
#define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__)
Disable the RTC Alarm interrupt.
#define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__)
Disable the write protection for RTC registers.
HAL_RTCStateTypeDef
HAL State structures definition.
@ HAL_RTC_STATE_TIMEOUT
@ HAL_RTC_STATE_ERROR
@ HAL_RTC_STATE_READY
@ HAL_RTC_STATE_BUSY
@ HAL_RTC_STATE_RESET
#define RTC_FLAG_ALRBF
#define RTC_FLAG_ALRBWF
#define RTC_FLAG_ALRAWF
#define RTC_FLAG_ALRAF
#define IS_RTC_FORMAT(FORMAT)
#define IS_RTC_ALARM_MASK(MASK)
#define IS_RTC_OUTPUT_POL(POL)
#define IS_RTC_SYNCH_PREDIV(PREDIV)
#define IS_RTC_DATE(DATE)
#define IS_RTC_HOUR24(HOUR)
#define IS_RTC_DAYLIGHT_SAVING(SAVE)
#define IS_RTC_STORE_OPERATION(OPERATION)
#define IS_RTC_HOUR_FORMAT(FORMAT)
#define IS_RTC_OUTPUT_TYPE(TYPE)
#define IS_RTC_HOUR12(HOUR)
#define IS_RTC_MONTH(MONTH)
#define IS_RTC_MINUTES(MINUTES)
#define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE)
#define IS_RTC_HOURFORMAT12(PM)
#define IS_RTC_ALARM(ALARM)
#define IS_RTC_OUTPUT(OUTPUT)
#define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY)
#define IS_RTC_ASYNCH_PREDIV(PREDIV)
#define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL)
#define IS_RTC_SECONDS(SECONDS)
#define IS_RTC_YEAR(YEAR)
#define IS_RTC_ALARM_SUB_SECOND_MASK(MASK)
#define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE)
#define IS_RTC_WEEKDAY(WEEKDAY)
#define RTC_FORMAT_BIN
#define RTC_IT_ALRA
#define RTC_IT_ALRB
#define RTC_OUTPUT_TYPE_PUSHPULL
#define RTC_DR_RESERVED_MASK
#define RTC_RSF_MASK
#define RTC_ISR_RESERVED_MASK
#define RTC_TIMEOUT_VALUE
#define RTC_TR_RESERVED_MASK
uint8_t RTC_ByteToBcd2(uint8_t number)
Converts a 2-digit number from decimal to BCD format.
HAL_StatusTypeDef RTC_ExitInitMode(RTC_HandleTypeDef *hrtc)
Exits the RTC Initialization mode.
HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef *hrtc)
Enters the RTC Initialization mode.
uint8_t RTC_Bcd2ToByte(uint8_t number)
Converts a 2-digit number from BCD to decimal format.
#define assert_param(expr)
This file contains all the functions prototypes for the HAL module driver.
HAL_StatusTypeDef
HAL Status structures definition
@ HAL_TIMEOUT
@ HAL_ERROR
@ HAL_OK
#define UNUSED(X)
#define __HAL_UNLOCK(__HANDLE__)
#define HAL_MAX_DELAY
@ HAL_UNLOCKED
#define __HAL_LOCK(__HANDLE__)
RTC Alarm structure definition.
RTC_TimeTypeDef AlarmTime
RTC Date structure definition.
RTC Handle Structure definition.
RTC_InitTypeDef Init
__IO HAL_RTCStateTypeDef State
HAL_LockTypeDef Lock
RTC Time structure definition.