stm32f30x_rtc.c
Go to the documentation of this file.
1 
240 /* Includes ------------------------------------------------------------------*/
241 #include "stm32f30x_rtc.h"
242 #include "stm32f30x_rcc.h"
243 
253 /* Private typedef -----------------------------------------------------------*/
254 /* Private define ------------------------------------------------------------*/
255 
256 /* Masks Definition */
257 #define RTC_TR_RESERVED_MASK ((uint32_t)0x007F7F7F)
258 #define RTC_DR_RESERVED_MASK ((uint32_t)0x00FFFF3F)
259 #define RTC_INIT_MASK ((uint32_t)0xFFFFFFFF)
260 #define RTC_RSF_MASK ((uint32_t)0xFFFFFF5F)
261 #define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_TSOVF | RTC_FLAG_TSF | RTC_FLAG_WUTF | \
262  RTC_FLAG_ALRBF | RTC_FLAG_ALRAF | RTC_FLAG_INITF | \
263  RTC_FLAG_RSF | RTC_FLAG_INITS | RTC_FLAG_WUTWF | \
264  RTC_FLAG_ALRBWF | RTC_FLAG_ALRAWF | RTC_FLAG_TAMP1F | \
265  RTC_FLAG_TAMP2F | RTC_FLAG_TAMP3F | RTC_FLAG_RECALPF | \
266  RTC_FLAG_SHPF))
267 
268 #define INITMODE_TIMEOUT ((uint32_t) 0x00002000)
269 #define SYNCHRO_TIMEOUT ((uint32_t) 0x00008000)
270 #define RECALPF_TIMEOUT ((uint32_t) 0x00001000)
271 #define SHPF_TIMEOUT ((uint32_t) 0x00002000)
272 
273 /* Private macro -------------------------------------------------------------*/
274 /* Private variables ---------------------------------------------------------*/
275 /* Private function prototypes -----------------------------------------------*/
276 static uint8_t RTC_ByteToBcd2(uint8_t Value);
277 static uint8_t RTC_Bcd2ToByte(uint8_t Value);
278 
279 /* Private functions ---------------------------------------------------------*/
280 
329 {
330  __IO uint32_t wutcounter = 0x00;
331  uint32_t wutwfstatus = 0x00;
333 
334  /* Disable the write protection for RTC registers */
335  RTC->WPR = 0xCA;
336  RTC->WPR = 0x53;
337 
338  /* Set Initialization mode */
339  if (RTC_EnterInitMode() == ERROR)
340  {
341  status = ERROR;
342  }
343  else
344  {
345  /* Reset TR, DR and CR registers */
346  RTC->TR = (uint32_t)0x00000000;
347  RTC->DR = (uint32_t)0x00002101;
348 
349  /* Reset All CR bits except CR[2:0] */
350  RTC->CR &= (uint32_t)0x00000007;
351 
352  /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
353  do
354  {
355  wutwfstatus = RTC->ISR & RTC_ISR_WUTWF;
356  wutcounter++;
357  } while((wutcounter != INITMODE_TIMEOUT) && (wutwfstatus == 0x00));
358 
359  if ((RTC->ISR & RTC_ISR_WUTWF) == RESET)
360  {
361  status = ERROR;
362  }
363  else
364  {
365  /* Reset all RTC CR register bits */
366  RTC->CR &= (uint32_t)0x00000000;
367  RTC->WUTR = (uint32_t)0x0000FFFF;
368  RTC->PRER = (uint32_t)0x007F00FF;
369  RTC->ALRMAR = (uint32_t)0x00000000;
370  RTC->ALRMBR = (uint32_t)0x00000000;
371  RTC->SHIFTR = (uint32_t)0x00000000;
372  RTC->CALR = (uint32_t)0x00000000;
373  RTC->ALRMASSR = (uint32_t)0x00000000;
374  RTC->ALRMBSSR = (uint32_t)0x00000000;
375 
376  /* Reset ISR register and exit initialization mode */
377  RTC->ISR = (uint32_t)0x00000000;
378 
379  /* Reset Tamper and alternate functions configuration register */
380  RTC->TAFCR = 0x00000000;
381 
382  /* Wait till the RTC RSF flag is set */
383  if (RTC_WaitForSynchro() == ERROR)
384  {
385  status = ERROR;
386  }
387  else
388  {
389  status = SUCCESS;
390  }
391  }
392  }
393 
394  /* Enable the write protection for RTC registers */
395  RTC->WPR = 0xFF;
396 
397  return status;
398 }
399 
412 {
414 
415  /* Check the parameters */
419 
420  /* Disable the write protection for RTC registers */
421  RTC->WPR = 0xCA;
422  RTC->WPR = 0x53;
423 
424  /* Set Initialization mode */
425  if (RTC_EnterInitMode() == ERROR)
426  {
427  status = ERROR;
428  }
429  else
430  {
431  /* Clear RTC CR FMT Bit */
432  RTC->CR &= ((uint32_t)~(RTC_CR_FMT));
433  /* Set RTC_CR register */
434  RTC->CR |= ((uint32_t)(RTC_InitStruct->RTC_HourFormat));
435 
436  /* Configure the RTC PRER */
437  RTC->PRER = (uint32_t)(RTC_InitStruct->RTC_SynchPrediv);
438  RTC->PRER |= (uint32_t)(RTC_InitStruct->RTC_AsynchPrediv << 16);
439 
440  /* Exit Initialization mode */
442 
443  status = SUCCESS;
444  }
445  /* Enable the write protection for RTC registers */
446  RTC->WPR = 0xFF;
447 
448  return status;
449 }
450 
457 void RTC_StructInit(RTC_InitTypeDef* RTC_InitStruct)
458 {
459  /* Initialize the RTC_HourFormat member */
460  RTC_InitStruct->RTC_HourFormat = RTC_HourFormat_24;
461 
462  /* Initialize the RTC_AsynchPrediv member */
463  RTC_InitStruct->RTC_AsynchPrediv = (uint32_t)0x7F;
464 
465  /* Initialize the RTC_SynchPrediv member */
466  RTC_InitStruct->RTC_SynchPrediv = (uint32_t)0xFF;
467 }
468 
480 {
481  /* Check the parameters */
483 
484  if (NewState != DISABLE)
485  {
486  /* Enable the write protection for RTC registers */
487  RTC->WPR = 0xFF;
488  }
489  else
490  {
491  /* Disable the write protection for RTC registers */
492  RTC->WPR = 0xCA;
493  RTC->WPR = 0x53;
494  }
495 }
496 
507 {
508  __IO uint32_t initcounter = 0x00;
510  uint32_t initstatus = 0x00;
511 
512  /* Check if the Initialization mode is set */
513  if ((RTC->ISR & RTC_ISR_INITF) == (uint32_t)RESET)
514  {
515  /* Set the Initialization mode */
516  RTC->ISR = (uint32_t)RTC_INIT_MASK;
517 
518  /* Wait till RTC is in INIT state and if Time out is reached exit */
519  do
520  {
521  initstatus = RTC->ISR & RTC_ISR_INITF;
522  initcounter++;
523  } while((initcounter != INITMODE_TIMEOUT) && (initstatus == 0x00));
524 
525  if ((RTC->ISR & RTC_ISR_INITF) != RESET)
526  {
527  status = SUCCESS;
528  }
529  else
530  {
531  status = ERROR;
532  }
533  }
534  else
535  {
536  status = SUCCESS;
537  }
538 
539  return (status);
540 }
541 
552 {
553  /* Exit Initialization mode */
554  RTC->ISR &= (uint32_t)~RTC_ISR_INIT;
555 }
556 
574 {
575  __IO uint32_t synchrocounter = 0;
577  uint32_t synchrostatus = 0x00;
578 
579  if ((RTC->CR & RTC_CR_BYPSHAD) != RESET)
580  {
581  /* Bypass shadow mode */
582  status = SUCCESS;
583  }
584  else
585  {
586  /* Disable the write protection for RTC registers */
587  RTC->WPR = 0xCA;
588  RTC->WPR = 0x53;
589 
590  /* Clear RSF flag */
591  RTC->ISR &= (uint32_t)RTC_RSF_MASK;
592 
593  /* Wait the registers to be synchronised */
594  do
595  {
596  synchrostatus = RTC->ISR & RTC_ISR_RSF;
597  synchrocounter++;
598  } while((synchrocounter != SYNCHRO_TIMEOUT) && (synchrostatus == 0x00));
599 
600  if ((RTC->ISR & RTC_ISR_RSF) != RESET)
601  {
602  status = SUCCESS;
603  }
604  else
605  {
606  status = ERROR;
607  }
608 
609  /* Enable the write protection for RTC registers */
610  RTC->WPR = 0xFF;
611  }
612 
613  return (status);
614 }
615 
625 {
627 
628  /* Check the parameters */
630 
631  /* Disable the write protection for RTC registers */
632  RTC->WPR = 0xCA;
633  RTC->WPR = 0x53;
634 
635  /* Set Initialization mode */
636  if (RTC_EnterInitMode() == ERROR)
637  {
638  status = ERROR;
639  }
640  else
641  {
642  if (NewState != DISABLE)
643  {
644  /* Enable the RTC reference clock detection */
645  RTC->CR |= RTC_CR_REFCKON;
646  }
647  else
648  {
649  /* Disable the RTC reference clock detection */
650  RTC->CR &= ~RTC_CR_REFCKON;
651  }
652  /* Exit Initialization mode */
654 
655  status = SUCCESS;
656  }
657 
658  /* Enable the write protection for RTC registers */
659  RTC->WPR = 0xFF;
660 
661  return status;
662 }
663 
673 {
674  /* Check the parameters */
676 
677  /* Disable the write protection for RTC registers */
678  RTC->WPR = 0xCA;
679  RTC->WPR = 0x53;
680 
681  if (NewState != DISABLE)
682  {
683  /* Set the BYPSHAD bit */
684  RTC->CR |= (uint8_t)RTC_CR_BYPSHAD;
685  }
686  else
687  {
688  /* Reset the BYPSHAD bit */
689  RTC->CR &= (uint8_t)~RTC_CR_BYPSHAD;
690  }
691 
692  /* Enable the write protection for RTC registers */
693  RTC->WPR = 0xFF;
694 }
695 
726 ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct)
727 {
728  uint32_t tmpreg = 0;
730 
731  /* Check the parameters */
732  assert_param(IS_RTC_FORMAT(RTC_Format));
733 
734  if (RTC_Format == RTC_Format_BIN)
735  {
736  if ((RTC->CR & RTC_CR_FMT) != (uint32_t)RESET)
737  {
738  assert_param(IS_RTC_HOUR12(RTC_TimeStruct->RTC_Hours));
739  assert_param(IS_RTC_H12(RTC_TimeStruct->RTC_H12));
740  }
741  else
742  {
743  RTC_TimeStruct->RTC_H12 = 0x00;
744  assert_param(IS_RTC_HOUR24(RTC_TimeStruct->RTC_Hours));
745  }
746  assert_param(IS_RTC_MINUTES(RTC_TimeStruct->RTC_Minutes));
747  assert_param(IS_RTC_SECONDS(RTC_TimeStruct->RTC_Seconds));
748  }
749  else
750  {
751  if ((RTC->CR & RTC_CR_FMT) != (uint32_t)RESET)
752  {
753  tmpreg = RTC_Bcd2ToByte(RTC_TimeStruct->RTC_Hours);
754  assert_param(IS_RTC_HOUR12(tmpreg));
755  assert_param(IS_RTC_H12(RTC_TimeStruct->RTC_H12));
756  }
757  else
758  {
759  RTC_TimeStruct->RTC_H12 = 0x00;
761  }
764  }
765 
766  /* Check the input parameters format */
767  if (RTC_Format != RTC_Format_BIN)
768  {
769  tmpreg = (((uint32_t)(RTC_TimeStruct->RTC_Hours) << 16) | \
770  ((uint32_t)(RTC_TimeStruct->RTC_Minutes) << 8) | \
771  ((uint32_t)RTC_TimeStruct->RTC_Seconds) | \
772  ((uint32_t)(RTC_TimeStruct->RTC_H12) << 16));
773  }
774  else
775  {
776  tmpreg = (uint32_t)(((uint32_t)RTC_ByteToBcd2(RTC_TimeStruct->RTC_Hours) << 16) | \
777  ((uint32_t)RTC_ByteToBcd2(RTC_TimeStruct->RTC_Minutes) << 8) | \
778  ((uint32_t)RTC_ByteToBcd2(RTC_TimeStruct->RTC_Seconds)) | \
779  (((uint32_t)RTC_TimeStruct->RTC_H12) << 16));
780  }
781 
782  /* Disable the write protection for RTC registers */
783  RTC->WPR = 0xCA;
784  RTC->WPR = 0x53;
785 
786  /* Set Initialization mode */
787  if (RTC_EnterInitMode() == ERROR)
788  {
789  status = ERROR;
790  }
791  else
792  {
793  /* Set the RTC_TR register */
794  RTC->TR = (uint32_t)(tmpreg & RTC_TR_RESERVED_MASK);
795 
796  /* Exit Initialization mode */
797  RTC_ExitInitMode();
798 
799  /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */
800  if ((RTC->CR & RTC_CR_BYPSHAD) == RESET)
801  {
802  if (RTC_WaitForSynchro() == ERROR)
803  {
804  status = ERROR;
805  }
806  else
807  {
808  status = SUCCESS;
809  }
810  }
811  else
812  {
813  status = SUCCESS;
814  }
815 
816  }
817  /* Enable the write protection for RTC registers */
818  RTC->WPR = 0xFF;
819 
820  return status;
821 }
822 
830 void RTC_TimeStructInit(RTC_TimeTypeDef* RTC_TimeStruct)
831 {
832  /* Time = 00h:00min:00sec */
833  RTC_TimeStruct->RTC_H12 = RTC_H12_AM;
834  RTC_TimeStruct->RTC_Hours = 0;
835  RTC_TimeStruct->RTC_Minutes = 0;
836  RTC_TimeStruct->RTC_Seconds = 0;
837 }
838 
849 void RTC_GetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct)
850 {
851  uint32_t tmpreg = 0;
852 
853  /* Check the parameters */
854  assert_param(IS_RTC_FORMAT(RTC_Format));
855 
856  /* Get the RTC_TR register */
857  tmpreg = (uint32_t)(RTC->TR & RTC_TR_RESERVED_MASK);
858 
859  /* Fill the structure fields with the read parameters */
860  RTC_TimeStruct->RTC_Hours = (uint8_t)((tmpreg & (RTC_TR_HT | RTC_TR_HU)) >> 16);
861  RTC_TimeStruct->RTC_Minutes = (uint8_t)((tmpreg & (RTC_TR_MNT | RTC_TR_MNU)) >>8);
862  RTC_TimeStruct->RTC_Seconds = (uint8_t)(tmpreg & (RTC_TR_ST | RTC_TR_SU));
863  RTC_TimeStruct->RTC_H12 = (uint8_t)((tmpreg & (RTC_TR_PM)) >> 16);
864 
865  /* Check the input parameters format */
866  if (RTC_Format == RTC_Format_BIN)
867  {
868  /* Convert the structure parameters to Binary format */
869  RTC_TimeStruct->RTC_Hours = (uint8_t)RTC_Bcd2ToByte(RTC_TimeStruct->RTC_Hours);
870  RTC_TimeStruct->RTC_Minutes = (uint8_t)RTC_Bcd2ToByte(RTC_TimeStruct->RTC_Minutes);
871  RTC_TimeStruct->RTC_Seconds = (uint8_t)RTC_Bcd2ToByte(RTC_TimeStruct->RTC_Seconds);
872  }
873 }
874 
882 uint32_t RTC_GetSubSecond(void)
883 {
884  uint32_t tmpreg = 0;
885 
886  /* Get subseconds values from the correspondent registers*/
887  tmpreg = (uint32_t)(RTC->SSR);
888 
889  /* Read DR register to unfroze calendar registers */
890  (void) (RTC->DR);
891 
892  return (tmpreg);
893 }
894 
907 ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct)
908 {
909  uint32_t tmpreg = 0;
911 
912  /* Check the parameters */
913  assert_param(IS_RTC_FORMAT(RTC_Format));
914 
915  if ((RTC_Format == RTC_Format_BIN) && ((RTC_DateStruct->RTC_Month & 0x10) == 0x10))
916  {
917  RTC_DateStruct->RTC_Month = (RTC_DateStruct->RTC_Month & (uint32_t)~(0x10)) + 0x0A;
918  }
919  if (RTC_Format == RTC_Format_BIN)
920  {
921  assert_param(IS_RTC_YEAR(RTC_DateStruct->RTC_Year));
922  assert_param(IS_RTC_MONTH(RTC_DateStruct->RTC_Month));
923  assert_param(IS_RTC_DATE(RTC_DateStruct->RTC_Date));
924  }
925  else
926  {
927  assert_param(IS_RTC_YEAR(RTC_Bcd2ToByte(RTC_DateStruct->RTC_Year)));
928  tmpreg = RTC_Bcd2ToByte(RTC_DateStruct->RTC_Month);
929  assert_param(IS_RTC_MONTH(tmpreg));
930  tmpreg = RTC_Bcd2ToByte(RTC_DateStruct->RTC_Date);
931  assert_param(IS_RTC_DATE(tmpreg));
932  }
933  assert_param(IS_RTC_WEEKDAY(RTC_DateStruct->RTC_WeekDay));
934 
935  /* Check the input parameters format */
936  if (RTC_Format != RTC_Format_BIN)
937  {
938  tmpreg = ((((uint32_t)RTC_DateStruct->RTC_Year) << 16) | \
939  (((uint32_t)RTC_DateStruct->RTC_Month) << 8) | \
940  ((uint32_t)RTC_DateStruct->RTC_Date) | \
941  (((uint32_t)RTC_DateStruct->RTC_WeekDay) << 13));
942  }
943  else
944  {
945  tmpreg = (((uint32_t)RTC_ByteToBcd2(RTC_DateStruct->RTC_Year) << 16) | \
946  ((uint32_t)RTC_ByteToBcd2(RTC_DateStruct->RTC_Month) << 8) | \
947  ((uint32_t)RTC_ByteToBcd2(RTC_DateStruct->RTC_Date)) | \
948  ((uint32_t)RTC_DateStruct->RTC_WeekDay << 13));
949  }
950 
951  /* Disable the write protection for RTC registers */
952  RTC->WPR = 0xCA;
953  RTC->WPR = 0x53;
954 
955  /* Set Initialization mode */
956  if (RTC_EnterInitMode() == ERROR)
957  {
958  status = ERROR;
959  }
960  else
961  {
962  /* Set the RTC_DR register */
963  RTC->DR = (uint32_t)(tmpreg & RTC_DR_RESERVED_MASK);
964 
965  /* Exit Initialization mode */
966  RTC_ExitInitMode();
967 
968  /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */
969  if ((RTC->CR & RTC_CR_BYPSHAD) == RESET)
970  {
971  if (RTC_WaitForSynchro() == ERROR)
972  {
973  status = ERROR;
974  }
975  else
976  {
977  status = SUCCESS;
978  }
979  }
980  else
981  {
982  status = SUCCESS;
983  }
984  }
985  /* Enable the write protection for RTC registers */
986  RTC->WPR = 0xFF;
987 
988  return status;
989 }
990 
998 void RTC_DateStructInit(RTC_DateTypeDef* RTC_DateStruct)
999 {
1000  /* Monday, January 01 xx00 */
1001  RTC_DateStruct->RTC_WeekDay = RTC_Weekday_Monday;
1002  RTC_DateStruct->RTC_Date = 1;
1003  RTC_DateStruct->RTC_Month = RTC_Month_January;
1004  RTC_DateStruct->RTC_Year = 0;
1005 }
1006 
1017 void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct)
1018 {
1019  uint32_t tmpreg = 0;
1020 
1021  /* Check the parameters */
1022  assert_param(IS_RTC_FORMAT(RTC_Format));
1023 
1024  /* Get the RTC_TR register */
1025  tmpreg = (uint32_t)(RTC->DR & RTC_DR_RESERVED_MASK);
1026 
1027  /* Fill the structure fields with the read parameters */
1028  RTC_DateStruct->RTC_Year = (uint8_t)((tmpreg & (RTC_DR_YT | RTC_DR_YU)) >> 16);
1029  RTC_DateStruct->RTC_Month = (uint8_t)((tmpreg & (RTC_DR_MT | RTC_DR_MU)) >> 8);
1030  RTC_DateStruct->RTC_Date = (uint8_t)(tmpreg & (RTC_DR_DT | RTC_DR_DU));
1031  RTC_DateStruct->RTC_WeekDay = (uint8_t)((tmpreg & (RTC_DR_WDU)) >> 13);
1032 
1033  /* Check the input parameters format */
1034  if (RTC_Format == RTC_Format_BIN)
1035  {
1036  /* Convert the structure parameters to Binary format */
1037  RTC_DateStruct->RTC_Year = (uint8_t)RTC_Bcd2ToByte(RTC_DateStruct->RTC_Year);
1038  RTC_DateStruct->RTC_Month = (uint8_t)RTC_Bcd2ToByte(RTC_DateStruct->RTC_Month);
1039  RTC_DateStruct->RTC_Date = (uint8_t)RTC_Bcd2ToByte(RTC_DateStruct->RTC_Date);
1040  RTC_DateStruct->RTC_WeekDay = (uint8_t)(RTC_DateStruct->RTC_WeekDay);
1041  }
1042 }
1043 
1077 void RTC_SetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct)
1078 {
1079  uint32_t tmpreg = 0;
1080 
1081  /* Check the parameters */
1082  assert_param(IS_RTC_FORMAT(RTC_Format));
1083  assert_param(IS_RTC_ALARM(RTC_Alarm));
1084  assert_param(IS_ALARM_MASK(RTC_AlarmStruct->RTC_AlarmMask));
1086 
1087  if (RTC_Format == RTC_Format_BIN)
1088  {
1089  if ((RTC->CR & RTC_CR_FMT) != (uint32_t)RESET)
1090  {
1092  assert_param(IS_RTC_H12(RTC_AlarmStruct->RTC_AlarmTime.RTC_H12));
1093  }
1094  else
1095  {
1096  RTC_AlarmStruct->RTC_AlarmTime.RTC_H12 = 0x00;
1098  }
1101 
1103  {
1105  }
1106  else
1107  {
1109  }
1110  }
1111  else
1112  {
1113  if ((RTC->CR & RTC_CR_FMT) != (uint32_t)RESET)
1114  {
1115  tmpreg = RTC_Bcd2ToByte(RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours);
1116  assert_param(IS_RTC_HOUR12(tmpreg));
1117  assert_param(IS_RTC_H12(RTC_AlarmStruct->RTC_AlarmTime.RTC_H12));
1118  }
1119  else
1120  {
1121  RTC_AlarmStruct->RTC_AlarmTime.RTC_H12 = 0x00;
1123  }
1124 
1127 
1129  {
1130  tmpreg = RTC_Bcd2ToByte(RTC_AlarmStruct->RTC_AlarmDateWeekDay);
1132  }
1133  else
1134  {
1135  tmpreg = RTC_Bcd2ToByte(RTC_AlarmStruct->RTC_AlarmDateWeekDay);
1137  }
1138  }
1139 
1140  /* Check the input parameters format */
1141  if (RTC_Format != RTC_Format_BIN)
1142  {
1143  tmpreg = (((uint32_t)(RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours) << 16) | \
1144  ((uint32_t)(RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes) << 8) | \
1145  ((uint32_t)RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds) | \
1146  ((uint32_t)(RTC_AlarmStruct->RTC_AlarmTime.RTC_H12) << 16) | \
1147  ((uint32_t)(RTC_AlarmStruct->RTC_AlarmDateWeekDay) << 24) | \
1148  ((uint32_t)RTC_AlarmStruct->RTC_AlarmDateWeekDaySel) | \
1149  ((uint32_t)RTC_AlarmStruct->RTC_AlarmMask));
1150  }
1151  else
1152  {
1153  tmpreg = (((uint32_t)RTC_ByteToBcd2(RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours) << 16) | \
1154  ((uint32_t)RTC_ByteToBcd2(RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes) << 8) | \
1155  ((uint32_t)RTC_ByteToBcd2(RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds)) | \
1156  ((uint32_t)(RTC_AlarmStruct->RTC_AlarmTime.RTC_H12) << 16) | \
1157  ((uint32_t)RTC_ByteToBcd2(RTC_AlarmStruct->RTC_AlarmDateWeekDay) << 24) | \
1158  ((uint32_t)RTC_AlarmStruct->RTC_AlarmDateWeekDaySel) | \
1159  ((uint32_t)RTC_AlarmStruct->RTC_AlarmMask));
1160  }
1161 
1162  /* Disable the write protection for RTC registers */
1163  RTC->WPR = 0xCA;
1164  RTC->WPR = 0x53;
1165 
1166  /* Configure the Alarm register */
1167  if (RTC_Alarm == RTC_Alarm_A)
1168  {
1169  RTC->ALRMAR = (uint32_t)tmpreg;
1170  }
1171  else
1172  {
1173  RTC->ALRMBR = (uint32_t)tmpreg;
1174  }
1175 
1176  /* Enable the write protection for RTC registers */
1177  RTC->WPR = 0xFF;
1178 }
1179 
1189 {
1190  /* Alarm Time Settings : Time = 00h:00mn:00sec */
1191  RTC_AlarmStruct->RTC_AlarmTime.RTC_H12 = RTC_H12_AM;
1192  RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours = 0;
1193  RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes = 0;
1194  RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds = 0;
1195 
1196  /* Alarm Date Settings : Date = 1st day of the month */
1198  RTC_AlarmStruct->RTC_AlarmDateWeekDay = 1;
1199 
1200  /* Alarm Masks Settings : Mask = all fields are not masked */
1201  RTC_AlarmStruct->RTC_AlarmMask = RTC_AlarmMask_None;
1202 }
1203 
1218 void RTC_GetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct)
1219 {
1220  uint32_t tmpreg = 0;
1221 
1222  /* Check the parameters */
1223  assert_param(IS_RTC_FORMAT(RTC_Format));
1224  assert_param(IS_RTC_ALARM(RTC_Alarm));
1225 
1226  /* Get the RTC_ALRMxR register */
1227  if (RTC_Alarm == RTC_Alarm_A)
1228  {
1229  tmpreg = (uint32_t)(RTC->ALRMAR);
1230  }
1231  else
1232  {
1233  tmpreg = (uint32_t)(RTC->ALRMBR);
1234  }
1235 
1236  /* Fill the structure with the read parameters */
1237  RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours = (uint32_t)((tmpreg & (RTC_ALRMAR_HT | \
1238  RTC_ALRMAR_HU)) >> 16);
1239  RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes = (uint32_t)((tmpreg & (RTC_ALRMAR_MNT | \
1240  RTC_ALRMAR_MNU)) >> 8);
1241  RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds = (uint32_t)(tmpreg & (RTC_ALRMAR_ST | \
1242  RTC_ALRMAR_SU));
1243  RTC_AlarmStruct->RTC_AlarmTime.RTC_H12 = (uint32_t)((tmpreg & RTC_ALRMAR_PM) >> 16);
1244  RTC_AlarmStruct->RTC_AlarmDateWeekDay = (uint32_t)((tmpreg & (RTC_ALRMAR_DT | RTC_ALRMAR_DU)) >> 24);
1245  RTC_AlarmStruct->RTC_AlarmDateWeekDaySel = (uint32_t)(tmpreg & RTC_ALRMAR_WDSEL);
1246  RTC_AlarmStruct->RTC_AlarmMask = (uint32_t)(tmpreg & RTC_AlarmMask_All);
1247 
1248  if (RTC_Format == RTC_Format_BIN)
1249  {
1250  RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours = RTC_Bcd2ToByte(RTC_AlarmStruct-> \
1251  RTC_AlarmTime.RTC_Hours);
1252  RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes = RTC_Bcd2ToByte(RTC_AlarmStruct-> \
1253  RTC_AlarmTime.RTC_Minutes);
1254  RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds = RTC_Bcd2ToByte(RTC_AlarmStruct-> \
1255  RTC_AlarmTime.RTC_Seconds);
1256  RTC_AlarmStruct->RTC_AlarmDateWeekDay = RTC_Bcd2ToByte(RTC_AlarmStruct->RTC_AlarmDateWeekDay);
1257  }
1258 }
1259 
1272 ErrorStatus RTC_AlarmCmd(uint32_t RTC_Alarm, FunctionalState NewState)
1273 {
1274  __IO uint32_t alarmcounter = 0x00;
1275  uint32_t alarmstatus = 0x00;
1277 
1278  /* Check the parameters */
1279  assert_param(IS_RTC_CMD_ALARM(RTC_Alarm));
1280  assert_param(IS_FUNCTIONAL_STATE(NewState));
1281 
1282  /* Disable the write protection for RTC registers */
1283  RTC->WPR = 0xCA;
1284  RTC->WPR = 0x53;
1285 
1286  /* Configure the Alarm state */
1287  if (NewState != DISABLE)
1288  {
1289  RTC->CR |= (uint32_t)RTC_Alarm;
1290 
1291  status = SUCCESS;
1292  }
1293  else
1294  {
1295  /* Disable the Alarm in RTC_CR register */
1296  RTC->CR &= (uint32_t)~RTC_Alarm;
1297 
1298  /* Wait till RTC ALRxWF flag is set and if Time out is reached exit */
1299  do
1300  {
1301  alarmstatus = RTC->ISR & (RTC_Alarm >> 8);
1302  alarmcounter++;
1303  } while((alarmcounter != INITMODE_TIMEOUT) && (alarmstatus == 0x00));
1304 
1305  if ((RTC->ISR & (RTC_Alarm >> 8)) == RESET)
1306  {
1307  status = ERROR;
1308  }
1309  else
1310  {
1311  status = SUCCESS;
1312  }
1313  }
1314 
1315  /* Enable the write protection for RTC registers */
1316  RTC->WPR = 0xFF;
1317 
1318  return status;
1319 }
1320 
1366 void RTC_AlarmSubSecondConfig(uint32_t RTC_Alarm, uint32_t RTC_AlarmSubSecondValue, uint32_t RTC_AlarmSubSecondMask)
1367 {
1368  uint32_t tmpreg = 0;
1369 
1370  /* Check the parameters */
1371  assert_param(IS_RTC_ALARM(RTC_Alarm));
1372  assert_param(IS_RTC_ALARM_SUB_SECOND_VALUE(RTC_AlarmSubSecondValue));
1373  assert_param(IS_RTC_ALARM_SUB_SECOND_MASK(RTC_AlarmSubSecondMask));
1374 
1375  /* Disable the write protection for RTC registers */
1376  RTC->WPR = 0xCA;
1377  RTC->WPR = 0x53;
1378 
1379  /* Configure the Alarm A or Alarm B SubSecond registers */
1380  tmpreg = (uint32_t) (uint32_t)(RTC_AlarmSubSecondValue) | (uint32_t)(RTC_AlarmSubSecondMask);
1381 
1382  if (RTC_Alarm == RTC_Alarm_A)
1383  {
1384  /* Configure the AlarmA SubSecond register */
1385  RTC->ALRMASSR = tmpreg;
1386  }
1387  else
1388  {
1389  /* Configure the Alarm B SubSecond register */
1390  RTC->ALRMBSSR = tmpreg;
1391  }
1392 
1393  /* Enable the write protection for RTC registers */
1394  RTC->WPR = 0xFF;
1395 
1396 }
1397 
1407 uint32_t RTC_GetAlarmSubSecond(uint32_t RTC_Alarm)
1408 {
1409  uint32_t tmpreg = 0;
1410 
1411  /* Get the RTC_ALRMxR register */
1412  if (RTC_Alarm == RTC_Alarm_A)
1413  {
1414  tmpreg = (uint32_t)((RTC->ALRMASSR) & RTC_ALRMASSR_SS);
1415  }
1416  else
1417  {
1418  tmpreg = (uint32_t)((RTC->ALRMBSSR) & RTC_ALRMBSSR_SS);
1419  }
1420 
1421  return (tmpreg);
1422 }
1423 
1455 void RTC_WakeUpClockConfig(uint32_t RTC_WakeUpClock)
1456 {
1457  /* Check the parameters */
1458  assert_param(IS_RTC_WAKEUP_CLOCK(RTC_WakeUpClock));
1459 
1460  /* Disable the write protection for RTC registers */
1461  RTC->WPR = 0xCA;
1462  RTC->WPR = 0x53;
1463 
1464  /* Clear the Wakeup Timer clock source bits in CR register */
1465  RTC->CR &= (uint32_t)~RTC_CR_WUCKSEL;
1466 
1467  /* Configure the clock source */
1468  RTC->CR |= (uint32_t)RTC_WakeUpClock;
1469 
1470  /* Enable the write protection for RTC registers */
1471  RTC->WPR = 0xFF;
1472 }
1473 
1482 void RTC_SetWakeUpCounter(uint32_t RTC_WakeUpCounter)
1483 {
1484  /* Check the parameters */
1485  assert_param(IS_RTC_WAKEUP_COUNTER(RTC_WakeUpCounter));
1486 
1487  /* Disable the write protection for RTC registers */
1488  RTC->WPR = 0xCA;
1489  RTC->WPR = 0x53;
1490 
1491  /* Configure the Wakeup Timer counter */
1492  RTC->WUTR = (uint32_t)RTC_WakeUpCounter;
1493 
1494  /* Enable the write protection for RTC registers */
1495  RTC->WPR = 0xFF;
1496 }
1497 
1503 uint32_t RTC_GetWakeUpCounter(void)
1504 {
1505  /* Get the counter value */
1506  return ((uint32_t)(RTC->WUTR & RTC_WUTR_WUT));
1507 }
1508 
1516 {
1517  __IO uint32_t wutcounter = 0x00;
1518  uint32_t wutwfstatus = 0x00;
1520 
1521  /* Check the parameters */
1522  assert_param(IS_FUNCTIONAL_STATE(NewState));
1523 
1524  /* Disable the write protection for RTC registers */
1525  RTC->WPR = 0xCA;
1526  RTC->WPR = 0x53;
1527 
1528  if (NewState != DISABLE)
1529  {
1530  /* Enable the Wakeup Timer */
1531  RTC->CR |= (uint32_t)RTC_CR_WUTE;
1532  status = SUCCESS;
1533  }
1534  else
1535  {
1536  /* Disable the Wakeup Timer */
1537  RTC->CR &= (uint32_t)~RTC_CR_WUTE;
1538  /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
1539  do
1540  {
1541  wutwfstatus = RTC->ISR & RTC_ISR_WUTWF;
1542  wutcounter++;
1543  } while((wutcounter != INITMODE_TIMEOUT) && (wutwfstatus == 0x00));
1544 
1545  if ((RTC->ISR & RTC_ISR_WUTWF) == RESET)
1546  {
1547  status = ERROR;
1548  }
1549  else
1550  {
1551  status = SUCCESS;
1552  }
1553  }
1554 
1555  /* Enable the write protection for RTC registers */
1556  RTC->WPR = 0xFF;
1557 
1558  return status;
1559 }
1560 
1591 void RTC_DayLightSavingConfig(uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation)
1592 {
1593  /* Check the parameters */
1594  assert_param(IS_RTC_DAYLIGHT_SAVING(RTC_DayLightSaving));
1595  assert_param(IS_RTC_STORE_OPERATION(RTC_StoreOperation));
1596 
1597  /* Disable the write protection for RTC registers */
1598  RTC->WPR = 0xCA;
1599  RTC->WPR = 0x53;
1600 
1601  /* Clear the bits to be configured */
1602  RTC->CR &= (uint32_t)~(RTC_CR_BCK);
1603 
1604  /* Configure the RTC_CR register */
1605  RTC->CR |= (uint32_t)(RTC_DayLightSaving | RTC_StoreOperation);
1606 
1607  /* Enable the write protection for RTC registers */
1608  RTC->WPR = 0xFF;
1609 }
1610 
1619 {
1620  return (RTC->CR & RTC_CR_BCK);
1621 }
1622 
1656 void RTC_OutputConfig(uint32_t RTC_Output, uint32_t RTC_OutputPolarity)
1657 {
1658  /* Check the parameters */
1659  assert_param(IS_RTC_OUTPUT(RTC_Output));
1660  assert_param(IS_RTC_OUTPUT_POL(RTC_OutputPolarity));
1661 
1662  /* Disable the write protection for RTC registers */
1663  RTC->WPR = 0xCA;
1664  RTC->WPR = 0x53;
1665 
1666  /* Clear the bits to be configured */
1667  RTC->CR &= (uint32_t)~(RTC_CR_OSEL | RTC_CR_POL);
1668 
1669  /* Configure the output selection and polarity */
1670  RTC->CR |= (uint32_t)(RTC_Output | RTC_OutputPolarity);
1671 
1672  /* Enable the write protection for RTC registers */
1673  RTC->WPR = 0xFF;
1674 }
1675 
1700 {
1701  /* Check the parameters */
1702  assert_param(IS_FUNCTIONAL_STATE(NewState));
1703 
1704  /* Disable the write protection for RTC registers */
1705  RTC->WPR = 0xCA;
1706  RTC->WPR = 0x53;
1707 
1708  if (NewState != DISABLE)
1709  {
1710  /* Enable the RTC clock output */
1711  RTC->CR |= (uint32_t)RTC_CR_COE;
1712  }
1713  else
1714  {
1715  /* Disable the RTC clock output */
1716  RTC->CR &= (uint32_t)~RTC_CR_COE;
1717  }
1718 
1719  /* Enable the write protection for RTC registers */
1720  RTC->WPR = 0xFF;
1721 }
1722 
1731 void RTC_CalibOutputConfig(uint32_t RTC_CalibOutput)
1732 {
1733  /* Check the parameters */
1734  assert_param(IS_RTC_CALIB_OUTPUT(RTC_CalibOutput));
1735 
1736  /* Disable the write protection for RTC registers */
1737  RTC->WPR = 0xCA;
1738  RTC->WPR = 0x53;
1739 
1740  /*clear flags before config*/
1741  RTC->CR &= (uint32_t)~(RTC_CR_COSEL);
1742 
1743  /* Configure the RTC_CR register */
1744  RTC->CR |= (uint32_t)RTC_CalibOutput;
1745 
1746  /* Enable the write protection for RTC registers */
1747  RTC->WPR = 0xFF;
1748 }
1749 
1767 ErrorStatus RTC_SmoothCalibConfig(uint32_t RTC_SmoothCalibPeriod,
1768  uint32_t RTC_SmoothCalibPlusPulses,
1769  uint32_t RTC_SmouthCalibMinusPulsesValue)
1770 {
1772  uint32_t recalpfcount = 0;
1773 
1774  /* Check the parameters */
1775  assert_param(IS_RTC_SMOOTH_CALIB_PERIOD(RTC_SmoothCalibPeriod));
1776  assert_param(IS_RTC_SMOOTH_CALIB_PLUS(RTC_SmoothCalibPlusPulses));
1777  assert_param(IS_RTC_SMOOTH_CALIB_MINUS(RTC_SmouthCalibMinusPulsesValue));
1778 
1779  /* Disable the write protection for RTC registers */
1780  RTC->WPR = 0xCA;
1781  RTC->WPR = 0x53;
1782 
1783  /* check if a calibration is pending*/
1784  if ((RTC->ISR & RTC_ISR_RECALPF) != RESET)
1785  {
1786  /* wait until the Calibration is completed*/
1787  while (((RTC->ISR & RTC_ISR_RECALPF) != RESET) && (recalpfcount != RECALPF_TIMEOUT))
1788  {
1789  recalpfcount++;
1790  }
1791  }
1792 
1793  /* check if the calibration pending is completed or if there is no calibration operation at all*/
1794  if ((RTC->ISR & RTC_ISR_RECALPF) == RESET)
1795  {
1796  /* Configure the Smooth calibration settings */
1797  RTC->CALR = (uint32_t)((uint32_t)RTC_SmoothCalibPeriod | (uint32_t)RTC_SmoothCalibPlusPulses | (uint32_t)RTC_SmouthCalibMinusPulsesValue);
1798 
1799  status = SUCCESS;
1800  }
1801  else
1802  {
1803  status = ERROR;
1804  }
1805 
1806  /* Enable the write protection for RTC registers */
1807  RTC->WPR = 0xFF;
1808 
1809  return (ErrorStatus)(status);
1810 }
1811 
1843 void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState)
1844 {
1845  uint32_t tmpreg = 0;
1846 
1847  /* Check the parameters */
1848  assert_param(IS_RTC_TIMESTAMP_EDGE(RTC_TimeStampEdge));
1849  assert_param(IS_FUNCTIONAL_STATE(NewState));
1850 
1851  /* Get the RTC_CR register and clear the bits to be configured */
1852  tmpreg = (uint32_t)(RTC->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));
1853 
1854  /* Get the new configuration */
1855  if (NewState != DISABLE)
1856  {
1857  tmpreg |= (uint32_t)(RTC_TimeStampEdge | RTC_CR_TSE);
1858  }
1859  else
1860  {
1861  tmpreg |= (uint32_t)(RTC_TimeStampEdge);
1862  }
1863 
1864  /* Disable the write protection for RTC registers */
1865  RTC->WPR = 0xCA;
1866  RTC->WPR = 0x53;
1867 
1868  /* Configure the Time Stamp TSEDGE and Enable bits */
1869  RTC->CR = (uint32_t)tmpreg;
1870 
1871  /* Enable the write protection for RTC registers */
1872  RTC->WPR = 0xFF;
1873 }
1874 
1887 void RTC_GetTimeStamp(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_StampTimeStruct,
1888  RTC_DateTypeDef* RTC_StampDateStruct)
1889 {
1890  uint32_t tmptime = 0, tmpdate = 0;
1891 
1892  /* Check the parameters */
1893  assert_param(IS_RTC_FORMAT(RTC_Format));
1894 
1895  /* Get the TimeStamp time and date registers values */
1896  tmptime = (uint32_t)(RTC->TSTR & RTC_TR_RESERVED_MASK);
1897  tmpdate = (uint32_t)(RTC->TSDR & RTC_DR_RESERVED_MASK);
1898 
1899  /* Fill the Time structure fields with the read parameters */
1900  RTC_StampTimeStruct->RTC_Hours = (uint8_t)((tmptime & (RTC_TR_HT | RTC_TR_HU)) >> 16);
1901  RTC_StampTimeStruct->RTC_Minutes = (uint8_t)((tmptime & (RTC_TR_MNT | RTC_TR_MNU)) >> 8);
1902  RTC_StampTimeStruct->RTC_Seconds = (uint8_t)(tmptime & (RTC_TR_ST | RTC_TR_SU));
1903  RTC_StampTimeStruct->RTC_H12 = (uint8_t)((tmptime & (RTC_TR_PM)) >> 16);
1904 
1905  /* Fill the Date structure fields with the read parameters */
1906  RTC_StampDateStruct->RTC_Year = 0;
1907  RTC_StampDateStruct->RTC_Month = (uint8_t)((tmpdate & (RTC_DR_MT | RTC_DR_MU)) >> 8);
1908  RTC_StampDateStruct->RTC_Date = (uint8_t)(tmpdate & (RTC_DR_DT | RTC_DR_DU));
1909  RTC_StampDateStruct->RTC_WeekDay = (uint8_t)((tmpdate & (RTC_DR_WDU)) >> 13);
1910 
1911  /* Check the input parameters format */
1912  if (RTC_Format == RTC_Format_BIN)
1913  {
1914  /* Convert the Time structure parameters to Binary format */
1915  RTC_StampTimeStruct->RTC_Hours = (uint8_t)RTC_Bcd2ToByte(RTC_StampTimeStruct->RTC_Hours);
1916  RTC_StampTimeStruct->RTC_Minutes = (uint8_t)RTC_Bcd2ToByte(RTC_StampTimeStruct->RTC_Minutes);
1917  RTC_StampTimeStruct->RTC_Seconds = (uint8_t)RTC_Bcd2ToByte(RTC_StampTimeStruct->RTC_Seconds);
1918 
1919  /* Convert the Date structure parameters to Binary format */
1920  RTC_StampDateStruct->RTC_Month = (uint8_t)RTC_Bcd2ToByte(RTC_StampDateStruct->RTC_Month);
1921  RTC_StampDateStruct->RTC_Date = (uint8_t)RTC_Bcd2ToByte(RTC_StampDateStruct->RTC_Date);
1922  RTC_StampDateStruct->RTC_WeekDay = (uint8_t)RTC_Bcd2ToByte(RTC_StampDateStruct->RTC_WeekDay);
1923  }
1924 }
1925 
1932 {
1933  /* Get timestamp subseconds values from the correspondent registers */
1934  return (uint32_t)(RTC->TSSSR);
1935 }
1936 
1969 void RTC_TamperTriggerConfig(uint32_t RTC_Tamper, uint32_t RTC_TamperTrigger)
1970 {
1971  /* Check the parameters */
1972  assert_param(IS_RTC_TAMPER(RTC_Tamper));
1973  assert_param(IS_RTC_TAMPER_TRIGGER(RTC_TamperTrigger));
1974 
1975  /* Check if the active level for Tamper is rising edge (Low level)*/
1976  if (RTC_TamperTrigger == RTC_TamperTrigger_RisingEdge)
1977  {
1978  /* Configure the RTC_TAFCR register */
1979  RTC->TAFCR &= (uint32_t)((uint32_t)~(RTC_Tamper << 1));
1980  }
1981  else
1982  {
1983  /* Configure the RTC_TAFCR register */
1984  RTC->TAFCR |= (uint32_t)(RTC_Tamper << 1);
1985  }
1986 }
1987 
1999 void RTC_TamperCmd(uint32_t RTC_Tamper, FunctionalState NewState)
2000 {
2001  /* Check the parameters */
2002  assert_param(IS_RTC_TAMPER(RTC_Tamper));
2003  assert_param(IS_FUNCTIONAL_STATE(NewState));
2004 
2005  if (NewState != DISABLE)
2006  {
2007  /* Enable the selected Tamper pin */
2008  RTC->TAFCR |= (uint32_t)RTC_Tamper;
2009  }
2010  else
2011  {
2012  /* Disable the selected Tamper pin */
2013  RTC->TAFCR &= (uint32_t)~RTC_Tamper;
2014  }
2015 }
2016 
2030 void RTC_TamperFilterConfig(uint32_t RTC_TamperFilter)
2031 {
2032  /* Check the parameters */
2033  assert_param(IS_RTC_TAMPER_FILTER(RTC_TamperFilter));
2034 
2035  /* Clear TAMPFLT[1:0] bits in the RTC_TAFCR register */
2036  RTC->TAFCR &= (uint32_t)~(RTC_TAFCR_TAMPFLT);
2037 
2038  /* Configure the RTC_TAFCR register */
2039  RTC->TAFCR |= (uint32_t)RTC_TamperFilter;
2040 }
2041 
2064 void RTC_TamperSamplingFreqConfig(uint32_t RTC_TamperSamplingFreq)
2065 {
2066  /* Check the parameters */
2067  assert_param(IS_RTC_TAMPER_SAMPLING_FREQ(RTC_TamperSamplingFreq));
2068 
2069  /* Clear TAMPFREQ[2:0] bits in the RTC_TAFCR register */
2070  RTC->TAFCR &= (uint32_t)~(RTC_TAFCR_TAMPFREQ);
2071 
2072  /* Configure the RTC_TAFCR register */
2073  RTC->TAFCR |= (uint32_t)RTC_TamperSamplingFreq;
2074 }
2075 
2087 void RTC_TamperPinsPrechargeDuration(uint32_t RTC_TamperPrechargeDuration)
2088 {
2089  /* Check the parameters */
2090  assert_param(IS_RTC_TAMPER_PRECHARGE_DURATION(RTC_TamperPrechargeDuration));
2091 
2092  /* Clear TAMPPRCH[1:0] bits in the RTC_TAFCR register */
2093  RTC->TAFCR &= (uint32_t)~(RTC_TAFCR_TAMPPRCH);
2094 
2095  /* Configure the RTC_TAFCR register */
2096  RTC->TAFCR |= (uint32_t)RTC_TamperPrechargeDuration;
2097 }
2098 
2108 {
2109  /* Check the parameters */
2110  assert_param(IS_FUNCTIONAL_STATE(NewState));
2111 
2112  if (NewState != DISABLE)
2113  {
2114  /* Save timestamp on tamper detection event */
2115  RTC->TAFCR |= (uint32_t)RTC_TAFCR_TAMPTS;
2116  }
2117  else
2118  {
2119  /* Tamper detection does not cause a timestamp to be saved */
2120  RTC->TAFCR &= (uint32_t)~RTC_TAFCR_TAMPTS;
2121  }
2122 }
2123 
2131 {
2132  /* Check the parameters */
2133  assert_param(IS_FUNCTIONAL_STATE(NewState));
2134 
2135  if (NewState != DISABLE)
2136  {
2137  /* Enable precharge of the selected Tamper pin */
2138  RTC->TAFCR &= (uint32_t)~RTC_TAFCR_TAMPPUDIS;
2139  }
2140  else
2141  {
2142  /* Disable precharge of the selected Tamper pin */
2143  RTC->TAFCR |= (uint32_t)RTC_TAFCR_TAMPPUDIS;
2144  }
2145 }
2146 
2171 void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data)
2172 {
2173  __IO uint32_t tmp = 0;
2174 
2175  /* Check the parameters */
2176  assert_param(IS_RTC_BKP(RTC_BKP_DR));
2177 
2178  tmp = RTC_BASE + 0x50;
2179  tmp += (RTC_BKP_DR * 4);
2180 
2181  /* Write the specified register */
2182  *(__IO uint32_t *)tmp = (uint32_t)Data;
2183 }
2184 
2192 uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR)
2193 {
2194  __IO uint32_t tmp = 0;
2195 
2196  /* Check the parameters */
2197  assert_param(IS_RTC_BKP(RTC_BKP_DR));
2198 
2199  tmp = RTC_BASE + 0x50;
2200  tmp += (RTC_BKP_DR * 4);
2201 
2202  /* Read the specified register */
2203  return (*(__IO uint32_t *)tmp);
2204 }
2205 
2232 void RTC_OutputTypeConfig(uint32_t RTC_OutputType)
2233 {
2234  /* Check the parameters */
2235  assert_param(IS_RTC_OUTPUT_TYPE(RTC_OutputType));
2236 
2237  RTC->TAFCR &= (uint32_t)~(RTC_TAFCR_ALARMOUTTYPE);
2238  RTC->TAFCR |= (uint32_t)(RTC_OutputType);
2239 }
2240 
2270 ErrorStatus RTC_SynchroShiftConfig(uint32_t RTC_ShiftAdd1S, uint32_t RTC_ShiftSubFS)
2271 {
2273  uint32_t shpfcount = 0;
2274 
2275  /* Check the parameters */
2276  assert_param(IS_RTC_SHIFT_ADD1S(RTC_ShiftAdd1S));
2277  assert_param(IS_RTC_SHIFT_SUBFS(RTC_ShiftSubFS));
2278 
2279  /* Disable the write protection for RTC registers */
2280  RTC->WPR = 0xCA;
2281  RTC->WPR = 0x53;
2282 
2283  /* Check if a Shift is pending*/
2284  if ((RTC->ISR & RTC_ISR_SHPF) != RESET)
2285  {
2286  /* Wait until the shift is completed*/
2287  while (((RTC->ISR & RTC_ISR_SHPF) != RESET) && (shpfcount != SHPF_TIMEOUT))
2288  {
2289  shpfcount++;
2290  }
2291  }
2292 
2293  /* Check if the Shift pending is completed or if there is no Shift operation at all*/
2294  if ((RTC->ISR & RTC_ISR_SHPF) == RESET)
2295  {
2296  /* check if the reference clock detection is disabled */
2297  if((RTC->CR & RTC_CR_REFCKON) == RESET)
2298  {
2299  /* Configure the Shift settings */
2300  RTC->SHIFTR = (uint32_t)(uint32_t)(RTC_ShiftSubFS) | (uint32_t)(RTC_ShiftAdd1S);
2301 
2302  if(RTC_WaitForSynchro() == ERROR)
2303  {
2304  status = ERROR;
2305  }
2306  else
2307  {
2308  status = SUCCESS;
2309  }
2310  }
2311  else
2312  {
2313  status = ERROR;
2314  }
2315  }
2316  else
2317  {
2318  status = ERROR;
2319  }
2320 
2321  /* Enable the write protection for RTC registers */
2322  RTC->WPR = 0xFF;
2323 
2324  return (ErrorStatus)(status);
2325 }
2326 
2386 void RTC_ITConfig(uint32_t RTC_IT, FunctionalState NewState)
2387 {
2388  /* Check the parameters */
2389  assert_param(IS_RTC_CONFIG_IT(RTC_IT));
2390  assert_param(IS_FUNCTIONAL_STATE(NewState));
2391 
2392  /* Disable the write protection for RTC registers */
2393  RTC->WPR = 0xCA;
2394  RTC->WPR = 0x53;
2395 
2396  if (NewState != DISABLE)
2397  {
2398  /* Configure the Interrupts in the RTC_CR register */
2399  RTC->CR |= (uint32_t)(RTC_IT & ~RTC_TAFCR_TAMPIE);
2400  /* Configure the Tamper Interrupt in the RTC_TAFCR */
2401  RTC->TAFCR |= (uint32_t)(RTC_IT & RTC_TAFCR_TAMPIE);
2402  }
2403  else
2404  {
2405  /* Configure the Interrupts in the RTC_CR register */
2406  RTC->CR &= (uint32_t)~(RTC_IT & (uint32_t)~RTC_TAFCR_TAMPIE);
2407  /* Configure the Tamper Interrupt in the RTC_TAFCR */
2408  RTC->TAFCR &= (uint32_t)~(RTC_IT & RTC_TAFCR_TAMPIE);
2409  }
2410  /* Enable the write protection for RTC registers */
2411  RTC->WPR = 0xFF;
2412 }
2413 
2436 FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG)
2437 {
2438  FlagStatus bitstatus = RESET;
2439  uint32_t tmpreg = 0;
2440 
2441  /* Check the parameters */
2442  assert_param(IS_RTC_GET_FLAG(RTC_FLAG));
2443 
2444  /* Get all the flags */
2445  tmpreg = (uint32_t)(RTC->ISR & RTC_FLAGS_MASK);
2446 
2447  /* Return the status of the flag */
2448  if ((tmpreg & RTC_FLAG) != (uint32_t)RESET)
2449  {
2450  bitstatus = SET;
2451  }
2452  else
2453  {
2454  bitstatus = RESET;
2455  }
2456  return bitstatus;
2457 }
2458 
2474 void RTC_ClearFlag(uint32_t RTC_FLAG)
2475 {
2476  /* Check the parameters */
2477  assert_param(IS_RTC_CLEAR_FLAG(RTC_FLAG));
2478 
2479  /* Clear the Flags in the RTC_ISR register */
2480  RTC->ISR = (uint32_t)((uint32_t)(~((RTC_FLAG | RTC_ISR_INIT)& 0x0001FFFF) | (uint32_t)(RTC->ISR & RTC_ISR_INIT)));
2481 }
2482 
2496 ITStatus RTC_GetITStatus(uint32_t RTC_IT)
2497 {
2498  ITStatus bitstatus = RESET;
2499  uint32_t tmpreg = 0, enablestatus = 0;
2500 
2501  /* Check the parameters */
2502  assert_param(IS_RTC_GET_IT(RTC_IT));
2503 
2504  /* Get the TAMPER Interrupt enable bit and pending bit */
2505  tmpreg = (uint32_t)(RTC->TAFCR & (RTC_TAFCR_TAMPIE));
2506 
2507  /* Get the Interrupt enable Status */
2508  enablestatus = (uint32_t)((RTC->CR & RTC_IT) | (tmpreg & ((RTC_IT >> (RTC_IT >> 18)) >> 15)));
2509 
2510  /* Get the Interrupt pending bit */
2511  tmpreg = (uint32_t)((RTC->ISR & (uint32_t)(RTC_IT >> 4)));
2512 
2513  /* Get the status of the Interrupt */
2514  if ((enablestatus != (uint32_t)RESET) && ((tmpreg & 0x0000FFFF) != (uint32_t)RESET))
2515  {
2516  bitstatus = SET;
2517  }
2518  else
2519  {
2520  bitstatus = RESET;
2521  }
2522  return bitstatus;
2523 }
2524 
2538 void RTC_ClearITPendingBit(uint32_t RTC_IT)
2539 {
2540  uint32_t tmpreg = 0;
2541 
2542  /* Check the parameters */
2543  assert_param(IS_RTC_CLEAR_IT(RTC_IT));
2544 
2545  /* Get the RTC_ISR Interrupt pending bits mask */
2546  tmpreg = (uint32_t)(RTC_IT >> 4);
2547 
2548  /* Clear the interrupt pending bits in the RTC_ISR register */
2549  RTC->ISR = (uint32_t)((uint32_t)(~((tmpreg | RTC_ISR_INIT)& 0x0000FFFF) | (uint32_t)(RTC->ISR & RTC_ISR_INIT)));
2550 }
2551 
2561 static uint8_t RTC_ByteToBcd2(uint8_t Value)
2562 {
2563  uint8_t bcdhigh = 0;
2564 
2565  while (Value >= 10)
2566  {
2567  bcdhigh++;
2568  Value -= 10;
2569  }
2570 
2571  return ((uint8_t)(bcdhigh << 4) | Value);
2572 }
2573 
2579 static uint8_t RTC_Bcd2ToByte(uint8_t Value)
2580 {
2581  uint8_t tmp = 0;
2582  tmp = ((uint8_t)(Value & (uint8_t)0xF0) >> (uint8_t)0x4) * 10;
2583  return (tmp + (Value & (uint8_t)0x0F));
2584 }
2585 
2598 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
ErrorStatus RTC_Init(RTC_InitTypeDef *RTC_InitStruct)
Initializes the RTC registers according to the specified parameters in RTC_InitStruct.
uint32_t RTC_AlarmMask
FlagStatus
Definition: stm32f4xx.h:706
#define RTC_ALRMAR_DU
Definition: stm32f4xx.h:9405
ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef *RTC_TimeStruct)
Set the RTC current time.
#define RTC_CR_WUCKSEL
Definition: stm32f4xx.h:9366
#define IS_RTC_TAMPER_TRIGGER(TRIGGER)
#define IS_RTC_CONFIG_IT(IT)
#define IS_RTC_WAKEUP_COUNTER(COUNTER)
ErrorStatus RTC_RefClockCmd(FunctionalState NewState)
Enables or disables the RTC reference clock detection.
#define RTC_Format_BIN
#define IS_RTC_CLEAR_IT(IT)
#define RTC_CR_COE
Definition: stm32f4xx.h:9344
#define IS_RTC_SYNCH_PREDIV(PREDIV)
#define IS_RTC_GET_FLAG(FLAG)
ErrorStatus RTC_WakeUpCmd(FunctionalState NewState)
Enables or Disables the RTC WakeUp timer.
#define IS_RTC_SHIFT_SUBFS(FS)
ErrorStatus RTC_WaitForSynchro(void)
Waits until the RTC Time and Date registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock...
FunctionalState
Definition: stm32f4xx.h:708
#define RTC_ALRMAR_HU
Definition: stm32f4xx.h:9415
#define IS_RTC_TAMPER(TAMPER)
#define RTC_TR_HT
Definition: stm32f4xx.h:9286
void RTC_TimeStructInit(RTC_TimeTypeDef *RTC_TimeStruct)
Fills each RTC_TimeStruct member with its default value (Time = 00h:00min:00sec). ...
#define SHPF_TIMEOUT
void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState)
Enables or Disables the RTC TimeStamp functionality with the specified time stamp pin stimulating edg...
#define RTC_DR_WDU
Definition: stm32f4xx.h:9324
#define IS_RTC_DATE(DATE)
ErrorStatus RTC_SmoothCalibConfig(uint32_t RTC_SmoothCalibPeriod, uint32_t RTC_SmoothCalibPlusPulses, uint32_t RTC_SmouthCalibMinusPulsesValue)
Configures the Smooth Calibration Settings.
#define RTC_ALRMAR_DT
Definition: stm32f4xx.h:9402
#define RTC_TAFCR_TAMPPRCH
Definition: stm32f4xx.h:9565
void RTC_CalibOutputCmd(FunctionalState NewState)
Enables or disables the RTC clock to be output through the relative pin.
#define IS_RTC_BKP(BKP)
void RTC_TamperCmd(uint32_t RTC_Tamper, FunctionalState NewState)
Enables or Disables the Tamper detection.
#define IS_RTC_YEAR(YEAR)
uint8_t RTC_AlarmDateWeekDay
static uint8_t RTC_ByteToBcd2(uint8_t Value)
Converts a 2 digit decimal to BCD format.
void RTC_ITConfig(uint32_t RTC_IT, FunctionalState NewState)
Enables or disables the specified RTC interrupts.
#define RTC_DR_YU
Definition: stm32f4xx.h:9319
#define RTC_ISR_RSF
Definition: stm32f4xx.h:9381
uint32_t RTC_AlarmDateWeekDaySel
RTC Init structures definition.
Definition: stm32f4xx_rtc.h:53
#define IS_RTC_FORMAT(FORMAT)
#define RTC_DR_DT
Definition: stm32f4xx.h:9334
ITStatus RTC_GetITStatus(uint32_t RTC_IT)
Checks whether the specified RTC interrupt has occurred or not.
#define RTC_ALRMAR_MNT
Definition: stm32f4xx.h:9421
#define IS_RTC_SMOOTH_CALIB_PLUS(PLUS)
#define RTC_TamperTrigger_RisingEdge
ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef *RTC_DateStruct)
Set the RTC current date.
#define IS_RTC_ALARM_SUB_SECOND_MASK(MASK)
#define RTC_ALRMAR_MNU
Definition: stm32f4xx.h:9425
void RTC_GetTimeStamp(uint32_t RTC_Format, RTC_TimeTypeDef *RTC_StampTimeStruct, RTC_DateTypeDef *RTC_StampDateStruct)
Gets the RTC TimeStamp value and masks.
#define IS_RTC_GET_IT(IT)
#define IS_RTC_SMOOTH_CALIB_MINUS(VALUE)
#define IS_RTC_OUTPUT_POL(POL)
void assert_param(int val)
static uint8_t RTC_Bcd2ToByte(uint8_t Value)
Convert from 2 digit BCD to Binary.
#define RTC_DR_DU
Definition: stm32f4xx.h:9337
#define RTC_CR_TSEDGE
Definition: stm32f4xx.h:9365
#define RTC_CR_FMT
Definition: stm32f4xx.h:9362
#define RTC_CR_WUTE
Definition: stm32f4xx.h:9358
void RTC_ClearITPendingBit(uint32_t RTC_IT)
Clears the RTC&#39;s interrupt pending bits.
ErrorStatus RTC_AlarmCmd(uint32_t RTC_Alarm, FunctionalState NewState)
Enables or disables the specified RTC Alarm.
#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
ErrorStatus RTC_EnterInitMode(void)
Enters the RTC Initialization mode.
ErrorStatus RTC_SynchroShiftConfig(uint32_t RTC_ShiftAdd1S, uint32_t RTC_ShiftSubFS)
Configures the Synchronization Shift Control Settings.
static volatile uint8_t * status
Definition: drv_i2c.c:102
#define RTC_Month_January
RTC_TimeTypeDef RTC_AlarmTime
#define IS_RTC_OUTPUT(OUTPUT)
#define RTC_ALRMAR_ST
Definition: stm32f4xx.h:9431
void RTC_TamperFilterConfig(uint32_t RTC_TamperFilter)
Configures the Tampers Filter.
#define RTC_ISR_WUTWF
Definition: stm32f4xx.h:9384
Definition: stm32f4xx.h:706
void RTC_CalibOutputConfig(uint32_t RTC_CalibOutput)
Configures the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
#define RTC_TAFCR_TAMPTS
Definition: stm32f4xx.h:9575
enum FlagStatus ITStatus
#define RTC_Alarm_A
uint32_t RTC_GetWakeUpCounter(void)
Returns the RTC WakeUp timer counter value.
This file contains all the functions prototypes for the RCC firmware library.
#define RTC_CR_OSEL
Definition: stm32f4xx.h:9345
#define IS_RTC_HOUR_FORMAT(FORMAT)
uint32_t RTC_GetSubSecond(void)
Gets the RTC current Calendar Subseconds value.
#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
void RTC_DateStructInit(RTC_DateTypeDef *RTC_DateStruct)
Fills each RTC_DateStruct member with its default value (Monday, January 01 xx00).
uint8_t RTC_WeekDay
Definition: stm32f4xx_rtc.h:90
#define IS_RTC_HOUR24(HOUR)
This file contains all the functions prototypes for the RTC firmware library.
#define RTC_ISR_INITF
Definition: stm32f4xx.h:9380
void RTC_GetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef *RTC_AlarmStruct)
Get the RTC Alarm value and masks.
void RTC_TamperTriggerConfig(uint32_t RTC_Tamper, uint32_t RTC_TamperTrigger)
Configures the select Tamper pin edge.
#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
uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR)
Reads data from the specified RTC Backup data Register.
uint32_t RTC_GetStoreOperation(void)
Returns the RTC Day Light Saving stored operation.
#define IS_RTC_ALARM(ALARM)
#define IS_RTC_CALIB_OUTPUT(OUTPUT)
#define IS_RTC_OUTPUT_TYPE(TYPE)
void RTC_StructInit(RTC_InitTypeDef *RTC_InitStruct)
Fills each RTC_InitStruct member with its default value.
#define IS_RTC_ASYNCH_PREDIV(PREDIV)
#define INITMODE_TIMEOUT
uint32_t RTC_AsynchPrediv
Definition: stm32f4xx_rtc.h:58
#define RTC_H12_AM
void RTC_ExitInitMode(void)
Exits the RTC Initialization mode.
#define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ)
#define RTC_DR_RESERVED_MASK
uint32_t RTC_GetTimeStampSubSecond(void)
Gets the RTC timestamp Subseconds value.
#define RTC_CR_BYPSHAD
Definition: stm32f4xx.h:9363
#define IS_RTC_TIMESTAMP_EDGE(EDGE)
void RTC_TamperPinsPrechargeDuration(uint32_t RTC_TamperPrechargeDuration)
Configures the Tampers Pins input Precharge Duration.
#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
void RTC_ClearFlag(uint32_t RTC_FLAG)
Clears the RTC&#39;s pending flags.
#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
void RTC_OutputTypeConfig(uint32_t RTC_OutputType)
Configures the RTC Output Pin mode.
ErrorStatus
Definition: stm32f4xx.h:711
#define RTC_AlarmMask_All
#define IS_ALARM_MASK(MASK)
void RTC_WakeUpClockConfig(uint32_t RTC_WakeUpClock)
Configures the RTC Wakeup clock source.
void RTC_TamperSamplingFreqConfig(uint32_t RTC_TamperSamplingFreq)
Configures the Tampers Sampling Frequency.
void RTC_OutputConfig(uint32_t RTC_Output, uint32_t RTC_OutputPolarity)
Configures the RTC output source (AFO_ALARM).
#define RECALPF_TIMEOUT
#define RTC_ALRMASSR_SS
Definition: stm32f4xx.h:9586
#define IS_RTC_WEEKDAY(WEEKDAY)
#define RTC_TR_RESERVED_MASK
#define RTC_TR_SU
Definition: stm32f4xx.h:9307
#define IS_RTC_MINUTES(MINUTES)
#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
FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG)
Checks whether the specified RTC flag is set or not.
#define RTC_ISR_INIT
Definition: stm32f4xx.h:9379
void RTC_GetTime(uint32_t RTC_Format, RTC_TimeTypeDef *RTC_TimeStruct)
Get the RTC current Time.
uint32_t RTC_GetAlarmSubSecond(uint32_t RTC_Alarm)
Gets the RTC Alarm Subseconds value.
#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
void RTC_BypassShadowCmd(FunctionalState NewState)
Enables or Disables the Bypass Shadow feature.
#define IS_RTC_SHIFT_ADD1S(SEL)
#define RTC_CR_COSEL
Definition: stm32f4xx.h:9349
#define IS_RTC_STORE_OPERATION(OPERATION)
void RTC_SetWakeUpCounter(uint32_t RTC_WakeUpCounter)
Configures the RTC Wakeup counter.
#define RTC_ALRMAR_SU
Definition: stm32f4xx.h:9435
void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data)
Writes a data in a specified RTC Backup data register.
#define IS_RTC_CMD_ALARM(ALARM)
void RTC_AlarmSubSecondConfig(uint32_t RTC_Alarm, uint32_t RTC_AlarmSubSecondValue, uint32_t RTC_AlarmSubSecondMask)
Configures the RTC AlarmA/B Subseconds value and mask.
#define RTC_TAFCR_TAMPPUDIS
Definition: stm32f4xx.h:9564
void RTC_TamperPullUpCmd(FunctionalState NewState)
Enables or Disables the Precharge of Tamper pin.
#define RTC_TR_MNT
Definition: stm32f4xx.h:9294
#define RTC_TAFCR_ALARMOUTTYPE
Definition: stm32f4xx.h:9561
#define IS_RTC_MONTH(MONTH)
uint8_t RTC_Minutes
Definition: stm32f4xx_rtc.h:75
void RTC_SetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef *RTC_AlarmStruct)
Set the specified RTC Alarm.
#define RTC_INIT_MASK
ErrorStatus RTC_DeInit(void)
Deinitializes the RTC registers to their default reset values.
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 RTC_TR_ST
Definition: stm32f4xx.h:9303
#define RTC_Weekday_Monday
#define RTC_CR_POL
Definition: stm32f4xx.h:9348
void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef *RTC_DateStruct)
Get the RTC current date.
#define RTC
Definition: stm32f4xx.h:2046
#define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE)
#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_DayLightSavingConfig(uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation)
Adds or substract one hour from the current time.
#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)
void RTC_TimeStampOnTamperDetectionCmd(FunctionalState NewState)
Enables or Disables the TimeStamp on Tamper Detection Event.
void RTC_WriteProtectionCmd(FunctionalState NewState)
Enables or disables the RTC registers write protection.
uint32_t RTC_SynchPrediv
Definition: stm32f4xx_rtc.h:61


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