1 /**
2   ******************************************************************************
3   * @file    stm32wlxx_ll_rtc.h
4   * @author  MCD Application Team
5   * @brief   Header file of RTC LL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2020 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 STM32WLxx_LL_RTC_H
21 #define STM32WLxx_LL_RTC_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32wlxx.h"
29 
30 /** @addtogroup STM32WLxx_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_LL_INIT_MASK              0xFFFFFFFFU
48 #define RTC_LL_RSF_MASK               0xFFFFFF5FU
49 
50 /* Write protection defines */
51 #define RTC_WRITE_PROTECTION_DISABLE  (uint8_t)0xFF
52 #define RTC_WRITE_PROTECTION_ENABLE_1 (uint8_t)0xCA
53 #define RTC_WRITE_PROTECTION_ENABLE_2 (uint8_t)0x53
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 #if !defined (UNUSED)
77 #define UNUSED(x) ((void)(x))
78 #endif
79 
80 /* Exported types ------------------------------------------------------------*/
81 #if defined(USE_FULL_LL_DRIVER)
82 /** @defgroup RTC_LL_ES_INIT RTC Exported Init structure
83   * @{
84   */
85 
86 /**
87   * @brief  RTC Init structures definition
88   */
89 typedef struct
90 {
91   uint32_t HourFormat;   /*!< Specifies the RTC Hours Format.
92                               This parameter can be a value of @ref RTC_LL_EC_HOURFORMAT
93 
94                               This feature can be modified afterwards using unitary function
95                               @ref LL_RTC_SetHourFormat(). */
96 
97   uint32_t AsynchPrescaler; /*!< Specifies the RTC Asynchronous Predivider value.
98                               This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F
99 
100                               This feature can be modified afterwards using unitary function
101                               @ref LL_RTC_SetAsynchPrescaler(). */
102 
103   uint32_t SynchPrescaler;  /*!< Specifies the RTC Synchronous Predivider value.
104                               This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF
105 
106                               This feature can be modified afterwards using unitary function
107                               @ref LL_RTC_SetSynchPrescaler(). */
108 } LL_RTC_InitTypeDef;
109 
110 /**
111   * @brief  RTC Time structure definition
112   */
113 typedef struct
114 {
115   uint32_t TimeFormat; /*!< Specifies the RTC AM/PM Time.
116                             This parameter can be a value of @ref RTC_LL_EC_TIME_FORMAT
117 
118                             This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetFormat(). */
119 
120   uint8_t Hours;       /*!< Specifies the RTC Time Hours.
121                             This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the @ref LL_RTC_TIME_FORMAT_PM is selected.
122                             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.
123 
124                             This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetHour(). */
125 
126   uint8_t Minutes;     /*!< Specifies the RTC Time Minutes.
127                             This parameter must be a number between Min_Data = 0 and Max_Data = 59
128 
129                             This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetMinute(). */
130 
131   uint8_t Seconds;     /*!< Specifies the RTC Time Seconds.
132                             This parameter must be a number between Min_Data = 0 and Max_Data = 59
133 
134                             This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetSecond(). */
135 } LL_RTC_TimeTypeDef;
136 
137 /**
138   * @brief  RTC Date structure definition
139   */
140 typedef struct
141 {
142   uint8_t WeekDay;  /*!< Specifies the RTC Date WeekDay.
143                          This parameter can be a value of @ref RTC_LL_EC_WEEKDAY
144 
145                          This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetWeekDay(). */
146 
147   uint8_t Month;    /*!< Specifies the RTC Date Month.
148                          This parameter can be a value of @ref RTC_LL_EC_MONTH
149 
150                          This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetMonth(). */
151 
152   uint8_t Day;      /*!< Specifies the RTC Date Day.
153                          This parameter must be a number between Min_Data = 1 and Max_Data = 31
154 
155                          This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetDay(). */
156 
157   uint8_t Year;     /*!< Specifies the RTC Date Year.
158                          This parameter must be a number between Min_Data = 0 and Max_Data = 99
159 
160                          This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetYear(). */
161 } LL_RTC_DateTypeDef;
162 
163 /**
164   * @brief  RTC Alarm structure definition
165   */
166 typedef struct
167 {
168   LL_RTC_TimeTypeDef AlarmTime;  /*!< Specifies the RTC Alarm Time members. */
169 
170   uint32_t AlarmMask;            /*!< Specifies the RTC Alarm Masks.
171                                       This parameter can be a value of @ref RTC_LL_EC_ALMA_MASK for ALARM A or @ref RTC_LL_EC_ALMB_MASK for ALARM B.
172 
173                                       This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetMask() for ALARM A
174                                       or @ref LL_RTC_ALMB_SetMask() for ALARM B
175                                  */
176 
177   uint32_t AlarmDateWeekDaySel;  /*!< Specifies the RTC Alarm is on day or WeekDay.
178                                       This parameter can be a value of @ref RTC_LL_EC_ALMA_WEEKDAY_SELECTION for ALARM A or @ref RTC_LL_EC_ALMB_WEEKDAY_SELECTION for ALARM B
179 
180                                       This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_EnableWeekday() or @ref LL_RTC_ALMA_DisableWeekday()
181                                       for ALARM A or @ref LL_RTC_ALMB_EnableWeekday() or @ref LL_RTC_ALMB_DisableWeekday() for ALARM B
182                                  */
183 
184   uint8_t AlarmDateWeekDay;      /*!< Specifies the RTC Alarm Day/WeekDay.
185                                       If AlarmDateWeekDaySel set to day, this parameter  must be a number between Min_Data = 1 and Max_Data = 31.
186 
187                                       This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetDay()
188                                       for ALARM A or @ref LL_RTC_ALMB_SetDay() for ALARM B.
189 
190                                       If AlarmDateWeekDaySel set to Weekday, this parameter can be a value of @ref RTC_LL_EC_WEEKDAY.
191 
192                                       This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetWeekDay()
193                                       for ALARM A or @ref LL_RTC_ALMB_SetWeekDay() for ALARM B.
194                                  */
195 } LL_RTC_AlarmTypeDef;
196 
197 /**
198   * @}
199   */
200 #endif /* USE_FULL_LL_DRIVER */
201 
202 /* Exported constants --------------------------------------------------------*/
203 /** @defgroup RTC_LL_Exported_Constants RTC Exported Constants
204   * @{
205   */
206 
207 #if defined(USE_FULL_LL_DRIVER)
208 /** @defgroup RTC_LL_EC_FORMAT FORMAT
209   * @{
210   */
211 #define LL_RTC_FORMAT_BIN                  0x00000000U /*!< Binary data format */
212 #define LL_RTC_FORMAT_BCD                  0x00000001U /*!< BCD data format */
213 /**
214   * @}
215   */
216 
217 /** @defgroup RTC_LL_EC_ALMA_WEEKDAY_SELECTION RTC Alarm A Date WeekDay
218   * @{
219   */
220 #define LL_RTC_ALMA_DATEWEEKDAYSEL_DATE    0x00000000U             /*!< Alarm A Date is selected */
221 #define LL_RTC_ALMA_DATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL        /*!< Alarm A WeekDay is selected */
222 /**
223   * @}
224   */
225 
226 /** @defgroup RTC_LL_EC_ALMB_WEEKDAY_SELECTION RTC Alarm B Date WeekDay
227   * @{
228   */
229 #define LL_RTC_ALMB_DATEWEEKDAYSEL_DATE    0x00000000U             /*!< Alarm B Date is selected */
230 #define LL_RTC_ALMB_DATEWEEKDAYSEL_WEEKDAY RTC_ALRMBR_WDSEL        /*!< Alarm B WeekDay is selected */
231 /**
232   * @}
233   */
234 
235 #endif /* USE_FULL_LL_DRIVER */
236 
237 /** @defgroup RTC_LL_EC_GET_FLAG Get Flags Defines
238   * @brief    Flags defines which can be used with LL_RTC_ReadReg function
239   * @{
240   */
241 #define LL_RTC_SCR_ITSF                    RTC_SCR_CITSF
242 #define LL_RTC_SCR_TSOVF                   RTC_SCR_CTSOVF
243 #define LL_RTC_SCR_TSF                     RTC_SCR_CTSF
244 #define LL_RTC_SCR_WUTF                    RTC_SCR_CWUTF
245 #define LL_RTC_SCR_ALRBF                   RTC_SCR_CALRBF
246 #define LL_RTC_SCR_ALRAF                   RTC_SCR_CALRAF
247 
248 #define LL_RTC_ICSR_RECALPF                RTC_ICSR_RECALPF
249 #define LL_RTC_ICSR_INITF                  RTC_ICSR_INITF
250 #define LL_RTC_ICSR_RSF                    RTC_ICSR_RSF
251 #define LL_RTC_ICSR_INITS                  RTC_ICSR_INITS
252 #define LL_RTC_ICSR_SHPF                   RTC_ICSR_SHPF
253 #define LL_RTC_ICSR_WUTWF                  RTC_ICSR_WUTWF
254 /**
255   * @}
256   */
257 
258 /** @defgroup RTC_LL_EC_IT IT Defines
259   * @brief    IT defines which can be used with LL_RTC_ReadReg and  LL_RTC_WriteReg functions
260   * @{
261   */
262 #define LL_RTC_CR_TSIE                     RTC_CR_TSIE
263 #define LL_RTC_CR_WUTIE                    RTC_CR_WUTIE
264 #define LL_RTC_CR_ALRBIE                   RTC_CR_ALRBIE
265 #define LL_RTC_CR_ALRAIE                   RTC_CR_ALRAIE
266 /**
267   * @}
268   */
269 
270 /** @defgroup RTC_LL_EC_WEEKDAY  WEEK DAY
271   * @{
272   */
273 #define LL_RTC_WEEKDAY_MONDAY              (uint8_t)0x01 /*!< Monday    */
274 #define LL_RTC_WEEKDAY_TUESDAY             (uint8_t)0x02 /*!< Tuesday   */
275 #define LL_RTC_WEEKDAY_WEDNESDAY           (uint8_t)0x03 /*!< Wednesday */
276 #define LL_RTC_WEEKDAY_THURSDAY            (uint8_t)0x04 /*!< Thrusday  */
277 #define LL_RTC_WEEKDAY_FRIDAY              (uint8_t)0x05 /*!< Friday    */
278 #define LL_RTC_WEEKDAY_SATURDAY            (uint8_t)0x06 /*!< Saturday  */
279 #define LL_RTC_WEEKDAY_SUNDAY              (uint8_t)0x07 /*!< Sunday    */
280 /**
281   * @}
282   */
283 
284 /** @defgroup RTC_LL_EC_MONTH  MONTH
285   * @{
286   */
287 #define LL_RTC_MONTH_JANUARY               (uint8_t)0x01  /*!< January   */
288 #define LL_RTC_MONTH_FEBRUARY              (uint8_t)0x02  /*!< February  */
289 #define LL_RTC_MONTH_MARCH                 (uint8_t)0x03  /*!< March     */
290 #define LL_RTC_MONTH_APRIL                 (uint8_t)0x04  /*!< April     */
291 #define LL_RTC_MONTH_MAY                   (uint8_t)0x05  /*!< May       */
292 #define LL_RTC_MONTH_JUNE                  (uint8_t)0x06  /*!< June      */
293 #define LL_RTC_MONTH_JULY                  (uint8_t)0x07  /*!< July      */
294 #define LL_RTC_MONTH_AUGUST                (uint8_t)0x08  /*!< August    */
295 #define LL_RTC_MONTH_SEPTEMBER             (uint8_t)0x09  /*!< September */
296 #define LL_RTC_MONTH_OCTOBER               (uint8_t)0x10  /*!< October   */
297 #define LL_RTC_MONTH_NOVEMBER              (uint8_t)0x11  /*!< November  */
298 #define LL_RTC_MONTH_DECEMBER              (uint8_t)0x12  /*!< December  */
299 /**
300   * @}
301   */
302 
303 /** @defgroup RTC_LL_EC_HOURFORMAT  HOUR FORMAT
304   * @{
305   */
306 #define LL_RTC_HOURFORMAT_24HOUR           0x00000000U    /*!< 24 hour/day format */
307 #define LL_RTC_HOURFORMAT_AMPM             RTC_CR_FMT     /*!< AM/PM hour format */
308 /**
309   * @}
310   */
311 
312 /** @defgroup RTC_LL_EC_ALARMOUT  ALARM OUTPUT
313   * @{
314   */
315 #define LL_RTC_ALARMOUT_DISABLE            0x00000000U             /*!< Output disabled */
316 #define LL_RTC_ALARMOUT_ALMA               RTC_CR_OSEL_0           /*!< Alarm A output enabled */
317 #define LL_RTC_ALARMOUT_ALMB               RTC_CR_OSEL_1           /*!< Alarm B output enabled */
318 #define LL_RTC_ALARMOUT_WAKEUP             RTC_CR_OSEL             /*!< Wakeup output enabled */
319 /**
320   * @}
321   */
322 
323 /** @defgroup RTC_LL_EC_ALARM_OUTPUTTYPE  ALARM OUTPUT TYPE
324   * @{
325   */
326 #define LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN  RTC_CR_TAMPALRM_TYPE   /*!< RTC_ALARM is open-drain output */
327 #define LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL   0x00000000U            /*!< RTC_ALARM is push-pull output */
328 /**
329 * @}
330 */
331 
332 /** @defgroup RTC_LL_EC_OUTPUTPOLARITY_PIN  OUTPUT POLARITY PIN
333   * @{
334   */
335 #define LL_RTC_OUTPUTPOLARITY_PIN_HIGH     0x00000000U           /*!< Pin is high when ALRAF/ALRBF/WUTF is asserted (depending on OSEL)*/
336 #define LL_RTC_OUTPUTPOLARITY_PIN_LOW      RTC_CR_POL            /*!< Pin is low when ALRAF/ALRBF/WUTF is asserted (depending on OSEL) */
337 /**
338   * @}
339   */
340 
341 /** @defgroup RTC_LL_EC_TIME_FORMAT TIME FORMAT
342   * @{
343   */
344 #define LL_RTC_TIME_FORMAT_AM_OR_24        0x00000000U           /*!< AM or 24-hour format */
345 #define LL_RTC_TIME_FORMAT_PM              RTC_TR_PM             /*!< PM */
346 /**
347   * @}
348   */
349 
350 /** @defgroup RTC_LL_EC_SHIFT_SECOND  SHIFT SECOND
351   * @{
352   */
353 #define LL_RTC_SHIFT_SECOND_DELAY          0x00000000U             /* Delay (seconds) = SUBFS / (PREDIV_S + 1) */
354 #define LL_RTC_SHIFT_SECOND_ADVANCE        RTC_SHIFTR_ADD1S      /* Advance (seconds) = (1 - (SUBFS / (PREDIV_S + 1))) */
355 /**
356   * @}
357   */
358 
359 /** @defgroup RTC_LL_EC_ALMA_MASK  ALARMA MASK
360   * @{
361   */
362 #define LL_RTC_ALMA_MASK_NONE              0x00000000U             /*!< No masks applied on Alarm A*/
363 #define LL_RTC_ALMA_MASK_DATEWEEKDAY       RTC_ALRMAR_MSK4         /*!< Date/day do not care in Alarm A comparison */
364 #define LL_RTC_ALMA_MASK_HOURS             RTC_ALRMAR_MSK3         /*!< Hours do not care in Alarm A comparison */
365 #define LL_RTC_ALMA_MASK_MINUTES           RTC_ALRMAR_MSK2         /*!< Minutes do not care in Alarm A comparison */
366 #define LL_RTC_ALMA_MASK_SECONDS           RTC_ALRMAR_MSK1         /*!< Seconds do not care in Alarm A comparison */
367 #define LL_RTC_ALMA_MASK_ALL               (RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1) /*!< Masks all */
368 /**
369   * @}
370   */
371 
372 /** @defgroup RTC_LL_EC_ALMA_TIME_FORMAT  ALARMA TIME FORMAT
373   * @{
374   */
375 #define LL_RTC_ALMA_TIME_FORMAT_AM         0x00000000U           /*!< AM or 24-hour format */
376 #define LL_RTC_ALMA_TIME_FORMAT_PM         RTC_ALRMAR_PM         /*!< PM */
377 /**
378   * @}
379   */
380 
381 /** @defgroup RTC_LL_EC_ALMA_SUBSECONDBIN_AUTOCLR  RTC Alarm Sub Seconds with binary mode auto clear Definitions
382   * @{
383   */
384 #define LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_NO    0UL                  /*!<  The synchronous binary counter (SS[31:0] in RTC_SSR) is free-running. */
385 #define LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_YES   RTC_ALRMASSR_SSCLR   /*!<  The synchronous binary counter (SS[31:0] in RTC_SSR) is running from 0xFFFF FFFF to
386                                                                           RTC_ALRMABINR -> SS[31:0] value and is automatically reloaded with 0xFFFF FFFF
387                                                                           when reaching RTC_ALRMABINR -> SS[31:0]. */
388 /**
389   * @}
390   */
391 
392 /** @defgroup RTC_LL_EC_ALMB_MASK  ALARMB MASK
393   * @{
394   */
395 #define LL_RTC_ALMB_MASK_NONE              0x00000000U             /*!< No masks applied on Alarm B*/
396 #define LL_RTC_ALMB_MASK_DATEWEEKDAY       RTC_ALRMBR_MSK4         /*!< Date/day do not care in Alarm B comparison */
397 #define LL_RTC_ALMB_MASK_HOURS             RTC_ALRMBR_MSK3         /*!< Hours do not care in Alarm B comparison */
398 #define LL_RTC_ALMB_MASK_MINUTES           RTC_ALRMBR_MSK2         /*!< Minutes do not care in Alarm B comparison */
399 #define LL_RTC_ALMB_MASK_SECONDS           RTC_ALRMBR_MSK1         /*!< Seconds do not care in Alarm B comparison */
400 #define LL_RTC_ALMB_MASK_ALL               (RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1) /*!< Masks all */
401 /**
402   * @}
403   */
404 
405 /** @defgroup RTC_LL_EC_ALMB_TIME_FORMAT  ALARMB TIME FORMAT
406   * @{
407   */
408 #define LL_RTC_ALMB_TIME_FORMAT_AM         0x00000000U           /*!< AM or 24-hour format */
409 #define LL_RTC_ALMB_TIME_FORMAT_PM         RTC_ALRMBR_PM         /*!< PM */
410 /**
411   * @}
412   */
413 
414 /** @defgroup RTC_LL_EC_ALMB_SUBSECONDBIN_AUTOCLR  Alarm Sub Seconds with binary mode auto clear Definitions
415   * @{
416   */
417 #define LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_NO    0UL                  /*!<  The synchronous binary counter (SS[31:0] in RTC_SSR) is free-running. */
418 #define LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_YES   RTC_ALRMBSSR_SSCLR   /*!<  The synchronous binary counter (SS[31:0] in RTC_SSR) is running from 0xFFFF FFFF to
419                                                                           RTC_ALRMABINR -> SS[31:0] value and is automatically reloaded with 0xFFFF FFFF
420                                                                           when reaching RTC_ALRMABINR -> SS[31:0]. */
421 /**
422   * @}
423   */
424 
425 /** @defgroup RTC_LL_EC_ALMB_FLAG_AUTOCLR  RTC Alarm Flag auto clear Definitions
426   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
427   * @{
428   */
429 #define LL_RTC_ALMB_FLAG_AUTOCLR_NO    0UL                  /*!<  */
430 #define LL_RTC_ALMB_FLAG_AUTOCLR_YES   RTC_CR_ALRBMSK       /*!<  */
431 /**
432   * @}
433   */
434 
435 /** @defgroup RTC_LL_EC_TIMESTAMP_EDGE  TIMESTAMP EDGE
436   * @{
437   */
438 #define LL_RTC_TIMESTAMP_EDGE_RISING       0x00000000U           /*!< RTC_TS input rising edge generates a time-stamp event */
439 #define LL_RTC_TIMESTAMP_EDGE_FALLING      RTC_CR_TSEDGE         /*!< RTC_TS input falling edge generates a time-stamp even */
440 /**
441   * @}
442   */
443 
444 /** @defgroup RTC_LL_EC_TS_TIME_FORMAT  TIMESTAMP TIME FORMAT
445   * @{
446   */
447 #define LL_RTC_TS_TIME_FORMAT_AM           0x00000000U           /*!< AM or 24-hour format */
448 #define LL_RTC_TS_TIME_FORMAT_PM           RTC_TSTR_PM           /*!< PM */
449 /**
450   * @}
451   */
452 
453 /** @defgroup RTC_LL_EC_TAMPER  TAMPER
454   * @{
455   */
456 #define LL_RTC_TAMPER_1                    TAMP_CR1_TAMP1E /*!< Tamper 1 input detection */
457 #define LL_RTC_TAMPER_2                    TAMP_CR1_TAMP2E /*!< Tamper 2 input detection */
458 #define LL_RTC_TAMPER_3                    TAMP_CR1_TAMP3E /*!< Tamper 3  input detection */
459 /**
460   * @}
461   */
462 
463 /** @defgroup RTC_LL_EC_TAMPER_MASK  TAMPER MASK
464   * @{
465   */
466 #define LL_RTC_TAMPER_MASK_TAMPER1         TAMP_CR2_TAMP1MSK /*!< Tamper 1 event generates a trigger event. TAMP1F is masked and internally cleared by hardware.The backup registers are not erased */
467 #define LL_RTC_TAMPER_MASK_TAMPER2         TAMP_CR2_TAMP2MSK /*!< Tamper 2 event generates a trigger event. TAMP2F is masked and internally cleared by hardware. The backup registers are not erased. */
468 #define LL_RTC_TAMPER_MASK_TAMPER3         TAMP_CR2_TAMP3MSK /*!< Tamper 3 event generates a trigger event. TAMP2F is masked and internally cleared by hardware. The backup registers are not erased. */
469 /**
470   * @}
471   */
472 
473 /** @defgroup RTC_LL_EC_TAMPER_NOERASE  TAMPER NO ERASE
474   * @{
475   */
476 #define LL_RTC_TAMPER_NOERASE_TAMPER1      TAMP_CR2_TAMP1NOERASE /*!< Tamper 1 event does not erase the backup registers. */
477 #define LL_RTC_TAMPER_NOERASE_TAMPER2      TAMP_CR2_TAMP2NOERASE /*!< Tamper 2 event does not erase the backup registers. */
478 #define LL_RTC_TAMPER_NOERASE_TAMPER3      TAMP_CR2_TAMP3NOERASE /*!< Tamper 3 event does not erase the backup registers. */
479 /**
480   * @}
481   */
482 
483 /** @defgroup RTC_LL_EC_TAMPER_DURATION  TAMPER DURATION
484   * @{
485   */
486 #define LL_RTC_TAMPER_DURATION_1RTCCLK     0x00000000U            /*!< Tamper pins are pre-charged before sampling during 1 RTCCLK cycle  */
487 #define LL_RTC_TAMPER_DURATION_2RTCCLK     TAMP_FLTCR_TAMPPRCH_0  /*!< Tamper pins are pre-charged before sampling during 2 RTCCLK cycles */
488 #define LL_RTC_TAMPER_DURATION_4RTCCLK     TAMP_FLTCR_TAMPPRCH_1  /*!< Tamper pins are pre-charged before sampling during 4 RTCCLK cycles */
489 #define LL_RTC_TAMPER_DURATION_8RTCCLK     TAMP_FLTCR_TAMPPRCH    /*!< Tamper pins are pre-charged before sampling during 8 RTCCLK cycles */
490 /**
491   * @}
492   */
493 
494 /** @defgroup RTC_LL_EC_TAMPER_FILTER  TAMPER FILTER
495   * @{
496   */
497 #define LL_RTC_TAMPER_FILTER_DISABLE       0x00000000U             /*!< Tamper filter is disabled */
498 #define LL_RTC_TAMPER_FILTER_2SAMPLE       TAMP_FLTCR_TAMPFLT_0    /*!< Tamper is activated after 2 consecutive samples at the active level */
499 #define LL_RTC_TAMPER_FILTER_4SAMPLE       TAMP_FLTCR_TAMPFLT_1    /*!< Tamper is activated after 4 consecutive samples at the active level */
500 #define LL_RTC_TAMPER_FILTER_8SAMPLE       TAMP_FLTCR_TAMPFLT      /*!< Tamper is activated after 8 consecutive samples at the active level. */
501 /**
502   * @}
503   */
504 
505 /** @defgroup RTC_LL_EC_TAMPER_SAMPLFREQDIV  TAMPER SAMPLING FREQUENCY DIVIDER
506   * @{
507   */
508 #define LL_RTC_TAMPER_SAMPLFREQDIV_32768   0x00000000U                                     /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 32768 */
509 #define LL_RTC_TAMPER_SAMPLFREQDIV_16384   TAMP_FLTCR_TAMPFREQ_0                           /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 16384 */
510 #define LL_RTC_TAMPER_SAMPLFREQDIV_8192    TAMP_FLTCR_TAMPFREQ_1                           /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 8192 */
511 #define LL_RTC_TAMPER_SAMPLFREQDIV_4096    (TAMP_FLTCR_TAMPFREQ_1 | TAMP_FLTCR_TAMPFREQ_0) /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 4096 */
512 #define LL_RTC_TAMPER_SAMPLFREQDIV_2048    TAMP_FLTCR_TAMPFREQ_2                           /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 2048 */
513 #define LL_RTC_TAMPER_SAMPLFREQDIV_1024    (TAMP_FLTCR_TAMPFREQ_2 | TAMP_FLTCR_TAMPFREQ_0) /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 1024 */
514 #define LL_RTC_TAMPER_SAMPLFREQDIV_512     (TAMP_FLTCR_TAMPFREQ_2 | TAMP_FLTCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 512 */
515 #define LL_RTC_TAMPER_SAMPLFREQDIV_256     TAMP_FLTCR_TAMPFREQ                             /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 256 */
516 /**
517   * @}
518   */
519 
520 /** @defgroup RTC_LL_EC_TAMPER_ACTIVELEVEL  TAMPER ACTIVE LEVEL
521   * @{
522   */
523 #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP1    TAMP_CR2_TAMP1TRG /*!< Tamper 1 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
524 #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP2    TAMP_CR2_TAMP2TRG /*!< Tamper 2 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
525 #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP3    TAMP_CR2_TAMP3TRG /*!< Tamper 3 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
526 /**
527   * @}
528   */
529 
530 
531 /** @defgroup RTC_LL_EC_INTERNAL  INTERNAL TAMPER
532   * @{
533   */
534 #define LL_RTC_TAMPER_ITAMP3               TAMP_CR1_ITAMP3E /*!< Internal tamper 3: LSE monitoring */
535 #define LL_RTC_TAMPER_ITAMP5               TAMP_CR1_ITAMP5E /*!< Internal tamper 5: RTC calendar overflow */
536 #define LL_RTC_TAMPER_ITAMP6               TAMP_CR1_ITAMP6E /*!< Internal tamper 6: JTAG access in RDP level 1 */
537 #define LL_RTC_TAMPER_ITAMP8               TAMP_CR1_ITAMP8E /*!< Internal tamper 8: Monotonic counter overflow */
538 /**
539   * @}
540   */
541 
542 /** @defgroup RTC_LL_EC_BKP  BACKUP
543   * @{
544   */
545 #define LL_RTC_BKP_NUMBER                  RTC_BACKUP_NB
546 #define LL_RTC_BKP_DR0                     0U
547 #define LL_RTC_BKP_DR1                     1U
548 #define LL_RTC_BKP_DR2                     2U
549 #define LL_RTC_BKP_DR3                     3U
550 #define LL_RTC_BKP_DR4                     4U
551 #define LL_RTC_BKP_DR5                     5U
552 #define LL_RTC_BKP_DR6                     6U
553 #define LL_RTC_BKP_DR7                     7U
554 #define LL_RTC_BKP_DR8                     8U
555 #define LL_RTC_BKP_DR9                     9U
556 #define LL_RTC_BKP_DR10                    10U
557 #define LL_RTC_BKP_DR11                    11U
558 #define LL_RTC_BKP_DR12                    12U
559 #define LL_RTC_BKP_DR13                    13U
560 #define LL_RTC_BKP_DR14                    14U
561 #define LL_RTC_BKP_DR15                    15U
562 #define LL_RTC_BKP_DR16                    16U
563 #define LL_RTC_BKP_DR17                    17U
564 #define LL_RTC_BKP_DR18                    18U
565 #define LL_RTC_BKP_DR19                    19U
566 /**
567   * @}
568   */
569 
570 /** @defgroup RTC_LL_EC_WAKEUPCLOCK_DIV  WAKEUP CLOCK DIV
571   * @{
572   */
573 #define LL_RTC_WAKEUPCLOCK_DIV_16          0x00000000U                           /*!< RTC/16 clock is selected */
574 #define LL_RTC_WAKEUPCLOCK_DIV_8           RTC_CR_WUCKSEL_0                      /*!< RTC/8 clock is selected */
575 #define LL_RTC_WAKEUPCLOCK_DIV_4           RTC_CR_WUCKSEL_1                      /*!< RTC/4 clock is selected */
576 #define LL_RTC_WAKEUPCLOCK_DIV_2           (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_0) /*!< RTC/2 clock is selected */
577 #define LL_RTC_WAKEUPCLOCK_CKSPRE          RTC_CR_WUCKSEL_2                      /*!< ck_spre (usually 1 Hz) clock is selected */
578 #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*/
579 /**
580   * @}
581   */
582 
583 /** @defgroup RTC_LL_EC_CALIB_OUTPUT  Calibration output
584   * @{
585   */
586 #define LL_RTC_CALIB_OUTPUT_NONE           0x00000000U                 /*!< Calibration output disabled */
587 #define LL_RTC_CALIB_OUTPUT_1HZ            (RTC_CR_COE | RTC_CR_COSEL) /*!< Calibration output is 1 Hz */
588 #define LL_RTC_CALIB_OUTPUT_512HZ          RTC_CR_COE                 /*!< Calibration output is 512 Hz */
589 /**
590   * @}
591   */
592 
593 /** @defgroup RTC_LL_EC_CALIB_INSERTPULSE  Calibration pulse insertion
594   * @{
595   */
596 #define LL_RTC_CALIB_INSERTPULSE_NONE      0x00000000U           /*!< No RTCCLK pulses are added */
597 #define LL_RTC_CALIB_INSERTPULSE_SET       RTC_CALR_CALP         /*!< One RTCCLK pulse is effectively inserted every 2exp11 pulses (frequency increased by 488.5 ppm) */
598 /**
599   * @}
600   */
601 
602 /** @defgroup RTC_LL_EC_CALIB_PERIOD  Calibration period
603   * @{
604   */
605 #define LL_RTC_CALIB_PERIOD_32SEC          0x00000000U           /*!< Use a 32-second calibration cycle period */
606 #define LL_RTC_CALIB_PERIOD_16SEC          RTC_CALR_CALW16       /*!< Use a 16-second calibration cycle period */
607 #define LL_RTC_CALIB_PERIOD_8SEC           RTC_CALR_CALW8        /*!< Use a 8-second calibration cycle period */
608 /**
609   * @}
610   */
611 
612 /** @defgroup RTC_LL_EC_CALIB_LOWPOWER  Calibration low power
613   * @{
614   */
615 #define LL_RTC_CALIB_LOWPOWER_NONE         0x00000000U           /*!< High conso mode */
616 #define LL_RTC_CALIB_LOWPOWER_SET          RTC_CALR_LPCAL        /*!< low power mode */
617 /**
618   * @}
619   */
620 
621 /** @defgroup RTC_LL_EC_BINARY_MODE  Binary mode (Sub Second Register)
622   * @{
623   */
624 #define LL_RTC_BINARY_NONE  0x00000000U     /*!< Free running BCD calendar mode (Binary mode disabled). */
625 #define LL_RTC_BINARY_ONLY  RTC_ICSR_BIN_0  /*!< Free running Binary mode (BCD mode disabled) */
626 #define LL_RTC_BINARY_MIX   RTC_ICSR_BIN_1  /*!< Free running BCD calendar and Binary mode enable */
627 /**
628   * @}
629   */
630 
631 /** @defgroup RTC_LL_EC_BINARY_MIX_BCDU  Calendar second incrementation in Binary mix mode
632   * @{
633   */
634 #define LL_RTC_BINARY_MIX_BCDU_0  0x00000000u                    /*!<  1s calendar increment is generated each time SS[7:0] = 0 */
635 #define LL_RTC_BINARY_MIX_BCDU_1  (0x1UL << RTC_ICSR_BCDU_Pos)   /*!<  1s calendar increment is generated each time SS[8:0] = 0 */
636 #define LL_RTC_BINARY_MIX_BCDU_2  (0x2UL << RTC_ICSR_BCDU_Pos)   /*!<  1s calendar increment is generated each time SS[9:0] = 0 */
637 #define LL_RTC_BINARY_MIX_BCDU_3  (0x3UL << RTC_ICSR_BCDU_Pos)   /*!<  1s calendar increment is generated each time SS[10:0] = 0 */
638 #define LL_RTC_BINARY_MIX_BCDU_4  (0x4UL << RTC_ICSR_BCDU_Pos)   /*!<  1s calendar increment is generated each time SS[11:0] = 0 */
639 #define LL_RTC_BINARY_MIX_BCDU_5  (0x5UL << RTC_ICSR_BCDU_Pos)   /*!<  1s calendar increment is generated each time SS[12:0] = 0 */
640 #define LL_RTC_BINARY_MIX_BCDU_6  (0x6UL << RTC_ICSR_BCDU_Pos)   /*!<  1s calendar increment is generated each time SS[13:0] = 0 */
641 #define LL_RTC_BINARY_MIX_BCDU_7  (0x7UL << RTC_ICSR_BCDU_Pos)   /*!<  1s calendar increment is generated each time SS[14:0] = 0 */
642 /**
643   * @}
644   */
645 
646 /**
647   * @}
648   */
649 
650 /* Exported macro ------------------------------------------------------------*/
651 /** @defgroup RTC_LL_Exported_Macros RTC Exported Macros
652   * @{
653   */
654 
655 /** @defgroup RTC_LL_EM_WRITE_READ Common Write and read registers Macros
656   * @{
657   */
658 
659 /**
660   * @brief  Write a value in RTC register
661   * @param  __INSTANCE__ RTC Instance
662   * @param  __REG__ Register to be written
663   * @param  __VALUE__ Value to be written in the register
664   * @retval None
665   */
666 #define LL_RTC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
667 
668 /**
669   * @brief  Read a value in RTC register
670   * @param  __INSTANCE__ RTC Instance
671   * @param  __REG__ Register to be read
672   * @retval Register value
673   */
674 #define LL_RTC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
675 /**
676   * @}
677   */
678 
679 /** @defgroup RTC_LL_EM_Convert Convert helper Macros
680   * @{
681   */
682 
683 /**
684   * @brief  Helper macro to convert a value from 2 digit decimal format to BCD format
685   * @param  __VALUE__ Byte to be converted
686   * @retval Converted byte
687   */
688 #define __LL_RTC_CONVERT_BIN2BCD(__VALUE__) ((uint8_t)((((__VALUE__) / 10U) << 4U) | ((__VALUE__) % 10U)))
689 
690 /**
691   * @brief  Helper macro to convert a value from BCD format to 2 digit decimal format
692   * @param  __VALUE__ BCD value to be converted
693   * @retval Converted byte
694   */
695 #define __LL_RTC_CONVERT_BCD2BIN(__VALUE__) ((uint8_t)((((uint8_t)((__VALUE__) & (uint8_t)0xF0U) >> (uint8_t)0x4U) * 10U) + ((__VALUE__) & (uint8_t)0x0FU)))
696 
697 /**
698   * @}
699   */
700 
701 /** @defgroup RTC_LL_EM_Date Date helper Macros
702   * @{
703   */
704 
705 /**
706   * @brief  Helper macro to retrieve weekday.
707   * @param  __RTC_DATE__ Date returned by @ref  LL_RTC_DATE_Get function.
708   * @retval Returned value can be one of the following values:
709   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
710   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
711   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
712   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
713   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
714   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
715   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
716   */
717 #define __LL_RTC_GET_WEEKDAY(__RTC_DATE__) (((__RTC_DATE__) >> RTC_OFFSET_WEEKDAY) & 0x000000FFU)
718 
719 /**
720   * @brief  Helper macro to retrieve Year in BCD format
721   * @param  __RTC_DATE__ Value returned by @ref  LL_RTC_DATE_Get
722   * @retval Year in BCD format (0x00 . . . 0x99)
723   */
724 #define __LL_RTC_GET_YEAR(__RTC_DATE__) ((__RTC_DATE__) & 0x000000FFU)
725 
726 /**
727   * @brief  Helper macro to retrieve Month in BCD format
728   * @param  __RTC_DATE__ Value returned by @ref  LL_RTC_DATE_Get
729   * @retval Returned value can be one of the following values:
730   *         @arg @ref LL_RTC_MONTH_JANUARY
731   *         @arg @ref LL_RTC_MONTH_FEBRUARY
732   *         @arg @ref LL_RTC_MONTH_MARCH
733   *         @arg @ref LL_RTC_MONTH_APRIL
734   *         @arg @ref LL_RTC_MONTH_MAY
735   *         @arg @ref LL_RTC_MONTH_JUNE
736   *         @arg @ref LL_RTC_MONTH_JULY
737   *         @arg @ref LL_RTC_MONTH_AUGUST
738   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
739   *         @arg @ref LL_RTC_MONTH_OCTOBER
740   *         @arg @ref LL_RTC_MONTH_NOVEMBER
741   *         @arg @ref LL_RTC_MONTH_DECEMBER
742   */
743 #define __LL_RTC_GET_MONTH(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_MONTH) & 0x000000FFU)
744 
745 /**
746   * @brief  Helper macro to retrieve Day in BCD format
747   * @param  __RTC_DATE__ Value returned by @ref  LL_RTC_DATE_Get
748   * @retval Day in BCD format (0x01 . . . 0x31)
749   */
750 #define __LL_RTC_GET_DAY(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_DAY) & 0x000000FFU)
751 
752 /**
753   * @}
754   */
755 
756 /** @defgroup RTC_LL_EM_Time Time helper Macros
757   * @{
758   */
759 
760 /**
761   * @brief  Helper macro to retrieve hour in BCD format
762   * @param  __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
763   * @retval Hours in BCD format (0x01. . .0x12 or between Min_Data=0x00 and Max_Data=0x23)
764   */
765 #define __LL_RTC_GET_HOUR(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_HOUR) & 0x000000FFU)
766 
767 /**
768   * @brief  Helper macro to retrieve minute in BCD format
769   * @param  __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
770   * @retval Minutes in BCD format (0x00. . .0x59)
771   */
772 #define __LL_RTC_GET_MINUTE(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_MINUTE) & 0x000000FFU)
773 
774 /**
775   * @brief  Helper macro to retrieve second in BCD format
776   * @param  __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
777   * @retval Seconds in  format (0x00. . .0x59)
778   */
779 #define __LL_RTC_GET_SECOND(__RTC_TIME__) ((__RTC_TIME__) & 0x000000FFU)
780 
781 /**
782   * @}
783   */
784 
785 /**
786   * @}
787   */
788 
789 /* Exported functions --------------------------------------------------------*/
790 /** @defgroup RTC_LL_Exported_Functions RTC Exported Functions
791   * @{
792   */
793 
794 /** @defgroup RTC_LL_EF_Configuration Configuration
795   * @{
796   */
797 
798 /**
799   * @brief  Set Hours format (24 hour/day or AM/PM hour format)
800   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
801   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
802   * @rmtoll RTC_CR           FMT           LL_RTC_SetHourFormat
803   * @param  RTCx RTC Instance
804   * @param  HourFormat This parameter can be one of the following values:
805   *         @arg @ref LL_RTC_HOURFORMAT_24HOUR
806   *         @arg @ref LL_RTC_HOURFORMAT_AMPM
807   * @retval None
808   */
LL_RTC_SetHourFormat(RTC_TypeDef * RTCx,uint32_t HourFormat)809 __STATIC_INLINE void LL_RTC_SetHourFormat(RTC_TypeDef *RTCx, uint32_t HourFormat)
810 {
811   MODIFY_REG(RTCx->CR, RTC_CR_FMT, HourFormat);
812 }
813 
814 /**
815   * @brief  Get Hours format (24 hour/day or AM/PM hour format)
816   * @rmtoll RTC_CR           FMT           LL_RTC_GetHourFormat
817   * @param  RTCx RTC Instance
818   * @retval Returned value can be one of the following values:
819   *         @arg @ref LL_RTC_HOURFORMAT_24HOUR
820   *         @arg @ref LL_RTC_HOURFORMAT_AMPM
821   */
LL_RTC_GetHourFormat(RTC_TypeDef * RTCx)822 __STATIC_INLINE uint32_t LL_RTC_GetHourFormat(RTC_TypeDef *RTCx)
823 {
824   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_FMT));
825 }
826 
827 /**
828   * @brief  Select the flag to be routed to RTC_ALARM output
829   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
830   * @rmtoll RTC_CR           OSEL          LL_RTC_SetAlarmOutEvent
831   * @param  RTCx RTC Instance
832   * @param  AlarmOutput This parameter can be one of the following values:
833   *         @arg @ref LL_RTC_ALARMOUT_DISABLE
834   *         @arg @ref LL_RTC_ALARMOUT_ALMA
835   *         @arg @ref LL_RTC_ALARMOUT_ALMB
836   *         @arg @ref LL_RTC_ALARMOUT_WAKEUP
837   * @retval None
838   */
LL_RTC_SetAlarmOutEvent(RTC_TypeDef * RTCx,uint32_t AlarmOutput)839 __STATIC_INLINE void LL_RTC_SetAlarmOutEvent(RTC_TypeDef *RTCx, uint32_t AlarmOutput)
840 {
841   MODIFY_REG(RTCx->CR, RTC_CR_OSEL, AlarmOutput);
842 }
843 
844 /**
845   * @brief  Get the flag to be routed to RTC_ALARM output
846   * @rmtoll RTC_CR           OSEL          LL_RTC_GetAlarmOutEvent
847   * @param  RTCx RTC Instance
848   * @retval Returned value can be one of the following values:
849   *         @arg @ref LL_RTC_ALARMOUT_DISABLE
850   *         @arg @ref LL_RTC_ALARMOUT_ALMA
851   *         @arg @ref LL_RTC_ALARMOUT_ALMB
852   *         @arg @ref LL_RTC_ALARMOUT_WAKEUP
853   */
LL_RTC_GetAlarmOutEvent(RTC_TypeDef * RTCx)854 __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutEvent(RTC_TypeDef *RTCx)
855 {
856   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_OSEL));
857 }
858 
859 /**
860   * @brief  Set RTC_ALARM output type (ALARM in push-pull or open-drain output)
861   * @rmtoll RTC_CR           TAMPALRM_TYPE          LL_RTC_SetAlarmOutputType
862   * @param  RTCx RTC Instance
863   * @param  Output This parameter can be one of the following values:
864   *         @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
865   *         @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
866   * @retval None
867   */
LL_RTC_SetAlarmOutputType(RTC_TypeDef * RTCx,uint32_t Output)868 __STATIC_INLINE void LL_RTC_SetAlarmOutputType(RTC_TypeDef *RTCx, uint32_t Output)
869 {
870   MODIFY_REG(RTCx->CR, RTC_CR_TAMPALRM_TYPE, Output);
871 }
872 
873 /**
874   * @brief  Get RTC_ALARM output type (ALARM in push-pull or open-drain output)
875   * @rmtoll RTC_CR           TAMPALRM_TYPE          LL_RTC_SetAlarmOutputType
876   * @param  RTCx RTC Instance
877   * @retval Returned value can be one of the following values:
878   *         @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
879   *         @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
880   */
LL_RTC_GetAlarmOutputType(RTC_TypeDef * RTCx)881 __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutputType(RTC_TypeDef *RTCx)
882 {
883   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_TAMPALRM_TYPE));
884 }
885 
886 /**
887   * @brief  Enable initialization mode
888   * @note   Initialization mode is used to program time and date register (RTC_TR and RTC_DR)
889   *         and prescaler register (RTC_PRER), plus BIN and BCDU fields.
890   *         Counters are stopped and start counting from the new value when INIT is reset.
891   * @rmtoll RTC_ICSR          INIT          LL_RTC_EnableInitMode
892   * @param  RTCx RTC Instance
893   * @retval None
894   */
LL_RTC_EnableInitMode(RTC_TypeDef * RTCx)895 __STATIC_INLINE void LL_RTC_EnableInitMode(RTC_TypeDef *RTCx)
896 {
897   /* Set the Initialization mode */
898   SET_BIT(RTCx->ICSR, RTC_ICSR_INIT);
899 }
900 
901 /**
902   * @brief  Disable initialization mode (Free running mode)
903   * @rmtoll RTC_ICSR          INIT          LL_RTC_DisableInitMode
904   * @param  RTCx RTC Instance
905   * @retval None
906   */
LL_RTC_DisableInitMode(RTC_TypeDef * RTCx)907 __STATIC_INLINE void LL_RTC_DisableInitMode(RTC_TypeDef *RTCx)
908 {
909   /* Exit Initialization mode */
910   CLEAR_BIT(RTCx->ICSR, RTC_ICSR_INIT);
911 }
912 
913 /**
914   * @brief  Set Binary mode (Sub Second Register)
915   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
916   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function).
917   * @rmtoll RTC_ICSR           BIN           LL_RTC_SetBinaryMode
918   * @param  RTCx RTC Instance
919   * @param  BinaryMode can be one of the following values:
920   *         @arg @ref LL_RTC_BINARY_NONE
921   *         @arg @ref LL_RTC_BINARY_ONLY
922   *         @arg @ref LL_RTC_BINARY_MIX
923   * @retval None
924   */
LL_RTC_SetBinaryMode(RTC_TypeDef * RTCx,uint32_t BinaryMode)925 __STATIC_INLINE void LL_RTC_SetBinaryMode(RTC_TypeDef *RTCx, uint32_t BinaryMode)
926 {
927   MODIFY_REG(RTCx->ICSR, RTC_ICSR_BIN, BinaryMode);
928 }
929 
930 /**
931   * @brief  Get Binary mode (Sub Second Register)
932   * @rmtoll RTC_ICSR           BIN           LL_RTC_GetBinaryMode
933   * @param  RTCx RTC Instance
934   * @retval This parameter can be one of the following values:
935   *         @arg @ref LL_RTC_BINARY_NONE
936   *         @arg @ref LL_RTC_BINARY_ONLY
937   *         @arg @ref LL_RTC_BINARY_MIX
938   * @retval None
939   */
LL_RTC_GetBinaryMode(RTC_TypeDef * RTCx)940 __STATIC_INLINE uint32_t LL_RTC_GetBinaryMode(RTC_TypeDef *RTCx)
941 {
942   return (uint32_t)(READ_BIT(RTCx->ICSR, RTC_ICSR_BIN));
943 }
944 
945 /**
946   * @brief  Set Binary Mix mode BCDU
947   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
948   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function).
949   * @rmtoll RTC_ICSR           BCDU          LL_RTC_SetBinMixBCDU
950   * @param  RTCx RTC Instance
951   * @param  BinMixBcdU can be one of the following values:
952   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_0
953   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_1
954   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_2
955   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_3
956   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_4
957   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_5
958   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_6
959   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_7
960   * @retval None
961   */
LL_RTC_SetBinMixBCDU(RTC_TypeDef * RTCx,uint32_t BinMixBcdU)962 __STATIC_INLINE void LL_RTC_SetBinMixBCDU(RTC_TypeDef *RTCx, uint32_t BinMixBcdU)
963 {
964   MODIFY_REG(RTCx->ICSR, RTC_ICSR_BCDU, BinMixBcdU);
965 }
966 
967 /**
968   * @brief  Get Binary Mix mode BCDU
969   * @rmtoll RTC_ICSR           BCDU          LL_RTC_GetBinMixBCDU
970   * @param  RTCx RTC Instance
971   * @retval This parameter can be one of the following values:
972   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_0
973   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_1
974   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_2
975   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_3
976   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_4
977   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_5
978   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_6
979   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_7
980   * @retval None
981   */
LL_RTC_GetBinMixBCDU(RTC_TypeDef * RTCx)982 __STATIC_INLINE uint32_t LL_RTC_GetBinMixBCDU(RTC_TypeDef *RTCx)
983 {
984   return (uint32_t)(READ_BIT(RTCx->ICSR, RTC_ICSR_BCDU));
985 }
986 
987 /**
988   * @brief  Set Output polarity (pin is low when ALRAF/ALRBF/WUTF is asserted)
989   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
990   * @rmtoll RTC_CR           POL           LL_RTC_SetOutputPolarity
991   * @param  RTCx RTC Instance
992   * @param  Polarity This parameter can be one of the following values:
993   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
994   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
995   * @retval None
996   */
LL_RTC_SetOutputPolarity(RTC_TypeDef * RTCx,uint32_t Polarity)997 __STATIC_INLINE void LL_RTC_SetOutputPolarity(RTC_TypeDef *RTCx, uint32_t Polarity)
998 {
999   MODIFY_REG(RTCx->CR, RTC_CR_POL, Polarity);
1000 }
1001 
1002 /**
1003   * @brief  Get Output polarity
1004   * @rmtoll RTC_CR           POL           LL_RTC_GetOutputPolarity
1005   * @param  RTCx RTC Instance
1006   * @retval Returned value can be one of the following values:
1007   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
1008   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
1009   */
LL_RTC_GetOutputPolarity(RTC_TypeDef * RTCx)1010 __STATIC_INLINE uint32_t LL_RTC_GetOutputPolarity(RTC_TypeDef *RTCx)
1011 {
1012   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_POL));
1013 }
1014 
1015 /**
1016   * @brief  Enable Bypass the shadow registers
1017   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1018   * @rmtoll RTC_CR           BYPSHAD       LL_RTC_EnableShadowRegBypass
1019   * @param  RTCx RTC Instance
1020   * @retval None
1021   */
LL_RTC_EnableShadowRegBypass(RTC_TypeDef * RTCx)1022 __STATIC_INLINE void LL_RTC_EnableShadowRegBypass(RTC_TypeDef *RTCx)
1023 {
1024   SET_BIT(RTCx->CR, RTC_CR_BYPSHAD);
1025 }
1026 
1027 /**
1028   * @brief  Disable Bypass the shadow registers
1029   * @rmtoll RTC_CR           BYPSHAD       LL_RTC_DisableShadowRegBypass
1030   * @param  RTCx RTC Instance
1031   * @retval None
1032   */
LL_RTC_DisableShadowRegBypass(RTC_TypeDef * RTCx)1033 __STATIC_INLINE void LL_RTC_DisableShadowRegBypass(RTC_TypeDef *RTCx)
1034 {
1035   CLEAR_BIT(RTCx->CR, RTC_CR_BYPSHAD);
1036 }
1037 
1038 /**
1039   * @brief  Check if Shadow registers bypass is enabled or not.
1040   * @rmtoll RTC_CR           BYPSHAD       LL_RTC_IsShadowRegBypassEnabled
1041   * @param  RTCx RTC Instance
1042   * @retval State of bit (1 or 0).
1043   */
LL_RTC_IsShadowRegBypassEnabled(RTC_TypeDef * RTCx)1044 __STATIC_INLINE uint32_t LL_RTC_IsShadowRegBypassEnabled(RTC_TypeDef *RTCx)
1045 {
1046   return ((READ_BIT(RTCx->CR, RTC_CR_BYPSHAD) == (RTC_CR_BYPSHAD)) ? 1U : 0U);
1047 }
1048 
1049 /**
1050   * @brief  Enable RTC_REFIN reference clock detection (50 or 60 Hz)
1051   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1052   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1053   * @rmtoll RTC_CR           REFCKON       LL_RTC_EnableRefClock
1054   * @param  RTCx RTC Instance
1055   * @retval None
1056   */
LL_RTC_EnableRefClock(RTC_TypeDef * RTCx)1057 __STATIC_INLINE void LL_RTC_EnableRefClock(RTC_TypeDef *RTCx)
1058 {
1059   SET_BIT(RTCx->CR, RTC_CR_REFCKON);
1060 }
1061 
1062 /**
1063   * @brief  Disable RTC_REFIN reference clock detection (50 or 60 Hz)
1064   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1065   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1066   * @rmtoll RTC_CR           REFCKON       LL_RTC_DisableRefClock
1067   * @param  RTCx RTC Instance
1068   * @retval None
1069   */
LL_RTC_DisableRefClock(RTC_TypeDef * RTCx)1070 __STATIC_INLINE void LL_RTC_DisableRefClock(RTC_TypeDef *RTCx)
1071 {
1072   CLEAR_BIT(RTCx->CR, RTC_CR_REFCKON);
1073 }
1074 
1075 /**
1076   * @brief  Set Asynchronous prescaler factor
1077   * @rmtoll RTC_PRER         PREDIV_A      LL_RTC_SetAsynchPrescaler
1078   * @param  RTCx RTC Instance
1079   * @param  AsynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7F
1080   * @retval None
1081   */
LL_RTC_SetAsynchPrescaler(RTC_TypeDef * RTCx,uint32_t AsynchPrescaler)1082 __STATIC_INLINE void LL_RTC_SetAsynchPrescaler(RTC_TypeDef *RTCx, uint32_t AsynchPrescaler)
1083 {
1084   MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_A, AsynchPrescaler << RTC_PRER_PREDIV_A_Pos);
1085 }
1086 
1087 /**
1088   * @brief  Set Synchronous prescaler factor
1089   * @rmtoll RTC_PRER         PREDIV_S      LL_RTC_SetSynchPrescaler
1090   * @param  RTCx RTC Instance
1091   * @param  SynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7FFF
1092   * @retval None
1093   */
LL_RTC_SetSynchPrescaler(RTC_TypeDef * RTCx,uint32_t SynchPrescaler)1094 __STATIC_INLINE void LL_RTC_SetSynchPrescaler(RTC_TypeDef *RTCx, uint32_t SynchPrescaler)
1095 {
1096   MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_S, SynchPrescaler);
1097 }
1098 
1099 /**
1100   * @brief  Get Asynchronous prescaler factor
1101   * @rmtoll RTC_PRER         PREDIV_A      LL_RTC_GetAsynchPrescaler
1102   * @param  RTCx RTC Instance
1103   * @retval Value between Min_Data = 0 and Max_Data = 0x7F
1104   */
LL_RTC_GetAsynchPrescaler(RTC_TypeDef * RTCx)1105 __STATIC_INLINE uint32_t LL_RTC_GetAsynchPrescaler(RTC_TypeDef *RTCx)
1106 {
1107   return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_A) >> RTC_PRER_PREDIV_A_Pos);
1108 }
1109 
1110 /**
1111   * @brief  Get Synchronous prescaler factor
1112   * @rmtoll RTC_PRER         PREDIV_S      LL_RTC_GetSynchPrescaler
1113   * @param  RTCx RTC Instance
1114   * @retval Value between Min_Data = 0 and Max_Data = 0x7FFF
1115   */
LL_RTC_GetSynchPrescaler(RTC_TypeDef * RTCx)1116 __STATIC_INLINE uint32_t LL_RTC_GetSynchPrescaler(RTC_TypeDef *RTCx)
1117 {
1118   return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_S));
1119 }
1120 
1121 /**
1122   * @brief  Enable the write protection for RTC registers.
1123   * @rmtoll RTC_WPR          KEY           LL_RTC_EnableWriteProtection
1124   * @param  RTCx RTC Instance
1125   * @retval None
1126   */
LL_RTC_EnableWriteProtection(RTC_TypeDef * RTCx)1127 __STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx)
1128 {
1129   WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_DISABLE);
1130 }
1131 
1132 /**
1133   * @brief  Disable the write protection for RTC registers.
1134   * @rmtoll RTC_WPR          KEY           LL_RTC_DisableWriteProtection
1135   * @param  RTCx RTC Instance
1136   * @retval None
1137   */
LL_RTC_DisableWriteProtection(RTC_TypeDef * RTCx)1138 __STATIC_INLINE void LL_RTC_DisableWriteProtection(RTC_TypeDef *RTCx)
1139 {
1140   WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_1);
1141   WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_2);
1142 }
1143 
1144 /**
1145   * @brief  Enable tamper output.
1146   * @note When the tamper output is enabled, all external and internal tamper flags
1147   *       are ORed and routed to the TAMPALRM output.
1148   * @rmtoll RTC_CR           TAMPOE       LL_RTC_EnableTamperOutput
1149   * @param  RTCx RTC Instance
1150   * @retval None
1151   */
LL_RTC_EnableTamperOutput(RTC_TypeDef * RTCx)1152 __STATIC_INLINE void LL_RTC_EnableTamperOutput(RTC_TypeDef *RTCx)
1153 {
1154   SET_BIT(RTCx->CR, RTC_CR_TAMPOE);
1155 }
1156 
1157 /**
1158   * @brief  Disable tamper output.
1159   * @rmtoll RTC_CR           TAMPOE       LL_RTC_DisableTamperOutput
1160   * @param  RTCx RTC Instance
1161   * @retval None
1162   */
LL_RTC_DisableTamperOutput(RTC_TypeDef * RTCx)1163 __STATIC_INLINE void LL_RTC_DisableTamperOutput(RTC_TypeDef *RTCx)
1164 {
1165   CLEAR_BIT(RTCx->CR, RTC_CR_TAMPOE);
1166 }
1167 
1168 /**
1169   * @brief  Check if tamper output is enabled or not.
1170   * @rmtoll RTC_CR           TAMPOE       LL_RTC_IsTamperOutputEnabled
1171   * @param  RTCx RTC Instance
1172   * @retval State of bit (1 or 0).
1173   */
LL_RTC_IsTamperOutputEnabled(RTC_TypeDef * RTCx)1174 __STATIC_INLINE uint32_t LL_RTC_IsTamperOutputEnabled(RTC_TypeDef *RTCx)
1175 {
1176   return ((READ_BIT(RTCx->CR, RTC_CR_TAMPOE) == (RTC_CR_TAMPOE)) ? 1U : 0U);
1177 }
1178 
1179 /**
1180   * @brief  Enable internal pull-up in output mode.
1181   * @rmtoll RTC_CR           TAMPALRM_PU       LL_RTC_EnableAlarmPullUp
1182   * @param  RTCx RTC Instance
1183   * @retval None
1184   */
LL_RTC_EnableAlarmPullUp(RTC_TypeDef * RTCx)1185 __STATIC_INLINE void LL_RTC_EnableAlarmPullUp(RTC_TypeDef *RTCx)
1186 {
1187   SET_BIT(RTCx->CR, RTC_CR_TAMPALRM_PU);
1188 }
1189 
1190 /**
1191   * @brief  Disable internal pull-up in output mode.
1192   * @rmtoll RTC_CR           TAMPALRM_PU       LL_RTC_EnableAlarmPullUp
1193   * @param  RTCx RTC Instance
1194   * @retval None
1195   */
LL_RTC_DisableAlarmPullUp(RTC_TypeDef * RTCx)1196 __STATIC_INLINE void LL_RTC_DisableAlarmPullUp(RTC_TypeDef *RTCx)
1197 {
1198   CLEAR_BIT(RTCx->CR, RTC_CR_TAMPALRM_PU);
1199 }
1200 
1201 /**
1202   * @brief  Check if internal pull-up in output mode is enabled or not.
1203   * @rmtoll RTC_CR           TAMPALRM_PU       LL_RTC_IsAlarmPullUpEnabled
1204   * @param  RTCx RTC Instance
1205   * @retval State of bit (1 or 0).
1206   */
LL_RTC_IsAlarmPullUpEnabled(RTC_TypeDef * RTCx)1207 __STATIC_INLINE uint32_t LL_RTC_IsAlarmPullUpEnabled(RTC_TypeDef *RTCx)
1208 {
1209   return ((READ_BIT(RTCx->CR, RTC_CR_TAMPALRM_PU) == (RTC_CR_TAMPALRM_PU)) ? 1U : 0U);
1210 }
1211 
1212 /**
1213   * @brief  Enable RTC_OUT2 output
1214   * @note RTC_OUT2 mapping depends on both OSEL (@ref LL_RTC_SetAlarmOutEvent)
1215   *       and COE (@ref LL_RTC_CAL_SetOutputFreq) settings.
1216   * @note RTC_OUT2 is not available ins VBAT mode.
1217   * @rmtoll RTC_CR           OUT2EN       LL_RTC_EnableOutput2
1218   * @param  RTCx RTC Instance
1219   * @retval None
1220   */
LL_RTC_EnableOutput2(RTC_TypeDef * RTCx)1221 __STATIC_INLINE void LL_RTC_EnableOutput2(RTC_TypeDef *RTCx)
1222 {
1223   SET_BIT(RTCx->CR, RTC_CR_OUT2EN);
1224 }
1225 
1226 /**
1227   * @brief  Disable RTC_OUT2 output
1228   * @rmtoll RTC_CR           OUT2EN       LL_RTC_DisableOutput2
1229   * @param  RTCx RTC Instance
1230   * @retval None
1231   */
LL_RTC_DisableOutput2(RTC_TypeDef * RTCx)1232 __STATIC_INLINE void LL_RTC_DisableOutput2(RTC_TypeDef *RTCx)
1233 {
1234   CLEAR_BIT(RTCx->CR, RTC_CR_OUT2EN);
1235 }
1236 
1237 /**
1238   * @brief  Check if RTC_OUT2 output is enabled or not.
1239   * @rmtoll RTC_CR           OUT2EN       LL_RTC_IsOutput2Enabled
1240   * @param  RTCx RTC Instance
1241   * @retval State of bit (1 or 0).
1242   */
LL_RTC_IsOutput2Enabled(RTC_TypeDef * RTCx)1243 __STATIC_INLINE uint32_t LL_RTC_IsOutput2Enabled(RTC_TypeDef *RTCx)
1244 {
1245   return ((READ_BIT(RTCx->CR, RTC_CR_OUT2EN) == (RTC_CR_OUT2EN)) ? 1U : 0U);
1246 }
1247 
1248 /**
1249   * @}
1250   */
1251 
1252 /** @defgroup RTC_LL_EF_Time Time
1253   * @{
1254   */
1255 
1256 /**
1257   * @brief  Set time format (AM/24-hour or PM notation)
1258   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1259   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1260   * @rmtoll RTC_TR           PM            LL_RTC_TIME_SetFormat
1261   * @param  RTCx RTC Instance
1262   * @param  TimeFormat This parameter can be one of the following values:
1263   *         @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
1264   *         @arg @ref LL_RTC_TIME_FORMAT_PM
1265   * @retval None
1266   */
LL_RTC_TIME_SetFormat(RTC_TypeDef * RTCx,uint32_t TimeFormat)1267 __STATIC_INLINE void LL_RTC_TIME_SetFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
1268 {
1269   MODIFY_REG(RTCx->TR, RTC_TR_PM, TimeFormat);
1270 }
1271 
1272 /**
1273   * @brief  Get time format (AM or PM notation)
1274   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1275   *       before reading this bit
1276   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1277   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1278   * @rmtoll RTC_TR           PM            LL_RTC_TIME_GetFormat
1279   * @param  RTCx RTC Instance
1280   * @retval Returned value can be one of the following values:
1281   *         @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
1282   *         @arg @ref LL_RTC_TIME_FORMAT_PM
1283   */
LL_RTC_TIME_GetFormat(RTC_TypeDef * RTCx)1284 __STATIC_INLINE uint32_t LL_RTC_TIME_GetFormat(RTC_TypeDef *RTCx)
1285 {
1286   return (uint32_t)(READ_BIT(RTCx->TR, RTC_TR_PM));
1287 }
1288 
1289 /**
1290   * @brief  Set Hours in BCD format
1291   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1292   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1293   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert hour from binary to BCD format
1294   * @rmtoll RTC_TR           HT            LL_RTC_TIME_SetHour\n
1295   *         RTC_TR           HU            LL_RTC_TIME_SetHour
1296   * @param  RTCx RTC Instance
1297   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1298   * @retval None
1299   */
LL_RTC_TIME_SetHour(RTC_TypeDef * RTCx,uint32_t Hours)1300 __STATIC_INLINE void LL_RTC_TIME_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
1301 {
1302   MODIFY_REG(RTCx->TR, (RTC_TR_HT | RTC_TR_HU),
1303              (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)));
1304 }
1305 
1306 /**
1307   * @brief  Get Hours in BCD format
1308   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1309   *       before reading this bit
1310   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1311   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1312   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert hour from BCD to
1313   *       Binary format
1314   * @rmtoll RTC_TR           HT            LL_RTC_TIME_GetHour\n
1315   *         RTC_TR           HU            LL_RTC_TIME_GetHour
1316   * @param  RTCx RTC Instance
1317   * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1318   */
LL_RTC_TIME_GetHour(RTC_TypeDef * RTCx)1319 __STATIC_INLINE uint32_t LL_RTC_TIME_GetHour(RTC_TypeDef *RTCx)
1320 {
1321   return (uint32_t)((READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU))) >> RTC_TR_HU_Pos);
1322 }
1323 
1324 /**
1325   * @brief  Set Minutes in BCD format
1326   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1327   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1328   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
1329   * @rmtoll RTC_TR           MNT           LL_RTC_TIME_SetMinute\n
1330   *         RTC_TR           MNU           LL_RTC_TIME_SetMinute
1331   * @param  RTCx RTC Instance
1332   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
1333   * @retval None
1334   */
LL_RTC_TIME_SetMinute(RTC_TypeDef * RTCx,uint32_t Minutes)1335 __STATIC_INLINE void LL_RTC_TIME_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
1336 {
1337   MODIFY_REG(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU),
1338              (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)));
1339 }
1340 
1341 /**
1342   * @brief  Get Minutes in BCD format
1343   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1344   *       before reading this bit
1345   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1346   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1347   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert minute from BCD
1348   *       to Binary format
1349   * @rmtoll RTC_TR           MNT           LL_RTC_TIME_GetMinute\n
1350   *         RTC_TR           MNU           LL_RTC_TIME_GetMinute
1351   * @param  RTCx RTC Instance
1352   * @retval Value between Min_Data=0x00 and Max_Data=0x59
1353   */
LL_RTC_TIME_GetMinute(RTC_TypeDef * RTCx)1354 __STATIC_INLINE uint32_t LL_RTC_TIME_GetMinute(RTC_TypeDef *RTCx)
1355 {
1356   return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU)) >> RTC_TR_MNU_Pos);
1357 }
1358 
1359 /**
1360   * @brief  Set Seconds in BCD format
1361   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1362   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1363   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
1364   * @rmtoll RTC_TR           ST            LL_RTC_TIME_SetSecond\n
1365   *         RTC_TR           SU            LL_RTC_TIME_SetSecond
1366   * @param  RTCx RTC Instance
1367   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
1368   * @retval None
1369   */
LL_RTC_TIME_SetSecond(RTC_TypeDef * RTCx,uint32_t Seconds)1370 __STATIC_INLINE void LL_RTC_TIME_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
1371 {
1372   MODIFY_REG(RTCx->TR, (RTC_TR_ST | RTC_TR_SU),
1373              (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos)));
1374 }
1375 
1376 /**
1377   * @brief  Get Seconds in BCD format
1378   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1379   *       before reading this bit
1380   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1381   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1382   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD
1383   *       to Binary format
1384   * @rmtoll RTC_TR           ST            LL_RTC_TIME_GetSecond\n
1385   *         RTC_TR           SU            LL_RTC_TIME_GetSecond
1386   * @param  RTCx RTC Instance
1387   * @retval Value between Min_Data=0x00 and Max_Data=0x59
1388   */
LL_RTC_TIME_GetSecond(RTC_TypeDef * RTCx)1389 __STATIC_INLINE uint32_t LL_RTC_TIME_GetSecond(RTC_TypeDef *RTCx)
1390 {
1391   return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_ST | RTC_TR_SU)) >> RTC_TR_SU_Pos);
1392 }
1393 
1394 /**
1395   * @brief  Set time (hour, minute and second) in BCD format
1396   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1397   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1398   * @note TimeFormat and Hours should follow the same format
1399   * @rmtoll RTC_TR           PM            LL_RTC_TIME_Config\n
1400   *         RTC_TR           HT            LL_RTC_TIME_Config\n
1401   *         RTC_TR           HU            LL_RTC_TIME_Config\n
1402   *         RTC_TR           MNT           LL_RTC_TIME_Config\n
1403   *         RTC_TR           MNU           LL_RTC_TIME_Config\n
1404   *         RTC_TR           ST            LL_RTC_TIME_Config\n
1405   *         RTC_TR           SU            LL_RTC_TIME_Config
1406   * @param  RTCx RTC Instance
1407   * @param  Format12_24 This parameter can be one of the following values:
1408   *         @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
1409   *         @arg @ref LL_RTC_TIME_FORMAT_PM
1410   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1411   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
1412   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
1413   * @retval None
1414   */
LL_RTC_TIME_Config(RTC_TypeDef * RTCx,uint32_t Format12_24,uint32_t Hours,uint32_t Minutes,uint32_t Seconds)1415 __STATIC_INLINE void LL_RTC_TIME_Config(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
1416 {
1417   uint32_t temp;
1418 
1419   temp = Format12_24                                                                                    | \
1420          (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos))     | \
1421          (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)) | \
1422          (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos));
1423   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);
1424 }
1425 
1426 /**
1427   * @brief  Get time (hour, minute and second) in BCD format
1428   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1429   *       before reading this bit
1430   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1431   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1432   * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
1433   *       are available to get independently each parameter.
1434   * @rmtoll RTC_TR           HT            LL_RTC_TIME_Get\n
1435   *         RTC_TR           HU            LL_RTC_TIME_Get\n
1436   *         RTC_TR           MNT           LL_RTC_TIME_Get\n
1437   *         RTC_TR           MNU           LL_RTC_TIME_Get\n
1438   *         RTC_TR           ST            LL_RTC_TIME_Get\n
1439   *         RTC_TR           SU            LL_RTC_TIME_Get
1440   * @param  RTCx RTC Instance
1441   * @retval Combination of hours, minutes and seconds (Format: 0x00HHMMSS).
1442   */
LL_RTC_TIME_Get(RTC_TypeDef * RTCx)1443 __STATIC_INLINE uint32_t LL_RTC_TIME_Get(RTC_TypeDef *RTCx)
1444 {
1445   uint32_t temp;
1446 
1447   temp = READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU | RTC_TR_MNT | RTC_TR_MNU | RTC_TR_ST | RTC_TR_SU));
1448   return (uint32_t)((((((temp & RTC_TR_HT) >> RTC_TR_HT_Pos) << 4U) | ((temp & RTC_TR_HU) >> RTC_TR_HU_Pos)) << RTC_OFFSET_HOUR)       |  \
1449                     (((((temp & RTC_TR_MNT) >> RTC_TR_MNT_Pos) << 4U) | ((temp & RTC_TR_MNU) >> RTC_TR_MNU_Pos)) << RTC_OFFSET_MINUTE) | \
1450                     ((((temp & RTC_TR_ST) >> RTC_TR_ST_Pos) << 4U) | ((temp & RTC_TR_SU) >> RTC_TR_SU_Pos)));
1451 }
1452 
1453 /**
1454   * @brief  Memorize whether the daylight saving time change has been performed
1455   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1456   * @rmtoll RTC_CR           BKP           LL_RTC_TIME_EnableDayLightStore
1457   * @param  RTCx RTC Instance
1458   * @retval None
1459   */
LL_RTC_TIME_EnableDayLightStore(RTC_TypeDef * RTCx)1460 __STATIC_INLINE void LL_RTC_TIME_EnableDayLightStore(RTC_TypeDef *RTCx)
1461 {
1462   SET_BIT(RTCx->CR, RTC_CR_BKP);
1463 }
1464 
1465 /**
1466   * @brief  Disable memorization whether the daylight saving time change has been performed.
1467   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1468   * @rmtoll RTC_CR           BKP           LL_RTC_TIME_DisableDayLightStore
1469   * @param  RTCx RTC Instance
1470   * @retval None
1471   */
LL_RTC_TIME_DisableDayLightStore(RTC_TypeDef * RTCx)1472 __STATIC_INLINE void LL_RTC_TIME_DisableDayLightStore(RTC_TypeDef *RTCx)
1473 {
1474   CLEAR_BIT(RTCx->CR, RTC_CR_BKP);
1475 }
1476 
1477 /**
1478   * @brief  Check if RTC Day Light Saving stored operation has been enabled or not
1479   * @rmtoll RTC_CR           BKP           LL_RTC_TIME_IsDayLightStoreEnabled
1480   * @param  RTCx RTC Instance
1481   * @retval State of bit (1 or 0).
1482   */
LL_RTC_TIME_IsDayLightStoreEnabled(RTC_TypeDef * RTCx)1483 __STATIC_INLINE uint32_t LL_RTC_TIME_IsDayLightStoreEnabled(RTC_TypeDef *RTCx)
1484 {
1485   return ((READ_BIT(RTCx->CR, RTC_CR_BKP) == (RTC_CR_BKP)) ? 1U : 0U);
1486 }
1487 
1488 /**
1489   * @brief  Subtract 1 hour (winter time change)
1490   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1491   * @rmtoll RTC_CR           SUB1H         LL_RTC_TIME_DecHour
1492   * @param  RTCx RTC Instance
1493   * @retval None
1494   */
LL_RTC_TIME_DecHour(RTC_TypeDef * RTCx)1495 __STATIC_INLINE void LL_RTC_TIME_DecHour(RTC_TypeDef *RTCx)
1496 {
1497   SET_BIT(RTCx->CR, RTC_CR_SUB1H);
1498 }
1499 
1500 /**
1501   * @brief  Add 1 hour (summer time change)
1502   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1503   * @rmtoll RTC_CR           ADD1H         LL_RTC_TIME_IncHour
1504   * @param  RTCx RTC Instance
1505   * @retval None
1506   */
LL_RTC_TIME_IncHour(RTC_TypeDef * RTCx)1507 __STATIC_INLINE void LL_RTC_TIME_IncHour(RTC_TypeDef *RTCx)
1508 {
1509   SET_BIT(RTCx->CR, RTC_CR_ADD1H);
1510 }
1511 
1512 /**
1513   * @brief  Get Sub second value in the synchronous prescaler counter.
1514   * @note  You can use both SubSeconds value and SecondFraction (PREDIV_S through
1515   *        LL_RTC_GetSynchPrescaler function) terms returned to convert Calendar
1516   *        SubSeconds value in second fraction ratio with time unit following
1517   *        generic formula:
1518   *          ==> Seconds fraction ratio * time_unit= [(SecondFraction-SubSeconds)/(SecondFraction+1)] * time_unit
1519   *        This conversion can be performed only if no shift operation is pending
1520   *        (ie. SHFP=0) when PREDIV_S >= SS.
1521   * @rmtoll RTC_SSR          SS            LL_RTC_TIME_GetSubSecond
1522   * @param  RTCx RTC Instance
1523   * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
1524   *         else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
1525   */
LL_RTC_TIME_GetSubSecond(RTC_TypeDef * RTCx)1526 __STATIC_INLINE uint32_t LL_RTC_TIME_GetSubSecond(RTC_TypeDef *RTCx)
1527 {
1528   return (uint32_t)(READ_BIT(RTCx->SSR, RTC_SSR_SS));
1529 }
1530 
1531 /**
1532   * @brief  Synchronize to a remote clock with a high degree of precision.
1533   * @note   This operation effectively subtracts from (delays) or advance the clock of a fraction of a second.
1534   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1535   * @note   When REFCKON is set, firmware must not write to Shift control register.
1536   * @rmtoll RTC_SHIFTR       ADD1S         LL_RTC_TIME_Synchronize\n
1537   *         RTC_SHIFTR       SUBFS         LL_RTC_TIME_Synchronize
1538   * @param  RTCx RTC Instance
1539   * @param  ShiftSecond This parameter can be one of the following values:
1540   *         @arg @ref LL_RTC_SHIFT_SECOND_DELAY
1541   *         @arg @ref LL_RTC_SHIFT_SECOND_ADVANCE
1542   * @param  Fraction Number of Seconds Fractions (any value from 0 to 0x7FFF)
1543   * @retval None
1544   */
LL_RTC_TIME_Synchronize(RTC_TypeDef * RTCx,uint32_t ShiftSecond,uint32_t Fraction)1545 __STATIC_INLINE void LL_RTC_TIME_Synchronize(RTC_TypeDef *RTCx, uint32_t ShiftSecond, uint32_t Fraction)
1546 {
1547   WRITE_REG(RTCx->SHIFTR, ShiftSecond | Fraction);
1548 }
1549 
1550 /**
1551   * @}
1552   */
1553 
1554 /** @defgroup RTC_LL_EF_Date Date
1555   * @{
1556   */
1557 
1558 /**
1559   * @brief  Set Year in BCD format
1560   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Year from binary to BCD format
1561   * @rmtoll RTC_DR           YT            LL_RTC_DATE_SetYear\n
1562   *         RTC_DR           YU            LL_RTC_DATE_SetYear
1563   * @param  RTCx RTC Instance
1564   * @param  Year Value between Min_Data=0x00 and Max_Data=0x99
1565   * @retval None
1566   */
LL_RTC_DATE_SetYear(RTC_TypeDef * RTCx,uint32_t Year)1567 __STATIC_INLINE void LL_RTC_DATE_SetYear(RTC_TypeDef *RTCx, uint32_t Year)
1568 {
1569   MODIFY_REG(RTCx->DR, (RTC_DR_YT | RTC_DR_YU),
1570              (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos)));
1571 }
1572 
1573 /**
1574   * @brief  Get Year in BCD format
1575   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1576   *       before reading this bit
1577   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Year from BCD to Binary format
1578   * @rmtoll RTC_DR           YT            LL_RTC_DATE_GetYear\n
1579   *         RTC_DR           YU            LL_RTC_DATE_GetYear
1580   * @param  RTCx RTC Instance
1581   * @retval Value between Min_Data=0x00 and Max_Data=0x99
1582   */
LL_RTC_DATE_GetYear(RTC_TypeDef * RTCx)1583 __STATIC_INLINE uint32_t LL_RTC_DATE_GetYear(RTC_TypeDef *RTCx)
1584 {
1585   return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_YT | RTC_DR_YU))) >> RTC_DR_YU_Pos);
1586 }
1587 
1588 /**
1589   * @brief  Set Week day
1590   * @rmtoll RTC_DR           WDU           LL_RTC_DATE_SetWeekDay
1591   * @param  RTCx RTC Instance
1592   * @param  WeekDay This parameter can be one of the following values:
1593   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
1594   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
1595   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1596   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
1597   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
1598   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
1599   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
1600   * @retval None
1601   */
LL_RTC_DATE_SetWeekDay(RTC_TypeDef * RTCx,uint32_t WeekDay)1602 __STATIC_INLINE void LL_RTC_DATE_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
1603 {
1604   MODIFY_REG(RTCx->DR, RTC_DR_WDU, WeekDay << RTC_DR_WDU_Pos);
1605 }
1606 
1607 /**
1608   * @brief  Get Week day
1609   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1610   *       before reading this bit
1611   * @rmtoll RTC_DR           WDU           LL_RTC_DATE_GetWeekDay
1612   * @param  RTCx RTC Instance
1613   * @retval Returned value can be one of the following values:
1614   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
1615   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
1616   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1617   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
1618   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
1619   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
1620   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
1621   */
LL_RTC_DATE_GetWeekDay(RTC_TypeDef * RTCx)1622 __STATIC_INLINE uint32_t LL_RTC_DATE_GetWeekDay(RTC_TypeDef *RTCx)
1623 {
1624   return (uint32_t)(READ_BIT(RTCx->DR, RTC_DR_WDU) >> RTC_DR_WDU_Pos);
1625 }
1626 
1627 /**
1628   * @brief  Set Month in BCD format
1629   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Month from binary to BCD format
1630   * @rmtoll RTC_DR           MT            LL_RTC_DATE_SetMonth\n
1631   *         RTC_DR           MU            LL_RTC_DATE_SetMonth
1632   * @param  RTCx RTC Instance
1633   * @param  Month This parameter can be one of the following values:
1634   *         @arg @ref LL_RTC_MONTH_JANUARY
1635   *         @arg @ref LL_RTC_MONTH_FEBRUARY
1636   *         @arg @ref LL_RTC_MONTH_MARCH
1637   *         @arg @ref LL_RTC_MONTH_APRIL
1638   *         @arg @ref LL_RTC_MONTH_MAY
1639   *         @arg @ref LL_RTC_MONTH_JUNE
1640   *         @arg @ref LL_RTC_MONTH_JULY
1641   *         @arg @ref LL_RTC_MONTH_AUGUST
1642   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
1643   *         @arg @ref LL_RTC_MONTH_OCTOBER
1644   *         @arg @ref LL_RTC_MONTH_NOVEMBER
1645   *         @arg @ref LL_RTC_MONTH_DECEMBER
1646   * @retval None
1647   */
LL_RTC_DATE_SetMonth(RTC_TypeDef * RTCx,uint32_t Month)1648 __STATIC_INLINE void LL_RTC_DATE_SetMonth(RTC_TypeDef *RTCx, uint32_t Month)
1649 {
1650   MODIFY_REG(RTCx->DR, (RTC_DR_MT | RTC_DR_MU),
1651              (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)));
1652 }
1653 
1654 /**
1655   * @brief  Get Month in BCD format
1656   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1657   *       before reading this bit
1658   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
1659   * @rmtoll RTC_DR           MT            LL_RTC_DATE_GetMonth\n
1660   *         RTC_DR           MU            LL_RTC_DATE_GetMonth
1661   * @param  RTCx RTC Instance
1662   * @retval Returned value can be one of the following values:
1663   *         @arg @ref LL_RTC_MONTH_JANUARY
1664   *         @arg @ref LL_RTC_MONTH_FEBRUARY
1665   *         @arg @ref LL_RTC_MONTH_MARCH
1666   *         @arg @ref LL_RTC_MONTH_APRIL
1667   *         @arg @ref LL_RTC_MONTH_MAY
1668   *         @arg @ref LL_RTC_MONTH_JUNE
1669   *         @arg @ref LL_RTC_MONTH_JULY
1670   *         @arg @ref LL_RTC_MONTH_AUGUST
1671   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
1672   *         @arg @ref LL_RTC_MONTH_OCTOBER
1673   *         @arg @ref LL_RTC_MONTH_NOVEMBER
1674   *         @arg @ref LL_RTC_MONTH_DECEMBER
1675   */
LL_RTC_DATE_GetMonth(RTC_TypeDef * RTCx)1676 __STATIC_INLINE uint32_t LL_RTC_DATE_GetMonth(RTC_TypeDef *RTCx)
1677 {
1678   return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_MT | RTC_DR_MU))) >> RTC_DR_MU_Pos);
1679 }
1680 
1681 /**
1682   * @brief  Set Day in BCD format
1683   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
1684   * @rmtoll RTC_DR           DT            LL_RTC_DATE_SetDay\n
1685   *         RTC_DR           DU            LL_RTC_DATE_SetDay
1686   * @param  RTCx RTC Instance
1687   * @param  Day Value between Min_Data=0x01 and Max_Data=0x31
1688   * @retval None
1689   */
LL_RTC_DATE_SetDay(RTC_TypeDef * RTCx,uint32_t Day)1690 __STATIC_INLINE void LL_RTC_DATE_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
1691 {
1692   MODIFY_REG(RTCx->DR, (RTC_DR_DT | RTC_DR_DU),
1693              (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos)));
1694 }
1695 
1696 /**
1697   * @brief  Get Day in BCD format
1698   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1699   *       before reading this bit
1700   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
1701   * @rmtoll RTC_DR           DT            LL_RTC_DATE_GetDay\n
1702   *         RTC_DR           DU            LL_RTC_DATE_GetDay
1703   * @param  RTCx RTC Instance
1704   * @retval Value between Min_Data=0x01 and Max_Data=0x31
1705   */
LL_RTC_DATE_GetDay(RTC_TypeDef * RTCx)1706 __STATIC_INLINE uint32_t LL_RTC_DATE_GetDay(RTC_TypeDef *RTCx)
1707 {
1708   return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_DT | RTC_DR_DU))) >> RTC_DR_DU_Pos);
1709 }
1710 
1711 /**
1712   * @brief  Set date (WeekDay, Day, Month and Year) in BCD format
1713   * @rmtoll RTC_DR           WDU           LL_RTC_DATE_Config\n
1714   *         RTC_DR           MT            LL_RTC_DATE_Config\n
1715   *         RTC_DR           MU            LL_RTC_DATE_Config\n
1716   *         RTC_DR           DT            LL_RTC_DATE_Config\n
1717   *         RTC_DR           DU            LL_RTC_DATE_Config\n
1718   *         RTC_DR           YT            LL_RTC_DATE_Config\n
1719   *         RTC_DR           YU            LL_RTC_DATE_Config
1720   * @param  RTCx RTC Instance
1721   * @param  WeekDay This parameter can be one of the following values:
1722   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
1723   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
1724   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1725   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
1726   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
1727   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
1728   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
1729   * @param  Day Value between Min_Data=0x01 and Max_Data=0x31
1730   * @param  Month This parameter can be one of the following values:
1731   *         @arg @ref LL_RTC_MONTH_JANUARY
1732   *         @arg @ref LL_RTC_MONTH_FEBRUARY
1733   *         @arg @ref LL_RTC_MONTH_MARCH
1734   *         @arg @ref LL_RTC_MONTH_APRIL
1735   *         @arg @ref LL_RTC_MONTH_MAY
1736   *         @arg @ref LL_RTC_MONTH_JUNE
1737   *         @arg @ref LL_RTC_MONTH_JULY
1738   *         @arg @ref LL_RTC_MONTH_AUGUST
1739   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
1740   *         @arg @ref LL_RTC_MONTH_OCTOBER
1741   *         @arg @ref LL_RTC_MONTH_NOVEMBER
1742   *         @arg @ref LL_RTC_MONTH_DECEMBER
1743   * @param  Year Value between Min_Data=0x00 and Max_Data=0x99
1744   * @retval None
1745   */
LL_RTC_DATE_Config(RTC_TypeDef * RTCx,uint32_t WeekDay,uint32_t Day,uint32_t Month,uint32_t Year)1746 __STATIC_INLINE void LL_RTC_DATE_Config(RTC_TypeDef *RTCx, uint32_t WeekDay, uint32_t Day, uint32_t Month, uint32_t Year)
1747 {
1748   uint32_t temp;
1749 
1750   temp = (WeekDay << RTC_DR_WDU_Pos)                                                        | \
1751          (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos))   | \
1752          (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)) | \
1753          (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos));
1754 
1755   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);
1756 }
1757 
1758 /**
1759   * @brief  Get date (WeekDay, Day, Month and Year) in BCD format
1760   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1761   *       before reading this bit
1762   * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_YEAR, __LL_RTC_GET_MONTH,
1763   * and __LL_RTC_GET_DAY are available to get independently each parameter.
1764   * @rmtoll RTC_DR           WDU           LL_RTC_DATE_Get\n
1765   *         RTC_DR           MT            LL_RTC_DATE_Get\n
1766   *         RTC_DR           MU            LL_RTC_DATE_Get\n
1767   *         RTC_DR           DT            LL_RTC_DATE_Get\n
1768   *         RTC_DR           DU            LL_RTC_DATE_Get\n
1769   *         RTC_DR           YT            LL_RTC_DATE_Get\n
1770   *         RTC_DR           YU            LL_RTC_DATE_Get
1771   * @param  RTCx RTC Instance
1772   * @retval Combination of WeekDay, Day, Month and Year (Format: 0xWWDDMMYY).
1773   */
LL_RTC_DATE_Get(RTC_TypeDef * RTCx)1774 __STATIC_INLINE uint32_t LL_RTC_DATE_Get(RTC_TypeDef *RTCx)
1775 {
1776   uint32_t temp;
1777 
1778   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));
1779   return (uint32_t)((((temp & RTC_DR_WDU) >> RTC_DR_WDU_Pos) << RTC_OFFSET_WEEKDAY) | \
1780                     (((((temp & RTC_DR_DT) >> RTC_DR_DT_Pos) << 4U) | ((temp & RTC_DR_DU) >> RTC_DR_DU_Pos)) << RTC_OFFSET_DAY)   | \
1781                     (((((temp & RTC_DR_MT) >> RTC_DR_MT_Pos) << 4U) | ((temp & RTC_DR_MU) >> RTC_DR_MU_Pos)) << RTC_OFFSET_MONTH) | \
1782                     ((((temp & RTC_DR_YT) >> RTC_DR_YT_Pos) << 4U) | ((temp & RTC_DR_YU) >> RTC_DR_YU_Pos)));
1783 }
1784 
1785 /**
1786   * @}
1787   */
1788 
1789 /** @defgroup RTC_LL_EF_ALARMA ALARMA
1790   * @{
1791   */
1792 
1793 /**
1794   * @brief  Enable Alarm A
1795   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1796   * @rmtoll RTC_CR           ALRAE         LL_RTC_ALMA_Enable
1797   * @param  RTCx RTC Instance
1798   * @retval None
1799   */
LL_RTC_ALMA_Enable(RTC_TypeDef * RTCx)1800 __STATIC_INLINE void LL_RTC_ALMA_Enable(RTC_TypeDef *RTCx)
1801 {
1802   SET_BIT(RTCx->CR, RTC_CR_ALRAE);
1803 }
1804 
1805 /**
1806   * @brief  Disable Alarm A
1807   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1808   * @rmtoll RTC_CR           ALRAE         LL_RTC_ALMA_Disable
1809   * @param  RTCx RTC Instance
1810   * @retval None
1811   */
LL_RTC_ALMA_Disable(RTC_TypeDef * RTCx)1812 __STATIC_INLINE void LL_RTC_ALMA_Disable(RTC_TypeDef *RTCx)
1813 {
1814   CLEAR_BIT(RTCx->CR, RTC_CR_ALRAE);
1815 }
1816 
1817 /**
1818   * @brief  Specify the Alarm A masks.
1819   * @rmtoll RTC_ALRMAR       MSK4          LL_RTC_ALMA_SetMask\n
1820   *         RTC_ALRMAR       MSK3          LL_RTC_ALMA_SetMask\n
1821   *         RTC_ALRMAR       MSK2          LL_RTC_ALMA_SetMask\n
1822   *         RTC_ALRMAR       MSK1          LL_RTC_ALMA_SetMask
1823   * @param  RTCx RTC Instance
1824   * @param  Mask This parameter can be a combination of the following values:
1825   *         @arg @ref LL_RTC_ALMA_MASK_NONE
1826   *         @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
1827   *         @arg @ref LL_RTC_ALMA_MASK_HOURS
1828   *         @arg @ref LL_RTC_ALMA_MASK_MINUTES
1829   *         @arg @ref LL_RTC_ALMA_MASK_SECONDS
1830   *         @arg @ref LL_RTC_ALMA_MASK_ALL
1831   * @retval None
1832   */
LL_RTC_ALMA_SetMask(RTC_TypeDef * RTCx,uint32_t Mask)1833 __STATIC_INLINE void LL_RTC_ALMA_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
1834 {
1835   MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1, Mask);
1836 }
1837 
1838 /**
1839   * @brief  Get the Alarm A masks.
1840   * @rmtoll RTC_ALRMAR       MSK4          LL_RTC_ALMA_GetMask\n
1841   *         RTC_ALRMAR       MSK3          LL_RTC_ALMA_GetMask\n
1842   *         RTC_ALRMAR       MSK2          LL_RTC_ALMA_GetMask\n
1843   *         RTC_ALRMAR       MSK1          LL_RTC_ALMA_GetMask
1844   * @param  RTCx RTC Instance
1845   * @retval Returned value can be can be a combination of the following values:
1846   *         @arg @ref LL_RTC_ALMA_MASK_NONE
1847   *         @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
1848   *         @arg @ref LL_RTC_ALMA_MASK_HOURS
1849   *         @arg @ref LL_RTC_ALMA_MASK_MINUTES
1850   *         @arg @ref LL_RTC_ALMA_MASK_SECONDS
1851   *         @arg @ref LL_RTC_ALMA_MASK_ALL
1852   */
LL_RTC_ALMA_GetMask(RTC_TypeDef * RTCx)1853 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMask(RTC_TypeDef *RTCx)
1854 {
1855   return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1));
1856 }
1857 
1858 /**
1859   * @brief  Enable AlarmA Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
1860   * @rmtoll RTC_ALRMAR       WDSEL         LL_RTC_ALMA_EnableWeekday
1861   * @param  RTCx RTC Instance
1862   * @retval None
1863   */
LL_RTC_ALMA_EnableWeekday(RTC_TypeDef * RTCx)1864 __STATIC_INLINE void LL_RTC_ALMA_EnableWeekday(RTC_TypeDef *RTCx)
1865 {
1866   SET_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
1867 }
1868 
1869 /**
1870   * @brief  Disable AlarmA Week day selection (DU[3:0] represents the date )
1871   * @rmtoll RTC_ALRMAR       WDSEL         LL_RTC_ALMA_DisableWeekday
1872   * @param  RTCx RTC Instance
1873   * @retval None
1874   */
LL_RTC_ALMA_DisableWeekday(RTC_TypeDef * RTCx)1875 __STATIC_INLINE void LL_RTC_ALMA_DisableWeekday(RTC_TypeDef *RTCx)
1876 {
1877   CLEAR_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
1878 }
1879 
1880 /**
1881   * @brief  Set ALARM A Day in BCD format
1882   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
1883   * @rmtoll RTC_ALRMAR       DT            LL_RTC_ALMA_SetDay\n
1884   *         RTC_ALRMAR       DU            LL_RTC_ALMA_SetDay
1885   * @param  RTCx RTC Instance
1886   * @param  Day Value between Min_Data=0x01 and Max_Data=0x31
1887   * @retval None
1888   */
LL_RTC_ALMA_SetDay(RTC_TypeDef * RTCx,uint32_t Day)1889 __STATIC_INLINE void LL_RTC_ALMA_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
1890 {
1891   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU),
1892              (((Day & 0xF0U) << (RTC_ALRMAR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMAR_DU_Pos)));
1893 }
1894 
1895 /**
1896   * @brief  Get ALARM A Day in BCD format
1897   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
1898   * @rmtoll RTC_ALRMAR       DT            LL_RTC_ALMA_GetDay\n
1899   *         RTC_ALRMAR       DU            LL_RTC_ALMA_GetDay
1900   * @param  RTCx RTC Instance
1901   * @retval Value between Min_Data=0x01 and Max_Data=0x31
1902   */
LL_RTC_ALMA_GetDay(RTC_TypeDef * RTCx)1903 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetDay(RTC_TypeDef *RTCx)
1904 {
1905   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU))) >> RTC_ALRMAR_DU_Pos);
1906 }
1907 
1908 /**
1909   * @brief  Set ALARM A Weekday
1910   * @rmtoll RTC_ALRMAR       DU            LL_RTC_ALMA_SetWeekDay
1911   * @param  RTCx RTC Instance
1912   * @param  WeekDay This parameter can be one of the following values:
1913   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
1914   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
1915   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1916   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
1917   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
1918   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
1919   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
1920   * @retval None
1921   */
LL_RTC_ALMA_SetWeekDay(RTC_TypeDef * RTCx,uint32_t WeekDay)1922 __STATIC_INLINE void LL_RTC_ALMA_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
1923 {
1924   MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_DU, WeekDay << RTC_ALRMAR_DU_Pos);
1925 }
1926 
1927 /**
1928   * @brief  Get ALARM A Weekday
1929   * @rmtoll RTC_ALRMAR       DU            LL_RTC_ALMA_GetWeekDay
1930   * @param  RTCx RTC Instance
1931   * @retval Returned value can be one of the following values:
1932   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
1933   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
1934   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1935   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
1936   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
1937   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
1938   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
1939   */
LL_RTC_ALMA_GetWeekDay(RTC_TypeDef * RTCx)1940 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetWeekDay(RTC_TypeDef *RTCx)
1941 {
1942   return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_DU) >> RTC_ALRMAR_DU_Pos);
1943 }
1944 
1945 /**
1946   * @brief  Set Alarm A time format (AM/24-hour or PM notation)
1947   * @rmtoll RTC_ALRMAR       PM            LL_RTC_ALMA_SetTimeFormat
1948   * @param  RTCx RTC Instance
1949   * @param  TimeFormat This parameter can be one of the following values:
1950   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
1951   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
1952   * @retval None
1953   */
LL_RTC_ALMA_SetTimeFormat(RTC_TypeDef * RTCx,uint32_t TimeFormat)1954 __STATIC_INLINE void LL_RTC_ALMA_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
1955 {
1956   MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_PM, TimeFormat);
1957 }
1958 
1959 /**
1960   * @brief  Get Alarm A time format (AM or PM notation)
1961   * @rmtoll RTC_ALRMAR       PM            LL_RTC_ALMA_GetTimeFormat
1962   * @param  RTCx RTC Instance
1963   * @retval Returned value can be one of the following values:
1964   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
1965   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
1966   */
LL_RTC_ALMA_GetTimeFormat(RTC_TypeDef * RTCx)1967 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTimeFormat(RTC_TypeDef *RTCx)
1968 {
1969   return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_PM));
1970 }
1971 
1972 /**
1973   * @brief  Set ALARM A Hours in BCD format
1974   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
1975   * @rmtoll RTC_ALRMAR       HT            LL_RTC_ALMA_SetHour\n
1976   *         RTC_ALRMAR       HU            LL_RTC_ALMA_SetHour
1977   * @param  RTCx RTC Instance
1978   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1979   * @retval None
1980   */
LL_RTC_ALMA_SetHour(RTC_TypeDef * RTCx,uint32_t Hours)1981 __STATIC_INLINE void LL_RTC_ALMA_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
1982 {
1983   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU),
1984              (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos)));
1985 }
1986 
1987 /**
1988   * @brief  Get ALARM A Hours in BCD format
1989   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
1990   * @rmtoll RTC_ALRMAR       HT            LL_RTC_ALMA_GetHour\n
1991   *         RTC_ALRMAR       HU            LL_RTC_ALMA_GetHour
1992   * @param  RTCx RTC Instance
1993   * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1994   */
LL_RTC_ALMA_GetHour(RTC_TypeDef * RTCx)1995 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetHour(RTC_TypeDef *RTCx)
1996 {
1997   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU))) >> RTC_ALRMAR_HU_Pos);
1998 }
1999 
2000 /**
2001   * @brief  Set ALARM A Minutes in BCD format
2002   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
2003   * @rmtoll RTC_ALRMAR       MNT           LL_RTC_ALMA_SetMinute\n
2004   *         RTC_ALRMAR       MNU           LL_RTC_ALMA_SetMinute
2005   * @param  RTCx RTC Instance
2006   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
2007   * @retval None
2008   */
LL_RTC_ALMA_SetMinute(RTC_TypeDef * RTCx,uint32_t Minutes)2009 __STATIC_INLINE void LL_RTC_ALMA_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
2010 {
2011   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU),
2012              (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)));
2013 }
2014 
2015 /**
2016   * @brief  Get ALARM A Minutes in BCD format
2017   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
2018   * @rmtoll RTC_ALRMAR       MNT           LL_RTC_ALMA_GetMinute\n
2019   *         RTC_ALRMAR       MNU           LL_RTC_ALMA_GetMinute
2020   * @param  RTCx RTC Instance
2021   * @retval Value between Min_Data=0x00 and Max_Data=0x59
2022   */
LL_RTC_ALMA_GetMinute(RTC_TypeDef * RTCx)2023 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMinute(RTC_TypeDef *RTCx)
2024 {
2025   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU))) >> RTC_ALRMAR_MNU_Pos);
2026 }
2027 
2028 /**
2029   * @brief  Set ALARM A Seconds in BCD format
2030   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
2031   * @rmtoll RTC_ALRMAR       ST            LL_RTC_ALMA_SetSecond\n
2032   *         RTC_ALRMAR       SU            LL_RTC_ALMA_SetSecond
2033   * @param  RTCx RTC Instance
2034   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
2035   * @retval None
2036   */
LL_RTC_ALMA_SetSecond(RTC_TypeDef * RTCx,uint32_t Seconds)2037 __STATIC_INLINE void LL_RTC_ALMA_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
2038 {
2039   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU),
2040              (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos)));
2041 }
2042 
2043 /**
2044   * @brief  Get ALARM A Seconds in BCD format
2045   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
2046   * @rmtoll RTC_ALRMAR       ST            LL_RTC_ALMA_GetSecond\n
2047   *         RTC_ALRMAR       SU            LL_RTC_ALMA_GetSecond
2048   * @param  RTCx RTC Instance
2049   * @retval Value between Min_Data=0x00 and Max_Data=0x59
2050   */
LL_RTC_ALMA_GetSecond(RTC_TypeDef * RTCx)2051 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSecond(RTC_TypeDef *RTCx)
2052 {
2053   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU))) >> RTC_ALRMAR_SU_Pos);
2054 }
2055 
2056 /**
2057   * @brief  Set Alarm A Time (hour, minute and second) in BCD format
2058   * @rmtoll RTC_ALRMAR       PM            LL_RTC_ALMA_ConfigTime\n
2059   *         RTC_ALRMAR       HT            LL_RTC_ALMA_ConfigTime\n
2060   *         RTC_ALRMAR       HU            LL_RTC_ALMA_ConfigTime\n
2061   *         RTC_ALRMAR       MNT           LL_RTC_ALMA_ConfigTime\n
2062   *         RTC_ALRMAR       MNU           LL_RTC_ALMA_ConfigTime\n
2063   *         RTC_ALRMAR       ST            LL_RTC_ALMA_ConfigTime\n
2064   *         RTC_ALRMAR       SU            LL_RTC_ALMA_ConfigTime
2065   * @param  RTCx RTC Instance
2066   * @param  Format12_24 This parameter can be one of the following values:
2067   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
2068   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
2069   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2070   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
2071   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
2072   * @retval None
2073   */
LL_RTC_ALMA_ConfigTime(RTC_TypeDef * RTCx,uint32_t Format12_24,uint32_t Hours,uint32_t Minutes,uint32_t Seconds)2074 __STATIC_INLINE void LL_RTC_ALMA_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
2075 {
2076   uint32_t temp;
2077 
2078   temp = Format12_24 | (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos))    | \
2079          (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)) | \
2080          (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos));
2081 
2082   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);
2083 }
2084 
2085 /**
2086   * @brief  Get Alarm B Time (hour, minute and second) in BCD format
2087   * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
2088   * are available to get independently each parameter.
2089   * @rmtoll RTC_ALRMAR       HT            LL_RTC_ALMA_GetTime\n
2090   *         RTC_ALRMAR       HU            LL_RTC_ALMA_GetTime\n
2091   *         RTC_ALRMAR       MNT           LL_RTC_ALMA_GetTime\n
2092   *         RTC_ALRMAR       MNU           LL_RTC_ALMA_GetTime\n
2093   *         RTC_ALRMAR       ST            LL_RTC_ALMA_GetTime\n
2094   *         RTC_ALRMAR       SU            LL_RTC_ALMA_GetTime
2095   * @param  RTCx RTC Instance
2096   * @retval Combination of hours, minutes and seconds.
2097   */
LL_RTC_ALMA_GetTime(RTC_TypeDef * RTCx)2098 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTime(RTC_TypeDef *RTCx)
2099 {
2100   return (uint32_t)((LL_RTC_ALMA_GetHour(RTCx) << RTC_OFFSET_HOUR) | (LL_RTC_ALMA_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMA_GetSecond(RTCx));
2101 }
2102 
2103 /**
2104   * @brief  Set Alarm A Mask the most-significant bits starting at this bit
2105   * @note This register can be written only when ALRAE is reset in RTC_CR register,
2106   *       or in initialization mode.
2107   * @rmtoll RTC_ALRMASSR     MASKSS        LL_RTC_ALMA_SetSubSecondMask
2108   * @param  RTCx RTC Instance
2109   * @param  Mask If binary mode is none, Value between Min_Data=0x0 and Max_Data=0xF
2110   *              else Value between Min_Data=0x0 and Max_Data=0x3F
2111   * @retval None
2112   */
LL_RTC_ALMA_SetSubSecondMask(RTC_TypeDef * RTCx,uint32_t Mask)2113 __STATIC_INLINE void LL_RTC_ALMA_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
2114 {
2115   MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS, Mask << RTC_ALRMASSR_MASKSS_Pos);
2116 }
2117 
2118 /**
2119   * @brief  Get Alarm A Mask the most-significant bits starting at this bit
2120   * @rmtoll RTC_ALRMASSR     MASKSS        LL_RTC_ALMA_GetSubSecondMask
2121   * @param  RTCx RTC Instance
2122   * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0xF
2123   *         else Value between Min_Data=0x0 and Max_Data=0x3F
2124   */
LL_RTC_ALMA_GetSubSecondMask(RTC_TypeDef * RTCx)2125 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecondMask(RTC_TypeDef *RTCx)
2126 {
2127   return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS) >> RTC_ALRMASSR_MASKSS_Pos);
2128 }
2129 
2130 /**
2131   * @brief  Set Alarm A Binary mode auto clear
2132   * @note This register can be written only when ALRAE is reset in RTC_CR register,
2133   *       or in initialization mode.
2134   * @rmtoll RTC_ALRABINR     SSCLR        LL_RTC_ALMA_SetBinAutoClr
2135   * @param  RTCx RTC Instance
2136   * @param  BinaryAutoClr This parameter can be one of the following values:
2137   *         @arg @ref LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_NO
2138   *         @arg @ref LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_YES
2139   * @retval None
2140   */
LL_RTC_ALMA_SetBinAutoClr(RTC_TypeDef * RTCx,uint32_t BinaryAutoClr)2141 __STATIC_INLINE void LL_RTC_ALMA_SetBinAutoClr(RTC_TypeDef *RTCx, uint32_t BinaryAutoClr)
2142 {
2143   MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_SSCLR, BinaryAutoClr);
2144 }
2145 
2146 /**
2147   * @brief  Get Alarm A Binary mode auto clear
2148   * @rmtoll RTC_ALRABINR     SSCLR        LL_RTC_ALMA_GetBinAutoClr
2149   * @param  RTCx RTC Instance
2150   * @retval It can be one of the following values:
2151   *         @arg @ref LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_NO
2152   *         @arg @ref LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_YES
2153   */
LL_RTC_ALMA_GetBinAutoClr(RTC_TypeDef * RTCx)2154 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetBinAutoClr(RTC_TypeDef *RTCx)
2155 {
2156   return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_SSCLR));
2157 }
2158 
2159 /**
2160   * @brief  Set Alarm A Sub seconds value
2161   * @rmtoll RTC_ALRMABINR     SS            LL_RTC_ALMA_SetSubSecond
2162   * @param  RTCx RTC Instance
2163   * @param  Subsecond  If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
2164   *                    else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
2165   * @retval None
2166   */
LL_RTC_ALMA_SetSubSecond(RTC_TypeDef * RTCx,uint32_t Subsecond)2167 __STATIC_INLINE void LL_RTC_ALMA_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
2168 {
2169   MODIFY_REG(RTCx->ALRABINR, RTC_ALRABINR_SS, Subsecond);
2170 }
2171 
2172 /**
2173   * @brief  Get Alarm A Sub seconds value
2174   * @rmtoll RTC_ALRMABINR     SS            LL_RTC_ALMA_GetSubSecond
2175   * @param  RTCx RTC Instance
2176   * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
2177   *         else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
2178   */
LL_RTC_ALMA_GetSubSecond(RTC_TypeDef * RTCx)2179 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecond(RTC_TypeDef *RTCx)
2180 {
2181   return (uint32_t)(READ_BIT(RTCx->ALRABINR, RTC_ALRABINR_SS));
2182 }
2183 
2184 /**
2185   * @}
2186   */
2187 
2188 /** @defgroup RTC_LL_EF_ALARMB ALARMB
2189   * @{
2190   */
2191 
2192 /**
2193   * @brief  Enable Alarm B
2194   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2195   * @rmtoll RTC_CR           ALRBE         LL_RTC_ALMB_Enable
2196   * @param  RTCx RTC Instance
2197   * @retval None
2198   */
LL_RTC_ALMB_Enable(RTC_TypeDef * RTCx)2199 __STATIC_INLINE void LL_RTC_ALMB_Enable(RTC_TypeDef *RTCx)
2200 {
2201   SET_BIT(RTCx->CR, RTC_CR_ALRBE);
2202 }
2203 
2204 /**
2205   * @brief  Disable Alarm B
2206   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2207   * @rmtoll RTC_CR           ALRBE         LL_RTC_ALMB_Disable
2208   * @param  RTCx RTC Instance
2209   * @retval None
2210   */
LL_RTC_ALMB_Disable(RTC_TypeDef * RTCx)2211 __STATIC_INLINE void LL_RTC_ALMB_Disable(RTC_TypeDef *RTCx)
2212 {
2213   CLEAR_BIT(RTCx->CR, RTC_CR_ALRBE);
2214 }
2215 
2216 /**
2217   * @brief  Specify the Alarm B masks.
2218   * @rmtoll RTC_ALRMBR       MSK4          LL_RTC_ALMB_SetMask\n
2219   *         RTC_ALRMBR       MSK3          LL_RTC_ALMB_SetMask\n
2220   *         RTC_ALRMBR       MSK2          LL_RTC_ALMB_SetMask\n
2221   *         RTC_ALRMBR       MSK1          LL_RTC_ALMB_SetMask
2222   * @param  RTCx RTC Instance
2223   * @param  Mask This parameter can be a combination of the following values:
2224   *         @arg @ref LL_RTC_ALMB_MASK_NONE
2225   *         @arg @ref LL_RTC_ALMB_MASK_DATEWEEKDAY
2226   *         @arg @ref LL_RTC_ALMB_MASK_HOURS
2227   *         @arg @ref LL_RTC_ALMB_MASK_MINUTES
2228   *         @arg @ref LL_RTC_ALMB_MASK_SECONDS
2229   *         @arg @ref LL_RTC_ALMB_MASK_ALL
2230   * @retval None
2231   */
LL_RTC_ALMB_SetMask(RTC_TypeDef * RTCx,uint32_t Mask)2232 __STATIC_INLINE void LL_RTC_ALMB_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
2233 {
2234   MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1, Mask);
2235 }
2236 
2237 /**
2238   * @brief  Get the Alarm B masks.
2239   * @rmtoll RTC_ALRMBR       MSK4          LL_RTC_ALMB_GetMask\n
2240   *         RTC_ALRMBR       MSK3          LL_RTC_ALMB_GetMask\n
2241   *         RTC_ALRMBR       MSK2          LL_RTC_ALMB_GetMask\n
2242   *         RTC_ALRMBR       MSK1          LL_RTC_ALMB_GetMask
2243   * @param  RTCx RTC Instance
2244   * @retval Returned value can be can be a combination of the following values:
2245   *         @arg @ref LL_RTC_ALMB_MASK_NONE
2246   *         @arg @ref LL_RTC_ALMB_MASK_DATEWEEKDAY
2247   *         @arg @ref LL_RTC_ALMB_MASK_HOURS
2248   *         @arg @ref LL_RTC_ALMB_MASK_MINUTES
2249   *         @arg @ref LL_RTC_ALMB_MASK_SECONDS
2250   *         @arg @ref LL_RTC_ALMB_MASK_ALL
2251   */
LL_RTC_ALMB_GetMask(RTC_TypeDef * RTCx)2252 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetMask(RTC_TypeDef *RTCx)
2253 {
2254   return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1));
2255 }
2256 
2257 /**
2258   * @brief  Enable AlarmB Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
2259   * @rmtoll RTC_ALRMBR       WDSEL         LL_RTC_ALMB_EnableWeekday
2260   * @param  RTCx RTC Instance
2261   * @retval None
2262   */
LL_RTC_ALMB_EnableWeekday(RTC_TypeDef * RTCx)2263 __STATIC_INLINE void LL_RTC_ALMB_EnableWeekday(RTC_TypeDef *RTCx)
2264 {
2265   SET_BIT(RTCx->ALRMBR, RTC_ALRMBR_WDSEL);
2266 }
2267 
2268 /**
2269   * @brief  Disable AlarmB Week day selection (DU[3:0] represents the date )
2270   * @rmtoll RTC_ALRMBR       WDSEL         LL_RTC_ALMB_DisableWeekday
2271   * @param  RTCx RTC Instance
2272   * @retval None
2273   */
LL_RTC_ALMB_DisableWeekday(RTC_TypeDef * RTCx)2274 __STATIC_INLINE void LL_RTC_ALMB_DisableWeekday(RTC_TypeDef *RTCx)
2275 {
2276   CLEAR_BIT(RTCx->ALRMBR, RTC_ALRMBR_WDSEL);
2277 }
2278 
2279 /**
2280   * @brief  Set ALARM B Day in BCD format
2281   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
2282   * @rmtoll RTC_ALRMBR       DT            LL_RTC_ALMB_SetDay\n
2283   *         RTC_ALRMBR       DU            LL_RTC_ALMB_SetDay
2284   * @param  RTCx RTC Instance
2285   * @param  Day Value between Min_Data=0x01 and Max_Data=0x31
2286   * @retval None
2287   */
LL_RTC_ALMB_SetDay(RTC_TypeDef * RTCx,uint32_t Day)2288 __STATIC_INLINE void LL_RTC_ALMB_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
2289 {
2290   MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_DT | RTC_ALRMBR_DU),
2291              (((Day & 0xF0U) << (RTC_ALRMBR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMBR_DU_Pos)));
2292 }
2293 
2294 /**
2295   * @brief  Get ALARM B Day in BCD format
2296   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
2297   * @rmtoll RTC_ALRMBR       DT            LL_RTC_ALMB_GetDay\n
2298   *         RTC_ALRMBR       DU            LL_RTC_ALMB_GetDay
2299   * @param  RTCx RTC Instance
2300   * @retval Value between Min_Data=0x01 and Max_Data=0x31
2301   */
LL_RTC_ALMB_GetDay(RTC_TypeDef * RTCx)2302 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetDay(RTC_TypeDef *RTCx)
2303 {
2304   return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_DT | RTC_ALRMBR_DU))) >> RTC_ALRMBR_DU_Pos);
2305 }
2306 
2307 /**
2308   * @brief  Set ALARM B Weekday
2309   * @rmtoll RTC_ALRMBR       DU            LL_RTC_ALMB_SetWeekDay
2310   * @param  RTCx RTC Instance
2311   * @param  WeekDay This parameter can be one of the following values:
2312   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
2313   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
2314   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
2315   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
2316   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
2317   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
2318   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
2319   * @retval None
2320   */
LL_RTC_ALMB_SetWeekDay(RTC_TypeDef * RTCx,uint32_t WeekDay)2321 __STATIC_INLINE void LL_RTC_ALMB_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
2322 {
2323   MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_DU, WeekDay << RTC_ALRMBR_DU_Pos);
2324 }
2325 
2326 /**
2327   * @brief  Get ALARM B Weekday
2328   * @rmtoll RTC_ALRMBR       DU            LL_RTC_ALMB_GetWeekDay
2329   * @param  RTCx RTC Instance
2330   * @retval Returned value can be one of the following values:
2331   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
2332   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
2333   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
2334   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
2335   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
2336   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
2337   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
2338   */
LL_RTC_ALMB_GetWeekDay(RTC_TypeDef * RTCx)2339 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetWeekDay(RTC_TypeDef *RTCx)
2340 {
2341   return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_DU) >> RTC_ALRMBR_DU_Pos);
2342 }
2343 
2344 /**
2345   * @brief  Set ALARM B time format (AM/24-hour or PM notation)
2346   * @rmtoll RTC_ALRMBR       PM            LL_RTC_ALMB_SetTimeFormat
2347   * @param  RTCx RTC Instance
2348   * @param  TimeFormat This parameter can be one of the following values:
2349   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
2350   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
2351   * @retval None
2352   */
LL_RTC_ALMB_SetTimeFormat(RTC_TypeDef * RTCx,uint32_t TimeFormat)2353 __STATIC_INLINE void LL_RTC_ALMB_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
2354 {
2355   MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_PM, TimeFormat);
2356 }
2357 
2358 /**
2359   * @brief  Get ALARM B time format (AM or PM notation)
2360   * @rmtoll RTC_ALRMBR       PM            LL_RTC_ALMB_GetTimeFormat
2361   * @param  RTCx RTC Instance
2362   * @retval Returned value can be one of the following values:
2363   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
2364   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
2365   */
LL_RTC_ALMB_GetTimeFormat(RTC_TypeDef * RTCx)2366 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetTimeFormat(RTC_TypeDef *RTCx)
2367 {
2368   return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_PM));
2369 }
2370 
2371 /**
2372   * @brief  Set ALARM B Hours in BCD format
2373   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
2374   * @rmtoll RTC_ALRMBR       HT            LL_RTC_ALMB_SetHour\n
2375   *         RTC_ALRMBR       HU            LL_RTC_ALMB_SetHour
2376   * @param  RTCx RTC Instance
2377   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2378   * @retval None
2379   */
LL_RTC_ALMB_SetHour(RTC_TypeDef * RTCx,uint32_t Hours)2380 __STATIC_INLINE void LL_RTC_ALMB_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
2381 {
2382   MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_HT | RTC_ALRMBR_HU),
2383              (((Hours & 0xF0U) << (RTC_ALRMBR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMBR_HU_Pos)));
2384 }
2385 
2386 /**
2387   * @brief  Get ALARM B Hours in BCD format
2388   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
2389   * @rmtoll RTC_ALRMBR       HT            LL_RTC_ALMB_GetHour\n
2390   *         RTC_ALRMBR       HU            LL_RTC_ALMB_GetHour
2391   * @param  RTCx RTC Instance
2392   * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2393   */
LL_RTC_ALMB_GetHour(RTC_TypeDef * RTCx)2394 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetHour(RTC_TypeDef *RTCx)
2395 {
2396   return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_HT | RTC_ALRMBR_HU))) >> RTC_ALRMBR_HU_Pos);
2397 }
2398 
2399 /**
2400   * @brief  Set ALARM B Minutes in BCD format
2401   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
2402   * @rmtoll RTC_ALRMBR       MNT           LL_RTC_ALMB_SetMinute\n
2403   *         RTC_ALRMBR       MNU           LL_RTC_ALMB_SetMinute
2404   * @param  RTCx RTC Instance
2405   * @param  Minutes between Min_Data=0x00 and Max_Data=0x59
2406   * @retval None
2407   */
LL_RTC_ALMB_SetMinute(RTC_TypeDef * RTCx,uint32_t Minutes)2408 __STATIC_INLINE void LL_RTC_ALMB_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
2409 {
2410   MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_MNT | RTC_ALRMBR_MNU),
2411              (((Minutes & 0xF0U) << (RTC_ALRMBR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMBR_MNU_Pos)));
2412 }
2413 
2414 /**
2415   * @brief  Get ALARM B Minutes in BCD format
2416   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
2417   * @rmtoll RTC_ALRMBR       MNT           LL_RTC_ALMB_GetMinute\n
2418   *         RTC_ALRMBR       MNU           LL_RTC_ALMB_GetMinute
2419   * @param  RTCx RTC Instance
2420   * @retval Value between Min_Data=0x00 and Max_Data=0x59
2421   */
LL_RTC_ALMB_GetMinute(RTC_TypeDef * RTCx)2422 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetMinute(RTC_TypeDef *RTCx)
2423 {
2424   return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_MNT | RTC_ALRMBR_MNU))) >> RTC_ALRMBR_MNU_Pos);
2425 }
2426 
2427 /**
2428   * @brief  Set ALARM B Seconds in BCD format
2429   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
2430   * @rmtoll RTC_ALRMBR       ST            LL_RTC_ALMB_SetSecond\n
2431   *         RTC_ALRMBR       SU            LL_RTC_ALMB_SetSecond
2432   * @param  RTCx RTC Instance
2433   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
2434   * @retval None
2435   */
LL_RTC_ALMB_SetSecond(RTC_TypeDef * RTCx,uint32_t Seconds)2436 __STATIC_INLINE void LL_RTC_ALMB_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
2437 {
2438   MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_ST | RTC_ALRMBR_SU),
2439              (((Seconds & 0xF0U) << (RTC_ALRMBR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMBR_SU_Pos)));
2440 }
2441 
2442 /**
2443   * @brief  Get ALARM B Seconds in BCD format
2444   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
2445   * @rmtoll RTC_ALRMBR       ST            LL_RTC_ALMB_GetSecond\n
2446   *         RTC_ALRMBR       SU            LL_RTC_ALMB_GetSecond
2447   * @param  RTCx RTC Instance
2448   * @retval Value between Min_Data=0x00 and Max_Data=0x59
2449   */
LL_RTC_ALMB_GetSecond(RTC_TypeDef * RTCx)2450 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSecond(RTC_TypeDef *RTCx)
2451 {
2452   return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_ST | RTC_ALRMBR_SU))) >> RTC_ALRMBR_SU_Pos);
2453 }
2454 
2455 /**
2456   * @brief  Set Alarm B Time (hour, minute and second) in BCD format
2457   * @rmtoll RTC_ALRMBR       PM            LL_RTC_ALMB_ConfigTime\n
2458   *         RTC_ALRMBR       HT            LL_RTC_ALMB_ConfigTime\n
2459   *         RTC_ALRMBR       HU            LL_RTC_ALMB_ConfigTime\n
2460   *         RTC_ALRMBR       MNT           LL_RTC_ALMB_ConfigTime\n
2461   *         RTC_ALRMBR       MNU           LL_RTC_ALMB_ConfigTime\n
2462   *         RTC_ALRMBR       ST            LL_RTC_ALMB_ConfigTime\n
2463   *         RTC_ALRMBR       SU            LL_RTC_ALMB_ConfigTime
2464   * @param  RTCx RTC Instance
2465   * @param  Format12_24 This parameter can be one of the following values:
2466   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
2467   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
2468   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2469   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
2470   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
2471   * @retval None
2472   */
LL_RTC_ALMB_ConfigTime(RTC_TypeDef * RTCx,uint32_t Format12_24,uint32_t Hours,uint32_t Minutes,uint32_t Seconds)2473 __STATIC_INLINE void LL_RTC_ALMB_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
2474 {
2475   uint32_t temp;
2476 
2477   temp = Format12_24 | (((Hours & 0xF0U) << (RTC_ALRMBR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMBR_HU_Pos))    | \
2478          (((Minutes & 0xF0U) << (RTC_ALRMBR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMBR_MNU_Pos)) | \
2479          (((Seconds & 0xF0U) << (RTC_ALRMBR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMBR_SU_Pos));
2480 
2481   MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_PM | RTC_ALRMBR_HT | RTC_ALRMBR_HU | RTC_ALRMBR_MNT | RTC_ALRMBR_MNU | RTC_ALRMBR_ST | RTC_ALRMBR_SU, temp);
2482 }
2483 
2484 /**
2485   * @brief  Get Alarm B Time (hour, minute and second) in BCD format
2486   * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
2487   * are available to get independently each parameter.
2488   * @rmtoll RTC_ALRMBR       HT            LL_RTC_ALMB_GetTime\n
2489   *         RTC_ALRMBR       HU            LL_RTC_ALMB_GetTime\n
2490   *         RTC_ALRMBR       MNT           LL_RTC_ALMB_GetTime\n
2491   *         RTC_ALRMBR       MNU           LL_RTC_ALMB_GetTime\n
2492   *         RTC_ALRMBR       ST            LL_RTC_ALMB_GetTime\n
2493   *         RTC_ALRMBR       SU            LL_RTC_ALMB_GetTime
2494   * @param  RTCx RTC Instance
2495   * @retval Combination of hours, minutes and seconds.
2496   */
LL_RTC_ALMB_GetTime(RTC_TypeDef * RTCx)2497 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetTime(RTC_TypeDef *RTCx)
2498 {
2499   return (uint32_t)((LL_RTC_ALMB_GetHour(RTCx) << RTC_OFFSET_HOUR) | (LL_RTC_ALMB_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMB_GetSecond(RTCx));
2500 }
2501 
2502 /**
2503   * @brief  Set Alarm B Mask the most-significant bits starting at this bit
2504   * @note This register can be written only when ALRBE is reset in RTC_CR register,
2505   *       or in initialization mode.
2506   * @rmtoll RTC_ALRMBSSR     MASKSS        LL_RTC_ALMB_SetSubSecondMask
2507   * @param  RTCx RTC Instance
2508   * @param  Mask If binary mode is none, Value between Min_Data=0x0 and Max_Data=0xF
2509   *              else Value between Min_Data=0x0 and Max_Data=0x3F
2510   * @retval None
2511   */
LL_RTC_ALMB_SetSubSecondMask(RTC_TypeDef * RTCx,uint32_t Mask)2512 __STATIC_INLINE void LL_RTC_ALMB_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
2513 {
2514   MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_MASKSS, Mask << RTC_ALRMBSSR_MASKSS_Pos);
2515 }
2516 
2517 /**
2518   * @brief  Get Alarm B Mask the most-significant bits starting at this bit
2519   * @rmtoll RTC_ALRMBSSR     MASKSS        LL_RTC_ALMB_GetSubSecondMask
2520   * @param  RTCx RTC Instance
2521   * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0xF
2522   *         else Value between Min_Data=0x0 and Max_Data=0x3F
2523   */
LL_RTC_ALMB_GetSubSecondMask(RTC_TypeDef * RTCx)2524 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSubSecondMask(RTC_TypeDef *RTCx)
2525 {
2526   return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_MASKSS) >> RTC_ALRMBSSR_MASKSS_Pos);
2527 }
2528 
2529 /**
2530   * @brief  Set Alarm B Binary mode auto clear
2531   * @note This register can be written only when ALRBE is reset in RTC_CR register,
2532   *       or in initialization mode.
2533   * @rmtoll RTC_ALRBBINR     SSCLR        LL_RTC_ALMB_SetBinAutoClr
2534   * @param  RTCx RTC Instance
2535   * @param  BinaryAutoClr This parameter can be one of the following values:
2536   *         @arg @ref LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_NO
2537   *         @arg @ref LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_YES
2538   * @retval None
2539   */
LL_RTC_ALMB_SetBinAutoClr(RTC_TypeDef * RTCx,uint32_t BinaryAutoClr)2540 __STATIC_INLINE void LL_RTC_ALMB_SetBinAutoClr(RTC_TypeDef *RTCx, uint32_t BinaryAutoClr)
2541 {
2542   MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_SSCLR, BinaryAutoClr);
2543 }
2544 
2545 /**
2546   * @brief  Get Alarm B Binary mode auto clear
2547   * @rmtoll RTC_ALRBBINR     SSCLR        LL_RTC_ALMB_GetBinAutoClr
2548   * @param  RTCx RTC Instance
2549   * @retval It can be one of the following values:
2550   *         @arg @ref LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_NO
2551   *         @arg @ref LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_YES
2552   */
LL_RTC_ALMB_GetBinAutoClr(RTC_TypeDef * RTCx)2553 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetBinAutoClr(RTC_TypeDef *RTCx)
2554 {
2555   return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_SSCLR));
2556 }
2557 
2558 /**
2559   * @brief  Set Alarm B Sub seconds value
2560   * @rmtoll RTC_ALRMBBINR     SS            LL_RTC_ALMB_SetSubSecond
2561   * @param  RTCx RTC Instance
2562   * @param  Subsecond  If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
2563   *                    else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
2564   * @retval None
2565   */
LL_RTC_ALMB_SetSubSecond(RTC_TypeDef * RTCx,uint32_t Subsecond)2566 __STATIC_INLINE void LL_RTC_ALMB_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
2567 {
2568   MODIFY_REG(RTCx->ALRBBINR, RTC_ALRBBINR_SS, Subsecond);
2569 }
2570 
2571 /**
2572   * @brief  Get Alarm B Sub seconds value
2573   * @rmtoll RTC_ALRMBBINR     SS            LL_RTC_ALMB_GetSubSecond
2574   * @param  RTCx RTC Instance
2575   * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
2576   *         else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
2577   */
LL_RTC_ALMB_GetSubSecond(RTC_TypeDef * RTCx)2578 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSubSecond(RTC_TypeDef *RTCx)
2579 {
2580   return (uint32_t)(READ_BIT(RTCx->ALRBBINR, RTC_ALRBBINR_SS));
2581 }
2582 
2583 /**
2584   * @}
2585   */
2586 
2587 /** @defgroup RTC_LL_EF_Timestamp Timestamp
2588   * @{
2589   */
2590 
2591 /**
2592   * @brief  Enable internal event timestamp
2593   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2594   * @rmtoll RTC_CR           ITSE          LL_RTC_TS_EnableInternalEvent
2595   * @param  RTCx RTC Instance
2596   * @retval None
2597   */
LL_RTC_TS_EnableInternalEvent(RTC_TypeDef * RTCx)2598 __STATIC_INLINE void LL_RTC_TS_EnableInternalEvent(RTC_TypeDef *RTCx)
2599 {
2600   SET_BIT(RTCx->CR, RTC_CR_ITSE);
2601 }
2602 
2603 /**
2604   * @brief  Disable internal event timestamp
2605   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2606   * @rmtoll RTC_CR           ITSE          LL_RTC_TS_DisableInternalEvent
2607   * @param  RTCx RTC Instance
2608   * @retval None
2609   */
LL_RTC_TS_DisableInternalEvent(RTC_TypeDef * RTCx)2610 __STATIC_INLINE void LL_RTC_TS_DisableInternalEvent(RTC_TypeDef *RTCx)
2611 {
2612   CLEAR_BIT(RTCx->CR, RTC_CR_ITSE);
2613 }
2614 
2615 /**
2616   * @brief  Enable Timestamp
2617   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2618   * @rmtoll RTC_CR           TSE           LL_RTC_TS_Enable
2619   * @param  RTCx RTC Instance
2620   * @retval None
2621   */
LL_RTC_TS_Enable(RTC_TypeDef * RTCx)2622 __STATIC_INLINE void LL_RTC_TS_Enable(RTC_TypeDef *RTCx)
2623 {
2624   SET_BIT(RTCx->CR, RTC_CR_TSE);
2625 }
2626 
2627 /**
2628   * @brief  Disable Timestamp
2629   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2630   * @rmtoll RTC_CR           TSE           LL_RTC_TS_Disable
2631   * @param  RTCx RTC Instance
2632   * @retval None
2633   */
LL_RTC_TS_Disable(RTC_TypeDef * RTCx)2634 __STATIC_INLINE void LL_RTC_TS_Disable(RTC_TypeDef *RTCx)
2635 {
2636   CLEAR_BIT(RTCx->CR, RTC_CR_TSE);
2637 }
2638 
2639 /**
2640   * @brief  Set Time-stamp event active edge
2641   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2642   * @note TSE must be reset when TSEDGE is changed to avoid unwanted TSF setting
2643   * @rmtoll RTC_CR           TSEDGE        LL_RTC_TS_SetActiveEdge
2644   * @param  RTCx RTC Instance
2645   * @param  Edge This parameter can be one of the following values:
2646   *         @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
2647   *         @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
2648   * @retval None
2649   */
LL_RTC_TS_SetActiveEdge(RTC_TypeDef * RTCx,uint32_t Edge)2650 __STATIC_INLINE void LL_RTC_TS_SetActiveEdge(RTC_TypeDef *RTCx, uint32_t Edge)
2651 {
2652   MODIFY_REG(RTCx->CR, RTC_CR_TSEDGE, Edge);
2653 }
2654 
2655 /**
2656   * @brief  Get Time-stamp event active edge
2657   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2658   * @rmtoll RTC_CR           TSEDGE        LL_RTC_TS_GetActiveEdge
2659   * @param  RTCx RTC Instance
2660   * @retval Returned value can be one of the following values:
2661   *         @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
2662   *         @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
2663   */
LL_RTC_TS_GetActiveEdge(RTC_TypeDef * RTCx)2664 __STATIC_INLINE uint32_t LL_RTC_TS_GetActiveEdge(RTC_TypeDef *RTCx)
2665 {
2666   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_TSEDGE));
2667 }
2668 
2669 /**
2670   * @brief  Get Timestamp AM/PM notation (AM or 24-hour format)
2671   * @rmtoll RTC_TSTR         PM            LL_RTC_TS_GetTimeFormat
2672   * @param  RTCx RTC Instance
2673   * @retval Returned value can be one of the following values:
2674   *         @arg @ref LL_RTC_TS_TIME_FORMAT_AM
2675   *         @arg @ref LL_RTC_TS_TIME_FORMAT_PM
2676   */
LL_RTC_TS_GetTimeFormat(RTC_TypeDef * RTCx)2677 __STATIC_INLINE uint32_t LL_RTC_TS_GetTimeFormat(RTC_TypeDef *RTCx)
2678 {
2679   return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_PM));
2680 }
2681 
2682 /**
2683   * @brief  Get Timestamp Hours in BCD format
2684   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
2685   * @rmtoll RTC_TSTR         HT            LL_RTC_TS_GetHour\n
2686   *         RTC_TSTR         HU            LL_RTC_TS_GetHour
2687   * @param  RTCx RTC Instance
2688   * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2689   */
LL_RTC_TS_GetHour(RTC_TypeDef * RTCx)2690 __STATIC_INLINE uint32_t LL_RTC_TS_GetHour(RTC_TypeDef *RTCx)
2691 {
2692   return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_HT | RTC_TSTR_HU) >> RTC_TSTR_HU_Pos);
2693 }
2694 
2695 /**
2696   * @brief  Get Timestamp Minutes in BCD format
2697   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
2698   * @rmtoll RTC_TSTR         MNT           LL_RTC_TS_GetMinute\n
2699   *         RTC_TSTR         MNU           LL_RTC_TS_GetMinute
2700   * @param  RTCx RTC Instance
2701   * @retval Value between Min_Data=0x00 and Max_Data=0x59
2702   */
LL_RTC_TS_GetMinute(RTC_TypeDef * RTCx)2703 __STATIC_INLINE uint32_t LL_RTC_TS_GetMinute(RTC_TypeDef *RTCx)
2704 {
2705   return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_MNT | RTC_TSTR_MNU) >> RTC_TSTR_MNU_Pos);
2706 }
2707 
2708 /**
2709   * @brief  Get Timestamp Seconds in BCD format
2710   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
2711   * @rmtoll RTC_TSTR         ST            LL_RTC_TS_GetSecond\n
2712   *         RTC_TSTR         SU            LL_RTC_TS_GetSecond
2713   * @param  RTCx RTC Instance
2714   * @retval Value between Min_Data=0x00 and Max_Data=0x59
2715   */
LL_RTC_TS_GetSecond(RTC_TypeDef * RTCx)2716 __STATIC_INLINE uint32_t LL_RTC_TS_GetSecond(RTC_TypeDef *RTCx)
2717 {
2718   return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_ST | RTC_TSTR_SU));
2719 }
2720 
2721 /**
2722   * @brief  Get Timestamp time (hour, minute and second) in BCD format
2723   * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
2724   * are available to get independently each parameter.
2725   * @rmtoll RTC_TSTR         HT            LL_RTC_TS_GetTime\n
2726   *         RTC_TSTR         HU            LL_RTC_TS_GetTime\n
2727   *         RTC_TSTR         MNT           LL_RTC_TS_GetTime\n
2728   *         RTC_TSTR         MNU           LL_RTC_TS_GetTime\n
2729   *         RTC_TSTR         ST            LL_RTC_TS_GetTime\n
2730   *         RTC_TSTR         SU            LL_RTC_TS_GetTime
2731   * @param  RTCx RTC Instance
2732   * @retval Combination of hours, minutes and seconds.
2733   */
LL_RTC_TS_GetTime(RTC_TypeDef * RTCx)2734 __STATIC_INLINE uint32_t LL_RTC_TS_GetTime(RTC_TypeDef *RTCx)
2735 {
2736   return (uint32_t)(READ_BIT(RTCx->TSTR,
2737                              RTC_TSTR_HT | RTC_TSTR_HU | RTC_TSTR_MNT | RTC_TSTR_MNU | RTC_TSTR_ST | RTC_TSTR_SU));
2738 }
2739 
2740 /**
2741   * @brief  Get Timestamp Week day
2742   * @rmtoll RTC_TSDR         WDU           LL_RTC_TS_GetWeekDay
2743   * @param  RTCx RTC Instance
2744   * @retval Returned value can be one of the following values:
2745   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
2746   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
2747   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
2748   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
2749   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
2750   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
2751   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
2752   */
LL_RTC_TS_GetWeekDay(RTC_TypeDef * RTCx)2753 __STATIC_INLINE uint32_t LL_RTC_TS_GetWeekDay(RTC_TypeDef *RTCx)
2754 {
2755   return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU) >> RTC_TSDR_WDU_Pos);
2756 }
2757 
2758 /**
2759   * @brief  Get Timestamp Month in BCD format
2760   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
2761   * @rmtoll RTC_TSDR         MT            LL_RTC_TS_GetMonth\n
2762   *         RTC_TSDR         MU            LL_RTC_TS_GetMonth
2763   * @param  RTCx RTC Instance
2764   * @retval Returned value can be one of the following values:
2765   *         @arg @ref LL_RTC_MONTH_JANUARY
2766   *         @arg @ref LL_RTC_MONTH_FEBRUARY
2767   *         @arg @ref LL_RTC_MONTH_MARCH
2768   *         @arg @ref LL_RTC_MONTH_APRIL
2769   *         @arg @ref LL_RTC_MONTH_MAY
2770   *         @arg @ref LL_RTC_MONTH_JUNE
2771   *         @arg @ref LL_RTC_MONTH_JULY
2772   *         @arg @ref LL_RTC_MONTH_AUGUST
2773   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
2774   *         @arg @ref LL_RTC_MONTH_OCTOBER
2775   *         @arg @ref LL_RTC_MONTH_NOVEMBER
2776   *         @arg @ref LL_RTC_MONTH_DECEMBER
2777   */
LL_RTC_TS_GetMonth(RTC_TypeDef * RTCx)2778 __STATIC_INLINE uint32_t LL_RTC_TS_GetMonth(RTC_TypeDef *RTCx)
2779 {
2780   return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_MT | RTC_TSDR_MU) >> RTC_TSDR_MU_Pos);
2781 }
2782 
2783 /**
2784   * @brief  Get Timestamp Day in BCD format
2785   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
2786   * @rmtoll RTC_TSDR         DT            LL_RTC_TS_GetDay\n
2787   *         RTC_TSDR         DU            LL_RTC_TS_GetDay
2788   * @param  RTCx RTC Instance
2789   * @retval Value between Min_Data=0x01 and Max_Data=0x31
2790   */
LL_RTC_TS_GetDay(RTC_TypeDef * RTCx)2791 __STATIC_INLINE uint32_t LL_RTC_TS_GetDay(RTC_TypeDef *RTCx)
2792 {
2793   return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_DT | RTC_TSDR_DU));
2794 }
2795 
2796 /**
2797   * @brief  Get Timestamp date (WeekDay, Day and Month) in BCD format
2798   * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_MONTH,
2799   * and __LL_RTC_GET_DAY are available to get independently each parameter.
2800   * @rmtoll RTC_TSDR         WDU           LL_RTC_TS_GetDate\n
2801   *         RTC_TSDR         MT            LL_RTC_TS_GetDate\n
2802   *         RTC_TSDR         MU            LL_RTC_TS_GetDate\n
2803   *         RTC_TSDR         DT            LL_RTC_TS_GetDate\n
2804   *         RTC_TSDR         DU            LL_RTC_TS_GetDate
2805   * @param  RTCx RTC Instance
2806   * @retval Combination of Weekday, Day and Month
2807   */
LL_RTC_TS_GetDate(RTC_TypeDef * RTCx)2808 __STATIC_INLINE uint32_t LL_RTC_TS_GetDate(RTC_TypeDef *RTCx)
2809 {
2810   return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU | RTC_TSDR_MT | RTC_TSDR_MU | RTC_TSDR_DT | RTC_TSDR_DU));
2811 }
2812 
2813 /**
2814   * @brief  Get time-stamp sub second value
2815   * @rmtoll RTC_TSSSR         SS            LL_RTC_TS_GetSubSecond
2816   * @param  RTCx RTC Instance
2817   * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
2818   *         else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
2819   */
LL_RTC_TS_GetSubSecond(RTC_TypeDef * RTCx)2820 __STATIC_INLINE uint32_t LL_RTC_TS_GetSubSecond(RTC_TypeDef *RTCx)
2821 {
2822   return (uint32_t)(READ_BIT(RTCx->TSSSR, RTC_TSSSR_SS));
2823 }
2824 
2825 /**
2826   * @brief  Activate timestamp on tamper detection event
2827   * @rmtoll RTC_CR       TAMPTS        LL_RTC_TS_EnableOnTamper
2828   * @param  RTCx RTC Instance
2829   * @retval None
2830   */
LL_RTC_TS_EnableOnTamper(RTC_TypeDef * RTCx)2831 __STATIC_INLINE void LL_RTC_TS_EnableOnTamper(RTC_TypeDef *RTCx)
2832 {
2833   SET_BIT(RTCx->CR, RTC_CR_TAMPTS);
2834 }
2835 
2836 /**
2837   * @brief  Disable timestamp on tamper detection event
2838   * @rmtoll RTC_CR       TAMPTS        LL_RTC_TS_DisableOnTamper
2839   * @param  RTCx RTC Instance
2840   * @retval None
2841   */
LL_RTC_TS_DisableOnTamper(RTC_TypeDef * RTCx)2842 __STATIC_INLINE void LL_RTC_TS_DisableOnTamper(RTC_TypeDef *RTCx)
2843 {
2844   CLEAR_BIT(RTCx->CR, RTC_CR_TAMPTS);
2845 }
2846 
2847 
2848 /**
2849   * @}
2850   */
2851 
2852 /** @defgroup RTC_LL_EF_Tamper Tamper
2853   * @{
2854   */
2855 
2856 /**
2857   * @brief  Enable TAMPx input detection
2858   * @rmtoll TAMP_CR1       TAMP1E     LL_RTC_TAMPER_Enable\n
2859   *         TAMP_CR1       TAMP2E     LL_RTC_TAMPER_Enable\n
2860   *         TAMP_CR1       TAMP3E     LL_RTC_TAMPER_Enable\n
2861   * @param  RTCx RTC Instance
2862   * @param  Tamper This parameter can be a combination of the following values:
2863   *         @arg @ref RTC_LL_EC_TAMPER
2864   *
2865   * @retval None
2866   */
LL_RTC_TAMPER_Enable(RTC_TypeDef * RTCx,uint32_t Tamper)2867 __STATIC_INLINE void LL_RTC_TAMPER_Enable(RTC_TypeDef *RTCx, uint32_t Tamper)
2868 {
2869   UNUSED(RTCx);
2870   SET_BIT(TAMP->CR1, Tamper);
2871 }
2872 
2873 /**
2874   * @brief  Clear TAMPx input detection
2875   * @rmtoll TAMP_CR1       TAMP1E      LL_RTC_TAMPER_Disable\n
2876   *         TAMP_CR1       TAMP2E      LL_RTC_TAMPER_Disable\n
2877   *         TAMP_CR1       TAMP3E      LL_RTC_TAMPER_Disable\n
2878   * @param  RTCx RTC Instance
2879   * @param  Tamper This parameter can be a combination of the following values:
2880   *         @arg @ref RTC_LL_EC_TAMPER
2881   *
2882   * @retval None
2883   */
LL_RTC_TAMPER_Disable(RTC_TypeDef * RTCx,uint32_t Tamper)2884 __STATIC_INLINE void LL_RTC_TAMPER_Disable(RTC_TypeDef *RTCx, uint32_t Tamper)
2885 {
2886   UNUSED(RTCx);
2887   CLEAR_BIT(TAMP->CR1, Tamper);
2888 }
2889 
2890 /**
2891   * @brief  Enable Tamper mask flag
2892   * @note Associated Tamper IT must not enabled when tamper mask is set.
2893   * @rmtoll TAMP_CR2       TAMP1MSK      LL_RTC_TAMPER_EnableMask\n
2894   *         TAMP_CR2       TAMP2MSK      LL_RTC_TAMPER_EnableMask\n
2895   *         TAMP_CR2       TAMP3MSK      LL_RTC_TAMPER_EnableMask
2896   * @param  RTCx RTC Instance
2897   * @param  Mask This parameter can be a combination of the following values:
2898   *         @arg @ref RTC_LL_EC_TAMPER_MASK
2899   *
2900   * @retval None
2901   */
LL_RTC_TAMPER_EnableMask(RTC_TypeDef * RTCx,uint32_t Mask)2902 __STATIC_INLINE void LL_RTC_TAMPER_EnableMask(RTC_TypeDef *RTCx, uint32_t Mask)
2903 {
2904   UNUSED(RTCx);
2905   SET_BIT(TAMP->CR2, Mask);
2906 }
2907 
2908 /**
2909   * @brief  Disable Tamper mask flag
2910   * @rmtoll TAMP_MISR       TAMP1MF       LL_RTC_TAMPER_DisableMask\n
2911   *         TAMP_MISR       TAMP2MF       LL_RTC_TAMPER_DisableMask\n
2912   *         TAMP_MISR       TAMP3MF       LL_RTC_TAMPER_DisableMask
2913   * @param  RTCx RTC Instance
2914   * @param  Mask This parameter can be a combination of the following values:
2915   *         @arg @ref RTC_LL_EC_TAMPER_MASK
2916   *
2917   * @retval None
2918   */
LL_RTC_TAMPER_DisableMask(RTC_TypeDef * RTCx,uint32_t Mask)2919 __STATIC_INLINE void LL_RTC_TAMPER_DisableMask(RTC_TypeDef *RTCx, uint32_t Mask)
2920 {
2921   UNUSED(RTCx);
2922   CLEAR_BIT(TAMP->CR2, Mask);
2923 }
2924 
2925 /**
2926   * @brief  Enable backup register erase after Tamper event detection
2927   * @rmtoll TAMP_CR2       TAMP1NOERASE  LL_RTC_TAMPER_EnableEraseBKP\n
2928   *         TAMP_CR2       TAMP2NOERASE  LL_RTC_TAMPER_EnableEraseBKP\n
2929   *         TAMP_CR2       TAMP3NOERASE  LL_RTC_TAMPER_EnableEraseBKP\n
2930   * @param  RTCx RTC Instance
2931   * @param  Tamper This parameter can be a combination of the following values:
2932   *         @arg @ref RTC_LL_EC_TAMPER_NOERASE
2933   *
2934   * @retval None
2935   */
LL_RTC_TAMPER_EnableEraseBKP(RTC_TypeDef * RTCx,uint32_t Tamper)2936 __STATIC_INLINE void LL_RTC_TAMPER_EnableEraseBKP(RTC_TypeDef *RTCx, uint32_t Tamper)
2937 {
2938   UNUSED(RTCx);
2939   CLEAR_BIT(TAMP->CR2, Tamper);
2940 }
2941 
2942 /**
2943   * @brief  Disable backup register erase after Tamper event detection
2944   * @rmtoll TAMP_CR2       TAMP1NOERASE  LL_RTC_TAMPER_DisableEraseBKP\n
2945   *         TAMP_CR2       TAMP2NOERASE  LL_RTC_TAMPER_DisableEraseBKP\n
2946   *         TAMP_CR2       TAMP3NOERASE  LL_RTC_TAMPER_DisableEraseBKP\n
2947   * @param  RTCx RTC Instance
2948   * @param  Tamper This parameter can be a combination of the following values:
2949   *         @arg @ref RTC_LL_EC_TAMPER_NOERASE
2950   *
2951   * @retval None
2952   */
LL_RTC_TAMPER_DisableEraseBKP(RTC_TypeDef * RTCx,uint32_t Tamper)2953 __STATIC_INLINE void LL_RTC_TAMPER_DisableEraseBKP(RTC_TypeDef *RTCx, uint32_t Tamper)
2954 {
2955   UNUSED(RTCx);
2956   SET_BIT(TAMP->CR2, Tamper);
2957 }
2958 
2959 /**
2960   * @brief  Disable RTC_TAMPx pull-up disable (Disable precharge of RTC_TAMPx pins)
2961   * @rmtoll TAMP_FLTCR       TAMPPUDIS     LL_RTC_TAMPER_DisablePullUp
2962   * @param  RTCx RTC Instance
2963   * @retval None
2964   */
LL_RTC_TAMPER_DisablePullUp(RTC_TypeDef * RTCx)2965 __STATIC_INLINE void LL_RTC_TAMPER_DisablePullUp(RTC_TypeDef *RTCx)
2966 {
2967   UNUSED(RTCx);
2968   SET_BIT(TAMP->FLTCR, TAMP_FLTCR_TAMPPUDIS);
2969 }
2970 
2971 /**
2972   * @brief  Enable RTC_TAMPx pull-up disable ( Precharge RTC_TAMPx pins before sampling)
2973   * @rmtoll TAMP_FLTCR       TAMPPUDIS     LL_RTC_TAMPER_EnablePullUp
2974   * @param  RTCx RTC Instance
2975   * @retval None
2976   */
LL_RTC_TAMPER_EnablePullUp(RTC_TypeDef * RTCx)2977 __STATIC_INLINE void LL_RTC_TAMPER_EnablePullUp(RTC_TypeDef *RTCx)
2978 {
2979   UNUSED(RTCx);
2980   CLEAR_BIT(TAMP->FLTCR, TAMP_FLTCR_TAMPPUDIS);
2981 }
2982 
2983 /**
2984   * @brief  Set RTC_TAMPx precharge duration
2985   * @rmtoll TAMP_FLTCR       TAMPPRCH      LL_RTC_TAMPER_SetPrecharge
2986   * @param  RTCx RTC Instance
2987   * @param  Duration This parameter can be one of the following values:
2988   *         @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
2989   *         @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
2990   *         @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
2991   *         @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
2992   * @retval None
2993   */
LL_RTC_TAMPER_SetPrecharge(RTC_TypeDef * RTCx,uint32_t Duration)2994 __STATIC_INLINE void LL_RTC_TAMPER_SetPrecharge(RTC_TypeDef *RTCx, uint32_t Duration)
2995 {
2996   UNUSED(RTCx);
2997   MODIFY_REG(TAMP->FLTCR, TAMP_FLTCR_TAMPPRCH, Duration);
2998 }
2999 
3000 /**
3001   * @brief  Get RTC_TAMPx precharge duration
3002   * @rmtoll TAMP_FLTCR       TAMPPRCH      LL_RTC_TAMPER_GetPrecharge
3003   * @param  RTCx RTC Instance
3004   * @retval Returned value can be one of the following values:
3005   *         @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
3006   *         @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
3007   *         @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
3008   *         @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
3009   */
LL_RTC_TAMPER_GetPrecharge(RTC_TypeDef * RTCx)3010 __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetPrecharge(RTC_TypeDef *RTCx)
3011 {
3012   UNUSED(RTCx);
3013   return (uint32_t)(READ_BIT(TAMP->FLTCR, TAMP_FLTCR_TAMPPRCH));
3014 }
3015 
3016 /**
3017   * @brief  Set RTC_TAMPx filter count
3018   * @rmtoll TAMP_FLTCR       TAMPFLT       LL_RTC_TAMPER_SetFilterCount
3019   * @param  RTCx RTC Instance
3020   * @param  FilterCount This parameter can be one of the following values:
3021   *         @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
3022   *         @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
3023   *         @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
3024   *         @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
3025   * @retval None
3026   */
LL_RTC_TAMPER_SetFilterCount(RTC_TypeDef * RTCx,uint32_t FilterCount)3027 __STATIC_INLINE void LL_RTC_TAMPER_SetFilterCount(RTC_TypeDef *RTCx, uint32_t FilterCount)
3028 {
3029   UNUSED(RTCx);
3030   MODIFY_REG(TAMP->FLTCR, TAMP_FLTCR_TAMPFLT, FilterCount);
3031 }
3032 
3033 /**
3034   * @brief  Get RTC_TAMPx filter count
3035   * @rmtoll TAMP_FLTCR       TAMPFLT       LL_RTC_TAMPER_GetFilterCount
3036   * @param  RTCx RTC Instance
3037   * @retval Returned value can be one of the following values:
3038   *         @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
3039   *         @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
3040   *         @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
3041   *         @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
3042   */
LL_RTC_TAMPER_GetFilterCount(RTC_TypeDef * RTCx)3043 __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetFilterCount(RTC_TypeDef *RTCx)
3044 {
3045   UNUSED(RTCx);
3046   return (uint32_t)(READ_BIT(TAMP->FLTCR, TAMP_FLTCR_TAMPFLT));
3047 }
3048 
3049 /**
3050   * @brief  Set Tamper sampling frequency
3051   * @rmtoll TAMP_FLTCR       TAMPFREQ      LL_RTC_TAMPER_SetSamplingFreq
3052   * @param  RTCx RTC Instance
3053   * @param  SamplingFreq This parameter can be one of the following values:
3054   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
3055   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
3056   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
3057   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
3058   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
3059   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
3060   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
3061   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
3062   * @retval None
3063   */
LL_RTC_TAMPER_SetSamplingFreq(RTC_TypeDef * RTCx,uint32_t SamplingFreq)3064 __STATIC_INLINE void LL_RTC_TAMPER_SetSamplingFreq(RTC_TypeDef *RTCx, uint32_t SamplingFreq)
3065 {
3066   UNUSED(RTCx);
3067   MODIFY_REG(TAMP->FLTCR, TAMP_FLTCR_TAMPFREQ, SamplingFreq);
3068 }
3069 
3070 /**
3071   * @brief  Get Tamper sampling frequency
3072   * @rmtoll TAMP_FLTCR       TAMPFREQ      LL_RTC_TAMPER_GetSamplingFreq
3073   * @param  RTCx RTC Instance
3074   * @retval Returned value can be one of the following values:
3075   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
3076   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
3077   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
3078   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
3079   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
3080   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
3081   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
3082   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
3083   */
LL_RTC_TAMPER_GetSamplingFreq(RTC_TypeDef * RTCx)3084 __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetSamplingFreq(RTC_TypeDef *RTCx)
3085 {
3086   UNUSED(RTCx);
3087   return (uint32_t)(READ_BIT(TAMP->FLTCR, TAMP_FLTCR_TAMPFREQ));
3088 }
3089 
3090 /**
3091   * @brief  Enable Active level for Tamper input
3092   * @rmtoll TAMP_CR2       TAMP1TRG       LL_RTC_TAMPER_EnableActiveLevel\n
3093   *         TAMP_CR2       TAMP2TRG       LL_RTC_TAMPER_EnableActiveLevel\n
3094   *         TAMP_CR2       TAMP3TRG       LL_RTC_TAMPER_EnableActiveLevel\n
3095   * @param  RTCx RTC Instance
3096   * @param  Tamper This parameter can be a combination of the following values:
3097   *         @arg @ref RTC_LL_EC_TAMPER_ACTIVELEVEL
3098   *
3099   * @retval None
3100   */
LL_RTC_TAMPER_EnableActiveLevel(RTC_TypeDef * RTCx,uint32_t Tamper)3101 __STATIC_INLINE void LL_RTC_TAMPER_EnableActiveLevel(RTC_TypeDef *RTCx, uint32_t Tamper)
3102 {
3103   UNUSED(RTCx);
3104   SET_BIT(TAMP->CR2, Tamper);
3105 }
3106 
3107 /**
3108   * @brief  Disable Active level for Tamper input
3109   * @rmtoll TAMP_CR2       TAMP1TRG      LL_RTC_TAMPER_DisableActiveLevel\n
3110   *         TAMP_CR2       TAMP2TRG      LL_RTC_TAMPER_DisableActiveLevel\n
3111   *         TAMP_CR2       TAMP3TRG      LL_RTC_TAMPER_DisableActiveLevel\n
3112   * @param  RTCx RTC Instance
3113   * @param  Tamper This parameter can be a combination of the following values:
3114   *         @arg @ref RTC_LL_EC_TAMPER_ACTIVELEVEL
3115   *
3116   * @retval None
3117   */
LL_RTC_TAMPER_DisableActiveLevel(RTC_TypeDef * RTCx,uint32_t Tamper)3118 __STATIC_INLINE void LL_RTC_TAMPER_DisableActiveLevel(RTC_TypeDef *RTCx, uint32_t Tamper)
3119 {
3120   UNUSED(RTCx);
3121   CLEAR_BIT(TAMP->CR2, Tamper);
3122 }
3123 
3124 /**
3125   * @}
3126   */
3127 
3128 /** @defgroup RTC_LL_EF_Internal_Tamper Internal Tamper
3129   * @{
3130   */
3131 
3132 /**
3133   * @brief  Enable internal tamper detection.
3134   * @rmtoll TAMP_CR1       ITAMP1E       LL_RTC_TAMPER_ITAMP_Enable\n
3135   *         TAMP_CR1       ITAMP2E       LL_RTC_TAMPER_ITAMP_Enable\n
3136   *         TAMP_CR1       ITAMP3E       LL_RTC_TAMPER_ITAMP_Enable\n
3137   *         TAMP_CR1       ITAMP5E       LL_RTC_TAMPER_ITAMP_Enable\n
3138   *         TAMP_CR1       ITAMP6E       LL_RTC_TAMPER_ITAMP_Enable
3139   *         TAMP_CR1       ITAMP8E       LL_RTC_TAMPER_ITAMP_Enable
3140   * @param  RTCx RTC Instance
3141   * @param  InternalTamper This parameter can be a combination of the following values:
3142   *         @arg @ref RTC_LL_EC_INTERNAL
3143   *
3144   * @retval None
3145   */
LL_RTC_TAMPER_ITAMP_Enable(RTC_TypeDef * RTCx,uint32_t InternalTamper)3146 __STATIC_INLINE void LL_RTC_TAMPER_ITAMP_Enable(RTC_TypeDef *RTCx, uint32_t InternalTamper)
3147 {
3148   UNUSED(RTCx);
3149   SET_BIT(TAMP->CR1, InternalTamper);
3150 }
3151 
3152 /**
3153   * @brief  Disable internal tamper detection.
3154   * @rmtoll TAMP_CR1       ITAMP1E       LL_RTC_TAMPER_ITAMP_Disable\n
3155   *         TAMP_CR1       ITAMP2E       LL_RTC_TAMPER_ITAMP_Disable\n
3156   *         TAMP_CR1       ITAMP3E       LL_RTC_TAMPER_ITAMP_Disable\n
3157   *         TAMP_CR1       ITAMP5E       LL_RTC_TAMPER_ITAMP_Disable\n
3158   *         TAMP_CR1       ITAMP6E       LL_RTC_TAMPER_ITAMP_Disable
3159   *         TAMP_CR1       ITAMP8E       LL_RTC_TAMPER_ITAMP_Disable
3160   * @param  RTCx RTC Instance
3161   * @param  InternalTamper This parameter can be a combination of the following values:
3162   *         @arg @ref RTC_LL_EC_INTERNAL
3163   *
3164   * @retval None
3165   */
LL_RTC_TAMPER_ITAMP_Disable(RTC_TypeDef * RTCx,uint32_t InternalTamper)3166 __STATIC_INLINE void LL_RTC_TAMPER_ITAMP_Disable(RTC_TypeDef *RTCx, uint32_t InternalTamper)
3167 {
3168   UNUSED(RTCx);
3169   CLEAR_BIT(TAMP->CR1, InternalTamper);
3170 }
3171 
3172 /**
3173   * @}
3174   */
3175 
3176 /** @defgroup RTC_LL_EF_Wakeup Wakeup
3177   * @{
3178   */
3179 
3180 /**
3181   * @brief  Enable Wakeup timer
3182   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3183   * @rmtoll RTC_CR           WUTE          LL_RTC_WAKEUP_Enable
3184   * @param  RTCx RTC Instance
3185   * @retval None
3186   */
LL_RTC_WAKEUP_Enable(RTC_TypeDef * RTCx)3187 __STATIC_INLINE void LL_RTC_WAKEUP_Enable(RTC_TypeDef *RTCx)
3188 {
3189   SET_BIT(RTCx->CR, RTC_CR_WUTE);
3190 }
3191 
3192 /**
3193   * @brief  Disable Wakeup timer
3194   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3195   * @rmtoll RTC_CR           WUTE          LL_RTC_WAKEUP_Disable
3196   * @param  RTCx RTC Instance
3197   * @retval None
3198   */
LL_RTC_WAKEUP_Disable(RTC_TypeDef * RTCx)3199 __STATIC_INLINE void LL_RTC_WAKEUP_Disable(RTC_TypeDef *RTCx)
3200 {
3201   CLEAR_BIT(RTCx->CR, RTC_CR_WUTE);
3202 }
3203 
3204 /**
3205   * @brief  Check if Wakeup timer is enabled or not
3206   * @rmtoll RTC_CR           WUTE          LL_RTC_WAKEUP_IsEnabled
3207   * @param  RTCx RTC Instance
3208   * @retval State of bit (1 or 0).
3209   */
LL_RTC_WAKEUP_IsEnabled(RTC_TypeDef * RTCx)3210 __STATIC_INLINE uint32_t LL_RTC_WAKEUP_IsEnabled(RTC_TypeDef *RTCx)
3211 {
3212   return ((READ_BIT(RTCx->CR, RTC_CR_WUTE) == (RTC_CR_WUTE)) ? 1U : 0U);
3213 }
3214 
3215 /**
3216   * @brief  Select Wakeup clock
3217   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3218   * @note Bit can be written only when RTC_CR WUTE bit = 0 and RTC_ICSR WUTWF bit = 1
3219   * @rmtoll RTC_CR           WUCKSEL       LL_RTC_WAKEUP_SetClock
3220   * @param  RTCx RTC Instance
3221   * @param  WakeupClock This parameter can be one of the following values:
3222   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
3223   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
3224   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
3225   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
3226   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
3227   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
3228   * @retval None
3229   */
LL_RTC_WAKEUP_SetClock(RTC_TypeDef * RTCx,uint32_t WakeupClock)3230 __STATIC_INLINE void LL_RTC_WAKEUP_SetClock(RTC_TypeDef *RTCx, uint32_t WakeupClock)
3231 {
3232   MODIFY_REG(RTCx->CR, RTC_CR_WUCKSEL, WakeupClock);
3233 }
3234 
3235 /**
3236   * @brief  Get Wakeup clock
3237   * @rmtoll RTC_CR           WUCKSEL       LL_RTC_WAKEUP_GetClock
3238   * @param  RTCx RTC Instance
3239   * @retval Returned value can be one of the following values:
3240   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
3241   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
3242   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
3243   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
3244   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
3245   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
3246   */
LL_RTC_WAKEUP_GetClock(RTC_TypeDef * RTCx)3247 __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetClock(RTC_TypeDef *RTCx)
3248 {
3249   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_WUCKSEL));
3250 }
3251 
3252 /**
3253   * @brief  Set Wakeup auto-reload value
3254   * @note Bit can be written only when WUTWF is set to 1 in RTC_ICSR
3255   * @rmtoll RTC_WUTR         WUT           LL_RTC_WAKEUP_SetAutoReload
3256   * @param  RTCx RTC Instance
3257   * @param  Value Value between Min_Data=0x00 and Max_Data=0xFFFF
3258   * @retval None
3259   */
LL_RTC_WAKEUP_SetAutoReload(RTC_TypeDef * RTCx,uint32_t Value)3260 __STATIC_INLINE void LL_RTC_WAKEUP_SetAutoReload(RTC_TypeDef *RTCx, uint32_t Value)
3261 {
3262   MODIFY_REG(RTCx->WUTR, RTC_WUTR_WUT, Value);
3263 }
3264 
3265 /**
3266   * @brief  Get Wakeup auto-reload value
3267   * @rmtoll RTC_WUTR         WUT           LL_RTC_WAKEUP_GetAutoReload
3268   * @param  RTCx RTC Instance
3269   * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF
3270   */
LL_RTC_WAKEUP_GetAutoReload(RTC_TypeDef * RTCx)3271 __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetAutoReload(RTC_TypeDef *RTCx)
3272 {
3273   return (uint32_t)(READ_BIT(RTCx->WUTR, RTC_WUTR_WUT));
3274 }
3275 
3276 /**
3277   * @}
3278   */
3279 
3280 /** @defgroup RTC_LL_EF_Backup_Registers Backup_Registers
3281   * @{
3282   */
3283 
3284 /**
3285   * @brief  Writes a data in a specified Backup data register.
3286   * @rmtoll TAMP_BKPxR        BKP           LL_RTC_BKP_SetRegister
3287   * @param  RTCx RTC Instance
3288   * @param  BackupRegister This parameter can be one of the following values:
3289   *         @arg @ref LL_RTC_BKP_DR0
3290   *         @arg @ref LL_RTC_BKP_DR1
3291   *         @arg @ref LL_RTC_BKP_DR2
3292   *         @arg @ref LL_RTC_BKP_DR3
3293   *         @arg @ref LL_RTC_BKP_DR4
3294   *         @arg @ref LL_RTC_BKP_DR5
3295   *         @arg @ref LL_RTC_BKP_DR6
3296   *         @arg @ref LL_RTC_BKP_DR7
3297   *         @arg @ref LL_RTC_BKP_DR8
3298   *         @arg @ref LL_RTC_BKP_DR9
3299   *         @arg @ref LL_RTC_BKP_DR10
3300   *         @arg @ref LL_RTC_BKP_DR11
3301   *         @arg @ref LL_RTC_BKP_DR12
3302   *         @arg @ref LL_RTC_BKP_DR13
3303   *         @arg @ref LL_RTC_BKP_DR14
3304   *         @arg @ref LL_RTC_BKP_DR15
3305   *         @arg @ref LL_RTC_BKP_DR16
3306   *         @arg @ref LL_RTC_BKP_DR17
3307   *         @arg @ref LL_RTC_BKP_DR18
3308   *         @arg @ref LL_RTC_BKP_DR19
3309   * @param  Data Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
3310   * @retval None
3311   */
LL_RTC_BKP_SetRegister(RTC_TypeDef * RTCx,uint32_t BackupRegister,uint32_t Data)3312 __STATIC_INLINE void LL_RTC_BKP_SetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister, uint32_t Data)
3313 {
3314   uint32_t tmp;
3315 
3316   UNUSED(RTCx);
3317 
3318   tmp = (uint32_t)(&(TAMP->BKP0R));
3319   tmp += (BackupRegister * 4U);
3320 
3321   /* Write the specified register */
3322   *(__IO uint32_t *)tmp = (uint32_t)Data;
3323 }
3324 
3325 /**
3326   * @brief  Reads data from the specified RTC Backup data Register.
3327   * @rmtoll TAMP_BKPxR        BKP           LL_RTC_BKP_GetRegister
3328   * @param  RTCx RTC Instance
3329   * @param  BackupRegister This parameter can be one of the following values:
3330   *         @arg @ref LL_RTC_BKP_DR0
3331   *         @arg @ref LL_RTC_BKP_DR1
3332   *         @arg @ref LL_RTC_BKP_DR2
3333   *         @arg @ref LL_RTC_BKP_DR3
3334   *         @arg @ref LL_RTC_BKP_DR4
3335   *         @arg @ref LL_RTC_BKP_DR5
3336   *         @arg @ref LL_RTC_BKP_DR6
3337   *         @arg @ref LL_RTC_BKP_DR7
3338   *         @arg @ref LL_RTC_BKP_DR8
3339   *         @arg @ref LL_RTC_BKP_DR9
3340   *         @arg @ref LL_RTC_BKP_DR10
3341   *         @arg @ref LL_RTC_BKP_DR11
3342   *         @arg @ref LL_RTC_BKP_DR12
3343   *         @arg @ref LL_RTC_BKP_DR13
3344   *         @arg @ref LL_RTC_BKP_DR14
3345   *         @arg @ref LL_RTC_BKP_DR15
3346   *         @arg @ref LL_RTC_BKP_DR16
3347   *         @arg @ref LL_RTC_BKP_DR17
3348   *         @arg @ref LL_RTC_BKP_DR18
3349   *         @arg @ref LL_RTC_BKP_DR19
3350   * @retval Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
3351   */
LL_RTC_BKP_GetRegister(RTC_TypeDef * RTCx,uint32_t BackupRegister)3352 __STATIC_INLINE uint32_t LL_RTC_BKP_GetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister)
3353 {
3354   uint32_t tmp;
3355 
3356   UNUSED(RTCx);
3357 
3358   tmp = (uint32_t)(&(TAMP->BKP0R));
3359   tmp += (BackupRegister * 4U);
3360 
3361   /* Read the specified register */
3362   return (*(__IO uint32_t *)tmp);
3363 }
3364 
3365 /**
3366   * @}
3367   */
3368 
3369 /** @defgroup RTC_LL_EF_Calibration Calibration
3370   * @{
3371   */
3372 
3373 /**
3374   * @brief  Set Calibration output frequency (1 Hz or 512 Hz)
3375   * @note Bits are write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3376   * @rmtoll RTC_CR           COE           LL_RTC_CAL_SetOutputFreq\n
3377   *         RTC_CR           COSEL         LL_RTC_CAL_SetOutputFreq
3378   * @param  RTCx RTC Instance
3379   * @param  Frequency This parameter can be one of the following values:
3380   *         @arg @ref LL_RTC_CALIB_OUTPUT_NONE
3381   *         @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
3382   *         @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
3383   * @retval None
3384   */
LL_RTC_CAL_SetOutputFreq(RTC_TypeDef * RTCx,uint32_t Frequency)3385 __STATIC_INLINE void LL_RTC_CAL_SetOutputFreq(RTC_TypeDef *RTCx, uint32_t Frequency)
3386 {
3387   MODIFY_REG(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL, Frequency);
3388 }
3389 
3390 /**
3391   * @brief  Get Calibration output frequency (1 Hz or 512 Hz)
3392   * @rmtoll RTC_CR           COE           LL_RTC_CAL_GetOutputFreq\n
3393   *         RTC_CR           COSEL         LL_RTC_CAL_GetOutputFreq
3394   * @param  RTCx RTC Instance
3395   * @retval Returned value can be one of the following values:
3396   *         @arg @ref LL_RTC_CALIB_OUTPUT_NONE
3397   *         @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
3398   *         @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
3399   */
LL_RTC_CAL_GetOutputFreq(RTC_TypeDef * RTCx)3400 __STATIC_INLINE uint32_t LL_RTC_CAL_GetOutputFreq(RTC_TypeDef *RTCx)
3401 {
3402   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL));
3403 }
3404 
3405 /**
3406   * @brief  Insert or not One RTCCLK pulse every 2exp11 pulses (frequency increased by 488.5 ppm)
3407   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3408   * @note Bit can be written only when RECALPF is set to 0 in RTC_ICSR
3409   * @rmtoll RTC_CALR         CALP          LL_RTC_CAL_SetPulse
3410   * @param  RTCx RTC Instance
3411   * @param  Pulse This parameter can be one of the following values:
3412   *         @arg @ref LL_RTC_CALIB_INSERTPULSE_NONE
3413   *         @arg @ref LL_RTC_CALIB_INSERTPULSE_SET
3414   * @retval None
3415   */
LL_RTC_CAL_SetPulse(RTC_TypeDef * RTCx,uint32_t Pulse)3416 __STATIC_INLINE void LL_RTC_CAL_SetPulse(RTC_TypeDef *RTCx, uint32_t Pulse)
3417 {
3418   MODIFY_REG(RTCx->CALR, RTC_CALR_CALP, Pulse);
3419 }
3420 
3421 /**
3422   * @brief  Check if one RTCCLK has been inserted or not every 2exp11 pulses (frequency increased by 488.5 ppm)
3423   * @rmtoll RTC_CALR         CALP          LL_RTC_CAL_IsPulseInserted
3424   * @param  RTCx RTC Instance
3425   * @retval State of bit (1 or 0).
3426   */
LL_RTC_CAL_IsPulseInserted(RTC_TypeDef * RTCx)3427 __STATIC_INLINE uint32_t LL_RTC_CAL_IsPulseInserted(RTC_TypeDef *RTCx)
3428 {
3429   return ((READ_BIT(RTCx->CALR, RTC_CALR_CALP) == (RTC_CALR_CALP)) ? 1U : 0U);
3430 }
3431 
3432 /**
3433   * @brief  Set the calibration cycle period
3434   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3435   * @note   Bit can be written only when RECALPF is set to 0 in RTC_ICSR
3436   * @rmtoll RTC_CALR         CALW8         LL_RTC_CAL_SetPeriod\n
3437   *         RTC_CALR         CALW16        LL_RTC_CAL_SetPeriod
3438   * @param  RTCx RTC Instance
3439   * @param  Period This parameter can be one of the following values:
3440   *         @arg @ref LL_RTC_CALIB_PERIOD_32SEC
3441   *         @arg @ref LL_RTC_CALIB_PERIOD_16SEC
3442   *         @arg @ref LL_RTC_CALIB_PERIOD_8SEC
3443   * @retval None
3444   */
LL_RTC_CAL_SetPeriod(RTC_TypeDef * RTCx,uint32_t Period)3445 __STATIC_INLINE void LL_RTC_CAL_SetPeriod(RTC_TypeDef *RTCx, uint32_t Period)
3446 {
3447   MODIFY_REG(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16, Period);
3448 }
3449 
3450 /**
3451   * @brief  Get the calibration cycle period
3452   * @rmtoll RTC_CALR         CALW8         LL_RTC_CAL_GetPeriod\n
3453   *         RTC_CALR         CALW16        LL_RTC_CAL_GetPeriod
3454   * @param  RTCx RTC Instance
3455   * @retval Returned value can be one of the following values:
3456   *         @arg @ref LL_RTC_CALIB_PERIOD_32SEC
3457   *         @arg @ref LL_RTC_CALIB_PERIOD_16SEC
3458   *         @arg @ref LL_RTC_CALIB_PERIOD_8SEC
3459   */
LL_RTC_CAL_GetPeriod(RTC_TypeDef * RTCx)3460 __STATIC_INLINE uint32_t LL_RTC_CAL_GetPeriod(RTC_TypeDef *RTCx)
3461 {
3462   return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16));
3463 }
3464 
3465 /**
3466   * @brief  Set Calibration minus
3467   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3468   * @note   Bit can be written only when RECALPF is set to 0 in RTC_ICSR
3469   * @rmtoll RTC_CALR         CALM          LL_RTC_CAL_SetMinus
3470   * @param  RTCx RTC Instance
3471   * @param  CalibMinus Value between Min_Data=0x00 and Max_Data=0x1FF
3472   * @retval None
3473   */
LL_RTC_CAL_SetMinus(RTC_TypeDef * RTCx,uint32_t CalibMinus)3474 __STATIC_INLINE void LL_RTC_CAL_SetMinus(RTC_TypeDef *RTCx, uint32_t CalibMinus)
3475 {
3476   MODIFY_REG(RTCx->CALR, RTC_CALR_CALM, CalibMinus);
3477 }
3478 
3479 /**
3480   * @brief  Get Calibration minus
3481   * @rmtoll RTC_CALR         CALM          LL_RTC_CAL_GetMinus
3482   * @param  RTCx RTC Instance
3483   * @retval Value between Min_Data=0x00 and Max_Data= 0x1FF
3484   */
LL_RTC_CAL_GetMinus(RTC_TypeDef * RTCx)3485 __STATIC_INLINE uint32_t LL_RTC_CAL_GetMinus(RTC_TypeDef *RTCx)
3486 {
3487   return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALM));
3488 }
3489 
3490 /**
3491   * @brief  Enable Calibration Low Power
3492   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3493   * @note   Bit can be written only when RECALPF is set to 0
3494   * @rmtoll RTC_CALR         LPCAL          LL_RTC_CAL_LowPower_Enable
3495   * @param  RTCx RTC Instance
3496   * @retval None
3497   */
LL_RTC_CAL_LowPower_Enable(RTC_TypeDef * RTCx)3498 __STATIC_INLINE void LL_RTC_CAL_LowPower_Enable(RTC_TypeDef *RTCx)
3499 {
3500   SET_BIT(RTCx->CALR, RTC_CALR_LPCAL);
3501 }
3502 
3503 /**
3504   * @brief  Disable Calibration Low Power
3505   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3506   * @note   Bit can be written only when RECALPF is set to 0
3507   * @rmtoll RTC_CALR         LPCAL          LL_RTC_CAL_LowPower_Disable
3508   * @param  RTCx RTC Instance
3509   * @retval None
3510   */
LL_RTC_CAL_LowPower_Disable(RTC_TypeDef * RTCx)3511 __STATIC_INLINE void LL_RTC_CAL_LowPower_Disable(RTC_TypeDef *RTCx)
3512 {
3513   CLEAR_BIT(RTCx->CALR, RTC_CALR_LPCAL);
3514 }
3515 
3516 /**
3517   * @brief  Check if Calibration Low Power is enabled or not
3518   * @rmtoll RTC_CALR         LPCAL          LL_RTC_CAL_LowPower_IsEnabled
3519   * @param  RTCx RTC Instance
3520   * @retval State of bit (1 or 0).
3521   */
LL_RTC_CAL_LowPower_IsEnabled(RTC_TypeDef * RTCx)3522 __STATIC_INLINE uint32_t LL_RTC_CAL_LowPower_IsEnabled(RTC_TypeDef *RTCx)
3523 {
3524   return ((READ_BIT(RTCx->CALR, RTC_CALR_LPCAL) == (RTC_CALR_LPCAL)) ? 1U : 0U);
3525 }
3526 
3527 /**
3528   * @}
3529   */
3530 
3531 /** @defgroup RTC_LL_EF_FLAG_Management FLAG_Management
3532   * @{
3533   */
3534 
3535 /**
3536   * @brief  Get Internal Time-stamp flag
3537   * @rmtoll RTC_SR          ITSF          LL_RTC_IsActiveFlag_ITS
3538   * @param  RTCx RTC Instance
3539   * @retval State of bit (1 or 0).
3540   */
LL_RTC_IsActiveFlag_ITS(RTC_TypeDef * RTCx)3541 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITS(RTC_TypeDef *RTCx)
3542 {
3543   return ((READ_BIT(RTCx->SR, RTC_SR_ITSF) == (RTC_SR_ITSF)) ? 1U : 0U);
3544 }
3545 
3546 /**
3547   * @brief  Get Recalibration pending Flag
3548   * @rmtoll RTC_ICSR          RECALPF       LL_RTC_IsActiveFlag_RECALP
3549   * @param  RTCx RTC Instance
3550   * @retval State of bit (1 or 0).
3551   */
LL_RTC_IsActiveFlag_RECALP(RTC_TypeDef * RTCx)3552 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RECALP(RTC_TypeDef *RTCx)
3553 {
3554   return ((READ_BIT(RTCx->ICSR, RTC_ICSR_RECALPF) == (RTC_ICSR_RECALPF)) ? 1U : 0U);
3555 }
3556 
3557 /**
3558   * @brief  Get Time-stamp overflow flag
3559   * @rmtoll RTC_SR          TSOVF         LL_RTC_IsActiveFlag_TSOV
3560   * @param  RTCx RTC Instance
3561   * @retval State of bit (1 or 0).
3562   */
LL_RTC_IsActiveFlag_TSOV(RTC_TypeDef * RTCx)3563 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSOV(RTC_TypeDef *RTCx)
3564 {
3565   return ((READ_BIT(RTCx->SR, RTC_SR_TSOVF) == (RTC_SR_TSOVF)) ? 1U : 0U);
3566 }
3567 
3568 /**
3569   * @brief  Get Time-stamp flag
3570   * @rmtoll RTC_SR          TSF           LL_RTC_IsActiveFlag_TS
3571   * @param  RTCx RTC Instance
3572   * @retval State of bit (1 or 0).
3573   */
LL_RTC_IsActiveFlag_TS(RTC_TypeDef * RTCx)3574 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TS(RTC_TypeDef *RTCx)
3575 {
3576   return ((READ_BIT(RTCx->SR, RTC_SR_TSF) == (RTC_SR_TSF)) ? 1U : 0U);
3577 }
3578 
3579 /**
3580   * @brief  Get Wakeup timer flag
3581   * @rmtoll RTC_SR          WUTF          LL_RTC_IsActiveFlag_WUT
3582   * @param  RTCx RTC Instance
3583   * @retval State of bit (1 or 0).
3584   */
LL_RTC_IsActiveFlag_WUT(RTC_TypeDef * RTCx)3585 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUT(RTC_TypeDef *RTCx)
3586 {
3587   return ((READ_BIT(RTCx->SR, RTC_SR_WUTF) == (RTC_SR_WUTF)) ? 1U : 0U);
3588 }
3589 
3590 /**
3591   * @brief  Get Alarm B flag
3592   * @rmtoll RTC_SR          ALRBF         LL_RTC_IsActiveFlag_ALRB
3593   * @param  RTCx RTC Instance
3594   * @retval State of bit (1 or 0).
3595   */
LL_RTC_IsActiveFlag_ALRB(RTC_TypeDef * RTCx)3596 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRB(RTC_TypeDef *RTCx)
3597 {
3598   return ((READ_BIT(RTCx->SR, RTC_SR_ALRBF) == (RTC_SR_ALRBF)) ? 1U : 0U);
3599 }
3600 
3601 /**
3602   * @brief  Get Alarm A flag
3603   * @rmtoll RTC_SR          ALRAF         LL_RTC_IsActiveFlag_ALRA
3604   * @param  RTCx RTC Instance
3605   * @retval State of bit (1 or 0).
3606   */
LL_RTC_IsActiveFlag_ALRA(RTC_TypeDef * RTCx)3607 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRA(RTC_TypeDef *RTCx)
3608 {
3609   return ((READ_BIT(RTCx->SR, RTC_SR_ALRAF) == (RTC_SR_ALRAF)) ? 1U : 0U);
3610 }
3611 
3612 /**
3613   * @brief  Get SSR Underflow flag
3614   * @rmtoll RTC_SR          SSRUF         LL_RTC_IsActiveFlag_SSRU
3615   * @param  RTCx RTC Instance
3616   * @retval State of bit (1 or 0).
3617   */
LL_RTC_IsActiveFlag_SSRU(RTC_TypeDef * RTCx)3618 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SSRU(RTC_TypeDef *RTCx)
3619 {
3620   return ((READ_BIT(RTCx->SR, RTC_SR_SSRUF) == (RTC_SR_SSRUF)) ? 1U : 0U);
3621 }
3622 
3623 /**
3624   * @brief  Clear Internal Time-stamp flag
3625   * @rmtoll RTC_SCR          CITSF          LL_RTC_ClearFlag_ITS
3626   * @param  RTCx RTC Instance
3627   * @retval None
3628   */
LL_RTC_ClearFlag_ITS(RTC_TypeDef * RTCx)3629 __STATIC_INLINE void LL_RTC_ClearFlag_ITS(RTC_TypeDef *RTCx)
3630 {
3631   WRITE_REG(RTCx->SCR, RTC_SCR_CITSF);
3632 }
3633 
3634 /**
3635   * @brief  Clear Time-stamp overflow flag
3636   * @rmtoll RTC_SCR          CTSOVF         LL_RTC_ClearFlag_TSOV
3637   * @param  RTCx RTC Instance
3638   * @retval None
3639   */
LL_RTC_ClearFlag_TSOV(RTC_TypeDef * RTCx)3640 __STATIC_INLINE void LL_RTC_ClearFlag_TSOV(RTC_TypeDef *RTCx)
3641 {
3642   WRITE_REG(RTCx->SCR, RTC_SCR_CTSOVF);
3643 }
3644 
3645 /**
3646   * @brief  Clear Time-stamp flag
3647   * @rmtoll RTC_SCR          CTSF           LL_RTC_ClearFlag_TS
3648   * @param  RTCx RTC Instance
3649   * @retval None
3650   */
LL_RTC_ClearFlag_TS(RTC_TypeDef * RTCx)3651 __STATIC_INLINE void LL_RTC_ClearFlag_TS(RTC_TypeDef *RTCx)
3652 {
3653   WRITE_REG(RTCx->SCR, RTC_SCR_CTSF);
3654 }
3655 
3656 /**
3657   * @brief  Clear Wakeup timer flag
3658   * @rmtoll RTC_SCR          CWUTF          LL_RTC_ClearFlag_WUT
3659   * @param  RTCx RTC Instance
3660   * @retval None
3661   */
LL_RTC_ClearFlag_WUT(RTC_TypeDef * RTCx)3662 __STATIC_INLINE void LL_RTC_ClearFlag_WUT(RTC_TypeDef *RTCx)
3663 {
3664   WRITE_REG(RTCx->SCR, RTC_SCR_CWUTF);
3665 }
3666 
3667 /**
3668   * @brief  Clear Alarm B flag
3669   * @rmtoll RTC_SCR          CALRBF         LL_RTC_ClearFlag_ALRB
3670   * @param  RTCx RTC Instance
3671   * @retval None
3672   */
LL_RTC_ClearFlag_ALRB(RTC_TypeDef * RTCx)3673 __STATIC_INLINE void LL_RTC_ClearFlag_ALRB(RTC_TypeDef *RTCx)
3674 {
3675   WRITE_REG(RTCx->SCR, RTC_SCR_CALRBF);
3676 }
3677 
3678 /**
3679   * @brief  Clear Alarm A flag
3680   * @rmtoll RTC_SCR          CALRAF         LL_RTC_ClearFlag_ALRA
3681   * @param  RTCx RTC Instance
3682   * @retval None
3683   */
LL_RTC_ClearFlag_ALRA(RTC_TypeDef * RTCx)3684 __STATIC_INLINE void LL_RTC_ClearFlag_ALRA(RTC_TypeDef *RTCx)
3685 {
3686   WRITE_REG(RTCx->SCR, RTC_SCR_CALRAF);
3687 }
3688 
3689 /**
3690   * @brief  Clear SSR Underflow flag
3691   * @rmtoll RTC_SCR          CSSRUF         LL_RTC_ClearFlag_SSRU
3692   * @param  RTCx RTC Instance
3693   * @retval None
3694   */
LL_RTC_ClearFlag_SSRU(RTC_TypeDef * RTCx)3695 __STATIC_INLINE void LL_RTC_ClearFlag_SSRU(RTC_TypeDef *RTCx)
3696 {
3697   WRITE_REG(RTCx->SCR, RTC_SCR_CSSRUF);
3698 }
3699 
3700 /**
3701   * @brief  Get Initialization flag
3702   * @rmtoll RTC_ICSR          INITF         LL_RTC_IsActiveFlag_INIT
3703   * @param  RTCx RTC Instance
3704   * @retval State of bit (1 or 0).
3705   */
LL_RTC_IsActiveFlag_INIT(RTC_TypeDef * RTCx)3706 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INIT(RTC_TypeDef *RTCx)
3707 {
3708   return ((READ_BIT(RTCx->ICSR, RTC_ICSR_INITF) == (RTC_ICSR_INITF)) ? 1U : 0U);
3709 }
3710 
3711 /**
3712   * @brief  Get Registers synchronization flag
3713   * @rmtoll RTC_ICSR          RSF           LL_RTC_IsActiveFlag_RS
3714   * @param  RTCx RTC Instance
3715   * @retval State of bit (1 or 0).
3716   */
LL_RTC_IsActiveFlag_RS(RTC_TypeDef * RTCx)3717 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(RTC_TypeDef *RTCx)
3718 {
3719   return ((READ_BIT(RTCx->ICSR, RTC_ICSR_RSF) == (RTC_ICSR_RSF)) ? 1U : 0U);
3720 }
3721 
3722 /**
3723   * @brief  Clear Registers synchronization flag
3724   * @rmtoll RTC_ICSR          RSF           LL_RTC_ClearFlag_RS
3725   * @param  RTCx RTC Instance
3726   * @retval None
3727   */
LL_RTC_ClearFlag_RS(RTC_TypeDef * RTCx)3728 __STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx)
3729 {
3730   WRITE_REG(RTCx->ICSR, (~((RTC_ICSR_RSF | RTC_ICSR_INIT) & 0x000000FFU) | (RTCx->ICSR & RTC_ICSR_INIT)));
3731 }
3732 
3733 /**
3734   * @brief  Get Initialization status flag
3735   * @rmtoll RTC_ICSR          INITS         LL_RTC_IsActiveFlag_INITS
3736   * @param  RTCx RTC Instance
3737   * @retval State of bit (1 or 0).
3738   */
LL_RTC_IsActiveFlag_INITS(RTC_TypeDef * RTCx)3739 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INITS(RTC_TypeDef *RTCx)
3740 {
3741   return ((READ_BIT(RTCx->ICSR, RTC_ICSR_INITS) == (RTC_ICSR_INITS)) ? 1U : 0U);
3742 }
3743 
3744 /**
3745   * @brief  Get Shift operation pending flag
3746   * @rmtoll RTC_ICSR          SHPF          LL_RTC_IsActiveFlag_SHP
3747   * @param  RTCx RTC Instance
3748   * @retval State of bit (1 or 0).
3749   */
LL_RTC_IsActiveFlag_SHP(RTC_TypeDef * RTCx)3750 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SHP(RTC_TypeDef *RTCx)
3751 {
3752   return ((READ_BIT(RTCx->ICSR, RTC_ICSR_SHPF) == (RTC_ICSR_SHPF)) ? 1U : 0U);
3753 }
3754 
3755 /**
3756   * @brief  Get Wakeup timer write flag
3757   * @rmtoll RTC_ICSR          WUTWF         LL_RTC_IsActiveFlag_WUTW
3758   * @param  RTCx RTC Instance
3759   * @retval State of bit (1 or 0).
3760   */
LL_RTC_IsActiveFlag_WUTW(RTC_TypeDef * RTCx)3761 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUTW(RTC_TypeDef *RTCx)
3762 {
3763   return ((READ_BIT(RTCx->ICSR, RTC_ICSR_WUTWF) == (RTC_ICSR_WUTWF)) ? 1U : 0U);
3764 }
3765 
3766 /**
3767   * @brief  Get Alarm A masked flag.
3768   * @rmtoll RTC_MISR          ALRAMF        LL_RTC_IsActiveFlag_ALRAM
3769   * @param  RTCx RTC Instance
3770   * @retval State of bit (1 or 0).
3771   */
LL_RTC_IsActiveFlag_ALRAM(RTC_TypeDef * RTCx)3772 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRAM(RTC_TypeDef *RTCx)
3773 {
3774   return ((READ_BIT(RTCx->MISR, RTC_MISR_ALRAMF) == (RTC_MISR_ALRAMF)) ? 1U : 0U);
3775 }
3776 
3777 /**
3778   * @brief  Get SSR Underflow masked flag.
3779   * @rmtoll RTC_MISR          SSRUMF        LL_RTC_IsActiveFlag_SSRUM
3780   * @param  RTCx RTC Instance
3781   * @retval State of bit (1 or 0).
3782   */
LL_RTC_IsActiveFlag_SSRUM(RTC_TypeDef * RTCx)3783 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SSRUM(RTC_TypeDef *RTCx)
3784 {
3785   return ((READ_BIT(RTCx->MISR, RTC_MISR_SSRUMF) == (RTC_MISR_SSRUMF)) ? 1U : 0U);
3786 }
3787 
3788 /**
3789   * @brief  Get Alarm B masked flag.
3790   * @rmtoll RTC_MISR          ALRBMF        LL_RTC_IsActiveFlag_ALRBM
3791   * @param  RTCx RTC Instance
3792   * @retval State of bit (1 or 0).
3793   */
LL_RTC_IsActiveFlag_ALRBM(RTC_TypeDef * RTCx)3794 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRBM(RTC_TypeDef *RTCx)
3795 {
3796   return ((READ_BIT(RTCx->MISR, RTC_MISR_ALRBMF) == (RTC_MISR_ALRBMF)) ? 1U : 0U);
3797 }
3798 
3799 /**
3800   * @brief  Get Wakeup timer masked flag.
3801   * @rmtoll RTC_MISR          WUTMF        LL_RTC_IsActiveFlag_WUTM
3802   * @param  RTCx RTC Instance
3803   * @retval State of bit (1 or 0).
3804   */
LL_RTC_IsActiveFlag_WUTM(RTC_TypeDef * RTCx)3805 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUTM(RTC_TypeDef *RTCx)
3806 {
3807   return ((READ_BIT(RTCx->MISR, RTC_MISR_WUTMF) == (RTC_MISR_WUTMF)) ? 1U : 0U);
3808 }
3809 
3810 /**
3811   * @brief  Get Time-stamp masked flag.
3812   * @rmtoll RTC_MISR          TSMF        LL_RTC_IsActiveFlag_TSM
3813   * @param  RTCx RTC Instance
3814   * @retval State of bit (1 or 0).
3815   */
LL_RTC_IsActiveFlag_TSM(RTC_TypeDef * RTCx)3816 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSM(RTC_TypeDef *RTCx)
3817 {
3818   return ((READ_BIT(RTCx->MISR, RTC_MISR_TSMF) == (RTC_MISR_TSMF)) ? 1U : 0U);
3819 }
3820 
3821 /**
3822   * @brief  Get Time-stamp overflow masked flag.
3823   * @rmtoll RTC_MISR          TSOVMF        LL_RTC_IsActiveFlag_TSOVM
3824   * @param  RTCx RTC Instance
3825   * @retval State of bit (1 or 0).
3826   */
LL_RTC_IsActiveFlag_TSOVM(RTC_TypeDef * RTCx)3827 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSOVM(RTC_TypeDef *RTCx)
3828 {
3829   return ((READ_BIT(RTCx->MISR, RTC_MISR_TSOVMF) == (RTC_MISR_TSOVMF)) ? 1U : 0U);
3830 }
3831 
3832 /**
3833   * @brief  Get Internal Time-stamp masked flag.
3834   * @rmtoll RTC_MISR          ITSMF        LL_RTC_IsActiveFlag_ITSM
3835   * @param  RTCx RTC Instance
3836   * @retval State of bit (1 or 0).
3837   */
LL_RTC_IsActiveFlag_ITSM(RTC_TypeDef * RTCx)3838 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITSM(RTC_TypeDef *RTCx)
3839 {
3840   return ((READ_BIT(RTCx->MISR, RTC_MISR_ITSMF) == (RTC_MISR_ITSMF)) ? 1U : 0U);
3841 }
3842 
3843 /**
3844   * @brief  Get tamper 1 detection flag.
3845   * @rmtoll TAMP_SR          TAMP1F        LL_RTC_IsActiveFlag_TAMP1
3846   * @param  RTCx RTC Instance
3847   * @retval State of bit (1 or 0).
3848   */
LL_RTC_IsActiveFlag_TAMP1(RTC_TypeDef * RTCx)3849 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP1(RTC_TypeDef *RTCx)
3850 {
3851   UNUSED(RTCx);
3852   return ((READ_BIT(TAMP->SR, TAMP_SR_TAMP1F) == (TAMP_SR_TAMP1F)) ? 1U : 0U);
3853 }
3854 
3855 /**
3856   * @brief  Get tamper 2 detection flag.
3857   * @rmtoll TAMP_SR          TAMP2F        LL_RTC_IsActiveFlag_TAMP2
3858   * @param  RTCx RTC Instance
3859   * @retval State of bit (1 or 0).
3860   */
LL_RTC_IsActiveFlag_TAMP2(RTC_TypeDef * RTCx)3861 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP2(RTC_TypeDef *RTCx)
3862 {
3863   UNUSED(RTCx);
3864   return ((READ_BIT(TAMP->SR, TAMP_SR_TAMP2F) == (TAMP_SR_TAMP2F)) ? 1U : 0U);
3865 }
3866 
3867 /**
3868   * @brief  Get tamper 3 detection flag.
3869   * @rmtoll TAMP_SR          TAMP3F        LL_RTC_IsActiveFlag_TAMP3
3870   * @param  RTCx RTC Instance
3871   * @retval State of bit (1 or 0).
3872   */
LL_RTC_IsActiveFlag_TAMP3(RTC_TypeDef * RTCx)3873 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP3(RTC_TypeDef *RTCx)
3874 {
3875   UNUSED(RTCx);
3876   return ((READ_BIT(TAMP->SR, TAMP_SR_TAMP3F) == (TAMP_SR_TAMP3F)) ? 1U : 0U);
3877 }
3878 /**
3879   * @brief  Get internal tamper 3 detection flag.
3880   * @rmtoll TAMP_SR          ITAMP3F        LL_RTC_IsActiveFlag_ITAMP3
3881   * @param  RTCx RTC Instance
3882   * @retval State of bit (1 or 0).
3883   */
LL_RTC_IsActiveFlag_ITAMP3(RTC_TypeDef * RTCx)3884 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP3(RTC_TypeDef *RTCx)
3885 {
3886   UNUSED(RTCx);
3887   return ((READ_BIT(TAMP->SR, TAMP_SR_ITAMP3F) == (TAMP_SR_ITAMP3F)) ? 1U : 0U);
3888 }
3889 
3890 
3891 /**
3892   * @brief  Get internal tamper 5 detection flag.
3893   * @rmtoll TAMP_SR          ITAMP5F        LL_RTC_IsActiveFlag_ITAMP5
3894   * @param  RTCx RTC Instance
3895   * @retval State of bit (1 or 0).
3896   */
LL_RTC_IsActiveFlag_ITAMP5(RTC_TypeDef * RTCx)3897 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP5(RTC_TypeDef *RTCx)
3898 {
3899   UNUSED(RTCx);
3900   return ((READ_BIT(TAMP->SR, TAMP_SR_ITAMP5F) == (TAMP_SR_ITAMP5F)) ? 1U : 0U);
3901 }
3902 
3903 /**
3904   * @brief  Get internal tamper 6 detection flag.
3905   * @rmtoll TAMP_SR          ITAMP6F        LL_RTC_IsActiveFlag_ITAMP6
3906   * @param  RTCx RTC Instance
3907   * @retval State of bit (1 or 0).
3908   */
LL_RTC_IsActiveFlag_ITAMP6(RTC_TypeDef * RTCx)3909 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP6(RTC_TypeDef *RTCx)
3910 {
3911   UNUSED(RTCx);
3912   return ((READ_BIT(TAMP->SR, TAMP_SR_ITAMP6F) == (TAMP_SR_ITAMP6F)) ? 1U : 0U);
3913 }
3914 
3915 /**
3916   * @brief  Get internal tamper 8 detection flag.
3917   * @rmtoll TAMP_SR          ITAMP8F        LL_RTC_IsActiveFlag_ITAMP8
3918   * @param  RTCx RTC Instance
3919   * @retval State of bit (1 or 0).
3920   */
LL_RTC_IsActiveFlag_ITAMP8(RTC_TypeDef * RTCx)3921 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP8(RTC_TypeDef *RTCx)
3922 {
3923   UNUSED(RTCx);
3924   return ((READ_BIT(TAMP->SR, TAMP_SR_ITAMP8F) == (TAMP_SR_ITAMP8F)) ? 1U : 0U);
3925 }
3926 
3927 /**
3928   * @brief  Get tamper 1 interrupt masked flag.
3929   * @rmtoll TAMP_MISR          TAMP1MF        LL_RTC_IsActiveFlag_TAMP1M
3930   * @param  RTCx RTC Instance
3931   * @retval State of bit (1 or 0).
3932   */
LL_RTC_IsActiveFlag_TAMP1M(RTC_TypeDef * RTCx)3933 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP1M(RTC_TypeDef *RTCx)
3934 {
3935   UNUSED(RTCx);
3936   return ((READ_BIT(TAMP->MISR, TAMP_MISR_TAMP1MF) == (TAMP_MISR_TAMP1MF)) ? 1U : 0U);
3937 }
3938 
3939 /**
3940   * @brief  Get tamper 2 interrupt masked flag.
3941   * @rmtoll TAMP_MISR          TAMP2MF        LL_RTC_IsActiveFlag_TAMP2M
3942   * @param  RTCx RTC Instance
3943   * @retval State of bit (1 or 0).
3944   */
LL_RTC_IsActiveFlag_TAMP2M(RTC_TypeDef * RTCx)3945 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP2M(RTC_TypeDef *RTCx)
3946 {
3947   UNUSED(RTCx);
3948   return ((READ_BIT(TAMP->MISR, TAMP_MISR_TAMP2MF) == (TAMP_MISR_TAMP2MF)) ? 1U : 0U);
3949 }
3950 
3951 /**
3952   * @brief  Get tamper 3 interrupt masked flag.
3953   * @rmtoll TAMP_MISR          TAMP3MF        LL_RTC_IsActiveFlag_TAMP3M
3954   * @param  RTCx RTC Instance
3955   * @retval State of bit (1 or 0).
3956   */
LL_RTC_IsActiveFlag_TAMP3M(RTC_TypeDef * RTCx)3957 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP3M(RTC_TypeDef *RTCx)
3958 {
3959   UNUSED(RTCx);
3960   return ((READ_BIT(TAMP->MISR, TAMP_MISR_TAMP3MF) == (TAMP_MISR_TAMP3MF)) ? 1U : 0U);
3961 }
3962 
3963 /**
3964   * @brief  Get internal tamper 3 interrupt masked flag.
3965   * @rmtoll TAMP_MISR          ITAMP3MF        LL_RTC_IsActiveFlag_ITAMP3M
3966   * @param  RTCx RTC Instance
3967   * @retval State of bit (1 or 0).
3968   */
LL_RTC_IsActiveFlag_ITAMP3M(RTC_TypeDef * RTCx)3969 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP3M(RTC_TypeDef *RTCx)
3970 {
3971   UNUSED(RTCx);
3972   return ((READ_BIT(TAMP->MISR, TAMP_MISR_ITAMP3MF) == (TAMP_MISR_ITAMP3MF)) ? 1U : 0U);
3973 }
3974 
3975 /**
3976   * @brief  Get internal tamper 5 interrupt masked flag.
3977   * @rmtoll TAMP_MISR          ITAMP5MF        LL_RTC_IsActiveFlag_ITAMP5M
3978   * @param  RTCx RTC Instance
3979   * @retval State of bit (1 or 0).
3980   */
LL_RTC_IsActiveFlag_ITAMP5M(RTC_TypeDef * RTCx)3981 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP5M(RTC_TypeDef *RTCx)
3982 {
3983   UNUSED(RTCx);
3984   return ((READ_BIT(TAMP->MISR, TAMP_MISR_ITAMP5MF) == (TAMP_MISR_ITAMP5MF)) ? 1U : 0U);
3985 }
3986 
3987 /**
3988   * @brief  Get internal tamper 6 interrupt masked flag.
3989   * @rmtoll TAMP_MISR          ITAMP6MF        LL_RTC_IsActiveFlag_ITAMP6M
3990   * @param  RTCx RTC Instance
3991   * @retval State of bit (1 or 0).
3992   */
LL_RTC_IsActiveFlag_ITAMP6M(RTC_TypeDef * RTCx)3993 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP6M(RTC_TypeDef *RTCx)
3994 {
3995   UNUSED(RTCx);
3996   return ((READ_BIT(TAMP->MISR, TAMP_MISR_ITAMP6MF) == (TAMP_MISR_ITAMP6MF)) ? 1U : 0U);
3997 }
3998 
3999 /**
4000   * @brief  Get internal tamper 8 interrupt masked flag.
4001   * @rmtoll TAMP_MISR          ITAMP8MF        LL_RTC_IsActiveFlag_ITAMP8M
4002   * @param  RTCx RTC Instance
4003   * @retval State of bit (1 or 0).
4004   */
LL_RTC_IsActiveFlag_ITAMP8M(RTC_TypeDef * RTCx)4005 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP8M(RTC_TypeDef *RTCx)
4006 {
4007   UNUSED(RTCx);
4008   return ((READ_BIT(TAMP->MISR, TAMP_MISR_ITAMP8MF) == (TAMP_MISR_ITAMP8MF)) ? 1U : 0U);
4009 }
4010 
4011 /**
4012   * @brief  Clear tamper 1 detection flag.
4013   * @rmtoll TAMP_SCR          CTAMP1F         LL_RTC_ClearFlag_TAMP1
4014   * @param  RTCx RTC Instance
4015   * @retval None
4016   */
LL_RTC_ClearFlag_TAMP1(RTC_TypeDef * RTCx)4017 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP1(RTC_TypeDef *RTCx)
4018 {
4019   UNUSED(RTCx);
4020   WRITE_REG(TAMP->SCR, TAMP_SCR_CTAMP1F);
4021 }
4022 
4023 /**
4024   * @brief  Clear tamper 2 detection flag.
4025   * @rmtoll TAMP_SCR          CTAMP2F         LL_RTC_ClearFlag_TAMP2
4026   * @param  RTCx RTC Instance
4027   * @retval None
4028   */
LL_RTC_ClearFlag_TAMP2(RTC_TypeDef * RTCx)4029 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP2(RTC_TypeDef *RTCx)
4030 {
4031   UNUSED(RTCx);
4032   WRITE_REG(TAMP->SCR, TAMP_SCR_CTAMP2F);
4033 }
4034 
4035 /**
4036   * @brief  Clear tamper 3 detection flag.
4037   * @rmtoll TAMP_SCR          CTAMP3F         LL_RTC_ClearFlag_TAMP3
4038   * @param  RTCx RTC Instance
4039   * @retval None
4040   */
LL_RTC_ClearFlag_TAMP3(RTC_TypeDef * RTCx)4041 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP3(RTC_TypeDef *RTCx)
4042 {
4043   UNUSED(RTCx);
4044   WRITE_REG(TAMP->SCR, TAMP_SCR_CTAMP3F);
4045 }
4046 
4047 
4048 /**
4049   * @brief  Clear internal tamper 3 detection flag.
4050   * @rmtoll TAMP_SCR          CITAMP3F         LL_RTC_ClearFlag_ITAMP3
4051   * @param  RTCx RTC Instance
4052   * @retval None
4053   */
LL_RTC_ClearFlag_ITAMP3(RTC_TypeDef * RTCx)4054 __STATIC_INLINE void LL_RTC_ClearFlag_ITAMP3(RTC_TypeDef *RTCx)
4055 {
4056   UNUSED(RTCx);
4057   WRITE_REG(TAMP->SCR, TAMP_SCR_CITAMP3F);
4058 }
4059 
4060 /**
4061   * @brief  Clear internal tamper 5 detection flag.
4062   * @rmtoll TAMP_SCR          CITAMP5F         LL_RTC_ClearFlag_ITAMP5
4063   * @param  RTCx RTC Instance
4064   * @retval None
4065   */
LL_RTC_ClearFlag_ITAMP5(RTC_TypeDef * RTCx)4066 __STATIC_INLINE void LL_RTC_ClearFlag_ITAMP5(RTC_TypeDef *RTCx)
4067 {
4068   UNUSED(RTCx);
4069   WRITE_REG(TAMP->SCR, TAMP_SCR_CITAMP5F);
4070 }
4071 
4072 /**
4073   * @brief  Clear internal tamper 6 detection flag.
4074   * @rmtoll TAMP_SCR          CITAMP6F         LL_RTC_ClearFlag_ITAMP6
4075   * @param  RTCx RTC Instance
4076   * @retval None
4077   */
LL_RTC_ClearFlag_ITAMP6(RTC_TypeDef * RTCx)4078 __STATIC_INLINE void LL_RTC_ClearFlag_ITAMP6(RTC_TypeDef *RTCx)
4079 {
4080   UNUSED(RTCx);
4081   WRITE_REG(TAMP->SCR, TAMP_SCR_CITAMP6F);
4082 }
4083 
4084 /**
4085   * @brief  Clear internal tamper 8 detection flag.
4086   * @rmtoll TAMP_SCR          CITAMP8F         LL_RTC_ClearFlag_ITAMP8
4087   * @param  RTCx RTC Instance
4088   * @retval None
4089   */
LL_RTC_ClearFlag_ITAMP8(RTC_TypeDef * RTCx)4090 __STATIC_INLINE void LL_RTC_ClearFlag_ITAMP8(RTC_TypeDef *RTCx)
4091 {
4092   UNUSED(RTCx);
4093   WRITE_REG(TAMP->SCR, TAMP_SCR_CITAMP8F);
4094 }
4095 
4096 /**
4097   * @}
4098   */
4099 
4100 /** @defgroup RTC_LL_EF_IT_Management IT_Management
4101   * @{
4102   */
4103 
4104 /**
4105   * @brief  Enable Time-stamp interrupt
4106   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
4107   * @rmtoll RTC_CR          TSIE         LL_RTC_EnableIT_TS
4108   * @param  RTCx RTC Instance
4109   * @retval None
4110   */
LL_RTC_EnableIT_TS(RTC_TypeDef * RTCx)4111 __STATIC_INLINE void LL_RTC_EnableIT_TS(RTC_TypeDef *RTCx)
4112 {
4113   SET_BIT(RTCx->CR, RTC_CR_TSIE);
4114 }
4115 
4116 /**
4117   * @brief  Disable Time-stamp interrupt
4118   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
4119   * @rmtoll RTC_CR          TSIE         LL_RTC_DisableIT_TS
4120   * @param  RTCx RTC Instance
4121   * @retval None
4122   */
LL_RTC_DisableIT_TS(RTC_TypeDef * RTCx)4123 __STATIC_INLINE void LL_RTC_DisableIT_TS(RTC_TypeDef *RTCx)
4124 {
4125   CLEAR_BIT(RTCx->CR, RTC_CR_TSIE);
4126 }
4127 
4128 /**
4129   * @brief  Enable Wakeup timer interrupt
4130   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
4131   * @rmtoll RTC_CR          WUTIE         LL_RTC_EnableIT_WUT
4132   * @param  RTCx RTC Instance
4133   * @retval None
4134   */
LL_RTC_EnableIT_WUT(RTC_TypeDef * RTCx)4135 __STATIC_INLINE void LL_RTC_EnableIT_WUT(RTC_TypeDef *RTCx)
4136 {
4137   SET_BIT(RTCx->CR, RTC_CR_WUTIE);
4138 }
4139 
4140 /**
4141   * @brief  Disable Wakeup timer interrupt
4142   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
4143   * @rmtoll RTC_CR          WUTIE         LL_RTC_DisableIT_WUT
4144   * @param  RTCx RTC Instance
4145   * @retval None
4146   */
LL_RTC_DisableIT_WUT(RTC_TypeDef * RTCx)4147 __STATIC_INLINE void LL_RTC_DisableIT_WUT(RTC_TypeDef *RTCx)
4148 {
4149   CLEAR_BIT(RTCx->CR, RTC_CR_WUTIE);
4150 }
4151 
4152 /**
4153   * @brief  Enable Alarm B interrupt
4154   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
4155   * @rmtoll RTC_CR           ALRBIE        LL_RTC_EnableIT_ALRB
4156   * @param  RTCx RTC Instance
4157   * @retval None
4158   */
LL_RTC_EnableIT_ALRB(RTC_TypeDef * RTCx)4159 __STATIC_INLINE void LL_RTC_EnableIT_ALRB(RTC_TypeDef *RTCx)
4160 {
4161   SET_BIT(RTCx->CR, RTC_CR_ALRBIE);
4162 }
4163 
4164 /**
4165   * @brief  Disable Alarm B interrupt
4166   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
4167   * @rmtoll RTC_CR           ALRBIE        LL_RTC_DisableIT_ALRB
4168   * @param  RTCx RTC Instance
4169   * @retval None
4170   */
LL_RTC_DisableIT_ALRB(RTC_TypeDef * RTCx)4171 __STATIC_INLINE void LL_RTC_DisableIT_ALRB(RTC_TypeDef *RTCx)
4172 {
4173   CLEAR_BIT(RTCx->CR, RTC_CR_ALRBIE);
4174 }
4175 
4176 /**
4177   * @brief  Enable Alarm A interrupt
4178   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
4179   * @rmtoll RTC_CR           ALRAIE        LL_RTC_EnableIT_ALRA
4180   * @param  RTCx RTC Instance
4181   * @retval None
4182   */
LL_RTC_EnableIT_ALRA(RTC_TypeDef * RTCx)4183 __STATIC_INLINE void LL_RTC_EnableIT_ALRA(RTC_TypeDef *RTCx)
4184 {
4185   SET_BIT(RTCx->CR, RTC_CR_ALRAIE);
4186 }
4187 
4188 /**
4189   * @brief  Disable Alarm A interrupt
4190   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
4191   * @rmtoll RTC_CR           ALRAIE        LL_RTC_DisableIT_ALRA
4192   * @param  RTCx RTC Instance
4193   * @retval None
4194   */
LL_RTC_DisableIT_ALRA(RTC_TypeDef * RTCx)4195 __STATIC_INLINE void LL_RTC_DisableIT_ALRA(RTC_TypeDef *RTCx)
4196 {
4197   CLEAR_BIT(RTCx->CR, RTC_CR_ALRAIE);
4198 }
4199 
4200 /**
4201   * @brief  Enable SSR Underflow interrupt
4202   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
4203   * @rmtoll RTC_CR           SSRUIE        LL_RTC_EnableIT_SSRU
4204   * @param  RTCx RTC Instance
4205   * @retval None
4206   */
LL_RTC_EnableIT_SSRU(RTC_TypeDef * RTCx)4207 __STATIC_INLINE void LL_RTC_EnableIT_SSRU(RTC_TypeDef *RTCx)
4208 {
4209   SET_BIT(RTCx->CR, RTC_CR_SSRUIE);
4210 }
4211 
4212 /**
4213   * @brief  Disable SSR Underflow interrupt
4214   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
4215   * @rmtoll RTC_CR           SSRUIE        LL_RTC_DisableIT_SSRU
4216   * @param  RTCx RTC Instance
4217   * @retval None
4218   */
LL_RTC_DisableIT_SSRU(RTC_TypeDef * RTCx)4219 __STATIC_INLINE void LL_RTC_DisableIT_SSRU(RTC_TypeDef *RTCx)
4220 {
4221   CLEAR_BIT(RTCx->CR, RTC_CR_SSRUIE);
4222 }
4223 
4224 /**
4225   * @brief  Check if Time-stamp interrupt is enabled or not
4226   * @rmtoll RTC_CR           TSIE          LL_RTC_IsEnabledIT_TS
4227   * @param  RTCx RTC Instance
4228   * @retval State of bit (1 or 0).
4229   */
LL_RTC_IsEnabledIT_TS(RTC_TypeDef * RTCx)4230 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TS(RTC_TypeDef *RTCx)
4231 {
4232   return ((READ_BIT(RTCx->CR, RTC_CR_TSIE) == (RTC_CR_TSIE)) ? 1U : 0U);
4233 }
4234 
4235 /**
4236   * @brief  Check if Wakeup timer interrupt is enabled or not
4237   * @rmtoll RTC_CR           WUTIE         LL_RTC_IsEnabledIT_WUT
4238   * @param  RTCx RTC Instance
4239   * @retval State of bit (1 or 0).
4240   */
LL_RTC_IsEnabledIT_WUT(RTC_TypeDef * RTCx)4241 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_WUT(RTC_TypeDef *RTCx)
4242 {
4243   return ((READ_BIT(RTCx->CR, RTC_CR_WUTIE) == (RTC_CR_WUTIE)) ? 1U : 0U);
4244 }
4245 
4246 /**
4247   * @brief  Check if Alarm B interrupt is enabled or not
4248   * @rmtoll RTC_CR           ALRBIE        LL_RTC_IsEnabledIT_ALRB
4249   * @param  RTCx RTC Instance
4250   * @retval State of bit (1 or 0).
4251   */
LL_RTC_IsEnabledIT_ALRB(RTC_TypeDef * RTCx)4252 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRB(RTC_TypeDef *RTCx)
4253 {
4254   return ((READ_BIT(RTCx->CR, RTC_CR_ALRBIE) == (RTC_CR_ALRBIE)) ? 1U : 0U);
4255 }
4256 
4257 /**
4258   * @brief  Check if Alarm A interrupt is enabled or not
4259   * @rmtoll RTC_CR           ALRAIE        LL_RTC_IsEnabledIT_ALRA
4260   * @param  RTCx RTC Instance
4261   * @retval State of bit (1 or 0).
4262   */
LL_RTC_IsEnabledIT_ALRA(RTC_TypeDef * RTCx)4263 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRA(RTC_TypeDef *RTCx)
4264 {
4265   return ((READ_BIT(RTCx->CR, RTC_CR_ALRAIE) == (RTC_CR_ALRAIE)) ? 1U : 0U);
4266 }
4267 
4268 /**
4269   * @brief  Check if SSR Underflow interrupt is enabled or not
4270   * @rmtoll RTC_CR           SSRUIE        LL_RTC_IsEnabledIT_SSRU
4271   * @param  RTCx RTC Instance
4272   * @retval State of bit (1 or 0).
4273   */
LL_RTC_IsEnabledIT_SSRU(RTC_TypeDef * RTCx)4274 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_SSRU(RTC_TypeDef *RTCx)
4275 {
4276   return ((READ_BIT(RTCx->CR, RTC_CR_SSRUIE) == (RTC_CR_SSRUIE)) ? 1U : 0U);
4277 }
4278 
4279 /**
4280   * @brief  Enable tamper 1 interrupt.
4281   * @rmtoll TAMP_IER           TAMP1IE          LL_RTC_EnableIT_TAMP1
4282   * @param  RTCx RTC Instance
4283   * @retval None
4284   */
LL_RTC_EnableIT_TAMP1(RTC_TypeDef * RTCx)4285 __STATIC_INLINE void LL_RTC_EnableIT_TAMP1(RTC_TypeDef *RTCx)
4286 {
4287   UNUSED(RTCx);
4288   SET_BIT(TAMP->IER, TAMP_IER_TAMP1IE);
4289 }
4290 
4291 /**
4292   * @brief  Disable tamper 1 interrupt.
4293   * @rmtoll TAMP_IER           TAMP1IE          LL_RTC_DisableIT_TAMP1
4294   * @param  RTCx RTC Instance
4295   * @retval None
4296   */
LL_RTC_DisableIT_TAMP1(RTC_TypeDef * RTCx)4297 __STATIC_INLINE void LL_RTC_DisableIT_TAMP1(RTC_TypeDef *RTCx)
4298 {
4299   UNUSED(RTCx);
4300   CLEAR_BIT(TAMP->IER, TAMP_IER_TAMP1IE);
4301 }
4302 
4303 /**
4304   * @brief  Enable tamper 2 interrupt.
4305   * @rmtoll TAMP_IER           TAMP2IE          LL_RTC_EnableIT_TAMP2
4306   * @param  RTCx RTC Instance
4307   * @retval None
4308   */
LL_RTC_EnableIT_TAMP2(RTC_TypeDef * RTCx)4309 __STATIC_INLINE void LL_RTC_EnableIT_TAMP2(RTC_TypeDef *RTCx)
4310 {
4311   UNUSED(RTCx);
4312   SET_BIT(TAMP->IER, TAMP_IER_TAMP2IE);
4313 }
4314 
4315 /**
4316   * @brief  Disable tamper 2 interrupt.
4317   * @rmtoll TAMP_IER           TAMP2IE          LL_RTC_DisableIT_TAMP2
4318   * @param  RTCx RTC Instance
4319   * @retval None
4320   */
LL_RTC_DisableIT_TAMP2(RTC_TypeDef * RTCx)4321 __STATIC_INLINE void LL_RTC_DisableIT_TAMP2(RTC_TypeDef *RTCx)
4322 {
4323   UNUSED(RTCx);
4324   CLEAR_BIT(TAMP->IER, TAMP_IER_TAMP2IE);
4325 }
4326 
4327 /**
4328   * @brief  Enable tamper 3 interrupt.
4329   * @rmtoll TAMP_IER           TAMP3IE          LL_RTC_EnableIT_TAMP3
4330   * @param  RTCx RTC Instance
4331   * @retval None
4332   */
LL_RTC_EnableIT_TAMP3(RTC_TypeDef * RTCx)4333 __STATIC_INLINE void LL_RTC_EnableIT_TAMP3(RTC_TypeDef *RTCx)
4334 {
4335   UNUSED(RTCx);
4336   SET_BIT(TAMP->IER, TAMP_IER_TAMP3IE);
4337 }
4338 /**
4339   * @brief  Disable tamper 3 interrupt.
4340   * @rmtoll TAMP_IER           TAMP3IE          LL_RTC_DisableIT_TAMP3
4341   * @param  RTCx RTC Instance
4342   * @retval None
4343   */
LL_RTC_DisableIT_TAMP3(RTC_TypeDef * RTCx)4344 __STATIC_INLINE void LL_RTC_DisableIT_TAMP3(RTC_TypeDef *RTCx)
4345 {
4346   UNUSED(RTCx);
4347   CLEAR_BIT(TAMP->IER, TAMP_IER_TAMP3IE);
4348 }
4349 
4350 /**
4351   * @brief  Enable internal tamper 3 interrupt.
4352   * @rmtoll TAMP_IER           ITAMP3IE          LL_RTC_EnableIT_ITAMP3
4353   * @param  RTCx RTC Instance
4354   * @retval None
4355   */
LL_RTC_EnableIT_ITAMP3(RTC_TypeDef * RTCx)4356 __STATIC_INLINE void LL_RTC_EnableIT_ITAMP3(RTC_TypeDef *RTCx)
4357 {
4358   UNUSED(RTCx);
4359   SET_BIT(TAMP->IER, TAMP_IER_ITAMP3IE);
4360 }
4361 /**
4362   * @brief  Disable internal tamper 3 interrupt.
4363   * @rmtoll TAMP_IER           ITAMP3IE          LL_RTC_DisableIT_ITAMP3
4364   * @param  RTCx RTC Instance
4365   * @retval None
4366   */
LL_RTC_DisableIT_ITAMP3(RTC_TypeDef * RTCx)4367 __STATIC_INLINE void LL_RTC_DisableIT_ITAMP3(RTC_TypeDef *RTCx)
4368 {
4369   UNUSED(RTCx);
4370   CLEAR_BIT(TAMP->IER, TAMP_IER_ITAMP3IE);
4371 }
4372 
4373 /**
4374   * @brief  Enable internal tamper 5 interrupt.
4375   * @rmtoll TAMP_IER           ITAMP5IE          LL_RTC_EnableIT_ITAMP5
4376   * @param  RTCx RTC Instance
4377   * @retval None
4378   */
LL_RTC_EnableIT_ITAMP5(RTC_TypeDef * RTCx)4379 __STATIC_INLINE void LL_RTC_EnableIT_ITAMP5(RTC_TypeDef *RTCx)
4380 {
4381   UNUSED(RTCx);
4382   SET_BIT(TAMP->IER, TAMP_IER_ITAMP5IE);
4383 }
4384 /**
4385   * @brief  Disable internal tamper 5 interrupt.
4386   * @rmtoll TAMP_IER           ITAMP5IE          LL_RTC_DisableIT_ITAMP5
4387   * @param  RTCx RTC Instance
4388   * @retval None
4389   */
LL_RTC_DisableIT_ITAMP5(RTC_TypeDef * RTCx)4390 __STATIC_INLINE void LL_RTC_DisableIT_ITAMP5(RTC_TypeDef *RTCx)
4391 {
4392   UNUSED(RTCx);
4393   CLEAR_BIT(TAMP->IER, TAMP_IER_ITAMP5IE);
4394 }
4395 
4396 /**
4397   * @brief  Enable internal tamper 6 interrupt.
4398   * @rmtoll TAMP_IER           ITAMP6IE          LL_RTC_EnableIT_ITAMP6
4399   * @param  RTCx RTC Instance
4400   * @retval None
4401   */
LL_RTC_EnableIT_ITAMP6(RTC_TypeDef * RTCx)4402 __STATIC_INLINE void LL_RTC_EnableIT_ITAMP6(RTC_TypeDef *RTCx)
4403 {
4404   UNUSED(RTCx);
4405   SET_BIT(TAMP->IER, TAMP_IER_ITAMP6IE);
4406 }
4407 
4408 /**
4409   * @brief  Disable internal tamper 6 interrupt.
4410   * @rmtoll TAMP_IER           TAMP6IE          LL_RTC_DisableIT_ITAMP6
4411   * @param  RTCx RTC Instance
4412   * @retval None
4413   */
LL_RTC_DisableIT_ITAMP6(RTC_TypeDef * RTCx)4414 __STATIC_INLINE void LL_RTC_DisableIT_ITAMP6(RTC_TypeDef *RTCx)
4415 {
4416   UNUSED(RTCx);
4417   CLEAR_BIT(TAMP->IER, TAMP_IER_ITAMP6IE);
4418 }
4419 
4420 /**
4421   * @brief  Enable internal tamper 8 interrupt.
4422   * @rmtoll TAMP_IER           ITAMP8IE          LL_RTC_EnableIT_ITAMP8
4423   * @param  RTCx RTC Instance
4424   * @retval None
4425   */
LL_RTC_EnableIT_ITAMP8(RTC_TypeDef * RTCx)4426 __STATIC_INLINE void LL_RTC_EnableIT_ITAMP8(RTC_TypeDef *RTCx)
4427 {
4428   UNUSED(RTCx);
4429   SET_BIT(TAMP->IER, TAMP_IER_ITAMP8IE);
4430 }
4431 
4432 /**
4433   * @brief  Disable internal tamper 8 interrupt.
4434   * @rmtoll TAMP_IER           TAMP8IE          LL_RTC_DisableIT_ITAMP8
4435   * @param  RTCx RTC Instance
4436   * @retval None
4437   */
LL_RTC_DisableIT_ITAMP8(RTC_TypeDef * RTCx)4438 __STATIC_INLINE void LL_RTC_DisableIT_ITAMP8(RTC_TypeDef *RTCx)
4439 {
4440   UNUSED(RTCx);
4441   CLEAR_BIT(TAMP->IER, TAMP_IER_ITAMP8IE);
4442 }
4443 
4444 /**
4445   * @brief  Check if tamper 1 interrupt is enabled or not.
4446   * @rmtoll TAMP_IER           TAMP1IE        LL_RTC_IsEnabledIT_TAMP1
4447   * @param  RTCx RTC Instance
4448   * @retval State of bit (1 or 0).
4449   */
LL_RTC_IsEnabledIT_TAMP1(RTC_TypeDef * RTCx)4450 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP1(RTC_TypeDef *RTCx)
4451 {
4452   UNUSED(RTCx);
4453   return ((READ_BIT(TAMP->IER, TAMP_IER_TAMP1IE) == (TAMP_IER_TAMP1IE)) ? 1U : 0U);
4454 }
4455 
4456 /**
4457   * @brief  Check if tamper 2 interrupt is enabled or not.
4458   * @rmtoll TAMP_IER           TAMP2IE        LL_RTC_IsEnabledIT_TAMP2
4459   * @param  RTCx RTC Instance
4460   * @retval State of bit (1 or 0).
4461   */
LL_RTC_IsEnabledIT_TAMP2(RTC_TypeDef * RTCx)4462 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP2(RTC_TypeDef *RTCx)
4463 {
4464   UNUSED(RTCx);
4465   return ((READ_BIT(TAMP->IER, TAMP_IER_TAMP2IE) == (TAMP_IER_TAMP2IE)) ? 1U : 0U);
4466 }
4467 
4468 /**
4469   * @brief  Check if tamper 3 interrupt is enabled or not.
4470   * @rmtoll TAMP_IER           TAMP3IE        LL_RTC_IsEnabledIT_TAMP3
4471   * @param  RTCx RTC Instance
4472   * @retval State of bit (1 or 0).
4473   */
LL_RTC_IsEnabledIT_TAMP3(RTC_TypeDef * RTCx)4474 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP3(RTC_TypeDef *RTCx)
4475 {
4476   UNUSED(RTCx);
4477   return ((READ_BIT(TAMP->IER, TAMP_IER_TAMP3IE) == (TAMP_IER_TAMP3IE)) ? 1U : 0U);
4478 }
4479 
4480 /**
4481   * @brief  Check if internal tamper 3 interrupt is enabled or not.
4482   * @rmtoll TAMP_IER           ITAMP3IE        LL_RTC_IsEnabledIT_ITAMP3
4483   * @param  RTCx RTC Instance
4484   * @retval State of bit (1 or 0).
4485   */
LL_RTC_IsEnabledIT_ITAMP3(RTC_TypeDef * RTCx)4486 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ITAMP3(RTC_TypeDef *RTCx)
4487 {
4488   UNUSED(RTCx);
4489   return ((READ_BIT(TAMP->IER, TAMP_IER_ITAMP3IE) == (TAMP_IER_ITAMP3IE)) ? 1U : 0U);
4490 }
4491 
4492 /**
4493   * @brief  Check if internal tamper 5 interrupt is enabled or not.
4494   * @rmtoll TAMP_IER           ITAMP5IE        LL_RTC_IsEnabledIT_ITAMP5
4495   * @param  RTCx RTC Instance
4496   * @retval State of bit (1 or 0).
4497   */
LL_RTC_IsEnabledIT_ITAMP5(RTC_TypeDef * RTCx)4498 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ITAMP5(RTC_TypeDef *RTCx)
4499 {
4500   UNUSED(RTCx);
4501   return ((READ_BIT(TAMP->IER, TAMP_IER_ITAMP5IE) == (TAMP_IER_ITAMP5IE)) ? 1U : 0U);
4502 }
4503 
4504 /**
4505   * @brief  Check if internal tamper 6 interrupt is enabled or not.
4506   * @rmtoll TAMP_IER           ITAMP6IE        LL_RTC_IsEnabledIT_ITAMP6
4507   * @param  RTCx RTC Instance
4508   * @retval State of bit (1 or 0).
4509   */
LL_RTC_IsEnabledIT_ITAMP6(RTC_TypeDef * RTCx)4510 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ITAMP6(RTC_TypeDef *RTCx)
4511 {
4512   UNUSED(RTCx);
4513   return ((READ_BIT(TAMP->IER, TAMP_IER_ITAMP6IE) == (TAMP_IER_ITAMP6IE)) ? 1U : 0U);
4514 }
4515 
4516 /**
4517   * @brief  Check if internal tamper 8 interrupt is enabled or not.
4518   * @rmtoll TAMP_IER           ITAMP8IE        LL_RTC_IsEnabledIT_ITAMP8
4519   * @param  RTCx RTC Instance
4520   * @retval State of bit (1 or 0).
4521   */
LL_RTC_IsEnabledIT_ITAMP8(RTC_TypeDef * RTCx)4522 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ITAMP8(RTC_TypeDef *RTCx)
4523 {
4524   UNUSED(RTCx);
4525   return ((READ_BIT(TAMP->IER, TAMP_IER_ITAMP8IE) == (TAMP_IER_ITAMP8IE)) ? 1U : 0U);
4526 }
4527 
4528 
4529 /**
4530   * @brief  Increment Monotonic counter.
4531   * @rmtoll TAMP_COUNTR         COUNT        LL_RTC_IncrementMonotonicCounter
4532   * @param  RTCx RTC Instance
4533   * @retval None.
4534   */
LL_RTC_IncrementMonotonicCounter(RTC_TypeDef * RTCx)4535 __STATIC_INLINE void LL_RTC_IncrementMonotonicCounter(RTC_TypeDef *RTCx)
4536 {
4537   UNUSED(RTCx);
4538   WRITE_REG(TAMP->COUNTR, 0u);
4539 }
4540 
4541 /**
4542   * @brief  Increment Monotonic counter.
4543   * @rmtoll TAMP_COUNTR         COUNT        LL_RTC_GetMonotonicCounter
4544   * @param  RTCx RTC Instance
4545   * @retval Monotonic counter value.
4546   */
LL_RTC_GetMonotonicCounter(RTC_TypeDef * RTCx)4547 __STATIC_INLINE uint32_t LL_RTC_GetMonotonicCounter(RTC_TypeDef *RTCx)
4548 {
4549   UNUSED(RTCx);
4550   return READ_REG(TAMP->COUNTR);
4551 }
4552 
4553 /**
4554   * @}
4555   */
4556 
4557 #if defined(USE_FULL_LL_DRIVER)
4558 /** @defgroup RTC_LL_EF_Init Initialization and de-initialization functions
4559   * @{
4560   */
4561 
4562 ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx);
4563 ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct);
4564 void        LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct);
4565 ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct);
4566 void        LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct);
4567 ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct);
4568 void        LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct);
4569 ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
4570 ErrorStatus LL_RTC_ALMB_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
4571 void        LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
4572 void        LL_RTC_ALMB_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
4573 ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx);
4574 ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx);
4575 ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx);
4576 
4577 /**
4578   * @}
4579   */
4580 #endif /* USE_FULL_LL_DRIVER */
4581 
4582 /**
4583   * @}
4584   */
4585 
4586 /**
4587   * @}
4588   */
4589 
4590 #endif /* defined(RTC) */
4591 
4592 /**
4593   * @}
4594   */
4595 
4596 #ifdef __cplusplus
4597 }
4598 #endif
4599 
4600 #endif /* STM32WLxx_LL_RTC_H */
4601