STM32F4xx HAL Driver master
STM32CubeF4 HAL / LL Drivers API Reference
Loading...
Searching...
No Matches
stm32f4xx_hal_rtc.c
Go to the documentation of this file.
1
189
190/* Includes ------------------------------------------------------------------*/
191#include "stm32f4xx_hal.h"
192
196
201
202#ifdef HAL_RTC_MODULE_ENABLED
203
204/* Private typedef -----------------------------------------------------------*/
205/* Private define ------------------------------------------------------------*/
206/* Private macro -------------------------------------------------------------*/
207/* Private variables ---------------------------------------------------------*/
208/* Private function prototypes -----------------------------------------------*/
209/* Exported functions --------------------------------------------------------*/
210
214
248
256{
257 HAL_StatusTypeDef status;
258
259 /* Check RTC handler validity */
260 if (hrtc == NULL)
261 {
262 return HAL_ERROR;
263 }
264
265 /* Check the parameters */
266 assert_param(IS_RTC_ALL_INSTANCE(hrtc->Instance));
273
274#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
275 if (hrtc->State == HAL_RTC_STATE_RESET)
276 {
277 /* Allocate lock resource and initialize it */
278 hrtc->Lock = HAL_UNLOCKED;
279
280 hrtc->AlarmAEventCallback = HAL_RTC_AlarmAEventCallback; /* Legacy weak AlarmAEventCallback */
281 hrtc->AlarmBEventCallback = HAL_RTCEx_AlarmBEventCallback; /* Legacy weak AlarmBEventCallback */
282 hrtc->TimeStampEventCallback = HAL_RTCEx_TimeStampEventCallback; /* Legacy weak TimeStampEventCallback */
283 hrtc->WakeUpTimerEventCallback = HAL_RTCEx_WakeUpTimerEventCallback; /* Legacy weak WakeUpTimerEventCallback */
284 hrtc->Tamper1EventCallback = HAL_RTCEx_Tamper1EventCallback; /* Legacy weak Tamper1EventCallback */
285#if defined(RTC_TAMPER2_SUPPORT)
286 hrtc->Tamper2EventCallback = HAL_RTCEx_Tamper2EventCallback; /* Legacy weak Tamper2EventCallback */
287#endif /* RTC_TAMPER2_SUPPORT */
288
289 if (hrtc->MspInitCallback == NULL)
290 {
291 hrtc->MspInitCallback = HAL_RTC_MspInit;
292 }
293 /* Init the low level hardware */
294 hrtc->MspInitCallback(hrtc);
295
296 if (hrtc->MspDeInitCallback == NULL)
297 {
298 hrtc->MspDeInitCallback = HAL_RTC_MspDeInit;
299 }
300 }
301#else /* USE_HAL_RTC_REGISTER_CALLBACKS */
302 if (hrtc->State == HAL_RTC_STATE_RESET)
303 {
304 /* Allocate lock resource and initialize it */
305 hrtc->Lock = HAL_UNLOCKED;
306
307 /* Initialize RTC MSP */
308 HAL_RTC_MspInit(hrtc);
309 }
310#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
311
312 /* Set RTC state */
314
315 /* Check whether the calendar needs to be initialized */
316 if (__HAL_RTC_IS_CALENDAR_INITIALIZED(hrtc) == 0U)
317 {
318 /* Disable the write protection for RTC registers */
320
321 /* Enter Initialization mode */
322 status = RTC_EnterInitMode(hrtc);
323
324 if (status == HAL_OK)
325 {
326 /* Clear RTC_CR FMT, OSEL and POL Bits */
327 hrtc->Instance->CR &= ((uint32_t)~(RTC_CR_FMT | RTC_CR_OSEL | RTC_CR_POL));
328 /* Set RTC_CR register */
329 hrtc->Instance->CR |= (uint32_t)(hrtc->Init.HourFormat | hrtc->Init.OutPut | hrtc->Init.OutPutPolarity);
330
331 /* Configure the RTC PRER */
332 hrtc->Instance->PRER = (uint32_t)(hrtc->Init.SynchPrediv);
333 hrtc->Instance->PRER |= (uint32_t)(hrtc->Init.AsynchPrediv << RTC_PRER_PREDIV_A_Pos);
334
335 /* Exit Initialization mode */
336 status = RTC_ExitInitMode(hrtc);
337 }
338
339 if (status == HAL_OK)
340 {
341 hrtc->Instance->TAFCR &= (uint32_t)~RTC_OUTPUT_TYPE_PUSHPULL;
342 hrtc->Instance->TAFCR |= (uint32_t)(hrtc->Init.OutPutType);
343 }
344
345 /* Enable the write protection for RTC registers */
347 }
348 else
349 {
350 /* The calendar is already initialized */
351 status = HAL_OK;
352 }
353
354 if (status == HAL_OK)
355 {
357 }
358
359 return status;
360}
361
370{
371 HAL_StatusTypeDef status;
372
373 /* Check the parameters */
374 assert_param(IS_RTC_ALL_INSTANCE(hrtc->Instance));
375
376 /* Set RTC state */
378
379 /* Disable the write protection for RTC registers */
381
382 /* Enter Initialization mode */
383 status = RTC_EnterInitMode(hrtc);
384
385 if (status == HAL_OK)
386 {
387 /* Reset RTC registers */
388 hrtc->Instance->TR = 0x00000000U;
389 hrtc->Instance->DR = (RTC_DR_WDU_0 | RTC_DR_MU_0 | RTC_DR_DU_0);
390 hrtc->Instance->CR = 0x00000000U;
391 hrtc->Instance->WUTR = RTC_WUTR_WUT;
392 hrtc->Instance->PRER = (uint32_t)(RTC_PRER_PREDIV_A | 0x000000FFU);
393 hrtc->Instance->CALIBR = 0x00000000U;
394 hrtc->Instance->ALRMAR = 0x00000000U;
395 hrtc->Instance->ALRMBR = 0x00000000U;
396 hrtc->Instance->CALR = 0x00000000U;
397 hrtc->Instance->SHIFTR = 0x00000000U;
398 hrtc->Instance->ALRMASSR = 0x00000000U;
399 hrtc->Instance->ALRMBSSR = 0x00000000U;
400
401 /* Exit Initialization mode */
402 status = RTC_ExitInitMode(hrtc);
403 }
404
405 /* Enable the write protection for RTC registers */
407
408 if (status == HAL_OK)
409 {
410 /* Reset Tamper and alternate functions configuration register */
411 hrtc->Instance->TAFCR = 0x00000000U;
412
413#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
414 if (hrtc->MspDeInitCallback == NULL)
415 {
416 hrtc->MspDeInitCallback = HAL_RTC_MspDeInit;
417 }
418
419 /* DeInit the low level hardware: CLOCK, NVIC.*/
420 hrtc->MspDeInitCallback(hrtc);
421#else /* USE_HAL_RTC_REGISTER_CALLBACKS */
422 /* De-Initialize RTC MSP */
423 HAL_RTC_MspDeInit(hrtc);
424#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
425
427 }
428
429 /* Release Lock */
430 __HAL_UNLOCK(hrtc);
431
432 return status;
433}
434
435#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
456HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback)
457{
458 HAL_StatusTypeDef status = HAL_OK;
459
460 if (pCallback == NULL)
461 {
462 return HAL_ERROR;
463 }
464
465 /* Process locked */
466 __HAL_LOCK(hrtc);
467
468 if (HAL_RTC_STATE_READY == hrtc->State)
469 {
470 switch (CallbackID)
471 {
472 case HAL_RTC_ALARM_A_EVENT_CB_ID :
473 hrtc->AlarmAEventCallback = pCallback;
474 break;
475
476 case HAL_RTC_ALARM_B_EVENT_CB_ID :
477 hrtc->AlarmBEventCallback = pCallback;
478 break;
479
480 case HAL_RTC_TIMESTAMP_EVENT_CB_ID :
481 hrtc->TimeStampEventCallback = pCallback;
482 break;
483
484 case HAL_RTC_WAKEUPTIMER_EVENT_CB_ID :
485 hrtc->WakeUpTimerEventCallback = pCallback;
486 break;
487
488 case HAL_RTC_TAMPER1_EVENT_CB_ID :
489 hrtc->Tamper1EventCallback = pCallback;
490 break;
491
492#if defined(RTC_TAMPER2_SUPPORT)
493 case HAL_RTC_TAMPER2_EVENT_CB_ID :
494 hrtc->Tamper2EventCallback = pCallback;
495 break;
496#endif /* RTC_TAMPER2_SUPPORT */
497
498 case HAL_RTC_MSPINIT_CB_ID :
499 hrtc->MspInitCallback = pCallback;
500 break;
501
502 case HAL_RTC_MSPDEINIT_CB_ID :
503 hrtc->MspDeInitCallback = pCallback;
504 break;
505
506 default :
507 /* Return error status */
508 status = HAL_ERROR;
509 break;
510 }
511 }
512 else if (HAL_RTC_STATE_RESET == hrtc->State)
513 {
514 switch (CallbackID)
515 {
516 case HAL_RTC_MSPINIT_CB_ID :
517 hrtc->MspInitCallback = pCallback;
518 break;
519
520 case HAL_RTC_MSPDEINIT_CB_ID :
521 hrtc->MspDeInitCallback = pCallback;
522 break;
523
524 default :
525 /* Return error status */
526 status = HAL_ERROR;
527 break;
528 }
529 }
530 else
531 {
532 /* Return error status */
533 status = HAL_ERROR;
534 }
535
536 /* Release Lock */
537 __HAL_UNLOCK(hrtc);
538
539 return status;
540}
541
561HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID)
562{
563 HAL_StatusTypeDef status = HAL_OK;
564
565 /* Process locked */
566 __HAL_LOCK(hrtc);
567
568 if (HAL_RTC_STATE_READY == hrtc->State)
569 {
570 switch (CallbackID)
571 {
572 case HAL_RTC_ALARM_A_EVENT_CB_ID :
573 hrtc->AlarmAEventCallback = HAL_RTC_AlarmAEventCallback; /* Legacy weak AlarmAEventCallback */
574 break;
575
576 case HAL_RTC_ALARM_B_EVENT_CB_ID :
577 hrtc->AlarmBEventCallback = HAL_RTCEx_AlarmBEventCallback; /* Legacy weak AlarmBEventCallback */
578 break;
579
580 case HAL_RTC_TIMESTAMP_EVENT_CB_ID :
581 hrtc->TimeStampEventCallback = HAL_RTCEx_TimeStampEventCallback; /* Legacy weak TimeStampEventCallback */
582 break;
583
584 case HAL_RTC_WAKEUPTIMER_EVENT_CB_ID :
585 hrtc->WakeUpTimerEventCallback = HAL_RTCEx_WakeUpTimerEventCallback; /* Legacy weak WakeUpTimerEventCallback */
586 break;
587
588 case HAL_RTC_TAMPER1_EVENT_CB_ID :
589 hrtc->Tamper1EventCallback = HAL_RTCEx_Tamper1EventCallback; /* Legacy weak Tamper1EventCallback */
590 break;
591
592#if defined(RTC_TAMPER2_SUPPORT)
593 case HAL_RTC_TAMPER2_EVENT_CB_ID :
594 hrtc->Tamper2EventCallback = HAL_RTCEx_Tamper2EventCallback; /* Legacy weak Tamper2EventCallback */
595 break;
596#endif /* RTC_TAMPER2_SUPPORT */
597
598 case HAL_RTC_MSPINIT_CB_ID :
599 hrtc->MspInitCallback = HAL_RTC_MspInit;
600 break;
601
602 case HAL_RTC_MSPDEINIT_CB_ID :
603 hrtc->MspDeInitCallback = HAL_RTC_MspDeInit;
604 break;
605
606 default :
607 /* Return error status */
608 status = HAL_ERROR;
609 break;
610 }
611 }
612 else if (HAL_RTC_STATE_RESET == hrtc->State)
613 {
614 switch (CallbackID)
615 {
616 case HAL_RTC_MSPINIT_CB_ID :
617 hrtc->MspInitCallback = HAL_RTC_MspInit;
618 break;
619
620 case HAL_RTC_MSPDEINIT_CB_ID :
621 hrtc->MspDeInitCallback = HAL_RTC_MspDeInit;
622 break;
623
624 default :
625 /* Return error status */
626 status = HAL_ERROR;
627 break;
628 }
629 }
630 else
631 {
632 /* Return error status */
633 status = HAL_ERROR;
634 }
635
636 /* Release Lock */
637 __HAL_UNLOCK(hrtc);
638
639 return status;
640}
641#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
642
649__weak void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
650{
651 /* Prevent unused argument(s) compilation warning */
652 UNUSED(hrtc);
653
654 /* NOTE: This function should not be modified, when the callback is needed,
655 the HAL_RTC_MspInit could be implemented in the user file
656 */
657}
658
665__weak void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc)
666{
667 /* Prevent unused argument(s) compilation warning */
668 UNUSED(hrtc);
669
670 /* NOTE: This function should not be modified, when the callback is needed,
671 the HAL_RTC_MspDeInit could be implemented in the user file
672 */
673}
674
678
692
707{
708 uint32_t tmpreg = 0U;
709 HAL_StatusTypeDef status;
710
711 /* Check the parameters */
715
716 /* Process Locked */
717 __HAL_LOCK(hrtc);
718
720
721 if (Format == RTC_FORMAT_BIN)
722 {
723 if ((hrtc->Instance->CR & RTC_CR_FMT) != 0U)
724 {
727 }
728 else
729 {
730 sTime->TimeFormat = 0x00U;
732 }
735
736 tmpreg = (uint32_t)(( (uint32_t)RTC_ByteToBcd2(sTime->Hours) << RTC_TR_HU_Pos) | \
737 ( (uint32_t)RTC_ByteToBcd2(sTime->Minutes) << RTC_TR_MNU_Pos) | \
738 ( (uint32_t)RTC_ByteToBcd2(sTime->Seconds)) | \
739 (((uint32_t)sTime->TimeFormat) << RTC_TR_PM_Pos));
740 }
741 else
742 {
743 if ((hrtc->Instance->CR & RTC_CR_FMT) != 0U)
744 {
747 }
748 else
749 {
750 sTime->TimeFormat = 0x00U;
752 }
755 tmpreg = (((uint32_t)(sTime->Hours) << RTC_TR_HU_Pos) | \
756 ((uint32_t)(sTime->Minutes) << RTC_TR_MNU_Pos) | \
757 ((uint32_t) sTime->Seconds) | \
758 ((uint32_t)(sTime->TimeFormat) << RTC_TR_PM_Pos));
759 }
760
761 /* Disable the write protection for RTC registers */
763
764 /* Enter Initialization mode */
765 status = RTC_EnterInitMode(hrtc);
766
767 if (status == HAL_OK)
768 {
769 /* Set the RTC_TR register */
770 hrtc->Instance->TR = (uint32_t)(tmpreg & RTC_TR_RESERVED_MASK);
771
772 /* Clear the bits to be configured (Deprecated. Use HAL_RTC_DST_xxx functions instead) */
773 hrtc->Instance->CR &= (uint32_t)~RTC_CR_BKP;
774
775 /* Configure the RTC_CR register (Deprecated. Use HAL_RTC_DST_xxx functions instead) */
776 hrtc->Instance->CR |= (uint32_t)(sTime->DayLightSaving | sTime->StoreOperation);
777
778 /* Exit Initialization mode */
779 status = RTC_ExitInitMode(hrtc);
780 }
781
782 if (status == HAL_OK)
783 {
785 }
786
787 /* Enable the write protection for RTC registers */
789
790 /* Process Unlocked */
791 __HAL_UNLOCK(hrtc);
792
793 return status;
794}
795
821{
822 uint32_t tmpreg = 0U;
823
824 /* Check the parameters */
826
827 /* Get subseconds value from the corresponding register */
828 sTime->SubSeconds = (uint32_t)(hrtc->Instance->SSR);
829
830 /* Get SecondFraction structure field from the corresponding register field*/
831 sTime->SecondFraction = (uint32_t)(hrtc->Instance->PRER & RTC_PRER_PREDIV_S);
832
833 /* Get the TR register */
834 tmpreg = (uint32_t)(hrtc->Instance->TR & RTC_TR_RESERVED_MASK);
835
836 /* Fill the structure fields with the read parameters */
837 sTime->Hours = (uint8_t)((tmpreg & (RTC_TR_HT | RTC_TR_HU)) >> RTC_TR_HU_Pos);
838 sTime->Minutes = (uint8_t)((tmpreg & (RTC_TR_MNT | RTC_TR_MNU)) >> RTC_TR_MNU_Pos);
839 sTime->Seconds = (uint8_t)( tmpreg & (RTC_TR_ST | RTC_TR_SU));
840 sTime->TimeFormat = (uint8_t)((tmpreg & (RTC_TR_PM)) >> RTC_TR_PM_Pos);
841
842 /* Check the input parameters format */
843 if (Format == RTC_FORMAT_BIN)
844 {
845 /* Convert the time structure parameters to Binary format */
846 sTime->Hours = (uint8_t)RTC_Bcd2ToByte(sTime->Hours);
847 sTime->Minutes = (uint8_t)RTC_Bcd2ToByte(sTime->Minutes);
848 sTime->Seconds = (uint8_t)RTC_Bcd2ToByte(sTime->Seconds);
849 }
850
851 return HAL_OK;
852}
853
866{
867 uint32_t datetmpreg = 0U;
868 HAL_StatusTypeDef status;
869
870 /* Check the parameters */
872
873 /* Process Locked */
874 __HAL_LOCK(hrtc);
875
877
878 if ((Format == RTC_FORMAT_BIN) && ((sDate->Month & 0x10U) == 0x10U))
879 {
880 sDate->Month = (uint8_t)((sDate->Month & (uint8_t)~(0x10U)) + (uint8_t)0x0AU);
881 }
882
884
885 if (Format == RTC_FORMAT_BIN)
886 {
890
891 datetmpreg = (((uint32_t)RTC_ByteToBcd2(sDate->Year) << RTC_DR_YU_Pos) | \
892 ((uint32_t)RTC_ByteToBcd2(sDate->Month) << RTC_DR_MU_Pos) | \
893 ((uint32_t)RTC_ByteToBcd2(sDate->Date)) | \
894 ((uint32_t)sDate->WeekDay << RTC_DR_WDU_Pos));
895 }
896 else
897 {
901
902 datetmpreg = ((((uint32_t)sDate->Year) << RTC_DR_YU_Pos) | \
903 (((uint32_t)sDate->Month) << RTC_DR_MU_Pos) | \
904 ((uint32_t) sDate->Date) | \
905 (((uint32_t)sDate->WeekDay) << RTC_DR_WDU_Pos));
906 }
907
908 /* Disable the write protection for RTC registers */
910
911 /* Enter Initialization mode */
912 status = RTC_EnterInitMode(hrtc);
913
914 if (status == HAL_OK)
915 {
916 /* Set the RTC_DR register */
917 hrtc->Instance->DR = (uint32_t)(datetmpreg & RTC_DR_RESERVED_MASK);
918
919 /* Exit Initialization mode */
920 status = RTC_ExitInitMode(hrtc);
921 }
922
923 if (status == HAL_OK)
924 {
926 }
927
928 /* Enable the write protection for RTC registers */
930
931 /* Process Unlocked */
932 __HAL_UNLOCK(hrtc);
933
934 return status;
935}
936
955{
956 uint32_t datetmpreg = 0U;
957
958 /* Check the parameters */
960
961 /* Get the DR register */
962 datetmpreg = (uint32_t)(hrtc->Instance->DR & RTC_DR_RESERVED_MASK);
963
964 /* Fill the structure fields with the read parameters */
965 sDate->Year = (uint8_t)((datetmpreg & (RTC_DR_YT | RTC_DR_YU)) >> RTC_DR_YU_Pos);
966 sDate->Month = (uint8_t)((datetmpreg & (RTC_DR_MT | RTC_DR_MU)) >> RTC_DR_MU_Pos);
967 sDate->Date = (uint8_t) (datetmpreg & (RTC_DR_DT | RTC_DR_DU));
968 sDate->WeekDay = (uint8_t)((datetmpreg & (RTC_DR_WDU)) >> RTC_DR_WDU_Pos);
969
970 /* Check the input parameters format */
971 if (Format == RTC_FORMAT_BIN)
972 {
973 /* Convert the date structure parameters to Binary format */
974 sDate->Year = (uint8_t)RTC_Bcd2ToByte(sDate->Year);
975 sDate->Month = (uint8_t)RTC_Bcd2ToByte(sDate->Month);
976 sDate->Date = (uint8_t)RTC_Bcd2ToByte(sDate->Date);
977 }
978 return HAL_OK;
979}
980
984
1013{
1014 uint32_t tickstart = 0U;
1015 uint32_t tmpreg = 0U;
1016 uint32_t subsecondtmpreg = 0U;
1017
1018 /* Check the parameters */
1019 assert_param(IS_RTC_FORMAT(Format));
1025
1026 /* Process Locked */
1027 __HAL_LOCK(hrtc);
1028
1029 /* Change RTC state to BUSY */
1030 hrtc->State = HAL_RTC_STATE_BUSY;
1031
1032 /* Check the data format (binary or BCD) and store the Alarm time and date
1033 configuration accordingly */
1034 if (Format == RTC_FORMAT_BIN)
1035 {
1036 if ((hrtc->Instance->CR & RTC_CR_FMT) != 0U)
1037 {
1040 }
1041 else
1042 {
1043 sAlarm->AlarmTime.TimeFormat = 0x00U;
1045 }
1048
1050 {
1052 }
1053 else
1054 {
1056 }
1057
1058 tmpreg = (((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Hours) << RTC_ALRMAR_HU_Pos) | \
1059 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Minutes) << RTC_ALRMAR_MNU_Pos) | \
1060 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Seconds)) | \
1061 ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << RTC_ALRMAR_PM_Pos) | \
1062 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmDateWeekDay) << RTC_ALRMAR_DU_Pos) | \
1063 ((uint32_t)sAlarm->AlarmDateWeekDaySel) | \
1064 ((uint32_t)sAlarm->AlarmMask));
1065 }
1066 else
1067 {
1068 if ((hrtc->Instance->CR & RTC_CR_FMT) != 0U)
1069 {
1072 }
1073 else
1074 {
1075 sAlarm->AlarmTime.TimeFormat = 0x00U;
1077 }
1078
1081
1083 {
1085 }
1086 else
1087 {
1089 }
1090
1091 tmpreg = (((uint32_t)(sAlarm->AlarmTime.Hours) << RTC_ALRMAR_HU_Pos) | \
1092 ((uint32_t)(sAlarm->AlarmTime.Minutes) << RTC_ALRMAR_MNU_Pos) | \
1093 ((uint32_t) sAlarm->AlarmTime.Seconds) | \
1094 ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << RTC_ALRMAR_PM_Pos) | \
1095 ((uint32_t)(sAlarm->AlarmDateWeekDay) << RTC_ALRMAR_DU_Pos) | \
1096 ((uint32_t) sAlarm->AlarmDateWeekDaySel) | \
1097 ((uint32_t) sAlarm->AlarmMask));
1098 }
1099
1100 /* Store the Alarm subseconds configuration */
1101 subsecondtmpreg = (uint32_t)((uint32_t)(sAlarm->AlarmTime.SubSeconds) | \
1102 (uint32_t)(sAlarm->AlarmSubSecondMask));
1103
1104 /* Disable the write protection for RTC registers */
1106
1107 if (sAlarm->Alarm == RTC_ALARM_A)
1108 {
1109 /* Disable Alarm A */
1111
1112 /* In case interrupt mode is used, the interrupt source must be disabled */
1114
1115 /* Clear Alarm A flag */
1117
1118 /* Get tick */
1119 tickstart = HAL_GetTick();
1120
1121 /* Wait till RTC ALRAWF flag is set and if timeout is reached exit */
1122 while (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAWF) == 0U)
1123 {
1124 if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
1125 {
1126 /* Enable the write protection for RTC registers */
1128
1130
1131 /* Process Unlocked */
1132 __HAL_UNLOCK(hrtc);
1133
1134 return HAL_TIMEOUT;
1135 }
1136 }
1137
1138 /* Configure Alarm A register */
1139 hrtc->Instance->ALRMAR = (uint32_t)tmpreg;
1140 /* Configure Alarm A Subseconds register */
1141 hrtc->Instance->ALRMASSR = subsecondtmpreg;
1142 /* Enable Alarm A */
1144 }
1145 else
1146 {
1147 /* Disable Alarm B */
1149
1150 /* In case interrupt mode is used, the interrupt source must be disabled */
1152
1153 /* Clear Alarm B flag */
1155
1156 /* Get tick */
1157 tickstart = HAL_GetTick();
1158
1159 /* Wait till RTC ALRBWF flag is set and if timeout is reached exit */
1160 while (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBWF) == 0U)
1161 {
1162 if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
1163 {
1164 /* Enable the write protection for RTC registers */
1166
1168
1169 /* Process Unlocked */
1170 __HAL_UNLOCK(hrtc);
1171
1172 return HAL_TIMEOUT;
1173 }
1174 }
1175
1176 /* Configure Alarm B register */
1177 hrtc->Instance->ALRMBR = (uint32_t)tmpreg;
1178 /* Configure Alarm B Subseconds register */
1179 hrtc->Instance->ALRMBSSR = subsecondtmpreg;
1180 /* Enable Alarm B */
1182 }
1183
1184 /* Enable the write protection for RTC registers */
1186
1187 /* Change RTC state back to READY */
1188 hrtc->State = HAL_RTC_STATE_READY;
1189
1190 /* Process Unlocked */
1191 __HAL_UNLOCK(hrtc);
1192
1193 return HAL_OK;
1194}
1195
1211{
1212 __IO uint32_t count = RTC_TIMEOUT_VALUE * (SystemCoreClock / 32U / 1000U);
1213 uint32_t tmpreg = 0U;
1214 uint32_t subsecondtmpreg = 0U;
1215
1216 /* Check the parameters */
1217 assert_param(IS_RTC_FORMAT(Format));
1223
1224 /* Process Locked */
1225 __HAL_LOCK(hrtc);
1226
1227 /* Change RTC state to BUSY */
1228 hrtc->State = HAL_RTC_STATE_BUSY;
1229
1230 /* Check the data format (binary or BCD) and store the Alarm time and date
1231 configuration accordingly */
1232 if (Format == RTC_FORMAT_BIN)
1233 {
1234 if ((hrtc->Instance->CR & RTC_CR_FMT) != 0U)
1235 {
1238 }
1239 else
1240 {
1241 sAlarm->AlarmTime.TimeFormat = 0x00U;
1243 }
1246
1248 {
1250 }
1251 else
1252 {
1254 }
1255
1256 tmpreg = (((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Hours) << RTC_ALRMAR_HU_Pos) | \
1257 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Minutes) << RTC_ALRMAR_MNU_Pos) | \
1258 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Seconds)) | \
1259 ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << RTC_ALRMAR_PM_Pos) | \
1260 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmDateWeekDay) << RTC_ALRMAR_DU_Pos) | \
1261 ((uint32_t)sAlarm->AlarmDateWeekDaySel) | \
1262 ((uint32_t)sAlarm->AlarmMask));
1263 }
1264 else
1265 {
1266 if ((hrtc->Instance->CR & RTC_CR_FMT) != 0U)
1267 {
1270 }
1271 else
1272 {
1273 sAlarm->AlarmTime.TimeFormat = 0x00U;
1275 }
1276
1279
1281 {
1283 }
1284 else
1285 {
1287 }
1288
1289 tmpreg = (((uint32_t)(sAlarm->AlarmTime.Hours) << RTC_ALRMAR_HU_Pos) | \
1290 ((uint32_t)(sAlarm->AlarmTime.Minutes) << RTC_ALRMAR_MNU_Pos) | \
1291 ((uint32_t) sAlarm->AlarmTime.Seconds) | \
1292 ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << RTC_ALRMAR_PM_Pos) | \
1293 ((uint32_t)(sAlarm->AlarmDateWeekDay) << RTC_ALRMAR_DU_Pos) | \
1294 ((uint32_t) sAlarm->AlarmDateWeekDaySel) | \
1295 ((uint32_t) sAlarm->AlarmMask));
1296 }
1297
1298 /* Store the Alarm subseconds configuration */
1299 subsecondtmpreg = (uint32_t)((uint32_t)(sAlarm->AlarmTime.SubSeconds) | \
1300 (uint32_t)(sAlarm->AlarmSubSecondMask));
1301
1302 /* Disable the write protection for RTC registers */
1304
1305 if (sAlarm->Alarm == RTC_ALARM_A)
1306 {
1307 /* Disable Alarm A */
1309
1310 /* Clear Alarm A flag */
1312
1313 /* Wait till RTC ALRAWF flag is set and if timeout is reached exit */
1314 do
1315 {
1316 count = count - 1U;
1317 if (count == 0U)
1318 {
1319 /* Enable the write protection for RTC registers */
1321
1323
1324 /* Process Unlocked */
1325 __HAL_UNLOCK(hrtc);
1326
1327 return HAL_TIMEOUT;
1328 }
1329 } while (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAWF) == 0U);
1330
1331 /* Configure Alarm A register */
1332 hrtc->Instance->ALRMAR = (uint32_t)tmpreg;
1333 /* Configure Alarm A Subseconds register */
1334 hrtc->Instance->ALRMASSR = subsecondtmpreg;
1335 /* Enable Alarm A */
1337 /* Enable Alarm A interrupt */
1339 }
1340 else
1341 {
1342 /* Disable Alarm B */
1344
1345 /* Clear Alarm B flag */
1347
1348 /* Reload the counter */
1349 count = RTC_TIMEOUT_VALUE * (SystemCoreClock / 32U / 1000U);
1350
1351 /* Wait till RTC ALRBWF flag is set and if timeout is reached exit */
1352 do
1353 {
1354 count = count - 1U;
1355 if (count == 0U)
1356 {
1357 /* Enable the write protection for RTC registers */
1359
1361
1362 /* Process Unlocked */
1363 __HAL_UNLOCK(hrtc);
1364
1365 return HAL_TIMEOUT;
1366 }
1367 } while (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBWF) == 0U);
1368
1369 /* Configure Alarm B register */
1370 hrtc->Instance->ALRMBR = (uint32_t)tmpreg;
1371 /* Configure Alarm B Subseconds register */
1372 hrtc->Instance->ALRMBSSR = subsecondtmpreg;
1373 /* Enable Alarm B */
1375 /* Enable Alarm B interrupt */
1377 }
1378
1379 /* Enable and configure the EXTI line associated to the RTC Alarm interrupt */
1382
1383 /* Enable the write protection for RTC registers */
1385
1386 /* Change RTC state back to READY */
1387 hrtc->State = HAL_RTC_STATE_READY;
1388
1389 /* Process Unlocked */
1390 __HAL_UNLOCK(hrtc);
1391
1392 return HAL_OK;
1393}
1394
1406{
1407 uint32_t tickstart = 0U;
1408
1409 /* Check the parameters */
1410 assert_param(IS_RTC_ALARM(Alarm));
1411
1412 /* Process Locked */
1413 __HAL_LOCK(hrtc);
1414
1415 hrtc->State = HAL_RTC_STATE_BUSY;
1416
1417 /* Disable the write protection for RTC registers */
1419
1420 if (Alarm == RTC_ALARM_A)
1421 {
1422 /* Disable Alarm A */
1424
1425 /* In case interrupt mode is used, the interrupt source must be disabled */
1427
1428 /* Get tick */
1429 tickstart = HAL_GetTick();
1430
1431 /* Wait till RTC ALRAWF flag is set and if timeout is reached exit */
1432 while (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAWF) == 0U)
1433 {
1434 if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
1435 {
1436 /* Enable the write protection for RTC registers */
1438
1440
1441 /* Process Unlocked */
1442 __HAL_UNLOCK(hrtc);
1443
1444 return HAL_TIMEOUT;
1445 }
1446 }
1447 }
1448 else
1449 {
1450 /* Disable Alarm B */
1452
1453 /* In case interrupt mode is used, the interrupt source must be disabled */
1455
1456 /* Get tick */
1457 tickstart = HAL_GetTick();
1458
1459 /* Wait till RTC ALRBWF flag is set and if timeout is reached exit */
1460 while (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBWF) == 0U)
1461 {
1462 if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
1463 {
1464 /* Enable the write protection for RTC registers */
1466
1468
1469 /* Process Unlocked */
1470 __HAL_UNLOCK(hrtc);
1471
1472 return HAL_TIMEOUT;
1473 }
1474 }
1475 }
1476
1477 /* Enable the write protection for RTC registers */
1479
1480 hrtc->State = HAL_RTC_STATE_READY;
1481
1482 /* Process Unlocked */
1483 __HAL_UNLOCK(hrtc);
1484
1485 return HAL_OK;
1486}
1487
1503HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format)
1504{
1505 uint32_t tmpreg = 0U;
1506 uint32_t subsecondtmpreg = 0U;
1507
1508 /* Check the parameters */
1509 assert_param(IS_RTC_FORMAT(Format));
1510 assert_param(IS_RTC_ALARM(Alarm));
1511
1512 if (Alarm == RTC_ALARM_A)
1513 {
1514 sAlarm->Alarm = RTC_ALARM_A;
1515
1516 tmpreg = (uint32_t)(hrtc->Instance->ALRMAR);
1517 subsecondtmpreg = (uint32_t)((hrtc->Instance->ALRMASSR) & RTC_ALRMASSR_SS);
1518 }
1519 else
1520 {
1521 sAlarm->Alarm = RTC_ALARM_B;
1522
1523 tmpreg = (uint32_t)(hrtc->Instance->ALRMBR);
1524 subsecondtmpreg = (uint32_t)((hrtc->Instance->ALRMBSSR) & RTC_ALRMBSSR_SS);
1525 }
1526
1527 /* Fill the structure with the read parameters */
1528 sAlarm->AlarmTime.Hours = (uint8_t) ((tmpreg & (RTC_ALRMAR_HT | RTC_ALRMAR_HU)) >> RTC_ALRMAR_HU_Pos);
1529 sAlarm->AlarmTime.Minutes = (uint8_t) ((tmpreg & (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU)) >> RTC_ALRMAR_MNU_Pos);
1530 sAlarm->AlarmTime.Seconds = (uint8_t) ( tmpreg & (RTC_ALRMAR_ST | RTC_ALRMAR_SU));
1531 sAlarm->AlarmTime.TimeFormat = (uint8_t) ((tmpreg & RTC_ALRMAR_PM) >> RTC_TR_PM_Pos);
1532 sAlarm->AlarmTime.SubSeconds = (uint32_t) subsecondtmpreg;
1533 sAlarm->AlarmDateWeekDay = (uint8_t) ((tmpreg & (RTC_ALRMAR_DT | RTC_ALRMAR_DU)) >> RTC_ALRMAR_DU_Pos);
1534 sAlarm->AlarmDateWeekDaySel = (uint32_t) (tmpreg & RTC_ALRMAR_WDSEL);
1535 sAlarm->AlarmMask = (uint32_t) (tmpreg & RTC_ALARMMASK_ALL);
1536
1537 if (Format == RTC_FORMAT_BIN)
1538 {
1539 sAlarm->AlarmTime.Hours = RTC_Bcd2ToByte(sAlarm->AlarmTime.Hours);
1543 }
1544
1545 return HAL_OK;
1546}
1547
1555{
1556 /* Clear the EXTI flag associated to the RTC Alarm interrupt */
1558
1559 /* Get the Alarm A interrupt source enable status */
1561 {
1562 /* Get the pending status of the Alarm A Interrupt */
1564 {
1565 /* Clear the Alarm A interrupt pending bit */
1567
1568 /* Alarm A callback */
1569#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
1570 hrtc->AlarmAEventCallback(hrtc);
1571#else
1573#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
1574 }
1575 }
1576
1577 /* Get the Alarm B interrupt source enable status */
1579 {
1580 /* Get the pending status of the Alarm B Interrupt */
1582 {
1583 /* Clear the Alarm B interrupt pending bit */
1585
1586 /* Alarm B callback */
1587#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
1588 hrtc->AlarmBEventCallback(hrtc);
1589#else
1591#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
1592 }
1593 }
1594
1595 /* Change RTC state */
1596 hrtc->State = HAL_RTC_STATE_READY;
1597}
1598
1606{
1607 /* Prevent unused argument(s) compilation warning */
1608 UNUSED(hrtc);
1609
1610 /* NOTE: This function should not be modified, when the callback is needed,
1611 the HAL_RTC_AlarmAEventCallback could be implemented in the user file
1612 */
1613}
1614
1623{
1624 uint32_t tickstart = 0U;
1625
1626 /* Get tick */
1627 tickstart = HAL_GetTick();
1628
1629 /* Wait till RTC ALRAF flag is set and if timeout is reached exit */
1630 while (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAF) == 0U)
1631 {
1632 if (Timeout != HAL_MAX_DELAY)
1633 {
1634 if ((Timeout == 0U) || ((HAL_GetTick() - tickstart) > Timeout))
1635 {
1637 return HAL_TIMEOUT;
1638 }
1639 }
1640 }
1641
1642 /* Clear the Alarm flag */
1644
1645 /* Change RTC state */
1646 hrtc->State = HAL_RTC_STATE_READY;
1647
1648 return HAL_OK;
1649}
1650
1654
1670
1687{
1688 uint32_t tickstart = 0U;
1689
1690 /* Clear RSF flag, keep reserved bits at reset values (setting other flags has no effect) */
1691 hrtc->Instance->ISR = ((uint32_t)(RTC_RSF_MASK & RTC_ISR_RESERVED_MASK));
1692
1693 /* Get tick */
1694 tickstart = HAL_GetTick();
1695
1696 /* Wait the registers to be synchronised */
1697 while ((hrtc->Instance->ISR & RTC_ISR_RSF) == 0U)
1698 {
1699 if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
1700 {
1701 return HAL_TIMEOUT;
1702 }
1703 }
1704
1705 return HAL_OK;
1706}
1707
1716{
1718 SET_BIT(hrtc->Instance->CR, RTC_CR_ADD1H);
1720}
1721
1730{
1732 SET_BIT(hrtc->Instance->CR, RTC_CR_SUB1H);
1734}
1735
1744{
1746 SET_BIT(hrtc->Instance->CR, RTC_CR_BKP);
1748}
1749
1757{
1759 CLEAR_BIT(hrtc->Instance->CR, RTC_CR_BKP);
1761}
1762
1769{
1770 return READ_BIT(hrtc->Instance->CR, RTC_CR_BKP);
1771}
1772
1776
1798{
1799 return hrtc->State;
1800}
1801
1805
1806
1810
1814
1824{
1825 uint32_t tickstart = 0U;
1826 HAL_StatusTypeDef status = HAL_OK;
1827
1828 /* Check that Initialization mode is not already set */
1829 if (READ_BIT(hrtc->Instance->ISR, RTC_ISR_INITF) == 0U)
1830 {
1831 /* Set INIT bit to enter Initialization mode */
1832 SET_BIT(hrtc->Instance->ISR, RTC_ISR_INIT);
1833
1834 /* Get tick */
1835 tickstart = HAL_GetTick();
1836
1837 /* Wait till RTC is in INIT state and if timeout is reached exit */
1838 while ((READ_BIT(hrtc->Instance->ISR, RTC_ISR_INITF) == 0U) && (status != HAL_ERROR))
1839 {
1840 if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
1841 {
1842 /* Set RTC state */
1843 hrtc->State = HAL_RTC_STATE_ERROR;
1844 status = HAL_ERROR;
1845 }
1846 }
1847 }
1848
1849 return status;
1850}
1851
1859{
1860 HAL_StatusTypeDef status = HAL_OK;
1861
1862 /* Clear INIT bit to exit Initialization mode */
1863 CLEAR_BIT(hrtc->Instance->ISR, RTC_ISR_INIT);
1864
1865 /* If CR_BYPSHAD bit = 0, wait for synchro */
1866 if (READ_BIT(hrtc->Instance->CR, RTC_CR_BYPSHAD) == 0U)
1867 {
1868 if (HAL_RTC_WaitForSynchro(hrtc) != HAL_OK)
1869 {
1870 /* Set RTC state */
1871 hrtc->State = HAL_RTC_STATE_ERROR;
1872 status = HAL_ERROR;
1873 }
1874 }
1875
1876 return status;
1877}
1878
1884uint8_t RTC_ByteToBcd2(uint8_t number)
1885{
1886 uint32_t bcdhigh = 0U;
1887
1888 while (number >= 10U)
1889 {
1890 bcdhigh++;
1891 number -= 10U;
1892 }
1893
1894 return ((uint8_t)(bcdhigh << 4U) | number);
1895}
1896
1902uint8_t RTC_Bcd2ToByte(uint8_t number)
1903{
1904 uint32_t tens = 0U;
1905 tens = (((uint32_t)number & 0xF0U) >> 4U) * 10U;
1906 return (uint8_t)(tens + ((uint32_t)number & 0x0FU));
1907}
1908
1912
1913#endif /* HAL_RTC_MODULE_ENABLED */
1917
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc)
void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc)
void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc)
Wake Up Timer Event Callback in non blocking mode.
void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc)
#define RTC_ALARMDATEWEEKDAYSEL_DATE
#define RTC_ALARMMASK_ALL
#define RTC_ALARM_B
#define RTC_ALARM_A
HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc)
void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc)
HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc)
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format)
HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format)
HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format)
HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format)
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
ALARM A Event Callback in non blocking mode.
HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm)
HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format)
HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format)
void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc)
HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format)
void HAL_RTC_DST_Add1Hour(RTC_HandleTypeDef *hrtc)
HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc)
void HAL_RTC_DST_Sub1Hour(RTC_HandleTypeDef *hrtc)
uint32_t HAL_RTC_DST_ReadStoreOperation(RTC_HandleTypeDef *hrtc)
void HAL_RTC_DST_ClearStoreOperation(RTC_HandleTypeDef *hrtc)
void HAL_RTC_DST_SetStoreOperation(RTC_HandleTypeDef *hrtc)
HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc)
#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)
HAL_StatusTypeDef RTC_ExitInitMode(RTC_HandleTypeDef *hrtc)
HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef *hrtc)
uint8_t RTC_Bcd2ToByte(uint8_t number)
#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 __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.
volatile HAL_RTCStateTypeDef State
RTC_InitTypeDef Init
HAL_LockTypeDef Lock
RTC Time structure definition.