stm32f4xx_rtc.c
Go to the documentation of this file.
1 
284 /* Includes ------------------------------------------------------------------*/
285 #include "stm32f4xx_rtc.h"
286 
296 /* Private typedef -----------------------------------------------------------*/
297 /* Private define ------------------------------------------------------------*/
298 
299 /* Masks Definition */
300 #define RTC_TR_RESERVED_MASK ((uint32_t)0x007F7F7F)
301 #define RTC_DR_RESERVED_MASK ((uint32_t)0x00FFFF3F)
302 #define RTC_INIT_MASK ((uint32_t)0xFFFFFFFF)
303 #define RTC_RSF_MASK ((uint32_t)0xFFFFFF5F)
304 #define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_TSOVF | RTC_FLAG_TSF | RTC_FLAG_WUTF | \
305  RTC_FLAG_ALRBF | RTC_FLAG_ALRAF | RTC_FLAG_INITF | \
306  RTC_FLAG_RSF | RTC_FLAG_INITS | RTC_FLAG_WUTWF | \
307  RTC_FLAG_ALRBWF | RTC_FLAG_ALRAWF | RTC_FLAG_TAMP1F | \
308  RTC_FLAG_RECALPF | RTC_FLAG_SHPF))
309 
310 #define INITMODE_TIMEOUT ((uint32_t) 0x00010000)
311 #define SYNCHRO_TIMEOUT ((uint32_t) 0x00020000)
312 #define RECALPF_TIMEOUT ((uint32_t) 0x00020000)
313 #define SHPF_TIMEOUT ((uint32_t) 0x00001000)
314 
315 /* Private macro -------------------------------------------------------------*/
316 /* Private variables ---------------------------------------------------------*/
317 /* Private function prototypes -----------------------------------------------*/
318 static uint8_t RTC_ByteToBcd2(uint8_t Value);
319 static uint8_t RTC_Bcd2ToByte(uint8_t Value);
320 
321 /* Private functions ---------------------------------------------------------*/
322 
376 {
377  __IO uint32_t wutcounter = 0x00;
378  uint32_t wutwfstatus = 0x00;
380 
381  /* Disable the write protection for RTC registers */
382  RTC->WPR = 0xCA;
383  RTC->WPR = 0x53;
384 
385  /* Set Initialization mode */
386  if (RTC_EnterInitMode() == ERROR)
387  {
388  status = ERROR;
389  }
390  else
391  {
392  /* Reset TR, DR and CR registers */
393  RTC->TR = (uint32_t)0x00000000;
394  RTC->DR = (uint32_t)0x00002101;
395  /* Reset All CR bits except CR[2:0] */
396  RTC->CR &= (uint32_t)0x00000007;
397 
398  /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
399  do
400  {
401  wutwfstatus = RTC->ISR & RTC_ISR_WUTWF;
402  wutcounter++;
403  } while((wutcounter != INITMODE_TIMEOUT) && (wutwfstatus == 0x00));
404 
405  if ((RTC->ISR & RTC_ISR_WUTWF) == RESET)
406  {
407  status = ERROR;
408  }
409  else
410  {
411  /* Reset all RTC CR register bits */
412  RTC->CR &= (uint32_t)0x00000000;
413  RTC->WUTR = (uint32_t)0x0000FFFF;
414  RTC->PRER = (uint32_t)0x007F00FF;
415  RTC->CALIBR = (uint32_t)0x00000000;
416  RTC->ALRMAR = (uint32_t)0x00000000;
417  RTC->ALRMBR = (uint32_t)0x00000000;
418  RTC->SHIFTR = (uint32_t)0x00000000;
419  RTC->CALR = (uint32_t)0x00000000;
420  RTC->ALRMASSR = (uint32_t)0x00000000;
421  RTC->ALRMBSSR = (uint32_t)0x00000000;
422 
423  /* Reset ISR register and exit initialization mode */
424  RTC->ISR = (uint32_t)0x00000000;
425 
426  /* Reset Tamper and alternate functions configuration register */
427  RTC->TAFCR = 0x00000000;
428 
429  if(RTC_WaitForSynchro() == ERROR)
430  {
431  status = ERROR;
432  }
433  else
434  {
435  status = SUCCESS;
436  }
437  }
438  }
439 
440  /* Enable the write protection for RTC registers */
441  RTC->WPR = 0xFF;
442 
443  return status;
444 }
445 
458 {
460 
461  /* Check the parameters */
465 
466  /* Disable the write protection for RTC registers */
467  RTC->WPR = 0xCA;
468  RTC->WPR = 0x53;
469 
470  /* Set Initialization mode */
471  if (RTC_EnterInitMode() == ERROR)
472  {
473  status = ERROR;
474  }
475  else
476  {
477  /* Clear RTC CR FMT Bit */
478  RTC->CR &= ((uint32_t)~(RTC_CR_FMT));
479  /* Set RTC_CR register */
480  RTC->CR |= ((uint32_t)(RTC_InitStruct->RTC_HourFormat));
481 
482  /* Configure the RTC PRER */
483  RTC->PRER = (uint32_t)(RTC_InitStruct->RTC_SynchPrediv);
484  RTC->PRER |= (uint32_t)(RTC_InitStruct->RTC_AsynchPrediv << 16);
485 
486  /* Exit Initialization mode */
488 
489  status = SUCCESS;
490  }
491  /* Enable the write protection for RTC registers */
492  RTC->WPR = 0xFF;
493 
494  return status;
495 }
496 
503 void RTC_StructInit(RTC_InitTypeDef* RTC_InitStruct)
504 {
505  /* Initialize the RTC_HourFormat member */
506  RTC_InitStruct->RTC_HourFormat = RTC_HourFormat_24;
507 
508  /* Initialize the RTC_AsynchPrediv member */
509  RTC_InitStruct->RTC_AsynchPrediv = (uint32_t)0x7F;
510 
511  /* Initialize the RTC_SynchPrediv member */
512  RTC_InitStruct->RTC_SynchPrediv = (uint32_t)0xFF;
513 }
514 
526 {
527  /* Check the parameters */
529 
530  if (NewState != DISABLE)
531  {
532  /* Enable the write protection for RTC registers */
533  RTC->WPR = 0xFF;
534  }
535  else
536  {
537  /* Disable the write protection for RTC registers */
538  RTC->WPR = 0xCA;
539  RTC->WPR = 0x53;
540  }
541 }
542 
553 {
554  __IO uint32_t initcounter = 0x00;
556  uint32_t initstatus = 0x00;
557 
558  /* Check if the Initialization mode is set */
559  if ((RTC->ISR & RTC_ISR_INITF) == (uint32_t)RESET)
560  {
561  /* Set the Initialization mode */
562  RTC->ISR = (uint32_t)RTC_INIT_MASK;
563 
564  /* Wait till RTC is in INIT state and if Time out is reached exit */
565  do
566  {
567  initstatus = RTC->ISR & RTC_ISR_INITF;
568  initcounter++;
569  } while((initcounter != INITMODE_TIMEOUT) && (initstatus == 0x00));
570 
571  if ((RTC->ISR & RTC_ISR_INITF) != RESET)
572  {
573  status = SUCCESS;
574  }
575  else
576  {
577  status = ERROR;
578  }
579  }
580  else
581  {
582  status = SUCCESS;
583  }
584 
585  return (status);
586 }
587 
598 {
599  /* Exit Initialization mode */
600  RTC->ISR &= (uint32_t)~RTC_ISR_INIT;
601 }
602 
620 {
621  __IO uint32_t synchrocounter = 0;
623  uint32_t synchrostatus = 0x00;
624 
625  /* Disable the write protection for RTC registers */
626  RTC->WPR = 0xCA;
627  RTC->WPR = 0x53;
628 
629  /* Clear RSF flag */
630  RTC->ISR &= (uint32_t)RTC_RSF_MASK;
631 
632  /* Wait the registers to be synchronised */
633  do
634  {
635  synchrostatus = RTC->ISR & RTC_ISR_RSF;
636  synchrocounter++;
637  } while((synchrocounter != SYNCHRO_TIMEOUT) && (synchrostatus == 0x00));
638 
639  if ((RTC->ISR & RTC_ISR_RSF) != RESET)
640  {
641  status = SUCCESS;
642  }
643  else
644  {
645  status = ERROR;
646  }
647 
648  /* Enable the write protection for RTC registers */
649  RTC->WPR = 0xFF;
650 
651  return (status);
652 }
653 
663 {
665 
666  /* Check the parameters */
668 
669  /* Disable the write protection for RTC registers */
670  RTC->WPR = 0xCA;
671  RTC->WPR = 0x53;
672 
673  /* Set Initialization mode */
674  if (RTC_EnterInitMode() == ERROR)
675  {
676  status = ERROR;
677  }
678  else
679  {
680  if (NewState != DISABLE)
681  {
682  /* Enable the RTC reference clock detection */
683  RTC->CR |= RTC_CR_REFCKON;
684  }
685  else
686  {
687  /* Disable the RTC reference clock detection */
688  RTC->CR &= ~RTC_CR_REFCKON;
689  }
690  /* Exit Initialization mode */
692 
693  status = SUCCESS;
694  }
695 
696  /* Enable the write protection for RTC registers */
697  RTC->WPR = 0xFF;
698 
699  return status;
700 }
701 
711 {
712  /* Check the parameters */
714 
715  /* Disable the write protection for RTC registers */
716  RTC->WPR = 0xCA;
717  RTC->WPR = 0x53;
718 
719  if (NewState != DISABLE)
720  {
721  /* Set the BYPSHAD bit */
722  RTC->CR |= (uint8_t)RTC_CR_BYPSHAD;
723  }
724  else
725  {
726  /* Reset the BYPSHAD bit */
727  RTC->CR &= (uint8_t)~RTC_CR_BYPSHAD;
728  }
729 
730  /* Enable the write protection for RTC registers */
731  RTC->WPR = 0xFF;
732 }
733 
765 ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct)
766 {
767  uint32_t tmpreg = 0;
769 
770  /* Check the parameters */
771  assert_param(IS_RTC_FORMAT(RTC_Format));
772 
773  if (RTC_Format == RTC_Format_BIN)
774  {
775  if ((RTC->CR & RTC_CR_FMT) != (uint32_t)RESET)
776  {
777  assert_param(IS_RTC_HOUR12(RTC_TimeStruct->RTC_Hours));
778  assert_param(IS_RTC_H12(RTC_TimeStruct->RTC_H12));
779  }
780  else
781  {
782  RTC_TimeStruct->RTC_H12 = 0x00;
783  assert_param(IS_RTC_HOUR24(RTC_TimeStruct->RTC_Hours));
784  }
785  assert_param(IS_RTC_MINUTES(RTC_TimeStruct->RTC_Minutes));
786  assert_param(IS_RTC_SECONDS(RTC_TimeStruct->RTC_Seconds));
787  }
788  else
789  {
790  if ((RTC->CR & RTC_CR_FMT) != (uint32_t)RESET)
791  {
792  tmpreg = RTC_Bcd2ToByte(RTC_TimeStruct->RTC_Hours);
793  assert_param(IS_RTC_HOUR12(tmpreg));
794  assert_param(IS_RTC_H12(RTC_TimeStruct->RTC_H12));
795  }
796  else
797  {
798  RTC_TimeStruct->RTC_H12 = 0x00;
800  }
803  }
804 
805  /* Check the input parameters format */
806  if (RTC_Format != RTC_Format_BIN)
807  {
808  tmpreg = (((uint32_t)(RTC_TimeStruct->RTC_Hours) << 16) | \
809  ((uint32_t)(RTC_TimeStruct->RTC_Minutes) << 8) | \
810  ((uint32_t)RTC_TimeStruct->RTC_Seconds) | \
811  ((uint32_t)(RTC_TimeStruct->RTC_H12) << 16));
812  }
813  else
814  {
815  tmpreg = (uint32_t)(((uint32_t)RTC_ByteToBcd2(RTC_TimeStruct->RTC_Hours) << 16) | \
816  ((uint32_t)RTC_ByteToBcd2(RTC_TimeStruct->RTC_Minutes) << 8) | \
817  ((uint32_t)RTC_ByteToBcd2(RTC_TimeStruct->RTC_Seconds)) | \
818  (((uint32_t)RTC_TimeStruct->RTC_H12) << 16));
819  }
820 
821  /* Disable the write protection for RTC registers */
822  RTC->WPR = 0xCA;
823  RTC->WPR = 0x53;
824 
825  /* Set Initialization mode */
826  if (RTC_EnterInitMode() == ERROR)
827  {
828  status = ERROR;
829  }
830  else
831  {
832  /* Set the RTC_TR register */
833  RTC->TR = (uint32_t)(tmpreg & RTC_TR_RESERVED_MASK);
834 
835  /* Exit Initialization mode */
836  RTC_ExitInitMode();
837 
838  /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */
839  if ((RTC->CR & RTC_CR_BYPSHAD) == RESET)
840  {
841  if(RTC_WaitForSynchro() == ERROR)
842  {
843  status = ERROR;
844  }
845  else
846  {
847  status = SUCCESS;
848  }
849  }
850  else
851  {
852  status = SUCCESS;
853  }
854  }
855  /* Enable the write protection for RTC registers */
856  RTC->WPR = 0xFF;
857 
858  return status;
859 }
860 
868 void RTC_TimeStructInit(RTC_TimeTypeDef* RTC_TimeStruct)
869 {
870  /* Time = 00h:00min:00sec */
871  RTC_TimeStruct->RTC_H12 = RTC_H12_AM;
872  RTC_TimeStruct->RTC_Hours = 0;
873  RTC_TimeStruct->RTC_Minutes = 0;
874  RTC_TimeStruct->RTC_Seconds = 0;
875 }
876 
887 void RTC_GetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct)
888 {
889  uint32_t tmpreg = 0;
890 
891  /* Check the parameters */
892  assert_param(IS_RTC_FORMAT(RTC_Format));
893 
894  /* Get the RTC_TR register */
895  tmpreg = (uint32_t)(RTC->TR & RTC_TR_RESERVED_MASK);
896 
897  /* Fill the structure fields with the read parameters */
898  RTC_TimeStruct->RTC_Hours = (uint8_t)((tmpreg & (RTC_TR_HT | RTC_TR_HU)) >> 16);
899  RTC_TimeStruct->RTC_Minutes = (uint8_t)((tmpreg & (RTC_TR_MNT | RTC_TR_MNU)) >>8);
900  RTC_TimeStruct->RTC_Seconds = (uint8_t)(tmpreg & (RTC_TR_ST | RTC_TR_SU));
901  RTC_TimeStruct->RTC_H12 = (uint8_t)((tmpreg & (RTC_TR_PM)) >> 16);
902 
903  /* Check the input parameters format */
904  if (RTC_Format == RTC_Format_BIN)
905  {
906  /* Convert the structure parameters to Binary format */
907  RTC_TimeStruct->RTC_Hours = (uint8_t)RTC_Bcd2ToByte(RTC_TimeStruct->RTC_Hours);
908  RTC_TimeStruct->RTC_Minutes = (uint8_t)RTC_Bcd2ToByte(RTC_TimeStruct->RTC_Minutes);
909  RTC_TimeStruct->RTC_Seconds = (uint8_t)RTC_Bcd2ToByte(RTC_TimeStruct->RTC_Seconds);
910  }
911 }
912 
920 uint32_t RTC_GetSubSecond(void)
921 {
922  uint32_t tmpreg = 0;
923 
924  /* Get sub seconds values from the correspondent registers*/
925  tmpreg = (uint32_t)(RTC->SSR);
926 
927  /* Read DR register to unfroze calendar registers */
928  (void) (RTC->DR);
929 
930  return (tmpreg);
931 }
932 
945 ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct)
946 {
947  uint32_t tmpreg = 0;
949 
950  /* Check the parameters */
951  assert_param(IS_RTC_FORMAT(RTC_Format));
952 
953  if ((RTC_Format == RTC_Format_BIN) && ((RTC_DateStruct->RTC_Month & 0x10) == 0x10))
954  {
955  RTC_DateStruct->RTC_Month = (RTC_DateStruct->RTC_Month & (uint32_t)~(0x10)) + 0x0A;
956  }
957  if (RTC_Format == RTC_Format_BIN)
958  {
959  assert_param(IS_RTC_YEAR(RTC_DateStruct->RTC_Year));
960  assert_param(IS_RTC_MONTH(RTC_DateStruct->RTC_Month));
961  assert_param(IS_RTC_DATE(RTC_DateStruct->RTC_Date));
962  }
963  else
964  {
965  assert_param(IS_RTC_YEAR(RTC_Bcd2ToByte(RTC_DateStruct->RTC_Year)));
966  tmpreg = RTC_Bcd2ToByte(RTC_DateStruct->RTC_Month);
967  assert_param(IS_RTC_MONTH(tmpreg));
968  tmpreg = RTC_Bcd2ToByte(RTC_DateStruct->RTC_Date);
969  assert_param(IS_RTC_DATE(tmpreg));
970  }
971  assert_param(IS_RTC_WEEKDAY(RTC_DateStruct->RTC_WeekDay));
972 
973  /* Check the input parameters format */
974  if (RTC_Format != RTC_Format_BIN)
975  {
976  tmpreg = ((((uint32_t)RTC_DateStruct->RTC_Year) << 16) | \
977  (((uint32_t)RTC_DateStruct->RTC_Month) << 8) | \
978  ((uint32_t)RTC_DateStruct->RTC_Date) | \
979  (((uint32_t)RTC_DateStruct->RTC_WeekDay) << 13));
980  }
981  else
982  {
983  tmpreg = (((uint32_t)RTC_ByteToBcd2(RTC_DateStruct->RTC_Year) << 16) | \
984  ((uint32_t)RTC_ByteToBcd2(RTC_DateStruct->RTC_Month) << 8) | \
985  ((uint32_t)RTC_ByteToBcd2(RTC_DateStruct->RTC_Date)) | \
986  ((uint32_t)RTC_DateStruct->RTC_WeekDay << 13));
987  }
988 
989  /* Disable the write protection for RTC registers */
990  RTC->WPR = 0xCA;
991  RTC->WPR = 0x53;
992 
993  /* Set Initialization mode */
994  if (RTC_EnterInitMode() == ERROR)
995  {
996  status = ERROR;
997  }
998  else
999  {
1000  /* Set the RTC_DR register */
1001  RTC->DR = (uint32_t)(tmpreg & RTC_DR_RESERVED_MASK);
1002 
1003  /* Exit Initialization mode */
1004  RTC_ExitInitMode();
1005 
1006  /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */
1007  if ((RTC->CR & RTC_CR_BYPSHAD) == RESET)
1008  {
1009  if(RTC_WaitForSynchro() == ERROR)
1010  {
1011  status = ERROR;
1012  }
1013  else
1014  {
1015  status = SUCCESS;
1016  }
1017  }
1018  else
1019  {
1020  status = SUCCESS;
1021  }
1022  }
1023  /* Enable the write protection for RTC registers */
1024  RTC->WPR = 0xFF;
1025 
1026  return status;
1027 }
1028 
1037 {
1038  /* Monday, January 01 xx00 */
1039  RTC_DateStruct->RTC_WeekDay = RTC_Weekday_Monday;
1040  RTC_DateStruct->RTC_Date = 1;
1041  RTC_DateStruct->RTC_Month = RTC_Month_January;
1042  RTC_DateStruct->RTC_Year = 0;
1043 }
1044 
1055 void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct)
1056 {
1057  uint32_t tmpreg = 0;
1058 
1059  /* Check the parameters */
1060  assert_param(IS_RTC_FORMAT(RTC_Format));
1061 
1062  /* Get the RTC_TR register */
1063  tmpreg = (uint32_t)(RTC->DR & RTC_DR_RESERVED_MASK);
1064 
1065  /* Fill the structure fields with the read parameters */
1066  RTC_DateStruct->RTC_Year = (uint8_t)((tmpreg & (RTC_DR_YT | RTC_DR_YU)) >> 16);
1067  RTC_DateStruct->RTC_Month = (uint8_t)((tmpreg & (RTC_DR_MT | RTC_DR_MU)) >> 8);
1068  RTC_DateStruct->RTC_Date = (uint8_t)(tmpreg & (RTC_DR_DT | RTC_DR_DU));
1069  RTC_DateStruct->RTC_WeekDay = (uint8_t)((tmpreg & (RTC_DR_WDU)) >> 13);
1070 
1071  /* Check the input parameters format */
1072  if (RTC_Format == RTC_Format_BIN)
1073  {
1074  /* Convert the structure parameters to Binary format */
1075  RTC_DateStruct->RTC_Year = (uint8_t)RTC_Bcd2ToByte(RTC_DateStruct->RTC_Year);
1076  RTC_DateStruct->RTC_Month = (uint8_t)RTC_Bcd2ToByte(RTC_DateStruct->RTC_Month);
1077  RTC_DateStruct->RTC_Date = (uint8_t)RTC_Bcd2ToByte(RTC_DateStruct->RTC_Date);
1078  }
1079 }
1080 
1115 void RTC_SetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct)
1116 {
1117  uint32_t tmpreg = 0;
1118 
1119  /* Check the parameters */
1120  assert_param(IS_RTC_FORMAT(RTC_Format));
1121  assert_param(IS_RTC_ALARM(RTC_Alarm));
1122  assert_param(IS_ALARM_MASK(RTC_AlarmStruct->RTC_AlarmMask));
1124 
1125  if (RTC_Format == RTC_Format_BIN)
1126  {
1127  if ((RTC->CR & RTC_CR_FMT) != (uint32_t)RESET)
1128  {
1130  assert_param(IS_RTC_H12(RTC_AlarmStruct->RTC_AlarmTime.RTC_H12));
1131  }
1132  else
1133  {
1134  RTC_AlarmStruct->RTC_AlarmTime.RTC_H12 = 0x00;
1136  }
1139 
1141  {
1143  }
1144  else
1145  {
1147  }
1148  }
1149  else
1150  {
1151  if ((RTC->CR & RTC_CR_FMT) != (uint32_t)RESET)
1152  {
1153  tmpreg = RTC_Bcd2ToByte(RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours);
1154  assert_param(IS_RTC_HOUR12(tmpreg));
1155  assert_param(IS_RTC_H12(RTC_AlarmStruct->RTC_AlarmTime.RTC_H12));
1156  }
1157  else
1158  {
1159  RTC_AlarmStruct->RTC_AlarmTime.RTC_H12 = 0x00;
1161  }
1162 
1165 
1167  {
1168  tmpreg = RTC_Bcd2ToByte(RTC_AlarmStruct->RTC_AlarmDateWeekDay);
1170  }
1171  else
1172  {
1173  tmpreg = RTC_Bcd2ToByte(RTC_AlarmStruct->RTC_AlarmDateWeekDay);
1175  }
1176  }
1177 
1178  /* Check the input parameters format */
1179  if (RTC_Format != RTC_Format_BIN)
1180  {
1181  tmpreg = (((uint32_t)(RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours) << 16) | \
1182  ((uint32_t)(RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes) << 8) | \
1183  ((uint32_t)RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds) | \
1184  ((uint32_t)(RTC_AlarmStruct->RTC_AlarmTime.RTC_H12) << 16) | \
1185  ((uint32_t)(RTC_AlarmStruct->RTC_AlarmDateWeekDay) << 24) | \
1186  ((uint32_t)RTC_AlarmStruct->RTC_AlarmDateWeekDaySel) | \
1187  ((uint32_t)RTC_AlarmStruct->RTC_AlarmMask));
1188  }
1189  else
1190  {
1191  tmpreg = (((uint32_t)RTC_ByteToBcd2(RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours) << 16) | \
1192  ((uint32_t)RTC_ByteToBcd2(RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes) << 8) | \
1193  ((uint32_t)RTC_ByteToBcd2(RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds)) | \
1194  ((uint32_t)(RTC_AlarmStruct->RTC_AlarmTime.RTC_H12) << 16) | \
1195  ((uint32_t)RTC_ByteToBcd2(RTC_AlarmStruct->RTC_AlarmDateWeekDay) << 24) | \
1196  ((uint32_t)RTC_AlarmStruct->RTC_AlarmDateWeekDaySel) | \
1197  ((uint32_t)RTC_AlarmStruct->RTC_AlarmMask));
1198  }
1199 
1200  /* Disable the write protection for RTC registers */
1201  RTC->WPR = 0xCA;
1202  RTC->WPR = 0x53;
1203 
1204  /* Configure the Alarm register */
1205  if (RTC_Alarm == RTC_Alarm_A)
1206  {
1207  RTC->ALRMAR = (uint32_t)tmpreg;
1208  }
1209  else
1210  {
1211  RTC->ALRMBR = (uint32_t)tmpreg;
1212  }
1213 
1214  /* Enable the write protection for RTC registers */
1215  RTC->WPR = 0xFF;
1216 }
1217 
1227 {
1228  /* Alarm Time Settings : Time = 00h:00mn:00sec */
1229  RTC_AlarmStruct->RTC_AlarmTime.RTC_H12 = RTC_H12_AM;
1230  RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours = 0;
1231  RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes = 0;
1232  RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds = 0;
1233 
1234  /* Alarm Date Settings : Date = 1st day of the month */
1236  RTC_AlarmStruct->RTC_AlarmDateWeekDay = 1;
1237 
1238  /* Alarm Masks Settings : Mask = all fields are not masked */
1239  RTC_AlarmStruct->RTC_AlarmMask = RTC_AlarmMask_None;
1240 }
1241 
1256 void RTC_GetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct)
1257 {
1258  uint32_t tmpreg = 0;
1259 
1260  /* Check the parameters */
1261  assert_param(IS_RTC_FORMAT(RTC_Format));
1262  assert_param(IS_RTC_ALARM(RTC_Alarm));
1263 
1264  /* Get the RTC_ALRMxR register */
1265  if (RTC_Alarm == RTC_Alarm_A)
1266  {
1267  tmpreg = (uint32_t)(RTC->ALRMAR);
1268  }
1269  else
1270  {
1271  tmpreg = (uint32_t)(RTC->ALRMBR);
1272  }
1273 
1274  /* Fill the structure with the read parameters */
1275  RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours = (uint32_t)((tmpreg & (RTC_ALRMAR_HT | \
1276  RTC_ALRMAR_HU)) >> 16);
1277  RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes = (uint32_t)((tmpreg & (RTC_ALRMAR_MNT | \
1278  RTC_ALRMAR_MNU)) >> 8);
1279  RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds = (uint32_t)(tmpreg & (RTC_ALRMAR_ST | \
1280  RTC_ALRMAR_SU));
1281  RTC_AlarmStruct->RTC_AlarmTime.RTC_H12 = (uint32_t)((tmpreg & RTC_ALRMAR_PM) >> 16);
1282  RTC_AlarmStruct->RTC_AlarmDateWeekDay = (uint32_t)((tmpreg & (RTC_ALRMAR_DT | RTC_ALRMAR_DU)) >> 24);
1283  RTC_AlarmStruct->RTC_AlarmDateWeekDaySel = (uint32_t)(tmpreg & RTC_ALRMAR_WDSEL);
1284  RTC_AlarmStruct->RTC_AlarmMask = (uint32_t)(tmpreg & RTC_AlarmMask_All);
1285 
1286  if (RTC_Format == RTC_Format_BIN)
1287  {
1288  RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours = RTC_Bcd2ToByte(RTC_AlarmStruct-> \
1289  RTC_AlarmTime.RTC_Hours);
1290  RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes = RTC_Bcd2ToByte(RTC_AlarmStruct-> \
1291  RTC_AlarmTime.RTC_Minutes);
1292  RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds = RTC_Bcd2ToByte(RTC_AlarmStruct-> \
1293  RTC_AlarmTime.RTC_Seconds);
1294  RTC_AlarmStruct->RTC_AlarmDateWeekDay = RTC_Bcd2ToByte(RTC_AlarmStruct->RTC_AlarmDateWeekDay);
1295  }
1296 }
1297 
1310 ErrorStatus RTC_AlarmCmd(uint32_t RTC_Alarm, FunctionalState NewState)
1311 {
1312  __IO uint32_t alarmcounter = 0x00;
1313  uint32_t alarmstatus = 0x00;
1315 
1316  /* Check the parameters */
1317  assert_param(IS_RTC_CMD_ALARM(RTC_Alarm));
1318  assert_param(IS_FUNCTIONAL_STATE(NewState));
1319 
1320  /* Disable the write protection for RTC registers */
1321  RTC->WPR = 0xCA;
1322  RTC->WPR = 0x53;
1323 
1324  /* Configure the Alarm state */
1325  if (NewState != DISABLE)
1326  {
1327  RTC->CR |= (uint32_t)RTC_Alarm;
1328 
1329  status = SUCCESS;
1330  }
1331  else
1332  {
1333  /* Disable the Alarm in RTC_CR register */
1334  RTC->CR &= (uint32_t)~RTC_Alarm;
1335 
1336  /* Wait till RTC ALRxWF flag is set and if Time out is reached exit */
1337  do
1338  {
1339  alarmstatus = RTC->ISR & (RTC_Alarm >> 8);
1340  alarmcounter++;
1341  } while((alarmcounter != INITMODE_TIMEOUT) && (alarmstatus == 0x00));
1342 
1343  if ((RTC->ISR & (RTC_Alarm >> 8)) == RESET)
1344  {
1345  status = ERROR;
1346  }
1347  else
1348  {
1349  status = SUCCESS;
1350  }
1351  }
1352 
1353  /* Enable the write protection for RTC registers */
1354  RTC->WPR = 0xFF;
1355 
1356  return status;
1357 }
1358 
1404 void RTC_AlarmSubSecondConfig(uint32_t RTC_Alarm, uint32_t RTC_AlarmSubSecondValue, uint32_t RTC_AlarmSubSecondMask)
1405 {
1406  uint32_t tmpreg = 0;
1407 
1408  /* Check the parameters */
1409  assert_param(IS_RTC_ALARM(RTC_Alarm));
1410  assert_param(IS_RTC_ALARM_SUB_SECOND_VALUE(RTC_AlarmSubSecondValue));
1411  assert_param(IS_RTC_ALARM_SUB_SECOND_MASK(RTC_AlarmSubSecondMask));
1412 
1413  /* Disable the write protection for RTC registers */
1414  RTC->WPR = 0xCA;
1415  RTC->WPR = 0x53;
1416 
1417  /* Configure the Alarm A or Alarm B Sub Second registers */
1418  tmpreg = (uint32_t) (uint32_t)(RTC_AlarmSubSecondValue) | (uint32_t)(RTC_AlarmSubSecondMask);
1419 
1420  if (RTC_Alarm == RTC_Alarm_A)
1421  {
1422  /* Configure the Alarm A Sub Second register */
1423  RTC->ALRMASSR = tmpreg;
1424  }
1425  else
1426  {
1427  /* Configure the Alarm B Sub Second register */
1428  RTC->ALRMBSSR = tmpreg;
1429  }
1430 
1431  /* Enable the write protection for RTC registers */
1432  RTC->WPR = 0xFF;
1433 
1434 }
1435 
1445 uint32_t RTC_GetAlarmSubSecond(uint32_t RTC_Alarm)
1446 {
1447  uint32_t tmpreg = 0;
1448 
1449  /* Get the RTC_ALRMxR register */
1450  if (RTC_Alarm == RTC_Alarm_A)
1451  {
1452  tmpreg = (uint32_t)((RTC->ALRMASSR) & RTC_ALRMASSR_SS);
1453  }
1454  else
1455  {
1456  tmpreg = (uint32_t)((RTC->ALRMBSSR) & RTC_ALRMBSSR_SS);
1457  }
1458 
1459  return (tmpreg);
1460 }
1461 
1494 void RTC_WakeUpClockConfig(uint32_t RTC_WakeUpClock)
1495 {
1496  /* Check the parameters */
1497  assert_param(IS_RTC_WAKEUP_CLOCK(RTC_WakeUpClock));
1498 
1499  /* Disable the write protection for RTC registers */
1500  RTC->WPR = 0xCA;
1501  RTC->WPR = 0x53;
1502 
1503  /* Clear the Wakeup Timer clock source bits in CR register */
1504  RTC->CR &= (uint32_t)~RTC_CR_WUCKSEL;
1505 
1506  /* Configure the clock source */
1507  RTC->CR |= (uint32_t)RTC_WakeUpClock;
1508 
1509  /* Enable the write protection for RTC registers */
1510  RTC->WPR = 0xFF;
1511 }
1512 
1521 void RTC_SetWakeUpCounter(uint32_t RTC_WakeUpCounter)
1522 {
1523  /* Check the parameters */
1524  assert_param(IS_RTC_WAKEUP_COUNTER(RTC_WakeUpCounter));
1525 
1526  /* Disable the write protection for RTC registers */
1527  RTC->WPR = 0xCA;
1528  RTC->WPR = 0x53;
1529 
1530  /* Configure the Wakeup Timer counter */
1531  RTC->WUTR = (uint32_t)RTC_WakeUpCounter;
1532 
1533  /* Enable the write protection for RTC registers */
1534  RTC->WPR = 0xFF;
1535 }
1536 
1542 uint32_t RTC_GetWakeUpCounter(void)
1543 {
1544  /* Get the counter value */
1545  return ((uint32_t)(RTC->WUTR & RTC_WUTR_WUT));
1546 }
1547 
1555 {
1556  __IO uint32_t wutcounter = 0x00;
1557  uint32_t wutwfstatus = 0x00;
1559 
1560  /* Check the parameters */
1561  assert_param(IS_FUNCTIONAL_STATE(NewState));
1562 
1563  /* Disable the write protection for RTC registers */
1564  RTC->WPR = 0xCA;
1565  RTC->WPR = 0x53;
1566 
1567  if (NewState != DISABLE)
1568  {
1569  /* Enable the Wakeup Timer */
1570  RTC->CR |= (uint32_t)RTC_CR_WUTE;
1571  status = SUCCESS;
1572  }
1573  else
1574  {
1575  /* Disable the Wakeup Timer */
1576  RTC->CR &= (uint32_t)~RTC_CR_WUTE;
1577  /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
1578  do
1579  {
1580  wutwfstatus = RTC->ISR & RTC_ISR_WUTWF;
1581  wutcounter++;
1582  } while((wutcounter != INITMODE_TIMEOUT) && (wutwfstatus == 0x00));
1583 
1584  if ((RTC->ISR & RTC_ISR_WUTWF) == RESET)
1585  {
1586  status = ERROR;
1587  }
1588  else
1589  {
1590  status = SUCCESS;
1591  }
1592  }
1593 
1594  /* Enable the write protection for RTC registers */
1595  RTC->WPR = 0xFF;
1596 
1597  return status;
1598 }
1599 
1631 void RTC_DayLightSavingConfig(uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation)
1632 {
1633  /* Check the parameters */
1634  assert_param(IS_RTC_DAYLIGHT_SAVING(RTC_DayLightSaving));
1635  assert_param(IS_RTC_STORE_OPERATION(RTC_StoreOperation));
1636 
1637  /* Disable the write protection for RTC registers */
1638  RTC->WPR = 0xCA;
1639  RTC->WPR = 0x53;
1640 
1641  /* Clear the bits to be configured */
1642  RTC->CR &= (uint32_t)~(RTC_CR_BCK);
1643 
1644  /* Configure the RTC_CR register */
1645  RTC->CR |= (uint32_t)(RTC_DayLightSaving | RTC_StoreOperation);
1646 
1647  /* Enable the write protection for RTC registers */
1648  RTC->WPR = 0xFF;
1649 }
1650 
1659 {
1660  return (RTC->CR & RTC_CR_BCK);
1661 }
1662 
1697 void RTC_OutputConfig(uint32_t RTC_Output, uint32_t RTC_OutputPolarity)
1698 {
1699  /* Check the parameters */
1700  assert_param(IS_RTC_OUTPUT(RTC_Output));
1701  assert_param(IS_RTC_OUTPUT_POL(RTC_OutputPolarity));
1702 
1703  /* Disable the write protection for RTC registers */
1704  RTC->WPR = 0xCA;
1705  RTC->WPR = 0x53;
1706 
1707  /* Clear the bits to be configured */
1708  RTC->CR &= (uint32_t)~(RTC_CR_OSEL | RTC_CR_POL);
1709 
1710  /* Configure the output selection and polarity */
1711  RTC->CR |= (uint32_t)(RTC_Output | RTC_OutputPolarity);
1712 
1713  /* Enable the write protection for RTC registers */
1714  RTC->WPR = 0xFF;
1715 }
1716 
1751 ErrorStatus RTC_CoarseCalibConfig(uint32_t RTC_CalibSign, uint32_t Value)
1752 {
1754 
1755  /* Check the parameters */
1756  assert_param(IS_RTC_CALIB_SIGN(RTC_CalibSign));
1758 
1759  /* Disable the write protection for RTC registers */
1760  RTC->WPR = 0xCA;
1761  RTC->WPR = 0x53;
1762 
1763  /* Set Initialization mode */
1764  if (RTC_EnterInitMode() == ERROR)
1765  {
1766  status = ERROR;
1767  }
1768  else
1769  {
1770  /* Set the coarse calibration value */
1771  RTC->CALIBR = (uint32_t)(RTC_CalibSign | Value);
1772  /* Exit Initialization mode */
1773  RTC_ExitInitMode();
1774 
1775  status = SUCCESS;
1776  }
1777 
1778  /* Enable the write protection for RTC registers */
1779  RTC->WPR = 0xFF;
1780 
1781  return status;
1782 }
1783 
1793 {
1795 
1796  /* Check the parameters */
1797  assert_param(IS_FUNCTIONAL_STATE(NewState));
1798 
1799  /* Disable the write protection for RTC registers */
1800  RTC->WPR = 0xCA;
1801  RTC->WPR = 0x53;
1802 
1803  /* Set Initialization mode */
1804  if (RTC_EnterInitMode() == ERROR)
1805  {
1806  status = ERROR;
1807  }
1808  else
1809  {
1810  if (NewState != DISABLE)
1811  {
1812  /* Enable the Coarse Calibration */
1813  RTC->CR |= (uint32_t)RTC_CR_DCE;
1814  }
1815  else
1816  {
1817  /* Disable the Coarse Calibration */
1818  RTC->CR &= (uint32_t)~RTC_CR_DCE;
1819  }
1820  /* Exit Initialization mode */
1821  RTC_ExitInitMode();
1822 
1823  status = SUCCESS;
1824  }
1825 
1826  /* Enable the write protection for RTC registers */
1827  RTC->WPR = 0xFF;
1828 
1829  return status;
1830 }
1831 
1839 {
1840  /* Check the parameters */
1841  assert_param(IS_FUNCTIONAL_STATE(NewState));
1842 
1843  /* Disable the write protection for RTC registers */
1844  RTC->WPR = 0xCA;
1845  RTC->WPR = 0x53;
1846 
1847  if (NewState != DISABLE)
1848  {
1849  /* Enable the RTC clock output */
1850  RTC->CR |= (uint32_t)RTC_CR_COE;
1851  }
1852  else
1853  {
1854  /* Disable the RTC clock output */
1855  RTC->CR &= (uint32_t)~RTC_CR_COE;
1856  }
1857 
1858  /* Enable the write protection for RTC registers */
1859  RTC->WPR = 0xFF;
1860 }
1861 
1870 void RTC_CalibOutputConfig(uint32_t RTC_CalibOutput)
1871 {
1872  /* Check the parameters */
1873  assert_param(IS_RTC_CALIB_OUTPUT(RTC_CalibOutput));
1874 
1875  /* Disable the write protection for RTC registers */
1876  RTC->WPR = 0xCA;
1877  RTC->WPR = 0x53;
1878 
1879  /*clear flags before configuration */
1880  RTC->CR &= (uint32_t)~(RTC_CR_COSEL);
1881 
1882  /* Configure the RTC_CR register */
1883  RTC->CR |= (uint32_t)RTC_CalibOutput;
1884 
1885  /* Enable the write protection for RTC registers */
1886  RTC->WPR = 0xFF;
1887 }
1888 
1906 ErrorStatus RTC_SmoothCalibConfig(uint32_t RTC_SmoothCalibPeriod,
1907  uint32_t RTC_SmoothCalibPlusPulses,
1908  uint32_t RTC_SmouthCalibMinusPulsesValue)
1909 {
1911  uint32_t recalpfcount = 0;
1912 
1913  /* Check the parameters */
1914  assert_param(IS_RTC_SMOOTH_CALIB_PERIOD(RTC_SmoothCalibPeriod));
1915  assert_param(IS_RTC_SMOOTH_CALIB_PLUS(RTC_SmoothCalibPlusPulses));
1916  assert_param(IS_RTC_SMOOTH_CALIB_MINUS(RTC_SmouthCalibMinusPulsesValue));
1917 
1918  /* Disable the write protection for RTC registers */
1919  RTC->WPR = 0xCA;
1920  RTC->WPR = 0x53;
1921 
1922  /* check if a calibration is pending*/
1923  if ((RTC->ISR & RTC_ISR_RECALPF) != RESET)
1924  {
1925  /* wait until the Calibration is completed*/
1926  while (((RTC->ISR & RTC_ISR_RECALPF) != RESET) && (recalpfcount != RECALPF_TIMEOUT))
1927  {
1928  recalpfcount++;
1929  }
1930  }
1931 
1932  /* check if the calibration pending is completed or if there is no calibration operation at all*/
1933  if ((RTC->ISR & RTC_ISR_RECALPF) == RESET)
1934  {
1935  /* Configure the Smooth calibration settings */
1936  RTC->CALR = (uint32_t)((uint32_t)RTC_SmoothCalibPeriod | (uint32_t)RTC_SmoothCalibPlusPulses | (uint32_t)RTC_SmouthCalibMinusPulsesValue);
1937 
1938  status = SUCCESS;
1939  }
1940  else
1941  {
1942  status = ERROR;
1943  }
1944 
1945  /* Enable the write protection for RTC registers */
1946  RTC->WPR = 0xFF;
1947 
1948  return (ErrorStatus)(status);
1949 }
1950 
1982 void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState)
1983 {
1984  uint32_t tmpreg = 0;
1985 
1986  /* Check the parameters */
1987  assert_param(IS_RTC_TIMESTAMP_EDGE(RTC_TimeStampEdge));
1988  assert_param(IS_FUNCTIONAL_STATE(NewState));
1989 
1990  /* Get the RTC_CR register and clear the bits to be configured */
1991  tmpreg = (uint32_t)(RTC->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));
1992 
1993  /* Get the new configuration */
1994  if (NewState != DISABLE)
1995  {
1996  tmpreg |= (uint32_t)(RTC_TimeStampEdge | RTC_CR_TSE);
1997  }
1998  else
1999  {
2000  tmpreg |= (uint32_t)(RTC_TimeStampEdge);
2001  }
2002 
2003  /* Disable the write protection for RTC registers */
2004  RTC->WPR = 0xCA;
2005  RTC->WPR = 0x53;
2006 
2007  /* Configure the Time Stamp TSEDGE and Enable bits */
2008  RTC->CR = (uint32_t)tmpreg;
2009 
2010  /* Enable the write protection for RTC registers */
2011  RTC->WPR = 0xFF;
2012 }
2013 
2026 void RTC_GetTimeStamp(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_StampTimeStruct,
2027  RTC_DateTypeDef* RTC_StampDateStruct)
2028 {
2029  uint32_t tmptime = 0, tmpdate = 0;
2030 
2031  /* Check the parameters */
2032  assert_param(IS_RTC_FORMAT(RTC_Format));
2033 
2034  /* Get the TimeStamp time and date registers values */
2035  tmptime = (uint32_t)(RTC->TSTR & RTC_TR_RESERVED_MASK);
2036  tmpdate = (uint32_t)(RTC->TSDR & RTC_DR_RESERVED_MASK);
2037 
2038  /* Fill the Time structure fields with the read parameters */
2039  RTC_StampTimeStruct->RTC_Hours = (uint8_t)((tmptime & (RTC_TR_HT | RTC_TR_HU)) >> 16);
2040  RTC_StampTimeStruct->RTC_Minutes = (uint8_t)((tmptime & (RTC_TR_MNT | RTC_TR_MNU)) >> 8);
2041  RTC_StampTimeStruct->RTC_Seconds = (uint8_t)(tmptime & (RTC_TR_ST | RTC_TR_SU));
2042  RTC_StampTimeStruct->RTC_H12 = (uint8_t)((tmptime & (RTC_TR_PM)) >> 16);
2043 
2044  /* Fill the Date structure fields with the read parameters */
2045  RTC_StampDateStruct->RTC_Year = 0;
2046  RTC_StampDateStruct->RTC_Month = (uint8_t)((tmpdate & (RTC_DR_MT | RTC_DR_MU)) >> 8);
2047  RTC_StampDateStruct->RTC_Date = (uint8_t)(tmpdate & (RTC_DR_DT | RTC_DR_DU));
2048  RTC_StampDateStruct->RTC_WeekDay = (uint8_t)((tmpdate & (RTC_DR_WDU)) >> 13);
2049 
2050  /* Check the input parameters format */
2051  if (RTC_Format == RTC_Format_BIN)
2052  {
2053  /* Convert the Time structure parameters to Binary format */
2054  RTC_StampTimeStruct->RTC_Hours = (uint8_t)RTC_Bcd2ToByte(RTC_StampTimeStruct->RTC_Hours);
2055  RTC_StampTimeStruct->RTC_Minutes = (uint8_t)RTC_Bcd2ToByte(RTC_StampTimeStruct->RTC_Minutes);
2056  RTC_StampTimeStruct->RTC_Seconds = (uint8_t)RTC_Bcd2ToByte(RTC_StampTimeStruct->RTC_Seconds);
2057 
2058  /* Convert the Date structure parameters to Binary format */
2059  RTC_StampDateStruct->RTC_Month = (uint8_t)RTC_Bcd2ToByte(RTC_StampDateStruct->RTC_Month);
2060  RTC_StampDateStruct->RTC_Date = (uint8_t)RTC_Bcd2ToByte(RTC_StampDateStruct->RTC_Date);
2061  RTC_StampDateStruct->RTC_WeekDay = (uint8_t)RTC_Bcd2ToByte(RTC_StampDateStruct->RTC_WeekDay);
2062  }
2063 }
2064 
2071 {
2072  /* Get timestamp sub seconds values from the correspondent registers */
2073  return (uint32_t)(RTC->TSSSR);
2074 }
2075 
2105 void RTC_TamperTriggerConfig(uint32_t RTC_Tamper, uint32_t RTC_TamperTrigger)
2106 {
2107  /* Check the parameters */
2108  assert_param(IS_RTC_TAMPER(RTC_Tamper));
2109  assert_param(IS_RTC_TAMPER_TRIGGER(RTC_TamperTrigger));
2110 
2111  if (RTC_TamperTrigger == RTC_TamperTrigger_RisingEdge)
2112  {
2113  /* Configure the RTC_TAFCR register */
2114  RTC->TAFCR &= (uint32_t)((uint32_t)~(RTC_Tamper << 1));
2115  }
2116  else
2117  {
2118  /* Configure the RTC_TAFCR register */
2119  RTC->TAFCR |= (uint32_t)(RTC_Tamper << 1);
2120  }
2121 }
2122 
2131 void RTC_TamperCmd(uint32_t RTC_Tamper, FunctionalState NewState)
2132 {
2133  /* Check the parameters */
2134  assert_param(IS_RTC_TAMPER(RTC_Tamper));
2135  assert_param(IS_FUNCTIONAL_STATE(NewState));
2136 
2137  if (NewState != DISABLE)
2138  {
2139  /* Enable the selected Tamper pin */
2140  RTC->TAFCR |= (uint32_t)RTC_Tamper;
2141  }
2142  else
2143  {
2144  /* Disable the selected Tamper pin */
2145  RTC->TAFCR &= (uint32_t)~RTC_Tamper;
2146  }
2147 }
2148 
2162 void RTC_TamperFilterConfig(uint32_t RTC_TamperFilter)
2163 {
2164  /* Check the parameters */
2165  assert_param(IS_RTC_TAMPER_FILTER(RTC_TamperFilter));
2166 
2167  /* Clear TAMPFLT[1:0] bits in the RTC_TAFCR register */
2168  RTC->TAFCR &= (uint32_t)~(RTC_TAFCR_TAMPFLT);
2169 
2170  /* Configure the RTC_TAFCR register */
2171  RTC->TAFCR |= (uint32_t)RTC_TamperFilter;
2172 }
2173 
2196 void RTC_TamperSamplingFreqConfig(uint32_t RTC_TamperSamplingFreq)
2197 {
2198  /* Check the parameters */
2199  assert_param(IS_RTC_TAMPER_SAMPLING_FREQ(RTC_TamperSamplingFreq));
2200 
2201  /* Clear TAMPFREQ[2:0] bits in the RTC_TAFCR register */
2202  RTC->TAFCR &= (uint32_t)~(RTC_TAFCR_TAMPFREQ);
2203 
2204  /* Configure the RTC_TAFCR register */
2205  RTC->TAFCR |= (uint32_t)RTC_TamperSamplingFreq;
2206 }
2207 
2219 void RTC_TamperPinsPrechargeDuration(uint32_t RTC_TamperPrechargeDuration)
2220 {
2221  /* Check the parameters */
2222  assert_param(IS_RTC_TAMPER_PRECHARGE_DURATION(RTC_TamperPrechargeDuration));
2223 
2224  /* Clear TAMPPRCH[1:0] bits in the RTC_TAFCR register */
2225  RTC->TAFCR &= (uint32_t)~(RTC_TAFCR_TAMPPRCH);
2226 
2227  /* Configure the RTC_TAFCR register */
2228  RTC->TAFCR |= (uint32_t)RTC_TamperPrechargeDuration;
2229 }
2230 
2240 {
2241  /* Check the parameters */
2242  assert_param(IS_FUNCTIONAL_STATE(NewState));
2243 
2244  if (NewState != DISABLE)
2245  {
2246  /* Save timestamp on tamper detection event */
2247  RTC->TAFCR |= (uint32_t)RTC_TAFCR_TAMPTS;
2248  }
2249  else
2250  {
2251  /* Tamper detection does not cause a timestamp to be saved */
2252  RTC->TAFCR &= (uint32_t)~RTC_TAFCR_TAMPTS;
2253  }
2254 }
2255 
2263 {
2264  /* Check the parameters */
2265  assert_param(IS_FUNCTIONAL_STATE(NewState));
2266 
2267  if (NewState != DISABLE)
2268  {
2269  /* Enable precharge of the selected Tamper pin */
2270  RTC->TAFCR &= (uint32_t)~RTC_TAFCR_TAMPPUDIS;
2271  }
2272  else
2273  {
2274  /* Disable precharge of the selected Tamper pin */
2275  RTC->TAFCR |= (uint32_t)RTC_TAFCR_TAMPPUDIS;
2276  }
2277 }
2278 
2303 void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data)
2304 {
2305  __IO uint32_t tmp = 0;
2306 
2307  /* Check the parameters */
2308  assert_param(IS_RTC_BKP(RTC_BKP_DR));
2309 
2310  tmp = RTC_BASE + 0x50;
2311  tmp += (RTC_BKP_DR * 4);
2312 
2313  /* Write the specified register */
2314  *(__IO uint32_t *)tmp = (uint32_t)Data;
2315 }
2316 
2324 uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR)
2325 {
2326  __IO uint32_t tmp = 0;
2327 
2328  /* Check the parameters */
2329  assert_param(IS_RTC_BKP(RTC_BKP_DR));
2330 
2331  tmp = RTC_BASE + 0x50;
2332  tmp += (RTC_BKP_DR * 4);
2333 
2334  /* Read the specified register */
2335  return (*(__IO uint32_t *)tmp);
2336 }
2337 
2363 void RTC_TamperPinSelection(uint32_t RTC_TamperPin)
2364 {
2365  /* Check the parameters */
2366  assert_param(IS_RTC_TAMPER_PIN(RTC_TamperPin));
2367 
2368  RTC->TAFCR &= (uint32_t)~(RTC_TAFCR_TAMPINSEL);
2369  RTC->TAFCR |= (uint32_t)(RTC_TamperPin);
2370 }
2371 
2380 void RTC_TimeStampPinSelection(uint32_t RTC_TimeStampPin)
2381 {
2382  /* Check the parameters */
2383  assert_param(IS_RTC_TIMESTAMP_PIN(RTC_TimeStampPin));
2384 
2385  RTC->TAFCR &= (uint32_t)~(RTC_TAFCR_TSINSEL);
2386  RTC->TAFCR |= (uint32_t)(RTC_TimeStampPin);
2387 }
2388 
2399 void RTC_OutputTypeConfig(uint32_t RTC_OutputType)
2400 {
2401  /* Check the parameters */
2402  assert_param(IS_RTC_OUTPUT_TYPE(RTC_OutputType));
2403 
2404  RTC->TAFCR &= (uint32_t)~(RTC_TAFCR_ALARMOUTTYPE);
2405  RTC->TAFCR |= (uint32_t)(RTC_OutputType);
2406 }
2407 
2437 ErrorStatus RTC_SynchroShiftConfig(uint32_t RTC_ShiftAdd1S, uint32_t RTC_ShiftSubFS)
2438 {
2440  uint32_t shpfcount = 0;
2441 
2442  /* Check the parameters */
2443  assert_param(IS_RTC_SHIFT_ADD1S(RTC_ShiftAdd1S));
2444  assert_param(IS_RTC_SHIFT_SUBFS(RTC_ShiftSubFS));
2445 
2446  /* Disable the write protection for RTC registers */
2447  RTC->WPR = 0xCA;
2448  RTC->WPR = 0x53;
2449 
2450  /* Check if a Shift is pending*/
2451  if ((RTC->ISR & RTC_ISR_SHPF) != RESET)
2452  {
2453  /* Wait until the shift is completed*/
2454  while (((RTC->ISR & RTC_ISR_SHPF) != RESET) && (shpfcount != SHPF_TIMEOUT))
2455  {
2456  shpfcount++;
2457  }
2458  }
2459 
2460  /* Check if the Shift pending is completed or if there is no Shift operation at all*/
2461  if ((RTC->ISR & RTC_ISR_SHPF) == RESET)
2462  {
2463  /* check if the reference clock detection is disabled */
2464  if((RTC->CR & RTC_CR_REFCKON) == RESET)
2465  {
2466  /* Configure the Shift settings */
2467  RTC->SHIFTR = (uint32_t)(uint32_t)(RTC_ShiftSubFS) | (uint32_t)(RTC_ShiftAdd1S);
2468 
2469  if(RTC_WaitForSynchro() == ERROR)
2470  {
2471  status = ERROR;
2472  }
2473  else
2474  {
2475  status = SUCCESS;
2476  }
2477  }
2478  else
2479  {
2480  status = ERROR;
2481  }
2482  }
2483  else
2484  {
2485  status = ERROR;
2486  }
2487 
2488  /* Enable the write protection for RTC registers */
2489  RTC->WPR = 0xFF;
2490 
2491  return (ErrorStatus)(status);
2492 }
2493 
2557 void RTC_ITConfig(uint32_t RTC_IT, FunctionalState NewState)
2558 {
2559  /* Check the parameters */
2560  assert_param(IS_RTC_CONFIG_IT(RTC_IT));
2561  assert_param(IS_FUNCTIONAL_STATE(NewState));
2562 
2563  /* Disable the write protection for RTC registers */
2564  RTC->WPR = 0xCA;
2565  RTC->WPR = 0x53;
2566 
2567  if (NewState != DISABLE)
2568  {
2569  /* Configure the Interrupts in the RTC_CR register */
2570  RTC->CR |= (uint32_t)(RTC_IT & ~RTC_TAFCR_TAMPIE);
2571  /* Configure the Tamper Interrupt in the RTC_TAFCR */
2572  RTC->TAFCR |= (uint32_t)(RTC_IT & RTC_TAFCR_TAMPIE);
2573  }
2574  else
2575  {
2576  /* Configure the Interrupts in the RTC_CR register */
2577  RTC->CR &= (uint32_t)~(RTC_IT & (uint32_t)~RTC_TAFCR_TAMPIE);
2578  /* Configure the Tamper Interrupt in the RTC_TAFCR */
2579  RTC->TAFCR &= (uint32_t)~(RTC_IT & RTC_TAFCR_TAMPIE);
2580  }
2581  /* Enable the write protection for RTC registers */
2582  RTC->WPR = 0xFF;
2583 }
2584 
2605 FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG)
2606 {
2607  FlagStatus bitstatus = RESET;
2608  uint32_t tmpreg = 0;
2609 
2610  /* Check the parameters */
2611  assert_param(IS_RTC_GET_FLAG(RTC_FLAG));
2612 
2613  /* Get all the flags */
2614  tmpreg = (uint32_t)(RTC->ISR & RTC_FLAGS_MASK);
2615 
2616  /* Return the status of the flag */
2617  if ((tmpreg & RTC_FLAG) != (uint32_t)RESET)
2618  {
2619  bitstatus = SET;
2620  }
2621  else
2622  {
2623  bitstatus = RESET;
2624  }
2625  return bitstatus;
2626 }
2627 
2641 void RTC_ClearFlag(uint32_t RTC_FLAG)
2642 {
2643  /* Check the parameters */
2644  assert_param(IS_RTC_CLEAR_FLAG(RTC_FLAG));
2645 
2646  /* Clear the Flags in the RTC_ISR register */
2647  RTC->ISR = (uint32_t)((uint32_t)(~((RTC_FLAG | RTC_ISR_INIT)& 0x0000FFFF) | (uint32_t)(RTC->ISR & RTC_ISR_INIT)));
2648 }
2649 
2661 ITStatus RTC_GetITStatus(uint32_t RTC_IT)
2662 {
2663  ITStatus bitstatus = RESET;
2664  uint32_t tmpreg = 0, enablestatus = 0;
2665 
2666  /* Check the parameters */
2667  assert_param(IS_RTC_GET_IT(RTC_IT));
2668 
2669  /* Get the TAMPER Interrupt enable bit and pending bit */
2670  tmpreg = (uint32_t)(RTC->TAFCR & (RTC_TAFCR_TAMPIE));
2671 
2672  /* Get the Interrupt enable Status */
2673  enablestatus = (uint32_t)((RTC->CR & RTC_IT) | (tmpreg & (RTC_IT >> 15)));
2674 
2675  /* Get the Interrupt pending bit */
2676  tmpreg = (uint32_t)((RTC->ISR & (uint32_t)(RTC_IT >> 4)));
2677 
2678  /* Get the status of the Interrupt */
2679  if ((enablestatus != (uint32_t)RESET) && ((tmpreg & 0x0000FFFF) != (uint32_t)RESET))
2680  {
2681  bitstatus = SET;
2682  }
2683  else
2684  {
2685  bitstatus = RESET;
2686  }
2687  return bitstatus;
2688 }
2689 
2701 void RTC_ClearITPendingBit(uint32_t RTC_IT)
2702 {
2703  uint32_t tmpreg = 0;
2704 
2705  /* Check the parameters */
2706  assert_param(IS_RTC_CLEAR_IT(RTC_IT));
2707 
2708  /* Get the RTC_ISR Interrupt pending bits mask */
2709  tmpreg = (uint32_t)(RTC_IT >> 4);
2710 
2711  /* Clear the interrupt pending bits in the RTC_ISR register */
2712  RTC->ISR = (uint32_t)((uint32_t)(~((tmpreg | RTC_ISR_INIT)& 0x0000FFFF) | (uint32_t)(RTC->ISR & RTC_ISR_INIT)));
2713 }
2714 
2724 static uint8_t RTC_ByteToBcd2(uint8_t Value)
2725 {
2726  uint8_t bcdhigh = 0;
2727 
2728  while (Value >= 10)
2729  {
2730  bcdhigh++;
2731  Value -= 10;
2732  }
2733 
2734  return ((uint8_t)(bcdhigh << 4) | Value);
2735 }
2736 
2742 static uint8_t RTC_Bcd2ToByte(uint8_t Value)
2743 {
2744  uint8_t tmp = 0;
2745  tmp = ((uint8_t)(Value & (uint8_t)0xF0) >> (uint8_t)0x4) * 10;
2746  return (tmp + (Value & (uint8_t)0x0F));
2747 }
2748 
2761 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#define RTC_TAFCR_TAMPINSEL
Definition: stm32f4xx.h:9563
uint32_t RTC_AlarmMask
FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG)
Checks whether the specified RTC flag is set or not.
FlagStatus
Definition: stm32f4xx.h:706
#define RTC_ALRMAR_DU
Definition: stm32f4xx.h:9405
void RTC_BypassShadowCmd(FunctionalState NewState)
Enables or Disables the Bypass Shadow feature.
#define RTC_CR_WUCKSEL
Definition: stm32f4xx.h:9366
#define IS_RTC_TAMPER_TRIGGER(TRIGGER)
#define IS_RTC_CONFIG_IT(IT)
static uint8_t RTC_Bcd2ToByte(uint8_t Value)
Convert from 2 digit BCD to Binary.
#define IS_RTC_WAKEUP_COUNTER(COUNTER)
#define RTC_Format_BIN
#define IS_RTC_CLEAR_IT(IT)
void RTC_TimeStampPinSelection(uint32_t RTC_TimeStampPin)
Selects the RTC TimeStamp Pin.
#define RTC_CR_COE
Definition: stm32f4xx.h:9344
#define IS_RTC_SYNCH_PREDIV(PREDIV)
#define IS_RTC_CALIB_VALUE(VALUE)
#define IS_RTC_GET_FLAG(FLAG)
#define IS_RTC_SHIFT_SUBFS(FS)
FunctionalState
Definition: stm32f4xx.h:708
ITStatus RTC_GetITStatus(uint32_t RTC_IT)
Checks whether the specified RTC interrupt has occurred or not.
#define RTC_ALRMAR_HU
Definition: stm32f4xx.h:9415
#define IS_RTC_TAMPER(TAMPER)
#define RTC_TR_HT
Definition: stm32f4xx.h:9286
void RTC_TamperCmd(uint32_t RTC_Tamper, FunctionalState NewState)
Enables or Disables the Tamper detection.
#define SHPF_TIMEOUT
#define RTC_DR_WDU
Definition: stm32f4xx.h:9324
#define IS_RTC_DATE(DATE)
#define RTC_ALRMAR_DT
Definition: stm32f4xx.h:9402
#define RTC_TAFCR_TAMPPRCH
Definition: stm32f4xx.h:9565
#define IS_RTC_CALIB_SIGN(SIGN)
void RTC_DayLightSavingConfig(uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation)
Adds or substract one hour from the current time.
#define IS_RTC_BKP(BKP)
#define IS_RTC_YEAR(YEAR)
#define RTC_CR_DCE
Definition: stm32f4xx.h:9361
ErrorStatus RTC_SynchroShiftConfig(uint32_t RTC_ShiftAdd1S, uint32_t RTC_ShiftSubFS)
Configures the Synchronization Shift Control Settings.
uint8_t RTC_AlarmDateWeekDay
void RTC_GetTimeStamp(uint32_t RTC_Format, RTC_TimeTypeDef *RTC_StampTimeStruct, RTC_DateTypeDef *RTC_StampDateStruct)
Get the RTC TimeStamp value and masks.
#define RTC_DR_YU
Definition: stm32f4xx.h:9319
uint32_t RTC_GetSubSecond(void)
Gets the RTC current Calendar Sub seconds value.
#define RTC_ISR_RSF
Definition: stm32f4xx.h:9381
#define IS_RTC_TAMPER_PIN(PIN)
uint32_t RTC_AlarmDateWeekDaySel
RTC Init structures definition.
Definition: stm32f4xx_rtc.h:53
#define IS_RTC_FORMAT(FORMAT)
#define RTC_TAFCR_TSINSEL
Definition: stm32f4xx.h:9562
void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef *RTC_DateStruct)
Get the RTC current date.
#define RTC_DR_DT
Definition: stm32f4xx.h:9334
#define RTC_ALRMAR_MNT
Definition: stm32f4xx.h:9421
#define IS_RTC_SMOOTH_CALIB_PLUS(PLUS)
#define RTC_TamperTrigger_RisingEdge
This file contains all the functions prototypes for the RTC firmware library.
void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState)
Enables or Disables the RTC TimeStamp functionality with the specified time stamp pin stimulating edg...
void RTC_AlarmStructInit(RTC_AlarmTypeDef *RTC_AlarmStruct)
Fills each RTC_AlarmStruct member with its default value (Time = 00h:00mn:00sec / Date = 1st day of t...
#define IS_RTC_ALARM_SUB_SECOND_MASK(MASK)
uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR)
Reads data from the specified RTC Backup data Register.
#define RTC_ALRMAR_MNU
Definition: stm32f4xx.h:9425
#define IS_RTC_GET_IT(IT)
#define IS_RTC_TIMESTAMP_PIN(PIN)
#define IS_RTC_SMOOTH_CALIB_MINUS(VALUE)
#define IS_RTC_OUTPUT_POL(POL)
void assert_param(int val)
#define RTC_DR_DU
Definition: stm32f4xx.h:9337
#define RTC_CR_TSEDGE
Definition: stm32f4xx.h:9365
ErrorStatus RTC_WakeUpCmd(FunctionalState NewState)
Enables or Disables the RTC WakeUp timer.
#define RTC_CR_FMT
Definition: stm32f4xx.h:9362
void RTC_SetWakeUpCounter(uint32_t RTC_WakeUpCounter)
Configures the RTC Wakeup counter.
#define RTC_CR_WUTE
Definition: stm32f4xx.h:9358
void RTC_WakeUpClockConfig(uint32_t RTC_WakeUpClock)
Configures the RTC Wakeup clock source.
ErrorStatus RTC_DeInit(void)
Deinitializes the RTC registers to their default reset values.
#define IS_RTC_H12(PM)
#define IS_FUNCTIONAL_STATE(STATE)
Definition: stm32f4xx.h:709
#define IS_RTC_CLEAR_FLAG(FLAG)
#define RTC_TR_MNU
Definition: stm32f4xx.h:9298
static volatile uint8_t * status
Definition: drv_i2c.c:102
#define RTC_Month_January
void RTC_GetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef *RTC_AlarmStruct)
Get the RTC Alarm value and masks.
RTC_TimeTypeDef RTC_AlarmTime
#define IS_RTC_OUTPUT(OUTPUT)
ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef *RTC_TimeStruct)
Set the RTC current time.
#define RTC_ALRMAR_ST
Definition: stm32f4xx.h:9431
void RTC_OutputTypeConfig(uint32_t RTC_OutputType)
Configures the RTC Output Pin mode.
void RTC_ExitInitMode(void)
Exits the RTC Initialization mode.
void RTC_WriteProtectionCmd(FunctionalState NewState)
Enables or disables the RTC registers write protection.
#define RTC_ISR_WUTWF
Definition: stm32f4xx.h:9384
Definition: stm32f4xx.h:706
#define RTC_TAFCR_TAMPTS
Definition: stm32f4xx.h:9575
enum FlagStatus ITStatus
#define RTC_Alarm_A
void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data)
Writes a data in a specified RTC Backup data register.
void RTC_CalibOutputCmd(FunctionalState NewState)
Enables or disables the RTC clock to be output through the relative pin.
ErrorStatus RTC_WaitForSynchro(void)
Waits until the RTC Time and Date registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock...
#define RTC_CR_OSEL
Definition: stm32f4xx.h:9345
void RTC_TamperPullUpCmd(FunctionalState NewState)
Enables or Disables the Precharge of Tamper pin.
#define IS_RTC_HOUR_FORMAT(FORMAT)
void RTC_AlarmSubSecondConfig(uint32_t RTC_Alarm, uint32_t RTC_AlarmSubSecondValue, uint32_t RTC_AlarmSubSecondMask)
Configure the RTC AlarmA/B Sub seconds value and mask.*.
#define __IO
Definition: core_cm0.h:198
RTC Date structure definition.
Definition: stm32f4xx_rtc.h:88
#define RTC_DR_YT
Definition: stm32f4xx.h:9314
#define RTC_TAFCR_TAMPFLT
Definition: stm32f4xx.h:9568
#define RTC_WUTR_WUT
Definition: stm32f4xx.h:9393
uint8_t RTC_WeekDay
Definition: stm32f4xx_rtc.h:90
#define IS_RTC_HOUR24(HOUR)
#define RTC_ISR_INITF
Definition: stm32f4xx.h:9380
uint32_t RTC_GetStoreOperation(void)
Returns the RTC Day Light Saving stored operation.
#define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD)
#define RTC_AlarmDateWeekDaySel_Date
#define RTC_CR_BCK
Definition: stm32f4xx.h:9350
#define RTC_ALRMBSSR_SS
Definition: stm32f4xx.h:9594
#define IS_RTC_ALARM(ALARM)
uint32_t RTC_GetWakeUpCounter(void)
Returns the RTC WakeUp timer counter value.
#define IS_RTC_CALIB_OUTPUT(OUTPUT)
#define IS_RTC_OUTPUT_TYPE(TYPE)
void RTC_GetTime(uint32_t RTC_Format, RTC_TimeTypeDef *RTC_TimeStruct)
Get the RTC current Time.
ErrorStatus RTC_AlarmCmd(uint32_t RTC_Alarm, FunctionalState NewState)
Enables or disables the specified RTC Alarm.
#define IS_RTC_ASYNCH_PREDIV(PREDIV)
void RTC_ITConfig(uint32_t RTC_IT, FunctionalState NewState)
Enables or disables the specified RTC interrupts.
#define INITMODE_TIMEOUT
uint32_t RTC_AsynchPrediv
Definition: stm32f4xx_rtc.h:58
#define RTC_H12_AM
#define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ)
void RTC_TamperPinsPrechargeDuration(uint32_t RTC_TamperPrechargeDuration)
Configures the Tampers Pins input Precharge Duration.
#define RTC_DR_RESERVED_MASK
ErrorStatus RTC_RefClockCmd(FunctionalState NewState)
Enables or disables the RTC reference clock detection.
void RTC_ClearFlag(uint32_t RTC_FLAG)
Clears the RTC&#39;s pending flags.
#define RTC_CR_BYPSHAD
Definition: stm32f4xx.h:9363
#define IS_RTC_TIMESTAMP_EDGE(EDGE)
#define RTC_ALRMAR_WDSEL
Definition: stm32f4xx.h:9401
uint8_t RTC_Seconds
Definition: stm32f4xx_rtc.h:78
#define RTC_TAFCR_TAMPIE
Definition: stm32f4xx.h:9576
#define RTC_DR_MU
Definition: stm32f4xx.h:9329
#define IS_RTC_SECONDS(SECONDS)
#define RTC_ISR_SHPF
Definition: stm32f4xx.h:9383
#define RTC_ISR_RECALPF
Definition: stm32f4xx.h:9372
ErrorStatus
Definition: stm32f4xx.h:711
#define RTC_AlarmMask_All
#define IS_ALARM_MASK(MASK)
void RTC_TamperSamplingFreqConfig(uint32_t RTC_TamperSamplingFreq)
Configures the Tampers Sampling Frequency.
ErrorStatus RTC_CoarseCalibConfig(uint32_t RTC_CalibSign, uint32_t Value)
Configures the Coarse calibration parameters.
uint32_t RTC_GetTimeStampSubSecond(void)
Get the RTC timestamp Sub seconds value.
#define RECALPF_TIMEOUT
#define RTC_ALRMASSR_SS
Definition: stm32f4xx.h:9586
#define IS_RTC_WEEKDAY(WEEKDAY)
void RTC_CalibOutputConfig(uint32_t RTC_CalibOutput)
Configure the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
#define RTC_TR_RESERVED_MASK
#define RTC_TR_SU
Definition: stm32f4xx.h:9307
ErrorStatus RTC_CoarseCalibCmd(FunctionalState NewState)
Enables or disables the Coarse calibration process.
#define IS_RTC_MINUTES(MINUTES)
void RTC_OutputConfig(uint32_t RTC_Output, uint32_t RTC_OutputPolarity)
Configures the RTC output source (AFO_ALARM).
#define RTC_TAFCR_TAMPFREQ
Definition: stm32f4xx.h:9571
#define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION)
#define RTC_CR_TSE
Definition: stm32f4xx.h:9357
#define RTC_TR_PM
Definition: stm32f4xx.h:9285
#define RTC_FLAGS_MASK
#define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE)
#define RTC_ALRMAR_PM
Definition: stm32f4xx.h:9411
#define RTC_ISR_INIT
Definition: stm32f4xx.h:9379
#define RTC_CR_REFCKON
Definition: stm32f4xx.h:9364
#define IS_RTC_TAMPER_FILTER(FILTER)
#define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY)
#define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL)
#define RTC_TR_HU
Definition: stm32f4xx.h:9289
RTC Time structure definition.
Definition: stm32f4xx_rtc.h:68
#define IS_RTC_SHIFT_ADD1S(SEL)
#define RTC_CR_COSEL
Definition: stm32f4xx.h:9349
#define IS_RTC_STORE_OPERATION(OPERATION)
void RTC_SetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef *RTC_AlarmStruct)
Set the specified RTC Alarm.
#define RTC_ALRMAR_SU
Definition: stm32f4xx.h:9435
void RTC_StructInit(RTC_InitTypeDef *RTC_InitStruct)
Fills each RTC_InitStruct member with its default value.
#define IS_RTC_CMD_ALARM(ALARM)
#define RTC_TAFCR_TAMPPUDIS
Definition: stm32f4xx.h:9564
void RTC_DateStructInit(RTC_DateTypeDef *RTC_DateStruct)
Fills each RTC_DateStruct member with its default value (Monday, January 01 xx00).
void RTC_TimeStructInit(RTC_TimeTypeDef *RTC_TimeStruct)
Fills each RTC_TimeStruct member with its default value (Time = 00h:00min:00sec). ...
#define RTC_TR_MNT
Definition: stm32f4xx.h:9294
#define RTC_TAFCR_ALARMOUTTYPE
Definition: stm32f4xx.h:9561
ErrorStatus RTC_Init(RTC_InitTypeDef *RTC_InitStruct)
Initializes the RTC registers according to the specified parameters in RTC_InitStruct.
#define IS_RTC_MONTH(MONTH)
uint8_t RTC_Minutes
Definition: stm32f4xx_rtc.h:75
#define RTC_INIT_MASK
uint32_t RTC_GetAlarmSubSecond(uint32_t RTC_Alarm)
Gets the RTC Alarm Sub seconds value.
void RTC_ClearITPendingBit(uint32_t RTC_IT)
Clears the RTC&#39;s interrupt pending bits.
void RTC_TamperTriggerConfig(uint32_t RTC_Tamper, uint32_t RTC_TamperTrigger)
Configures the select Tamper pin edge.
#define RTC_TR_ST
Definition: stm32f4xx.h:9303
static uint8_t RTC_ByteToBcd2(uint8_t Value)
Converts a 2 digit decimal to BCD format.
ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef *RTC_DateStruct)
Set the RTC current date.
#define RTC_Weekday_Monday
#define RTC_CR_POL
Definition: stm32f4xx.h:9348
#define RTC
Definition: stm32f4xx.h:2046
ErrorStatus RTC_EnterInitMode(void)
Enters the RTC Initialization mode.
#define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE)
void RTC_TamperFilterConfig(uint32_t RTC_TamperFilter)
Configures the Tampers Filter.
#define RTC_ALRMAR_HT
Definition: stm32f4xx.h:9412
#define RTC_DR_MT
Definition: stm32f4xx.h:9328
#define IS_RTC_DAYLIGHT_SAVING(SAVE)
RTC Alarm structure definition.
#define RTC_RSF_MASK
void RTC_TimeStampOnTamperDetectionCmd(FunctionalState NewState)
Enables or Disables the TimeStamp on Tamper Detection Event.
void RTC_TamperPinSelection(uint32_t RTC_TamperPin)
Selects the RTC Tamper Pin.
#define SYNCHRO_TIMEOUT
#define IS_RTC_HOUR12(HOUR)
#define RTC_HourFormat_24
#define RTC_AlarmMask_None
#define RTC_BASE
Definition: stm32f4xx.h:1894
uint32_t RTC_HourFormat
Definition: stm32f4xx_rtc.h:55
#define IS_RTC_WAKEUP_CLOCK(CLOCK)
uint32_t RTC_SynchPrediv
Definition: stm32f4xx_rtc.h:61
ErrorStatus RTC_SmoothCalibConfig(uint32_t RTC_SmoothCalibPeriod, uint32_t RTC_SmoothCalibPlusPulses, uint32_t RTC_SmouthCalibMinusPulsesValue)
Configures the Smooth Calibration Settings.


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:07:49