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