1 /**
2   ******************************************************************************
3   * @file    stm32wb0x_ll_rtc.h
4   * @author  MCD Application Team
5   * @brief   Header file of RTC LL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2024 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32WB0x_LL_RTC_H
21 #define STM32WB0x_LL_RTC_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32wb0x.h"
29 
30 /** @addtogroup STM32WB0x_LL_Driver
31   * @{
32   */
33 
34 #if defined(RTC)
35 
36 /** @defgroup RTC_LL RTC
37   * @{
38   */
39 
40 /* Private types -------------------------------------------------------------*/
41 /* Private variables ---------------------------------------------------------*/
42 /* Private constants ---------------------------------------------------------*/
43 /** @defgroup RTC_LL_Private_Constants RTC Private Constants
44   * @{
45   */
46 /* Masks Definition */
47 #define RTC_INIT_MASK                 0xFFFFFFFFU
48 #define RTC_RSF_MASK                  ((uint32_t)~(RTC_ISR_INIT | RTC_ISR_RSF))
49 
50 /* Write protection defines */
51 #define RTC_WRITE_PROTECTION_DISABLE  ((uint8_t)0xFFU)
52 #define RTC_WRITE_PROTECTION_ENABLE_1 ((uint8_t)0xCAU)
53 #define RTC_WRITE_PROTECTION_ENABLE_2 ((uint8_t)0x53U)
54 
55 /* Defines used to combine date & time */
56 #define RTC_OFFSET_WEEKDAY            24U
57 #define RTC_OFFSET_DAY                16U
58 #define RTC_OFFSET_MONTH              8U
59 #define RTC_OFFSET_HOUR               16U
60 #define RTC_OFFSET_MINUTE             8U
61 
62 /**
63   * @}
64   */
65 
66 /* Private macros ------------------------------------------------------------*/
67 #if defined(USE_FULL_LL_DRIVER)
68 /** @defgroup RTC_LL_Private_Macros RTC Private Macros
69   * @{
70   */
71 /**
72   * @}
73   */
74 #endif /*USE_FULL_LL_DRIVER*/
75 
76 /* Exported types ------------------------------------------------------------*/
77 #if defined(USE_FULL_LL_DRIVER)
78 /** @defgroup RTC_LL_ES_INIT RTC Exported Init structure
79   * @{
80   */
81 
82 /**
83   * @brief  RTC Init structures definition
84   */
85 typedef struct
86 {
87   uint32_t HourFormat;   /*!< Specifies the RTC Hours Format.
88                               This parameter can be a value of @ref RTC_LL_EC_HOURFORMAT
89 
90                               This feature can be modified afterwards using unitary function
91                               @ref LL_RTC_SetHourFormat(). */
92 
93   uint32_t AsynchPrescaler; /*!< Specifies the RTC Asynchronous Predivider value.
94                               This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F
95 
96                               This feature can be modified afterwards using unitary function
97                               @ref LL_RTC_SetAsynchPrescaler(). */
98 
99   uint32_t SynchPrescaler;  /*!< Specifies the RTC Synchronous Predivider value.
100                               This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF
101 
102                               This feature can be modified afterwards using unitary function
103                               @ref LL_RTC_SetSynchPrescaler(). */
104 } LL_RTC_InitTypeDef;
105 
106 /**
107   * @brief  RTC Time structure definition
108   */
109 typedef struct
110 {
111   uint32_t TimeFormat; /*!< Specifies the RTC AM/PM Time.
112                             This parameter can be a value of @ref RTC_LL_EC_TIME_FORMAT
113 
114                             This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetFormat(). */
115 
116   uint8_t Hours;       /*!< Specifies the RTC Time Hours.
117                             This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the @ref LL_RTC_TIME_FORMAT_PM is selected.
118                             This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the @ref LL_RTC_TIME_FORMAT_AM_OR_24 is selected.
119 
120                             This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetHour(). */
121 
122   uint8_t Minutes;     /*!< Specifies the RTC Time Minutes.
123                             This parameter must be a number between Min_Data = 0 and Max_Data = 59
124 
125                             This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetMinute(). */
126 
127   uint8_t Seconds;     /*!< Specifies the RTC Time Seconds.
128                             This parameter must be a number between Min_Data = 0 and Max_Data = 59
129 
130                             This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetSecond(). */
131 } LL_RTC_TimeTypeDef;
132 
133 /**
134   * @brief  RTC Date structure definition
135   */
136 typedef struct
137 {
138   uint8_t WeekDay;  /*!< Specifies the RTC Date WeekDay.
139                          This parameter can be a value of @ref RTC_LL_EC_WEEKDAY
140 
141                          This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetWeekDay(). */
142 
143   uint8_t Month;    /*!< Specifies the RTC Date Month.
144                          This parameter can be a value of @ref RTC_LL_EC_MONTH
145 
146                          This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetMonth(). */
147 
148   uint8_t Day;      /*!< Specifies the RTC Date Day.
149                          This parameter must be a number between Min_Data = 1 and Max_Data = 31
150 
151                          This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetDay(). */
152 
153   uint8_t Year;     /*!< Specifies the RTC Date Year.
154                          This parameter must be a number between Min_Data = 0 and Max_Data = 99
155 
156                          This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetYear(). */
157 } LL_RTC_DateTypeDef;
158 
159 /**
160   * @brief  RTC Alarm structure definition
161   */
162 typedef struct
163 {
164   LL_RTC_TimeTypeDef AlarmTime;  /*!< Specifies the RTC Alarm Time members. */
165 
166   uint32_t AlarmMask;            /*!< Specifies the RTC Alarm Masks.
167                                       This parameter can be a value of @ref RTC_LL_EC_ALMA_MASK for ALARM A.
168 
169                                       This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetMask().
170                                  */
171 
172   uint32_t AlarmDateWeekDaySel;  /*!< Specifies the RTC Alarm is on day or WeekDay.
173                                       This parameter can be a value of @ref RTC_LL_EC_ALMA_WEEKDAY_SELECTION for ALARM A.
174 
175                                       This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_EnableWeekday() or @ref LL_RTC_ALMA_DisableWeekday().
176                                  */
177 
178   uint8_t AlarmDateWeekDay;      /*!< Specifies the RTC Alarm Day/WeekDay.
179                                       If AlarmDateWeekDaySel set to day, this parameter  must be a number between Min_Data = 1 and Max_Data = 31.
180 
181                                       This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetDay().
182 
183                                       If AlarmDateWeekDaySel set to Weekday, this parameter can be a value of @ref RTC_LL_EC_WEEKDAY.
184 
185                                       This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetWeekDay().
186                                  */
187 } LL_RTC_AlarmTypeDef;
188 
189 /**
190   * @}
191   */
192 #endif /* USE_FULL_LL_DRIVER */
193 
194 /* Exported constants --------------------------------------------------------*/
195 /** @defgroup RTC_LL_Exported_Constants RTC Exported Constants
196   * @{
197   */
198 
199 #if defined(USE_FULL_LL_DRIVER)
200 /** @defgroup RTC_LL_EC_FORMAT FORMAT
201   * @{
202   */
203 #define LL_RTC_FORMAT_BIN                  0x00000000U /*!< Binary data format */
204 #define LL_RTC_FORMAT_BCD                  0x00000001U /*!< BCD data format */
205 /**
206   * @}
207   */
208 
209 /** @defgroup RTC_LL_EC_ALMA_WEEKDAY_SELECTION RTC Alarm A Date WeekDay
210   * @{
211   */
212 #define LL_RTC_ALMA_DATEWEEKDAYSEL_DATE    0x00000000U             /*!< Alarm A Date is selected */
213 #define LL_RTC_ALMA_DATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL        /*!< Alarm A WeekDay is selected */
214 /**
215   * @}
216   */
217 
218 #endif /* USE_FULL_LL_DRIVER */
219 
220 /** @defgroup RTC_LL_EC_GET_FLAG Get Flags Defines
221   * @brief    Flags defines which can be used with LL_RTC_ReadReg function
222   * @{
223   */
224 #define LL_RTC_ISR_RECALPF                 RTC_ISR_RECALPF
225 #define LL_RTC_ISR_TSOVF                   RTC_ISR_TSOVF
226 #define LL_RTC_ISR_TSF                     RTC_ISR_TSF
227 #define LL_RTC_ISR_WUTF                    RTC_ISR_WUTF
228 #define LL_RTC_ISR_ALRAF                   RTC_ISR_ALRAF
229 #define LL_RTC_ISR_INITF                   RTC_ISR_INITF
230 #define LL_RTC_ISR_RSF                     RTC_ISR_RSF
231 #define LL_RTC_ISR_INITS                   RTC_ISR_INITS
232 #define LL_RTC_ISR_SHPF                    RTC_ISR_SHPF
233 #define LL_RTC_ISR_WUTWF                   RTC_ISR_WUTWF
234 #define LL_RTC_ISR_ALRAWF                  RTC_ISR_ALRAWF
235 /**
236   * @}
237   */
238 
239 /** @defgroup RTC_LL_EC_IT IT Defines
240   * @brief    IT defines which can be used with LL_RTC_ReadReg and  LL_RTC_WriteReg functions
241   * @{
242   */
243 #define LL_RTC_CR_TSIE                     RTC_CR_TSIE
244 #define LL_RTC_CR_WUTIE                    RTC_CR_WUTIE
245 #define LL_RTC_CR_ALRAIE                   RTC_CR_ALRAIE
246 #define LL_RTC__TAMPIE               RTC__TAMPIE
247 /**
248   * @}
249   */
250 
251 /** @defgroup RTC_LL_EC_WEEKDAY  WEEK DAY
252   * @{
253   */
254 #define LL_RTC_WEEKDAY_MONDAY              ((uint8_t)0x01U) /*!< Monday    */
255 #define LL_RTC_WEEKDAY_TUESDAY             ((uint8_t)0x02U) /*!< Tuesday   */
256 #define LL_RTC_WEEKDAY_WEDNESDAY           ((uint8_t)0x03U) /*!< Wednesday */
257 #define LL_RTC_WEEKDAY_THURSDAY            ((uint8_t)0x04U) /*!< Thrusday  */
258 #define LL_RTC_WEEKDAY_FRIDAY              ((uint8_t)0x05U) /*!< Friday    */
259 #define LL_RTC_WEEKDAY_SATURDAY            ((uint8_t)0x06U) /*!< Saturday  */
260 #define LL_RTC_WEEKDAY_SUNDAY              ((uint8_t)0x07U) /*!< Sunday    */
261 /**
262   * @}
263   */
264 
265 /** @defgroup RTC_LL_EC_MONTH  MONTH
266   * @{
267   */
268 #define LL_RTC_MONTH_JANUARY               ((uint8_t)0x01U)  /*!< January   */
269 #define LL_RTC_MONTH_FEBRUARY              ((uint8_t)0x02U)  /*!< February  */
270 #define LL_RTC_MONTH_MARCH                 ((uint8_t)0x03U)  /*!< March     */
271 #define LL_RTC_MONTH_APRIL                 ((uint8_t)0x04U)  /*!< April     */
272 #define LL_RTC_MONTH_MAY                   ((uint8_t)0x05U)  /*!< May       */
273 #define LL_RTC_MONTH_JUNE                  ((uint8_t)0x06U)  /*!< June      */
274 #define LL_RTC_MONTH_JULY                  ((uint8_t)0x07U)  /*!< July      */
275 #define LL_RTC_MONTH_AUGUST                ((uint8_t)0x08U)  /*!< August    */
276 #define LL_RTC_MONTH_SEPTEMBER             ((uint8_t)0x09U)  /*!< September */
277 #define LL_RTC_MONTH_OCTOBER               ((uint8_t)0x10U)  /*!< October   */
278 #define LL_RTC_MONTH_NOVEMBER              ((uint8_t)0x11U)  /*!< November  */
279 #define LL_RTC_MONTH_DECEMBER              ((uint8_t)0x12U)  /*!< December  */
280 /**
281   * @}
282   */
283 
284 /** @defgroup RTC_LL_EC_HOURFORMAT  HOUR FORMAT
285   * @{
286   */
287 #define LL_RTC_HOURFORMAT_24HOUR           0x00000000U           /*!< 24 hour/day format */
288 #define LL_RTC_HOURFORMAT_AMPM             RTC_CR_FMT            /*!< AM/PM hour format */
289 /**
290   * @}
291   */
292 
293 /** @defgroup RTC_LL_EC_ALARMOUT  ALARM OUTPUT
294   * @{
295   */
296 #define LL_RTC_ALARMOUT_DISABLE            0x00000000U             /*!< Output disabled */
297 #define LL_RTC_ALARMOUT_ALMA               RTC_CR_OSEL_0           /*!< Alarm A output enabled */
298 #define LL_RTC_ALARMOUT_ALMB               RTC_CR_OSEL_1           /*!< Alarm B output enabled */
299 #define LL_RTC_ALARMOUT_WAKEUP             RTC_CR_OSEL             /*!< Wakeup output enabled */
300 /**
301   * @}
302   */
303 
304 /** @defgroup RTC_LL_EC_ALARM_OUTPUTTYPE  ALARM OUTPUT TYPE
305   * @{
306   */
307 #define LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN  0x00000000U                          /*!< RTC_ALARM, when mapped on PC13, is open-drain output */
308 #define LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL   RTC__ALARMOUTTYPE /*!< RTC_ALARM, when mapped on PC13, is push-pull output */
309 /**
310   * @}
311   */
312 
313 /** @defgroup RTC_LL_EC_OUTPUTPOLARITY_PIN  OUTPUT POLARITY PIN
314   * @{
315   */
316 #define LL_RTC_OUTPUTPOLARITY_PIN_HIGH     0x00000000U           /*!< Pin is high when ALRAF/ALRBF/WUTF is asserted (depending on OSEL)*/
317 #define LL_RTC_OUTPUTPOLARITY_PIN_LOW      RTC_CR_POL            /*!< Pin is low when ALRAF/ALRBF/WUTF is asserted (depending on OSEL) */
318 /**
319   * @}
320   */
321 
322 /** @defgroup RTC_LL_EC_TIME_FORMAT TIME FORMAT
323   * @{
324   */
325 #define LL_RTC_TIME_FORMAT_AM_OR_24        0x00000000U           /*!< AM or 24-hour format */
326 #define LL_RTC_TIME_FORMAT_PM              RTC_TR_PM             /*!< PM */
327 /**
328   * @}
329   */
330 
331 /** @defgroup RTC_LL_EC_SHIFT_SECOND  SHIFT SECOND
332   * @{
333   */
334 #define LL_RTC_SHIFT_SECOND_DELAY          0x00000000U           /* Delay (seconds) = SUBFS / (PREDIV_S + 1) */
335 #define LL_RTC_SHIFT_SECOND_ADVANCE        RTC_SHIFTR_ADD1S      /* Advance (seconds) = (1 - (SUBFS / (PREDIV_S + 1))) */
336 /**
337   * @}
338   */
339 
340 /** @defgroup RTC_LL_EC_ALMA_MASK  ALARMA MASK
341   * @{
342   */
343 #define LL_RTC_ALMA_MASK_NONE              0x00000000U             /*!< No masks applied on Alarm A*/
344 #define LL_RTC_ALMA_MASK_DATEWEEKDAY       RTC_ALRMAR_MSK4         /*!< Date/day do not care in Alarm A comparison */
345 #define LL_RTC_ALMA_MASK_HOURS             RTC_ALRMAR_MSK3         /*!< Hours do not care in Alarm A comparison */
346 #define LL_RTC_ALMA_MASK_MINUTES           RTC_ALRMAR_MSK2         /*!< Minutes do not care in Alarm A comparison */
347 #define LL_RTC_ALMA_MASK_SECONDS           RTC_ALRMAR_MSK1         /*!< Seconds do not care in Alarm A comparison */
348 #define LL_RTC_ALMA_MASK_ALL               (RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1) /*!< Masks all */
349 /**
350   * @}
351   */
352 
353 /** @defgroup RTC_LL_EC_ALMA_TIME_FORMAT  ALARMA TIME FORMAT
354   * @{
355   */
356 #define LL_RTC_ALMA_TIME_FORMAT_AM         0x00000000U           /*!< AM or 24-hour format */
357 #define LL_RTC_ALMA_TIME_FORMAT_PM         RTC_ALRMAR_PM         /*!< PM */
358 /**
359   * @}
360   */
361 
362 /** @defgroup RTC_LL_EC_WAKEUPCLOCK_DIV  WAKEUP CLOCK DIV
363   * @{
364   */
365 #define LL_RTC_WAKEUPCLOCK_DIV_16          0x00000000U                           /*!< RTC/16 clock is selected */
366 #define LL_RTC_WAKEUPCLOCK_DIV_8           (RTC_CR_WUCKSEL_0)                    /*!< RTC/8 clock is selected */
367 #define LL_RTC_WAKEUPCLOCK_DIV_4           (RTC_CR_WUCKSEL_1)                    /*!< RTC/4 clock is selected */
368 #define LL_RTC_WAKEUPCLOCK_DIV_2           (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_0) /*!< RTC/2 clock is selected */
369 #define LL_RTC_WAKEUPCLOCK_CKSPRE          (RTC_CR_WUCKSEL_2)                    /*!< ck_spre (usually 1 Hz) clock is selected */
370 #define LL_RTC_WAKEUPCLOCK_CKSPRE_WUT      (RTC_CR_WUCKSEL_2 | RTC_CR_WUCKSEL_1) /*!< ck_spre (usually 1 Hz) clock is selected and 2exp16 is added to the WUT counter value*/
371 /**
372   * @}
373   */
374 
375 /** @defgroup RTC_LL_EC_BKP  BACKUP
376   * @{
377   */
378 #define LL_RTC_BKP_DR0                     0x00000000U
379 #define LL_RTC_BKP_DR1                     0x00000001U
380 /**
381   * @}
382   */
383 
384 /** @defgroup RTC_LL_EC_CALIB_OUTPUT  Calibration output
385   * @{
386   */
387 #define LL_RTC_CALIB_OUTPUT_NONE           0x00000000U                 /*!< Calibration output disabled */
388 #define LL_RTC_CALIB_OUTPUT_1HZ            (RTC_CR_COE | RTC_CR_COSEL) /*!< Calibration output is 1 Hz */
389 #define LL_RTC_CALIB_OUTPUT_512HZ          (RTC_CR_COE)                /*!< Calibration output is 512 Hz */
390 /**
391   * @}
392   */
393 
394 /** @defgroup RTC_LL_EC_CALIB_INSERTPULSE  Calibration pulse insertion
395   * @{
396   */
397 #define LL_RTC_CALIB_INSERTPULSE_NONE      0x00000000U           /*!< No RTCCLK pulses are added */
398 #define LL_RTC_CALIB_INSERTPULSE_SET       RTC_CALR_CALP         /*!< One RTCCLK pulse is effectively inserted every 2exp11 pulses (frequency increased by 488.5 ppm) */
399 /**
400   * @}
401   */
402 
403 /** @defgroup RTC_LL_EC_CALIB_PERIOD  Calibration period
404   * @{
405   */
406 #define LL_RTC_CALIB_PERIOD_32SEC          0x00000000U           /*!< Use a 32-second calibration cycle period */
407 #define LL_RTC_CALIB_PERIOD_16SEC          RTC_CALR_CALW16       /*!< Use a 16-second calibration cycle period */
408 #define LL_RTC_CALIB_PERIOD_8SEC           RTC_CALR_CALW8        /*!< Use a 8-second calibration cycle period */
409 /**
410   * @}
411   */
412 
413 /**
414   * @}
415   */
416 
417 /* Exported macro ------------------------------------------------------------*/
418 /** @defgroup RTC_LL_Exported_Macros RTC Exported Macros
419   * @{
420   */
421 
422 /** @defgroup RTC_LL_EM_WRITE_READ Common Write and read registers Macros
423   * @{
424   */
425 
426 /**
427   * @brief  Write a value in RTC register
428   * @param  __INSTANCE__ RTC Instance
429   * @param  __REG__ Register to be written
430   * @param  __VALUE__ Value to be written in the register
431   * @retval None
432   */
433 #define LL_RTC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
434 
435 /**
436   * @brief  Read a value in RTC register
437   * @param  __INSTANCE__ RTC Instance
438   * @param  __REG__ Register to be read
439   * @retval Register value
440   */
441 #define LL_RTC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
442 /**
443   * @}
444   */
445 
446 /** @defgroup RTC_LL_EM_Convert Convert helper Macros
447   * @{
448   */
449 
450 /**
451   * @brief  Helper macro to convert a value from 2 digit decimal format to BCD format
452   * @param  __VALUE__ Byte to be converted
453   * @retval Converted byte
454   */
455 #define __LL_RTC_CONVERT_BIN2BCD(__VALUE__) (uint8_t)((((__VALUE__) / 10U) << 4U) | ((__VALUE__) % 10U))
456 
457 /**
458   * @brief  Helper macro to convert a value from BCD format to 2 digit decimal format
459   * @param  __VALUE__ BCD value to be converted
460   * @retval Converted byte
461   */
462 #define __LL_RTC_CONVERT_BCD2BIN(__VALUE__) (uint8_t)(((uint8_t)((__VALUE__) & (uint8_t)0xF0U) >> (uint8_t)0x4U) * 10U + ((__VALUE__) & (uint8_t)0x0FU))
463 
464 /**
465   * @}
466   */
467 
468 /** @defgroup RTC_LL_EM_Date Date helper Macros
469   * @{
470   */
471 
472 /**
473   * @brief  Helper macro to retrieve weekday.
474   * @param  __RTC_DATE__ Date returned by @ref  LL_RTC_DATE_Get function.
475   * @retval Returned value can be one of the following values:
476   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
477   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
478   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
479   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
480   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
481   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
482   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
483   */
484 #define __LL_RTC_GET_WEEKDAY(__RTC_DATE__) (((__RTC_DATE__) >> RTC_OFFSET_WEEKDAY) & 0x000000FFU)
485 
486 /**
487   * @brief  Helper macro to retrieve Year in BCD format
488   * @param  __RTC_DATE__ Value returned by @ref  LL_RTC_DATE_Get
489   * @retval Year in BCD format (0x00 . . . 0x99)
490   */
491 #define __LL_RTC_GET_YEAR(__RTC_DATE__) ((__RTC_DATE__) & 0x000000FFU)
492 
493 /**
494   * @brief  Helper macro to retrieve Month in BCD format
495   * @param  __RTC_DATE__ Value returned by @ref  LL_RTC_DATE_Get
496   * @retval Returned value can be one of the following values:
497   *         @arg @ref LL_RTC_MONTH_JANUARY
498   *         @arg @ref LL_RTC_MONTH_FEBRUARY
499   *         @arg @ref LL_RTC_MONTH_MARCH
500   *         @arg @ref LL_RTC_MONTH_APRIL
501   *         @arg @ref LL_RTC_MONTH_MAY
502   *         @arg @ref LL_RTC_MONTH_JUNE
503   *         @arg @ref LL_RTC_MONTH_JULY
504   *         @arg @ref LL_RTC_MONTH_AUGUST
505   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
506   *         @arg @ref LL_RTC_MONTH_OCTOBER
507   *         @arg @ref LL_RTC_MONTH_NOVEMBER
508   *         @arg @ref LL_RTC_MONTH_DECEMBER
509   */
510 #define __LL_RTC_GET_MONTH(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_MONTH) & 0x000000FFU)
511 
512 /**
513   * @brief  Helper macro to retrieve Day in BCD format
514   * @param  __RTC_DATE__ Value returned by @ref  LL_RTC_DATE_Get
515   * @retval Day in BCD format (0x01 . . . 0x31)
516   */
517 #define __LL_RTC_GET_DAY(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_DAY) & 0x000000FFU)
518 
519 /**
520   * @}
521   */
522 
523 /** @defgroup RTC_LL_EM_Time Time helper Macros
524   * @{
525   */
526 
527 /**
528   * @brief  Helper macro to retrieve hour in BCD format
529   * @param  __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
530   * @retval Hours in BCD format (0x01. . .0x12 or between Min_Data=0x00 and Max_Data=0x23)
531   */
532 #define __LL_RTC_GET_HOUR(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_HOUR) & 0x000000FFU)
533 
534 /**
535   * @brief  Helper macro to retrieve minute in BCD format
536   * @param  __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
537   * @retval Minutes in BCD format (0x00. . .0x59)
538   */
539 #define __LL_RTC_GET_MINUTE(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_MINUTE) & 0x000000FFU)
540 
541 /**
542   * @brief  Helper macro to retrieve second in BCD format
543   * @param  __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
544   * @retval Seconds in  format (0x00. . .0x59)
545   */
546 #define __LL_RTC_GET_SECOND(__RTC_TIME__) ((__RTC_TIME__) & 0x000000FFU)
547 
548 /**
549   * @}
550   */
551 
552 /**
553   * @}
554   */
555 
556 /* Exported functions --------------------------------------------------------*/
557 /** @defgroup RTC_LL_Exported_Functions RTC Exported Functions
558   * @{
559   */
560 
561 /** @defgroup RTC_LL_EF_Configuration Configuration
562   * @{
563   */
564 
565 /**
566   * @brief  Set Hours format (24 hour/day or AM/PM hour format)
567   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
568   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
569   * @rmtoll CR           FMT           LL_RTC_SetHourFormat
570   * @param  RTCx RTC Instance
571   * @param  HourFormat This parameter can be one of the following values:
572   *         @arg @ref LL_RTC_HOURFORMAT_24HOUR
573   *         @arg @ref LL_RTC_HOURFORMAT_AMPM
574   * @retval None
575   */
LL_RTC_SetHourFormat(RTC_TypeDef * RTCx,uint32_t HourFormat)576 __STATIC_INLINE void LL_RTC_SetHourFormat(RTC_TypeDef *RTCx, uint32_t HourFormat)
577 {
578   MODIFY_REG(RTCx->CR, RTC_CR_FMT, HourFormat);
579 }
580 
581 /**
582   * @brief  Get Hours format (24 hour/day or AM/PM hour format)
583   * @rmtoll CR           FMT           LL_RTC_GetHourFormat
584   * @param  RTCx RTC Instance
585   * @retval Returned value can be one of the following values:
586   *         @arg @ref LL_RTC_HOURFORMAT_24HOUR
587   *         @arg @ref LL_RTC_HOURFORMAT_AMPM
588   */
LL_RTC_GetHourFormat(RTC_TypeDef * RTCx)589 __STATIC_INLINE uint32_t LL_RTC_GetHourFormat(RTC_TypeDef *RTCx)
590 {
591   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_FMT));
592 }
593 
594 /**
595   * @brief  Select the flag to be routed to RTC_ALARM output
596   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
597   * @rmtoll CR           OSEL          LL_RTC_SetAlarmOutEvent
598   * @param  RTCx RTC Instance
599   * @param  AlarmOutput This parameter can be one of the following values:
600   *         @arg @ref LL_RTC_ALARMOUT_DISABLE
601   *         @arg @ref LL_RTC_ALARMOUT_ALMA
602   *         @arg @ref LL_RTC_ALARMOUT_ALMB
603   *         @arg @ref LL_RTC_ALARMOUT_WAKEUP
604   * @retval None
605   */
LL_RTC_SetAlarmOutEvent(RTC_TypeDef * RTCx,uint32_t AlarmOutput)606 __STATIC_INLINE void LL_RTC_SetAlarmOutEvent(RTC_TypeDef *RTCx, uint32_t AlarmOutput)
607 {
608   MODIFY_REG(RTCx->CR, RTC_CR_OSEL, AlarmOutput);
609 }
610 
611 /**
612   * @brief  Get the flag to be routed to RTC_ALARM output
613   * @rmtoll CR           OSEL          LL_RTC_GetAlarmOutEvent
614   * @param  RTCx RTC Instance
615   * @retval Returned value can be one of the following values:
616   *         @arg @ref LL_RTC_ALARMOUT_DISABLE
617   *         @arg @ref LL_RTC_ALARMOUT_ALMA
618   *         @arg @ref LL_RTC_ALARMOUT_ALMB
619   *         @arg @ref LL_RTC_ALARMOUT_WAKEUP
620   */
LL_RTC_GetAlarmOutEvent(RTC_TypeDef * RTCx)621 __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutEvent(RTC_TypeDef *RTCx)
622 {
623   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_OSEL));
624 }
625 
626 /**
627   * @brief  Enable initialization mode
628   * @note   Initialization mode is used to program time and date register (RTC_TR and RTC_DR)
629   *         and prescaler register (RTC_PRER).
630   *         Counters are stopped and start counting from the new value when INIT is reset.
631   * @rmtoll ISR          INIT          LL_RTC_EnableInitMode
632   * @param  RTCx RTC Instance
633   * @retval None
634   */
LL_RTC_EnableInitMode(RTC_TypeDef * RTCx)635 __STATIC_INLINE void LL_RTC_EnableInitMode(RTC_TypeDef *RTCx)
636 {
637   /* Set the Initialization mode */
638   WRITE_REG(RTCx->ISR, RTC_INIT_MASK);
639 }
640 
641 /**
642   * @brief  Disable initialization mode (Free running mode)
643   * @rmtoll ISR          INIT          LL_RTC_DisableInitMode
644   * @param  RTCx RTC Instance
645   * @retval None
646   */
LL_RTC_DisableInitMode(RTC_TypeDef * RTCx)647 __STATIC_INLINE void LL_RTC_DisableInitMode(RTC_TypeDef *RTCx)
648 {
649   /* Exit Initialization mode */
650   WRITE_REG(RTCx->ISR, (uint32_t)~RTC_ISR_INIT);
651 }
652 
653 /**
654   * @brief  Set Output polarity (pin is low when ALRAF/ALRBF/WUTF is asserted)
655   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
656   * @rmtoll CR           POL           LL_RTC_SetOutputPolarity
657   * @param  RTCx RTC Instance
658   * @param  Polarity This parameter can be one of the following values:
659   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
660   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
661   * @retval None
662   */
LL_RTC_SetOutputPolarity(RTC_TypeDef * RTCx,uint32_t Polarity)663 __STATIC_INLINE void LL_RTC_SetOutputPolarity(RTC_TypeDef *RTCx, uint32_t Polarity)
664 {
665   MODIFY_REG(RTCx->CR, RTC_CR_POL, Polarity);
666 }
667 
668 /**
669   * @brief  Get Output polarity
670   * @rmtoll CR           POL           LL_RTC_GetOutputPolarity
671   * @param  RTCx RTC Instance
672   * @retval Returned value can be one of the following values:
673   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
674   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
675   */
LL_RTC_GetOutputPolarity(RTC_TypeDef * RTCx)676 __STATIC_INLINE uint32_t LL_RTC_GetOutputPolarity(RTC_TypeDef *RTCx)
677 {
678   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_POL));
679 }
680 
681 /**
682   * @brief  Enable Bypass the shadow registers
683   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
684   * @rmtoll CR           BYPSHAD       LL_RTC_EnableShadowRegBypass
685   * @param  RTCx RTC Instance
686   * @retval None
687   */
LL_RTC_EnableShadowRegBypass(RTC_TypeDef * RTCx)688 __STATIC_INLINE void LL_RTC_EnableShadowRegBypass(RTC_TypeDef *RTCx)
689 {
690   SET_BIT(RTCx->CR, RTC_CR_BYPSHAD);
691 }
692 
693 /**
694   * @brief  Disable Bypass the shadow registers
695   * @rmtoll CR           BYPSHAD       LL_RTC_DisableShadowRegBypass
696   * @param  RTCx RTC Instance
697   * @retval None
698   */
LL_RTC_DisableShadowRegBypass(RTC_TypeDef * RTCx)699 __STATIC_INLINE void LL_RTC_DisableShadowRegBypass(RTC_TypeDef *RTCx)
700 {
701   CLEAR_BIT(RTCx->CR, RTC_CR_BYPSHAD);
702 }
703 
704 /**
705   * @brief  Check if Shadow registers bypass is enabled or not.
706   * @rmtoll CR           BYPSHAD       LL_RTC_IsShadowRegBypassEnabled
707   * @param  RTCx RTC Instance
708   * @retval State of bit (1 or 0).
709   */
LL_RTC_IsShadowRegBypassEnabled(RTC_TypeDef * RTCx)710 __STATIC_INLINE uint32_t LL_RTC_IsShadowRegBypassEnabled(RTC_TypeDef *RTCx)
711 {
712   return ((READ_BIT(RTCx->CR, RTC_CR_BYPSHAD) == (RTC_CR_BYPSHAD)) ? 1UL : 0UL);
713 }
714 
715 /**
716   * @brief  Set Asynchronous prescaler factor
717   * @rmtoll PRER         PREDIV_A      LL_RTC_SetAsynchPrescaler
718   * @param  RTCx RTC Instance
719   * @param  AsynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7F
720   * @retval None
721   */
LL_RTC_SetAsynchPrescaler(RTC_TypeDef * RTCx,uint32_t AsynchPrescaler)722 __STATIC_INLINE void LL_RTC_SetAsynchPrescaler(RTC_TypeDef *RTCx, uint32_t AsynchPrescaler)
723 {
724   MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_A, AsynchPrescaler << RTC_PRER_PREDIV_A_Pos);
725 }
726 
727 /**
728   * @brief  Set Synchronous prescaler factor
729   * @rmtoll PRER         PREDIV_S      LL_RTC_SetSynchPrescaler
730   * @param  RTCx RTC Instance
731   * @param  SynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7FFF
732   * @retval None
733   */
LL_RTC_SetSynchPrescaler(RTC_TypeDef * RTCx,uint32_t SynchPrescaler)734 __STATIC_INLINE void LL_RTC_SetSynchPrescaler(RTC_TypeDef *RTCx, uint32_t SynchPrescaler)
735 {
736   MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_S, SynchPrescaler);
737 }
738 
739 /**
740   * @brief  Get Asynchronous prescaler factor
741   * @rmtoll PRER         PREDIV_A      LL_RTC_GetAsynchPrescaler
742   * @param  RTCx RTC Instance
743   * @retval Value between Min_Data = 0 and Max_Data = 0x7F
744   */
LL_RTC_GetAsynchPrescaler(RTC_TypeDef * RTCx)745 __STATIC_INLINE uint32_t LL_RTC_GetAsynchPrescaler(RTC_TypeDef *RTCx)
746 {
747   return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_A) >> RTC_PRER_PREDIV_A_Pos);
748 }
749 
750 /**
751   * @brief  Get Synchronous prescaler factor
752   * @rmtoll PRER         PREDIV_S      LL_RTC_GetSynchPrescaler
753   * @param  RTCx RTC Instance
754   * @retval Value between Min_Data = 0 and Max_Data = 0x7FFF
755   */
LL_RTC_GetSynchPrescaler(RTC_TypeDef * RTCx)756 __STATIC_INLINE uint32_t LL_RTC_GetSynchPrescaler(RTC_TypeDef *RTCx)
757 {
758   return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_S));
759 }
760 
761 /**
762   * @brief  Enable the write protection for RTC registers.
763   * @rmtoll WPR          KEY           LL_RTC_EnableWriteProtection
764   * @param  RTCx RTC Instance
765   * @retval None
766   */
LL_RTC_EnableWriteProtection(RTC_TypeDef * RTCx)767 __STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx)
768 {
769   WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_DISABLE);
770 }
771 
772 /**
773   * @brief  Disable the write protection for RTC registers.
774   * @rmtoll WPR          KEY           LL_RTC_DisableWriteProtection
775   * @param  RTCx RTC Instance
776   * @retval None
777   */
LL_RTC_DisableWriteProtection(RTC_TypeDef * RTCx)778 __STATIC_INLINE void LL_RTC_DisableWriteProtection(RTC_TypeDef *RTCx)
779 {
780   WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_1);
781   WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_2);
782 }
783 
784 /**
785   * @}
786   */
787 
788 /** @defgroup RTC_LL_EF_Time Time
789   * @{
790   */
791 
792 /**
793   * @brief  Set time format (AM/24-hour or PM notation)
794   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
795   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
796   * @rmtoll TR           PM            LL_RTC_TIME_SetFormat
797   * @param  RTCx RTC Instance
798   * @param  TimeFormat This parameter can be one of the following values:
799   *         @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
800   *         @arg @ref LL_RTC_TIME_FORMAT_PM
801   * @retval None
802   */
LL_RTC_TIME_SetFormat(RTC_TypeDef * RTCx,uint32_t TimeFormat)803 __STATIC_INLINE void LL_RTC_TIME_SetFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
804 {
805   MODIFY_REG(RTCx->TR, RTC_TR_PM, TimeFormat);
806 }
807 
808 /**
809   * @brief  Get time format (AM or PM notation)
810   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
811   *       before reading this bit
812   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
813   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
814   * @rmtoll TR           PM            LL_RTC_TIME_GetFormat
815   * @param  RTCx RTC Instance
816   * @retval Returned value can be one of the following values:
817   *         @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
818   *         @arg @ref LL_RTC_TIME_FORMAT_PM
819   */
LL_RTC_TIME_GetFormat(RTC_TypeDef * RTCx)820 __STATIC_INLINE uint32_t LL_RTC_TIME_GetFormat(RTC_TypeDef *RTCx)
821 {
822   return (uint32_t)(READ_BIT(RTCx->TR, RTC_TR_PM));
823 }
824 
825 /**
826   * @brief  Set Hours in BCD format
827   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
828   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
829   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert hour from binary to BCD format
830   * @rmtoll TR           HT            LL_RTC_TIME_SetHour\n
831   *         TR           HU            LL_RTC_TIME_SetHour
832   * @param  RTCx RTC Instance
833   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
834   * @retval None
835   */
LL_RTC_TIME_SetHour(RTC_TypeDef * RTCx,uint32_t Hours)836 __STATIC_INLINE void LL_RTC_TIME_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
837 {
838   MODIFY_REG(RTCx->TR, (RTC_TR_HT | RTC_TR_HU),
839              (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)));
840 }
841 
842 /**
843   * @brief  Get Hours in BCD format
844   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
845   *       before reading this bit
846   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
847   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
848   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert hour from BCD to
849   *       Binary format
850   * @rmtoll TR           HT            LL_RTC_TIME_GetHour\n
851   *         TR           HU            LL_RTC_TIME_GetHour
852   * @param  RTCx RTC Instance
853   * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
854   */
LL_RTC_TIME_GetHour(RTC_TypeDef * RTCx)855 __STATIC_INLINE uint32_t LL_RTC_TIME_GetHour(RTC_TypeDef *RTCx)
856 {
857   return (uint32_t)((READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU))) >> RTC_TR_HU_Pos);
858 }
859 
860 /**
861   * @brief  Set Minutes in BCD format
862   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
863   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
864   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
865   * @rmtoll TR           MNT           LL_RTC_TIME_SetMinute\n
866   *         TR           MNU           LL_RTC_TIME_SetMinute
867   * @param  RTCx RTC Instance
868   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
869   * @retval None
870   */
LL_RTC_TIME_SetMinute(RTC_TypeDef * RTCx,uint32_t Minutes)871 __STATIC_INLINE void LL_RTC_TIME_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
872 {
873   MODIFY_REG(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU),
874              (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)));
875 }
876 
877 /**
878   * @brief  Get Minutes in BCD format
879   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
880   *       before reading this bit
881   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
882   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
883   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert minute from BCD
884   *       to Binary format
885   * @rmtoll TR           MNT           LL_RTC_TIME_GetMinute\n
886   *         TR           MNU           LL_RTC_TIME_GetMinute
887   * @param  RTCx RTC Instance
888   * @retval Value between Min_Data=0x00 and Max_Data=0x59
889   */
LL_RTC_TIME_GetMinute(RTC_TypeDef * RTCx)890 __STATIC_INLINE uint32_t LL_RTC_TIME_GetMinute(RTC_TypeDef *RTCx)
891 {
892   return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU)) >> RTC_TR_MNU_Pos);
893 }
894 
895 /**
896   * @brief  Set Seconds in BCD format
897   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
898   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
899   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
900   * @rmtoll TR           ST            LL_RTC_TIME_SetSecond\n
901   *         TR           SU            LL_RTC_TIME_SetSecond
902   * @param  RTCx RTC Instance
903   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
904   * @retval None
905   */
LL_RTC_TIME_SetSecond(RTC_TypeDef * RTCx,uint32_t Seconds)906 __STATIC_INLINE void LL_RTC_TIME_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
907 {
908   MODIFY_REG(RTCx->TR, (RTC_TR_ST | RTC_TR_SU),
909              (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos)));
910 }
911 
912 /**
913   * @brief  Get Seconds in BCD format
914   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
915   *       before reading this bit
916   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
917   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
918   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD
919   *       to Binary format
920   * @rmtoll TR           ST            LL_RTC_TIME_GetSecond\n
921   *         TR           SU            LL_RTC_TIME_GetSecond
922   * @param  RTCx RTC Instance
923   * @retval Value between Min_Data=0x00 and Max_Data=0x59
924   */
LL_RTC_TIME_GetSecond(RTC_TypeDef * RTCx)925 __STATIC_INLINE uint32_t LL_RTC_TIME_GetSecond(RTC_TypeDef *RTCx)
926 {
927   return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_ST | RTC_TR_SU)) >> RTC_TR_SU_Pos);
928 }
929 
930 /**
931   * @brief  Set time (hour, minute and second) in BCD format
932   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
933   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
934   * @note TimeFormat and Hours should follow the same format
935   * @rmtoll TR           PM            LL_RTC_TIME_Config\n
936   *         TR           HT            LL_RTC_TIME_Config\n
937   *         TR           HU            LL_RTC_TIME_Config\n
938   *         TR           MNT           LL_RTC_TIME_Config\n
939   *         TR           MNU           LL_RTC_TIME_Config\n
940   *         TR           ST            LL_RTC_TIME_Config\n
941   *         TR           SU            LL_RTC_TIME_Config
942   * @param  RTCx RTC Instance
943   * @param  Format12_24 This parameter can be one of the following values:
944   *         @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
945   *         @arg @ref LL_RTC_TIME_FORMAT_PM
946   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
947   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
948   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
949   * @retval None
950   */
LL_RTC_TIME_Config(RTC_TypeDef * RTCx,uint32_t Format12_24,uint32_t Hours,uint32_t Minutes,uint32_t Seconds)951 __STATIC_INLINE void LL_RTC_TIME_Config(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
952 {
953   uint32_t temp;
954 
955   temp = Format12_24                                                                            | \
956          (((Hours   & 0xF0U) << (RTC_TR_HT_Pos  - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos))    | \
957          (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)) | \
958          (((Seconds & 0xF0U) << (RTC_TR_ST_Pos  - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos));
959   MODIFY_REG(RTCx->TR, (RTC_TR_PM | RTC_TR_HT | RTC_TR_HU | RTC_TR_MNT | RTC_TR_MNU | RTC_TR_ST | RTC_TR_SU), temp);
960 }
961 
962 /**
963   * @brief  Get time (hour, minute and second) in BCD format
964   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
965   *       before reading this bit
966   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
967   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
968   * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
969   *       are available to get independently each parameter.
970   * @rmtoll TR           HT            LL_RTC_TIME_Get\n
971   *         TR           HU            LL_RTC_TIME_Get\n
972   *         TR           MNT           LL_RTC_TIME_Get\n
973   *         TR           MNU           LL_RTC_TIME_Get\n
974   *         TR           ST            LL_RTC_TIME_Get\n
975   *         TR           SU            LL_RTC_TIME_Get
976   * @param  RTCx RTC Instance
977   * @retval Combination of hours, minutes and seconds (Format: 0x00HHMMSS).
978   */
LL_RTC_TIME_Get(RTC_TypeDef * RTCx)979 __STATIC_INLINE uint32_t LL_RTC_TIME_Get(RTC_TypeDef *RTCx)
980 {
981   return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU | RTC_TR_MNT | RTC_TR_MNU | RTC_TR_ST | RTC_TR_SU)));
982 }
983 
984 /**
985   * @brief  Memorize whether the daylight saving time change has been performed
986   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
987   * @rmtoll CR           BKP           LL_RTC_TIME_EnableDayLightStore
988   * @param  RTCx RTC Instance
989   * @retval None
990   */
LL_RTC_TIME_EnableDayLightStore(RTC_TypeDef * RTCx)991 __STATIC_INLINE void LL_RTC_TIME_EnableDayLightStore(RTC_TypeDef *RTCx)
992 {
993   SET_BIT(RTCx->CR, RTC_CR_BKP);
994 }
995 
996 /**
997   * @brief  Disable memorization whether the daylight saving time change has been performed.
998   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
999   * @rmtoll CR           BKP           LL_RTC_TIME_DisableDayLightStore
1000   * @param  RTCx RTC Instance
1001   * @retval None
1002   */
LL_RTC_TIME_DisableDayLightStore(RTC_TypeDef * RTCx)1003 __STATIC_INLINE void LL_RTC_TIME_DisableDayLightStore(RTC_TypeDef *RTCx)
1004 {
1005   CLEAR_BIT(RTCx->CR, RTC_CR_BKP);
1006 }
1007 
1008 /**
1009   * @brief  Check if RTC Day Light Saving stored operation has been enabled or not
1010   * @rmtoll CR           BKP           LL_RTC_TIME_IsDayLightStoreEnabled
1011   * @param  RTCx RTC Instance
1012   * @retval State of bit (1 or 0).
1013   */
LL_RTC_TIME_IsDayLightStoreEnabled(RTC_TypeDef * RTCx)1014 __STATIC_INLINE uint32_t LL_RTC_TIME_IsDayLightStoreEnabled(RTC_TypeDef *RTCx)
1015 {
1016   return ((READ_BIT(RTCx->CR, RTC_CR_BKP) == (RTC_CR_BKP)) ? 1UL : 0UL);
1017 }
1018 
1019 /**
1020   * @brief  Subtract 1 hour (winter time change)
1021   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1022   * @rmtoll CR           SUB1H         LL_RTC_TIME_DecHour
1023   * @param  RTCx RTC Instance
1024   * @retval None
1025   */
LL_RTC_TIME_DecHour(RTC_TypeDef * RTCx)1026 __STATIC_INLINE void LL_RTC_TIME_DecHour(RTC_TypeDef *RTCx)
1027 {
1028   SET_BIT(RTCx->CR, RTC_CR_SUB1H);
1029 }
1030 
1031 /**
1032   * @brief  Add 1 hour (summer time change)
1033   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1034   * @rmtoll CR           ADD1H         LL_RTC_TIME_IncHour
1035   * @param  RTCx RTC Instance
1036   * @retval None
1037   */
LL_RTC_TIME_IncHour(RTC_TypeDef * RTCx)1038 __STATIC_INLINE void LL_RTC_TIME_IncHour(RTC_TypeDef *RTCx)
1039 {
1040   SET_BIT(RTCx->CR, RTC_CR_ADD1H);
1041 }
1042 
1043 /**
1044   * @brief  Get subseconds value in the synchronous prescaler counter.
1045   * @note  You can use both SubSeconds value and SecondFraction (PREDIV_S through
1046   *        LL_RTC_GetSynchPrescaler function) terms returned to convert Calendar
1047   *        SubSeconds value in second fraction ratio with time unit following
1048   *        generic formula:
1049   *          ==> Seconds fraction ratio * time_unit =
1050   *                 [(SecondFraction-SubSeconds)/(SecondFraction+1)] * time_unit
1051   *        This conversion can be performed only if no shift operation is pending
1052   *        (ie. SHFP=0) when PREDIV_S >= SS.
1053   * @rmtoll SSR          SS            LL_RTC_TIME_GetSubSecond
1054   * @param  RTCx RTC Instance
1055   * @retval Subseconds value (number between 0 and 65535)
1056   */
LL_RTC_TIME_GetSubSecond(RTC_TypeDef * RTCx)1057 __STATIC_INLINE uint32_t LL_RTC_TIME_GetSubSecond(RTC_TypeDef *RTCx)
1058 {
1059   return (uint32_t)(READ_BIT(RTCx->SSR, RTC_SSR_SS));
1060 }
1061 
1062 /**
1063   * @brief  Synchronize to a remote clock with a high degree of precision.
1064   * @note   This operation effectively subtracts from (delays) or advance the clock of a fraction of a second.
1065   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1066   * @note   When REFCKON is set, firmware must not write to Shift control register.
1067   * @rmtoll SHIFTR       ADD1S         LL_RTC_TIME_Synchronize\n
1068   *         SHIFTR       SUBFS         LL_RTC_TIME_Synchronize
1069   * @param  RTCx RTC Instance
1070   * @param  ShiftSecond This parameter can be one of the following values:
1071   *         @arg @ref LL_RTC_SHIFT_SECOND_DELAY
1072   *         @arg @ref LL_RTC_SHIFT_SECOND_ADVANCE
1073   * @param  Fraction Number of Seconds Fractions (any value from 0 to 0x7FFF)
1074   * @retval None
1075   */
LL_RTC_TIME_Synchronize(RTC_TypeDef * RTCx,uint32_t ShiftSecond,uint32_t Fraction)1076 __STATIC_INLINE void LL_RTC_TIME_Synchronize(RTC_TypeDef *RTCx, uint32_t ShiftSecond, uint32_t Fraction)
1077 {
1078   WRITE_REG(RTCx->SHIFTR, ShiftSecond | Fraction);
1079 }
1080 
1081 /**
1082   * @}
1083   */
1084 
1085 /** @defgroup RTC_LL_EF_Date Date
1086   * @{
1087   */
1088 
1089 /**
1090   * @brief  Set Year in BCD format
1091   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Year from binary to BCD format
1092   * @rmtoll DR           YT            LL_RTC_DATE_SetYear\n
1093   *         DR           YU            LL_RTC_DATE_SetYear
1094   * @param  RTCx RTC Instance
1095   * @param  Year Value between Min_Data=0x00 and Max_Data=0x99
1096   * @retval None
1097   */
LL_RTC_DATE_SetYear(RTC_TypeDef * RTCx,uint32_t Year)1098 __STATIC_INLINE void LL_RTC_DATE_SetYear(RTC_TypeDef *RTCx, uint32_t Year)
1099 {
1100   MODIFY_REG(RTCx->DR, (RTC_DR_YT | RTC_DR_YU),
1101              (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos)));
1102 }
1103 
1104 /**
1105   * @brief  Get Year in BCD format
1106   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
1107   *       before reading this bit
1108   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Year from BCD to Binary format
1109   * @rmtoll DR           YT            LL_RTC_DATE_GetYear\n
1110   *         DR           YU            LL_RTC_DATE_GetYear
1111   * @param  RTCx RTC Instance
1112   * @retval Value between Min_Data=0x00 and Max_Data=0x99
1113   */
LL_RTC_DATE_GetYear(RTC_TypeDef * RTCx)1114 __STATIC_INLINE uint32_t LL_RTC_DATE_GetYear(RTC_TypeDef *RTCx)
1115 {
1116   return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_YT | RTC_DR_YU))) >> RTC_DR_YU_Pos);
1117 }
1118 
1119 /**
1120   * @brief  Set Week day
1121   * @rmtoll DR           WDU           LL_RTC_DATE_SetWeekDay
1122   * @param  RTCx RTC Instance
1123   * @param  WeekDay This parameter can be one of the following values:
1124   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
1125   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
1126   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1127   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
1128   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
1129   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
1130   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
1131   * @retval None
1132   */
LL_RTC_DATE_SetWeekDay(RTC_TypeDef * RTCx,uint32_t WeekDay)1133 __STATIC_INLINE void LL_RTC_DATE_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
1134 {
1135   MODIFY_REG(RTCx->DR, RTC_DR_WDU, WeekDay << RTC_DR_WDU_Pos);
1136 }
1137 
1138 /**
1139   * @brief  Get Week day
1140   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
1141   *       before reading this bit
1142   * @rmtoll DR           WDU           LL_RTC_DATE_GetWeekDay
1143   * @param  RTCx RTC Instance
1144   * @retval Returned value can be one of the following values:
1145   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
1146   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
1147   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1148   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
1149   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
1150   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
1151   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
1152   */
LL_RTC_DATE_GetWeekDay(RTC_TypeDef * RTCx)1153 __STATIC_INLINE uint32_t LL_RTC_DATE_GetWeekDay(RTC_TypeDef *RTCx)
1154 {
1155   return (uint32_t)(READ_BIT(RTCx->DR, RTC_DR_WDU) >> RTC_DR_WDU_Pos);
1156 }
1157 
1158 /**
1159   * @brief  Set Month in BCD format
1160   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Month from binary to BCD format
1161   * @rmtoll DR           MT            LL_RTC_DATE_SetMonth\n
1162   *         DR           MU            LL_RTC_DATE_SetMonth
1163   * @param  RTCx RTC Instance
1164   * @param  Month This parameter can be one of the following values:
1165   *         @arg @ref LL_RTC_MONTH_JANUARY
1166   *         @arg @ref LL_RTC_MONTH_FEBRUARY
1167   *         @arg @ref LL_RTC_MONTH_MARCH
1168   *         @arg @ref LL_RTC_MONTH_APRIL
1169   *         @arg @ref LL_RTC_MONTH_MAY
1170   *         @arg @ref LL_RTC_MONTH_JUNE
1171   *         @arg @ref LL_RTC_MONTH_JULY
1172   *         @arg @ref LL_RTC_MONTH_AUGUST
1173   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
1174   *         @arg @ref LL_RTC_MONTH_OCTOBER
1175   *         @arg @ref LL_RTC_MONTH_NOVEMBER
1176   *         @arg @ref LL_RTC_MONTH_DECEMBER
1177   * @retval None
1178   */
LL_RTC_DATE_SetMonth(RTC_TypeDef * RTCx,uint32_t Month)1179 __STATIC_INLINE void LL_RTC_DATE_SetMonth(RTC_TypeDef *RTCx, uint32_t Month)
1180 {
1181   MODIFY_REG(RTCx->DR, (RTC_DR_MT | RTC_DR_MU),
1182              (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)));
1183 }
1184 
1185 /**
1186   * @brief  Get Month in BCD format
1187   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
1188   *       before reading this bit
1189   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
1190   * @rmtoll DR           MT            LL_RTC_DATE_GetMonth\n
1191   *         DR           MU            LL_RTC_DATE_GetMonth
1192   * @param  RTCx RTC Instance
1193   * @retval Returned value can be one of the following values:
1194   *         @arg @ref LL_RTC_MONTH_JANUARY
1195   *         @arg @ref LL_RTC_MONTH_FEBRUARY
1196   *         @arg @ref LL_RTC_MONTH_MARCH
1197   *         @arg @ref LL_RTC_MONTH_APRIL
1198   *         @arg @ref LL_RTC_MONTH_MAY
1199   *         @arg @ref LL_RTC_MONTH_JUNE
1200   *         @arg @ref LL_RTC_MONTH_JULY
1201   *         @arg @ref LL_RTC_MONTH_AUGUST
1202   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
1203   *         @arg @ref LL_RTC_MONTH_OCTOBER
1204   *         @arg @ref LL_RTC_MONTH_NOVEMBER
1205   *         @arg @ref LL_RTC_MONTH_DECEMBER
1206   */
LL_RTC_DATE_GetMonth(RTC_TypeDef * RTCx)1207 __STATIC_INLINE uint32_t LL_RTC_DATE_GetMonth(RTC_TypeDef *RTCx)
1208 {
1209   return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_MT | RTC_DR_MU))) >> RTC_DR_MU_Pos);
1210 }
1211 
1212 /**
1213   * @brief  Set Day in BCD format
1214   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
1215   * @rmtoll DR           DT            LL_RTC_DATE_SetDay\n
1216   *         DR           DU            LL_RTC_DATE_SetDay
1217   * @param  RTCx RTC Instance
1218   * @param  Day Value between Min_Data=0x01 and Max_Data=0x31
1219   * @retval None
1220   */
LL_RTC_DATE_SetDay(RTC_TypeDef * RTCx,uint32_t Day)1221 __STATIC_INLINE void LL_RTC_DATE_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
1222 {
1223   MODIFY_REG(RTCx->DR, (RTC_DR_DT | RTC_DR_DU),
1224              (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos)));
1225 }
1226 
1227 /**
1228   * @brief  Get Day in BCD format
1229   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
1230   *       before reading this bit
1231   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
1232   * @rmtoll DR           DT            LL_RTC_DATE_GetDay\n
1233   *         DR           DU            LL_RTC_DATE_GetDay
1234   * @param  RTCx RTC Instance
1235   * @retval Value between Min_Data=0x01 and Max_Data=0x31
1236   */
LL_RTC_DATE_GetDay(RTC_TypeDef * RTCx)1237 __STATIC_INLINE uint32_t LL_RTC_DATE_GetDay(RTC_TypeDef *RTCx)
1238 {
1239   return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_DT | RTC_DR_DU))) >> RTC_DR_DU_Pos);
1240 }
1241 
1242 /**
1243   * @brief  Set date (WeekDay, Day, Month and Year) in BCD format
1244   * @rmtoll DR           WDU           LL_RTC_DATE_Config\n
1245   *         DR           MT            LL_RTC_DATE_Config\n
1246   *         DR           MU            LL_RTC_DATE_Config\n
1247   *         DR           DT            LL_RTC_DATE_Config\n
1248   *         DR           DU            LL_RTC_DATE_Config\n
1249   *         DR           YT            LL_RTC_DATE_Config\n
1250   *         DR           YU            LL_RTC_DATE_Config
1251   * @param  RTCx RTC Instance
1252   * @param  WeekDay This parameter can be one of the following values:
1253   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
1254   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
1255   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1256   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
1257   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
1258   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
1259   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
1260   * @param  Day Value between Min_Data=0x01 and Max_Data=0x31
1261   * @param  Month This parameter can be one of the following values:
1262   *         @arg @ref LL_RTC_MONTH_JANUARY
1263   *         @arg @ref LL_RTC_MONTH_FEBRUARY
1264   *         @arg @ref LL_RTC_MONTH_MARCH
1265   *         @arg @ref LL_RTC_MONTH_APRIL
1266   *         @arg @ref LL_RTC_MONTH_MAY
1267   *         @arg @ref LL_RTC_MONTH_JUNE
1268   *         @arg @ref LL_RTC_MONTH_JULY
1269   *         @arg @ref LL_RTC_MONTH_AUGUST
1270   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
1271   *         @arg @ref LL_RTC_MONTH_OCTOBER
1272   *         @arg @ref LL_RTC_MONTH_NOVEMBER
1273   *         @arg @ref LL_RTC_MONTH_DECEMBER
1274   * @param  Year Value between Min_Data=0x00 and Max_Data=0x99
1275   * @retval None
1276   */
LL_RTC_DATE_Config(RTC_TypeDef * RTCx,uint32_t WeekDay,uint32_t Day,uint32_t Month,uint32_t Year)1277 __STATIC_INLINE void LL_RTC_DATE_Config(RTC_TypeDef *RTCx, uint32_t WeekDay, uint32_t Day, uint32_t Month, uint32_t Year)
1278 {
1279   uint32_t temp;
1280 
1281   temp = (  WeekDay                                                    << RTC_DR_WDU_Pos) | \
1282          (((Year  & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year  & 0x0FU) << RTC_DR_YU_Pos)) | \
1283          (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)) | \
1284          (((Day   & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day   & 0x0FU) << RTC_DR_DU_Pos));
1285 
1286   MODIFY_REG(RTCx->DR, (RTC_DR_WDU | RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | RTC_DR_DU | RTC_DR_YT | RTC_DR_YU), temp);
1287 }
1288 
1289 /**
1290   * @brief  Get date (WeekDay, Day, Month and Year) in BCD format
1291   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
1292   *       before reading this bit
1293   * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_YEAR, __LL_RTC_GET_MONTH,
1294   * and __LL_RTC_GET_DAY are available to get independently each parameter.
1295   * @rmtoll DR           WDU           LL_RTC_DATE_Get\n
1296   *         DR           MT            LL_RTC_DATE_Get\n
1297   *         DR           MU            LL_RTC_DATE_Get\n
1298   *         DR           DT            LL_RTC_DATE_Get\n
1299   *         DR           DU            LL_RTC_DATE_Get\n
1300   *         DR           YT            LL_RTC_DATE_Get\n
1301   *         DR           YU            LL_RTC_DATE_Get
1302   * @param  RTCx RTC Instance
1303   * @retval Combination of WeekDay, Day, Month and Year (Format: 0xWWDDMMYY).
1304   */
LL_RTC_DATE_Get(RTC_TypeDef * RTCx)1305 __STATIC_INLINE uint32_t LL_RTC_DATE_Get(RTC_TypeDef *RTCx)
1306 {
1307   uint32_t temp;
1308 
1309   temp = READ_BIT(RTCx->DR, (RTC_DR_WDU | RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | RTC_DR_DU | RTC_DR_YT | RTC_DR_YU));
1310 
1311   return (uint32_t)((((temp &              RTC_DR_WDU) >> RTC_DR_WDU_Pos) << RTC_OFFSET_WEEKDAY) | \
1312                     (((temp & (RTC_DR_DT | RTC_DR_DU)) >> RTC_DR_DU_Pos)  << RTC_OFFSET_DAY)     | \
1313                     (((temp & (RTC_DR_MT | RTC_DR_MU)) >> RTC_DR_MU_Pos)  << RTC_OFFSET_MONTH)   | \
1314                      ((temp & (RTC_DR_YT | RTC_DR_YU)) >> RTC_DR_YU_Pos));
1315 }
1316 
1317 /**
1318   * @}
1319   */
1320 
1321 /** @defgroup RTC_LL_EF_ALARMA ALARMA
1322   * @{
1323   */
1324 
1325 /**
1326   * @brief  Enable Alarm A
1327   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1328   * @rmtoll CR           ALRAE         LL_RTC_ALMA_Enable
1329   * @param  RTCx RTC Instance
1330   * @retval None
1331   */
LL_RTC_ALMA_Enable(RTC_TypeDef * RTCx)1332 __STATIC_INLINE void LL_RTC_ALMA_Enable(RTC_TypeDef *RTCx)
1333 {
1334   SET_BIT(RTCx->CR, RTC_CR_ALRAE);
1335 }
1336 
1337 /**
1338   * @brief  Disable Alarm A
1339   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1340   * @rmtoll CR           ALRAE         LL_RTC_ALMA_Disable
1341   * @param  RTCx RTC Instance
1342   * @retval None
1343   */
LL_RTC_ALMA_Disable(RTC_TypeDef * RTCx)1344 __STATIC_INLINE void LL_RTC_ALMA_Disable(RTC_TypeDef *RTCx)
1345 {
1346   CLEAR_BIT(RTCx->CR, RTC_CR_ALRAE);
1347 }
1348 
1349 /**
1350   * @brief  Specify the Alarm A masks.
1351   * @rmtoll ALRMAR       MSK4          LL_RTC_ALMA_SetMask\n
1352   *         ALRMAR       MSK3          LL_RTC_ALMA_SetMask\n
1353   *         ALRMAR       MSK2          LL_RTC_ALMA_SetMask\n
1354   *         ALRMAR       MSK1          LL_RTC_ALMA_SetMask
1355   * @param  RTCx RTC Instance
1356   * @param  Mask This parameter can be a combination of the following values:
1357   *         @arg @ref LL_RTC_ALMA_MASK_NONE
1358   *         @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
1359   *         @arg @ref LL_RTC_ALMA_MASK_HOURS
1360   *         @arg @ref LL_RTC_ALMA_MASK_MINUTES
1361   *         @arg @ref LL_RTC_ALMA_MASK_SECONDS
1362   *         @arg @ref LL_RTC_ALMA_MASK_ALL
1363   * @retval None
1364   */
LL_RTC_ALMA_SetMask(RTC_TypeDef * RTCx,uint32_t Mask)1365 __STATIC_INLINE void LL_RTC_ALMA_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
1366 {
1367   MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1, Mask);
1368 }
1369 
1370 /**
1371   * @brief  Get the Alarm A masks.
1372   * @rmtoll ALRMAR       MSK4          LL_RTC_ALMA_GetMask\n
1373   *         ALRMAR       MSK3          LL_RTC_ALMA_GetMask\n
1374   *         ALRMAR       MSK2          LL_RTC_ALMA_GetMask\n
1375   *         ALRMAR       MSK1          LL_RTC_ALMA_GetMask
1376   * @param  RTCx RTC Instance
1377   * @retval Returned value can be can be a combination of the following values:
1378   *         @arg @ref LL_RTC_ALMA_MASK_NONE
1379   *         @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
1380   *         @arg @ref LL_RTC_ALMA_MASK_HOURS
1381   *         @arg @ref LL_RTC_ALMA_MASK_MINUTES
1382   *         @arg @ref LL_RTC_ALMA_MASK_SECONDS
1383   *         @arg @ref LL_RTC_ALMA_MASK_ALL
1384   */
LL_RTC_ALMA_GetMask(RTC_TypeDef * RTCx)1385 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMask(RTC_TypeDef *RTCx)
1386 {
1387   return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1));
1388 }
1389 
1390 /**
1391   * @brief  Enable AlarmA Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
1392   * @rmtoll ALRMAR       WDSEL         LL_RTC_ALMA_EnableWeekday
1393   * @param  RTCx RTC Instance
1394   * @retval None
1395   */
LL_RTC_ALMA_EnableWeekday(RTC_TypeDef * RTCx)1396 __STATIC_INLINE void LL_RTC_ALMA_EnableWeekday(RTC_TypeDef *RTCx)
1397 {
1398   SET_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
1399 }
1400 
1401 /**
1402   * @brief  Disable AlarmA Week day selection (DU[3:0] represents the date )
1403   * @rmtoll ALRMAR       WDSEL         LL_RTC_ALMA_DisableWeekday
1404   * @param  RTCx RTC Instance
1405   * @retval None
1406   */
LL_RTC_ALMA_DisableWeekday(RTC_TypeDef * RTCx)1407 __STATIC_INLINE void LL_RTC_ALMA_DisableWeekday(RTC_TypeDef *RTCx)
1408 {
1409   CLEAR_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
1410 }
1411 
1412 /**
1413   * @brief  Set ALARM A Day in BCD format
1414   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
1415   * @rmtoll ALRMAR       DT            LL_RTC_ALMA_SetDay\n
1416   *         ALRMAR       DU            LL_RTC_ALMA_SetDay
1417   * @param  RTCx RTC Instance
1418   * @param  Day Value between Min_Data=0x01 and Max_Data=0x31
1419   * @retval None
1420   */
LL_RTC_ALMA_SetDay(RTC_TypeDef * RTCx,uint32_t Day)1421 __STATIC_INLINE void LL_RTC_ALMA_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
1422 {
1423   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU),
1424              (((Day & 0xF0U) << (RTC_ALRMAR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMAR_DU_Pos)));
1425 }
1426 
1427 /**
1428   * @brief  Get ALARM A Day in BCD format
1429   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
1430   * @rmtoll ALRMAR       DT            LL_RTC_ALMA_GetDay\n
1431   *         ALRMAR       DU            LL_RTC_ALMA_GetDay
1432   * @param  RTCx RTC Instance
1433   * @retval Value between Min_Data=0x01 and Max_Data=0x31
1434   */
LL_RTC_ALMA_GetDay(RTC_TypeDef * RTCx)1435 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetDay(RTC_TypeDef *RTCx)
1436 {
1437   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU))) >> RTC_ALRMAR_DU_Pos);
1438 }
1439 
1440 /**
1441   * @brief  Set ALARM A Weekday
1442   * @rmtoll ALRMAR       DU            LL_RTC_ALMA_SetWeekDay
1443   * @param  RTCx RTC Instance
1444   * @param  WeekDay This parameter can be one of the following values:
1445   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
1446   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
1447   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1448   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
1449   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
1450   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
1451   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
1452   * @retval None
1453   */
LL_RTC_ALMA_SetWeekDay(RTC_TypeDef * RTCx,uint32_t WeekDay)1454 __STATIC_INLINE void LL_RTC_ALMA_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
1455 {
1456   MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_DU, WeekDay << RTC_ALRMAR_DU_Pos);
1457 }
1458 
1459 /**
1460   * @brief  Get ALARM A Weekday
1461   * @rmtoll ALRMAR       DU            LL_RTC_ALMA_GetWeekDay
1462   * @param  RTCx RTC Instance
1463   * @retval Returned value can be one of the following values:
1464   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
1465   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
1466   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1467   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
1468   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
1469   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
1470   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
1471   */
LL_RTC_ALMA_GetWeekDay(RTC_TypeDef * RTCx)1472 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetWeekDay(RTC_TypeDef *RTCx)
1473 {
1474   return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_DU) >> RTC_ALRMAR_DU_Pos);
1475 }
1476 
1477 /**
1478   * @brief  Set Alarm A time format (AM/24-hour or PM notation)
1479   * @rmtoll ALRMAR       PM            LL_RTC_ALMA_SetTimeFormat
1480   * @param  RTCx RTC Instance
1481   * @param  TimeFormat This parameter can be one of the following values:
1482   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
1483   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
1484   * @retval None
1485   */
LL_RTC_ALMA_SetTimeFormat(RTC_TypeDef * RTCx,uint32_t TimeFormat)1486 __STATIC_INLINE void LL_RTC_ALMA_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
1487 {
1488   MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_PM, TimeFormat);
1489 }
1490 
1491 /**
1492   * @brief  Get Alarm A time format (AM or PM notation)
1493   * @rmtoll ALRMAR       PM            LL_RTC_ALMA_GetTimeFormat
1494   * @param  RTCx RTC Instance
1495   * @retval Returned value can be one of the following values:
1496   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
1497   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
1498   */
LL_RTC_ALMA_GetTimeFormat(RTC_TypeDef * RTCx)1499 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTimeFormat(RTC_TypeDef *RTCx)
1500 {
1501   return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_PM));
1502 }
1503 
1504 /**
1505   * @brief  Set ALARM A Hours in BCD format
1506   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
1507   * @rmtoll ALRMAR       HT            LL_RTC_ALMA_SetHour\n
1508   *         ALRMAR       HU            LL_RTC_ALMA_SetHour
1509   * @param  RTCx RTC Instance
1510   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1511   * @retval None
1512   */
LL_RTC_ALMA_SetHour(RTC_TypeDef * RTCx,uint32_t Hours)1513 __STATIC_INLINE void LL_RTC_ALMA_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
1514 {
1515   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU),
1516              (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos)));
1517 }
1518 
1519 /**
1520   * @brief  Get ALARM A Hours in BCD format
1521   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
1522   * @rmtoll ALRMAR       HT            LL_RTC_ALMA_GetHour\n
1523   *         ALRMAR       HU            LL_RTC_ALMA_GetHour
1524   * @param  RTCx RTC Instance
1525   * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1526   */
LL_RTC_ALMA_GetHour(RTC_TypeDef * RTCx)1527 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetHour(RTC_TypeDef *RTCx)
1528 {
1529   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU))) >> RTC_ALRMAR_HU_Pos);
1530 }
1531 
1532 /**
1533   * @brief  Set ALARM A Minutes in BCD format
1534   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
1535   * @rmtoll ALRMAR       MNT           LL_RTC_ALMA_SetMinute\n
1536   *         ALRMAR       MNU           LL_RTC_ALMA_SetMinute
1537   * @param  RTCx RTC Instance
1538   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
1539   * @retval None
1540   */
LL_RTC_ALMA_SetMinute(RTC_TypeDef * RTCx,uint32_t Minutes)1541 __STATIC_INLINE void LL_RTC_ALMA_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
1542 {
1543   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU),
1544              (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)));
1545 }
1546 
1547 /**
1548   * @brief  Get ALARM A Minutes in BCD format
1549   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
1550   * @rmtoll ALRMAR       MNT           LL_RTC_ALMA_GetMinute\n
1551   *         ALRMAR       MNU           LL_RTC_ALMA_GetMinute
1552   * @param  RTCx RTC Instance
1553   * @retval Value between Min_Data=0x00 and Max_Data=0x59
1554   */
LL_RTC_ALMA_GetMinute(RTC_TypeDef * RTCx)1555 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMinute(RTC_TypeDef *RTCx)
1556 {
1557   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU))) >> RTC_ALRMAR_MNU_Pos);
1558 }
1559 
1560 /**
1561   * @brief  Set ALARM A Seconds in BCD format
1562   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
1563   * @rmtoll ALRMAR       ST            LL_RTC_ALMA_SetSecond\n
1564   *         ALRMAR       SU            LL_RTC_ALMA_SetSecond
1565   * @param  RTCx RTC Instance
1566   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
1567   * @retval None
1568   */
LL_RTC_ALMA_SetSecond(RTC_TypeDef * RTCx,uint32_t Seconds)1569 __STATIC_INLINE void LL_RTC_ALMA_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
1570 {
1571   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU),
1572              (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos)));
1573 }
1574 
1575 /**
1576   * @brief  Get ALARM A Seconds in BCD format
1577   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
1578   * @rmtoll ALRMAR       ST            LL_RTC_ALMA_GetSecond\n
1579   *         ALRMAR       SU            LL_RTC_ALMA_GetSecond
1580   * @param  RTCx RTC Instance
1581   * @retval Value between Min_Data=0x00 and Max_Data=0x59
1582   */
LL_RTC_ALMA_GetSecond(RTC_TypeDef * RTCx)1583 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSecond(RTC_TypeDef *RTCx)
1584 {
1585   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU))) >> RTC_ALRMAR_SU_Pos);
1586 }
1587 
1588 /**
1589   * @brief  Set Alarm A Time (hour, minute and second) in BCD format
1590   * @rmtoll ALRMAR       PM            LL_RTC_ALMA_ConfigTime\n
1591   *         ALRMAR       HT            LL_RTC_ALMA_ConfigTime\n
1592   *         ALRMAR       HU            LL_RTC_ALMA_ConfigTime\n
1593   *         ALRMAR       MNT           LL_RTC_ALMA_ConfigTime\n
1594   *         ALRMAR       MNU           LL_RTC_ALMA_ConfigTime\n
1595   *         ALRMAR       ST            LL_RTC_ALMA_ConfigTime\n
1596   *         ALRMAR       SU            LL_RTC_ALMA_ConfigTime
1597   * @param  RTCx RTC Instance
1598   * @param  Format12_24 This parameter can be one of the following values:
1599   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
1600   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
1601   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1602   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
1603   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
1604   * @retval None
1605   */
LL_RTC_ALMA_ConfigTime(RTC_TypeDef * RTCx,uint32_t Format12_24,uint32_t Hours,uint32_t Minutes,uint32_t Seconds)1606 __STATIC_INLINE void LL_RTC_ALMA_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
1607 {
1608   uint32_t temp;
1609 
1610   temp = Format12_24                                                                                    | \
1611          (((Hours   & 0xF0U) << (RTC_ALRMAR_HT_Pos  - 4U)) | ((Hours   & 0x0FU) << RTC_ALRMAR_HU_Pos))  | \
1612          (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)) | \
1613          (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos  - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos));
1614 
1615   MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_PM | RTC_ALRMAR_HT | RTC_ALRMAR_HU | RTC_ALRMAR_MNT | RTC_ALRMAR_MNU | RTC_ALRMAR_ST | RTC_ALRMAR_SU, temp);
1616 }
1617 
1618 /**
1619   * @brief  Get Alarm B Time (hour, minute and second) in BCD format
1620   * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
1621   * are available to get independently each parameter.
1622   * @rmtoll ALRMAR       HT            LL_RTC_ALMA_GetTime\n
1623   *         ALRMAR       HU            LL_RTC_ALMA_GetTime\n
1624   *         ALRMAR       MNT           LL_RTC_ALMA_GetTime\n
1625   *         ALRMAR       MNU           LL_RTC_ALMA_GetTime\n
1626   *         ALRMAR       ST            LL_RTC_ALMA_GetTime\n
1627   *         ALRMAR       SU            LL_RTC_ALMA_GetTime
1628   * @param  RTCx RTC Instance
1629   * @retval Combination of hours, minutes and seconds.
1630   */
LL_RTC_ALMA_GetTime(RTC_TypeDef * RTCx)1631 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTime(RTC_TypeDef *RTCx)
1632 {
1633   return (uint32_t)((LL_RTC_ALMA_GetHour(RTCx) << RTC_OFFSET_HOUR) | (LL_RTC_ALMA_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMA_GetSecond(RTCx));
1634 }
1635 
1636 /**
1637   * @brief  Mask the most-significant bits of the subseconds field starting from
1638   *         the bit specified in parameter Mask
1639   * @note This register can be written only when ALRAE is reset in RTC_CR register,
1640   *       or in initialization mode.
1641   * @rmtoll ALRMASSR     MASKSS        LL_RTC_ALMA_SetSubSecondMask
1642   * @param  RTCx RTC Instance
1643   * @param  Mask Value between Min_Data=0x00 and Max_Data=0xF
1644   * @retval None
1645   */
LL_RTC_ALMA_SetSubSecondMask(RTC_TypeDef * RTCx,uint32_t Mask)1646 __STATIC_INLINE void LL_RTC_ALMA_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
1647 {
1648   MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS, Mask << RTC_ALRMASSR_MASKSS_Pos);
1649 }
1650 
1651 /**
1652   * @brief  Get Alarm A subseconds mask
1653   * @rmtoll ALRMASSR     MASKSS        LL_RTC_ALMA_GetSubSecondMask
1654   * @param  RTCx RTC Instance
1655   * @retval Value between Min_Data=0x00 and Max_Data=0xF
1656   */
LL_RTC_ALMA_GetSubSecondMask(RTC_TypeDef * RTCx)1657 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecondMask(RTC_TypeDef *RTCx)
1658 {
1659   return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS) >> RTC_ALRMASSR_MASKSS_Pos);
1660 }
1661 
1662 /**
1663   * @brief  Set Alarm A subseconds value
1664   * @rmtoll ALRMASSR     SS            LL_RTC_ALMA_SetSubSecond
1665   * @param  RTCx RTC Instance
1666   * @param  Subsecond Value between Min_Data=0x00 and Max_Data=0x7FFF
1667   * @retval None
1668   */
LL_RTC_ALMA_SetSubSecond(RTC_TypeDef * RTCx,uint32_t Subsecond)1669 __STATIC_INLINE void LL_RTC_ALMA_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
1670 {
1671   MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_SS, Subsecond);
1672 }
1673 
1674 /**
1675   * @brief  Get Alarm A subseconds value
1676   * @rmtoll ALRMASSR     SS            LL_RTC_ALMA_GetSubSecond
1677   * @param  RTCx RTC Instance
1678   * @retval Value between Min_Data=0x00 and Max_Data=0x7FFF
1679   */
LL_RTC_ALMA_GetSubSecond(RTC_TypeDef * RTCx)1680 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecond(RTC_TypeDef *RTCx)
1681 {
1682   return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_SS));
1683 }
1684 
1685 /**
1686   * @}
1687   */
1688 
1689 /** @defgroup RTC_LL_EF_Wakeup Wakeup
1690   * @{
1691   */
1692 
1693 /**
1694   * @brief  Enable Wakeup timer
1695   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1696   * @rmtoll CR           WUTE          LL_RTC_WAKEUP_Enable
1697   * @param  RTCx RTC Instance
1698   * @retval None
1699   */
LL_RTC_WAKEUP_Enable(RTC_TypeDef * RTCx)1700 __STATIC_INLINE void LL_RTC_WAKEUP_Enable(RTC_TypeDef *RTCx)
1701 {
1702   SET_BIT(RTCx->CR, RTC_CR_WUTE);
1703 }
1704 
1705 /**
1706   * @brief  Disable Wakeup timer
1707   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1708   * @rmtoll CR           WUTE          LL_RTC_WAKEUP_Disable
1709   * @param  RTCx RTC Instance
1710   * @retval None
1711   */
LL_RTC_WAKEUP_Disable(RTC_TypeDef * RTCx)1712 __STATIC_INLINE void LL_RTC_WAKEUP_Disable(RTC_TypeDef *RTCx)
1713 {
1714   CLEAR_BIT(RTCx->CR, RTC_CR_WUTE);
1715 }
1716 
1717 /**
1718   * @brief  Check if Wakeup timer is enabled or not
1719   * @rmtoll CR           WUTE          LL_RTC_WAKEUP_IsEnabled
1720   * @param  RTCx RTC Instance
1721   * @retval State of bit (1 or 0).
1722   */
LL_RTC_WAKEUP_IsEnabled(RTC_TypeDef * RTCx)1723 __STATIC_INLINE uint32_t LL_RTC_WAKEUP_IsEnabled(RTC_TypeDef *RTCx)
1724 {
1725   return ((READ_BIT(RTCx->CR, RTC_CR_WUTE) == (RTC_CR_WUTE)) ? 1UL : 0UL);
1726 }
1727 
1728 /**
1729   * @brief  Select Wakeup clock
1730   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1731   * @note   Bit can be written only when RTC_CR WUTE bit = 0 and RTC_ISR WUTWF bit = 1
1732   * @rmtoll CR           WUCKSEL       LL_RTC_WAKEUP_SetClock
1733   * @param  RTCx RTC Instance
1734   * @param  WakeupClock This parameter can be one of the following values:
1735   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
1736   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
1737   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
1738   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
1739   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
1740   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
1741   * @retval None
1742   */
LL_RTC_WAKEUP_SetClock(RTC_TypeDef * RTCx,uint32_t WakeupClock)1743 __STATIC_INLINE void LL_RTC_WAKEUP_SetClock(RTC_TypeDef *RTCx, uint32_t WakeupClock)
1744 {
1745   MODIFY_REG(RTCx->CR, RTC_CR_WUCKSEL, WakeupClock);
1746 }
1747 
1748 /**
1749   * @brief  Get Wakeup clock
1750   * @rmtoll CR           WUCKSEL       LL_RTC_WAKEUP_GetClock
1751   * @param  RTCx RTC Instance
1752   * @retval Returned value can be one of the following values:
1753   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
1754   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
1755   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
1756   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
1757   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
1758   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
1759   */
LL_RTC_WAKEUP_GetClock(RTC_TypeDef * RTCx)1760 __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetClock(RTC_TypeDef *RTCx)
1761 {
1762   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_WUCKSEL));
1763 }
1764 
1765 /**
1766   * @brief  Set Wakeup auto-reload value
1767   * @note   Bit can be written only when WUTWF is set to 1 in RTC_ISR
1768   * @rmtoll WUTR         WUT           LL_RTC_WAKEUP_SetAutoReload
1769   * @param  RTCx RTC Instance
1770   * @param  Value Value between Min_Data=0x00 and Max_Data=0xFFFF
1771   * @retval None
1772   */
LL_RTC_WAKEUP_SetAutoReload(RTC_TypeDef * RTCx,uint32_t Value)1773 __STATIC_INLINE void LL_RTC_WAKEUP_SetAutoReload(RTC_TypeDef *RTCx, uint32_t Value)
1774 {
1775   MODIFY_REG(RTCx->WUTR, RTC_WUTR_WUT, Value);
1776 }
1777 
1778 /**
1779   * @brief  Get Wakeup auto-reload value
1780   * @rmtoll WUTR         WUT           LL_RTC_WAKEUP_GetAutoReload
1781   * @param  RTCx RTC Instance
1782   * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF
1783   */
LL_RTC_WAKEUP_GetAutoReload(RTC_TypeDef * RTCx)1784 __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetAutoReload(RTC_TypeDef *RTCx)
1785 {
1786   return (uint32_t)(READ_BIT(RTCx->WUTR, RTC_WUTR_WUT));
1787 }
1788 
1789 /**
1790   * @}
1791   */
1792 
1793 /** @defgroup RTC_LL_EF_Backup_Registers Backup_Registers
1794   * @{
1795   */
1796 
1797 /**
1798   * @brief  Writes a data in a specified RTC Backup data register.
1799   * @rmtoll BKPxR        BKP           LL_RTC_BAK_SetRegister
1800   * @param  RTCx RTC Instance
1801   * @param  BackupRegister This parameter can be one of the following values:
1802   *         @arg @ref LL_RTC_BKP_DR0
1803   *         @arg @ref LL_RTC_BKP_DR1
1804   *         @arg @ref LL_RTC_BKP_DR2
1805   *         @arg @ref LL_RTC_BKP_DR3
1806   *         @arg @ref LL_RTC_BKP_DR4
1807   * @param  Data Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
1808   * @retval None
1809   */
LL_RTC_BAK_SetRegister(RTC_TypeDef * RTCx,uint32_t BackupRegister,uint32_t Data)1810 __STATIC_INLINE void LL_RTC_BAK_SetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister, uint32_t Data)
1811 {
1812   uint32_t temp;
1813 
1814   temp = (uint32_t)(&(RTCx->BKP0R));
1815   temp += (BackupRegister * 4U);
1816 
1817   /* Write the specified register */
1818   *(__IO uint32_t *)temp = (uint32_t)Data;
1819 }
1820 
1821 /**
1822   * @brief  Reads data from the specified RTC Backup data Register.
1823   * @rmtoll BKPxR        BKP           LL_RTC_BAK_GetRegister
1824   * @param  RTCx RTC Instance
1825   * @param  BackupRegister This parameter can be one of the following values:
1826   *         @arg @ref LL_RTC_BKP_DR0
1827   *         @arg @ref LL_RTC_BKP_DR1
1828   *         @arg @ref LL_RTC_BKP_DR2
1829   *         @arg @ref LL_RTC_BKP_DR3
1830   *         @arg @ref LL_RTC_BKP_DR4
1831   * @retval Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
1832   */
LL_RTC_BAK_GetRegister(RTC_TypeDef * RTCx,uint32_t BackupRegister)1833 __STATIC_INLINE uint32_t LL_RTC_BAK_GetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister)
1834 {
1835   uint32_t temp;
1836 
1837   temp = (uint32_t)(&(RTCx->BKP0R));
1838   temp += (BackupRegister * 4U);
1839 
1840   /* Read the specified register */
1841   return (*(__IO uint32_t *)temp);
1842 }
1843 
1844 /**
1845   * @}
1846   */
1847 
1848 /** @defgroup RTC_LL_EF_Calibration Calibration
1849   * @{
1850   */
1851 
1852 /**
1853   * @brief  Set Calibration output frequency (1 Hz or 512 Hz)
1854   * @note Bits are write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1855   * @rmtoll CR           COE           LL_RTC_CAL_SetOutputFreq\n
1856   *         CR           COSEL         LL_RTC_CAL_SetOutputFreq
1857   * @param  RTCx RTC Instance
1858   * @param  Frequency This parameter can be one of the following values:
1859   *         @arg @ref LL_RTC_CALIB_OUTPUT_NONE
1860   *         @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
1861   *         @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
1862   *
1863   * @retval None
1864   */
LL_RTC_CAL_SetOutputFreq(RTC_TypeDef * RTCx,uint32_t Frequency)1865 __STATIC_INLINE void LL_RTC_CAL_SetOutputFreq(RTC_TypeDef *RTCx, uint32_t Frequency)
1866 {
1867   MODIFY_REG(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL, Frequency);
1868 }
1869 
1870 /**
1871   * @brief  Get Calibration output frequency (1 Hz or 512 Hz)
1872   * @rmtoll CR           COE           LL_RTC_CAL_GetOutputFreq\n
1873   *         CR           COSEL         LL_RTC_CAL_GetOutputFreq
1874   * @param  RTCx RTC Instance
1875   * @retval Returned value can be one of the following values:
1876   *         @arg @ref LL_RTC_CALIB_OUTPUT_NONE
1877   *         @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
1878   *         @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
1879   *
1880   */
LL_RTC_CAL_GetOutputFreq(RTC_TypeDef * RTCx)1881 __STATIC_INLINE uint32_t LL_RTC_CAL_GetOutputFreq(RTC_TypeDef *RTCx)
1882 {
1883   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL));
1884 }
1885 
1886 /**
1887   * @brief  Insert or not One RTCCLK pulse every 2exp11 pulses (frequency increased by 488.5 ppm)
1888   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1889   * @note   Bit can be written only when RECALPF is set to 0 in RTC_ISR
1890   * @rmtoll CALR         CALP          LL_RTC_CAL_SetPulse
1891   * @param  RTCx RTC Instance
1892   * @param  Pulse This parameter can be one of the following values:
1893   *         @arg @ref LL_RTC_CALIB_INSERTPULSE_NONE
1894   *         @arg @ref LL_RTC_CALIB_INSERTPULSE_SET
1895   * @retval None
1896   */
LL_RTC_CAL_SetPulse(RTC_TypeDef * RTCx,uint32_t Pulse)1897 __STATIC_INLINE void LL_RTC_CAL_SetPulse(RTC_TypeDef *RTCx, uint32_t Pulse)
1898 {
1899   MODIFY_REG(RTCx->CALR, RTC_CALR_CALP, Pulse);
1900 }
1901 
1902 /**
1903   * @brief  Check if one RTCCLK has been inserted or not every 2exp11 pulses (frequency increased by 488.5 ppm)
1904   * @rmtoll CALR         CALP          LL_RTC_CAL_IsPulseInserted
1905   * @param  RTCx RTC Instance
1906   * @retval State of bit (1 or 0).
1907   */
LL_RTC_CAL_IsPulseInserted(RTC_TypeDef * RTCx)1908 __STATIC_INLINE uint32_t LL_RTC_CAL_IsPulseInserted(RTC_TypeDef *RTCx)
1909 {
1910   return ((READ_BIT(RTCx->CALR, RTC_CALR_CALP) == (RTC_CALR_CALP)) ? 1UL : 0UL);
1911 }
1912 
1913 /**
1914   * @brief  Set smooth calibration cycle period
1915   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1916   * @note   Bit can be written only when RECALPF is set to 0 in RTC_ISR
1917   * @rmtoll CALR         CALW8         LL_RTC_CAL_SetPeriod\n
1918   *         CALR         CALW16        LL_RTC_CAL_SetPeriod
1919   * @param  RTCx RTC Instance
1920   * @param  Period This parameter can be one of the following values:
1921   *         @arg @ref LL_RTC_CALIB_PERIOD_32SEC
1922   *         @arg @ref LL_RTC_CALIB_PERIOD_16SEC
1923   *         @arg @ref LL_RTC_CALIB_PERIOD_8SEC
1924   * @retval None
1925   */
LL_RTC_CAL_SetPeriod(RTC_TypeDef * RTCx,uint32_t Period)1926 __STATIC_INLINE void LL_RTC_CAL_SetPeriod(RTC_TypeDef *RTCx, uint32_t Period)
1927 {
1928   MODIFY_REG(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16, Period);
1929 }
1930 
1931 /**
1932   * @brief  Get smooth calibration cycle period
1933   * @rmtoll CALR         CALW8         LL_RTC_CAL_GetPeriod\n
1934   *         CALR         CALW16        LL_RTC_CAL_GetPeriod
1935   * @param  RTCx RTC Instance
1936   * @retval Returned value can be one of the following values:
1937   *         @arg @ref LL_RTC_CALIB_PERIOD_32SEC
1938   *         @arg @ref LL_RTC_CALIB_PERIOD_16SEC
1939   *         @arg @ref LL_RTC_CALIB_PERIOD_8SEC
1940   */
LL_RTC_CAL_GetPeriod(RTC_TypeDef * RTCx)1941 __STATIC_INLINE uint32_t LL_RTC_CAL_GetPeriod(RTC_TypeDef *RTCx)
1942 {
1943   return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16));
1944 }
1945 
1946 /**
1947   * @brief  Set smooth Calibration minus
1948   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1949   * @note   Bit can be written only when RECALPF is set to 0 in RTC_ISR
1950   * @rmtoll CALR         CALM          LL_RTC_CAL_SetMinus
1951   * @param  RTCx RTC Instance
1952   * @param  CalibMinus Value between Min_Data=0x00 and Max_Data=0x1FF
1953   * @retval None
1954   */
LL_RTC_CAL_SetMinus(RTC_TypeDef * RTCx,uint32_t CalibMinus)1955 __STATIC_INLINE void LL_RTC_CAL_SetMinus(RTC_TypeDef *RTCx, uint32_t CalibMinus)
1956 {
1957   MODIFY_REG(RTCx->CALR, RTC_CALR_CALM, CalibMinus);
1958 }
1959 
1960 /**
1961   * @brief  Get smooth Calibration minus
1962   * @rmtoll CALR         CALM          LL_RTC_CAL_GetMinus
1963   * @param  RTCx RTC Instance
1964   * @retval Value between Min_Data=0x00 and Max_Data= 0x1FF
1965   */
LL_RTC_CAL_GetMinus(RTC_TypeDef * RTCx)1966 __STATIC_INLINE uint32_t LL_RTC_CAL_GetMinus(RTC_TypeDef *RTCx)
1967 {
1968   return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALM));
1969 }
1970 
1971 /**
1972   * @}
1973   */
1974 
1975 /** @defgroup RTC_LL_EF_FLAG_Management FLAG_Management
1976   * @{
1977   */
1978 
1979 /**
1980   * @brief  Get Recalibration pending Flag
1981   * @rmtoll ISR          RECALPF       LL_RTC_IsActiveFlag_RECALP
1982   * @param  RTCx RTC Instance
1983   * @retval State of bit (1 or 0).
1984   */
LL_RTC_IsActiveFlag_RECALP(RTC_TypeDef * RTCx)1985 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RECALP(RTC_TypeDef *RTCx)
1986 {
1987   return ((READ_BIT(RTCx->ISR, RTC_ISR_RECALPF) == (RTC_ISR_RECALPF)) ? 1UL : 0UL);
1988 }
1989 
1990 /**
1991   * @brief  Get Wakeup timer flag
1992   * @rmtoll ISR          WUTF          LL_RTC_IsActiveFlag_WUT
1993   * @param  RTCx RTC Instance
1994   * @retval State of bit (1 or 0).
1995   */
LL_RTC_IsActiveFlag_WUT(RTC_TypeDef * RTCx)1996 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUT(RTC_TypeDef *RTCx)
1997 {
1998   return ((READ_BIT(RTCx->ISR, RTC_ISR_WUTF) == (RTC_ISR_WUTF)) ? 1UL : 0UL);
1999 }
2000 
2001 /**
2002   * @brief  Get Alarm A flag
2003   * @rmtoll ISR          ALRAF         LL_RTC_IsActiveFlag_ALRA
2004   * @param  RTCx RTC Instance
2005   * @retval State of bit (1 or 0).
2006   */
LL_RTC_IsActiveFlag_ALRA(RTC_TypeDef * RTCx)2007 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRA(RTC_TypeDef *RTCx)
2008 {
2009   return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRAF) == (RTC_ISR_ALRAF)) ? 1UL : 0UL);
2010 }
2011 
2012 /**
2013   * @brief  Clear Wakeup timer flag
2014   * @rmtoll ISR          WUTF          LL_RTC_ClearFlag_WUT
2015   * @param  RTCx RTC Instance
2016   * @retval None
2017   */
LL_RTC_ClearFlag_WUT(RTC_TypeDef * RTCx)2018 __STATIC_INLINE void LL_RTC_ClearFlag_WUT(RTC_TypeDef *RTCx)
2019 {
2020   WRITE_REG(RTCx->ISR, (~((RTC_ISR_WUTF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
2021 }
2022 
2023 /**
2024   * @brief  Clear Alarm A flag
2025   * @rmtoll ISR          ALRAF         LL_RTC_ClearFlag_ALRA
2026   * @param  RTCx RTC Instance
2027   * @retval None
2028   */
LL_RTC_ClearFlag_ALRA(RTC_TypeDef * RTCx)2029 __STATIC_INLINE void LL_RTC_ClearFlag_ALRA(RTC_TypeDef *RTCx)
2030 {
2031   WRITE_REG(RTCx->ISR, (~((RTC_ISR_ALRAF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
2032 }
2033 
2034 /**
2035   * @brief  Get Initialization flag
2036   * @rmtoll ISR          INITF         LL_RTC_IsActiveFlag_INIT
2037   * @param  RTCx RTC Instance
2038   * @retval State of bit (1 or 0).
2039   */
LL_RTC_IsActiveFlag_INIT(RTC_TypeDef * RTCx)2040 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INIT(RTC_TypeDef *RTCx)
2041 {
2042   return ((READ_BIT(RTCx->ISR, RTC_ISR_INITF) == (RTC_ISR_INITF)) ? 1UL : 0UL);
2043 }
2044 
2045 /**
2046   * @brief  Get Registers synchronization flag
2047   * @rmtoll ISR          RSF           LL_RTC_IsActiveFlag_RS
2048   * @param  RTCx RTC Instance
2049   * @retval State of bit (1 or 0).
2050   */
LL_RTC_IsActiveFlag_RS(RTC_TypeDef * RTCx)2051 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(RTC_TypeDef *RTCx)
2052 {
2053   return ((READ_BIT(RTCx->ISR, RTC_ISR_RSF) == (RTC_ISR_RSF)) ? 1UL : 0UL);
2054 }
2055 
2056 /**
2057   * @brief  Clear Registers synchronization flag
2058   * @rmtoll ISR          RSF           LL_RTC_ClearFlag_RS
2059   * @param  RTCx RTC Instance
2060   * @retval None
2061   */
LL_RTC_ClearFlag_RS(RTC_TypeDef * RTCx)2062 __STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx)
2063 {
2064   WRITE_REG(RTCx->ISR, (~((RTC_ISR_RSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
2065 }
2066 
2067 /**
2068   * @brief  Get Initialization status flag
2069   * @rmtoll ISR          INITS         LL_RTC_IsActiveFlag_INITS
2070   * @param  RTCx RTC Instance
2071   * @retval State of bit (1 or 0).
2072   */
LL_RTC_IsActiveFlag_INITS(RTC_TypeDef * RTCx)2073 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INITS(RTC_TypeDef *RTCx)
2074 {
2075   return ((READ_BIT(RTCx->ISR, RTC_ISR_INITS) == (RTC_ISR_INITS)) ? 1UL : 0UL);
2076 }
2077 
2078 /**
2079   * @brief  Get Shift operation pending flag
2080   * @rmtoll ISR          SHPF          LL_RTC_IsActiveFlag_SHP
2081   * @param  RTCx RTC Instance
2082   * @retval State of bit (1 or 0).
2083   */
LL_RTC_IsActiveFlag_SHP(RTC_TypeDef * RTCx)2084 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SHP(RTC_TypeDef *RTCx)
2085 {
2086   return ((READ_BIT(RTCx->ISR, RTC_ISR_SHPF) == (RTC_ISR_SHPF)) ? 1UL : 0UL);
2087 }
2088 
2089 /**
2090   * @brief  Get Wakeup timer write flag
2091   * @rmtoll ISR          WUTWF         LL_RTC_IsActiveFlag_WUTW
2092   * @param  RTCx RTC Instance
2093   * @retval State of bit (1 or 0).
2094   */
LL_RTC_IsActiveFlag_WUTW(RTC_TypeDef * RTCx)2095 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUTW(RTC_TypeDef *RTCx)
2096 {
2097   return ((READ_BIT(RTCx->ISR, RTC_ISR_WUTWF) == (RTC_ISR_WUTWF)) ? 1UL : 0UL);
2098 }
2099 
2100 /**
2101   * @brief  Get Alarm A write flag
2102   * @rmtoll ISR          ALRAWF        LL_RTC_IsActiveFlag_ALRAW
2103   * @param  RTCx RTC Instance
2104   * @retval State of bit (1 or 0).
2105   */
LL_RTC_IsActiveFlag_ALRAW(RTC_TypeDef * RTCx)2106 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRAW(RTC_TypeDef *RTCx)
2107 {
2108   return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRAWF) == (RTC_ISR_ALRAWF)) ? 1UL : 0UL);
2109 }
2110 
2111 /**
2112   * @}
2113   */
2114 
2115 /** @defgroup RTC_LL_EF_IT_Management IT_Management
2116   * @{
2117   */
2118 
2119 /**
2120   * @brief  Enable Wakeup timer interrupt
2121   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2122   * @rmtoll CR           WUTIE         LL_RTC_EnableIT_WUT
2123   * @param  RTCx RTC Instance
2124   * @retval None
2125   */
LL_RTC_EnableIT_WUT(RTC_TypeDef * RTCx)2126 __STATIC_INLINE void LL_RTC_EnableIT_WUT(RTC_TypeDef *RTCx)
2127 {
2128   SET_BIT(RTCx->CR, RTC_CR_WUTIE);
2129 }
2130 
2131 /**
2132   * @brief  Disable Wakeup timer interrupt
2133   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2134   * @rmtoll CR           WUTIE         LL_RTC_DisableIT_WUT
2135   * @param  RTCx RTC Instance
2136   * @retval None
2137   */
LL_RTC_DisableIT_WUT(RTC_TypeDef * RTCx)2138 __STATIC_INLINE void LL_RTC_DisableIT_WUT(RTC_TypeDef *RTCx)
2139 {
2140   CLEAR_BIT(RTCx->CR, RTC_CR_WUTIE);
2141 }
2142 
2143 /**
2144   * @brief  Enable Alarm A interrupt
2145   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2146   * @rmtoll CR           ALRAIE        LL_RTC_EnableIT_ALRA
2147   * @param  RTCx RTC Instance
2148   * @retval None
2149   */
LL_RTC_EnableIT_ALRA(RTC_TypeDef * RTCx)2150 __STATIC_INLINE void LL_RTC_EnableIT_ALRA(RTC_TypeDef *RTCx)
2151 {
2152   SET_BIT(RTCx->CR, RTC_CR_ALRAIE);
2153 }
2154 
2155 /**
2156   * @brief  Disable Alarm A interrupt
2157   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2158   * @rmtoll CR           ALRAIE        LL_RTC_DisableIT_ALRA
2159   * @param  RTCx RTC Instance
2160   * @retval None
2161   */
LL_RTC_DisableIT_ALRA(RTC_TypeDef * RTCx)2162 __STATIC_INLINE void LL_RTC_DisableIT_ALRA(RTC_TypeDef *RTCx)
2163 {
2164   CLEAR_BIT(RTCx->CR, RTC_CR_ALRAIE);
2165 }
2166 
2167 /**
2168   * @brief  Check if  Wakeup timer interrupt is enabled or not
2169   * @rmtoll CR           WUTIE         LL_RTC_IsEnabledIT_WUT
2170   * @param  RTCx RTC Instance
2171   * @retval State of bit (1 or 0).
2172   */
LL_RTC_IsEnabledIT_WUT(RTC_TypeDef * RTCx)2173 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_WUT(RTC_TypeDef *RTCx)
2174 {
2175   return ((READ_BIT(RTCx->CR, RTC_CR_WUTIE) == (RTC_CR_WUTIE)) ? 1UL : 0UL);
2176 }
2177 
2178 /**
2179   * @brief  Check if  Alarm A interrupt is enabled or not
2180   * @rmtoll CR           ALRAIE        LL_RTC_IsEnabledIT_ALRA
2181   * @param  RTCx RTC Instance
2182   * @retval State of bit (1 or 0).
2183   */
LL_RTC_IsEnabledIT_ALRA(RTC_TypeDef * RTCx)2184 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRA(RTC_TypeDef *RTCx)
2185 {
2186   return ((READ_BIT(RTCx->CR, RTC_CR_ALRAIE) == (RTC_CR_ALRAIE)) ? 1UL : 0UL);
2187 }
2188 
2189 /**
2190   * @}
2191   */
2192 
2193 #if defined(USE_FULL_LL_DRIVER)
2194 /** @defgroup RTC_LL_EF_Init Initialization and de-initialization functions
2195   * @{
2196   */
2197 
2198 ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx);
2199 ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct);
2200 void        LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct);
2201 ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct);
2202 void        LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct);
2203 ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct);
2204 void        LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct);
2205 ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
2206 void        LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
2207 ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx);
2208 ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx);
2209 ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx);
2210 
2211 /**
2212   * @}
2213   */
2214 #endif /* USE_FULL_LL_DRIVER */
2215 
2216 /**
2217   * @}
2218   */
2219 
2220 /**
2221   * @}
2222   */
2223 
2224 #endif /* defined(RTC) */
2225 
2226 /**
2227   * @}
2228   */
2229 
2230 #ifdef __cplusplus
2231 }
2232 #endif
2233 
2234 #endif /* STM32WB0x_LL_RTC_H */
2235