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)) 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) 377 __IO uint32_t wutcounter = 0x00;
378 uint32_t wutwfstatus = 0x00;
393 RTC->TR = (uint32_t)0x00000000;
394 RTC->DR = (uint32_t)0x00002101;
396 RTC->CR &= (uint32_t)0x00000007;
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;
424 RTC->ISR = (uint32_t)0x00000000;
427 RTC->TAFCR = 0x00000000;
554 __IO uint32_t initcounter = 0x00;
556 uint32_t initstatus = 0x00;
621 __IO uint32_t synchrocounter = 0;
623 uint32_t synchrostatus = 0x00;
637 }
while((synchrocounter !=
SYNCHRO_TIMEOUT) && (synchrostatus == 0x00));
782 RTC_TimeStruct->
RTC_H12 = 0x00;
798 RTC_TimeStruct->
RTC_H12 = 0x00;
808 tmpreg = (((uint32_t)(RTC_TimeStruct->
RTC_Hours) << 16) | \
811 ((uint32_t)(RTC_TimeStruct->
RTC_H12) << 16));
818 (((uint32_t)RTC_TimeStruct->
RTC_H12) << 16));
925 tmpreg = (uint32_t)(
RTC->SSR);
976 tmpreg = ((((uint32_t)RTC_DateStruct->
RTC_Year) << 16) | \
977 (((uint32_t)RTC_DateStruct->
RTC_Month) << 8) | \
978 ((uint32_t)RTC_DateStruct->
RTC_Date) | \
1057 uint32_t tmpreg = 0;
1117 uint32_t tmpreg = 0;
1207 RTC->ALRMAR = (uint32_t)tmpreg;
1211 RTC->ALRMBR = (uint32_t)tmpreg;
1258 uint32_t tmpreg = 0;
1267 tmpreg = (uint32_t)(
RTC->ALRMAR);
1271 tmpreg = (uint32_t)(
RTC->ALRMBR);
1289 RTC_AlarmTime.RTC_Hours);
1291 RTC_AlarmTime.RTC_Minutes);
1293 RTC_AlarmTime.RTC_Seconds);
1312 __IO uint32_t alarmcounter = 0x00;
1313 uint32_t alarmstatus = 0x00;
1327 RTC->CR |= (uint32_t)RTC_Alarm;
1334 RTC->CR &= (uint32_t)~RTC_Alarm;
1339 alarmstatus =
RTC->ISR & (RTC_Alarm >> 8);
1343 if ((
RTC->ISR & (RTC_Alarm >> 8)) ==
RESET)
1406 uint32_t tmpreg = 0;
1418 tmpreg = (uint32_t) (uint32_t)(RTC_AlarmSubSecondValue) | (uint32_t)(RTC_AlarmSubSecondMask);
1423 RTC->ALRMASSR = tmpreg;
1428 RTC->ALRMBSSR = tmpreg;
1447 uint32_t tmpreg = 0;
1507 RTC->CR |= (uint32_t)RTC_WakeUpClock;
1531 RTC->WUTR = (uint32_t)RTC_WakeUpCounter;
1556 __IO uint32_t wutcounter = 0x00;
1557 uint32_t wutwfstatus = 0x00;
1645 RTC->CR |= (uint32_t)(RTC_DayLightSaving | RTC_StoreOperation);
1711 RTC->CR |= (uint32_t)(RTC_Output | RTC_OutputPolarity);
1771 RTC->CALIBR = (uint32_t)(RTC_CalibSign | Value);
1883 RTC->CR |= (uint32_t)RTC_CalibOutput;
1907 uint32_t RTC_SmoothCalibPlusPulses,
1908 uint32_t RTC_SmouthCalibMinusPulsesValue)
1911 uint32_t recalpfcount = 0;
1936 RTC->CALR = (uint32_t)((uint32_t)RTC_SmoothCalibPeriod | (uint32_t)RTC_SmoothCalibPlusPulses | (uint32_t)RTC_SmouthCalibMinusPulsesValue);
1984 uint32_t tmpreg = 0;
1996 tmpreg |= (uint32_t)(RTC_TimeStampEdge |
RTC_CR_TSE);
2000 tmpreg |= (uint32_t)(RTC_TimeStampEdge);
2008 RTC->CR = (uint32_t)tmpreg;
2029 uint32_t tmptime = 0, tmpdate = 0;
2073 return (uint32_t)(
RTC->TSSSR);
2114 RTC->TAFCR &= (uint32_t)((uint32_t)~(RTC_Tamper << 1));
2119 RTC->TAFCR |= (uint32_t)(RTC_Tamper << 1);
2140 RTC->TAFCR |= (uint32_t)RTC_Tamper;
2145 RTC->TAFCR &= (uint32_t)~RTC_Tamper;
2171 RTC->TAFCR |= (uint32_t)RTC_TamperFilter;
2205 RTC->TAFCR |= (uint32_t)RTC_TamperSamplingFreq;
2228 RTC->TAFCR |= (uint32_t)RTC_TamperPrechargeDuration;
2305 __IO uint32_t tmp = 0;
2311 tmp += (RTC_BKP_DR * 4);
2314 *(
__IO uint32_t *)tmp = (uint32_t)Data;
2326 __IO uint32_t tmp = 0;
2332 tmp += (RTC_BKP_DR * 4);
2335 return (*(
__IO uint32_t *)tmp);
2369 RTC->TAFCR |= (uint32_t)(RTC_TamperPin);
2386 RTC->TAFCR |= (uint32_t)(RTC_TimeStampPin);
2405 RTC->TAFCR |= (uint32_t)(RTC_OutputType);
2440 uint32_t shpfcount = 0;
2467 RTC->SHIFTR = (uint32_t)(uint32_t)(RTC_ShiftSubFS) | (uint32_t)(RTC_ShiftAdd1S);
2608 uint32_t tmpreg = 0;
2617 if ((tmpreg & RTC_FLAG) != (uint32_t)
RESET)
2664 uint32_t tmpreg = 0, enablestatus = 0;
2673 enablestatus = (uint32_t)((
RTC->CR & RTC_IT) | (tmpreg & (RTC_IT >> 15)));
2676 tmpreg = (uint32_t)((
RTC->ISR & (uint32_t)(RTC_IT >> 4)));
2679 if ((enablestatus != (uint32_t)
RESET) && ((tmpreg & 0x0000FFFF) != (uint32_t)
RESET))
2703 uint32_t tmpreg = 0;
2709 tmpreg = (uint32_t)(RTC_IT >> 4);
2726 uint8_t bcdhigh = 0;
2734 return ((uint8_t)(bcdhigh << 4) | Value);
2745 tmp = ((uint8_t)(Value & (uint8_t)0xF0) >> (uint8_t)0x4) * 10;
2746 return (tmp + (Value & (uint8_t)0x0F));
#define RTC_TAFCR_TAMPINSEL
FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG)
Checks whether the specified RTC flag is set or not.
void RTC_BypassShadowCmd(FunctionalState NewState)
Enables or Disables the Bypass Shadow feature.
#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 IS_RTC_CLEAR_IT(IT)
void RTC_TimeStampPinSelection(uint32_t RTC_TimeStampPin)
Selects the RTC TimeStamp Pin.
#define IS_RTC_SYNCH_PREDIV(PREDIV)
#define IS_RTC_CALIB_VALUE(VALUE)
#define IS_RTC_GET_FLAG(FLAG)
#define IS_RTC_SHIFT_SUBFS(FS)
ITStatus RTC_GetITStatus(uint32_t RTC_IT)
Checks whether the specified RTC interrupt has occurred or not.
#define IS_RTC_TAMPER(TAMPER)
void RTC_TamperCmd(uint32_t RTC_Tamper, FunctionalState NewState)
Enables or Disables the Tamper detection.
#define IS_RTC_DATE(DATE)
#define RTC_TAFCR_TAMPPRCH
#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_YEAR(YEAR)
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.
uint32_t RTC_GetSubSecond(void)
Gets the RTC current Calendar Sub seconds value.
#define IS_RTC_TAMPER_PIN(PIN)
uint32_t RTC_AlarmDateWeekDaySel
RTC Init structures definition.
#define RTC_TAFCR_TSINSEL
void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef *RTC_DateStruct)
Get the RTC current date.
#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 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)
ErrorStatus RTC_WakeUpCmd(FunctionalState NewState)
Enables or Disables the RTC WakeUp timer.
void RTC_SetWakeUpCounter(uint32_t RTC_WakeUpCounter)
Configures the RTC Wakeup counter.
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_FUNCTIONAL_STATE(STATE)
#define IS_RTC_CLEAR_FLAG(FLAG)
static volatile uint8_t * status
#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.
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.
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...
void RTC_TamperPullUpCmd(FunctionalState NewState)
Enables or Disables the Precharge of Tamper pin.
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.*.
RTC Date structure definition.
#define RTC_TAFCR_TAMPFLT
#define IS_RTC_HOUR24(HOUR)
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 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.
uint32_t RTC_AsynchPrediv
#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's pending flags.
#define IS_RTC_TIMESTAMP_EDGE(EDGE)
#define IS_RTC_SECONDS(SECONDS)
#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 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
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
#define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION)
#define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE)
#define IS_RTC_TAMPER_FILTER(FILTER)
#define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY)
#define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL)
RTC Time structure definition.
#define IS_RTC_SHIFT_ADD1S(SEL)
#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.
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
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_TAFCR_ALARMOUTTYPE
ErrorStatus RTC_Init(RTC_InitTypeDef *RTC_InitStruct)
Initializes the RTC registers according to the specified parameters in RTC_InitStruct.
#define IS_RTC_MONTH(MONTH)
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's interrupt pending bits.
void RTC_TamperTriggerConfig(uint32_t RTC_Tamper, uint32_t RTC_TamperTrigger)
Configures the select Tamper pin edge.
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
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 IS_RTC_DAYLIGHT_SAVING(SAVE)
RTC Alarm structure definition.
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 IS_RTC_HOUR12(HOUR)
#define RTC_AlarmMask_None
#define IS_RTC_WAKEUP_CLOCK(CLOCK)
ErrorStatus RTC_SmoothCalibConfig(uint32_t RTC_SmoothCalibPeriod, uint32_t RTC_SmoothCalibPlusPulses, uint32_t RTC_SmouthCalibMinusPulsesValue)
Configures the Smooth Calibration Settings.