18 #if defined(USE_FULL_LL_DRIVER)
23 #ifdef USE_FULL_ASSERT
24 #include "stm32_assert.h"
26 #define assert_param(expr) ((void)0U)
46 #define RTC_ASYNCH_PRESC_DEFAULT 0x0000007FU
47 #define RTC_SYNCH_PRESC_DEFAULT 0x000000FFU
50 #define RTC_INITMODE_TIMEOUT 1000U
51 #define RTC_SYNCHRO_TIMEOUT 1000U
61 #define IS_LL_RTC_HOURFORMAT(__VALUE__) (((__VALUE__) == LL_RTC_HOURFORMAT_24HOUR) \
62 || ((__VALUE__) == LL_RTC_HOURFORMAT_AMPM))
64 #define IS_LL_RTC_ASYNCH_PREDIV(__VALUE__) ((__VALUE__) <= 0x7FU)
66 #define IS_LL_RTC_SYNCH_PREDIV(__VALUE__) ((__VALUE__) <= 0x7FFFU)
68 #define IS_LL_RTC_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_FORMAT_BIN) \
69 || ((__VALUE__) == LL_RTC_FORMAT_BCD))
71 #define IS_LL_RTC_TIME_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_TIME_FORMAT_AM_OR_24) \
72 || ((__VALUE__) == LL_RTC_TIME_FORMAT_PM))
74 #define IS_LL_RTC_HOUR12(__HOUR__) (((__HOUR__) > 0U) && ((__HOUR__) <= 12U))
75 #define IS_LL_RTC_HOUR24(__HOUR__) ((__HOUR__) <= 23U)
76 #define IS_LL_RTC_MINUTES(__MINUTES__) ((__MINUTES__) <= 59U)
77 #define IS_LL_RTC_SECONDS(__SECONDS__) ((__SECONDS__) <= 59U)
79 #define IS_LL_RTC_WEEKDAY(__VALUE__) (((__VALUE__) == LL_RTC_WEEKDAY_MONDAY) \
80 || ((__VALUE__) == LL_RTC_WEEKDAY_TUESDAY) \
81 || ((__VALUE__) == LL_RTC_WEEKDAY_WEDNESDAY) \
82 || ((__VALUE__) == LL_RTC_WEEKDAY_THURSDAY) \
83 || ((__VALUE__) == LL_RTC_WEEKDAY_FRIDAY) \
84 || ((__VALUE__) == LL_RTC_WEEKDAY_SATURDAY) \
85 || ((__VALUE__) == LL_RTC_WEEKDAY_SUNDAY))
87 #define IS_LL_RTC_DAY(__DAY__) (((__DAY__) >= 1U) && ((__DAY__) <= 31U))
89 #define IS_LL_RTC_MONTH(__MONTH__) (((__MONTH__) >= 1U) && ((__MONTH__) <= 12U))
91 #define IS_LL_RTC_YEAR(__YEAR__) ((__YEAR__) <= 99U)
93 #define IS_LL_RTC_ALMA_MASK(__VALUE__) (((__VALUE__) == LL_RTC_ALMA_MASK_NONE) \
94 || ((__VALUE__) == LL_RTC_ALMA_MASK_DATEWEEKDAY) \
95 || ((__VALUE__) == LL_RTC_ALMA_MASK_HOURS) \
96 || ((__VALUE__) == LL_RTC_ALMA_MASK_MINUTES) \
97 || ((__VALUE__) == LL_RTC_ALMA_MASK_SECONDS) \
98 || ((__VALUE__) == LL_RTC_ALMA_MASK_ALL))
100 #define IS_LL_RTC_ALMB_MASK(__VALUE__) (((__VALUE__) == LL_RTC_ALMB_MASK_NONE) \
101 || ((__VALUE__) == LL_RTC_ALMB_MASK_DATEWEEKDAY) \
102 || ((__VALUE__) == LL_RTC_ALMB_MASK_HOURS) \
103 || ((__VALUE__) == LL_RTC_ALMB_MASK_MINUTES) \
104 || ((__VALUE__) == LL_RTC_ALMB_MASK_SECONDS) \
105 || ((__VALUE__) == LL_RTC_ALMB_MASK_ALL))
107 #define IS_LL_RTC_ALMA_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) || \
108 ((__SEL__) == LL_RTC_ALMA_DATEWEEKDAYSEL_WEEKDAY))
110 #define IS_LL_RTC_ALMB_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) || \
111 ((__SEL__) == LL_RTC_ALMB_DATEWEEKDAYSEL_WEEKDAY))
137 ErrorStatus status = ERROR;
140 assert_param(IS_RTC_ALL_INSTANCE(RTCx));
149 LL_RTC_WriteReg(RTCx, TR, 0x00000000U);
150 LL_RTC_WriteReg(RTCx, WUTR, RTC_WUTR_WUT);
151 LL_RTC_WriteReg(RTCx, DR, (RTC_DR_WDU_0 | RTC_DR_MU_0 | RTC_DR_DU_0));
154 LL_RTC_WriteReg(RTCx, CR, (LL_RTC_ReadReg(RTCx, CR) & RTC_CR_WUCKSEL));
156 LL_RTC_WriteReg(RTCx, PRER, (RTC_PRER_PREDIV_A | RTC_SYNCH_PRESC_DEFAULT));
157 LL_RTC_WriteReg(RTCx, ALRMAR, 0x00000000U);
158 LL_RTC_WriteReg(RTCx, ALRMBR, 0x00000000U);
159 LL_RTC_WriteReg(RTCx, CALR, 0x00000000U);
160 LL_RTC_WriteReg(RTCx, SHIFTR, 0x00000000U);
161 LL_RTC_WriteReg(RTCx, ALRMASSR, 0x00000000U);
162 LL_RTC_WriteReg(RTCx, ALRMBSSR, 0x00000000U);
165 LL_RTC_WriteReg(RTCx, ISR, 0x00000000U);
168 LL_RTC_WriteReg(RTCx, TAFCR, 0x00000000U);
194 ErrorStatus status = ERROR;
197 assert_param(IS_RTC_ALL_INSTANCE(RTCx));
198 assert_param(IS_LL_RTC_HOURFORMAT(RTC_InitStruct->
HourFormat));
199 assert_param(IS_LL_RTC_ASYNCH_PREDIV(RTC_InitStruct->
AsynchPrescaler));
200 assert_param(IS_LL_RTC_SYNCH_PREDIV(RTC_InitStruct->
SynchPrescaler));
234 RTC_InitStruct->
HourFormat = LL_RTC_HOURFORMAT_24HOUR;
253 ErrorStatus status = ERROR;
256 assert_param(IS_RTC_ALL_INSTANCE(RTCx));
257 assert_param(IS_LL_RTC_FORMAT(RTC_Format));
259 if (RTC_Format == LL_RTC_FORMAT_BIN)
263 assert_param(IS_LL_RTC_HOUR12(RTC_TimeStruct->
Hours));
264 assert_param(IS_LL_RTC_TIME_FORMAT(RTC_TimeStruct->
TimeFormat));
269 assert_param(IS_LL_RTC_HOUR24(RTC_TimeStruct->
Hours));
271 assert_param(IS_LL_RTC_MINUTES(RTC_TimeStruct->
Minutes));
272 assert_param(IS_LL_RTC_SECONDS(RTC_TimeStruct->
Seconds));
278 assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->
Hours)));
279 assert_param(IS_LL_RTC_TIME_FORMAT(RTC_TimeStruct->
TimeFormat));
284 assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->
Hours)));
286 assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->
Minutes)));
287 assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->
Seconds)));
297 if (RTC_Format != LL_RTC_FORMAT_BIN)
305 __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->
Minutes),
306 __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->
Seconds));
336 RTC_TimeStruct->
TimeFormat = LL_RTC_TIME_FORMAT_AM_OR_24;
337 RTC_TimeStruct->
Hours = 0U;
356 ErrorStatus status = ERROR;
359 assert_param(IS_RTC_ALL_INSTANCE(RTCx));
360 assert_param(IS_LL_RTC_FORMAT(RTC_Format));
362 if ((RTC_Format == LL_RTC_FORMAT_BIN) && ((RTC_DateStruct->
Month & 0x10U) == 0x10U))
364 RTC_DateStruct->
Month = (uint8_t)(RTC_DateStruct->
Month & (uint8_t)~(0x10U)) + 0x0AU;
366 if (RTC_Format == LL_RTC_FORMAT_BIN)
368 assert_param(IS_LL_RTC_YEAR(RTC_DateStruct->
Year));
369 assert_param(IS_LL_RTC_MONTH(RTC_DateStruct->
Month));
370 assert_param(IS_LL_RTC_DAY(RTC_DateStruct->
Day));
374 assert_param(IS_LL_RTC_YEAR(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->
Year)));
375 assert_param(IS_LL_RTC_MONTH(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->
Month)));
376 assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->
Day)));
378 assert_param(IS_LL_RTC_WEEKDAY(RTC_DateStruct->
WeekDay));
387 if (RTC_Format != LL_RTC_FORMAT_BIN)
394 __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->
Month), __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->
Year));
424 RTC_DateStruct->
WeekDay = LL_RTC_WEEKDAY_MONDAY;
425 RTC_DateStruct->
Day = 1U;
426 RTC_DateStruct->
Month = LL_RTC_MONTH_JANUARY;
427 RTC_DateStruct->
Year = 0U;
447 assert_param(IS_RTC_ALL_INSTANCE(RTCx));
448 assert_param(IS_LL_RTC_FORMAT(RTC_Format));
449 assert_param(IS_LL_RTC_ALMA_MASK(RTC_AlarmStruct->
AlarmMask));
452 if (RTC_Format == LL_RTC_FORMAT_BIN)
480 assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->
AlarmTime.
Hours)));
486 assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->
AlarmTime.
Hours)));
489 assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->
AlarmTime.
Minutes)));
490 assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->
AlarmTime.
Seconds)));
494 assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->
AlarmDateWeekDay)));
498 assert_param(IS_LL_RTC_WEEKDAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->
AlarmDateWeekDay)));
510 if (RTC_Format != LL_RTC_FORMAT_BIN)
527 if (RTC_Format != LL_RTC_FORMAT_BIN)
565 assert_param(IS_RTC_ALL_INSTANCE(RTCx));
566 assert_param(IS_LL_RTC_FORMAT(RTC_Format));
567 assert_param(IS_LL_RTC_ALMB_MASK(RTC_AlarmStruct->
AlarmMask));
570 if (RTC_Format == LL_RTC_FORMAT_BIN)
598 assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->
AlarmTime.
Hours)));
604 assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->
AlarmTime.
Hours)));
607 assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->
AlarmTime.
Minutes)));
608 assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->
AlarmTime.
Seconds)));
612 assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->
AlarmDateWeekDay)));
616 assert_param(IS_LL_RTC_WEEKDAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->
AlarmDateWeekDay)));
628 if (RTC_Format != LL_RTC_FORMAT_BIN)
645 if (RTC_Format != LL_RTC_FORMAT_BIN)
685 RTC_AlarmStruct->
AlarmMask = LL_RTC_ALMA_MASK_NONE;
707 RTC_AlarmStruct->
AlarmMask = LL_RTC_ALMB_MASK_NONE;
721 __IO uint32_t timeout = RTC_INITMODE_TIMEOUT;
722 ErrorStatus status = SUCCESS;
726 assert_param(IS_RTC_ALL_INSTANCE(RTCx));
736 while ((timeout != 0U) && (tmp != 1U))
766 assert_param(IS_RTC_ALL_INSTANCE(RTCx));
792 __IO uint32_t timeout = RTC_SYNCHRO_TIMEOUT;
793 ErrorStatus status = SUCCESS;
797 assert_param(IS_RTC_ALL_INSTANCE(RTCx));
804 while ((timeout != 0U) && (tmp != 1U))
__STATIC_INLINE uint32_t LL_SYSTICK_IsActiveCounterFlag(void)
This function checks if the Systick counter flag is active or not.
__STATIC_INLINE void LL_RTC_ALMA_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
Specify the Alarm A masks. @rmtoll ALRMAR MSK4 LL_RTC_ALMA_SetMask ALRMAR MSK3 LL_RTC_ALMA_SetMask ...
__STATIC_INLINE void LL_RTC_ALMA_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
Set ALARM A Day in BCD format.
__STATIC_INLINE void LL_RTC_ALMA_DisableWeekday(RTC_TypeDef *RTCx)
Disable AlarmA Week day selection (DU[3:0] represents the date ) @rmtoll ALRMAR WDSEL LL_RTC_ALMA_Dis...
__STATIC_INLINE void LL_RTC_ALMA_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
Set ALARM A Weekday @rmtoll ALRMAR DU LL_RTC_ALMA_SetWeekDay.
__STATIC_INLINE void LL_RTC_ALMA_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
Set Alarm A Time (hour, minute and second) in BCD format @rmtoll ALRMAR PM LL_RTC_ALMA_ConfigTime AL...
__STATIC_INLINE void LL_RTC_ALMA_EnableWeekday(RTC_TypeDef *RTCx)
Enable AlarmA Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care) @rmtoll AL...
__STATIC_INLINE void LL_RTC_ALMB_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
Set ALARM B Weekday @rmtoll ALRMBR DU LL_RTC_ALMB_SetWeekDay.
__STATIC_INLINE void LL_RTC_ALMB_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
Specify the Alarm B masks. @rmtoll ALRMBR MSK4 LL_RTC_ALMB_SetMask ALRMBR MSK3 LL_RTC_ALMB_SetMask ...
__STATIC_INLINE void LL_RTC_ALMB_DisableWeekday(RTC_TypeDef *RTCx)
Disable AlarmB Week day selection (DU[3:0] represents the date ) @rmtoll ALRMBR WDSEL LL_RTC_ALMB_Dis...
__STATIC_INLINE void LL_RTC_ALMB_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
Set ALARM B Day in BCD format.
__STATIC_INLINE void LL_RTC_ALMB_EnableWeekday(RTC_TypeDef *RTCx)
Enable AlarmB Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care) @rmtoll AL...
__STATIC_INLINE void LL_RTC_ALMB_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
Set Alarm B Time (hour, minute and second) in BCD format @rmtoll ALRMBR PM LL_RTC_ALMB_ConfigTime AL...
__STATIC_INLINE void LL_RTC_DisableInitMode(RTC_TypeDef *RTCx)
Disable initialization mode (Free running mode) @rmtoll ISR INIT LL_RTC_DisableInitMode.
__STATIC_INLINE void LL_RTC_EnableInitMode(RTC_TypeDef *RTCx)
Enable initialization mode.
__STATIC_INLINE uint32_t LL_RTC_GetHourFormat(RTC_TypeDef *RTCx)
Get Hours format (24 hour/day or AM/PM hour format) @rmtoll CR FMT LL_RTC_GetHourFormat.
__STATIC_INLINE void LL_RTC_DisableWriteProtection(RTC_TypeDef *RTCx)
Disable the write protection for RTC registers. @rmtoll WPR KEY LL_RTC_DisableWriteProtection.
__STATIC_INLINE uint32_t LL_RTC_IsShadowRegBypassEnabled(RTC_TypeDef *RTCx)
Check if Shadow registers bypass is enabled or not. @rmtoll CR BYPSHAD LL_RTC_IsShadowRegBypassEnable...
__STATIC_INLINE void LL_RTC_SetHourFormat(RTC_TypeDef *RTCx, uint32_t HourFormat)
Set Hours format (24 hour/day or AM/PM hour format)
__STATIC_INLINE void LL_RTC_SetAsynchPrescaler(RTC_TypeDef *RTCx, uint32_t AsynchPrescaler)
Set Asynchronous prescaler factor @rmtoll PRER PREDIV_A LL_RTC_SetAsynchPrescaler.
__STATIC_INLINE void LL_RTC_SetSynchPrescaler(RTC_TypeDef *RTCx, uint32_t SynchPrescaler)
Set Synchronous prescaler factor @rmtoll PRER PREDIV_S LL_RTC_SetSynchPrescaler.
__STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx)
Enable the write protection for RTC registers. @rmtoll WPR KEY LL_RTC_EnableWriteProtection.
__STATIC_INLINE void LL_RTC_DATE_Config(RTC_TypeDef *RTCx, uint32_t WeekDay, uint32_t Day, uint32_t Month, uint32_t Year)
Set date (WeekDay, Day, Month and Year) in BCD format @rmtoll DR WDU LL_RTC_DATE_Config DR MT LL_RTC...
__STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INIT(RTC_TypeDef *RTCx)
Get Initialization flag @rmtoll ISR INITF LL_RTC_IsActiveFlag_INIT.
__STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(RTC_TypeDef *RTCx)
Get Registers synchronization flag @rmtoll ISR RSF LL_RTC_IsActiveFlag_RS.
__STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx)
Clear Registers synchronization flag @rmtoll ISR RSF LL_RTC_ClearFlag_RS.
ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx)
Enters the RTC Initialization mode.
void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct)
Set each LL_RTC_InitTypeDef field to default value.
void LL_RTC_ALMB_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
Set each LL_RTC_AlarmTypeDef of ALARMA field to default value (Time = 00h:00mn:00sec / Day = 1st day ...
ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx)
Exit the RTC Initialization mode.
void LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
Set each LL_RTC_AlarmTypeDef of ALARMA field to default value (Time = 00h:00mn:00sec / Day = 1st day ...
ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx)
De-Initializes the RTC registers to their default reset values.
void LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct)
Set each LL_RTC_DateTypeDef field to default value (date = Monday, January 01 xx00)
ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct)
Set the RTC current time.
ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct)
Set the RTC current date.
ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx)
Waits until the RTC Time and Day registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock.
void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct)
Set each LL_RTC_TimeTypeDef field to default value (Time = 00h:00min:00sec).
ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
Set the RTC Alarm A.
ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct)
Initializes the RTC registers according to the specified parameters in RTC_InitStruct.
ErrorStatus LL_RTC_ALMB_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
Set the RTC Alarm B.
__STATIC_INLINE void LL_RTC_TIME_Config(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
Set time (hour, minute and second) in BCD format.
uint32_t AlarmDateWeekDaySel
LL_RTC_TimeTypeDef AlarmTime
RTC Alarm structure definition.
RTC Date structure definition.
RTC Init structures definition.
RTC Time structure definition.
Header file of CORTEX LL module.
Header file of RTC LL module.