1 /**
2   ******************************************************************************
3   * @file    stm32n6xx_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 STM32N6xx_LL_RTC_H
21 #define STM32N6xx_LL_RTC_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32n6xx.h"
29 
30 /** @addtogroup STM32N6xx_LL_Driver
31   * @{
32   */
33 
34 #if defined(RTC)
35 
36 /** @defgroup RTC_LL RTC
37   * @{
38   */
39 
40 /* Private types -------------------------------------------------------------*/
41 /* Private variables ---------------------------------------------------------*/
42 /* Private constants ---------------------------------------------------------*/
43 /** @defgroup RTC_LL_Private_Constants RTC Private Constants
44   * @{
45   */
46 /* Masks Definition */
47 #define RTC_LL_INIT_MASK              0xFFFFFFFFU
48 #define RTC_LL_RSF_MASK               0xFFFFFF5FU
49 
50 /* Write protection defines */
51 #define RTC_WRITE_PROTECTION_DISABLE  (uint8_t)0xFF
52 #define RTC_WRITE_PROTECTION_ENABLE_1 (uint8_t)0xCA
53 #define RTC_WRITE_PROTECTION_ENABLE_2 (uint8_t)0x53
54 
55 /* Defines used to combine date & time */
56 #define RTC_OFFSET_WEEKDAY            24U
57 #define RTC_OFFSET_DAY                16U
58 #define RTC_OFFSET_MONTH              8U
59 #define RTC_OFFSET_HOUR               16U
60 #define RTC_OFFSET_MINUTE             8U
61 
62 /**
63   * @}
64   */
65 
66 /* Private macros ------------------------------------------------------------*/
67 #if defined(USE_FULL_LL_DRIVER)
68 /** @defgroup RTC_LL_Private_Macros RTC Private Macros
69   * @{
70   */
71 /**
72   * @}
73   */
74 #endif /*USE_FULL_LL_DRIVER*/
75 
76 #if !defined (UNUSED)
77 #define UNUSED(x) ((void)(x))
78 #endif /* !defined (UNUSED) */
79 
80 /* Exported types ------------------------------------------------------------*/
81 #if defined(USE_FULL_LL_DRIVER)
82 /** @defgroup RTC_LL_ES_INIT RTC Exported Init structure
83   * @{
84   */
85 
86 /**
87   * @brief  RTC Init structures definition
88   */
89 typedef struct
90 {
91   uint32_t HourFormat;   /*!< Specifies the RTC Hours Format.
92                               This parameter can be a value of @ref RTC_LL_EC_HOURFORMAT
93 
94                               This feature can be modified afterwards using unitary function
95                               @ref LL_RTC_SetHourFormat(). */
96 
97   uint32_t AsynchPrescaler; /*!< Specifies the RTC Asynchronous Predivider value.
98                               This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F
99 
100                               This feature can be modified afterwards using unitary function
101                               @ref LL_RTC_SetAsynchPrescaler(). */
102 
103   uint32_t SynchPrescaler;  /*!< Specifies the RTC Synchronous Predivider value.
104                               This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF
105 
106                               This feature can be modified afterwards using unitary function
107                               @ref LL_RTC_SetSynchPrescaler(). */
108 } LL_RTC_InitTypeDef;
109 
110 /**
111   * @brief  RTC Time structure definition
112   */
113 typedef struct
114 {
115   uint32_t TimeFormat; /*!< Specifies the RTC AM/PM Time.
116                             This parameter can be a value of @ref RTC_LL_EC_TIME_FORMAT
117 
118                             This feature can be modified afterwards using unitary function
119                             @ref LL_RTC_TIME_SetFormat(). */
120 
121   uint8_t Hours;       /*!< Specifies the RTC Time Hours.
122                             This parameter must be a number between Min_Data = 0 and Max_Data = 12
123                             if the @ref LL_RTC_TIME_FORMAT_PM is selected.
124 
125                             This parameter must be a number between Min_Data = 0 and Max_Data = 23
126                             if the @ref LL_RTC_TIME_FORMAT_AM_OR_24 is selected.
127 
128                             This feature can be modified afterwards using unitary function
129                             @ref LL_RTC_TIME_SetHour(). */
130 
131   uint8_t Minutes;     /*!< Specifies the RTC Time Minutes.
132                             This parameter must be a number between Min_Data = 0 and Max_Data = 59
133 
134                             This feature can be modified afterwards using unitary function
135                             @ref LL_RTC_TIME_SetMinute(). */
136 
137   uint8_t Seconds;     /*!< Specifies the RTC Time Seconds.
138                             This parameter must be a number between Min_Data = 0 and Max_Data = 59
139 
140                             This feature can be modified afterwards using unitary function
141                             @ref LL_RTC_TIME_SetSecond(). */
142 } LL_RTC_TimeTypeDef;
143 
144 /**
145   * @brief  RTC Date structure definition
146   */
147 typedef struct
148 {
149   uint8_t WeekDay;  /*!< Specifies the RTC Date WeekDay.
150                          This parameter can be a value of @ref RTC_LL_EC_WEEKDAY
151 
152                          This feature can be modified afterwards using unitary function
153                          @ref LL_RTC_DATE_SetWeekDay(). */
154 
155   uint8_t Month;    /*!< Specifies the RTC Date Month.
156                          This parameter can be a value of @ref RTC_LL_EC_MONTH
157 
158                          This feature can be modified afterwards using unitary function
159                          @ref LL_RTC_DATE_SetMonth(). */
160 
161   uint8_t Day;      /*!< Specifies the RTC Date Day.
162                          This parameter must be a number between Min_Data = 1 and Max_Data = 31
163 
164                          This feature can be modified afterwards using unitary function
165                          @ref LL_RTC_DATE_SetDay(). */
166 
167   uint8_t Year;     /*!< Specifies the RTC Date Year.
168                          This parameter must be a number between Min_Data = 0 and Max_Data = 99
169 
170                          This feature can be modified afterwards using unitary function
171                          @ref LL_RTC_DATE_SetYear(). */
172 } LL_RTC_DateTypeDef;
173 
174 /**
175   * @brief  RTC Alarm structure definition
176   */
177 typedef struct
178 {
179   LL_RTC_TimeTypeDef AlarmTime;  /*!< Specifies the RTC Alarm Time members. */
180 
181   uint32_t AlarmMask;            /*!< Specifies the RTC Alarm Masks.
182                                       This parameter can be a value of @ref RTC_LL_EC_ALMA_MASK for ALARM A or
183                                       @ref RTC_LL_EC_ALMB_MASK for ALARM B.
184 
185                                       This feature can be modified afterwards using unitary function
186                                       @ref LL_RTC_ALMA_SetMask() for ALARM A or @ref LL_RTC_ALMB_SetMask() for ALARM B.
187                                  */
188 
189   uint32_t AlarmDateWeekDaySel;  /*!< Specifies the RTC Alarm is on day or WeekDay.
190                                       This parameter can be a value of @ref RTC_LL_EC_ALMA_WEEKDAY_SELECTION
191                                       for ALARM A or @ref RTC_LL_EC_ALMB_WEEKDAY_SELECTION for ALARM B.
192 
193                                       This feature can be modified afterwards using unitary function
194                                       @ref LL_RTC_ALMA_EnableWeekday() or @ref LL_RTC_ALMA_DisableWeekday() for ALARM A
195                                       or @ref LL_RTC_ALMB_EnableWeekday() or @ref LL_RTC_ALMB_DisableWeekday()
196                                       for ALARM B.
197                                  */
198 
199   uint8_t AlarmDateWeekDay;      /*!< Specifies the RTC Alarm Day/WeekDay.
200                                       If AlarmDateWeekDaySel set to day, this parameter must be a number
201                                       between Min_Data = 1 and Max_Data = 31.
202 
203                                       This feature can be modified afterwards using unitary function
204                                       @ref LL_RTC_ALMA_SetDay() for ALARM A or @ref LL_RTC_ALMB_SetDay() for ALARM B.
205 
206                                       If AlarmDateWeekDaySel set to Weekday, this parameter can be a value of
207                                       @ref RTC_LL_EC_WEEKDAY.
208 
209                                       This feature can be modified afterwards using unitary function
210                                       @ref LL_RTC_ALMA_SetWeekDay() for ALARM A or
211                                       @ref LL_RTC_ALMB_SetWeekDay() for ALARM B.
212                                  */
213 } LL_RTC_AlarmTypeDef;
214 
215 /**
216   * @}
217   */
218 #endif /* USE_FULL_LL_DRIVER */
219 
220 /* Exported constants --------------------------------------------------------*/
221 /** @defgroup RTC_LL_Exported_Constants RTC Exported Constants
222   * @{
223   */
224 
225 #if defined(USE_FULL_LL_DRIVER)
226 /** @defgroup RTC_LL_EC_FORMAT FORMAT
227   * @{
228   */
229 #define LL_RTC_FORMAT_BIN                  0U                    /*!< Binary data format */
230 #define LL_RTC_FORMAT_BCD                  1U                    /*!< BCD data format    */
231 /**
232   * @}
233   */
234 
235 /** @defgroup RTC_LL_EC_ALMA_WEEKDAY_SELECTION RTC Alarm A Date WeekDay
236   * @{
237   */
238 #define LL_RTC_ALMA_DATEWEEKDAYSEL_DATE    0U                    /*!< Alarm A Date is selected    */
239 #define LL_RTC_ALMA_DATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL      /*!< Alarm A WeekDay is selected */
240 /**
241   * @}
242   */
243 
244 /** @defgroup RTC_LL_EC_ALMB_WEEKDAY_SELECTION RTC Alarm B Date WeekDay
245   * @{
246   */
247 #define LL_RTC_ALMB_DATEWEEKDAYSEL_DATE    0U                    /*!< Alarm B Date is selected    */
248 #define LL_RTC_ALMB_DATEWEEKDAYSEL_WEEKDAY RTC_ALRMBR_WDSEL      /*!< Alarm B WeekDay is selected */
249 /**
250   * @}
251   */
252 
253 #endif /* USE_FULL_LL_DRIVER */
254 
255 /** @defgroup RTC_LL_EC_GET_FLAG Get Flags Defines
256   * @brief    Flags defines which can be used with LL_RTC_ReadReg function
257   * @{
258   */
259 #define LL_RTC_SCR_SSRUF                   RTC_SCR_CSSRUF
260 #define LL_RTC_SCR_ITSF                    RTC_SCR_CITSF
261 #define LL_RTC_SCR_TSOVF                   RTC_SCR_CTSOVF
262 #define LL_RTC_SCR_TSF                     RTC_SCR_CTSF
263 #define LL_RTC_SCR_WUTF                    RTC_SCR_CWUTF
264 #define LL_RTC_SCR_ALRBF                   RTC_SCR_CALRBF
265 #define LL_RTC_SCR_ALRAF                   RTC_SCR_CALRAF
266 
267 #define LL_RTC_ICSR_RECALPF                RTC_ICSR_RECALPF
268 #define LL_RTC_ICSR_BCDU_2                 RTC_ICSR_BCDU_2
269 #define LL_RTC_ICSR_BCDU_1                 RTC_ICSR_BCDU_1
270 #define LL_RTC_ICSR_BCDU_0                 RTC_ICSR_BCDU_0
271 #define LL_RTC_ICSR_BIN_1                  RTC_ICSR_BIN_1
272 #define LL_RTC_ICSR_BIN_0                  RTC_ICSR_BIN_0
273 #define LL_RTC_ICSR_INITF                  RTC_ICSR_INITF
274 #define LL_RTC_ICSR_RSF                    RTC_ICSR_RSF
275 #define LL_RTC_ICSR_INITS                  RTC_ICSR_INITS
276 #define LL_RTC_ICSR_SHPF                   RTC_ICSR_SHPF
277 #define LL_RTC_ICSR_WUTWF                  RTC_ICSR_WUTWF
278 /**
279   * @}
280   */
281 
282 /** @defgroup RTC_LL_EC_IT IT Defines
283   * @brief    IT defines which can be used with LL_RTC_ReadReg and  LL_RTC_WriteReg functions
284   * @{
285   */
286 #define LL_RTC_CR_TSIE                     RTC_CR_TSIE
287 #define LL_RTC_CR_WUTIE                    RTC_CR_WUTIE
288 #define LL_RTC_CR_ALRBIE                   RTC_CR_ALRBIE
289 #define LL_RTC_CR_ALRAIE                   RTC_CR_ALRAIE
290 /**
291   * @}
292   */
293 
294 /** @defgroup RTC_LL_EC_WEEKDAY  WEEK DAY
295   * @{
296   */
297 #define LL_RTC_WEEKDAY_MONDAY              (uint8_t)0x01         /*!< Monday    */
298 #define LL_RTC_WEEKDAY_TUESDAY             (uint8_t)0x02         /*!< Tuesday   */
299 #define LL_RTC_WEEKDAY_WEDNESDAY           (uint8_t)0x03         /*!< Wednesday */
300 #define LL_RTC_WEEKDAY_THURSDAY            (uint8_t)0x04         /*!< Thrusday  */
301 #define LL_RTC_WEEKDAY_FRIDAY              (uint8_t)0x05         /*!< Friday    */
302 #define LL_RTC_WEEKDAY_SATURDAY            (uint8_t)0x06         /*!< Saturday  */
303 #define LL_RTC_WEEKDAY_SUNDAY              (uint8_t)0x07         /*!< Sunday    */
304 /**
305   * @}
306   */
307 
308 /** @defgroup RTC_LL_EC_MONTH  MONTH
309   * @{
310   */
311 #define LL_RTC_MONTH_JANUARY               (uint8_t)0x01         /*!< January   */
312 #define LL_RTC_MONTH_FEBRUARY              (uint8_t)0x02         /*!< February  */
313 #define LL_RTC_MONTH_MARCH                 (uint8_t)0x03         /*!< March     */
314 #define LL_RTC_MONTH_APRIL                 (uint8_t)0x04         /*!< April     */
315 #define LL_RTC_MONTH_MAY                   (uint8_t)0x05         /*!< May       */
316 #define LL_RTC_MONTH_JUNE                  (uint8_t)0x06         /*!< June      */
317 #define LL_RTC_MONTH_JULY                  (uint8_t)0x07         /*!< July      */
318 #define LL_RTC_MONTH_AUGUST                (uint8_t)0x08         /*!< August    */
319 #define LL_RTC_MONTH_SEPTEMBER             (uint8_t)0x09         /*!< September */
320 #define LL_RTC_MONTH_OCTOBER               (uint8_t)0x10         /*!< October   */
321 #define LL_RTC_MONTH_NOVEMBER              (uint8_t)0x11         /*!< November  */
322 #define LL_RTC_MONTH_DECEMBER              (uint8_t)0x12         /*!< December  */
323 /**
324   * @}
325   */
326 
327 /** @defgroup RTC_LL_EC_HOURFORMAT  HOUR FORMAT
328   * @{
329   */
330 #define LL_RTC_HOURFORMAT_24HOUR           0U                    /*!< 24 hour/day format */
331 #define LL_RTC_HOURFORMAT_AMPM             RTC_CR_FMT            /*!< AM/PM hour format  */
332 /**
333   * @}
334   */
335 
336 /** @defgroup RTC_LL_EC_ALARMOUT  ALARM OUTPUT
337   * @{
338   */
339 #define LL_RTC_ALARMOUT_DISABLE            0U                    /*!< Output disabled        */
340 #define LL_RTC_ALARMOUT_ALMA               RTC_CR_OSEL_0         /*!< Alarm A output enabled */
341 #define LL_RTC_ALARMOUT_ALMB               RTC_CR_OSEL_1         /*!< Alarm B output enabled */
342 #define LL_RTC_ALARMOUT_WAKEUP             RTC_CR_OSEL           /*!< Wakeup output enabled  */
343 /**
344   * @}
345   */
346 
347 /** @defgroup RTC_LL_EC_ALARM_OUTPUTTYPE  ALARM OUTPUT TYPE
348   * @{
349   */
350 #define LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL   0U                      /*!< RTC_ALARM is push-pull output  */
351 #define LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN  RTC_CR_TAMPALRM_TYPE    /*!< RTC_ALARM is open-drain output */
352 /**
353   * @}
354   */
355 
356 /** @defgroup RTC_LL_EC_OUTPUTPOLARITY_PIN  OUTPUT POLARITY PIN
357   * @{
358   */
359 #define LL_RTC_OUTPUTPOLARITY_PIN_HIGH     0U                    /*!< Pin is high when ALRAF/ALRBF/WUTF is asserted (depending on OSEL) */
360 #define LL_RTC_OUTPUTPOLARITY_PIN_LOW      RTC_CR_POL            /*!< Pin is low when ALRAF/ALRBF/WUTF is asserted (depending on OSEL)  */
361 /**
362   * @}
363   */
364 
365 /** @defgroup RTC_LL_EC_TIME_FORMAT TIME FORMAT
366   * @{
367   */
368 #define LL_RTC_TIME_FORMAT_AM_OR_24        0U                    /*!< AM or 24-hour format */
369 #define LL_RTC_TIME_FORMAT_PM              RTC_TR_PM             /*!< PM                   */
370 /**
371   * @}
372   */
373 
374 /** @defgroup RTC_LL_EC_SHIFT_SECOND  SHIFT SECOND
375   * @{
376   */
377 #define LL_RTC_SHIFT_SECOND_DELAY          0U                    /*!< Delay (seconds) = SUBFS / (PREDIV_S + 1)           */
378 #define LL_RTC_SHIFT_SECOND_ADVANCE        RTC_SHIFTR_ADD1S      /*!< Advance (seconds) = (1 - (SUBFS / (PREDIV_S + 1))) */
379 /**
380   * @}
381   */
382 
383 /** @defgroup RTC_LL_EC_ALMA_MASK  ALARMA MASK
384   * @{
385   */
386 #define LL_RTC_ALMA_MASK_NONE              0U                    /*!< No masks applied on Alarm A                */
387 #define LL_RTC_ALMA_MASK_DATEWEEKDAY       RTC_ALRMAR_MSK4       /*!< Date/day do not care in Alarm A comparison */
388 #define LL_RTC_ALMA_MASK_HOURS             RTC_ALRMAR_MSK3       /*!< Hours do not care in Alarm A comparison    */
389 #define LL_RTC_ALMA_MASK_MINUTES           RTC_ALRMAR_MSK2       /*!< Minutes do not care in Alarm A comparison  */
390 #define LL_RTC_ALMA_MASK_SECONDS           RTC_ALRMAR_MSK1       /*!< Seconds do not care in Alarm A comparison  */
391 #define LL_RTC_ALMA_MASK_ALL               (RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1) /*!< Masks all */
392 /**
393   * @}
394   */
395 
396 /** @defgroup RTC_LL_EC_ALMA_TIME_FORMAT  ALARMA TIME FORMAT
397   * @{
398   */
399 #define LL_RTC_ALMA_TIME_FORMAT_AM         0U                    /*!< AM or 24-hour format */
400 #define LL_RTC_ALMA_TIME_FORMAT_PM         RTC_ALRMAR_PM         /*!< PM                   */
401 /**
402   * @}
403   */
404 
405 /** @defgroup RTC_LL_EC_ALMA_SUBSECONDBIN_AUTOCLR  RTC Alarm Sub Seconds with binary mode auto clear Definitions
406   * @{
407   */
408 #define LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_NO    0UL
409 /*!< The synchronous binary counter (SS[31:0] in RTC_SSR) is free-running. */
410 
411 #define LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_YES   RTC_ALRMASSR_SSCLR
412 /*!< The synchronous binary counter (SS[31:0] in RTC_SSR) is running from 0xFFFF FFFF to RTC_ALRMABINR -> SS[31:0]
413      value and is automatically reloaded with 0xFFFF FFFF when reaching RTC_ALRMABINR -> SS[31:0]. */
414 /**
415   * @}
416   */
417 
418 /** @defgroup RTC_LL_EC_ALMB_MASK  ALARMB MASK
419   * @{
420   */
421 #define LL_RTC_ALMB_MASK_NONE              0U                    /*!< No masks applied on Alarm B                */
422 #define LL_RTC_ALMB_MASK_DATEWEEKDAY       RTC_ALRMBR_MSK4       /*!< Date/day do not care in Alarm B comparison */
423 #define LL_RTC_ALMB_MASK_HOURS             RTC_ALRMBR_MSK3       /*!< Hours do not care in Alarm B comparison    */
424 #define LL_RTC_ALMB_MASK_MINUTES           RTC_ALRMBR_MSK2       /*!< Minutes do not care in Alarm B comparison  */
425 #define LL_RTC_ALMB_MASK_SECONDS           RTC_ALRMBR_MSK1       /*!< Seconds do not care in Alarm B comparison  */
426 #define LL_RTC_ALMB_MASK_ALL               (RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1) /*!< Masks all */
427 /**
428   * @}
429   */
430 
431 /** @defgroup RTC_LL_EC_ALMB_TIME_FORMAT  ALARMB TIME FORMAT
432   * @{
433   */
434 #define LL_RTC_ALMB_TIME_FORMAT_AM         0U                    /*!< AM or 24-hour format */
435 #define LL_RTC_ALMB_TIME_FORMAT_PM         RTC_ALRMBR_PM         /*!< PM */
436 /**
437   * @}
438   */
439 
440 /** @defgroup RTC_LL_EC_ALMB_SUBSECONDBIN_AUTOCLR  Alarm Sub Seconds with binary mode auto clear Definitions
441   * @{
442   */
443 #define LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_NO    0UL
444 /*!< The synchronous binary counter (SS[31:0] in RTC_SSR) is free-running. */
445 
446 #define LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_YES   RTC_ALRMBSSR_SSCLR
447 /*!< The synchronous binary counter (SS[31:0] in RTC_SSR) is running from 0xFFFF FFFF to RTC_ALRMBBINR -> SS[31:0]
448      value and is automatically reloaded with 0xFFFF FFFF when reaching RTC_ALRMBBINR -> SS[31:0]. */
449 /**
450   * @}
451   */
452 
453 /** @defgroup RTC_LL_EC_TIMESTAMP_EDGE  TIMESTAMP EDGE
454   * @{
455   */
456 #define LL_RTC_TIMESTAMP_EDGE_RISING       0U                    /*!< RTC_TS input rising edge generates a time-stamp event */
457 #define LL_RTC_TIMESTAMP_EDGE_FALLING      RTC_CR_TSEDGE         /*!< RTC_TS input falling edge generates a time-stamp even */
458 /**
459   * @}
460   */
461 
462 /** @defgroup RTC_LL_EC_TS_TIME_FORMAT  TIMESTAMP TIME FORMAT
463   * @{
464   */
465 #define LL_RTC_TS_TIME_FORMAT_AM           0U                    /*!< AM or 24-hour format */
466 #define LL_RTC_TS_TIME_FORMAT_PM           RTC_TSTR_PM           /*!< PM */
467 /**
468   * @}
469   */
470 
471 /** @defgroup RTC_LL_EC_TAMPER  TAMPER
472   * @{
473   */
474 #define LL_RTC_TAMPER_1                    TAMP_CR1_TAMP1E       /*!< Tamper 1 input detection */
475 #define LL_RTC_TAMPER_2                    TAMP_CR1_TAMP2E       /*!< Tamper 2 input detection */
476 #define LL_RTC_TAMPER_3                    TAMP_CR1_TAMP3E       /*!< Tamper 3  input detection */
477 #define LL_RTC_TAMPER_4                    TAMP_CR1_TAMP4E       /*!< Tamper 4  input detection */
478 #define LL_RTC_TAMPER_5                    TAMP_CR1_TAMP5E       /*!< Tamper 5  input detection */
479 #define LL_RTC_TAMPER_6                    TAMP_CR1_TAMP6E       /*!< Tamper 6  input detection */
480 #define LL_RTC_TAMPER_7                    TAMP_CR1_TAMP7E       /*!< Tamper 7  input detection */
481 /**
482   * @}
483   */
484 
485 /** @defgroup RTC_LL_EC_TAMPER_MASK  TAMPER MASK
486   * @{
487   */
488 #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 */
489 #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 */
490 #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 */
491 /**
492   * @}
493   */
494 
495 /** @defgroup RTC_LL_EC_TAMPER_NOERASE  TAMPER NO ERASE
496   * @{
497   */
498 #define LL_RTC_TAMPER_NOERASE_TAMPER1      TAMP_CR2_TAMP1POM     /*!< Tamper 1 event does not erase the backup registers */
499 #define LL_RTC_TAMPER_NOERASE_TAMPER2      TAMP_CR2_TAMP2POM     /*!< Tamper 2 event does not erase the backup registers */
500 #define LL_RTC_TAMPER_NOERASE_TAMPER3      TAMP_CR2_TAMP3POM     /*!< Tamper 3 event does not erase the backup registers */
501 #define LL_RTC_TAMPER_NOERASE_TAMPER4      TAMP_CR2_TAMP4POM     /*!< Tamper 4 event does not erase the backup registers */
502 #define LL_RTC_TAMPER_NOERASE_TAMPER5      TAMP_CR2_TAMP5POM     /*!< Tamper 5 event does not erase the backup registers */
503 #define LL_RTC_TAMPER_NOERASE_TAMPER6      TAMP_CR2_TAMP6POM     /*!< Tamper 6 event does not erase the backup registers */
504 #define LL_RTC_TAMPER_NOERASE_TAMPER7      TAMP_CR2_TAMP7POM     /*!< Tamper 7 event does not erase the backup registers */
505 /**
506   * @}
507   */
508 
509 /** @defgroup RTC_LL_EC_TAMPER_DURATION  TAMPER DURATION
510   * @{
511   */
512 #define LL_RTC_TAMPER_DURATION_1RTCCLK     0U                    /*!< Tamper pins are pre-charged before sampling during 1 RTCCLK cycle  */
513 #define LL_RTC_TAMPER_DURATION_2RTCCLK     TAMP_FLTCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before sampling during 2 RTCCLK cycles */
514 #define LL_RTC_TAMPER_DURATION_4RTCCLK     TAMP_FLTCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before sampling during 4 RTCCLK cycles */
515 #define LL_RTC_TAMPER_DURATION_8RTCCLK     TAMP_FLTCR_TAMPPRCH   /*!< Tamper pins are pre-charged before sampling during 8 RTCCLK cycles */
516 /**
517   * @}
518   */
519 
520 /** @defgroup RTC_LL_EC_TAMPER_FILTER  TAMPER FILTER
521   * @{
522   */
523 #define LL_RTC_TAMPER_FILTER_DISABLE       0U                    /*!< Tamper filter is disabled */
524 #define LL_RTC_TAMPER_FILTER_2SAMPLE       TAMP_FLTCR_TAMPFLT_0  /*!< Tamper is activated after 2 consecutive samples at the active level */
525 #define LL_RTC_TAMPER_FILTER_4SAMPLE       TAMP_FLTCR_TAMPFLT_1  /*!< Tamper is activated after 4 consecutive samples at the active level */
526 #define LL_RTC_TAMPER_FILTER_8SAMPLE       TAMP_FLTCR_TAMPFLT    /*!< Tamper is activated after 8 consecutive samples at the active level */
527 /**
528   * @}
529   */
530 
531 /** @defgroup RTC_LL_EC_TAMPER_SAMPLFREQDIV  TAMPER SAMPLING FREQUENCY DIVIDER
532   * @{
533   */
534 #define LL_RTC_TAMPER_SAMPLFREQDIV_32768   0U                                              /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 32768 */
535 #define LL_RTC_TAMPER_SAMPLFREQDIV_16384   TAMP_FLTCR_TAMPFREQ_0                           /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 16384 */
536 #define LL_RTC_TAMPER_SAMPLFREQDIV_8192    TAMP_FLTCR_TAMPFREQ_1                           /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 8192  */
537 #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  */
538 #define LL_RTC_TAMPER_SAMPLFREQDIV_2048    TAMP_FLTCR_TAMPFREQ_2                           /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 2048  */
539 #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  */
540 #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   */
541 #define LL_RTC_TAMPER_SAMPLFREQDIV_256     TAMP_FLTCR_TAMPFREQ                             /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 256   */
542 /**
543   * @}
544   */
545 
546 /** @defgroup RTC_LL_EC_TAMPER_ACTIVELEVEL  TAMPER ACTIVE LEVEL
547   * @{
548   */
549 #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 */
550 #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 */
551 #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 */
552 #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 */
553 #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 */
554 #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP6    TAMP_CR2_TAMP6TRG     /*!< Tamper 6 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
555 #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP7    TAMP_CR2_TAMP7TRG     /*!< Tamper 7 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
556 /**
557   * @}
558   */
559 
560 /** @defgroup RTC_LL_EC_INTERNAL  INTERNAL TAMPER
561   * @{
562   */
563 #define LL_RTC_TAMPER_ITAMP1               TAMP_CR1_ITAMP1E      /*!< Internal tamper 1: RTC supply voltage monitoring                                   */
564 #define LL_RTC_TAMPER_ITAMP2               TAMP_CR1_ITAMP2E      /*!< Internal tamper 2: Temperature monitoring                                          */
565 #define LL_RTC_TAMPER_ITAMP3               TAMP_CR1_ITAMP3E      /*!< Internal tamper 3: LSE monitoring                                                  */
566 #define LL_RTC_TAMPER_ITAMP4               TAMP_CR1_ITAMP4E      /*!< Internal tamper 4: HSE monitoring                                                  */
567 #define LL_RTC_TAMPER_ITAMP5               TAMP_CR1_ITAMP5E      /*!< Internal tamper 5: RTC calendar overflow                                           */
568 #define LL_RTC_TAMPER_ITAMP6               TAMP_CR1_ITAMP6E      /*!< Internal tamper 6: JTAG/SWD access when RDP > 0                                    */
569 #define LL_RTC_TAMPER_ITAMP7               TAMP_CR1_ITAMP7E      /*!< Internal tamper 7: Voltage monitoring (VCORE, VREF+), through ADC analog watchdog  */
570 #define LL_RTC_TAMPER_ITAMP8               TAMP_CR1_ITAMP8E      /*!< Internal tamper 8: Monotonic counter overflow                                      */
571 #define LL_RTC_TAMPER_ITAMP9               TAMP_CR1_ITAMP9E      /*!< Internal tamper 9: Cryptographic IPs fault                                         */
572 #define LL_RTC_TAMPER_ITAMP11              TAMP_CR1_ITAMP11E     /*!< Internal tamper 11: IWDG reset when tamper flag is set                             */
573 /**
574   * @}
575   */
576 
577 /** @defgroup RTC_LL_EC_ITAMPER_NOERASE  INTERNAL TAMPER NO ERASE
578   * @{
579   */
580 #define LL_RTC_TAMPER_NOERASE_ITAMPER1     TAMP_CR3_ITAMP1POM    /*!< Internal tamper 1 event does not erase the backup registers  */
581 #define LL_RTC_TAMPER_NOERASE_ITAMPER2     TAMP_CR3_ITAMP2POM    /*!< Internal tamper 2 event does not erase the backup registers  */
582 #define LL_RTC_TAMPER_NOERASE_ITAMPER3     TAMP_CR3_ITAMP3POM    /*!< Internal tamper 3 event does not erase the backup registers  */
583 #define LL_RTC_TAMPER_NOERASE_ITAMPER4     TAMP_CR3_ITAMP4POM    /*!< Internal tamper 4 event does not erase the backup registers  */
584 #define LL_RTC_TAMPER_NOERASE_ITAMPER5     TAMP_CR3_ITAMP5POM    /*!< Internal tamper 5 event does not erase the backup registers  */
585 #define LL_RTC_TAMPER_NOERASE_ITAMPER6     TAMP_CR3_ITAMP6POM    /*!< Internal tamper 6 event does not erase the backup registers  */
586 #define LL_RTC_TAMPER_NOERASE_ITAMPER7     TAMP_CR3_ITAMP7POM    /*!< Internal tamper 7 event does not erase the backup registers  */
587 #define LL_RTC_TAMPER_NOERASE_ITAMPER8     TAMP_CR3_ITAMP8POM    /*!< Internal tamper 8 event does not erase the backup registers  */
588 #define LL_RTC_TAMPER_NOERASE_ITAMPER9     TAMP_CR3_ITAMP9POM    /*!< Internal tamper 9 event does not erase the backup registers  */
589 #define LL_RTC_TAMPER_NOERASE_ITAMPER11    TAMP_CR3_ITAMP11POM   /*!< Internal tamper 11 event does not erase the backup registers */
590 #define LL_RTC_TAMPER_NOERASE_ITAMPER15    TAMP_CR3_ITAMP15POM   /*!< Internal tamper 15 event does not erase the backup registers */
591 /**
592   * @}
593   */
594 
595 /** @defgroup RTC_LL_EC_ACTIVE_MODE   ACTIVE TAMPER MODE
596   * @{
597   */
598 #define LL_RTC_TAMPER_ATAMP_TAMP1AM        TAMP_ATCR1_TAMP1AM    /*!< Tamper 1 is active */
599 #define LL_RTC_TAMPER_ATAMP_TAMP2AM        TAMP_ATCR1_TAMP2AM    /*!< Tamper 2 is active */
600 #define LL_RTC_TAMPER_ATAMP_TAMP3AM        TAMP_ATCR1_TAMP3AM    /*!< Tamper 3 is active */
601 #define LL_RTC_TAMPER_ATAMP_TAMP4AM        TAMP_ATCR1_TAMP4AM    /*!< Tamper 4 is active */
602 #define LL_RTC_TAMPER_ATAMP_TAMP5AM        TAMP_ATCR1_TAMP5AM    /*!< Tamper 5 is active */
603 #define LL_RTC_TAMPER_ATAMP_TAMP6AM        TAMP_ATCR1_TAMP6AM    /*!< Tamper 6 is active */
604 #define LL_RTC_TAMPER_ATAMP_TAMP7AM        TAMP_ATCR1_TAMP7AM    /*!< Tamper 7 is active */
605 /**
606   * @}
607   */
608 
609 /** @defgroup RTC_LL_EC_ACTIVE_ASYNC_PRESCALER   ACTIVE TAMPER ASYNCHRONOUS PRESCALER CLOCK
610   * @{
611   */
612 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK        0U                                                                      /*!< RTCCLK       */
613 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_2      TAMP_ATCR1_ATCKSEL_0                                                    /*!< RTCCLK/2     */
614 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_4      TAMP_ATCR1_ATCKSEL_1                                                    /*!< RTCCLK/4     */
615 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_8      (TAMP_ATCR1_ATCKSEL_1 | TAMP_ATCR1_ATCKSEL_0)                           /*!< RTCCLK/8     */
616 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_16     TAMP_ATCR1_ATCKSEL_2                                                    /*!< RTCCLK/16    */
617 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_32     (TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_0)                           /*!< RTCCLK/32    */
618 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_64     (TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_1)                           /*!< RTCCLK/64    */
619 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_128    (TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_1 | TAMP_ATCR1_ATCKSEL_0)    /*!< RTCCLK/128   */
620 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_256    TAMP_ATCR1_ATCKSEL_3                                                    /*!< RTCCLK/256   */
621 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_512    (TAMP_ATCR1_ATCKSEL_3 | TAMP_ATCR1_ATCKSEL_0)                           /*!< RTCCLK/512   */
622 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_1024   (TAMP_ATCR1_ATCKSEL_3 | TAMP_ATCR1_ATCKSEL_1)                           /*!< RTCCLK/1024  */
623 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_2048   (TAMP_ATCR1_ATCKSEL_3 | TAMP_ATCR1_ATCKSEL_1 | TAMP_ATCR1_ATCKSEL_0)    /*!< RTCCLK/2048  */
624 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_4096   (TAMP_ATCR1_ATCKSEL_3 | TAMP_ATCR1_ATCKSEL_2)                           /*!< RTCCLK/4096  */
625 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_8192   (TAMP_ATCR1_ATCKSEL_3 | TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_0)    /*!< RTCCLK/8192  */
626 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_16384  (TAMP_ATCR1_ATCKSEL_3 | TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_1)    /*!< RTCCLK/16384 */
627 #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_32768  (TAMP_ATCR1_ATCKSEL_3 | TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_1 |\
628                                                      TAMP_ATCR1_ATCKSEL_0)                                                  /*!< RTCCLK/32768 */
629 
630 /**
631   * @}
632   */
633 
634 /** @defgroup RTC_LL_EC_ACTIVE_OUTPUT_SELECTION   ACTIVE TAMPER OUTPUT SELECTION
635   * @{
636   */
637 #define LL_RTC_TAMPER_ATAMP1IN_ATAMP1OUT   (0U << TAMP_ATCR2_ATOSEL1_Pos)
638 #define LL_RTC_TAMPER_ATAMP1IN_ATAMP2OUT   (1U << TAMP_ATCR2_ATOSEL1_Pos)
639 #define LL_RTC_TAMPER_ATAMP1IN_ATAMP3OUT   (2U << TAMP_ATCR2_ATOSEL1_Pos)
640 #define LL_RTC_TAMPER_ATAMP1IN_ATAMP4OUT   (3U << TAMP_ATCR2_ATOSEL1_Pos)
641 #define LL_RTC_TAMPER_ATAMP1IN_ATAMP5OUT   (4U << TAMP_ATCR2_ATOSEL1_Pos)
642 #define LL_RTC_TAMPER_ATAMP1IN_ATAMP6OUT   (5U << TAMP_ATCR2_ATOSEL1_Pos)
643 #define LL_RTC_TAMPER_ATAMP1IN_ATAMP7OUT   (6U << TAMP_ATCR2_ATOSEL1_Pos)
644 #define LL_RTC_TAMPER_ATAMP1IN_ATAMP8OUT   (7U << TAMP_ATCR2_ATOSEL1_Pos)
645 
646 #define LL_RTC_TAMPER_ATAMP2IN_ATAMP1OUT   (0U << TAMP_ATCR2_ATOSEL2_Pos)
647 #define LL_RTC_TAMPER_ATAMP2IN_ATAMP2OUT   (1U << TAMP_ATCR2_ATOSEL2_Pos)
648 #define LL_RTC_TAMPER_ATAMP2IN_ATAMP3OUT   (2U << TAMP_ATCR2_ATOSEL2_Pos)
649 #define LL_RTC_TAMPER_ATAMP2IN_ATAMP4OUT   (3U << TAMP_ATCR2_ATOSEL2_Pos)
650 #define LL_RTC_TAMPER_ATAMP2IN_ATAMP5OUT   (4U << TAMP_ATCR2_ATOSEL2_Pos)
651 #define LL_RTC_TAMPER_ATAMP2IN_ATAMP6OUT   (5U << TAMP_ATCR2_ATOSEL2_Pos)
652 #define LL_RTC_TAMPER_ATAMP2IN_ATAMP7OUT   (6U << TAMP_ATCR2_ATOSEL2_Pos)
653 #define LL_RTC_TAMPER_ATAMP2IN_ATAMP8OUT   (7U << TAMP_ATCR2_ATOSEL2_Pos)
654 
655 #define LL_RTC_TAMPER_ATAMP3IN_ATAMP1OUT   (0U << TAMP_ATCR2_ATOSEL3_Pos)
656 #define LL_RTC_TAMPER_ATAMP3IN_ATAMP2OUT   (1U << TAMP_ATCR2_ATOSEL3_Pos)
657 #define LL_RTC_TAMPER_ATAMP3IN_ATAMP3OUT   (2U << TAMP_ATCR2_ATOSEL3_Pos)
658 #define LL_RTC_TAMPER_ATAMP3IN_ATAMP4OUT   (3U << TAMP_ATCR2_ATOSEL3_Pos)
659 #define LL_RTC_TAMPER_ATAMP3IN_ATAMP5OUT   (4U << TAMP_ATCR2_ATOSEL3_Pos)
660 #define LL_RTC_TAMPER_ATAMP3IN_ATAMP6OUT   (5U << TAMP_ATCR2_ATOSEL3_Pos)
661 #define LL_RTC_TAMPER_ATAMP3IN_ATAMP7OUT   (6U << TAMP_ATCR2_ATOSEL3_Pos)
662 #define LL_RTC_TAMPER_ATAMP3IN_ATAMP8OUT   (7U << TAMP_ATCR2_ATOSEL3_Pos)
663 
664 #define LL_RTC_TAMPER_ATAMP4IN_ATAMP1OUT   (0U << TAMP_ATCR2_ATOSEL4_Pos)
665 #define LL_RTC_TAMPER_ATAMP4IN_ATAMP2OUT   (1U << TAMP_ATCR2_ATOSEL4_Pos)
666 #define LL_RTC_TAMPER_ATAMP4IN_ATAMP3OUT   (2U << TAMP_ATCR2_ATOSEL4_Pos)
667 #define LL_RTC_TAMPER_ATAMP4IN_ATAMP4OUT   (3U << TAMP_ATCR2_ATOSEL4_Pos)
668 #define LL_RTC_TAMPER_ATAMP4IN_ATAMP5OUT   (4U << TAMP_ATCR2_ATOSEL4_Pos)
669 #define LL_RTC_TAMPER_ATAMP4IN_ATAMP6OUT   (5U << TAMP_ATCR2_ATOSEL4_Pos)
670 #define LL_RTC_TAMPER_ATAMP4IN_ATAMP7OUT   (6U << TAMP_ATCR2_ATOSEL4_Pos)
671 #define LL_RTC_TAMPER_ATAMP4IN_ATAMP8OUT   (7U << TAMP_ATCR2_ATOSEL4_Pos)
672 
673 #define LL_RTC_TAMPER_ATAMP5IN_ATAMP1OUT   (0U << TAMP_ATCR2_ATOSEL5_Pos)
674 #define LL_RTC_TAMPER_ATAMP5IN_ATAMP2OUT   (1U << TAMP_ATCR2_ATOSEL5_Pos)
675 #define LL_RTC_TAMPER_ATAMP5IN_ATAMP3OUT   (2U << TAMP_ATCR2_ATOSEL5_Pos)
676 #define LL_RTC_TAMPER_ATAMP5IN_ATAMP4OUT   (3U << TAMP_ATCR2_ATOSEL5_Pos)
677 #define LL_RTC_TAMPER_ATAMP5IN_ATAMP5OUT   (4U << TAMP_ATCR2_ATOSEL5_Pos)
678 #define LL_RTC_TAMPER_ATAMP5IN_ATAMP6OUT   (5U << TAMP_ATCR2_ATOSEL5_Pos)
679 #define LL_RTC_TAMPER_ATAMP5IN_ATAMP7OUT   (6U << TAMP_ATCR2_ATOSEL5_Pos)
680 #define LL_RTC_TAMPER_ATAMP5IN_ATAMP8OUT   (7U << TAMP_ATCR2_ATOSEL5_Pos)
681 
682 #define LL_RTC_TAMPER_ATAMP6IN_ATAMP1OUT   (0U << TAMP_ATCR2_ATOSEL6_Pos)
683 #define LL_RTC_TAMPER_ATAMP6IN_ATAMP2OUT   (1U << TAMP_ATCR2_ATOSEL6_Pos)
684 #define LL_RTC_TAMPER_ATAMP6IN_ATAMP3OUT   (2U << TAMP_ATCR2_ATOSEL6_Pos)
685 #define LL_RTC_TAMPER_ATAMP6IN_ATAMP4OUT   (3U << TAMP_ATCR2_ATOSEL6_Pos)
686 #define LL_RTC_TAMPER_ATAMP6IN_ATAMP5OUT   (4U << TAMP_ATCR2_ATOSEL6_Pos)
687 #define LL_RTC_TAMPER_ATAMP6IN_ATAMP6OUT   (5U << TAMP_ATCR2_ATOSEL6_Pos)
688 #define LL_RTC_TAMPER_ATAMP6IN_ATAMP7OUT   (6U << TAMP_ATCR2_ATOSEL6_Pos)
689 #define LL_RTC_TAMPER_ATAMP6IN_ATAMP8OUT   (7U << TAMP_ATCR2_ATOSEL6_Pos)
690 
691 #define LL_RTC_TAMPER_ATAMP7IN_ATAMP1OUT   (0U << TAMP_ATCR2_ATOSEL7_Pos)
692 #define LL_RTC_TAMPER_ATAMP7IN_ATAMP2OUT   (1U << TAMP_ATCR2_ATOSEL7_Pos)
693 #define LL_RTC_TAMPER_ATAMP7IN_ATAMP3OUT   (2U << TAMP_ATCR2_ATOSEL7_Pos)
694 #define LL_RTC_TAMPER_ATAMP7IN_ATAMP4OUT   (3U << TAMP_ATCR2_ATOSEL7_Pos)
695 #define LL_RTC_TAMPER_ATAMP7IN_ATAMP5OUT   (4U << TAMP_ATCR2_ATOSEL7_Pos)
696 #define LL_RTC_TAMPER_ATAMP7IN_ATAMP6OUT   (5U << TAMP_ATCR2_ATOSEL7_Pos)
697 #define LL_RTC_TAMPER_ATAMP7IN_ATAMP7OUT   (6U << TAMP_ATCR2_ATOSEL7_Pos)
698 #define LL_RTC_TAMPER_ATAMP7IN_ATAMP8OUT   (7U << TAMP_ATCR2_ATOSEL7_Pos)
699 /**
700   * @}
701   */
702 
703 /** @defgroup RTC_LL_EC_BKP  BACKUP
704   * @{
705   */
706 #define LL_RTC_BKP_NUMBER                  RTC_BACKUP_NB
707 #define LL_RTC_BKP_DR0                     0U
708 #define LL_RTC_BKP_DR1                     1U
709 #define LL_RTC_BKP_DR2                     2U
710 #define LL_RTC_BKP_DR3                     3U
711 #define LL_RTC_BKP_DR4                     4U
712 #define LL_RTC_BKP_DR5                     5U
713 #define LL_RTC_BKP_DR6                     6U
714 #define LL_RTC_BKP_DR7                     7U
715 #define LL_RTC_BKP_DR8                     8U
716 #define LL_RTC_BKP_DR9                     9U
717 #define LL_RTC_BKP_DR10                    10U
718 #define LL_RTC_BKP_DR11                    11U
719 #define LL_RTC_BKP_DR12                    12U
720 #define LL_RTC_BKP_DR13                    13U
721 #define LL_RTC_BKP_DR14                    14U
722 #define LL_RTC_BKP_DR15                    15U
723 #define LL_RTC_BKP_DR16                    16U
724 #define LL_RTC_BKP_DR17                    17U
725 #define LL_RTC_BKP_DR18                    18U
726 #define LL_RTC_BKP_DR19                    19U
727 #define LL_RTC_BKP_DR20                    20U
728 #define LL_RTC_BKP_DR21                    21U
729 #define LL_RTC_BKP_DR22                    22U
730 #define LL_RTC_BKP_DR23                    23U
731 #define LL_RTC_BKP_DR24                    24U
732 #define LL_RTC_BKP_DR25                    25U
733 #define LL_RTC_BKP_DR26                    26U
734 #define LL_RTC_BKP_DR27                    27U
735 #define LL_RTC_BKP_DR28                    28U
736 #define LL_RTC_BKP_DR29                    29U
737 #define LL_RTC_BKP_DR30                    30U
738 #define LL_RTC_BKP_DR31                    31U
739 /**
740   * @}
741   */
742 
743 /** @defgroup RTC_LL_EC_WAKEUPCLOCK_DIV  WAKEUP CLOCK DIV
744   * @{
745   */
746 #define LL_RTC_WAKEUPCLOCK_DIV_16          0U                                    /*!< RTC/16 clock is selected */
747 #define LL_RTC_WAKEUPCLOCK_DIV_8           RTC_CR_WUCKSEL_0                      /*!< RTC/8 clock is selected  */
748 #define LL_RTC_WAKEUPCLOCK_DIV_4           RTC_CR_WUCKSEL_1                      /*!< RTC/4 clock is selected  */
749 #define LL_RTC_WAKEUPCLOCK_DIV_2           (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_0) /*!< RTC/2 clock is selected  */
750 #define LL_RTC_WAKEUPCLOCK_CKSPRE          RTC_CR_WUCKSEL_2                      /*!< ck_spre (usually 1 Hz) clock is selected                                              */
751 #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 */
752 /**
753   * @}
754   */
755 
756 /** @defgroup RTC_LL_EC_CALIB_OUTPUT  Calibration output
757   * @{
758   */
759 #define LL_RTC_CALIB_OUTPUT_NONE           0U                          /*!< Calibration output disabled  */
760 #define LL_RTC_CALIB_OUTPUT_1HZ            (RTC_CR_COE | RTC_CR_COSEL) /*!< Calibration output is 1 Hz   */
761 #define LL_RTC_CALIB_OUTPUT_512HZ          RTC_CR_COE                  /*!< Calibration output is 512 Hz */
762 /**
763   * @}
764   */
765 
766 /** @defgroup RTC_LL_EC_CALIB_INSERTPULSE  Calibration pulse insertion
767   * @{
768   */
769 #define LL_RTC_CALIB_INSERTPULSE_NONE      0U                    /*!< No RTCCLK pulses are added                                                                      */
770 #define LL_RTC_CALIB_INSERTPULSE_SET       RTC_CALR_CALP         /*!< One RTCCLK pulse is effectively inserted every 2exp11 pulses (frequency increased by 488.5 ppm) */
771 /**
772   * @}
773   */
774 
775 /** @defgroup RTC_LL_EC_CALIB_PERIOD  Calibration period
776   * @{
777   */
778 #define LL_RTC_CALIB_PERIOD_32SEC          0U                    /*!< Use a 32-second calibration cycle period */
779 #define LL_RTC_CALIB_PERIOD_16SEC          RTC_CALR_CALW16       /*!< Use a 16-second calibration cycle period */
780 #define LL_RTC_CALIB_PERIOD_8SEC           RTC_CALR_CALW8        /*!< Use a 8-second calibration cycle period  */
781 /**
782   * @}
783   */
784 
785 /** @defgroup RTC_LL_EC_CALIB_LOWPOWER  Calibration low power
786   * @{
787   */
788 #define LL_RTC_CALIB_LOWPOWER_NONE         0U                    /*!< High conso mode */
789 #define LL_RTC_CALIB_LOWPOWER_SET          RTC_CALR_LPCAL        /*!< Low power mode  */
790 /**
791   * @}
792   */
793 
794 /** @defgroup RTC_LL_EC_BINARY_MODE  Binary mode (Sub Second Register)
795   * @{
796   */
797 #define LL_RTC_BINARY_NONE                 0U                    /*!< Free running BCD calendar mode (Binary mode disabled) */
798 #define LL_RTC_BINARY_ONLY                 RTC_ICSR_BIN_0        /*!< Free running Binary mode (BCD mode disabled)          */
799 #define LL_RTC_BINARY_MIX                  RTC_ICSR_BIN_1        /*!< Free running BCD calendar and Binary mode enable      */
800 /**
801   * @}
802   */
803 
804 /** @defgroup RTC_LL_EC_BINARY_MIX_BCDU  Calendar second incrementation in Binary mix mode
805   * @{
806   */
807 #define LL_RTC_BINARY_MIX_BCDU_0           0U                            /*!< 1s calendar increment is generated each time SS[7:0] = 0  */
808 #define LL_RTC_BINARY_MIX_BCDU_1           (0x1UL << RTC_ICSR_BCDU_Pos)  /*!< 1s calendar increment is generated each time SS[8:0] = 0  */
809 #define LL_RTC_BINARY_MIX_BCDU_2           (0x2UL << RTC_ICSR_BCDU_Pos)  /*!< 1s calendar increment is generated each time SS[9:0] = 0  */
810 #define LL_RTC_BINARY_MIX_BCDU_3           (0x3UL << RTC_ICSR_BCDU_Pos)  /*!< 1s calendar increment is generated each time SS[10:0] = 0 */
811 #define LL_RTC_BINARY_MIX_BCDU_4           (0x4UL << RTC_ICSR_BCDU_Pos)  /*!< 1s calendar increment is generated each time SS[11:0] = 0 */
812 #define LL_RTC_BINARY_MIX_BCDU_5           (0x5UL << RTC_ICSR_BCDU_Pos)  /*!< 1s calendar increment is generated each time SS[12:0] = 0 */
813 #define LL_RTC_BINARY_MIX_BCDU_6           (0x6UL << RTC_ICSR_BCDU_Pos)  /*!< 1s calendar increment is generated each time SS[13:0] = 0 */
814 #define LL_RTC_BINARY_MIX_BCDU_7           (0x7UL << RTC_ICSR_BCDU_Pos)  /*!< 1s calendar increment is generated each time SS[14:0] = 0 */
815 /**
816   * @}
817   */
818 
819 /** @defgroup RTC_LL_EC_SECURE_RTC_FULL  Secure full rtc
820   * @{
821   */
822 #define LL_RTC_SECURE_FULL_YES             RTC_SECCFGR_SEC       /*!< RTC full secure                                                                  */
823 #define LL_RTC_SECURE_FULL_NO              0U                    /*!< RTC is not full secure, features can be secure. See RTC_LL_EC_SECURE_RTC_FEATURE */
824 /**
825   * @}
826   */
827 
828 /** @defgroup RTC_LL_EC_SECURE_RTC_FEATURE  Secure features rtc in case of LL_RTC_SECURE_FULL_NO.
829   * @{
830   */
831 #define LL_RTC_SECURE_FEATURE_INIT         RTC_SECCFGR_INITSEC   /*!< Initialization feature is secure */
832 #define LL_RTC_SECURE_FEATURE_CAL          RTC_SECCFGR_CALSEC    /*!< Calibration feature is secure    */
833 #define LL_RTC_SECURE_FEATURE_TS           RTC_SECCFGR_TSSEC     /*!< Time stamp feature is secure     */
834 #define LL_RTC_SECURE_FEATURE_WUT          RTC_SECCFGR_WUTSEC    /*!< Wake up timer feature is secure  */
835 #define LL_RTC_SECURE_FEATURE_ALRA         RTC_SECCFGR_ALRASEC   /*!< Alarm A feature is secure        */
836 #define LL_RTC_SECURE_FEATURE_ALRB         RTC_SECCFGR_ALRBSEC   /*!< Alarm B feature is secure        */
837 /**
838   * @}
839   */
840 
841 /** @defgroup RTC_LL_EC_SECURE_TAMP  Secure tamp
842   * @{
843   */
844 #define LL_TAMP_SECURE_FULL_YES            TAMP_SECCFGR_TAMPSEC  /*!< TAMP full secure   */
845 #define LL_TAMP_SECURE_FULL_NO             0U                    /*!< TAMP is not secure */
846 /**
847   * @}
848   */
849 
850 /** @defgroup RTC_LL_EC_PRIVILEGE_RTC_FULL  Privilege full rtc
851   * @{
852   */
853 #define LL_RTC_PRIVILEGE_FULL_YES          RTC_PRIVCFGR_PRIV     /*!< RTC full privilege                                                                          */
854 #define LL_RTC_PRIVILEGE_FULL_NO           0U                    /*!< RTC is not full privilege, features can be unprivilege. See RTC_LL_EC_PRIVILEGE_RTC_FEATURE */
855 /**
856   * @}
857   */
858 
859 /** @defgroup RTC_LL_EC_PRIVILEGE_RTC_FEATURE  Privilege rtc features in case of LL_RTC_PRIVILEGE_FULL_NO.
860   * @{
861   */
862 #define LL_RTC_PRIVILEGE_FEATURE_INIT      RTC_PRIVCFGR_INITPRIV /*!< Initialization feature is privilege */
863 #define LL_RTC_PRIVILEGE_FEATURE_CAL       RTC_PRIVCFGR_CALPRIV  /*!< Calibration feature is privilege    */
864 #define LL_RTC_PRIVILEGE_FEATURE_TS        RTC_PRIVCFGR_TSPRIV   /*!< Time stamp feature is privilege     */
865 #define LL_RTC_PRIVILEGE_FEATURE_WUT       RTC_PRIVCFGR_WUTPRIV  /*!< Wake up timer feature is privilege  */
866 #define LL_RTC_PRIVILEGE_FEATURE_ALRA      RTC_PRIVCFGR_ALRAPRIV /*!< Alarm A feature is privilege        */
867 #define LL_RTC_PRIVILEGE_FEATURE_ALRB      RTC_PRIVCFGR_ALRBPRIV /*!< Alarm B feature is privilege        */
868 /**
869   * @}
870   */
871 
872 /** @defgroup RTC_LL_EC_PRIVILEGE_TAMP_FULL  Privilege full tamp
873   * @{
874   */
875 #define LL_TAMP_PRIVILEGE_FULL_YES         TAMP_PRIVCFGR_TAMPPRIV /*!< TAMP full privilege   */
876 #define LL_TAMP_PRIVILEGE_FULL_NO          0U                     /*!< TAMP is not privilege */
877 /**
878   * @}
879   */
880 
881 /** @defgroup RTC_LL_EC_PRIVILEGE_BACKUP_REG_ZONE  Privilege Backup register privilege zone
882   * @{
883   */
884 #define LL_RTC_PRIVILEGE_BKUP_ZONE_NONE    0U
885 #define LL_RTC_PRIVILEGE_BKUP_ZONE_1       TAMP_PRIVCFGR_BKPRWPRIV
886 #define LL_RTC_PRIVILEGE_BKUP_ZONE_2       TAMP_PRIVCFGR_BKPWPRIV
887 #define LL_RTC_PRIVILEGE_BKUP_ZONE_ALL     (LL_RTC_PRIVILEGE_BKUP_ZONE_1 |  LL_RTC_PRIVILEGE_BKUP_ZONE_2)
888 /**
889   * @}
890   */
891 
892 /**
893   * @}
894   */
895 
896 /* Exported macro ------------------------------------------------------------*/
897 /** @defgroup RTC_LL_Exported_Macros RTC Exported Macros
898   * @{
899   */
900 
901 /** @defgroup RTC_LL_EM_WRITE_READ Common Write and read registers Macros
902   * @{
903   */
904 
905 /**
906   * @brief  Write a value in RTC register
907   * @param  __INSTANCE__ RTC Instance
908   * @param  __REG__ Register to be written
909   * @param  __VALUE__ Value to be written in the register
910   * @retval None
911   */
912 #define LL_RTC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
913 
914 /**
915   * @brief  Read a value in RTC register
916   * @param  __INSTANCE__ RTC Instance
917   * @param  __REG__ Register to be read
918   * @retval Register value
919   */
920 #define LL_RTC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
921 /**
922   * @}
923   */
924 
925 /** @defgroup RTC_LL_EM_Convert Convert helper Macros
926   * @{
927   */
928 
929 /**
930   * @brief  Helper macro to convert a value from 2 digit decimal format to BCD format
931   * @param  __VALUE__ Byte to be converted
932   * @retval Converted byte
933   */
934 #define __LL_RTC_CONVERT_BIN2BCD(__VALUE__) ((uint8_t)((((__VALUE__) / 10U) << 4U) | ((__VALUE__) % 10U)))
935 
936 /**
937   * @brief  Helper macro to convert a value from BCD format to 2 digit decimal format
938   * @param  __VALUE__ BCD value to be converted
939   * @retval Converted byte
940   */
941 #define __LL_RTC_CONVERT_BCD2BIN(__VALUE__)  \
942   ((uint8_t)((((uint8_t)((__VALUE__) & (uint8_t)0xF0U) >> (uint8_t)0x4U) * 10U) + ((__VALUE__) & (uint8_t)0x0FU)))
943 
944 /**
945   * @}
946   */
947 
948 /** @defgroup RTC_LL_EM_Date Date helper Macros
949   * @{
950   */
951 
952 /**
953   * @brief  Helper macro to retrieve weekday.
954   * @param  __RTC_DATE__ Date returned by @ref  LL_RTC_DATE_Get function.
955   * @retval Returned value can be one of the following values:
956   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
957   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
958   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
959   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
960   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
961   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
962   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
963   */
964 #define __LL_RTC_GET_WEEKDAY(__RTC_DATE__) (((__RTC_DATE__) >> RTC_OFFSET_WEEKDAY) & 0x000000FFU)
965 
966 /**
967   * @brief  Helper macro to retrieve Year in BCD format
968   * @param  __RTC_DATE__ Value returned by @ref  LL_RTC_DATE_Get
969   * @retval Year in BCD format (0x00 . . . 0x99)
970   */
971 #define __LL_RTC_GET_YEAR(__RTC_DATE__) ((__RTC_DATE__) & 0x000000FFU)
972 
973 /**
974   * @brief  Helper macro to retrieve Month in BCD format
975   * @param  __RTC_DATE__ Value returned by @ref  LL_RTC_DATE_Get
976   * @retval Returned value can be one of the following values:
977   *         @arg @ref LL_RTC_MONTH_JANUARY
978   *         @arg @ref LL_RTC_MONTH_FEBRUARY
979   *         @arg @ref LL_RTC_MONTH_MARCH
980   *         @arg @ref LL_RTC_MONTH_APRIL
981   *         @arg @ref LL_RTC_MONTH_MAY
982   *         @arg @ref LL_RTC_MONTH_JUNE
983   *         @arg @ref LL_RTC_MONTH_JULY
984   *         @arg @ref LL_RTC_MONTH_AUGUST
985   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
986   *         @arg @ref LL_RTC_MONTH_OCTOBER
987   *         @arg @ref LL_RTC_MONTH_NOVEMBER
988   *         @arg @ref LL_RTC_MONTH_DECEMBER
989   */
990 #define __LL_RTC_GET_MONTH(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_MONTH) & 0x000000FFU)
991 
992 /**
993   * @brief  Helper macro to retrieve Day in BCD format
994   * @param  __RTC_DATE__ Value returned by @ref  LL_RTC_DATE_Get
995   * @retval Day in BCD format (0x01 . . . 0x31)
996   */
997 #define __LL_RTC_GET_DAY(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_DAY) & 0x000000FFU)
998 
999 /**
1000   * @}
1001   */
1002 
1003 /** @defgroup RTC_LL_EM_Time Time helper Macros
1004   * @{
1005   */
1006 
1007 /**
1008   * @brief  Helper macro to retrieve hour in BCD format
1009   * @param  __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
1010   * @retval Hours in BCD format (0x01. . .0x12 or between Min_Data=0x00 and Max_Data=0x23)
1011   */
1012 #define __LL_RTC_GET_HOUR(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_HOUR) & 0x000000FFU)
1013 
1014 /**
1015   * @brief  Helper macro to retrieve minute in BCD format
1016   * @param  __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
1017   * @retval Minutes in BCD format (0x00. . .0x59)
1018   */
1019 #define __LL_RTC_GET_MINUTE(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_MINUTE) & 0x000000FFU)
1020 
1021 /**
1022   * @brief  Helper macro to retrieve second in BCD format
1023   * @param  __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
1024   * @retval Seconds in  format (0x00. . .0x59)
1025   */
1026 #define __LL_RTC_GET_SECOND(__RTC_TIME__) ((__RTC_TIME__) & 0x000000FFU)
1027 
1028 /**
1029   * @}
1030   */
1031 
1032 /**
1033   * @}
1034   */
1035 
1036 /* Exported functions --------------------------------------------------------*/
1037 /** @defgroup RTC_LL_Exported_Functions RTC Exported Functions
1038   * @{
1039   */
1040 
1041 /** @defgroup RTC_LL_EF_Configuration Configuration
1042   * @{
1043   */
1044 
1045 /**
1046   * @brief  Set Hours format (24 hour/day or AM/PM hour format)
1047   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1048   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1049   * @rmtoll RTC_CR           FMT           LL_RTC_SetHourFormat
1050   * @param  RTCx RTC Instance
1051   * @param  HourFormat This parameter can be one of the following values:
1052   *         @arg @ref LL_RTC_HOURFORMAT_24HOUR
1053   *         @arg @ref LL_RTC_HOURFORMAT_AMPM
1054   * @retval None
1055   */
LL_RTC_SetHourFormat(RTC_TypeDef * RTCx,uint32_t HourFormat)1056 __STATIC_INLINE void LL_RTC_SetHourFormat(RTC_TypeDef *RTCx, uint32_t HourFormat)
1057 {
1058   MODIFY_REG(RTCx->CR, RTC_CR_FMT, HourFormat);
1059 }
1060 
1061 /**
1062   * @brief  Get Hours format (24 hour/day or AM/PM hour format)
1063   * @rmtoll RTC_CR           FMT           LL_RTC_GetHourFormat
1064   * @param  RTCx RTC Instance
1065   * @retval Returned value can be one of the following values:
1066   *         @arg @ref LL_RTC_HOURFORMAT_24HOUR
1067   *         @arg @ref LL_RTC_HOURFORMAT_AMPM
1068   */
LL_RTC_GetHourFormat(const RTC_TypeDef * RTCx)1069 __STATIC_INLINE uint32_t LL_RTC_GetHourFormat(const RTC_TypeDef *RTCx)
1070 {
1071   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_FMT));
1072 }
1073 
1074 /**
1075   * @brief  Select the flag to be routed to RTC_ALARM output
1076   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1077   * @rmtoll RTC_CR           OSEL          LL_RTC_SetAlarmOutEvent
1078   * @param  RTCx RTC Instance
1079   * @param  AlarmOutput This parameter can be one of the following values:
1080   *         @arg @ref LL_RTC_ALARMOUT_DISABLE
1081   *         @arg @ref LL_RTC_ALARMOUT_ALMA
1082   *         @arg @ref LL_RTC_ALARMOUT_ALMB
1083   *         @arg @ref LL_RTC_ALARMOUT_WAKEUP
1084   * @retval None
1085   */
LL_RTC_SetAlarmOutEvent(RTC_TypeDef * RTCx,uint32_t AlarmOutput)1086 __STATIC_INLINE void LL_RTC_SetAlarmOutEvent(RTC_TypeDef *RTCx, uint32_t AlarmOutput)
1087 {
1088   MODIFY_REG(RTCx->CR, RTC_CR_OSEL, AlarmOutput);
1089 }
1090 
1091 /**
1092   * @brief  Get the flag to be routed to RTC_ALARM output
1093   * @rmtoll RTC_CR           OSEL          LL_RTC_GetAlarmOutEvent
1094   * @param  RTCx RTC Instance
1095   * @retval Returned value can be one of the following values:
1096   *         @arg @ref LL_RTC_ALARMOUT_DISABLE
1097   *         @arg @ref LL_RTC_ALARMOUT_ALMA
1098   *         @arg @ref LL_RTC_ALARMOUT_ALMB
1099   *         @arg @ref LL_RTC_ALARMOUT_WAKEUP
1100   */
LL_RTC_GetAlarmOutEvent(const RTC_TypeDef * RTCx)1101 __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutEvent(const RTC_TypeDef *RTCx)
1102 {
1103   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_OSEL));
1104 }
1105 
1106 /**
1107   * @brief  Set RTC_ALARM output type (ALARM in push-pull or open-drain output)
1108   * @rmtoll RTC_CR           TAMPALRM_TYPE          LL_RTC_SetAlarmOutputType
1109   * @param  RTCx RTC Instance
1110   * @param  Output This parameter can be one of the following values:
1111   *         @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
1112   *         @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
1113   * @retval None
1114   */
LL_RTC_SetAlarmOutputType(RTC_TypeDef * RTCx,uint32_t Output)1115 __STATIC_INLINE void LL_RTC_SetAlarmOutputType(RTC_TypeDef *RTCx, uint32_t Output)
1116 {
1117   MODIFY_REG(RTCx->CR, RTC_CR_TAMPALRM_TYPE, Output);
1118 }
1119 
1120 /**
1121   * @brief  Get RTC_ALARM output type (ALARM in push-pull or open-drain output)
1122   * @rmtoll RTC_CR           TAMPALRM_TYPE          LL_RTC_GetAlarmOutputType
1123   * @param  RTCx RTC Instance
1124   * @retval Returned value can be one of the following values:
1125   *         @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
1126   *         @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
1127   */
LL_RTC_GetAlarmOutputType(const RTC_TypeDef * RTCx)1128 __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutputType(const RTC_TypeDef *RTCx)
1129 {
1130   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_TAMPALRM_TYPE));
1131 }
1132 
1133 /**
1134   * @brief  Enable initialization mode
1135   * @note   Initialization mode is used to program time and date register (RTC_TR and RTC_DR)
1136   *         and prescaler register (RTC_PRER).
1137   *         Counters are stopped and start counting from the new value when INIT is reset.
1138   * @rmtoll RTC_ICSR          INIT          LL_RTC_EnableInitMode
1139   * @param  RTCx RTC Instance
1140   * @retval None
1141   */
LL_RTC_EnableInitMode(RTC_TypeDef * RTCx)1142 __STATIC_INLINE void LL_RTC_EnableInitMode(RTC_TypeDef *RTCx)
1143 {
1144   /* Set the Initialization mode */
1145   SET_BIT(RTCx->ICSR, RTC_ICSR_INIT);
1146 }
1147 
1148 /**
1149   * @brief  Disable initialization mode (Free running mode)
1150   * @rmtoll RTC_ICSR          INIT          LL_RTC_DisableInitMode
1151   * @param  RTCx RTC Instance
1152   * @retval None
1153   */
LL_RTC_DisableInitMode(RTC_TypeDef * RTCx)1154 __STATIC_INLINE void LL_RTC_DisableInitMode(RTC_TypeDef *RTCx)
1155 {
1156   /* Exit Initialization mode */
1157   CLEAR_BIT(RTCx->ICSR, RTC_ICSR_INIT);
1158 
1159 }
1160 
1161 /**
1162   * @brief  Set Binary mode (Sub Second Register)
1163   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1164   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function).
1165   * @rmtoll RTC_ICSR           BIN           LL_RTC_SetBinaryMode
1166   * @param  RTCx RTC Instance
1167   * @param  BinaryMode can be one of the following values:
1168   *         @arg @ref LL_RTC_BINARY_NONE
1169   *         @arg @ref LL_RTC_BINARY_ONLY
1170   *         @arg @ref LL_RTC_BINARY_MIX
1171   * @retval None
1172   */
LL_RTC_SetBinaryMode(RTC_TypeDef * RTCx,uint32_t BinaryMode)1173 __STATIC_INLINE void LL_RTC_SetBinaryMode(RTC_TypeDef *RTCx, uint32_t BinaryMode)
1174 {
1175   MODIFY_REG(RTCx->ICSR, RTC_ICSR_BIN, BinaryMode);
1176 }
1177 
1178 /**
1179   * @brief  Get Binary mode (Sub Second Register)
1180   * @rmtoll RTC_ICSR           BIN           LL_RTC_GetBinaryMode
1181   * @param  RTCx RTC Instance
1182   * @retval This parameter can be one of the following values:
1183   *         @arg @ref LL_RTC_BINARY_NONE
1184   *         @arg @ref LL_RTC_BINARY_ONLY
1185   *         @arg @ref LL_RTC_BINARY_MIX
1186   * @retval None
1187   */
LL_RTC_GetBinaryMode(const RTC_TypeDef * RTCx)1188 __STATIC_INLINE uint32_t LL_RTC_GetBinaryMode(const RTC_TypeDef *RTCx)
1189 {
1190   return (uint32_t)(READ_BIT(RTCx->ICSR, RTC_ICSR_BIN));
1191 }
1192 
1193 /**
1194   * @brief  Set Binary Mix mode BCDU
1195   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1196   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function).
1197   * @rmtoll RTC_ICSR           BCDU          LL_RTC_SetBinMixBCDU
1198   * @param  RTCx RTC Instance
1199   * @param  BinMixBcdU can be one of the following values:
1200   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_0
1201   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_1
1202   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_2
1203   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_3
1204   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_4
1205   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_5
1206   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_6
1207   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_7
1208   * @retval None
1209   */
LL_RTC_SetBinMixBCDU(RTC_TypeDef * RTCx,uint32_t BinMixBcdU)1210 __STATIC_INLINE void LL_RTC_SetBinMixBCDU(RTC_TypeDef *RTCx, uint32_t BinMixBcdU)
1211 {
1212   MODIFY_REG(RTCx->ICSR, RTC_ICSR_BCDU, BinMixBcdU);
1213 }
1214 
1215 /**
1216   * @brief  Get Binary Mix mode BCDU
1217   * @rmtoll RTC_ICSR           BCDU          LL_RTC_GetBinMixBCDU
1218   * @param  RTCx RTC Instance
1219   * @retval This parameter can be one of the following values:
1220   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_0
1221   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_1
1222   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_2
1223   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_3
1224   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_4
1225   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_5
1226   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_6
1227   *         @arg @ref LL_RTC_BINARY_MIX_BCDU_7
1228   * @retval None
1229   */
LL_RTC_GetBinMixBCDU(const RTC_TypeDef * RTCx)1230 __STATIC_INLINE uint32_t LL_RTC_GetBinMixBCDU(const RTC_TypeDef *RTCx)
1231 {
1232   return (uint32_t)(READ_BIT(RTCx->ICSR, RTC_ICSR_BCDU));
1233 }
1234 
1235 /**
1236   * @brief  Set Output polarity (pin is low when ALRAF/ALRBF/WUTF is asserted)
1237   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1238   * @rmtoll RTC_CR           POL           LL_RTC_SetOutputPolarity
1239   * @param  RTCx RTC Instance
1240   * @param  Polarity This parameter can be one of the following values:
1241   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
1242   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
1243   * @retval None
1244   */
LL_RTC_SetOutputPolarity(RTC_TypeDef * RTCx,uint32_t Polarity)1245 __STATIC_INLINE void LL_RTC_SetOutputPolarity(RTC_TypeDef *RTCx, uint32_t Polarity)
1246 {
1247   MODIFY_REG(RTCx->CR, RTC_CR_POL, Polarity);
1248 }
1249 
1250 /**
1251   * @brief  Get Output polarity
1252   * @rmtoll RTC_CR           POL           LL_RTC_GetOutputPolarity
1253   * @param  RTCx RTC Instance
1254   * @retval Returned value can be one of the following values:
1255   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
1256   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
1257   */
LL_RTC_GetOutputPolarity(const RTC_TypeDef * RTCx)1258 __STATIC_INLINE uint32_t LL_RTC_GetOutputPolarity(const RTC_TypeDef *RTCx)
1259 {
1260   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_POL));
1261 }
1262 
1263 /**
1264   * @brief  Enable Bypass the shadow registers
1265   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1266   * @rmtoll RTC_CR           BYPSHAD       LL_RTC_EnableShadowRegBypass
1267   * @param  RTCx RTC Instance
1268   * @retval None
1269   */
LL_RTC_EnableShadowRegBypass(RTC_TypeDef * RTCx)1270 __STATIC_INLINE void LL_RTC_EnableShadowRegBypass(RTC_TypeDef *RTCx)
1271 {
1272   SET_BIT(RTCx->CR, RTC_CR_BYPSHAD);
1273 }
1274 
1275 /**
1276   * @brief  Disable Bypass the shadow registers
1277   * @rmtoll RTC_CR           BYPSHAD       LL_RTC_DisableShadowRegBypass
1278   * @param  RTCx RTC Instance
1279   * @retval None
1280   */
LL_RTC_DisableShadowRegBypass(RTC_TypeDef * RTCx)1281 __STATIC_INLINE void LL_RTC_DisableShadowRegBypass(RTC_TypeDef *RTCx)
1282 {
1283   CLEAR_BIT(RTCx->CR, RTC_CR_BYPSHAD);
1284 }
1285 
1286 /**
1287   * @brief  Check if Shadow registers bypass is enabled or not.
1288   * @rmtoll RTC_CR           BYPSHAD       LL_RTC_IsShadowRegBypassEnabled
1289   * @param  RTCx RTC Instance
1290   * @retval State of bit (1 or 0).
1291   */
LL_RTC_IsShadowRegBypassEnabled(const RTC_TypeDef * RTCx)1292 __STATIC_INLINE uint32_t LL_RTC_IsShadowRegBypassEnabled(const RTC_TypeDef *RTCx)
1293 {
1294   return ((READ_BIT(RTCx->CR, RTC_CR_BYPSHAD) == (RTC_CR_BYPSHAD)) ? 1U : 0U);
1295 }
1296 
1297 /**
1298   * @brief  Enable RTC_REFIN reference clock detection (50 or 60 Hz)
1299   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1300   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1301   * @rmtoll RTC_CR           REFCKON       LL_RTC_EnableRefClock
1302   * @param  RTCx RTC Instance
1303   * @retval None
1304   */
LL_RTC_EnableRefClock(RTC_TypeDef * RTCx)1305 __STATIC_INLINE void LL_RTC_EnableRefClock(RTC_TypeDef *RTCx)
1306 {
1307   SET_BIT(RTCx->CR, RTC_CR_REFCKON);
1308 }
1309 
1310 /**
1311   * @brief  Disable RTC_REFIN reference clock detection (50 or 60 Hz)
1312   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1313   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1314   * @rmtoll RTC_CR           REFCKON       LL_RTC_DisableRefClock
1315   * @param  RTCx RTC Instance
1316   * @retval None
1317   */
LL_RTC_DisableRefClock(RTC_TypeDef * RTCx)1318 __STATIC_INLINE void LL_RTC_DisableRefClock(RTC_TypeDef *RTCx)
1319 {
1320   CLEAR_BIT(RTCx->CR, RTC_CR_REFCKON);
1321 }
1322 
1323 /**
1324   * @brief  Set Asynchronous prescaler factor
1325   * @rmtoll RTC_PRER         PREDIV_A      LL_RTC_SetAsynchPrescaler
1326   * @param  RTCx RTC Instance
1327   * @param  AsynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7F
1328   * @retval None
1329   */
LL_RTC_SetAsynchPrescaler(RTC_TypeDef * RTCx,uint32_t AsynchPrescaler)1330 __STATIC_INLINE void LL_RTC_SetAsynchPrescaler(RTC_TypeDef *RTCx, uint32_t AsynchPrescaler)
1331 {
1332   MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_A, AsynchPrescaler << RTC_PRER_PREDIV_A_Pos);
1333 }
1334 
1335 /**
1336   * @brief  Set Synchronous prescaler factor
1337   * @rmtoll RTC_PRER         PREDIV_S      LL_RTC_SetSynchPrescaler
1338   * @param  RTCx RTC Instance
1339   * @param  SynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7FFF
1340   * @retval None
1341   */
LL_RTC_SetSynchPrescaler(RTC_TypeDef * RTCx,uint32_t SynchPrescaler)1342 __STATIC_INLINE void LL_RTC_SetSynchPrescaler(RTC_TypeDef *RTCx, uint32_t SynchPrescaler)
1343 {
1344   MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_S, SynchPrescaler);
1345 }
1346 
1347 /**
1348   * @brief  Get Asynchronous prescaler factor
1349   * @rmtoll RTC_PRER         PREDIV_A      LL_RTC_GetAsynchPrescaler
1350   * @param  RTCx RTC Instance
1351   * @retval Value between Min_Data = 0 and Max_Data = 0x7F
1352   */
LL_RTC_GetAsynchPrescaler(const RTC_TypeDef * RTCx)1353 __STATIC_INLINE uint32_t LL_RTC_GetAsynchPrescaler(const RTC_TypeDef *RTCx)
1354 {
1355   return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_A) >> RTC_PRER_PREDIV_A_Pos);
1356 }
1357 
1358 /**
1359   * @brief  Get Synchronous prescaler factor
1360   * @rmtoll RTC_PRER         PREDIV_S      LL_RTC_GetSynchPrescaler
1361   * @param  RTCx RTC Instance
1362   * @retval Value between Min_Data = 0 and Max_Data = 0x7FFF
1363   */
LL_RTC_GetSynchPrescaler(const RTC_TypeDef * RTCx)1364 __STATIC_INLINE uint32_t LL_RTC_GetSynchPrescaler(const RTC_TypeDef *RTCx)
1365 {
1366   return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_S));
1367 }
1368 
1369 /**
1370   * @brief  Enable the write protection for RTC registers.
1371   * @rmtoll RTC_WPR          KEY           LL_RTC_EnableWriteProtection
1372   * @param  RTCx RTC Instance
1373   * @retval None
1374   */
LL_RTC_EnableWriteProtection(RTC_TypeDef * RTCx)1375 __STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx)
1376 {
1377   WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_DISABLE);
1378 }
1379 
1380 /**
1381   * @brief  Disable the write protection for RTC registers.
1382   * @rmtoll RTC_WPR          KEY           LL_RTC_DisableWriteProtection
1383   * @param  RTCx RTC Instance
1384   * @retval None
1385   */
LL_RTC_DisableWriteProtection(RTC_TypeDef * RTCx)1386 __STATIC_INLINE void LL_RTC_DisableWriteProtection(RTC_TypeDef *RTCx)
1387 {
1388   WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_1);
1389   WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_2);
1390 }
1391 
1392 /**
1393   * @brief  Enable tamper output.
1394   * @note When the tamper output is enabled, all external and internal tamper flags
1395   *       are ORed and routed to the TAMPALRM output.
1396   * @rmtoll RTC_CR           TAMPOE       LL_RTC_EnableTamperOutput
1397   * @param  RTCx RTC Instance
1398   * @retval None
1399   */
LL_RTC_EnableTamperOutput(RTC_TypeDef * RTCx)1400 __STATIC_INLINE void LL_RTC_EnableTamperOutput(RTC_TypeDef *RTCx)
1401 {
1402   SET_BIT(RTCx->CR, RTC_CR_TAMPOE);
1403 }
1404 
1405 /**
1406   * @brief  Disable tamper output.
1407   * @rmtoll RTC_CR           TAMPOE       LL_RTC_DisableTamperOutput
1408   * @param  RTCx RTC Instance
1409   * @retval None
1410   */
LL_RTC_DisableTamperOutput(RTC_TypeDef * RTCx)1411 __STATIC_INLINE void LL_RTC_DisableTamperOutput(RTC_TypeDef *RTCx)
1412 {
1413   CLEAR_BIT(RTCx->CR, RTC_CR_TAMPOE);
1414 }
1415 
1416 /**
1417   * @brief  Check if tamper output is enabled or not.
1418   * @rmtoll RTC_CR           TAMPOE       LL_RTC_IsTamperOutputEnabled
1419   * @param  RTCx RTC Instance
1420   * @retval State of bit (1 or 0).
1421   */
LL_RTC_IsTamperOutputEnabled(const RTC_TypeDef * RTCx)1422 __STATIC_INLINE uint32_t LL_RTC_IsTamperOutputEnabled(const RTC_TypeDef *RTCx)
1423 {
1424   return ((READ_BIT(RTCx->CR, RTC_CR_TAMPOE) == (RTC_CR_TAMPOE)) ? 1U : 0U);
1425 }
1426 
1427 /**
1428   * @brief  Enable internal pull-up in output mode.
1429   * @rmtoll RTC_CR           TAMPALRM_PU       LL_RTC_EnableAlarmPullUp
1430   * @param  RTCx RTC Instance
1431   * @retval None
1432   */
LL_RTC_EnableAlarmPullUp(RTC_TypeDef * RTCx)1433 __STATIC_INLINE void LL_RTC_EnableAlarmPullUp(RTC_TypeDef *RTCx)
1434 {
1435   SET_BIT(RTCx->CR, RTC_CR_TAMPALRM_PU);
1436 }
1437 
1438 /**
1439   * @brief  Disable internal pull-up in output mode.
1440   * @rmtoll RTC_CR           TAMPALRM_PU       LL_RTC_EnableAlarmPullUp
1441   * @param  RTCx RTC Instance
1442   * @retval None
1443   */
LL_RTC_DisableAlarmPullUp(RTC_TypeDef * RTCx)1444 __STATIC_INLINE void LL_RTC_DisableAlarmPullUp(RTC_TypeDef *RTCx)
1445 {
1446   CLEAR_BIT(RTCx->CR, RTC_CR_TAMPALRM_PU);
1447 }
1448 
1449 /**
1450   * @brief  Check if internal pull-up in output mode is enabled or not.
1451   * @rmtoll RTC_CR           TAMPALRM_PU       LL_RTC_IsAlarmPullUpEnabled
1452   * @param  RTCx RTC Instance
1453   * @retval State of bit (1 or 0).
1454   */
LL_RTC_IsAlarmPullUpEnabled(const RTC_TypeDef * RTCx)1455 __STATIC_INLINE uint32_t LL_RTC_IsAlarmPullUpEnabled(const RTC_TypeDef *RTCx)
1456 {
1457   return ((READ_BIT(RTCx->CR, RTC_CR_TAMPALRM_PU) == (RTC_CR_TAMPALRM_PU)) ? 1U : 0U);
1458 }
1459 
1460 /**
1461   * @brief  Enable RTC_OUT2 output
1462   * @note RTC_OUT2 mapping depends on both OSEL (@ref LL_RTC_SetAlarmOutEvent)
1463   *       and COE (@ref LL_RTC_CAL_SetOutputFreq) settings.
1464   * @note RTC_OUT2 is not available in VBAT mode.
1465   * @rmtoll RTC_CR           OUT2EN       LL_RTC_EnableOutput2
1466   * @param  RTCx RTC Instance
1467   * @retval None
1468   */
LL_RTC_EnableOutput2(RTC_TypeDef * RTCx)1469 __STATIC_INLINE void LL_RTC_EnableOutput2(RTC_TypeDef *RTCx)
1470 {
1471   SET_BIT(RTCx->CR, RTC_CR_OUT2EN);
1472 }
1473 
1474 /**
1475   * @brief  Disable RTC_OUT2 output
1476   * @rmtoll RTC_CR           OUT2EN       LL_RTC_DisableOutput2
1477   * @param  RTCx RTC Instance
1478   * @retval None
1479   */
LL_RTC_DisableOutput2(RTC_TypeDef * RTCx)1480 __STATIC_INLINE void LL_RTC_DisableOutput2(RTC_TypeDef *RTCx)
1481 {
1482   CLEAR_BIT(RTCx->CR, RTC_CR_OUT2EN);
1483 }
1484 
1485 /**
1486   * @brief  Check if RTC_OUT2 output is enabled or not.
1487   * @rmtoll RTC_CR           OUT2EN       LL_RTC_IsOutput2Enabled
1488   * @param  RTCx RTC Instance
1489   * @retval State of bit (1 or 0).
1490   */
LL_RTC_IsOutput2Enabled(const RTC_TypeDef * RTCx)1491 __STATIC_INLINE uint32_t LL_RTC_IsOutput2Enabled(const RTC_TypeDef *RTCx)
1492 {
1493   return ((READ_BIT(RTCx->CR, RTC_CR_OUT2EN) == (RTC_CR_OUT2EN)) ? 1U : 0U);
1494 }
1495 /**
1496   * @}
1497   */
1498 
1499 /** @defgroup RTC_LL_EF_Time Time
1500   * @{
1501   */
1502 
1503 /**
1504   * @brief  Set time format (AM/24-hour or PM notation)
1505   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1506   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1507   * @rmtoll RTC_TR           PM            LL_RTC_TIME_SetFormat
1508   * @param  RTCx RTC Instance
1509   * @param  TimeFormat This parameter can be one of the following values:
1510   *         @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
1511   *         @arg @ref LL_RTC_TIME_FORMAT_PM
1512   * @retval None
1513   */
LL_RTC_TIME_SetFormat(RTC_TypeDef * RTCx,uint32_t TimeFormat)1514 __STATIC_INLINE void LL_RTC_TIME_SetFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
1515 {
1516   MODIFY_REG(RTCx->TR, RTC_TR_PM, TimeFormat);
1517 }
1518 
1519 /**
1520   * @brief  Get time format (AM or PM notation)
1521   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
1522   *       before reading this bit
1523   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1524   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1525   * @rmtoll RTC_TR           PM            LL_RTC_TIME_GetFormat
1526   * @param  RTCx RTC Instance
1527   * @retval Returned value can be one of the following values:
1528   *         @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
1529   *         @arg @ref LL_RTC_TIME_FORMAT_PM
1530   */
LL_RTC_TIME_GetFormat(const RTC_TypeDef * RTCx)1531 __STATIC_INLINE uint32_t LL_RTC_TIME_GetFormat(const RTC_TypeDef *RTCx)
1532 {
1533   return (uint32_t)(READ_BIT(RTCx->TR, RTC_TR_PM));
1534 }
1535 
1536 /**
1537   * @brief  Set Hours in BCD format
1538   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1539   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1540   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert hour from binary to BCD format
1541   * @rmtoll RTC_TR           HT            LL_RTC_TIME_SetHour\n
1542   *         RTC_TR           HU            LL_RTC_TIME_SetHour
1543   * @param  RTCx RTC Instance
1544   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1545   * @retval None
1546   */
LL_RTC_TIME_SetHour(RTC_TypeDef * RTCx,uint32_t Hours)1547 __STATIC_INLINE void LL_RTC_TIME_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
1548 {
1549   MODIFY_REG(RTCx->TR, (RTC_TR_HT | RTC_TR_HU),
1550              (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)));
1551 }
1552 
1553 /**
1554   * @brief  Get Hours in BCD format
1555   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
1556   *       before reading this bit
1557   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1558   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1559   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert hour from BCD to
1560   *       Binary format
1561   * @rmtoll RTC_TR           HT            LL_RTC_TIME_GetHour\n
1562   *         RTC_TR           HU            LL_RTC_TIME_GetHour
1563   * @param  RTCx RTC Instance
1564   * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1565   */
LL_RTC_TIME_GetHour(const RTC_TypeDef * RTCx)1566 __STATIC_INLINE uint32_t LL_RTC_TIME_GetHour(const RTC_TypeDef *RTCx)
1567 {
1568   return (uint32_t)((READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU))) >> RTC_TR_HU_Pos);
1569 }
1570 
1571 /**
1572   * @brief  Set Minutes in BCD format
1573   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1574   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1575   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
1576   * @rmtoll RTC_TR           MNT           LL_RTC_TIME_SetMinute\n
1577   *         RTC_TR           MNU           LL_RTC_TIME_SetMinute
1578   * @param  RTCx RTC Instance
1579   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
1580   * @retval None
1581   */
LL_RTC_TIME_SetMinute(RTC_TypeDef * RTCx,uint32_t Minutes)1582 __STATIC_INLINE void LL_RTC_TIME_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
1583 {
1584   MODIFY_REG(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU),
1585              (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)));
1586 }
1587 
1588 /**
1589   * @brief  Get Minutes 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 Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1593   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1594   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert minute from BCD
1595   *       to Binary format
1596   * @rmtoll RTC_TR           MNT           LL_RTC_TIME_GetMinute\n
1597   *         RTC_TR           MNU           LL_RTC_TIME_GetMinute
1598   * @param  RTCx RTC Instance
1599   * @retval Value between Min_Data=0x00 and Max_Data=0x59
1600   */
LL_RTC_TIME_GetMinute(const RTC_TypeDef * RTCx)1601 __STATIC_INLINE uint32_t LL_RTC_TIME_GetMinute(const RTC_TypeDef *RTCx)
1602 {
1603   return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU)) >> RTC_TR_MNU_Pos);
1604 }
1605 
1606 /**
1607   * @brief  Set Seconds in BCD format
1608   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1609   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1610   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
1611   * @rmtoll RTC_TR           ST            LL_RTC_TIME_SetSecond\n
1612   *         RTC_TR           SU            LL_RTC_TIME_SetSecond
1613   * @param  RTCx RTC Instance
1614   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
1615   * @retval None
1616   */
LL_RTC_TIME_SetSecond(RTC_TypeDef * RTCx,uint32_t Seconds)1617 __STATIC_INLINE void LL_RTC_TIME_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
1618 {
1619   MODIFY_REG(RTCx->TR, (RTC_TR_ST | RTC_TR_SU),
1620              (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos)));
1621 }
1622 
1623 /**
1624   * @brief  Get Seconds in BCD format
1625   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
1626   *       before reading this bit
1627   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1628   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1629   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD
1630   *       to Binary format
1631   * @rmtoll RTC_TR           ST            LL_RTC_TIME_GetSecond\n
1632   *         RTC_TR           SU            LL_RTC_TIME_GetSecond
1633   * @param  RTCx RTC Instance
1634   * @retval Value between Min_Data=0x00 and Max_Data=0x59
1635   */
LL_RTC_TIME_GetSecond(const RTC_TypeDef * RTCx)1636 __STATIC_INLINE uint32_t LL_RTC_TIME_GetSecond(const RTC_TypeDef *RTCx)
1637 {
1638   return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_ST | RTC_TR_SU)) >> RTC_TR_SU_Pos);
1639 }
1640 
1641 /**
1642   * @brief  Set time (hour, minute and second) in BCD format
1643   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1644   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1645   * @note TimeFormat and Hours should follow the same format
1646   * @rmtoll RTC_TR           PM            LL_RTC_TIME_Config\n
1647   *         RTC_TR           HT            LL_RTC_TIME_Config\n
1648   *         RTC_TR           HU            LL_RTC_TIME_Config\n
1649   *         RTC_TR           MNT           LL_RTC_TIME_Config\n
1650   *         RTC_TR           MNU           LL_RTC_TIME_Config\n
1651   *         RTC_TR           ST            LL_RTC_TIME_Config\n
1652   *         RTC_TR           SU            LL_RTC_TIME_Config
1653   * @param  RTCx RTC Instance
1654   * @param  Format12_24 This parameter can be one of the following values:
1655   *         @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
1656   *         @arg @ref LL_RTC_TIME_FORMAT_PM
1657   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1658   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
1659   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
1660   * @retval None
1661   */
LL_RTC_TIME_Config(RTC_TypeDef * RTCx,uint32_t Format12_24,uint32_t Hours,uint32_t Minutes,uint32_t Seconds)1662 __STATIC_INLINE void LL_RTC_TIME_Config(RTC_TypeDef *RTCx,
1663                                         uint32_t Format12_24,
1664                                         uint32_t Hours,
1665                                         uint32_t Minutes,
1666                                         uint32_t Seconds)
1667 {
1668   uint32_t temp;
1669 
1670   temp = Format12_24                                                                                    | \
1671          (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos))     | \
1672          (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)) | \
1673          (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos));
1674   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);
1675 }
1676 
1677 /**
1678   * @brief  Get time (hour, minute and second) in BCD format
1679   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
1680   *       before reading this bit
1681   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1682   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1683   * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
1684   *       are available to get independently each parameter.
1685   * @rmtoll RTC_TR           HT            LL_RTC_TIME_Get\n
1686   *         RTC_TR           HU            LL_RTC_TIME_Get\n
1687   *         RTC_TR           MNT           LL_RTC_TIME_Get\n
1688   *         RTC_TR           MNU           LL_RTC_TIME_Get\n
1689   *         RTC_TR           ST            LL_RTC_TIME_Get\n
1690   *         RTC_TR           SU            LL_RTC_TIME_Get
1691   * @param  RTCx RTC Instance
1692   * @retval Combination of hours, minutes and seconds (Format: 0x00HHMMSS).
1693   */
LL_RTC_TIME_Get(const RTC_TypeDef * RTCx)1694 __STATIC_INLINE uint32_t LL_RTC_TIME_Get(const RTC_TypeDef *RTCx)
1695 {
1696   uint32_t temp;
1697 
1698   temp = READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU | RTC_TR_MNT | RTC_TR_MNU | RTC_TR_ST | RTC_TR_SU));
1699   return (uint32_t)((((((temp & RTC_TR_HT) >> RTC_TR_HT_Pos) << 4U)                  | \
1700                       ((temp & RTC_TR_HU) >> RTC_TR_HU_Pos)) << RTC_OFFSET_HOUR)     | \
1701                     (((((temp & RTC_TR_MNT) >> RTC_TR_MNT_Pos) << 4U)                | \
1702                       ((temp & RTC_TR_MNU) >> RTC_TR_MNU_Pos)) << RTC_OFFSET_MINUTE) | \
1703                     ((((temp & RTC_TR_ST) >> RTC_TR_ST_Pos) << 4U) | ((temp & RTC_TR_SU) >> RTC_TR_SU_Pos)));
1704 }
1705 
1706 /**
1707   * @brief  Memorize whether the daylight saving time change has been performed
1708   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1709   * @rmtoll RTC_CR           BKP           LL_RTC_TIME_EnableDayLightStore
1710   * @param  RTCx RTC Instance
1711   * @retval None
1712   */
LL_RTC_TIME_EnableDayLightStore(RTC_TypeDef * RTCx)1713 __STATIC_INLINE void LL_RTC_TIME_EnableDayLightStore(RTC_TypeDef *RTCx)
1714 {
1715   SET_BIT(RTCx->CR, RTC_CR_BKP);
1716 }
1717 
1718 /**
1719   * @brief  Disable memorization whether the daylight saving time change has been performed.
1720   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1721   * @rmtoll RTC_CR           BKP           LL_RTC_TIME_DisableDayLightStore
1722   * @param  RTCx RTC Instance
1723   * @retval None
1724   */
LL_RTC_TIME_DisableDayLightStore(RTC_TypeDef * RTCx)1725 __STATIC_INLINE void LL_RTC_TIME_DisableDayLightStore(RTC_TypeDef *RTCx)
1726 {
1727   CLEAR_BIT(RTCx->CR, RTC_CR_BKP);
1728 }
1729 
1730 /**
1731   * @brief  Check if RTC Day Light Saving stored operation has been enabled or not
1732   * @rmtoll RTC_CR           BKP           LL_RTC_TIME_IsDayLightStoreEnabled
1733   * @param  RTCx RTC Instance
1734   * @retval State of bit (1 or 0).
1735   */
LL_RTC_TIME_IsDayLightStoreEnabled(const RTC_TypeDef * RTCx)1736 __STATIC_INLINE uint32_t LL_RTC_TIME_IsDayLightStoreEnabled(const RTC_TypeDef *RTCx)
1737 {
1738   return ((READ_BIT(RTCx->CR, RTC_CR_BKP) == (RTC_CR_BKP)) ? 1U : 0U);
1739 }
1740 
1741 /**
1742   * @brief  Subtract 1 hour (winter time change)
1743   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1744   * @rmtoll RTC_CR           SUB1H         LL_RTC_TIME_DecHour
1745   * @param  RTCx RTC Instance
1746   * @retval None
1747   */
LL_RTC_TIME_DecHour(RTC_TypeDef * RTCx)1748 __STATIC_INLINE void LL_RTC_TIME_DecHour(RTC_TypeDef *RTCx)
1749 {
1750   SET_BIT(RTCx->CR, RTC_CR_SUB1H);
1751 }
1752 
1753 /**
1754   * @brief  Add 1 hour (summer time change)
1755   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1756   * @rmtoll RTC_CR           ADD1H         LL_RTC_TIME_IncHour
1757   * @param  RTCx RTC Instance
1758   * @retval None
1759   */
LL_RTC_TIME_IncHour(RTC_TypeDef * RTCx)1760 __STATIC_INLINE void LL_RTC_TIME_IncHour(RTC_TypeDef *RTCx)
1761 {
1762   SET_BIT(RTCx->CR, RTC_CR_ADD1H);
1763 }
1764 
1765 /**
1766   * @brief  Get Sub second value in the synchronous prescaler counter.
1767   * @note  You can use both SubSeconds value and SecondFraction (PREDIV_S through
1768   *        LL_RTC_GetSynchPrescaler function) terms returned to convert Calendar
1769   *        SubSeconds value in second fraction ratio with time unit following
1770   *        generic formula:
1771   *          ==> Seconds fraction ratio * time_unit= [(SecondFraction-SubSeconds)/(SecondFraction+1)] * time_unit
1772   *        This conversion can be performed only if no shift operation is pending
1773   *        (ie. SHFP=0) when PREDIV_S >= SS.
1774   * @rmtoll RTC_SSR          SS            LL_RTC_TIME_GetSubSecond
1775   * @param  RTCx RTC Instance
1776   * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
1777   *         else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
1778   */
LL_RTC_TIME_GetSubSecond(const RTC_TypeDef * RTCx)1779 __STATIC_INLINE uint32_t LL_RTC_TIME_GetSubSecond(const RTC_TypeDef *RTCx)
1780 {
1781   return (uint32_t)(READ_BIT(RTCx->SSR, RTC_SSR_SS));
1782 }
1783 
1784 /**
1785   * @brief  Synchronize to a remote clock with a high degree of precision.
1786   * @note   This operation effectively subtracts from (delays) or advance the clock of a fraction of a second.
1787   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1788   * @note   When REFCKON is set, firmware must not write to Shift control register.
1789   * @rmtoll RTC_SHIFTR       ADD1S         LL_RTC_TIME_Synchronize\n
1790   *         RTC_SHIFTR       SUBFS         LL_RTC_TIME_Synchronize
1791   * @param  RTCx RTC Instance
1792   * @param  ShiftSecond This parameter can be one of the following values:
1793   *         @arg @ref LL_RTC_SHIFT_SECOND_DELAY
1794   *         @arg @ref LL_RTC_SHIFT_SECOND_ADVANCE
1795   * @param  Fraction Number of Seconds Fractions (any value from 0 to 0x7FFF)
1796   * @retval None
1797   */
LL_RTC_TIME_Synchronize(RTC_TypeDef * RTCx,uint32_t ShiftSecond,uint32_t Fraction)1798 __STATIC_INLINE void LL_RTC_TIME_Synchronize(RTC_TypeDef *RTCx, uint32_t ShiftSecond, uint32_t Fraction)
1799 {
1800   WRITE_REG(RTCx->SHIFTR, ShiftSecond | Fraction);
1801 }
1802 
1803 /**
1804   * @}
1805   */
1806 
1807 /** @defgroup RTC_LL_EF_Date Date
1808   * @{
1809   */
1810 
1811 /**
1812   * @brief  Set Year in BCD format
1813   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Year from binary to BCD format
1814   * @rmtoll RTC_DR           YT            LL_RTC_DATE_SetYear\n
1815   *         RTC_DR           YU            LL_RTC_DATE_SetYear
1816   * @param  RTCx RTC Instance
1817   * @param  Year Value between Min_Data=0x00 and Max_Data=0x99
1818   * @retval None
1819   */
LL_RTC_DATE_SetYear(RTC_TypeDef * RTCx,uint32_t Year)1820 __STATIC_INLINE void LL_RTC_DATE_SetYear(RTC_TypeDef *RTCx, uint32_t Year)
1821 {
1822   MODIFY_REG(RTCx->DR, (RTC_DR_YT | RTC_DR_YU),
1823              (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos)));
1824 }
1825 
1826 /**
1827   * @brief  Get Year in BCD format
1828   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
1829   *       before reading this bit
1830   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Year from BCD to Binary format
1831   * @rmtoll RTC_DR           YT            LL_RTC_DATE_GetYear\n
1832   *         RTC_DR           YU            LL_RTC_DATE_GetYear
1833   * @param  RTCx RTC Instance
1834   * @retval Value between Min_Data=0x00 and Max_Data=0x99
1835   */
LL_RTC_DATE_GetYear(const RTC_TypeDef * RTCx)1836 __STATIC_INLINE uint32_t LL_RTC_DATE_GetYear(const RTC_TypeDef *RTCx)
1837 {
1838   return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_YT | RTC_DR_YU))) >> RTC_DR_YU_Pos);
1839 }
1840 
1841 /**
1842   * @brief  Set Week day
1843   * @rmtoll RTC_DR           WDU           LL_RTC_DATE_SetWeekDay
1844   * @param  RTCx RTC Instance
1845   * @param  WeekDay This parameter can be one of the following values:
1846   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
1847   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
1848   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1849   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
1850   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
1851   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
1852   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
1853   * @retval None
1854   */
LL_RTC_DATE_SetWeekDay(RTC_TypeDef * RTCx,uint32_t WeekDay)1855 __STATIC_INLINE void LL_RTC_DATE_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
1856 {
1857   MODIFY_REG(RTCx->DR, RTC_DR_WDU, WeekDay << RTC_DR_WDU_Pos);
1858 }
1859 
1860 /**
1861   * @brief  Get Week day
1862   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
1863   *       before reading this bit
1864   * @rmtoll RTC_DR           WDU           LL_RTC_DATE_GetWeekDay
1865   * @param  RTCx RTC Instance
1866   * @retval Returned value can be one of the following values:
1867   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
1868   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
1869   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1870   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
1871   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
1872   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
1873   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
1874   */
LL_RTC_DATE_GetWeekDay(const RTC_TypeDef * RTCx)1875 __STATIC_INLINE uint32_t LL_RTC_DATE_GetWeekDay(const RTC_TypeDef *RTCx)
1876 {
1877   return (uint32_t)(READ_BIT(RTCx->DR, RTC_DR_WDU) >> RTC_DR_WDU_Pos);
1878 }
1879 
1880 /**
1881   * @brief  Set Month in BCD format
1882   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Month from binary to BCD format
1883   * @rmtoll RTC_DR           MT            LL_RTC_DATE_SetMonth\n
1884   *         RTC_DR           MU            LL_RTC_DATE_SetMonth
1885   * @param  RTCx RTC Instance
1886   * @param  Month This parameter can be one of the following values:
1887   *         @arg @ref LL_RTC_MONTH_JANUARY
1888   *         @arg @ref LL_RTC_MONTH_FEBRUARY
1889   *         @arg @ref LL_RTC_MONTH_MARCH
1890   *         @arg @ref LL_RTC_MONTH_APRIL
1891   *         @arg @ref LL_RTC_MONTH_MAY
1892   *         @arg @ref LL_RTC_MONTH_JUNE
1893   *         @arg @ref LL_RTC_MONTH_JULY
1894   *         @arg @ref LL_RTC_MONTH_AUGUST
1895   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
1896   *         @arg @ref LL_RTC_MONTH_OCTOBER
1897   *         @arg @ref LL_RTC_MONTH_NOVEMBER
1898   *         @arg @ref LL_RTC_MONTH_DECEMBER
1899   * @retval None
1900   */
LL_RTC_DATE_SetMonth(RTC_TypeDef * RTCx,uint32_t Month)1901 __STATIC_INLINE void LL_RTC_DATE_SetMonth(RTC_TypeDef *RTCx, uint32_t Month)
1902 {
1903   MODIFY_REG(RTCx->DR, (RTC_DR_MT | RTC_DR_MU),
1904              (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)));
1905 }
1906 
1907 /**
1908   * @brief  Get Month in BCD format
1909   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
1910   *       before reading this bit
1911   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
1912   * @rmtoll RTC_DR           MT            LL_RTC_DATE_GetMonth\n
1913   *         RTC_DR           MU            LL_RTC_DATE_GetMonth
1914   * @param  RTCx RTC Instance
1915   * @retval Returned value can be one of the following values:
1916   *         @arg @ref LL_RTC_MONTH_JANUARY
1917   *         @arg @ref LL_RTC_MONTH_FEBRUARY
1918   *         @arg @ref LL_RTC_MONTH_MARCH
1919   *         @arg @ref LL_RTC_MONTH_APRIL
1920   *         @arg @ref LL_RTC_MONTH_MAY
1921   *         @arg @ref LL_RTC_MONTH_JUNE
1922   *         @arg @ref LL_RTC_MONTH_JULY
1923   *         @arg @ref LL_RTC_MONTH_AUGUST
1924   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
1925   *         @arg @ref LL_RTC_MONTH_OCTOBER
1926   *         @arg @ref LL_RTC_MONTH_NOVEMBER
1927   *         @arg @ref LL_RTC_MONTH_DECEMBER
1928   */
LL_RTC_DATE_GetMonth(const RTC_TypeDef * RTCx)1929 __STATIC_INLINE uint32_t LL_RTC_DATE_GetMonth(const RTC_TypeDef *RTCx)
1930 {
1931   return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_MT | RTC_DR_MU))) >> RTC_DR_MU_Pos);
1932 }
1933 
1934 /**
1935   * @brief  Set Day in BCD format
1936   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
1937   * @rmtoll RTC_DR           DT            LL_RTC_DATE_SetDay\n
1938   *         RTC_DR           DU            LL_RTC_DATE_SetDay
1939   * @param  RTCx RTC Instance
1940   * @param  Day Value between Min_Data=0x01 and Max_Data=0x31
1941   * @retval None
1942   */
LL_RTC_DATE_SetDay(RTC_TypeDef * RTCx,uint32_t Day)1943 __STATIC_INLINE void LL_RTC_DATE_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
1944 {
1945   MODIFY_REG(RTCx->DR, (RTC_DR_DT | RTC_DR_DU),
1946              (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos)));
1947 }
1948 
1949 /**
1950   * @brief  Get Day in BCD format
1951   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
1952   *       before reading this bit
1953   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
1954   * @rmtoll RTC_DR           DT            LL_RTC_DATE_GetDay\n
1955   *         RTC_DR           DU            LL_RTC_DATE_GetDay
1956   * @param  RTCx RTC Instance
1957   * @retval Value between Min_Data=0x01 and Max_Data=0x31
1958   */
LL_RTC_DATE_GetDay(const RTC_TypeDef * RTCx)1959 __STATIC_INLINE uint32_t LL_RTC_DATE_GetDay(const RTC_TypeDef *RTCx)
1960 {
1961   return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_DT | RTC_DR_DU))) >> RTC_DR_DU_Pos);
1962 }
1963 
1964 /**
1965   * @brief  Set date (WeekDay, Day, Month and Year) in BCD format
1966   * @rmtoll RTC_DR           WDU           LL_RTC_DATE_Config\n
1967   *         RTC_DR           MT            LL_RTC_DATE_Config\n
1968   *         RTC_DR           MU            LL_RTC_DATE_Config\n
1969   *         RTC_DR           DT            LL_RTC_DATE_Config\n
1970   *         RTC_DR           DU            LL_RTC_DATE_Config\n
1971   *         RTC_DR           YT            LL_RTC_DATE_Config\n
1972   *         RTC_DR           YU            LL_RTC_DATE_Config
1973   * @param  RTCx RTC Instance
1974   * @param  WeekDay This parameter can be one of the following values:
1975   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
1976   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
1977   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1978   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
1979   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
1980   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
1981   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
1982   * @param  Day Value between Min_Data=0x01 and Max_Data=0x31
1983   * @param  Month This parameter can be one of the following values:
1984   *         @arg @ref LL_RTC_MONTH_JANUARY
1985   *         @arg @ref LL_RTC_MONTH_FEBRUARY
1986   *         @arg @ref LL_RTC_MONTH_MARCH
1987   *         @arg @ref LL_RTC_MONTH_APRIL
1988   *         @arg @ref LL_RTC_MONTH_MAY
1989   *         @arg @ref LL_RTC_MONTH_JUNE
1990   *         @arg @ref LL_RTC_MONTH_JULY
1991   *         @arg @ref LL_RTC_MONTH_AUGUST
1992   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
1993   *         @arg @ref LL_RTC_MONTH_OCTOBER
1994   *         @arg @ref LL_RTC_MONTH_NOVEMBER
1995   *         @arg @ref LL_RTC_MONTH_DECEMBER
1996   * @param  Year Value between Min_Data=0x00 and Max_Data=0x99
1997   * @retval None
1998   */
LL_RTC_DATE_Config(RTC_TypeDef * RTCx,uint32_t WeekDay,uint32_t Day,uint32_t Month,uint32_t Year)1999 __STATIC_INLINE void LL_RTC_DATE_Config(RTC_TypeDef *RTCx,
2000                                         uint32_t WeekDay,
2001                                         uint32_t Day,
2002                                         uint32_t Month,
2003                                         uint32_t Year)
2004 {
2005   uint32_t temp;
2006 
2007   temp = (WeekDay << RTC_DR_WDU_Pos)                                                      | \
2008          (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos))   | \
2009          (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)) | \
2010          (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos));
2011 
2012   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);
2013 }
2014 
2015 /**
2016   * @brief  Get date (WeekDay, Day, Month and Year) in BCD format
2017   * @note if RTC shadow registers are not bypassed (BYPSHAD=0), need to check if RSF flag is set
2018   *       before reading this bit
2019   * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_YEAR, __LL_RTC_GET_MONTH,
2020   * and __LL_RTC_GET_DAY are available to get independently each parameter.
2021   * @rmtoll RTC_DR           WDU           LL_RTC_DATE_Get\n
2022   *         RTC_DR           MT            LL_RTC_DATE_Get\n
2023   *         RTC_DR           MU            LL_RTC_DATE_Get\n
2024   *         RTC_DR           DT            LL_RTC_DATE_Get\n
2025   *         RTC_DR           DU            LL_RTC_DATE_Get\n
2026   *         RTC_DR           YT            LL_RTC_DATE_Get\n
2027   *         RTC_DR           YU            LL_RTC_DATE_Get
2028   * @param  RTCx RTC Instance
2029   * @retval Combination of WeekDay, Day, Month and Year (Format: 0xWWDDMMYY).
2030   */
LL_RTC_DATE_Get(const RTC_TypeDef * RTCx)2031 __STATIC_INLINE uint32_t LL_RTC_DATE_Get(const RTC_TypeDef *RTCx)
2032 {
2033   uint32_t temp;
2034 
2035   temp = READ_BIT(RTCx->DR, (RTC_DR_WDU | RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | RTC_DR_DU | RTC_DR_YT | RTC_DR_YU));
2036   return (uint32_t)((((temp & RTC_DR_WDU) >> RTC_DR_WDU_Pos) << RTC_OFFSET_WEEKDAY) | \
2037                     (((((temp & RTC_DR_DT) >> RTC_DR_DT_Pos) << 4U)                 | \
2038                       ((temp & RTC_DR_DU) >> RTC_DR_DU_Pos)) << RTC_OFFSET_DAY)       | \
2039                     (((((temp & RTC_DR_MT) >> RTC_DR_MT_Pos) << 4U)                 | \
2040                       ((temp & RTC_DR_MU) >> RTC_DR_MU_Pos)) << RTC_OFFSET_MONTH)     | \
2041                     ((((temp & RTC_DR_YT) >> RTC_DR_YT_Pos) << 4U) | ((temp & RTC_DR_YU) >> RTC_DR_YU_Pos)));
2042 }
2043 
2044 /**
2045   * @}
2046   */
2047 
2048 /** @defgroup RTC_LL_EF_ALARMA ALARMA
2049   * @{
2050   */
2051 
2052 /**
2053   * @brief  Enable Alarm A
2054   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2055   * @rmtoll RTC_CR           ALRAE         LL_RTC_ALMA_Enable
2056   * @param  RTCx RTC Instance
2057   * @retval None
2058   */
LL_RTC_ALMA_Enable(RTC_TypeDef * RTCx)2059 __STATIC_INLINE void LL_RTC_ALMA_Enable(RTC_TypeDef *RTCx)
2060 {
2061   SET_BIT(RTCx->CR, RTC_CR_ALRAE);
2062 }
2063 
2064 /**
2065   * @brief  Disable Alarm A
2066   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2067   * @rmtoll RTC_CR           ALRAE         LL_RTC_ALMA_Disable
2068   * @param  RTCx RTC Instance
2069   * @retval None
2070   */
LL_RTC_ALMA_Disable(RTC_TypeDef * RTCx)2071 __STATIC_INLINE void LL_RTC_ALMA_Disable(RTC_TypeDef *RTCx)
2072 {
2073   CLEAR_BIT(RTCx->CR, RTC_CR_ALRAE);
2074 }
2075 
2076 /**
2077   * @brief  Specify the Alarm A masks.
2078   * @rmtoll RTC_ALRMAR       MSK4          LL_RTC_ALMA_SetMask\n
2079   *         RTC_ALRMAR       MSK3          LL_RTC_ALMA_SetMask\n
2080   *         RTC_ALRMAR       MSK2          LL_RTC_ALMA_SetMask\n
2081   *         RTC_ALRMAR       MSK1          LL_RTC_ALMA_SetMask
2082   * @param  RTCx RTC Instance
2083   * @param  Mask This parameter can be a combination of the following values:
2084   *         @arg @ref LL_RTC_ALMA_MASK_NONE
2085   *         @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
2086   *         @arg @ref LL_RTC_ALMA_MASK_HOURS
2087   *         @arg @ref LL_RTC_ALMA_MASK_MINUTES
2088   *         @arg @ref LL_RTC_ALMA_MASK_SECONDS
2089   *         @arg @ref LL_RTC_ALMA_MASK_ALL
2090   * @retval None
2091   */
LL_RTC_ALMA_SetMask(RTC_TypeDef * RTCx,uint32_t Mask)2092 __STATIC_INLINE void LL_RTC_ALMA_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
2093 {
2094   MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1, Mask);
2095 }
2096 
2097 /**
2098   * @brief  Get the Alarm A masks.
2099   * @rmtoll RTC_ALRMAR       MSK4          LL_RTC_ALMA_GetMask\n
2100   *         RTC_ALRMAR       MSK3          LL_RTC_ALMA_GetMask\n
2101   *         RTC_ALRMAR       MSK2          LL_RTC_ALMA_GetMask\n
2102   *         RTC_ALRMAR       MSK1          LL_RTC_ALMA_GetMask
2103   * @param  RTCx RTC Instance
2104   * @retval Returned value can be can be a combination of the following values:
2105   *         @arg @ref LL_RTC_ALMA_MASK_NONE
2106   *         @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
2107   *         @arg @ref LL_RTC_ALMA_MASK_HOURS
2108   *         @arg @ref LL_RTC_ALMA_MASK_MINUTES
2109   *         @arg @ref LL_RTC_ALMA_MASK_SECONDS
2110   *         @arg @ref LL_RTC_ALMA_MASK_ALL
2111   */
LL_RTC_ALMA_GetMask(const RTC_TypeDef * RTCx)2112 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMask(const RTC_TypeDef *RTCx)
2113 {
2114   return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1));
2115 }
2116 
2117 /**
2118   * @brief  Enable AlarmA Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
2119   * @rmtoll RTC_ALRMAR       WDSEL         LL_RTC_ALMA_EnableWeekday
2120   * @param  RTCx RTC Instance
2121   * @retval None
2122   */
LL_RTC_ALMA_EnableWeekday(RTC_TypeDef * RTCx)2123 __STATIC_INLINE void LL_RTC_ALMA_EnableWeekday(RTC_TypeDef *RTCx)
2124 {
2125   SET_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
2126 }
2127 
2128 /**
2129   * @brief  Disable AlarmA Week day selection (DU[3:0] represents the date )
2130   * @rmtoll RTC_ALRMAR       WDSEL         LL_RTC_ALMA_DisableWeekday
2131   * @param  RTCx RTC Instance
2132   * @retval None
2133   */
LL_RTC_ALMA_DisableWeekday(RTC_TypeDef * RTCx)2134 __STATIC_INLINE void LL_RTC_ALMA_DisableWeekday(RTC_TypeDef *RTCx)
2135 {
2136   CLEAR_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
2137 }
2138 
2139 /**
2140   * @brief  Set ALARM A Day in BCD format
2141   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
2142   * @rmtoll RTC_ALRMAR       DT            LL_RTC_ALMA_SetDay\n
2143   *         RTC_ALRMAR       DU            LL_RTC_ALMA_SetDay
2144   * @param  RTCx RTC Instance
2145   * @param  Day Value between Min_Data=0x01 and Max_Data=0x31
2146   * @retval None
2147   */
LL_RTC_ALMA_SetDay(RTC_TypeDef * RTCx,uint32_t Day)2148 __STATIC_INLINE void LL_RTC_ALMA_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
2149 {
2150   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU),
2151              (((Day & 0xF0U) << (RTC_ALRMAR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMAR_DU_Pos)));
2152 }
2153 
2154 /**
2155   * @brief  Get ALARM A Day in BCD format
2156   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
2157   * @rmtoll RTC_ALRMAR       DT            LL_RTC_ALMA_GetDay\n
2158   *         RTC_ALRMAR       DU            LL_RTC_ALMA_GetDay
2159   * @param  RTCx RTC Instance
2160   * @retval Value between Min_Data=0x01 and Max_Data=0x31
2161   */
LL_RTC_ALMA_GetDay(const RTC_TypeDef * RTCx)2162 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetDay(const RTC_TypeDef *RTCx)
2163 {
2164   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU))) >> RTC_ALRMAR_DU_Pos);
2165 }
2166 
2167 /**
2168   * @brief  Set ALARM A Weekday
2169   * @rmtoll RTC_ALRMAR       DU            LL_RTC_ALMA_SetWeekDay
2170   * @param  RTCx RTC Instance
2171   * @param  WeekDay This parameter can be one of the following values:
2172   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
2173   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
2174   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
2175   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
2176   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
2177   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
2178   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
2179   * @retval None
2180   */
LL_RTC_ALMA_SetWeekDay(RTC_TypeDef * RTCx,uint32_t WeekDay)2181 __STATIC_INLINE void LL_RTC_ALMA_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
2182 {
2183   MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_DU, WeekDay << RTC_ALRMAR_DU_Pos);
2184 }
2185 
2186 /**
2187   * @brief  Get ALARM A Weekday
2188   * @rmtoll RTC_ALRMAR       DU            LL_RTC_ALMA_GetWeekDay
2189   * @param  RTCx RTC Instance
2190   * @retval Returned value can be one of the following values:
2191   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
2192   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
2193   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
2194   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
2195   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
2196   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
2197   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
2198   */
LL_RTC_ALMA_GetWeekDay(const RTC_TypeDef * RTCx)2199 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetWeekDay(const RTC_TypeDef *RTCx)
2200 {
2201   return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_DU) >> RTC_ALRMAR_DU_Pos);
2202 }
2203 
2204 /**
2205   * @brief  Set Alarm A time format (AM/24-hour or PM notation)
2206   * @rmtoll RTC_ALRMAR       PM            LL_RTC_ALMA_SetTimeFormat
2207   * @param  RTCx RTC Instance
2208   * @param  TimeFormat This parameter can be one of the following values:
2209   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
2210   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
2211   * @retval None
2212   */
LL_RTC_ALMA_SetTimeFormat(RTC_TypeDef * RTCx,uint32_t TimeFormat)2213 __STATIC_INLINE void LL_RTC_ALMA_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
2214 {
2215   MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_PM, TimeFormat);
2216 }
2217 
2218 /**
2219   * @brief  Get Alarm A time format (AM or PM notation)
2220   * @rmtoll RTC_ALRMAR       PM            LL_RTC_ALMA_GetTimeFormat
2221   * @param  RTCx RTC Instance
2222   * @retval Returned value can be one of the following values:
2223   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
2224   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
2225   */
LL_RTC_ALMA_GetTimeFormat(const RTC_TypeDef * RTCx)2226 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTimeFormat(const RTC_TypeDef *RTCx)
2227 {
2228   return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_PM));
2229 }
2230 
2231 /**
2232   * @brief  Set ALARM A Hours in BCD format
2233   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
2234   * @rmtoll RTC_ALRMAR       HT            LL_RTC_ALMA_SetHour\n
2235   *         RTC_ALRMAR       HU            LL_RTC_ALMA_SetHour
2236   * @param  RTCx RTC Instance
2237   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2238   * @retval None
2239   */
LL_RTC_ALMA_SetHour(RTC_TypeDef * RTCx,uint32_t Hours)2240 __STATIC_INLINE void LL_RTC_ALMA_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
2241 {
2242   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU),
2243              (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos)));
2244 }
2245 
2246 /**
2247   * @brief  Get ALARM A Hours in BCD format
2248   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
2249   * @rmtoll RTC_ALRMAR       HT            LL_RTC_ALMA_GetHour\n
2250   *         RTC_ALRMAR       HU            LL_RTC_ALMA_GetHour
2251   * @param  RTCx RTC Instance
2252   * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2253   */
LL_RTC_ALMA_GetHour(const RTC_TypeDef * RTCx)2254 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetHour(const RTC_TypeDef *RTCx)
2255 {
2256   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU))) >> RTC_ALRMAR_HU_Pos);
2257 }
2258 
2259 /**
2260   * @brief  Set ALARM A Minutes in BCD format
2261   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
2262   * @rmtoll RTC_ALRMAR       MNT           LL_RTC_ALMA_SetMinute\n
2263   *         RTC_ALRMAR       MNU           LL_RTC_ALMA_SetMinute
2264   * @param  RTCx RTC Instance
2265   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
2266   * @retval None
2267   */
LL_RTC_ALMA_SetMinute(RTC_TypeDef * RTCx,uint32_t Minutes)2268 __STATIC_INLINE void LL_RTC_ALMA_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
2269 {
2270   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU),
2271              (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)));
2272 }
2273 
2274 /**
2275   * @brief  Get ALARM A Minutes in BCD format
2276   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
2277   * @rmtoll RTC_ALRMAR       MNT           LL_RTC_ALMA_GetMinute\n
2278   *         RTC_ALRMAR       MNU           LL_RTC_ALMA_GetMinute
2279   * @param  RTCx RTC Instance
2280   * @retval Value between Min_Data=0x00 and Max_Data=0x59
2281   */
LL_RTC_ALMA_GetMinute(const RTC_TypeDef * RTCx)2282 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMinute(const RTC_TypeDef *RTCx)
2283 {
2284   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU))) >> RTC_ALRMAR_MNU_Pos);
2285 }
2286 
2287 /**
2288   * @brief  Set ALARM A Seconds in BCD format
2289   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
2290   * @rmtoll RTC_ALRMAR       ST            LL_RTC_ALMA_SetSecond\n
2291   *         RTC_ALRMAR       SU            LL_RTC_ALMA_SetSecond
2292   * @param  RTCx RTC Instance
2293   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
2294   * @retval None
2295   */
LL_RTC_ALMA_SetSecond(RTC_TypeDef * RTCx,uint32_t Seconds)2296 __STATIC_INLINE void LL_RTC_ALMA_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
2297 {
2298   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU),
2299              (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos)));
2300 }
2301 
2302 /**
2303   * @brief  Get ALARM A Seconds in BCD format
2304   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
2305   * @rmtoll RTC_ALRMAR       ST            LL_RTC_ALMA_GetSecond\n
2306   *         RTC_ALRMAR       SU            LL_RTC_ALMA_GetSecond
2307   * @param  RTCx RTC Instance
2308   * @retval Value between Min_Data=0x00 and Max_Data=0x59
2309   */
LL_RTC_ALMA_GetSecond(const RTC_TypeDef * RTCx)2310 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSecond(const RTC_TypeDef *RTCx)
2311 {
2312   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU))) >> RTC_ALRMAR_SU_Pos);
2313 }
2314 
2315 /**
2316   * @brief  Set Alarm A Time (hour, minute and second) in BCD format
2317   * @rmtoll RTC_ALRMAR       PM            LL_RTC_ALMA_ConfigTime\n
2318   *         RTC_ALRMAR       HT            LL_RTC_ALMA_ConfigTime\n
2319   *         RTC_ALRMAR       HU            LL_RTC_ALMA_ConfigTime\n
2320   *         RTC_ALRMAR       MNT           LL_RTC_ALMA_ConfigTime\n
2321   *         RTC_ALRMAR       MNU           LL_RTC_ALMA_ConfigTime\n
2322   *         RTC_ALRMAR       ST            LL_RTC_ALMA_ConfigTime\n
2323   *         RTC_ALRMAR       SU            LL_RTC_ALMA_ConfigTime
2324   * @param  RTCx RTC Instance
2325   * @param  Format12_24 This parameter can be one of the following values:
2326   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
2327   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
2328   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2329   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
2330   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
2331   * @retval None
2332   */
LL_RTC_ALMA_ConfigTime(RTC_TypeDef * RTCx,uint32_t Format12_24,uint32_t Hours,uint32_t Minutes,uint32_t Seconds)2333 __STATIC_INLINE void LL_RTC_ALMA_ConfigTime(RTC_TypeDef *RTCx,
2334                                             uint32_t Format12_24,
2335                                             uint32_t Hours,
2336                                             uint32_t Minutes,
2337                                             uint32_t Seconds)
2338 {
2339   uint32_t temp;
2340 
2341   temp = Format12_24 | (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos))    | \
2342          (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)) | \
2343          (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos));
2344 
2345   MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_PM | RTC_ALRMAR_HT | RTC_ALRMAR_HU | RTC_ALRMAR_MNT | RTC_ALRMAR_MNU | \
2346              RTC_ALRMAR_ST | RTC_ALRMAR_SU, temp);
2347 }
2348 
2349 /**
2350   * @brief  Get Alarm B Time (hour, minute and second) in BCD format
2351   * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
2352   * are available to get independently each parameter.
2353   * @rmtoll RTC_ALRMAR       HT            LL_RTC_ALMA_GetTime\n
2354   *         RTC_ALRMAR       HU            LL_RTC_ALMA_GetTime\n
2355   *         RTC_ALRMAR       MNT           LL_RTC_ALMA_GetTime\n
2356   *         RTC_ALRMAR       MNU           LL_RTC_ALMA_GetTime\n
2357   *         RTC_ALRMAR       ST            LL_RTC_ALMA_GetTime\n
2358   *         RTC_ALRMAR       SU            LL_RTC_ALMA_GetTime
2359   * @param  RTCx RTC Instance
2360   * @retval Combination of hours, minutes and seconds.
2361   */
LL_RTC_ALMA_GetTime(const RTC_TypeDef * RTCx)2362 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTime(const RTC_TypeDef *RTCx)
2363 {
2364   return (uint32_t)((LL_RTC_ALMA_GetHour(RTCx) << RTC_OFFSET_HOUR) |
2365                     (LL_RTC_ALMA_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMA_GetSecond(RTCx));
2366 }
2367 
2368 /**
2369   * @brief  Set Alarm A Mask the most-significant bits starting at this bit
2370   * @note This register can be written only when ALRAE is reset in RTC_CR register,
2371   *       or in initialization mode.
2372   * @rmtoll RTC_ALRMASSR     MASKSS        LL_RTC_ALMA_SetSubSecondMask
2373   * @param  RTCx RTC Instance
2374   * @param  Mask If binary mode is none, Value between Min_Data=0x0 and Max_Data=0xF
2375   *              else Value between Min_Data=0x0 and Max_Data=0x3F
2376   * @retval None
2377   */
LL_RTC_ALMA_SetSubSecondMask(RTC_TypeDef * RTCx,uint32_t Mask)2378 __STATIC_INLINE void LL_RTC_ALMA_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
2379 {
2380   MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS, Mask << RTC_ALRMASSR_MASKSS_Pos);
2381 }
2382 
2383 /**
2384   * @brief  Get Alarm A Mask the most-significant bits starting at this bit
2385   * @rmtoll RTC_ALRMASSR     MASKSS        LL_RTC_ALMA_GetSubSecondMask
2386   * @param  RTCx RTC Instance
2387   * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0xF
2388   *         else Value between Min_Data=0x0 and Max_Data=0x3F
2389   */
LL_RTC_ALMA_GetSubSecondMask(const RTC_TypeDef * RTCx)2390 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecondMask(const RTC_TypeDef *RTCx)
2391 {
2392   return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS) >> RTC_ALRMASSR_MASKSS_Pos);
2393 }
2394 
2395 /**
2396   * @brief  Set Alarm A Binary mode auto clear
2397   * @note This register can be written only when ALRAE is reset in RTC_CR register,
2398   *       or in initialization mode.
2399   * @rmtoll RTC_ALRABINR     SSCLR        LL_RTC_ALMA_SetBinAutoClr
2400   * @param  RTCx RTC Instance
2401   * @param  BinaryAutoClr This parameter can be one of the following values:
2402   *         @arg @ref LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_NO
2403   *         @arg @ref LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_YES
2404   * @retval None
2405   */
LL_RTC_ALMA_SetBinAutoClr(RTC_TypeDef * RTCx,uint32_t BinaryAutoClr)2406 __STATIC_INLINE void LL_RTC_ALMA_SetBinAutoClr(RTC_TypeDef *RTCx, uint32_t BinaryAutoClr)
2407 {
2408   MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_SSCLR, BinaryAutoClr);
2409 }
2410 
2411 /**
2412   * @brief  Get Alarm A Binary mode auto clear
2413   * @rmtoll RTC_ALRABINR     SSCLR        LL_RTC_ALMA_GetBinAutoClr
2414   * @param  RTCx RTC Instance
2415   * @retval It can be one of the following values:
2416   *         @arg @ref LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_NO
2417   *         @arg @ref LL_RTC_ALMA_SUBSECONDBIN_AUTOCLR_YES
2418   */
LL_RTC_ALMA_GetBinAutoClr(const RTC_TypeDef * RTCx)2419 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetBinAutoClr(const RTC_TypeDef *RTCx)
2420 {
2421   return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_SSCLR));
2422 }
2423 
2424 /**
2425   * @brief  Set Alarm A Sub seconds value
2426   * @rmtoll RCT_ALRMASSR     SS            LL_RTC_ALMA_SetSubSecond
2427   * @param  RTCx RTC Instance
2428   * @param  Subsecond  If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
2429   *                    else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
2430   * @retval None
2431   */
LL_RTC_ALMA_SetSubSecond(RTC_TypeDef * RTCx,uint32_t Subsecond)2432 __STATIC_INLINE void LL_RTC_ALMA_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
2433 {
2434   MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_SS, Subsecond);
2435 }
2436 
2437 /**
2438   * @brief  Get Alarm A Sub seconds value
2439   * @rmtoll RCT_ALRMASSR     SS            LL_RTC_ALMA_GetSubSecond
2440   * @param  RTCx RTC Instance
2441   * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
2442   *         else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
2443   */
LL_RTC_ALMA_GetSubSecond(const RTC_TypeDef * RTCx)2444 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecond(const RTC_TypeDef *RTCx)
2445 {
2446   return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_SS));
2447 }
2448 
2449 /**
2450   * @}
2451   */
2452 
2453 /** @defgroup RTC_LL_EF_ALARMB ALARMB
2454   * @{
2455   */
2456 
2457 /**
2458   * @brief  Enable Alarm B
2459   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2460   * @rmtoll RTC_CR           ALRBE         LL_RTC_ALMB_Enable
2461   * @param  RTCx RTC Instance
2462   * @retval None
2463   */
LL_RTC_ALMB_Enable(RTC_TypeDef * RTCx)2464 __STATIC_INLINE void LL_RTC_ALMB_Enable(RTC_TypeDef *RTCx)
2465 {
2466   SET_BIT(RTCx->CR, RTC_CR_ALRBE);
2467 }
2468 
2469 /**
2470   * @brief  Disable Alarm B
2471   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2472   * @rmtoll RTC_CR           ALRBE         LL_RTC_ALMB_Disable
2473   * @param  RTCx RTC Instance
2474   * @retval None
2475   */
LL_RTC_ALMB_Disable(RTC_TypeDef * RTCx)2476 __STATIC_INLINE void LL_RTC_ALMB_Disable(RTC_TypeDef *RTCx)
2477 {
2478   CLEAR_BIT(RTCx->CR, RTC_CR_ALRBE);
2479 }
2480 
2481 /**
2482   * @brief  Specify the Alarm B masks.
2483   * @rmtoll RTC_ALRMBR       MSK4          LL_RTC_ALMB_SetMask\n
2484   *         RTC_ALRMBR       MSK3          LL_RTC_ALMB_SetMask\n
2485   *         RTC_ALRMBR       MSK2          LL_RTC_ALMB_SetMask\n
2486   *         RTC_ALRMBR       MSK1          LL_RTC_ALMB_SetMask
2487   * @param  RTCx RTC Instance
2488   * @param  Mask This parameter can be a combination of the following values:
2489   *         @arg @ref LL_RTC_ALMB_MASK_NONE
2490   *         @arg @ref LL_RTC_ALMB_MASK_DATEWEEKDAY
2491   *         @arg @ref LL_RTC_ALMB_MASK_HOURS
2492   *         @arg @ref LL_RTC_ALMB_MASK_MINUTES
2493   *         @arg @ref LL_RTC_ALMB_MASK_SECONDS
2494   *         @arg @ref LL_RTC_ALMB_MASK_ALL
2495   * @retval None
2496   */
LL_RTC_ALMB_SetMask(RTC_TypeDef * RTCx,uint32_t Mask)2497 __STATIC_INLINE void LL_RTC_ALMB_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
2498 {
2499   MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1, Mask);
2500 }
2501 
2502 /**
2503   * @brief  Get the Alarm B masks.
2504   * @rmtoll RTC_ALRMBR       MSK4          LL_RTC_ALMB_GetMask\n
2505   *         RTC_ALRMBR       MSK3          LL_RTC_ALMB_GetMask\n
2506   *         RTC_ALRMBR       MSK2          LL_RTC_ALMB_GetMask\n
2507   *         RTC_ALRMBR       MSK1          LL_RTC_ALMB_GetMask
2508   * @param  RTCx RTC Instance
2509   * @retval Returned value can be can be a combination of the following values:
2510   *         @arg @ref LL_RTC_ALMB_MASK_NONE
2511   *         @arg @ref LL_RTC_ALMB_MASK_DATEWEEKDAY
2512   *         @arg @ref LL_RTC_ALMB_MASK_HOURS
2513   *         @arg @ref LL_RTC_ALMB_MASK_MINUTES
2514   *         @arg @ref LL_RTC_ALMB_MASK_SECONDS
2515   *         @arg @ref LL_RTC_ALMB_MASK_ALL
2516   */
LL_RTC_ALMB_GetMask(const RTC_TypeDef * RTCx)2517 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetMask(const RTC_TypeDef *RTCx)
2518 {
2519   return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1));
2520 }
2521 
2522 /**
2523   * @brief  Enable AlarmB Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
2524   * @rmtoll RTC_ALRMBR       WDSEL         LL_RTC_ALMB_EnableWeekday
2525   * @param  RTCx RTC Instance
2526   * @retval None
2527   */
LL_RTC_ALMB_EnableWeekday(RTC_TypeDef * RTCx)2528 __STATIC_INLINE void LL_RTC_ALMB_EnableWeekday(RTC_TypeDef *RTCx)
2529 {
2530   SET_BIT(RTCx->ALRMBR, RTC_ALRMBR_WDSEL);
2531 }
2532 
2533 /**
2534   * @brief  Disable AlarmB Week day selection (DU[3:0] represents the date )
2535   * @rmtoll RTC_ALRMBR       WDSEL         LL_RTC_ALMB_DisableWeekday
2536   * @param  RTCx RTC Instance
2537   * @retval None
2538   */
LL_RTC_ALMB_DisableWeekday(RTC_TypeDef * RTCx)2539 __STATIC_INLINE void LL_RTC_ALMB_DisableWeekday(RTC_TypeDef *RTCx)
2540 {
2541   CLEAR_BIT(RTCx->ALRMBR, RTC_ALRMBR_WDSEL);
2542 }
2543 
2544 /**
2545   * @brief  Set ALARM B Day in BCD format
2546   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
2547   * @rmtoll RTC_ALRMBR       DT            LL_RTC_ALMB_SetDay\n
2548   *         RTC_ALRMBR       DU            LL_RTC_ALMB_SetDay
2549   * @param  RTCx RTC Instance
2550   * @param  Day Value between Min_Data=0x01 and Max_Data=0x31
2551   * @retval None
2552   */
LL_RTC_ALMB_SetDay(RTC_TypeDef * RTCx,uint32_t Day)2553 __STATIC_INLINE void LL_RTC_ALMB_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
2554 {
2555   MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_DT | RTC_ALRMBR_DU),
2556              (((Day & 0xF0U) << (RTC_ALRMBR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMBR_DU_Pos)));
2557 }
2558 
2559 /**
2560   * @brief  Get ALARM B Day in BCD format
2561   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
2562   * @rmtoll RTC_ALRMBR       DT            LL_RTC_ALMB_GetDay\n
2563   *         RTC_ALRMBR       DU            LL_RTC_ALMB_GetDay
2564   * @param  RTCx RTC Instance
2565   * @retval Value between Min_Data=0x01 and Max_Data=0x31
2566   */
LL_RTC_ALMB_GetDay(const RTC_TypeDef * RTCx)2567 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetDay(const RTC_TypeDef *RTCx)
2568 {
2569   return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_DT | RTC_ALRMBR_DU))) >> RTC_ALRMBR_DU_Pos);
2570 }
2571 
2572 /**
2573   * @brief  Set ALARM B Weekday
2574   * @rmtoll RTC_ALRMBR       DU            LL_RTC_ALMB_SetWeekDay
2575   * @param  RTCx RTC Instance
2576   * @param  WeekDay This parameter can be one of the following values:
2577   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
2578   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
2579   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
2580   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
2581   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
2582   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
2583   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
2584   * @retval None
2585   */
LL_RTC_ALMB_SetWeekDay(RTC_TypeDef * RTCx,uint32_t WeekDay)2586 __STATIC_INLINE void LL_RTC_ALMB_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
2587 {
2588   MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_DU, WeekDay << RTC_ALRMBR_DU_Pos);
2589 }
2590 
2591 /**
2592   * @brief  Get ALARM B Weekday
2593   * @rmtoll RTC_ALRMBR       DU            LL_RTC_ALMB_GetWeekDay
2594   * @param  RTCx RTC Instance
2595   * @retval Returned value can be one of the following values:
2596   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
2597   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
2598   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
2599   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
2600   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
2601   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
2602   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
2603   */
LL_RTC_ALMB_GetWeekDay(const RTC_TypeDef * RTCx)2604 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetWeekDay(const RTC_TypeDef *RTCx)
2605 {
2606   return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_DU) >> RTC_ALRMBR_DU_Pos);
2607 }
2608 
2609 /**
2610   * @brief  Set ALARM B time format (AM/24-hour or PM notation)
2611   * @rmtoll RTC_ALRMBR       PM            LL_RTC_ALMB_SetTimeFormat
2612   * @param  RTCx RTC Instance
2613   * @param  TimeFormat This parameter can be one of the following values:
2614   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
2615   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
2616   * @retval None
2617   */
LL_RTC_ALMB_SetTimeFormat(RTC_TypeDef * RTCx,uint32_t TimeFormat)2618 __STATIC_INLINE void LL_RTC_ALMB_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
2619 {
2620   MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_PM, TimeFormat);
2621 }
2622 
2623 /**
2624   * @brief  Get ALARM B time format (AM or PM notation)
2625   * @rmtoll RTC_ALRMBR       PM            LL_RTC_ALMB_GetTimeFormat
2626   * @param  RTCx RTC Instance
2627   * @retval Returned value can be one of the following values:
2628   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
2629   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
2630   */
LL_RTC_ALMB_GetTimeFormat(const RTC_TypeDef * RTCx)2631 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetTimeFormat(const RTC_TypeDef *RTCx)
2632 {
2633   return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_PM));
2634 }
2635 
2636 /**
2637   * @brief  Set ALARM B Hours in BCD format
2638   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
2639   * @rmtoll RTC_ALRMBR       HT            LL_RTC_ALMB_SetHour\n
2640   *         RTC_ALRMBR       HU            LL_RTC_ALMB_SetHour
2641   * @param  RTCx RTC Instance
2642   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2643   * @retval None
2644   */
LL_RTC_ALMB_SetHour(RTC_TypeDef * RTCx,uint32_t Hours)2645 __STATIC_INLINE void LL_RTC_ALMB_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
2646 {
2647   MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_HT | RTC_ALRMBR_HU),
2648              (((Hours & 0xF0U) << (RTC_ALRMBR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMBR_HU_Pos)));
2649 }
2650 
2651 /**
2652   * @brief  Get ALARM B Hours in BCD format
2653   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
2654   * @rmtoll RTC_ALRMBR       HT            LL_RTC_ALMB_GetHour\n
2655   *         RTC_ALRMBR       HU            LL_RTC_ALMB_GetHour
2656   * @param  RTCx RTC Instance
2657   * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2658   */
LL_RTC_ALMB_GetHour(const RTC_TypeDef * RTCx)2659 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetHour(const RTC_TypeDef *RTCx)
2660 {
2661   return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_HT | RTC_ALRMBR_HU))) >> RTC_ALRMBR_HU_Pos);
2662 }
2663 
2664 /**
2665   * @brief  Set ALARM B Minutes in BCD format
2666   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
2667   * @rmtoll RTC_ALRMBR       MNT           LL_RTC_ALMB_SetMinute\n
2668   *         RTC_ALRMBR       MNU           LL_RTC_ALMB_SetMinute
2669   * @param  RTCx RTC Instance
2670   * @param  Minutes between Min_Data=0x00 and Max_Data=0x59
2671   * @retval None
2672   */
LL_RTC_ALMB_SetMinute(RTC_TypeDef * RTCx,uint32_t Minutes)2673 __STATIC_INLINE void LL_RTC_ALMB_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
2674 {
2675   MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_MNT | RTC_ALRMBR_MNU),
2676              (((Minutes & 0xF0U) << (RTC_ALRMBR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMBR_MNU_Pos)));
2677 }
2678 
2679 /**
2680   * @brief  Get ALARM B Minutes in BCD format
2681   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
2682   * @rmtoll RTC_ALRMBR       MNT           LL_RTC_ALMB_GetMinute\n
2683   *         RTC_ALRMBR       MNU           LL_RTC_ALMB_GetMinute
2684   * @param  RTCx RTC Instance
2685   * @retval Value between Min_Data=0x00 and Max_Data=0x59
2686   */
LL_RTC_ALMB_GetMinute(const RTC_TypeDef * RTCx)2687 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetMinute(const RTC_TypeDef *RTCx)
2688 {
2689   return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_MNT | RTC_ALRMBR_MNU))) >> RTC_ALRMBR_MNU_Pos);
2690 }
2691 
2692 /**
2693   * @brief  Set ALARM B Seconds in BCD format
2694   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
2695   * @rmtoll RTC_ALRMBR       ST            LL_RTC_ALMB_SetSecond\n
2696   *         RTC_ALRMBR       SU            LL_RTC_ALMB_SetSecond
2697   * @param  RTCx RTC Instance
2698   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
2699   * @retval None
2700   */
LL_RTC_ALMB_SetSecond(RTC_TypeDef * RTCx,uint32_t Seconds)2701 __STATIC_INLINE void LL_RTC_ALMB_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
2702 {
2703   MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_ST | RTC_ALRMBR_SU),
2704              (((Seconds & 0xF0U) << (RTC_ALRMBR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMBR_SU_Pos)));
2705 }
2706 
2707 /**
2708   * @brief  Get ALARM B Seconds in BCD format
2709   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
2710   * @rmtoll RTC_ALRMBR       ST            LL_RTC_ALMB_GetSecond\n
2711   *         RTC_ALRMBR       SU            LL_RTC_ALMB_GetSecond
2712   * @param  RTCx RTC Instance
2713   * @retval Value between Min_Data=0x00 and Max_Data=0x59
2714   */
LL_RTC_ALMB_GetSecond(const RTC_TypeDef * RTCx)2715 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSecond(const RTC_TypeDef *RTCx)
2716 {
2717   return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_ST | RTC_ALRMBR_SU))) >> RTC_ALRMBR_SU_Pos);
2718 }
2719 
2720 /**
2721   * @brief  Set Alarm B Time (hour, minute and second) in BCD format
2722   * @rmtoll RTC_ALRMBR       PM            LL_RTC_ALMB_ConfigTime\n
2723   *         RTC_ALRMBR       HT            LL_RTC_ALMB_ConfigTime\n
2724   *         RTC_ALRMBR       HU            LL_RTC_ALMB_ConfigTime\n
2725   *         RTC_ALRMBR       MNT           LL_RTC_ALMB_ConfigTime\n
2726   *         RTC_ALRMBR       MNU           LL_RTC_ALMB_ConfigTime\n
2727   *         RTC_ALRMBR       ST            LL_RTC_ALMB_ConfigTime\n
2728   *         RTC_ALRMBR       SU            LL_RTC_ALMB_ConfigTime
2729   * @param  RTCx RTC Instance
2730   * @param  Format12_24 This parameter can be one of the following values:
2731   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
2732   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
2733   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2734   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
2735   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
2736   * @retval None
2737   */
LL_RTC_ALMB_ConfigTime(RTC_TypeDef * RTCx,uint32_t Format12_24,uint32_t Hours,uint32_t Minutes,uint32_t Seconds)2738 __STATIC_INLINE void LL_RTC_ALMB_ConfigTime(RTC_TypeDef *RTCx,
2739                                             uint32_t Format12_24,
2740                                             uint32_t Hours,
2741                                             uint32_t Minutes,
2742                                             uint32_t Seconds)
2743 {
2744   uint32_t temp;
2745 
2746   temp = Format12_24 | (((Hours & 0xF0U) << (RTC_ALRMBR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMBR_HU_Pos))    | \
2747          (((Minutes & 0xF0U) << (RTC_ALRMBR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMBR_MNU_Pos)) | \
2748          (((Seconds & 0xF0U) << (RTC_ALRMBR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMBR_SU_Pos));
2749 
2750   MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_PM | RTC_ALRMBR_HT | RTC_ALRMBR_HU | RTC_ALRMBR_MNT | RTC_ALRMBR_MNU | \
2751              RTC_ALRMBR_ST | RTC_ALRMBR_SU, temp);
2752 }
2753 
2754 /**
2755   * @brief  Get Alarm B Time (hour, minute and second) in BCD format
2756   * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
2757   * are available to get independently each parameter.
2758   * @rmtoll RTC_ALRMBR       HT            LL_RTC_ALMB_GetTime\n
2759   *         RTC_ALRMBR       HU            LL_RTC_ALMB_GetTime\n
2760   *         RTC_ALRMBR       MNT           LL_RTC_ALMB_GetTime\n
2761   *         RTC_ALRMBR       MNU           LL_RTC_ALMB_GetTime\n
2762   *         RTC_ALRMBR       ST            LL_RTC_ALMB_GetTime\n
2763   *         RTC_ALRMBR       SU            LL_RTC_ALMB_GetTime
2764   * @param  RTCx RTC Instance
2765   * @retval Combination of hours, minutes and seconds.
2766   */
LL_RTC_ALMB_GetTime(const RTC_TypeDef * RTCx)2767 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetTime(const RTC_TypeDef *RTCx)
2768 {
2769   return (uint32_t)((LL_RTC_ALMB_GetHour(RTCx) << RTC_OFFSET_HOUR) | \
2770                     (LL_RTC_ALMB_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMB_GetSecond(RTCx));
2771 }
2772 
2773 /**
2774   * @brief  Set Alarm B Mask the most-significant bits starting at this bit
2775   * @note This register can be written only when ALRBE is reset in RTC_CR register,
2776   *       or in initialization mode.
2777   * @rmtoll RTC_ALRMBSSR     MASKSS        LL_RTC_ALMB_SetSubSecondMask
2778   * @param  RTCx RTC Instance
2779   * @param  Mask If binary mode is none, Value between Min_Data=0x0 and Max_Data=0xF
2780   *              else Value between Min_Data=0x0 and Max_Data=0x3F
2781   * @retval None
2782   */
LL_RTC_ALMB_SetSubSecondMask(RTC_TypeDef * RTCx,uint32_t Mask)2783 __STATIC_INLINE void LL_RTC_ALMB_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
2784 {
2785   MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_MASKSS, Mask << RTC_ALRMBSSR_MASKSS_Pos);
2786 }
2787 
2788 /**
2789   * @brief  Get Alarm B Mask the most-significant bits starting at this bit
2790   * @rmtoll RTC_ALRMBSSR     MASKSS        LL_RTC_ALMB_GetSubSecondMask
2791   * @param  RTCx RTC Instance
2792   * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0xF
2793   *         else Value between Min_Data=0x0 and Max_Data=0x3F
2794   */
LL_RTC_ALMB_GetSubSecondMask(const RTC_TypeDef * RTCx)2795 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSubSecondMask(const RTC_TypeDef *RTCx)
2796 {
2797   return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_MASKSS)  >> RTC_ALRMBSSR_MASKSS_Pos);
2798 }
2799 
2800 /**
2801   * @brief  Set Alarm B Binary mode auto clear
2802   * @note This register can be written only when ALRBE is reset in RTC_CR register,
2803   *       or in initialization mode.
2804   * @rmtoll RTC_ALRBBINR     SSCLR        LL_RTC_ALMB_SetBinAutoClr
2805   * @param  RTCx RTC Instance
2806   * @param  BinaryAutoClr This parameter can be one of the following values:
2807   *         @arg @ref LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_NO
2808   *         @arg @ref LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_YES
2809   * @retval None
2810   */
LL_RTC_ALMB_SetBinAutoClr(RTC_TypeDef * RTCx,uint32_t BinaryAutoClr)2811 __STATIC_INLINE void LL_RTC_ALMB_SetBinAutoClr(RTC_TypeDef *RTCx, uint32_t BinaryAutoClr)
2812 {
2813   MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_SSCLR, BinaryAutoClr);
2814 }
2815 
2816 /**
2817   * @brief  Get Alarm B Binary mode auto clear
2818   * @rmtoll RTC_ALRBBINR     SSCLR        LL_RTC_ALMB_GetBinAutoClr
2819   * @param  RTCx RTC Instance
2820   * @retval It can be one of the following values:
2821   *         @arg @ref LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_NO
2822   *         @arg @ref LL_RTC_ALMB_SUBSECONDBIN_AUTOCLR_YES
2823   */
LL_RTC_ALMB_GetBinAutoClr(const RTC_TypeDef * RTCx)2824 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetBinAutoClr(const RTC_TypeDef *RTCx)
2825 {
2826   return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_SSCLR));
2827 }
2828 
2829 /**
2830   * @brief  Set Alarm B Sub seconds value
2831   * @rmtoll RTC_ALRMBSSR     SS            LL_RTC_ALMB_SetSubSecond
2832   * @param  RTCx RTC Instance
2833   * @param  Subsecond  If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
2834   *                    else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
2835   * @retval None
2836   */
LL_RTC_ALMB_SetSubSecond(RTC_TypeDef * RTCx,uint32_t Subsecond)2837 __STATIC_INLINE void LL_RTC_ALMB_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
2838 {
2839   MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_SS, Subsecond);
2840 }
2841 
2842 /**
2843   * @brief  Get Alarm B Sub seconds value
2844   * @rmtoll RTC_ALRMBSSR     SS            LL_RTC_ALMB_GetSubSecond
2845   * @param  RTCx RTC Instance
2846   * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
2847   *         else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
2848   */
LL_RTC_ALMB_GetSubSecond(const RTC_TypeDef * RTCx)2849 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSubSecond(const RTC_TypeDef *RTCx)
2850 {
2851   return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_SS));
2852 }
2853 
2854 /**
2855   * @}
2856   */
2857 
2858 /** @defgroup RTC_LL_EF_Timestamp Timestamp
2859   * @{
2860   */
2861 
2862 /**
2863   * @brief  Enable internal event timestamp
2864   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2865   * @rmtoll RTC_CR           ITSE          LL_RTC_TS_EnableInternalEvent
2866   * @param  RTCx RTC Instance
2867   * @retval None
2868   */
LL_RTC_TS_EnableInternalEvent(RTC_TypeDef * RTCx)2869 __STATIC_INLINE void LL_RTC_TS_EnableInternalEvent(RTC_TypeDef *RTCx)
2870 {
2871   SET_BIT(RTCx->CR, RTC_CR_ITSE);
2872 }
2873 
2874 /**
2875   * @brief  Disable internal event timestamp
2876   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2877   * @rmtoll RTC_CR           ITSE          LL_RTC_TS_DisableInternalEvent
2878   * @param  RTCx RTC Instance
2879   * @retval None
2880   */
LL_RTC_TS_DisableInternalEvent(RTC_TypeDef * RTCx)2881 __STATIC_INLINE void LL_RTC_TS_DisableInternalEvent(RTC_TypeDef *RTCx)
2882 {
2883   CLEAR_BIT(RTCx->CR, RTC_CR_ITSE);
2884 }
2885 
2886 /**
2887   * @brief  Enable Timestamp
2888   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2889   * @rmtoll RTC_CR           TSE           LL_RTC_TS_Enable
2890   * @param  RTCx RTC Instance
2891   * @retval None
2892   */
LL_RTC_TS_Enable(RTC_TypeDef * RTCx)2893 __STATIC_INLINE void LL_RTC_TS_Enable(RTC_TypeDef *RTCx)
2894 {
2895   SET_BIT(RTCx->CR, RTC_CR_TSE);
2896 }
2897 
2898 /**
2899   * @brief  Disable Timestamp
2900   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2901   * @rmtoll RTC_CR           TSE           LL_RTC_TS_Disable
2902   * @param  RTCx RTC Instance
2903   * @retval None
2904   */
LL_RTC_TS_Disable(RTC_TypeDef * RTCx)2905 __STATIC_INLINE void LL_RTC_TS_Disable(RTC_TypeDef *RTCx)
2906 {
2907   CLEAR_BIT(RTCx->CR, RTC_CR_TSE);
2908 }
2909 
2910 /**
2911   * @brief  Set Time-stamp event active edge
2912   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2913   * @note TSE must be reset when TSEDGE is changed to avoid unwanted TSF setting
2914   * @rmtoll RTC_CR           TSEDGE        LL_RTC_TS_SetActiveEdge
2915   * @param  RTCx RTC Instance
2916   * @param  Edge This parameter can be one of the following values:
2917   *         @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
2918   *         @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
2919   * @retval None
2920   */
LL_RTC_TS_SetActiveEdge(RTC_TypeDef * RTCx,uint32_t Edge)2921 __STATIC_INLINE void LL_RTC_TS_SetActiveEdge(RTC_TypeDef *RTCx, uint32_t Edge)
2922 {
2923   MODIFY_REG(RTCx->CR, RTC_CR_TSEDGE, Edge);
2924 }
2925 
2926 /**
2927   * @brief  Get Time-stamp event active edge
2928   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2929   * @rmtoll RTC_CR           TSEDGE        LL_RTC_TS_GetActiveEdge
2930   * @param  RTCx RTC Instance
2931   * @retval Returned value can be one of the following values:
2932   *         @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
2933   *         @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
2934   */
LL_RTC_TS_GetActiveEdge(const RTC_TypeDef * RTCx)2935 __STATIC_INLINE uint32_t LL_RTC_TS_GetActiveEdge(const RTC_TypeDef *RTCx)
2936 {
2937   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_TSEDGE));
2938 }
2939 
2940 /**
2941   * @brief  Get Timestamp AM/PM notation (AM or 24-hour format)
2942   * @rmtoll RTC_TSTR         PM            LL_RTC_TS_GetTimeFormat
2943   * @param  RTCx RTC Instance
2944   * @retval Returned value can be one of the following values:
2945   *         @arg @ref LL_RTC_TS_TIME_FORMAT_AM
2946   *         @arg @ref LL_RTC_TS_TIME_FORMAT_PM
2947   */
LL_RTC_TS_GetTimeFormat(const RTC_TypeDef * RTCx)2948 __STATIC_INLINE uint32_t LL_RTC_TS_GetTimeFormat(const RTC_TypeDef *RTCx)
2949 {
2950   return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_PM));
2951 }
2952 
2953 /**
2954   * @brief  Get Timestamp Hours in BCD format
2955   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
2956   * @rmtoll RTC_TSTR         HT            LL_RTC_TS_GetHour\n
2957   *         RTC_TSTR         HU            LL_RTC_TS_GetHour
2958   * @param  RTCx RTC Instance
2959   * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2960   */
LL_RTC_TS_GetHour(const RTC_TypeDef * RTCx)2961 __STATIC_INLINE uint32_t LL_RTC_TS_GetHour(const RTC_TypeDef *RTCx)
2962 {
2963   return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_HT | RTC_TSTR_HU) >> RTC_TSTR_HU_Pos);
2964 }
2965 
2966 /**
2967   * @brief  Get Timestamp Minutes in BCD format
2968   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
2969   * @rmtoll RTC_TSTR         MNT           LL_RTC_TS_GetMinute\n
2970   *         RTC_TSTR         MNU           LL_RTC_TS_GetMinute
2971   * @param  RTCx RTC Instance
2972   * @retval Value between Min_Data=0x00 and Max_Data=0x59
2973   */
LL_RTC_TS_GetMinute(const RTC_TypeDef * RTCx)2974 __STATIC_INLINE uint32_t LL_RTC_TS_GetMinute(const RTC_TypeDef *RTCx)
2975 {
2976   return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_MNT | RTC_TSTR_MNU) >> RTC_TSTR_MNU_Pos);
2977 }
2978 
2979 /**
2980   * @brief  Get Timestamp Seconds in BCD format
2981   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
2982   * @rmtoll RTC_TSTR         ST            LL_RTC_TS_GetSecond\n
2983   *         RTC_TSTR         SU            LL_RTC_TS_GetSecond
2984   * @param  RTCx RTC Instance
2985   * @retval Value between Min_Data=0x00 and Max_Data=0x59
2986   */
LL_RTC_TS_GetSecond(const RTC_TypeDef * RTCx)2987 __STATIC_INLINE uint32_t LL_RTC_TS_GetSecond(const RTC_TypeDef *RTCx)
2988 {
2989   return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_ST | RTC_TSTR_SU));
2990 }
2991 
2992 /**
2993   * @brief  Get Timestamp time (hour, minute and second) in BCD format
2994   * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
2995   * are available to get independently each parameter.
2996   * @rmtoll RTC_TSTR         HT            LL_RTC_TS_GetTime\n
2997   *         RTC_TSTR         HU            LL_RTC_TS_GetTime\n
2998   *         RTC_TSTR         MNT           LL_RTC_TS_GetTime\n
2999   *         RTC_TSTR         MNU           LL_RTC_TS_GetTime\n
3000   *         RTC_TSTR         ST            LL_RTC_TS_GetTime\n
3001   *         RTC_TSTR         SU            LL_RTC_TS_GetTime
3002   * @param  RTCx RTC Instance
3003   * @retval Combination of hours, minutes and seconds.
3004   */
LL_RTC_TS_GetTime(const RTC_TypeDef * RTCx)3005 __STATIC_INLINE uint32_t LL_RTC_TS_GetTime(const RTC_TypeDef *RTCx)
3006 {
3007   return (uint32_t)(READ_BIT(RTCx->TSTR,
3008                              RTC_TSTR_HT | RTC_TSTR_HU | RTC_TSTR_MNT | RTC_TSTR_MNU | RTC_TSTR_ST | RTC_TSTR_SU));
3009 }
3010 
3011 /**
3012   * @brief  Get Timestamp Week day
3013   * @rmtoll RTC_TSDR         WDU           LL_RTC_TS_GetWeekDay
3014   * @param  RTCx RTC Instance
3015   * @retval Returned value can be one of the following values:
3016   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
3017   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
3018   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
3019   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
3020   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
3021   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
3022   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
3023   */
LL_RTC_TS_GetWeekDay(const RTC_TypeDef * RTCx)3024 __STATIC_INLINE uint32_t LL_RTC_TS_GetWeekDay(const RTC_TypeDef *RTCx)
3025 {
3026   return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU) >> RTC_TSDR_WDU_Pos);
3027 }
3028 
3029 /**
3030   * @brief  Get Timestamp Month in BCD format
3031   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
3032   * @rmtoll RTC_TSDR         MT            LL_RTC_TS_GetMonth\n
3033   *         RTC_TSDR         MU            LL_RTC_TS_GetMonth
3034   * @param  RTCx RTC Instance
3035   * @retval Returned value can be one of the following values:
3036   *         @arg @ref LL_RTC_MONTH_JANUARY
3037   *         @arg @ref LL_RTC_MONTH_FEBRUARY
3038   *         @arg @ref LL_RTC_MONTH_MARCH
3039   *         @arg @ref LL_RTC_MONTH_APRIL
3040   *         @arg @ref LL_RTC_MONTH_MAY
3041   *         @arg @ref LL_RTC_MONTH_JUNE
3042   *         @arg @ref LL_RTC_MONTH_JULY
3043   *         @arg @ref LL_RTC_MONTH_AUGUST
3044   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
3045   *         @arg @ref LL_RTC_MONTH_OCTOBER
3046   *         @arg @ref LL_RTC_MONTH_NOVEMBER
3047   *         @arg @ref LL_RTC_MONTH_DECEMBER
3048   */
LL_RTC_TS_GetMonth(const RTC_TypeDef * RTCx)3049 __STATIC_INLINE uint32_t LL_RTC_TS_GetMonth(const RTC_TypeDef *RTCx)
3050 {
3051   return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_MT | RTC_TSDR_MU) >> RTC_TSDR_MU_Pos);
3052 }
3053 
3054 /**
3055   * @brief  Get Timestamp Day in BCD format
3056   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
3057   * @rmtoll RTC_TSDR         DT            LL_RTC_TS_GetDay\n
3058   *         RTC_TSDR         DU            LL_RTC_TS_GetDay
3059   * @param  RTCx RTC Instance
3060   * @retval Value between Min_Data=0x01 and Max_Data=0x31
3061   */
LL_RTC_TS_GetDay(const RTC_TypeDef * RTCx)3062 __STATIC_INLINE uint32_t LL_RTC_TS_GetDay(const RTC_TypeDef *RTCx)
3063 {
3064   return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_DT | RTC_TSDR_DU));
3065 }
3066 
3067 /**
3068   * @brief  Get Timestamp date (WeekDay, Day and Month) in BCD format
3069   * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_MONTH,
3070   * and __LL_RTC_GET_DAY are available to get independently each parameter.
3071   * @rmtoll RTC_TSDR         WDU           LL_RTC_TS_GetDate\n
3072   *         RTC_TSDR         MT            LL_RTC_TS_GetDate\n
3073   *         RTC_TSDR         MU            LL_RTC_TS_GetDate\n
3074   *         RTC_TSDR         DT            LL_RTC_TS_GetDate\n
3075   *         RTC_TSDR         DU            LL_RTC_TS_GetDate
3076   * @param  RTCx RTC Instance
3077   * @retval Combination of Weekday, Day and Month
3078   */
LL_RTC_TS_GetDate(const RTC_TypeDef * RTCx)3079 __STATIC_INLINE uint32_t LL_RTC_TS_GetDate(const RTC_TypeDef *RTCx)
3080 {
3081   return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU | RTC_TSDR_MT | RTC_TSDR_MU | RTC_TSDR_DT | RTC_TSDR_DU));
3082 }
3083 
3084 /**
3085   * @brief  Get time-stamp sub second value
3086   * @rmtoll RTC_TSDR         SS            LL_RTC_TS_GetSubSecond
3087   * @param  RTCx RTC Instance
3088   * @retval If binary mode is none, Value between Min_Data=0x0 and Max_Data=0x7FFF
3089   *         else Value between Min_Data=0x0 and Max_Data=0xFFFFFFFF
3090   */
LL_RTC_TS_GetSubSecond(const RTC_TypeDef * RTCx)3091 __STATIC_INLINE uint32_t LL_RTC_TS_GetSubSecond(const RTC_TypeDef *RTCx)
3092 {
3093   return (uint32_t)(READ_BIT(RTCx->TSSSR, RTC_TSSSR_SS));
3094 }
3095 
3096 /**
3097   * @brief  Activate timestamp on tamper detection event
3098   * @rmtoll RTC_CR       TAMPTS        LL_RTC_TS_EnableOnTamper
3099   * @param  RTCx RTC Instance
3100   * @retval None
3101   */
LL_RTC_TS_EnableOnTamper(RTC_TypeDef * RTCx)3102 __STATIC_INLINE void LL_RTC_TS_EnableOnTamper(RTC_TypeDef *RTCx)
3103 {
3104   SET_BIT(RTCx->CR, RTC_CR_TAMPTS);
3105 }
3106 
3107 /**
3108   * @brief  Disable timestamp on tamper detection event
3109   * @rmtoll RTC_CR       TAMPTS        LL_RTC_TS_DisableOnTamper
3110   * @param  RTCx RTC Instance
3111   * @retval None
3112   */
LL_RTC_TS_DisableOnTamper(RTC_TypeDef * RTCx)3113 __STATIC_INLINE void LL_RTC_TS_DisableOnTamper(RTC_TypeDef *RTCx)
3114 {
3115   CLEAR_BIT(RTCx->CR, RTC_CR_TAMPTS);
3116 }
3117 
3118 
3119 /**
3120   * @}
3121   */
3122 
3123 /** @defgroup RTC_LL_EF_Tamper Tamper
3124   * @{
3125   */
3126 
3127 /**
3128   * @brief  Enable TAMPx input detection
3129   * @rmtoll TAMP_CR1       TAMP1E        LL_RTC_TAMPER_Enable\n
3130   *         TAMP_CR1       TAMP2E...     LL_RTC_TAMPER_Enable\n
3131   * @param  RTCx RTC Instance
3132   * @param  Tamper This parameter can be a combination of the following values:
3133   *         @arg @ref RTC_LL_EC_TAMPER
3134   *
3135   * @retval None
3136   */
LL_RTC_TAMPER_Enable(const RTC_TypeDef * RTCx,uint32_t Tamper)3137 __STATIC_INLINE void LL_RTC_TAMPER_Enable(const RTC_TypeDef *RTCx, uint32_t Tamper)
3138 {
3139   UNUSED(RTCx);
3140   SET_BIT(TAMP->CR1, Tamper);
3141 }
3142 
3143 /**
3144   * @brief  Clear TAMPx input detection
3145   * @rmtoll TAMP_CR1       TAMP1E         LL_RTC_TAMPER_Disable\n
3146   *         TAMP_CR1       TAMP2E...      LL_RTC_TAMPER_Disable
3147   * @param  RTCx RTC Instance
3148   * @param  Tamper This parameter can be a combination of the following values:
3149   *         @arg @ref RTC_LL_EC_TAMPER
3150   *
3151   * @retval None
3152   */
LL_RTC_TAMPER_Disable(const RTC_TypeDef * RTCx,uint32_t Tamper)3153 __STATIC_INLINE void LL_RTC_TAMPER_Disable(const RTC_TypeDef *RTCx, uint32_t Tamper)
3154 {
3155   UNUSED(RTCx);
3156   CLEAR_BIT(TAMP->CR1, Tamper);
3157 }
3158 
3159 /**
3160   * @brief  Enable Tamper mask flag
3161   * @note Associated Tamper IT must not enabled when tamper mask is set.
3162   * @rmtoll TAMP_CR2       TAMP1MF       LL_RTC_TAMPER_EnableMask\n
3163   *         TAMP_CR2       TAMP2MF...    LL_RTC_TAMPER_EnableMask
3164   * @param  RTCx RTC Instance
3165   * @param  Mask This parameter can be a combination of the following values:
3166   *         @arg @ref RTC_LL_EC_TAMPER_MASK
3167   *
3168   * @retval None
3169   */
LL_RTC_TAMPER_EnableMask(const RTC_TypeDef * RTCx,uint32_t Mask)3170 __STATIC_INLINE void LL_RTC_TAMPER_EnableMask(const RTC_TypeDef *RTCx, uint32_t Mask)
3171 {
3172   UNUSED(RTCx);
3173   SET_BIT(TAMP->CR2, Mask);
3174 }
3175 
3176 /**
3177   * @brief  Disable Tamper mask flag
3178   * @rmtoll TAMP_CR2       TAMP1MF       LL_RTC_TAMPER_DisableMask\n
3179   *         TAMP_CR2       TAMP2MF...    LL_RTC_TAMPER_DisableMask
3180   * @param  RTCx RTC Instance
3181   * @param  Mask This parameter can be a combination of the following values:
3182   *         @arg @ref RTC_LL_EC_TAMPER_MASK
3183   *
3184   * @retval None
3185   */
LL_RTC_TAMPER_DisableMask(const RTC_TypeDef * RTCx,uint32_t Mask)3186 __STATIC_INLINE void LL_RTC_TAMPER_DisableMask(const RTC_TypeDef *RTCx, uint32_t Mask)
3187 {
3188   UNUSED(RTCx);
3189   CLEAR_BIT(TAMP->CR2, Mask);
3190 }
3191 
3192 /**
3193   * @brief  Enable backup register erase after Tamper event detection
3194   * @rmtoll TAMP_CR2       TAMP1POM     LL_RTC_TAMPER_EnableEraseBKP\n
3195   *         TAMP_CR2       TAMP2POM...  LL_RTC_TAMPER_EnableEraseBKP
3196   * @param  RTCx RTC Instance
3197   * @param  Tamper This parameter can be a combination of the following values:
3198   *         @arg @ref RTC_LL_EC_TAMPER_NOERASE
3199   *
3200   * @retval None
3201   */
LL_RTC_TAMPER_EnableEraseBKP(const RTC_TypeDef * RTCx,uint32_t Tamper)3202 __STATIC_INLINE void LL_RTC_TAMPER_EnableEraseBKP(const RTC_TypeDef *RTCx, uint32_t Tamper)
3203 {
3204   UNUSED(RTCx);
3205   CLEAR_BIT(TAMP->CR2, Tamper);
3206 }
3207 
3208 /**
3209   * @brief  Disable backup register erase after Tamper event detection
3210   * @rmtoll TAMP_CR2       TAMP1POM     LL_RTC_TAMPER_DisableEraseBKP\n
3211   *         TAMP_CR2       TAMP2POM...  LL_RTC_TAMPER_DisableEraseBKP
3212   * @param  RTCx RTC Instance
3213   * @param  Tamper This parameter can be a combination of the following values:
3214   *         @arg @ref RTC_LL_EC_TAMPER_NOERASE
3215   *
3216   * @retval None
3217   */
LL_RTC_TAMPER_DisableEraseBKP(const RTC_TypeDef * RTCx,uint32_t Tamper)3218 __STATIC_INLINE void LL_RTC_TAMPER_DisableEraseBKP(const RTC_TypeDef *RTCx, uint32_t Tamper)
3219 {
3220   UNUSED(RTCx);
3221   SET_BIT(TAMP->CR2, Tamper);
3222 }
3223 
3224 /**
3225   * @brief  Disable RTC_TAMPx pull-up disable (Disable precharge of RTC_TAMPx pins)
3226   * @rmtoll TAMP_FLTCR       TAMPPUDIS     LL_RTC_TAMPER_DisablePullUp
3227   * @param  RTCx RTC Instance
3228   * @retval None
3229   */
LL_RTC_TAMPER_DisablePullUp(const RTC_TypeDef * RTCx)3230 __STATIC_INLINE void LL_RTC_TAMPER_DisablePullUp(const RTC_TypeDef *RTCx)
3231 {
3232   UNUSED(RTCx);
3233   SET_BIT(TAMP->FLTCR, TAMP_FLTCR_TAMPPUDIS);
3234 }
3235 
3236 /**
3237   * @brief  Enable RTC_TAMPx pull-up disable ( Precharge RTC_TAMPx pins before sampling)
3238   * @rmtoll TAMP_FLTCR       TAMPPUDIS     LL_RTC_TAMPER_EnablePullUp
3239   * @param  RTCx RTC Instance
3240   * @retval None
3241   */
LL_RTC_TAMPER_EnablePullUp(const RTC_TypeDef * RTCx)3242 __STATIC_INLINE void LL_RTC_TAMPER_EnablePullUp(const RTC_TypeDef *RTCx)
3243 {
3244   UNUSED(RTCx);
3245   CLEAR_BIT(TAMP->FLTCR, TAMP_FLTCR_TAMPPUDIS);
3246 }
3247 
3248 /**
3249   * @brief  Set RTC_TAMPx precharge duration
3250   * @rmtoll TAMP_FLTCR       TAMPPRCH      LL_RTC_TAMPER_SetPrecharge
3251   * @param  RTCx RTC Instance
3252   * @param  Duration This parameter can be one of the following values:
3253   *         @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
3254   *         @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
3255   *         @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
3256   *         @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
3257   * @retval None
3258   */
LL_RTC_TAMPER_SetPrecharge(const RTC_TypeDef * RTCx,uint32_t Duration)3259 __STATIC_INLINE void LL_RTC_TAMPER_SetPrecharge(const RTC_TypeDef *RTCx, uint32_t Duration)
3260 {
3261   UNUSED(RTCx);
3262   MODIFY_REG(TAMP->FLTCR, TAMP_FLTCR_TAMPPRCH, Duration);
3263 }
3264 
3265 /**
3266   * @brief  Get RTC_TAMPx precharge duration
3267   * @rmtoll TAMP_FLTCR       TAMPPRCH      LL_RTC_TAMPER_GetPrecharge
3268   * @param  RTCx RTC Instance
3269   * @retval Returned value can be one of the following values:
3270   *         @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
3271   *         @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
3272   *         @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
3273   *         @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
3274   */
LL_RTC_TAMPER_GetPrecharge(const RTC_TypeDef * RTCx)3275 __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetPrecharge(const RTC_TypeDef *RTCx)
3276 {
3277   UNUSED(RTCx);
3278   return (uint32_t)(READ_BIT(TAMP->FLTCR, TAMP_FLTCR_TAMPPRCH));
3279 }
3280 
3281 /**
3282   * @brief  Set RTC_TAMPx filter count
3283   * @rmtoll TAMP_FLTCR       TAMPFLT       LL_RTC_TAMPER_SetFilterCount
3284   * @param  RTCx RTC Instance
3285   * @param  FilterCount This parameter can be one of the following values:
3286   *         @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
3287   *         @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
3288   *         @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
3289   *         @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
3290   * @retval None
3291   */
LL_RTC_TAMPER_SetFilterCount(const RTC_TypeDef * RTCx,uint32_t FilterCount)3292 __STATIC_INLINE void LL_RTC_TAMPER_SetFilterCount(const RTC_TypeDef *RTCx, uint32_t FilterCount)
3293 {
3294   UNUSED(RTCx);
3295   MODIFY_REG(TAMP->FLTCR, TAMP_FLTCR_TAMPFLT, FilterCount);
3296 }
3297 
3298 /**
3299   * @brief  Get RTC_TAMPx filter count
3300   * @rmtoll TAMP_FLTCR       TAMPFLT       LL_RTC_TAMPER_GetFilterCount
3301   * @param  RTCx RTC Instance
3302   * @retval Returned value can be one of the following values:
3303   *         @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
3304   *         @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
3305   *         @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
3306   *         @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
3307   */
LL_RTC_TAMPER_GetFilterCount(const RTC_TypeDef * RTCx)3308 __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetFilterCount(const RTC_TypeDef *RTCx)
3309 {
3310   UNUSED(RTCx);
3311   return (uint32_t)(READ_BIT(TAMP->FLTCR, TAMP_FLTCR_TAMPFLT));
3312 }
3313 
3314 /**
3315   * @brief  Set Tamper sampling frequency
3316   * @rmtoll TAMP_FLTCR       TAMPFREQ      LL_RTC_TAMPER_SetSamplingFreq
3317   * @param  RTCx RTC Instance
3318   * @param  SamplingFreq This parameter can be one of the following values:
3319   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
3320   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
3321   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
3322   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
3323   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
3324   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
3325   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
3326   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
3327   * @retval None
3328   */
LL_RTC_TAMPER_SetSamplingFreq(const RTC_TypeDef * RTCx,uint32_t SamplingFreq)3329 __STATIC_INLINE void LL_RTC_TAMPER_SetSamplingFreq(const RTC_TypeDef *RTCx, uint32_t SamplingFreq)
3330 {
3331   UNUSED(RTCx);
3332   MODIFY_REG(TAMP->FLTCR, TAMP_FLTCR_TAMPFREQ, SamplingFreq);
3333 }
3334 
3335 /**
3336   * @brief  Get Tamper sampling frequency
3337   * @rmtoll TAMP_FLTCR       TAMPFREQ      LL_RTC_TAMPER_GetSamplingFreq
3338   * @param  RTCx RTC Instance
3339   * @retval Returned value can be one of the following values:
3340   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
3341   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
3342   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
3343   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
3344   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
3345   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
3346   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
3347   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
3348   */
LL_RTC_TAMPER_GetSamplingFreq(const RTC_TypeDef * RTCx)3349 __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetSamplingFreq(const RTC_TypeDef *RTCx)
3350 {
3351   UNUSED(RTCx);
3352   return (uint32_t)(READ_BIT(TAMP->FLTCR, TAMP_FLTCR_TAMPFREQ));
3353 }
3354 
3355 /**
3356   * @brief  Enable Active level for Tamper input
3357   * @rmtoll TAMP_CR2       TAMP1TRG       LL_RTC_TAMPER_EnableActiveLevel\n
3358   *         TAMP_CR2       TAMP2TRG       LL_RTC_TAMPER_EnableActiveLevel\n
3359   *         TAMP_CR2       TAMPxTRG       LL_RTC_TAMPER_EnableActiveLevel\n
3360   * @param  RTCx RTC Instance
3361   * @param  Tamper This parameter can be a combination of the following values:
3362   *         @arg @ref RTC_LL_EC_TAMPER_ACTIVELEVEL
3363   *
3364   * @retval None
3365   */
LL_RTC_TAMPER_EnableActiveLevel(const RTC_TypeDef * RTCx,uint32_t Tamper)3366 __STATIC_INLINE void LL_RTC_TAMPER_EnableActiveLevel(const RTC_TypeDef *RTCx, uint32_t Tamper)
3367 {
3368   UNUSED(RTCx);
3369   SET_BIT(TAMP->CR2, Tamper);
3370 }
3371 
3372 /**
3373   * @brief  Disable Active level for Tamper input
3374   * @rmtoll TAMP_CR2       TAMP1TRG      LL_RTC_TAMPER_DisableActiveLevel\n
3375   *         TAMP_CR2       TAMP2TRG      LL_RTC_TAMPER_DisableActiveLevel\n
3376   *         TAMP_CR2       TAMPxTRG      LL_RTC_TAMPER_DisableActiveLevel\n
3377   * @param  RTCx RTC Instance
3378   * @param  Tamper This parameter can be a combination of the following values:
3379   *         @arg @ref RTC_LL_EC_TAMPER_ACTIVELEVEL
3380   *
3381   * @retval None
3382   */
LL_RTC_TAMPER_DisableActiveLevel(const RTC_TypeDef * RTCx,uint32_t Tamper)3383 __STATIC_INLINE void LL_RTC_TAMPER_DisableActiveLevel(const RTC_TypeDef *RTCx, uint32_t Tamper)
3384 {
3385   UNUSED(RTCx);
3386   CLEAR_BIT(TAMP->CR2, Tamper);
3387 }
3388 
3389 /**
3390   * @}
3391   */
3392 
3393 /** @defgroup RTC_LL_EF_Internal_Tamper Internal Tamper
3394   * @{
3395   */
3396 
3397 /**
3398   * @brief  Enable internal tamper detection.
3399   * @rmtoll TAMP_CR1       ITAMP1E       LL_RTC_TAMPER_ITAMP_Enable\n
3400   *         TAMP_CR1       ITAMP2E       LL_RTC_TAMPER_ITAMP_Enable\n
3401   *         TAMP_CR1       ITAMPxE       LL_RTC_TAMPER_ITAMP_Enable
3402   * @param  RTCx RTC Instance
3403   * @param  InternalTamper This parameter can be a combination of the following values:
3404   *         @arg @ref RTC_LL_EC_INTERNAL
3405   *
3406   * @retval None
3407   */
LL_RTC_TAMPER_ITAMP_Enable(const RTC_TypeDef * RTCx,uint32_t InternalTamper)3408 __STATIC_INLINE void LL_RTC_TAMPER_ITAMP_Enable(const RTC_TypeDef *RTCx, uint32_t InternalTamper)
3409 {
3410   UNUSED(RTCx);
3411   SET_BIT(TAMP->CR1, InternalTamper);
3412 }
3413 
3414 /**
3415   * @brief  Disable internal tamper detection.
3416   * @rmtoll TAMP_CR1       ITAMP1E       LL_RTC_TAMPER_ITAMP_Disable\n
3417   *         TAMP_CR1       ITAMP2E       LL_RTC_TAMPER_ITAMP_Disable\n
3418   *         TAMP_CR1       ITAMPxE       LL_RTC_TAMPER_ITAMP_Disable\n
3419   * @param  RTCx RTC Instance
3420   * @param  InternalTamper This parameter can be a combination of the following values:
3421   *         @arg @ref RTC_LL_EC_INTERNAL
3422   *
3423   * @retval None
3424   */
LL_RTC_TAMPER_ITAMP_Disable(const RTC_TypeDef * RTCx,uint32_t InternalTamper)3425 __STATIC_INLINE void LL_RTC_TAMPER_ITAMP_Disable(const RTC_TypeDef *RTCx, uint32_t InternalTamper)
3426 {
3427   UNUSED(RTCx);
3428   CLEAR_BIT(TAMP->CR1, InternalTamper);
3429 }
3430 
3431 /**
3432   * @brief  Enable backup register erase after internal tamper event detection
3433   * @rmtoll TAMP_CR3       ITAMP1POM     LL_RTC_TAMPER_ITAMP_EnableEraseBKP
3434   *         TAMP_CR3       ITAMP2POM...  LL_RTC_TAMPER_ITAMP_EnableEraseBKP
3435   * @param  RTCx RTC Instance
3436   * @param  InternalTamper This parameter can be a combination of the following values:
3437   *         @arg @ref RTC_LL_EC_ITAMPER_NOERASE
3438   *
3439   * @retval None
3440   */
LL_RTC_TAMPER_ITAMP_EnableEraseBKP(const RTC_TypeDef * RTCx,uint32_t InternalTamper)3441 __STATIC_INLINE void LL_RTC_TAMPER_ITAMP_EnableEraseBKP(const RTC_TypeDef *RTCx, uint32_t InternalTamper)
3442 {
3443   UNUSED(RTCx);
3444   CLEAR_BIT(TAMP->CR3, InternalTamper);
3445 }
3446 
3447 /**
3448   * @brief  Disable backup register erase after internal tamper event detection
3449   * @rmtoll TAMP_CR3       ITAMP1POM     LL_RTC_TAMPER_ITAMP_DisableEraseBKP
3450   *         TAMP_CR3       ITAMP2POM...  LL_RTC_TAMPER_ITAMP_DisableEraseBKP
3451   * @param  RTCx RTC Instance
3452   * @param  InternalTamper This parameter can be a combination of the following values:
3453   *         @arg @ref RTC_LL_EC_ITAMPER_NOERASE
3454   *
3455   * @retval None
3456   */
LL_RTC_TAMPER_ITAMP_DisableEraseBKP(const RTC_TypeDef * RTCx,uint32_t InternalTamper)3457 __STATIC_INLINE void LL_RTC_TAMPER_ITAMP_DisableEraseBKP(const RTC_TypeDef *RTCx, uint32_t InternalTamper)
3458 {
3459   UNUSED(RTCx);
3460   SET_BIT(TAMP->CR3, InternalTamper);
3461 }
3462 
3463 /**
3464   * @}
3465   */
3466 
3467 /** @defgroup RTC_LL_EF_Active_Tamper Active Tamper
3468   * @{
3469   */
3470 /**
3471   * @brief  Enable tamper active mode.
3472   * @rmtoll TAMP_ATCR1     TAMP1AM       LL_RTC_TAMPER_ATAMP_EnableActiveMode\n
3473   * @rmtoll TAMP_ATCR1     TAMP2AM       LL_RTC_TAMPER_ATAMP_EnableActiveMode\n
3474   * @rmtoll TAMP_ATCR1     TAMPxAM       LL_RTC_TAMPER_ATAMP_EnableActiveMode\n
3475   * @param  Tamper to configure as active. This parameter can be a combination of the following values:
3476   *         @arg @ref RTC_LL_EC_ACTIVE_MODE
3477   *
3478   * @retval None
3479   */
LL_RTC_TAMPER_ATAMP_EnableActiveMode(uint32_t Tamper)3480 __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_EnableActiveMode(uint32_t Tamper)
3481 {
3482   SET_BIT(TAMP->ATCR1, Tamper);
3483 }
3484 
3485 /**
3486   * @brief  Disable tamper active mode.
3487   * @rmtoll TAMP_ATCR1     TAMP1AM       LL_RTC_TAMPER_ATAMP_DisableActiveMode\n
3488   * @rmtoll TAMP_ATCR1     TAMP2AM       LL_RTC_TAMPER_ATAMP_DisableActiveMode\n
3489   * @rmtoll TAMP_ATCR1     TAMPxAM       LL_RTC_TAMPER_ATAMP_DisableActiveMode\n
3490   * @param  Tamper to configure as active. This parameter can be a combination of the following values:
3491   *         @arg @ref RTC_LL_EC_ACTIVE_MODE
3492   *
3493   * @retval None
3494   */
LL_RTC_TAMPER_ATAMP_DisableActiveMode(uint32_t Tamper)3495 __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_DisableActiveMode(uint32_t Tamper)
3496 {
3497   CLEAR_BIT(TAMP->ATCR1, Tamper);
3498 }
3499 
3500 /**
3501   * @brief  Enable active tamper filter.
3502   * @rmtoll TAMP_ATCR1     FLTEN         LL_RTC_TAMPER_ATAMP_EnableFilter\n
3503   * @retval None
3504   */
LL_RTC_TAMPER_ATAMP_EnableFilter(void)3505 __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_EnableFilter(void)
3506 {
3507   SET_BIT(TAMP->ATCR1, TAMP_ATCR1_FLTEN);
3508 }
3509 
3510 /**
3511   * @brief  Disable active tamper filter.
3512   * @rmtoll TAMP_ATCR1     FLTEN         LL_RTC_TAMPER_ATAMP_DisableFilter\n
3513   * @retval None
3514   */
LL_RTC_TAMPER_ATAMP_DisableFilter(void)3515 __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_DisableFilter(void)
3516 {
3517   CLEAR_BIT(TAMP->ATCR1, TAMP_ATCR1_FLTEN);
3518 }
3519 
3520 /**
3521   * @brief  Set Active tamper output change period.
3522   * @rmtoll TAMP_ATCR1     ATPER         LL_RTC_TAMPER_ATAMP_SetOutputChangePeriod\n
3523   * @param  ActiveOutputChangePeriod This parameter can be a value from 0 to 7
3524   * @retval None
3525   */
LL_RTC_TAMPER_ATAMP_SetOutputChangePeriod(uint32_t ActiveOutputChangePeriod)3526 __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_SetOutputChangePeriod(uint32_t ActiveOutputChangePeriod)
3527 {
3528   MODIFY_REG(TAMP->ATCR1, TAMP_ATCR1_ATPER, (ActiveOutputChangePeriod << TAMP_ATCR1_ATPER_Pos));
3529 }
3530 
3531 /**
3532   * @brief  Get Active tamper output change period.
3533   * @rmtoll TAMP_ATCR1     ATPER         LL_RTC_TAMPER_ATAMP_GetOutputChangePeriod\n
3534   * @retval Output change period. This parameter can be a value from 0 to 7.
3535   */
LL_RTC_TAMPER_ATAMP_GetOutputChangePeriod(void)3536 __STATIC_INLINE uint32_t LL_RTC_TAMPER_ATAMP_GetOutputChangePeriod(void)
3537 {
3538   return (READ_BIT(TAMP->ATCR1, TAMP_ATCR1_ATPER) >> TAMP_ATCR1_ATPER_Pos);
3539 }
3540 
3541 /**
3542   * @brief  Set Active tamper asynchronous prescaler clock selection.
3543   * @rmtoll TAMP_ATCR1     ATCKSEL       LL_RTC_TAMPER_ATAMP_SetAsyncPrescaler\n
3544   * @param  ActiveAsynvPrescaler Specifies the Active Tamper asynchronous Prescaler clock.
3545             This parameter can be a value of the following values:
3546   *         @arg @ref RTC_LL_EC_ACTIVE_ASYNC_PRESCALER
3547   * @retval None
3548   */
LL_RTC_TAMPER_ATAMP_SetAsyncPrescaler(uint32_t ActiveAsynvPrescaler)3549 __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_SetAsyncPrescaler(uint32_t ActiveAsynvPrescaler)
3550 {
3551   MODIFY_REG(TAMP->ATCR1, TAMP_ATCR1_ATCKSEL, ActiveAsynvPrescaler);
3552 }
3553 
3554 /**
3555   * @brief  Get Active tamper asynchronous prescaler clock selection.
3556   * @rmtoll TAMP_ATCR1     ATCKSEL       LL_RTC_TAMPER_ATAMP_GetAsyncPrescaler\n
3557   * @retval One of @arg @ref RTC_LL_EC_ACTIVE_ASYNC_PRESCALER
3558   */
LL_RTC_TAMPER_ATAMP_GetAsyncPrescaler(void)3559 __STATIC_INLINE uint32_t LL_RTC_TAMPER_ATAMP_GetAsyncPrescaler(void)
3560 {
3561   return (READ_BIT(TAMP->ATCR1, TAMP_ATCR1_ATCKSEL));
3562 }
3563 
3564 /**
3565   * @brief  Enable active tamper output sharing.
3566   * @rmtoll TAMP_ATCR1     ATOSHARE      LL_RTC_TAMPER_ATAMP_EnableOutputSharing\n
3567   * @retval None
3568   */
LL_RTC_TAMPER_ATAMP_EnableOutputSharing(void)3569 __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_EnableOutputSharing(void)
3570 {
3571   SET_BIT(TAMP->ATCR1, TAMP_ATCR1_ATOSHARE);
3572 }
3573 
3574 /**
3575   * @brief  Disable active tamper output sharing.
3576   * @rmtoll TAMP_ATCR1     ATOSHARE      LL_RTC_TAMPER_ATAMP_DisableOutputSharing\n
3577   * @retval None
3578   */
LL_RTC_TAMPER_ATAMP_DisableOutputSharing(void)3579 __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_DisableOutputSharing(void)
3580 {
3581   CLEAR_BIT(TAMP->ATCR1, TAMP_ATCR1_ATOSHARE);
3582 }
3583 
3584 /**
3585   * @brief  Set Active tamper shared output selection.
3586   * @rmtoll TAMP_ATCR2     ATOSELx       LL_RTC_TAMPER_ATAMP_SetSharedOuputSelection\n
3587   * @param  OutputSelection Specifies all the output selection of the Active Tamper.
3588             This parameter is a combinasation of the following values:
3589   *         One of @arg @ref RTC_LL_EC_ACTIVE_OUTPUT_SELECTION
3590   * @retval None
3591   */
LL_RTC_TAMPER_ATAMP_SetSharedOuputSelection(uint32_t OutputSelection)3592 __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_SetSharedOuputSelection(uint32_t OutputSelection)
3593 {
3594   MODIFY_REG(TAMP->ATCR2, (TAMP_ATCR2_ATOSEL1 | TAMP_ATCR2_ATOSEL2 | TAMP_ATCR2_ATOSEL3 | TAMP_ATCR2_ATOSEL4 | \
3595                            TAMP_ATCR2_ATOSEL5 | TAMP_ATCR2_ATOSEL6 | TAMP_ATCR2_ATOSEL7), \
3596              OutputSelection);
3597 }
3598 
3599 /**
3600   * @brief  Get Active tamper shared output selection.
3601   * @rmtoll TAMP_ATCR2     ATOSELx       LL_RTC_TAMPER_ATAMP_GetSharedOuputSelection\n
3602   * @retval A combination of @arg @ref RTC_LL_EC_ACTIVE_OUTPUT_SELECTION
3603   */
LL_RTC_TAMPER_ATAMP_GetSharedOuputSelection(void)3604 __STATIC_INLINE uint32_t LL_RTC_TAMPER_ATAMP_GetSharedOuputSelection(void)
3605 {
3606   return (READ_BIT(TAMP->ATCR2, (TAMP_ATCR2_ATOSEL1 | TAMP_ATCR2_ATOSEL2 | TAMP_ATCR2_ATOSEL3 | TAMP_ATCR2_ATOSEL4 | \
3607                                  TAMP_ATCR2_ATOSEL5 | TAMP_ATCR2_ATOSEL6 | TAMP_ATCR2_ATOSEL7)));
3608 }
3609 
3610 /**
3611   * @brief  Write active tamper seed.
3612   * @rmtoll TAMP_ATSEEDR   SEED          LL_RTC_TAMPER_ATAMP_WriteSeed\n
3613   * @param  Seed
3614   * @retval None
3615   */
LL_RTC_TAMPER_ATAMP_WriteSeed(uint32_t Seed)3616 __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_WriteSeed(uint32_t Seed)
3617 {
3618   WRITE_REG(TAMP->ATSEEDR, Seed);
3619 }
3620 
3621 /**
3622   * @brief  Get active tamper initialization status flag.
3623   * @rmtoll TAMP_ATOR      INITS         LL_RTC_IsActiveFlag_ATAMP_INITS
3624   * @retval State of bit (1 or 0).
3625   */
LL_RTC_IsActiveFlag_ATAMP_INITS(void)3626 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ATAMP_INITS(void)
3627 {
3628   return ((READ_BIT(TAMP->ATOR, TAMP_ATOR_INITS) == (TAMP_ATOR_INITS)) ? 1U : 0U);
3629 }
3630 
3631 /**
3632   * @brief  Get active tamper seed running status flag.
3633   * @rmtoll TAMP_ATOR      SEEDF         LL_RTC_IsActiveFlag_ATAMP_SEEDF
3634   * @retval State of bit (1 or 0).
3635   */
LL_RTC_IsActiveFlag_ATAMP_SEEDF(void)3636 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ATAMP_SEEDF(void)
3637 {
3638   return ((READ_BIT(TAMP->ATOR, TAMP_ATOR_SEEDF) == (TAMP_ATOR_SEEDF)) ? 1U : 0U);
3639 }
3640 
3641 /**
3642   * @}
3643   */
3644 
3645 /** @defgroup RTC_LL_EF_Wakeup Wakeup
3646   * @{
3647   */
3648 
3649 /**
3650   * @brief  Enable Wakeup timer
3651   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3652   * @rmtoll RTC_CR           WUTE          LL_RTC_WAKEUP_Enable
3653   * @param  RTCx RTC Instance
3654   * @retval None
3655   */
LL_RTC_WAKEUP_Enable(RTC_TypeDef * RTCx)3656 __STATIC_INLINE void LL_RTC_WAKEUP_Enable(RTC_TypeDef *RTCx)
3657 {
3658   SET_BIT(RTCx->CR, RTC_CR_WUTE);
3659 }
3660 
3661 /**
3662   * @brief  Disable Wakeup timer
3663   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3664   * @rmtoll RTC_CR           WUTE          LL_RTC_WAKEUP_Disable
3665   * @param  RTCx RTC Instance
3666   * @retval None
3667   */
LL_RTC_WAKEUP_Disable(RTC_TypeDef * RTCx)3668 __STATIC_INLINE void LL_RTC_WAKEUP_Disable(RTC_TypeDef *RTCx)
3669 {
3670   CLEAR_BIT(RTCx->CR, RTC_CR_WUTE);
3671 }
3672 
3673 /**
3674   * @brief  Check if Wakeup timer is enabled or not
3675   * @rmtoll RTC_CR           WUTE          LL_RTC_WAKEUP_IsEnabled
3676   * @param  RTCx RTC Instance
3677   * @retval State of bit (1 or 0).
3678   */
LL_RTC_WAKEUP_IsEnabled(const RTC_TypeDef * RTCx)3679 __STATIC_INLINE uint32_t LL_RTC_WAKEUP_IsEnabled(const RTC_TypeDef *RTCx)
3680 {
3681   return ((READ_BIT(RTCx->CR, RTC_CR_WUTE) == (RTC_CR_WUTE)) ? 1U : 0U);
3682 }
3683 
3684 /**
3685   * @brief  Select Wakeup clock
3686   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3687   * @note   Bit can be written only when RTC_CR WUTE bit = 0 and RTC_ICSR WUTWF bit = 1
3688   * @rmtoll RTC_CR           WUCKSEL       LL_RTC_WAKEUP_SetClock
3689   * @param  RTCx RTC Instance
3690   * @param  WakeupClock This parameter can be one of the following values:
3691   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
3692   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
3693   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
3694   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
3695   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
3696   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
3697   * @retval None
3698   */
LL_RTC_WAKEUP_SetClock(RTC_TypeDef * RTCx,uint32_t WakeupClock)3699 __STATIC_INLINE void LL_RTC_WAKEUP_SetClock(RTC_TypeDef *RTCx, uint32_t WakeupClock)
3700 {
3701   MODIFY_REG(RTCx->CR, RTC_CR_WUCKSEL, WakeupClock);
3702 }
3703 
3704 /**
3705   * @brief  Get Wakeup clock
3706   * @rmtoll RTC_CR           WUCKSEL       LL_RTC_WAKEUP_GetClock
3707   * @param  RTCx RTC Instance
3708   * @retval Returned value can be one of the following values:
3709   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
3710   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
3711   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
3712   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
3713   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
3714   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
3715   */
LL_RTC_WAKEUP_GetClock(const RTC_TypeDef * RTCx)3716 __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetClock(const RTC_TypeDef *RTCx)
3717 {
3718   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_WUCKSEL));
3719 }
3720 
3721 /**
3722   * @brief  Set Wakeup auto-reload value
3723   * @note   Bit can be written only when WUTWF is set to 1 in RTC_ICSR
3724   * @rmtoll RTC_WUTR         WUT           LL_RTC_WAKEUP_SetAutoReload
3725   * @param  RTCx RTC Instance
3726   * @param  Value Value between Min_Data=0x00 and Max_Data=0xFFFF
3727   * @retval None
3728   */
LL_RTC_WAKEUP_SetAutoReload(RTC_TypeDef * RTCx,uint32_t Value)3729 __STATIC_INLINE void LL_RTC_WAKEUP_SetAutoReload(RTC_TypeDef *RTCx, uint32_t Value)
3730 {
3731   MODIFY_REG(RTCx->WUTR, RTC_WUTR_WUT, Value);
3732 }
3733 
3734 /**
3735   * @brief  Get Wakeup auto-reload value
3736   * @rmtoll RTC_WUTR         WUT           LL_RTC_WAKEUP_GetAutoReload
3737   * @param  RTCx RTC Instance
3738   * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF
3739   */
LL_RTC_WAKEUP_GetAutoReload(const RTC_TypeDef * RTCx)3740 __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetAutoReload(const RTC_TypeDef *RTCx)
3741 {
3742   return (uint32_t)(READ_BIT(RTCx->WUTR, RTC_WUTR_WUT));
3743 }
3744 
3745 /**
3746   * @}
3747   */
3748 
3749 /** @defgroup RTC_LL_EF_Backup_Registers Backup_Registers
3750   * @{
3751   */
3752 
3753 /**
3754   * @brief  Writes a data in a specified Backup data register.
3755   * @rmtoll TAMP_BKPxR        BKP           LL_RTC_BKP_SetRegister
3756   * @param  RTCx RTC Instance
3757   * @param  BackupRegister This parameter can be one of the following values:
3758   *         @arg @ref LL_RTC_BKP_DR0
3759   *         @arg @ref LL_RTC_BKP_DR1
3760   *         @arg @ref LL_RTC_BKP_DR2
3761   *         @arg @ref LL_RTC_BKP_DR3
3762   *         @arg @ref LL_RTC_BKP_DR4
3763   *         @arg      LL_RTC_BKP_DRx ...
3764   * @param  Data Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
3765   * @retval None
3766   */
LL_RTC_BKP_SetRegister(const RTC_TypeDef * RTCx,uint32_t BackupRegister,uint32_t Data)3767 __STATIC_INLINE void LL_RTC_BKP_SetRegister(const RTC_TypeDef *RTCx, uint32_t BackupRegister, uint32_t Data)
3768 {
3769   __IO uint32_t tmp;
3770 
3771   UNUSED(RTCx);
3772 
3773   tmp = (uint32_t)(&(TAMP->BKP0R));
3774   tmp += (BackupRegister * 4U);
3775 
3776   /* Write the specified register */
3777   *(__IO uint32_t *)tmp = (uint32_t)Data;
3778 }
3779 
3780 /**
3781   * @brief  Reads data from the specified RTC Backup data Register.
3782   * @rmtoll TAMP_BKPxR        BKP           LL_RTC_BKP_GetRegister
3783   * @param  RTCx RTC Instance
3784   * @param  BackupRegister This parameter can be one of the following values:
3785   *         @arg @ref LL_RTC_BKP_DR0
3786   *         @arg @ref LL_RTC_BKP_DR1
3787   *         @arg @ref LL_RTC_BKP_DR2
3788   *         @arg @ref LL_RTC_BKP_DR3
3789   *         @arg @ref LL_RTC_BKP_DR4
3790   *         @arg      LL_RTC_BKP_DRx ...
3791   * @retval Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
3792   */
LL_RTC_BKP_GetRegister(const RTC_TypeDef * RTCx,uint32_t BackupRegister)3793 __STATIC_INLINE uint32_t LL_RTC_BKP_GetRegister(const RTC_TypeDef *RTCx, uint32_t BackupRegister)
3794 {
3795   uint32_t tmp;
3796 
3797   UNUSED(RTCx);
3798 
3799   tmp = (uint32_t)(&(TAMP->BKP0R));
3800   tmp += (BackupRegister * 4U);
3801 
3802   /* Read the specified register */
3803   return (*(__IO uint32_t *)tmp);
3804 }
3805 
3806 /**
3807   * @}
3808   */
3809 
3810 /** @defgroup RTC_LL_EF_Calibration Calibration
3811   * @{
3812   */
3813 
3814 /**
3815   * @brief  Set Calibration output frequency (1 Hz or 512 Hz)
3816   * @note Bits are write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3817   * @rmtoll RTC_CR           COE           LL_RTC_CAL_SetOutputFreq\n
3818   *         RTC_CR           COSEL         LL_RTC_CAL_SetOutputFreq
3819   * @param  RTCx RTC Instance
3820   * @param  Frequency This parameter can be one of the following values:
3821   *         @arg @ref LL_RTC_CALIB_OUTPUT_NONE
3822   *         @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
3823   *         @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
3824   * @retval None
3825   */
LL_RTC_CAL_SetOutputFreq(RTC_TypeDef * RTCx,uint32_t Frequency)3826 __STATIC_INLINE void LL_RTC_CAL_SetOutputFreq(RTC_TypeDef *RTCx, uint32_t Frequency)
3827 {
3828   MODIFY_REG(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL, Frequency);
3829 }
3830 
3831 /**
3832   * @brief  Get Calibration output frequency (1 Hz or 512 Hz)
3833   * @rmtoll RTC_CR           COE           LL_RTC_CAL_GetOutputFreq\n
3834   *         RTC_CR           COSEL         LL_RTC_CAL_GetOutputFreq
3835   * @param  RTCx RTC Instance
3836   * @retval Returned value can be one of the following values:
3837   *         @arg @ref LL_RTC_CALIB_OUTPUT_NONE
3838   *         @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
3839   *         @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
3840   */
LL_RTC_CAL_GetOutputFreq(const RTC_TypeDef * RTCx)3841 __STATIC_INLINE uint32_t LL_RTC_CAL_GetOutputFreq(const RTC_TypeDef *RTCx)
3842 {
3843   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL));
3844 }
3845 
3846 /**
3847   * @brief  Insert or not One RTCCLK pulse every 2exp11 pulses (frequency increased by 488.5 ppm)
3848   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3849   * @note Bit can be written only when RECALPF is set to 0 in RTC_ICSR
3850   * @rmtoll RTC_CALR         CALP          LL_RTC_CAL_SetPulse
3851   * @param  RTCx RTC Instance
3852   * @param  Pulse This parameter can be one of the following values:
3853   *         @arg @ref LL_RTC_CALIB_INSERTPULSE_NONE
3854   *         @arg @ref LL_RTC_CALIB_INSERTPULSE_SET
3855   * @retval None
3856   */
LL_RTC_CAL_SetPulse(RTC_TypeDef * RTCx,uint32_t Pulse)3857 __STATIC_INLINE void LL_RTC_CAL_SetPulse(RTC_TypeDef *RTCx, uint32_t Pulse)
3858 {
3859   MODIFY_REG(RTCx->CALR, RTC_CALR_CALP, Pulse);
3860 }
3861 
3862 /**
3863   * @brief  Check if one RTCCLK has been inserted or not every 2exp11 pulses (frequency increased by 488.5 ppm)
3864   * @rmtoll RTC_CALR         CALP          LL_RTC_CAL_IsPulseInserted
3865   * @param  RTCx RTC Instance
3866   * @retval State of bit (1 or 0).
3867   */
LL_RTC_CAL_IsPulseInserted(const RTC_TypeDef * RTCx)3868 __STATIC_INLINE uint32_t LL_RTC_CAL_IsPulseInserted(const RTC_TypeDef *RTCx)
3869 {
3870   return ((READ_BIT(RTCx->CALR, RTC_CALR_CALP) == (RTC_CALR_CALP)) ? 1U : 0U);
3871 }
3872 
3873 /**
3874   * @brief  Set the calibration cycle period
3875   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3876   * @note   Bit can be written only when RECALPF is set to 0 in RTC_ICSR
3877   * @rmtoll RTC_CALR         CALW8         LL_RTC_CAL_SetPeriod\n
3878   *         RTC_CALR         CALW16        LL_RTC_CAL_SetPeriod
3879   * @param  RTCx RTC Instance
3880   * @param  Period This parameter can be one of the following values:
3881   *         @arg @ref LL_RTC_CALIB_PERIOD_32SEC
3882   *         @arg @ref LL_RTC_CALIB_PERIOD_16SEC
3883   *         @arg @ref LL_RTC_CALIB_PERIOD_8SEC
3884   * @retval None
3885   */
LL_RTC_CAL_SetPeriod(RTC_TypeDef * RTCx,uint32_t Period)3886 __STATIC_INLINE void LL_RTC_CAL_SetPeriod(RTC_TypeDef *RTCx, uint32_t Period)
3887 {
3888   MODIFY_REG(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16, Period);
3889 }
3890 
3891 /**
3892   * @brief  Get the calibration cycle period
3893   * @rmtoll RTC_CALR         CALW8         LL_RTC_CAL_GetPeriod\n
3894   *         RTC_CALR         CALW16        LL_RTC_CAL_GetPeriod
3895   * @param  RTCx RTC Instance
3896   * @retval Returned value can be one of the following values:
3897   *         @arg @ref LL_RTC_CALIB_PERIOD_32SEC
3898   *         @arg @ref LL_RTC_CALIB_PERIOD_16SEC
3899   *         @arg @ref LL_RTC_CALIB_PERIOD_8SEC
3900   */
LL_RTC_CAL_GetPeriod(const RTC_TypeDef * RTCx)3901 __STATIC_INLINE uint32_t LL_RTC_CAL_GetPeriod(const RTC_TypeDef *RTCx)
3902 {
3903   return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16));
3904 }
3905 
3906 /**
3907   * @brief  Set Calibration minus
3908   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3909   * @note   Bit can be written only when RECALPF is set to 0 in RTC_ICSR
3910   * @rmtoll RTC_CALR         CALM          LL_RTC_CAL_SetMinus
3911   * @param  RTCx RTC Instance
3912   * @param  CalibMinus Value between Min_Data=0x00 and Max_Data=0x1FF
3913   * @retval None
3914   */
LL_RTC_CAL_SetMinus(RTC_TypeDef * RTCx,uint32_t CalibMinus)3915 __STATIC_INLINE void LL_RTC_CAL_SetMinus(RTC_TypeDef *RTCx, uint32_t CalibMinus)
3916 {
3917   MODIFY_REG(RTCx->CALR, RTC_CALR_CALM, CalibMinus);
3918 }
3919 
3920 /**
3921   * @brief  Get Calibration minus
3922   * @rmtoll RTC_CALR         CALM          LL_RTC_CAL_GetMinus
3923   * @param  RTCx RTC Instance
3924   * @retval Value between Min_Data=0x00 and Max_Data= 0x1FF
3925   */
LL_RTC_CAL_GetMinus(const RTC_TypeDef * RTCx)3926 __STATIC_INLINE uint32_t LL_RTC_CAL_GetMinus(const RTC_TypeDef *RTCx)
3927 {
3928   return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALM));
3929 }
3930 
3931 /**
3932   * @brief  Enable Calibration Low Power
3933   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3934   * @note   Bit can be written only when RECALPF is set to 0
3935   * @rmtoll RTC_CALR         LPCAL          LL_RTC_CAL_LowPower_Enable
3936   * @param  RTCx RTC Instance
3937   * @retval None
3938   */
LL_RTC_CAL_LowPower_Enable(RTC_TypeDef * RTCx)3939 __STATIC_INLINE void LL_RTC_CAL_LowPower_Enable(RTC_TypeDef *RTCx)
3940 {
3941   SET_BIT(RTCx->CALR, RTC_CALR_LPCAL);
3942 }
3943 
3944 /**
3945   * @brief  Disable Calibration Low Power
3946   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3947   * @note   Bit can be written only when RECALPF is set to 0
3948   * @rmtoll RTC_CALR         LPCAL          LL_RTC_CAL_LowPower_Disable
3949   * @param  RTCx RTC Instance
3950   * @retval None
3951   */
LL_RTC_CAL_LowPower_Disable(RTC_TypeDef * RTCx)3952 __STATIC_INLINE void LL_RTC_CAL_LowPower_Disable(RTC_TypeDef *RTCx)
3953 {
3954   CLEAR_BIT(RTCx->CALR, RTC_CALR_LPCAL);
3955 }
3956 
3957 /**
3958   * @brief  Check if Calibration Low Power is enabled or not
3959   * @rmtoll RTC_CALR         LPCAL          LL_RTC_CAL_LowPower_IsEnabled
3960   * @param  RTCx RTC Instance
3961   * @retval State of bit (1 or 0).
3962   */
LL_RTC_CAL_LowPower_IsEnabled(const RTC_TypeDef * RTCx)3963 __STATIC_INLINE uint32_t LL_RTC_CAL_LowPower_IsEnabled(const RTC_TypeDef *RTCx)
3964 {
3965   return ((READ_BIT(RTCx->CALR, RTC_CALR_LPCAL) == (RTC_CALR_LPCAL)) ? 1U : 0U);
3966 }
3967 
3968 /**
3969   * @}
3970   */
3971 
3972 /** @defgroup RTC_LL_EF_FLAG_Management FLAG_Management
3973   * @{
3974   */
3975 
3976 /**
3977   * @brief  Get Internal Time-stamp flag
3978   * @rmtoll RTC_SR          ITSF          LL_RTC_IsActiveFlag_ITS
3979   * @param  RTCx RTC Instance
3980   * @retval State of bit (1 or 0).
3981   */
LL_RTC_IsActiveFlag_ITS(const RTC_TypeDef * RTCx)3982 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITS(const RTC_TypeDef *RTCx)
3983 {
3984   return ((READ_BIT(RTCx->SR, RTC_SR_ITSF) == (RTC_SR_ITSF)) ? 1U : 0U);
3985 }
3986 
3987 /**
3988   * @brief  Get Recalibration pending Flag
3989   * @rmtoll RTC_ICSR          RECALPF       LL_RTC_IsActiveFlag_RECALP
3990   * @param  RTCx RTC Instance
3991   * @retval State of bit (1 or 0).
3992   */
LL_RTC_IsActiveFlag_RECALP(const RTC_TypeDef * RTCx)3993 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RECALP(const RTC_TypeDef *RTCx)
3994 {
3995   return ((READ_BIT(RTCx->ICSR, RTC_ICSR_RECALPF) == (RTC_ICSR_RECALPF)) ? 1U : 0U);
3996 }
3997 
3998 /**
3999   * @brief  Get Time-stamp overflow flag
4000   * @rmtoll RTC_SR          TSOVF         LL_RTC_IsActiveFlag_TSOV
4001   * @param  RTCx RTC Instance
4002   * @retval State of bit (1 or 0).
4003   */
LL_RTC_IsActiveFlag_TSOV(const RTC_TypeDef * RTCx)4004 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSOV(const RTC_TypeDef *RTCx)
4005 {
4006   return ((READ_BIT(RTCx->SR, RTC_SR_TSOVF) == (RTC_SR_TSOVF)) ? 1U : 0U);
4007 }
4008 
4009 /**
4010   * @brief  Get Time-stamp flag
4011   * @rmtoll RTC_SR          TSF           LL_RTC_IsActiveFlag_TS
4012   * @param  RTCx RTC Instance
4013   * @retval State of bit (1 or 0).
4014   */
LL_RTC_IsActiveFlag_TS(const RTC_TypeDef * RTCx)4015 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TS(const RTC_TypeDef *RTCx)
4016 {
4017   return ((READ_BIT(RTCx->SR, RTC_SR_TSF) == (RTC_SR_TSF)) ? 1U : 0U);
4018 }
4019 
4020 /**
4021   * @brief  Get Wakeup timer flag
4022   * @rmtoll RTC_SR          WUTF          LL_RTC_IsActiveFlag_WUT
4023   * @param  RTCx RTC Instance
4024   * @retval State of bit (1 or 0).
4025   */
LL_RTC_IsActiveFlag_WUT(const RTC_TypeDef * RTCx)4026 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUT(const RTC_TypeDef *RTCx)
4027 {
4028   return ((READ_BIT(RTCx->SR, RTC_SR_WUTF) == (RTC_SR_WUTF)) ? 1U : 0U);
4029 }
4030 
4031 /**
4032   * @brief  Get Alarm B flag
4033   * @rmtoll RTC_SR          ALRBF         LL_RTC_IsActiveFlag_ALRB
4034   * @param  RTCx RTC Instance
4035   * @retval State of bit (1 or 0).
4036   */
LL_RTC_IsActiveFlag_ALRB(const RTC_TypeDef * RTCx)4037 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRB(const RTC_TypeDef *RTCx)
4038 {
4039   return ((READ_BIT(RTCx->SR, RTC_SR_ALRBF) == (RTC_SR_ALRBF)) ? 1U : 0U);
4040 }
4041 
4042 /**
4043   * @brief  Get Alarm A flag
4044   * @rmtoll RTC_SR          ALRAF         LL_RTC_IsActiveFlag_ALRA
4045   * @param  RTCx RTC Instance
4046   * @retval State of bit (1 or 0).
4047   */
LL_RTC_IsActiveFlag_ALRA(const RTC_TypeDef * RTCx)4048 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRA(const RTC_TypeDef *RTCx)
4049 {
4050   return ((READ_BIT(RTCx->SR, RTC_SR_ALRAF) == (RTC_SR_ALRAF)) ? 1U : 0U);
4051 }
4052 
4053 /**
4054   * @brief  Get SSR Underflow flag
4055   * @rmtoll RTC_SR          SSRUF         LL_RTC_IsActiveFlag_SSRU
4056   * @param  RTCx RTC Instance
4057   * @retval State of bit (1 or 0).
4058   */
LL_RTC_IsActiveFlag_SSRU(const RTC_TypeDef * RTCx)4059 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SSRU(const RTC_TypeDef *RTCx)
4060 {
4061   return ((READ_BIT(RTCx->SR, RTC_SR_SSRUF) == (RTC_SR_SSRUF)) ? 1U : 0U);
4062 }
4063 
4064 /**
4065   * @brief  Clear Internal Time-stamp flag
4066   * @rmtoll RTC_SCR          CITSF          LL_RTC_ClearFlag_ITS
4067   * @param  RTCx RTC Instance
4068   * @retval None
4069   */
LL_RTC_ClearFlag_ITS(RTC_TypeDef * RTCx)4070 __STATIC_INLINE void LL_RTC_ClearFlag_ITS(RTC_TypeDef *RTCx)
4071 {
4072   WRITE_REG(RTCx->SCR, RTC_SCR_CITSF);
4073 }
4074 
4075 /**
4076   * @brief  Clear Time-stamp overflow flag
4077   * @rmtoll RTC_SCR          CTSOVF         LL_RTC_ClearFlag_TSOV
4078   * @param  RTCx RTC Instance
4079   * @retval None
4080   */
LL_RTC_ClearFlag_TSOV(RTC_TypeDef * RTCx)4081 __STATIC_INLINE void LL_RTC_ClearFlag_TSOV(RTC_TypeDef *RTCx)
4082 {
4083   WRITE_REG(RTCx->SCR, RTC_SCR_CTSOVF);
4084 }
4085 
4086 /**
4087   * @brief  Clear Time-stamp flag
4088   * @rmtoll RTC_SCR          CTSF           LL_RTC_ClearFlag_TS
4089   * @param  RTCx RTC Instance
4090   * @retval None
4091   */
LL_RTC_ClearFlag_TS(RTC_TypeDef * RTCx)4092 __STATIC_INLINE void LL_RTC_ClearFlag_TS(RTC_TypeDef *RTCx)
4093 {
4094   WRITE_REG(RTCx->SCR, RTC_SCR_CTSF);
4095 }
4096 
4097 /**
4098   * @brief  Clear Wakeup timer flag
4099   * @rmtoll RTC_SCR          CWUTF          LL_RTC_ClearFlag_WUT
4100   * @param  RTCx RTC Instance
4101   * @retval None
4102   */
LL_RTC_ClearFlag_WUT(RTC_TypeDef * RTCx)4103 __STATIC_INLINE void LL_RTC_ClearFlag_WUT(RTC_TypeDef *RTCx)
4104 {
4105   WRITE_REG(RTCx->SCR, RTC_SCR_CWUTF);
4106 }
4107 
4108 /**
4109   * @brief  Clear Alarm B flag
4110   * @rmtoll RTC_SCR          CALRBF         LL_RTC_ClearFlag_ALRB
4111   * @param  RTCx RTC Instance
4112   * @retval None
4113   */
LL_RTC_ClearFlag_ALRB(RTC_TypeDef * RTCx)4114 __STATIC_INLINE void LL_RTC_ClearFlag_ALRB(RTC_TypeDef *RTCx)
4115 {
4116   WRITE_REG(RTCx->SCR, RTC_SCR_CALRBF);
4117 }
4118 
4119 /**
4120   * @brief  Clear Alarm A flag
4121   * @rmtoll RTC_SCR          CALRAF         LL_RTC_ClearFlag_ALRA
4122   * @param  RTCx RTC Instance
4123   * @retval None
4124   */
LL_RTC_ClearFlag_ALRA(RTC_TypeDef * RTCx)4125 __STATIC_INLINE void LL_RTC_ClearFlag_ALRA(RTC_TypeDef *RTCx)
4126 {
4127   WRITE_REG(RTCx->SCR, RTC_SCR_CALRAF);
4128 }
4129 
4130 /**
4131   * @brief  Clear SSR Underflow flag
4132   * @rmtoll RTC_SCR          CSSRUF         LL_RTC_ClearFlag_SSRU
4133   * @param  RTCx RTC Instance
4134   * @retval None
4135   */
LL_RTC_ClearFlag_SSRU(RTC_TypeDef * RTCx)4136 __STATIC_INLINE void LL_RTC_ClearFlag_SSRU(RTC_TypeDef *RTCx)
4137 {
4138   WRITE_REG(RTCx->SCR, RTC_SCR_CSSRUF);
4139 }
4140 
4141 /**
4142   * @brief  Get Initialization flag
4143   * @rmtoll RTC_ICSR          INITF         LL_RTC_IsActiveFlag_INIT
4144   * @param  RTCx RTC Instance
4145   * @retval State of bit (1 or 0).
4146   */
LL_RTC_IsActiveFlag_INIT(const RTC_TypeDef * RTCx)4147 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INIT(const RTC_TypeDef *RTCx)
4148 {
4149   return ((READ_BIT(RTCx->ICSR, RTC_ICSR_INITF) == (RTC_ICSR_INITF)) ? 1U : 0U);
4150 }
4151 
4152 /**
4153   * @brief  Get Registers synchronization flag
4154   * @rmtoll RTC_ICSR          RSF           LL_RTC_IsActiveFlag_RS
4155   * @param  RTCx RTC Instance
4156   * @retval State of bit (1 or 0).
4157   */
LL_RTC_IsActiveFlag_RS(const RTC_TypeDef * RTCx)4158 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(const RTC_TypeDef *RTCx)
4159 {
4160   return ((READ_BIT(RTCx->ICSR, RTC_ICSR_RSF) == (RTC_ICSR_RSF)) ? 1U : 0U);
4161 }
4162 
4163 /**
4164   * @brief  Clear Registers synchronization flag
4165   * @rmtoll RTC_ICSR          RSF           LL_RTC_ClearFlag_RS
4166   * @param  RTCx RTC Instance
4167   * @retval None
4168   */
LL_RTC_ClearFlag_RS(RTC_TypeDef * RTCx)4169 __STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx)
4170 {
4171   WRITE_REG(RTCx->ICSR, (~((RTC_ICSR_RSF | RTC_ICSR_INIT) & 0x000000FFU) | (RTCx->ICSR & RTC_ICSR_INIT)));
4172 }
4173 
4174 /**
4175   * @brief  Get Initialization status flag
4176   * @rmtoll RTC_ICSR          INITS         LL_RTC_IsActiveFlag_INITS
4177   * @param  RTCx RTC Instance
4178   * @retval State of bit (1 or 0).
4179   */
LL_RTC_IsActiveFlag_INITS(const RTC_TypeDef * RTCx)4180 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INITS(const RTC_TypeDef *RTCx)
4181 {
4182   return ((READ_BIT(RTCx->ICSR, RTC_ICSR_INITS) == (RTC_ICSR_INITS)) ? 1U : 0U);
4183 }
4184 
4185 /**
4186   * @brief  Get Shift operation pending flag
4187   * @rmtoll RTC_ICSR          SHPF          LL_RTC_IsActiveFlag_SHP
4188   * @param  RTCx RTC Instance
4189   * @retval State of bit (1 or 0).
4190   */
LL_RTC_IsActiveFlag_SHP(const RTC_TypeDef * RTCx)4191 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SHP(const RTC_TypeDef *RTCx)
4192 {
4193   return ((READ_BIT(RTCx->ICSR, RTC_ICSR_SHPF) == (RTC_ICSR_SHPF)) ? 1U : 0U);
4194 }
4195 
4196 /**
4197   * @brief  Get Wakeup timer write flag
4198   * @rmtoll RTC_ICSR          WUTWF         LL_RTC_IsActiveFlag_WUTW
4199   * @param  RTCx RTC Instance
4200   * @retval State of bit (1 or 0).
4201   */
LL_RTC_IsActiveFlag_WUTW(const RTC_TypeDef * RTCx)4202 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUTW(const RTC_TypeDef *RTCx)
4203 {
4204   return ((READ_BIT(RTCx->ICSR, RTC_ICSR_WUTWF) == (RTC_ICSR_WUTWF)) ? 1U : 0U);
4205 }
4206 
4207 /**
4208   * @brief  Get Alarm A masked flag.
4209   * @rmtoll RTC_MISR          ALRAMF        LL_RTC_IsActiveFlag_ALRAM
4210   * @param  RTCx RTC Instance
4211   * @retval State of bit (1 or 0).
4212   */
LL_RTC_IsActiveFlag_ALRAM(const RTC_TypeDef * RTCx)4213 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRAM(const RTC_TypeDef *RTCx)
4214 {
4215   return ((READ_BIT(RTCx->MISR, RTC_MISR_ALRAMF) == (RTC_MISR_ALRAMF)) ? 1U : 0U);
4216 }
4217 
4218 /**
4219   * @brief  Get SSR Underflow masked flag.
4220   * @rmtoll RTC_MISR          SSRUMF        LL_RTC_IsActiveFlag_SSRUM
4221   * @param  RTCx RTC Instance
4222   * @retval State of bit (1 or 0).
4223   */
LL_RTC_IsActiveFlag_SSRUM(const RTC_TypeDef * RTCx)4224 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SSRUM(const RTC_TypeDef *RTCx)
4225 {
4226   return ((READ_BIT(RTCx->MISR, RTC_MISR_SSRUMF) == (RTC_MISR_SSRUMF)) ? 1U : 0U);
4227 }
4228 
4229 /**
4230   * @brief  Get Alarm B masked flag.
4231   * @rmtoll RTC_MISR          ALRBMF        LL_RTC_IsActiveFlag_ALRBM
4232   * @param  RTCx RTC Instance
4233   * @retval State of bit (1 or 0).
4234   */
LL_RTC_IsActiveFlag_ALRBM(const RTC_TypeDef * RTCx)4235 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRBM(const RTC_TypeDef *RTCx)
4236 {
4237   return ((READ_BIT(RTCx->MISR, RTC_MISR_ALRBMF) == (RTC_MISR_ALRBMF)) ? 1U : 0U);
4238 }
4239 
4240 /**
4241   * @brief  Get Wakeup timer masked flag.
4242   * @rmtoll RTC_MISR          WUTMF        LL_RTC_IsActiveFlag_WUTM
4243   * @param  RTCx RTC Instance
4244   * @retval State of bit (1 or 0).
4245   */
LL_RTC_IsActiveFlag_WUTM(const RTC_TypeDef * RTCx)4246 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUTM(const RTC_TypeDef *RTCx)
4247 {
4248   return ((READ_BIT(RTCx->MISR, RTC_MISR_WUTMF) == (RTC_MISR_WUTMF)) ? 1U : 0U);
4249 }
4250 
4251 /**
4252   * @brief  Get Time-stamp masked flag.
4253   * @rmtoll RTC_MISR          TSMF        LL_RTC_IsActiveFlag_TSM
4254   * @param  RTCx RTC Instance
4255   * @retval State of bit (1 or 0).
4256   */
LL_RTC_IsActiveFlag_TSM(const RTC_TypeDef * RTCx)4257 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSM(const RTC_TypeDef *RTCx)
4258 {
4259   return ((READ_BIT(RTCx->MISR, RTC_MISR_TSMF) == (RTC_MISR_TSMF)) ? 1U : 0U);
4260 }
4261 
4262 /**
4263   * @brief  Get Time-stamp overflow masked flag.
4264   * @rmtoll RTC_MISR          TSOVMF        LL_RTC_IsActiveFlag_TSOVM
4265   * @param  RTCx RTC Instance
4266   * @retval State of bit (1 or 0).
4267   */
LL_RTC_IsActiveFlag_TSOVM(const RTC_TypeDef * RTCx)4268 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSOVM(const RTC_TypeDef *RTCx)
4269 {
4270   return ((READ_BIT(RTCx->MISR, RTC_MISR_TSOVMF) == (RTC_MISR_TSOVMF)) ? 1U : 0U);
4271 }
4272 
4273 /**
4274   * @brief  Get Internal Time-stamp masked flag.
4275   * @rmtoll RTC_MISR          ITSMF        LL_RTC_IsActiveFlag_ITSM
4276   * @param  RTCx RTC Instance
4277   * @retval State of bit (1 or 0).
4278   */
LL_RTC_IsActiveFlag_ITSM(const RTC_TypeDef * RTCx)4279 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITSM(const RTC_TypeDef *RTCx)
4280 {
4281   return ((READ_BIT(RTCx->MISR, RTC_MISR_ITSMF) == (RTC_MISR_ITSMF)) ? 1U : 0U);
4282 }
4283 
4284 /**
4285   * @brief  Get tamper 1 detection flag.
4286   * @rmtoll TAMP_SR          TAMP1F        LL_RTC_IsActiveFlag_TAMP1
4287   * @param  RTCx RTC Instance
4288   * @retval State of bit (1 or 0).
4289   */
LL_RTC_IsActiveFlag_TAMP1(const RTC_TypeDef * RTCx)4290 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP1(const RTC_TypeDef *RTCx)
4291 {
4292   UNUSED(RTCx);
4293   return ((READ_BIT(TAMP->SR, TAMP_SR_TAMP1F) == (TAMP_SR_TAMP1F)) ? 1U : 0U);
4294 }
4295 
4296 /**
4297   * @brief  Get tamper 2 detection flag.
4298   * @rmtoll TAMP_SR          TAMP2F        LL_RTC_IsActiveFlag_TAMP2
4299   * @param  RTCx RTC Instance
4300   * @retval State of bit (1 or 0).
4301   */
LL_RTC_IsActiveFlag_TAMP2(const RTC_TypeDef * RTCx)4302 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP2(const RTC_TypeDef *RTCx)
4303 {
4304   UNUSED(RTCx);
4305   return ((READ_BIT(TAMP->SR, TAMP_SR_TAMP2F) == (TAMP_SR_TAMP2F)) ? 1U : 0U);
4306 }
4307 
4308 /**
4309   * @brief  Get tamper 3 detection flag.
4310   * @rmtoll TAMP_SR          TAMP3F        LL_RTC_IsActiveFlag_TAMP3
4311   * @param  RTCx RTC Instance
4312   * @retval State of bit (1 or 0).
4313   */
LL_RTC_IsActiveFlag_TAMP3(const RTC_TypeDef * RTCx)4314 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP3(const RTC_TypeDef *RTCx)
4315 {
4316   UNUSED(RTCx);
4317   return ((READ_BIT(TAMP->SR, TAMP_SR_TAMP3F) == (TAMP_SR_TAMP3F)) ? 1U : 0U);
4318 }
4319 
4320 /**
4321   * @brief  Get tamper 4 detection flag.
4322   * @rmtoll TAMP_SR          TAMP4F        LL_RTC_IsActiveFlag_TAMP4
4323   * @param  RTCx RTC Instance
4324   * @retval State of bit (1 or 0).
4325   */
LL_RTC_IsActiveFlag_TAMP4(const RTC_TypeDef * RTCx)4326 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP4(const RTC_TypeDef *RTCx)
4327 {
4328   UNUSED(RTCx);
4329   return ((READ_BIT(TAMP->SR, TAMP_SR_TAMP4F) == (TAMP_SR_TAMP4F)) ? 1U : 0U);
4330 }
4331 
4332 /**
4333   * @brief  Get tamper 5 detection flag.
4334   * @rmtoll TAMP_SR          TAMP5F        LL_RTC_IsActiveFlag_TAMP5
4335   * @param  RTCx RTC Instance
4336   * @retval State of bit (1 or 0).
4337   */
LL_RTC_IsActiveFlag_TAMP5(const RTC_TypeDef * RTCx)4338 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP5(const RTC_TypeDef *RTCx)
4339 {
4340   UNUSED(RTCx);
4341   return ((READ_BIT(TAMP->SR, TAMP_SR_TAMP5F) == (TAMP_SR_TAMP5F)) ? 1U : 0U);
4342 }
4343 
4344 /**
4345   * @brief  Get tamper 6 detection flag.
4346   * @rmtoll TAMP_SR          TAMP6F        LL_RTC_IsActiveFlag_TAMP6
4347   * @param  RTCx RTC Instance
4348   * @retval State of bit (1 or 0).
4349   */
LL_RTC_IsActiveFlag_TAMP6(const RTC_TypeDef * RTCx)4350 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP6(const RTC_TypeDef *RTCx)
4351 {
4352   UNUSED(RTCx);
4353   return ((READ_BIT(TAMP->SR, TAMP_SR_TAMP6F) == (TAMP_SR_TAMP6F)) ? 1U : 0U);
4354 }
4355 
4356 /**
4357   * @brief  Get tamper 7 detection flag.
4358   * @rmtoll TAMP_SR          TAMP7F        LL_RTC_IsActiveFlag_TAMP7
4359   * @param  RTCx RTC Instance
4360   * @retval State of bit (1 or 0).
4361   */
LL_RTC_IsActiveFlag_TAMP7(const RTC_TypeDef * RTCx)4362 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP7(const RTC_TypeDef *RTCx)
4363 {
4364   UNUSED(RTCx);
4365   return ((READ_BIT(TAMP->SR, TAMP_SR_TAMP7F) == (TAMP_SR_TAMP7F)) ? 1U : 0U);
4366 }
4367 
4368 /**
4369   * @brief  Get internal tamper 1 detection flag.
4370   * @rmtoll TAMP_SR          ITAMP1F        LL_RTC_IsActiveFlag_ITAMP1
4371   * @param  RTCx RTC Instance
4372   * @retval State of bit (1 or 0).
4373   */
LL_RTC_IsActiveFlag_ITAMP1(const RTC_TypeDef * RTCx)4374 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP1(const RTC_TypeDef *RTCx)
4375 {
4376   UNUSED(RTCx);
4377   return ((READ_BIT(TAMP->SR, TAMP_SR_ITAMP1F) == (TAMP_SR_ITAMP1F)) ? 1U : 0U);
4378 }
4379 
4380 /**
4381   * @brief  Get internal tamper 2 detection flag.
4382   * @rmtoll TAMP_SR          ITAMP2F        LL_RTC_IsActiveFlag_ITAMP2
4383   * @param  RTCx RTC Instance
4384   * @retval State of bit (1 or 0).
4385   */
LL_RTC_IsActiveFlag_ITAMP2(const RTC_TypeDef * RTCx)4386 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP2(const RTC_TypeDef *RTCx)
4387 {
4388   UNUSED(RTCx);
4389   return ((READ_BIT(TAMP->SR, TAMP_SR_ITAMP2F) == (TAMP_SR_ITAMP2F)) ? 1U : 0U);
4390 }
4391 
4392 /**
4393   * @brief  Get internal tamper 3 detection flag.
4394   * @rmtoll TAMP_SR          ITAMP3F        LL_RTC_IsActiveFlag_ITAMP3
4395   * @param  RTCx RTC Instance
4396   * @retval State of bit (1 or 0).
4397   */
LL_RTC_IsActiveFlag_ITAMP3(const RTC_TypeDef * RTCx)4398 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP3(const RTC_TypeDef *RTCx)
4399 {
4400   UNUSED(RTCx);
4401   return ((READ_BIT(TAMP->SR, TAMP_SR_ITAMP3F) == (TAMP_SR_ITAMP3F)) ? 1U : 0U);
4402 }
4403 
4404 /**
4405   * @brief  Get internal tamper 4 detection flag.
4406   * @rmtoll TAMP_SR          ITAMP4F        LL_RTC_IsActiveFlag_ITAMP4
4407   * @param  RTCx RTC Instance
4408   * @retval State of bit (1 or 0).
4409   */
LL_RTC_IsActiveFlag_ITAMP4(const RTC_TypeDef * RTCx)4410 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP4(const RTC_TypeDef *RTCx)
4411 {
4412   UNUSED(RTCx);
4413   return ((READ_BIT(TAMP->SR, TAMP_SR_ITAMP4F) == (TAMP_SR_ITAMP4F)) ? 1U : 0U);
4414 }
4415 
4416 /**
4417   * @brief  Get internal tamper 5 detection flag.
4418   * @rmtoll TAMP_SR          ITAMP5F        LL_RTC_IsActiveFlag_ITAMP5
4419   * @param  RTCx RTC Instance
4420   * @retval State of bit (1 or 0).
4421   */
LL_RTC_IsActiveFlag_ITAMP5(const RTC_TypeDef * RTCx)4422 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP5(const RTC_TypeDef *RTCx)
4423 {
4424   UNUSED(RTCx);
4425   return ((READ_BIT(TAMP->SR, TAMP_SR_ITAMP5F) == (TAMP_SR_ITAMP5F)) ? 1U : 0U);
4426 }
4427 
4428 /**
4429   * @brief  Get internal tamper 6 detection flag.
4430   * @rmtoll TAMP_SR          ITAMP6F        LL_RTC_IsActiveFlag_ITAMP6
4431   * @param  RTCx RTC Instance
4432   * @retval State of bit (1 or 0).
4433   */
LL_RTC_IsActiveFlag_ITAMP6(const RTC_TypeDef * RTCx)4434 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP6(const RTC_TypeDef *RTCx)
4435 {
4436   UNUSED(RTCx);
4437   return ((READ_BIT(TAMP->SR, TAMP_SR_ITAMP6F) == (TAMP_SR_ITAMP6F)) ? 1U : 0U);
4438 }
4439 
4440 /**
4441   * @brief  Get internal tamper 7 detection flag.
4442   * @rmtoll TAMP_SR          ITAMP7F        LL_RTC_IsActiveFlag_ITAMP7
4443   * @param  RTCx RTC Instance
4444   * @retval State of bit (1 or 0).
4445   */
LL_RTC_IsActiveFlag_ITAMP7(const RTC_TypeDef * RTCx)4446 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP7(const RTC_TypeDef *RTCx)
4447 {
4448   UNUSED(RTCx);
4449   return ((READ_BIT(TAMP->SR, TAMP_SR_ITAMP7F) == (TAMP_SR_ITAMP7F)) ? 1U : 0U);
4450 }
4451 
4452 /**
4453   * @brief  Get internal tamper 8 detection flag.
4454   * @rmtoll TAMP_SR          ITAMP8F        LL_RTC_IsActiveFlag_ITAMP8
4455   * @param  RTCx RTC Instance
4456   * @retval State of bit (1 or 0).
4457   */
LL_RTC_IsActiveFlag_ITAMP8(const RTC_TypeDef * RTCx)4458 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP8(const RTC_TypeDef *RTCx)
4459 {
4460   UNUSED(RTCx);
4461   return ((READ_BIT(TAMP->SR, TAMP_SR_ITAMP8F) == (TAMP_SR_ITAMP8F)) ? 1U : 0U);
4462 }
4463 
4464 /**
4465   * @brief  Get internal tamper 9 detection flag.
4466   * @rmtoll TAMP_SR          ITAMP9F        LL_RTC_IsActiveFlag_ITAMP9
4467   * @param  RTCx RTC Instance
4468   * @retval State of bit (1 or 0).
4469   */
LL_RTC_IsActiveFlag_ITAMP9(const RTC_TypeDef * RTCx)4470 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP9(const RTC_TypeDef *RTCx)
4471 {
4472   UNUSED(RTCx);
4473   return ((READ_BIT(TAMP->SR, TAMP_SR_ITAMP9F) == (TAMP_SR_ITAMP9F)) ? 1U : 0U);
4474 }
4475 
4476 /**
4477   * @brief  Get internal tamper 11 detection flag.
4478   * @rmtoll TAMP_SR          ITAMP11F        LL_RTC_IsActiveFlag_ITAMP11
4479   * @param  RTCx RTC Instance
4480   * @retval State of bit (1 or 0).
4481   */
LL_RTC_IsActiveFlag_ITAMP11(const RTC_TypeDef * RTCx)4482 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP11(const RTC_TypeDef *RTCx)
4483 {
4484   UNUSED(RTCx);
4485   return ((READ_BIT(TAMP->SR, TAMP_SR_ITAMP11F) == (TAMP_SR_ITAMP11F)) ? 1U : 0U);
4486 }
4487 
4488 /**
4489   * @brief  Get tamper 1 interrupt masked flag.
4490   * @rmtoll TAMP_MISR          TAMP1MF        LL_RTC_IsActiveFlag_TAMP1M
4491   * @param  RTCx RTC Instance
4492   * @retval State of bit (1 or 0).
4493   */
LL_RTC_IsActiveFlag_TAMP1M(const RTC_TypeDef * RTCx)4494 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP1M(const RTC_TypeDef *RTCx)
4495 {
4496   UNUSED(RTCx);
4497   return ((READ_BIT(TAMP->MISR, TAMP_MISR_TAMP1MF) == (TAMP_MISR_TAMP1MF)) ? 1U : 0U);
4498 }
4499 
4500 /**
4501   * @brief  Get tamper 2 interrupt masked flag.
4502   * @rmtoll TAMP_MISR          TAMP2MF        LL_RTC_IsActiveFlag_TAMP2M
4503   * @param  RTCx RTC Instance
4504   * @retval State of bit (1 or 0).
4505   */
LL_RTC_IsActiveFlag_TAMP2M(const RTC_TypeDef * RTCx)4506 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP2M(const RTC_TypeDef *RTCx)
4507 {
4508   UNUSED(RTCx);
4509   return ((READ_BIT(TAMP->MISR, TAMP_MISR_TAMP2MF) == (TAMP_MISR_TAMP2MF)) ? 1U : 0U);
4510 }
4511 
4512 /**
4513   * @brief  Get tamper 3 interrupt masked flag.
4514   * @rmtoll TAMP_MISR          TAMP3MF        LL_RTC_IsActiveFlag_TAMP3M
4515   * @param  RTCx RTC Instance
4516   * @retval State of bit (1 or 0).
4517   */
LL_RTC_IsActiveFlag_TAMP3M(const RTC_TypeDef * RTCx)4518 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP3M(const RTC_TypeDef *RTCx)
4519 {
4520   UNUSED(RTCx);
4521   return ((READ_BIT(TAMP->MISR, TAMP_MISR_TAMP3MF) == (TAMP_MISR_TAMP3MF)) ? 1U : 0U);
4522 }
4523 
4524 /**
4525   * @brief  Get tamper 4 interrupt masked flag.
4526   * @rmtoll TAMP_MISR          TAMP4MF        LL_RTC_IsActiveFlag_TAMP4M
4527   * @param  RTCx RTC Instance
4528   * @retval State of bit (1 or 0).
4529   */
LL_RTC_IsActiveFlag_TAMP4M(const RTC_TypeDef * RTCx)4530 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP4M(const RTC_TypeDef *RTCx)
4531 {
4532   UNUSED(RTCx);
4533   return ((READ_BIT(TAMP->MISR, TAMP_MISR_TAMP4MF) == (TAMP_MISR_TAMP4MF)) ? 1U : 0U);
4534 }
4535 
4536 /**
4537   * @brief  Get tamper 5 interrupt masked flag.
4538   * @rmtoll TAMP_MISR          TAMP5MF        LL_RTC_IsActiveFlag_TAMP5M
4539   * @param  RTCx RTC Instance
4540   * @retval State of bit (1 or 0).
4541   */
LL_RTC_IsActiveFlag_TAMP5M(const RTC_TypeDef * RTCx)4542 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP5M(const RTC_TypeDef *RTCx)
4543 {
4544   UNUSED(RTCx);
4545   return ((READ_BIT(TAMP->MISR, TAMP_MISR_TAMP5MF) == (TAMP_MISR_TAMP5MF)) ? 1U : 0U);
4546 }
4547 
4548 /**
4549   * @brief  Get tamper 6 interrupt masked flag.
4550   * @rmtoll TAMP_MISR          TAMP6MF        LL_RTC_IsActiveFlag_TAMP6M
4551   * @param  RTCx RTC Instance
4552   * @retval State of bit (1 or 0).
4553   */
LL_RTC_IsActiveFlag_TAMP6M(const RTC_TypeDef * RTCx)4554 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP6M(const RTC_TypeDef *RTCx)
4555 {
4556   UNUSED(RTCx);
4557   return ((READ_BIT(TAMP->MISR, TAMP_MISR_TAMP6MF) == (TAMP_MISR_TAMP6MF)) ? 1U : 0U);
4558 }
4559 
4560 /**
4561   * @brief  Get tamper 7 interrupt masked flag.
4562   * @rmtoll TAMP_MISR          TAMP7MF        LL_RTC_IsActiveFlag_TAMP7M
4563   * @param  RTCx RTC Instance
4564   * @retval State of bit (1 or 0).
4565   */
LL_RTC_IsActiveFlag_TAMP7M(const RTC_TypeDef * RTCx)4566 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP7M(const RTC_TypeDef *RTCx)
4567 {
4568   UNUSED(RTCx);
4569   return ((READ_BIT(TAMP->MISR, TAMP_MISR_TAMP7MF) == (TAMP_MISR_TAMP7MF)) ? 1U : 0U);
4570 }
4571 
4572 /**
4573   * @brief  Get internal tamper 1 interrupt masked flag.
4574   * @rmtoll TAMP_MISR          ITAMP1MF        LL_RTC_IsActiveFlag_ITAMP1M
4575   * @param  RTCx RTC Instance
4576   * @retval State of bit (1 or 0).
4577   */
LL_RTC_IsActiveFlag_ITAMP1M(const RTC_TypeDef * RTCx)4578 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP1M(const RTC_TypeDef *RTCx)
4579 {
4580   UNUSED(RTCx);
4581   return ((READ_BIT(TAMP->MISR, TAMP_MISR_ITAMP1MF) == (TAMP_MISR_ITAMP1MF)) ? 1U : 0U);
4582 }
4583 
4584 /**
4585   * @brief  Get internal tamper 2 interrupt masked flag.
4586   * @rmtoll TAMP_MISR          ITAMP2MF        LL_RTC_IsActiveFlag_ITAMP2M
4587   * @param  RTCx RTC Instance
4588   * @retval State of bit (1 or 0).
4589   */
LL_RTC_IsActiveFlag_ITAMP2M(const RTC_TypeDef * RTCx)4590 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP2M(const RTC_TypeDef *RTCx)
4591 {
4592   UNUSED(RTCx);
4593   return ((READ_BIT(TAMP->MISR, TAMP_MISR_ITAMP2MF) == (TAMP_MISR_ITAMP2MF)) ? 1U : 0U);
4594 }
4595 
4596 /**
4597   * @brief  Get internal tamper 3 interrupt masked flag.
4598   * @rmtoll TAMP_MISR          ITAMP3MF        LL_RTC_IsActiveFlag_ITAMP3M
4599   * @param  RTCx RTC Instance
4600   * @retval State of bit (1 or 0).
4601   */
LL_RTC_IsActiveFlag_ITAMP3M(const RTC_TypeDef * RTCx)4602 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP3M(const RTC_TypeDef *RTCx)
4603 {
4604   UNUSED(RTCx);
4605   return ((READ_BIT(TAMP->MISR, TAMP_MISR_ITAMP3MF) == (TAMP_MISR_ITAMP3MF)) ? 1U : 0U);
4606 }
4607 
4608 /**
4609   * @brief  Get internal tamper 4 interrupt masked flag.
4610   * @rmtoll TAMP_MISR          ITAMP4MF        LL_RTC_IsActiveFlag_ITAMP4M
4611   * @param  RTCx RTC Instance
4612   * @retval State of bit (1 or 0).
4613   */
LL_RTC_IsActiveFlag_ITAMP4M(const RTC_TypeDef * RTCx)4614 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP4M(const RTC_TypeDef *RTCx)
4615 {
4616   UNUSED(RTCx);
4617   return ((READ_BIT(TAMP->MISR, TAMP_MISR_ITAMP4MF) == (TAMP_MISR_ITAMP4MF)) ? 1U : 0U);
4618 }
4619 
4620 /**
4621   * @brief  Get internal tamper 5 interrupt masked flag.
4622   * @rmtoll TAMP_MISR          ITAMP5MF        LL_RTC_IsActiveFlag_ITAMP5M
4623   * @param  RTCx RTC Instance
4624   * @retval State of bit (1 or 0).
4625   */
LL_RTC_IsActiveFlag_ITAMP5M(const RTC_TypeDef * RTCx)4626 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP5M(const RTC_TypeDef *RTCx)
4627 {
4628   UNUSED(RTCx);
4629   return ((READ_BIT(TAMP->MISR, TAMP_MISR_ITAMP5MF) == (TAMP_MISR_ITAMP5MF)) ? 1U : 0U);
4630 }
4631 
4632 /**
4633   * @brief  Get internal tamper 6 interrupt masked flag.
4634   * @rmtoll TAMP_MISR          ITAMP6MF        LL_RTC_IsActiveFlag_ITAMP6M
4635   * @param  RTCx RTC Instance
4636   * @retval State of bit (1 or 0).
4637   */
LL_RTC_IsActiveFlag_ITAMP6M(const RTC_TypeDef * RTCx)4638 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP6M(const RTC_TypeDef *RTCx)
4639 {
4640   UNUSED(RTCx);
4641   return ((READ_BIT(TAMP->MISR, TAMP_MISR_ITAMP6MF) == (TAMP_MISR_ITAMP6MF)) ? 1U : 0U);
4642 }
4643 
4644 /**
4645   * @brief  Get internal tamper 7 interrupt masked flag.
4646   * @rmtoll TAMP_MISR          ITAMP7MF        LL_RTC_IsActiveFlag_ITAMP7M
4647   * @param  RTCx RTC Instance
4648   * @retval State of bit (1 or 0).
4649   */
LL_RTC_IsActiveFlag_ITAMP7M(const RTC_TypeDef * RTCx)4650 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP7M(const RTC_TypeDef *RTCx)
4651 {
4652   UNUSED(RTCx);
4653   return ((READ_BIT(TAMP->MISR, TAMP_MISR_ITAMP7MF) == (TAMP_MISR_ITAMP7MF)) ? 1U : 0U);
4654 }
4655 
4656 /**
4657   * @brief  Get internal tamper 8 interrupt masked flag.
4658   * @rmtoll TAMP_MISR          ITAMP8MF        LL_RTC_IsActiveFlag_ITAMP8M
4659   * @param  RTCx RTC Instance
4660   * @retval State of bit (1 or 0).
4661   */
LL_RTC_IsActiveFlag_ITAMP8M(const RTC_TypeDef * RTCx)4662 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP8M(const RTC_TypeDef *RTCx)
4663 {
4664   UNUSED(RTCx);
4665   return ((READ_BIT(TAMP->MISR, TAMP_MISR_ITAMP8MF) == (TAMP_MISR_ITAMP8MF)) ? 1U : 0U);
4666 }
4667 
4668 /**
4669   * @brief  Get internal tamper 9 interrupt masked flag.
4670   * @rmtoll TAMP_MISR          ITAMP9MF        LL_RTC_IsActiveFlag_ITAMP9M
4671   * @param  RTCx RTC Instance
4672   * @retval State of bit (1 or 0).
4673   */
LL_RTC_IsActiveFlag_ITAMP9M(const RTC_TypeDef * RTCx)4674 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP9M(const RTC_TypeDef *RTCx)
4675 {
4676   UNUSED(RTCx);
4677   return ((READ_BIT(TAMP->MISR, TAMP_MISR_ITAMP9MF) == (TAMP_MISR_ITAMP9MF)) ? 1U : 0U);
4678 }
4679 
4680 /**
4681   * @brief  Get internal tamper 11 interrupt masked flag.
4682   * @rmtoll TAMP_MISR          ITAMP11MF        LL_RTC_IsActiveFlag_ITAMP11M
4683   * @param  RTCx RTC Instance
4684   * @retval State of bit (1 or 0).
4685   */
LL_RTC_IsActiveFlag_ITAMP11M(const RTC_TypeDef * RTCx)4686 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITAMP11M(const RTC_TypeDef *RTCx)
4687 {
4688   UNUSED(RTCx);
4689   return ((READ_BIT(TAMP->MISR, TAMP_MISR_ITAMP11MF) == (TAMP_MISR_ITAMP11MF)) ? 1U : 0U);
4690 }
4691 
4692 /**
4693   * @brief  Clear tamper 1 detection flag.
4694   * @rmtoll TAMP_SCR          CTAMP1F         LL_RTC_ClearFlag_TAMP1
4695   * @param  RTCx RTC Instance
4696   * @retval None
4697   */
LL_RTC_ClearFlag_TAMP1(const RTC_TypeDef * RTCx)4698 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP1(const RTC_TypeDef *RTCx)
4699 {
4700   UNUSED(RTCx);
4701   WRITE_REG(TAMP->SCR, TAMP_SCR_CTAMP1F);
4702 }
4703 
4704 /**
4705   * @brief  Clear tamper 2 detection flag.
4706   * @rmtoll TAMP_SCR          CTAMP2F         LL_RTC_ClearFlag_TAMP2
4707   * @param  RTCx RTC Instance
4708   * @retval None
4709   */
LL_RTC_ClearFlag_TAMP2(const RTC_TypeDef * RTCx)4710 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP2(const RTC_TypeDef *RTCx)
4711 {
4712   UNUSED(RTCx);
4713   WRITE_REG(TAMP->SCR, TAMP_SCR_CTAMP2F);
4714 }
4715 
4716 /**
4717   * @brief  Clear tamper 3 detection flag.
4718   * @rmtoll TAMP_SCR          CTAMP3F         LL_RTC_ClearFlag_TAMP3
4719   * @param  RTCx RTC Instance
4720   * @retval None
4721   */
LL_RTC_ClearFlag_TAMP3(const RTC_TypeDef * RTCx)4722 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP3(const RTC_TypeDef *RTCx)
4723 {
4724   UNUSED(RTCx);
4725   WRITE_REG(TAMP->SCR, TAMP_SCR_CTAMP3F);
4726 }
4727 
4728 /**
4729   * @brief  Clear tamper 4 detection flag.
4730   * @rmtoll TAMP_SCR          CTAMP4F         LL_RTC_ClearFlag_TAMP4
4731   * @param  RTCx RTC Instance
4732   * @retval None
4733   */
LL_RTC_ClearFlag_TAMP4(const RTC_TypeDef * RTCx)4734 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP4(const RTC_TypeDef *RTCx)
4735 {
4736   UNUSED(RTCx);
4737   WRITE_REG(TAMP->SCR, TAMP_SCR_CTAMP4F);
4738 }
4739 
4740 /**
4741   * @brief  Clear tamper 5 detection flag.
4742   * @rmtoll TAMP_SCR          CTAMP5F         LL_RTC_ClearFlag_TAMP5
4743   * @param  RTCx RTC Instance
4744   * @retval None
4745   */
LL_RTC_ClearFlag_TAMP5(const RTC_TypeDef * RTCx)4746 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP5(const RTC_TypeDef *RTCx)
4747 {
4748   UNUSED(RTCx);
4749   WRITE_REG(TAMP->SCR, TAMP_SCR_CTAMP5F);
4750 }
4751 
4752 /**
4753   * @brief  Clear tamper 6 detection flag.
4754   * @rmtoll TAMP_SCR          CTAMP6F         LL_RTC_ClearFlag_TAMP6
4755   * @param  RTCx RTC Instance
4756   * @retval None
4757   */
LL_RTC_ClearFlag_TAMP6(const RTC_TypeDef * RTCx)4758 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP6(const RTC_TypeDef *RTCx)
4759 {
4760   UNUSED(RTCx);
4761   WRITE_REG(TAMP->SCR, TAMP_SCR_CTAMP6F);
4762 }
4763 
4764 /**
4765   * @brief  Clear tamper 7 detection flag.
4766   * @rmtoll TAMP_SCR          CTAMP7F         LL_RTC_ClearFlag_TAMP7
4767   * @param  RTCx RTC Instance
4768   * @retval None
4769   */
LL_RTC_ClearFlag_TAMP7(const RTC_TypeDef * RTCx)4770 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP7(const RTC_TypeDef *RTCx)
4771 {
4772   UNUSED(RTCx);
4773   WRITE_REG(TAMP->SCR, TAMP_SCR_CTAMP7F);
4774 }
4775 
4776 /**
4777   * @brief  Clear internal tamper 1 detection flag.
4778   * @rmtoll TAMP_SCR          CITAMP1F         LL_RTC_ClearFlag_ITAMP1
4779   * @param  RTCx RTC Instance
4780   * @retval None
4781   */
LL_RTC_ClearFlag_ITAMP1(const RTC_TypeDef * RTCx)4782 __STATIC_INLINE void LL_RTC_ClearFlag_ITAMP1(const RTC_TypeDef *RTCx)
4783 {
4784   UNUSED(RTCx);
4785   WRITE_REG(TAMP->SCR, TAMP_SCR_CITAMP1F);
4786 }
4787 
4788 /**
4789   * @brief  Clear internal tamper 2 detection flag.
4790   * @rmtoll TAMP_SCR          CITAMP2F         LL_RTC_ClearFlag_ITAMP2
4791   * @param  RTCx RTC Instance
4792   * @retval None
4793   */
LL_RTC_ClearFlag_ITAMP2(const RTC_TypeDef * RTCx)4794 __STATIC_INLINE void LL_RTC_ClearFlag_ITAMP2(const RTC_TypeDef *RTCx)
4795 {
4796   UNUSED(RTCx);
4797   WRITE_REG(TAMP->SCR, TAMP_SCR_CITAMP2F);
4798 }
4799 
4800 /**
4801   * @brief  Clear internal tamper 3 detection flag.
4802   * @rmtoll TAMP_SCR          CITAMP3F         LL_RTC_ClearFlag_ITAMP3
4803   * @param  RTCx RTC Instance
4804   * @retval None
4805   */
LL_RTC_ClearFlag_ITAMP3(const RTC_TypeDef * RTCx)4806 __STATIC_INLINE void LL_RTC_ClearFlag_ITAMP3(const RTC_TypeDef *RTCx)
4807 {
4808   UNUSED(RTCx);
4809   WRITE_REG(TAMP->SCR, TAMP_SCR_CITAMP3F);
4810 }
4811 
4812 /**
4813   * @brief  Clear internal tamper 4 detection flag.
4814   * @rmtoll TAMP_SCR          CITAMP4F         LL_RTC_ClearFlag_ITAMP4
4815   * @param  RTCx RTC Instance
4816   * @retval None
4817   */
LL_RTC_ClearFlag_ITAMP4(const RTC_TypeDef * RTCx)4818 __STATIC_INLINE void LL_RTC_ClearFlag_ITAMP4(const RTC_TypeDef *RTCx)
4819 {
4820   UNUSED(RTCx);
4821   WRITE_REG(TAMP->SCR, TAMP_SCR_CITAMP4F);
4822 }
4823 
4824 /**
4825   * @brief  Clear internal tamper 5 detection flag.
4826   * @rmtoll TAMP_SCR          CITAMP5F         LL_RTC_ClearFlag_ITAMP5
4827   * @param  RTCx RTC Instance
4828   * @retval None
4829   */
LL_RTC_ClearFlag_ITAMP5(const RTC_TypeDef * RTCx)4830 __STATIC_INLINE void LL_RTC_ClearFlag_ITAMP5(const RTC_TypeDef *RTCx)
4831 {
4832   UNUSED(RTCx);
4833   WRITE_REG(TAMP->SCR, TAMP_SCR_CITAMP5F);
4834 }
4835 
4836 /**
4837   * @brief  Clear internal tamper 6 detection flag.
4838   * @rmtoll TAMP_SCR          CITAMP6F         LL_RTC_ClearFlag_ITAMP6
4839   * @param  RTCx RTC Instance
4840   * @retval None
4841   */
LL_RTC_ClearFlag_ITAMP6(const RTC_TypeDef * RTCx)4842 __STATIC_INLINE void LL_RTC_ClearFlag_ITAMP6(const RTC_TypeDef *RTCx)
4843 {
4844   UNUSED(RTCx);
4845   WRITE_REG(TAMP->SCR, TAMP_SCR_CITAMP6F);
4846 }
4847 
4848 /**
4849   * @brief  Clear internal tamper 7 detection flag.
4850   * @rmtoll TAMP_SCR          CITAMP7F         LL_RTC_ClearFlag_ITAMP7
4851   * @param  RTCx RTC Instance
4852   * @retval None
4853   */
LL_RTC_ClearFlag_ITAMP7(const RTC_TypeDef * RTCx)4854 __STATIC_INLINE void LL_RTC_ClearFlag_ITAMP7(const RTC_TypeDef *RTCx)
4855 {
4856   UNUSED(RTCx);
4857   WRITE_REG(TAMP->SCR, TAMP_SCR_CITAMP7F);
4858 }
4859 
4860 /**
4861   * @brief  Clear internal tamper 8 detection flag.
4862   * @rmtoll TAMP_SCR          CITAMP8F         LL_RTC_ClearFlag_ITAMP8
4863   * @param  RTCx RTC Instance
4864   * @retval None
4865   */
LL_RTC_ClearFlag_ITAMP8(const RTC_TypeDef * RTCx)4866 __STATIC_INLINE void LL_RTC_ClearFlag_ITAMP8(const RTC_TypeDef *RTCx)
4867 {
4868   UNUSED(RTCx);
4869   WRITE_REG(TAMP->SCR, TAMP_SCR_CITAMP8F);
4870 }
4871 
4872 /**
4873   * @brief  Clear internal tamper 9 detection flag.
4874   * @rmtoll TAMP_SCR          CITAMP9F         LL_RTC_ClearFlag_ITAMP9
4875   * @param  RTCx RTC Instance
4876   * @retval None
4877   */
LL_RTC_ClearFlag_ITAMP9(const RTC_TypeDef * RTCx)4878 __STATIC_INLINE void LL_RTC_ClearFlag_ITAMP9(const RTC_TypeDef *RTCx)
4879 {
4880   UNUSED(RTCx);
4881   WRITE_REG(TAMP->SCR, TAMP_SCR_CITAMP9F);
4882 }
4883 
4884 /**
4885   * @brief  Clear internal tamper 11 detection flag.
4886   * @rmtoll TAMP_SCR          CITAMP11F         LL_RTC_ClearFlag_ITAMP11
4887   * @param  RTCx RTC Instance
4888   * @retval None
4889   */
LL_RTC_ClearFlag_ITAMP11(const RTC_TypeDef * RTCx)4890 __STATIC_INLINE void LL_RTC_ClearFlag_ITAMP11(const RTC_TypeDef *RTCx)
4891 {
4892   UNUSED(RTCx);
4893   WRITE_REG(TAMP->SCR, TAMP_SCR_CITAMP11F);
4894 }
4895 
4896 /**
4897   * @}
4898   */
4899 
4900 /** @defgroup RTC_LL_EF_SECURITY SECURITY_Management
4901   * @{
4902   */
4903 
4904 #if defined (CPU_IN_SECURE_STATE)
4905 /**
4906   * @brief  Set RTC secure level.
4907   * @note   secure features are relevant if LL_RTC_SECURE_FULL_NO.
4908   * @rmtoll RTC_SECCFGR           SEC           LL_RTC_SetRtcSecure
4909   * @rmtoll RTC_SECCFGR           INITSEC       LL_RTC_SetRtcSecure
4910   * @rmtoll RTC_SECCFGR           CALSEC        LL_RTC_SetRtcSecure
4911   * @rmtoll RTC_SECCFGR           TSSEC         LL_RTC_SetRtcSecure
4912   * @rmtoll RTC_SECCFGR           WUTSEC        LL_RTC_SetRtcSecure
4913   * @rmtoll RTC_SECCFGR           ALRASEC       LL_RTC_SetRtcSecure
4914   * @rmtoll RTC_SECCFGR           ALRBSEC       LL_RTC_SetRtcSecure
4915   * @param  RTCx RTC Instance
4916   * @param  rtcSecure This parameter can be a combination of the following values:
4917   *         @arg @ref LL_RTC_SECURE_FULL_YES
4918   *         @arg @ref LL_RTC_SECURE_FULL_NO
4919   *         @arg @ref LL_RTC_SECURE_FEATURE_INIT
4920   *         @arg @ref LL_RTC_SECURE_FEATURE_CAL
4921   *         @arg @ref LL_RTC_SECURE_FEATURE_TS
4922   *         @arg @ref LL_RTC_SECURE_FEATURE_WUT
4923   *         @arg @ref LL_RTC_SECURE_FEATURE_ALRA
4924   *         @arg @ref LL_RTC_SECURE_FEATURE_ALRB
4925 
4926   * @retval None
4927   */
LL_RTC_SetRtcSecure(RTC_TypeDef * RTCx,uint32_t rtcSecure)4928 __STATIC_INLINE void LL_RTC_SetRtcSecure(RTC_TypeDef *RTCx, uint32_t rtcSecure)
4929 {
4930   MODIFY_REG(RTCx->SECCFGR, RTC_SECCFGR_SEC | RTC_SECCFGR_INITSEC | RTC_SECCFGR_CALSEC | RTC_SECCFGR_TSSEC | \
4931              RTC_SECCFGR_WUTSEC | RTC_SECCFGR_ALRASEC | RTC_SECCFGR_ALRBSEC, rtcSecure);
4932 }
4933 #endif /* defined (CPU_IN_SECURE_STATE) */
4934 
4935 /**
4936   * @brief  Get RTC secure level.
4937   * @note   Secure features is relevant if LL_RTC_SECURE_FULL_NO.
4938   * @rmtoll RTC_SECCFGR           SEC           LL_RTC_SetRtcSecure
4939   * @rmtoll RTC_SECCFGR           INISEC        LL_RTC_SetRtcSecure
4940   * @rmtoll RTC_SECCFGR           CALSEC        LL_RTC_SetRtcSecure
4941   * @rmtoll RTC_SECCFGR           TSSEC         LL_RTC_SetRtcSecure
4942   * @rmtoll RTC_SECCFGR           WUTSEC        LL_RTC_SetRtcSecure
4943   * @rmtoll RTC_SECCFGR           ALRASEC       LL_RTC_SetRtcSecure
4944   * @rmtoll RTC_SECCFGR           ALRBSEC       LL_RTC_SetRtcSecure
4945   * @param  RTCx RTC Instance
4946   * @retval Combination of the following values:
4947   *         @arg @ref LL_RTC_SECURE_FULL_YES
4948   *         @arg @ref LL_RTC_SECURE_FULL_NO
4949   *         @arg @ref LL_RTC_SECURE_FEATURE_INIT
4950   *         @arg @ref LL_RTC_SECURE_FEATURE_CAL
4951   *         @arg @ref LL_RTC_SECURE_FEATURE_TS
4952   *         @arg @ref LL_RTC_SECURE_FEATURE_WUT
4953   *         @arg @ref LL_RTC_SECURE_FEATURE_ALRA
4954   *         @arg @ref LL_RTC_SECURE_FEATURE_ALRB
4955   */
LL_RTC_GetRtcSecure(const RTC_TypeDef * RTCx)4956 __STATIC_INLINE uint32_t LL_RTC_GetRtcSecure(const RTC_TypeDef *RTCx)
4957 {
4958   return READ_BIT(RTCx->SECCFGR, RTC_SECCFGR_SEC | RTC_SECCFGR_INITSEC | RTC_SECCFGR_CALSEC | RTC_SECCFGR_TSSEC | \
4959                   RTC_SECCFGR_WUTSEC | RTC_SECCFGR_ALRASEC | RTC_SECCFGR_ALRBSEC);
4960 }
4961 
4962 #if defined (CPU_IN_SECURE_STATE)
4963 /**
4964   * @brief  Set TAMPER secure level.
4965   * @rmtoll TAMP_SECCFGR          TAMPSEC           LL_RTC_SetTampSecure
4966   * @param  RTCx RTC Instance
4967   * @param  tampSecure This parameter can be one of the following values:
4968   *         @arg @ref LL_TAMP_SECURE_FULL_YES
4969   *         @arg @ref LL_TAMP_SECURE_FULL_NO
4970   * @retval None
4971   */
LL_RTC_SetTampSecure(const RTC_TypeDef * RTCx,uint32_t tampSecure)4972 __STATIC_INLINE void LL_RTC_SetTampSecure(const RTC_TypeDef *RTCx, uint32_t tampSecure)
4973 {
4974   UNUSED(RTCx);
4975   MODIFY_REG(TAMP->SECCFGR, TAMP_SECCFGR_TAMPSEC, tampSecure);
4976 }
4977 #endif /* defined (CPU_IN_SECURE_STATE) */
4978 
4979 /**
4980   * @brief  Get TAMPER secure level.
4981   * @rmtoll TAMP_SECCFGR          TAMPSEC           LL_RTC_GetTampSecure
4982   * @param  RTCx RTC Instance
4983   * @retval This parameter can be one of the following values:
4984   *         @arg @ref LL_TAMP_SECURE_FULL_YES
4985   *         @arg @ref LL_TAMP_SECURE_FULL_NO
4986   */
LL_RTC_GetTampSecure(const RTC_TypeDef * RTCx)4987 __STATIC_INLINE uint32_t LL_RTC_GetTampSecure(const RTC_TypeDef *RTCx)
4988 {
4989   UNUSED(RTCx);
4990   return READ_BIT(TAMP->SECCFGR, TAMP_SECCFGR_TAMPSEC);
4991 }
4992 
4993 /**
4994   * @}
4995   */
4996 
4997 /** @defgroup RTC_LL_EF_PRIVILEGE PRIVILEGE_Management
4998   * @{
4999   */
5000 
5001 /**
5002   * @brief  Set RTC privilege level.
5003   * @note   Privilege features are relevant if LL_RTC_PRIVILEGE_FULL_NO.
5004   * @rmtoll RTC_PRIVCFGR           PRIV              LL_RTC_SetRtcPrivilege
5005   * @rmtoll RTC_PRIVCFGR           INITPRIV          LL_RTC_SetRtcPrivilege
5006   * @rmtoll RTC_PRIVCFGR           CALPRIV           LL_RTC_SetRtcPrivilege
5007   * @rmtoll RTC_PRIVCFGR           TSPRIV            LL_RTC_SetRtcPrivilege
5008   * @rmtoll RTC_PRIVCFGR           WUTPRIV           LL_RTC_SetRtcPrivilege
5009   * @rmtoll RTC_PRIVCFGR           ALRAPRIV          LL_RTC_SetRtcPrivilege
5010   * @rmtoll RTC_PRIVCFGR           ALRBPRIV          LL_RTC_SetRtcPrivilege
5011   * @param  RTCx RTC Instance
5012   * @param  rtcPrivilege This parameter can be a combination of the following values:
5013   *         @arg @ref LL_RTC_PRIVILEGE_FULL_YES
5014   *         @arg @ref LL_RTC_PRIVILEGE_FULL_NO
5015   *         @arg @ref LL_RTC_PRIVILEGE_FEATURE_INIT
5016   *         @arg @ref LL_RTC_PRIVILEGE_FEATURE_CAL
5017   *         @arg @ref LL_RTC_PRIVILEGE_FEATURE_TS
5018   *         @arg @ref LL_RTC_PRIVILEGE_FEATURE_WUT
5019   *         @arg @ref LL_RTC_PRIVILEGE_FEATURE_ALRA
5020   *         @arg @ref LL_RTC_PRIVILEGE_FEATURE_ALRB
5021   * @retval None
5022   */
LL_RTC_SetRtcPrivilege(RTC_TypeDef * RTCx,uint32_t rtcPrivilege)5023 __STATIC_INLINE void LL_RTC_SetRtcPrivilege(RTC_TypeDef *RTCx, uint32_t rtcPrivilege)
5024 {
5025   MODIFY_REG(RTCx->PRIVCFGR, RTC_PRIVCFGR_PRIV | RTC_PRIVCFGR_INITPRIV | RTC_PRIVCFGR_CALPRIV | RTC_PRIVCFGR_TSPRIV | \
5026              RTC_PRIVCFGR_WUTPRIV | RTC_PRIVCFGR_ALRAPRIV | RTC_PRIVCFGR_ALRBPRIV, rtcPrivilege);
5027 }
5028 
5029 /**
5030   * @brief  Get RTC privilege level.
5031   * @note   Privilege features are relevant if LL_RTC_PRIVILEGE_FULL_NO.
5032   * @rmtoll RTC_PRIVCFGR           PRIV              LL_RTC_SetRtcPrivilege
5033   * @rmtoll RTC_PRIVCFGR           INITPRIV          LL_RTC_SetRtcPrivilege
5034   * @rmtoll RTC_PRIVCFGR           CALPRIV           LL_RTC_SetRtcPrivilege
5035   * @rmtoll RTC_PRIVCFGR           TSPRIV            LL_RTC_SetRtcPrivilege
5036   * @rmtoll RTC_PRIVCFGR           WUTPRIV           LL_RTC_SetRtcPrivilege
5037   * @rmtoll RTC_PRIVCFGR           ALRAPRIV          LL_RTC_SetRtcPrivilege
5038   * @rmtoll RTC_PRIVCFGR           ALRBPRIV          LL_RTC_SetRtcPrivilege
5039   * @param  RTCx RTC Instance
5040   * @retval Combination of the following values:
5041   *         @arg @ref LL_RTC_PRIVILEGE_FULL_YES
5042   *         @arg @ref LL_RTC_PRIVILEGE_FULL_NO
5043   *         @arg @ref LL_RTC_PRIVILEGE_FEATURE_INIT
5044   *         @arg @ref LL_RTC_PRIVILEGE_FEATURE_CAL
5045   *         @arg @ref LL_RTC_PRIVILEGE_FEATURE_TS
5046   *         @arg @ref LL_RTC_PRIVILEGE_FEATURE_WUT
5047   *         @arg @ref LL_RTC_PRIVILEGE_FEATURE_ALRA
5048   *         @arg @ref LL_RTC_PRIVILEGE_FEATURE_ALRB
5049   */
LL_RTC_GetRtcPrivilege(const RTC_TypeDef * RTCx)5050 __STATIC_INLINE uint32_t LL_RTC_GetRtcPrivilege(const RTC_TypeDef *RTCx)
5051 {
5052   return READ_BIT(RTCx->PRIVCFGR, RTC_PRIVCFGR_PRIV   | RTC_PRIVCFGR_INITPRIV | RTC_PRIVCFGR_CALPRIV  | \
5053                   RTC_PRIVCFGR_TSPRIV | RTC_PRIVCFGR_WUTPRIV  | RTC_PRIVCFGR_ALRAPRIV | \
5054                   RTC_PRIVCFGR_ALRBPRIV);
5055 }
5056 
5057 /**
5058   * @brief  Set TAMPER privilege level.
5059   * @rmtoll TAMP_PRIVCFGR          TAMPPRIV           LL_RTC_SetTampPrivilege
5060   * @param  RTCx RTC Instance
5061   * @param  tampPrivilege This parameter can be one of the following values:
5062   *         @arg @ref LL_TAMP_PRIVILEGE_FULL_YES
5063   *         @arg @ref LL_TAMP_PRIVILEGE_FULL_NO
5064   * @retval None
5065   */
LL_RTC_SetTampPrivilege(const RTC_TypeDef * RTCx,uint32_t tampPrivilege)5066 __STATIC_INLINE void LL_RTC_SetTampPrivilege(const RTC_TypeDef *RTCx, uint32_t tampPrivilege)
5067 {
5068   UNUSED(RTCx);
5069   MODIFY_REG(TAMP->PRIVCFGR, TAMP_PRIVCFGR_TAMPPRIV, tampPrivilege);
5070 }
5071 
5072 /**
5073   * @brief  Get TAMPER privilege level.
5074   * @rmtoll TAMP_PRIVCFGR          TAMPPRIV           LL_RTC_GetTampPrivilege
5075   * @param  RTCx RTC Instance
5076   * @retval This parameter can be one of the following values:
5077   *         @arg @ref LL_TAMP_PRIVILEGE_FULL_YES
5078   *         @arg @ref LL_TAMP_PRIVILEGE_FULL_NO
5079   */
LL_RTC_GetTampPrivilege(const RTC_TypeDef * RTCx)5080 __STATIC_INLINE uint32_t LL_RTC_GetTampPrivilege(const RTC_TypeDef *RTCx)
5081 {
5082   UNUSED(RTCx);
5083   return READ_BIT(TAMP->PRIVCFGR, TAMP_PRIVCFGR_TAMPPRIV);
5084 }
5085 
5086 /**
5087   * @brief  Set Backup Registers privilege level.
5088   * @note   bckupRegisterPrivilege is only writable in secure mode or if trustzone is disabled
5089   * @rmtoll TAMP_PRIVCFGR          BKPWPRIV           LL_RTC_SetBackupRegisterPrivilege
5090   * @rmtoll TAMP_PRIVCFGR          BKPRWPRIV          LL_RTC_SetBackupRegisterPrivilege
5091   * @param  RTCx RTC Instance
5092   * @param  bckupRegisterPrivilege This parameter can be one of the following values:
5093   *         @arg @ref LL_RTC_PRIVILEGE_BKUP_ZONE_NONE
5094   *         @arg @ref LL_RTC_PRIVILEGE_BKUP_ZONE_1
5095   *         @arg @ref LL_RTC_PRIVILEGE_BKUP_ZONE_2
5096   *         @arg @ref LL_RTC_PRIVILEGE_BKUP_ZONE_ALL
5097   * @retval None
5098   */
LL_RTC_SetBackupRegisterPrivilege(const RTC_TypeDef * RTCx,uint32_t bckupRegisterPrivilege)5099 __STATIC_INLINE void LL_RTC_SetBackupRegisterPrivilege(const RTC_TypeDef *RTCx, uint32_t bckupRegisterPrivilege)
5100 {
5101   UNUSED(RTCx);
5102   MODIFY_REG(TAMP->PRIVCFGR, (TAMP_PRIVCFGR_BKPWPRIV | TAMP_PRIVCFGR_BKPRWPRIV), bckupRegisterPrivilege);
5103 }
5104 
5105 /**
5106   * @brief  Get Backup Registers privilege level.
5107   * @rmtoll TAMP_PRIVCFGR          BKPWPRIV           LL_RTC_GetBackupRegisterPrivilege
5108   * @rmtoll TAMP_PRIVCFGR          BKPRWPRIV          LL_RTC_GetBackupRegisterPrivilege
5109   * @param  RTCx RTC Instance
5110   * @retval This parameter can be one of the following values:
5111   *         @arg @ref LL_RTC_PRIVILEGE_BKUP_ZONE_NONE
5112   *         @arg @ref LL_RTC_PRIVILEGE_BKUP_ZONE_1
5113   *         @arg @ref LL_RTC_PRIVILEGE_BKUP_ZONE_2
5114   *         @arg @ref LL_RTC_PRIVILEGE_BKUP_ZONE_ALL
5115   */
LL_RTC_GetBackupRegisterPrivilege(const RTC_TypeDef * RTCx)5116 __STATIC_INLINE uint32_t LL_RTC_GetBackupRegisterPrivilege(const RTC_TypeDef *RTCx)
5117 {
5118   UNUSED(RTCx);
5119   return READ_BIT(TAMP->PRIVCFGR, (TAMP_PRIVCFGR_BKPWPRIV | TAMP_PRIVCFGR_BKPRWPRIV));
5120 }
5121 /**
5122   * @}
5123   */
5124 
5125 /** @defgroup RTC_LL_EF_BACKUP_REG_PROTECTION PROTECTION_BACKUP_REG_Management
5126   * @brief    Backup register protection is common to security and privilege.
5127   * @{
5128   */
5129 
5130 /**
5131   * @brief  Set Backup registers protection level.
5132   * @note   Zone 1 : read protection write protection
5133   * @note   Zone 2 : read non-protection  write protection
5134   * @note   Zone 3 : read non-protection  write non-protection
5135   * @note   zone 1 : start from 0 to startZone2 start value
5136   * @note   zone 2 : start from startZone2 start value to startZone3 start value
5137   * @note   zone 3 : start from to startZone3 to the end of BACKUPREG
5138   * @note   Warning : this parameter is only writable in secure mode or if trustzone is disabled
5139   * @rmtoll TAMP_SECCFGR          BKPWSEC           LL_RTC_SetBackupRegProtection
5140   * @rmtoll TAMP_SECCFGR          BKPRWSEC          LL_RTC_SetBackupRegProtection
5141   * @param  RTCx RTC Instance
5142   * @param  startZone2 This parameter can be one of the following values:
5143   *         @arg @ref LL_RTC_BKP_DR0
5144   *         @arg @ref LL_RTC_BKP_DR1
5145   *         @arg @ref LL_RTC_BKP_DR2
5146   *         @arg @ref LL_RTC_BKP_DR3
5147   *         @arg @ref LL_RTC_BKP_DR4
5148   *         @arg      LL_RTC_BKP_DRx ...
5149   * @param  startZone3 This parameter can be one of the following values:
5150   *         @arg @ref LL_RTC_BKP_DR0
5151   *         @arg @ref LL_RTC_BKP_DR1
5152   *         @arg @ref LL_RTC_BKP_DR2
5153   *         @arg @ref LL_RTC_BKP_DR3
5154   *         @arg @ref LL_RTC_BKP_DR4
5155   *         @arg      LL_RTC_BKP_DRx ...
5156   * @retval None
5157   */
LL_RTC_SetBackupRegProtection(const RTC_TypeDef * RTCx,uint32_t startZone2,uint32_t startZone3)5158 __STATIC_INLINE void LL_RTC_SetBackupRegProtection(const RTC_TypeDef *RTCx, uint32_t startZone2, uint32_t startZone3)
5159 {
5160   UNUSED(RTCx);
5161   MODIFY_REG(TAMP->SECCFGR, (TAMP_SECCFGR_BKPRWSEC_Msk | TAMP_SECCFGR_BKPWSEC_Msk),
5162              (startZone2 << TAMP_SECCFGR_BKPRWSEC_Pos) | (startZone3 << TAMP_SECCFGR_BKPWSEC_Pos));
5163 }
5164 
5165 /**
5166   * @brief  Get Backup registers protection level start zone 2.
5167   * @note   Zone 1 : read protection write protection
5168   * @note   Zone 2 : read non-protection/non-privile  write protection
5169   * @note   Zone 3 : read non-protection  write non-protection
5170   * @rmtoll TAMP_SECCFGR          BKPRWSEC         LL_RTC_GetBackupRegProtectionStartZone2
5171   * @param  RTCx RTC Instance
5172   * @retval Start zone 2
5173   */
LL_RTC_GetBackupRegProtectionStartZone2(const RTC_TypeDef * RTCx)5174 __STATIC_INLINE uint32_t LL_RTC_GetBackupRegProtectionStartZone2(const RTC_TypeDef *RTCx)
5175 {
5176   UNUSED(RTCx);
5177   return READ_BIT(TAMP->SECCFGR, TAMP_SECCFGR_BKPRWSEC_Msk) >> TAMP_SECCFGR_BKPRWSEC_Pos;
5178 }
5179 
5180 /**
5181   * @brief  Get Backup registers protection level start zone 3.
5182   * @note   Zone 1 : read protection write protection
5183   * @note   Zone 2 : read non-protection  write protection
5184   * @note   Zone 3 : read non-protection  write non-protection
5185   * @rmtoll TAMP_SECCFGR          BKPWSEC           LL_RTC_GetBackupRegProtectionStartZone3
5186   * @param  RTCx RTC Instance
5187   * @retval Start zone 2
5188   */
LL_RTC_GetBackupRegProtectionStartZone3(const RTC_TypeDef * RTCx)5189 __STATIC_INLINE uint32_t LL_RTC_GetBackupRegProtectionStartZone3(const RTC_TypeDef *RTCx)
5190 {
5191   UNUSED(RTCx);
5192   return READ_BIT(TAMP->SECCFGR, TAMP_SECCFGR_BKPWSEC_Msk) >> TAMP_SECCFGR_BKPWSEC_Pos;
5193 }
5194 /**
5195   * @}
5196   */
5197 
5198 /** @defgroup RTC_LL_EF_IT_Management IT_Management
5199   * @{
5200   */
5201 
5202 /**
5203   * @brief  Enable Time-stamp interrupt
5204   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
5205   * @rmtoll RTC_CR          TSIE         LL_RTC_EnableIT_TS
5206   * @param  RTCx RTC Instance
5207   * @retval None
5208   */
LL_RTC_EnableIT_TS(RTC_TypeDef * RTCx)5209 __STATIC_INLINE void LL_RTC_EnableIT_TS(RTC_TypeDef *RTCx)
5210 {
5211   SET_BIT(RTCx->CR, RTC_CR_TSIE);
5212 }
5213 
5214 /**
5215   * @brief  Disable Time-stamp interrupt
5216   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
5217   * @rmtoll RTC_CR          TSIE         LL_RTC_DisableIT_TS
5218   * @param  RTCx RTC Instance
5219   * @retval None
5220   */
LL_RTC_DisableIT_TS(RTC_TypeDef * RTCx)5221 __STATIC_INLINE void LL_RTC_DisableIT_TS(RTC_TypeDef *RTCx)
5222 {
5223   CLEAR_BIT(RTCx->CR, RTC_CR_TSIE);
5224 }
5225 
5226 /**
5227   * @brief  Enable Wakeup timer interrupt
5228   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
5229   * @rmtoll RTC_CR          WUTIE         LL_RTC_EnableIT_WUT
5230   * @param  RTCx RTC Instance
5231   * @retval None
5232   */
LL_RTC_EnableIT_WUT(RTC_TypeDef * RTCx)5233 __STATIC_INLINE void LL_RTC_EnableIT_WUT(RTC_TypeDef *RTCx)
5234 {
5235   SET_BIT(RTCx->CR, RTC_CR_WUTIE);
5236 }
5237 
5238 /**
5239   * @brief  Disable Wakeup timer interrupt
5240   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
5241   * @rmtoll RTC_CR          WUTIE         LL_RTC_DisableIT_WUT
5242   * @param  RTCx RTC Instance
5243   * @retval None
5244   */
LL_RTC_DisableIT_WUT(RTC_TypeDef * RTCx)5245 __STATIC_INLINE void LL_RTC_DisableIT_WUT(RTC_TypeDef *RTCx)
5246 {
5247   CLEAR_BIT(RTCx->CR, RTC_CR_WUTIE);
5248 }
5249 
5250 /**
5251   * @brief  Enable Alarm B interrupt
5252   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
5253   * @rmtoll RTC_CR           ALRBIE        LL_RTC_EnableIT_ALRB
5254   * @param  RTCx RTC Instance
5255   * @retval None
5256   */
LL_RTC_EnableIT_ALRB(RTC_TypeDef * RTCx)5257 __STATIC_INLINE void LL_RTC_EnableIT_ALRB(RTC_TypeDef *RTCx)
5258 {
5259   SET_BIT(RTCx->CR, RTC_CR_ALRBIE);
5260 }
5261 
5262 /**
5263   * @brief  Disable Alarm B interrupt
5264   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
5265   * @rmtoll RTC_CR           ALRBIE        LL_RTC_DisableIT_ALRB
5266   * @param  RTCx RTC Instance
5267   * @retval None
5268   */
LL_RTC_DisableIT_ALRB(RTC_TypeDef * RTCx)5269 __STATIC_INLINE void LL_RTC_DisableIT_ALRB(RTC_TypeDef *RTCx)
5270 {
5271   CLEAR_BIT(RTCx->CR, RTC_CR_ALRBIE);
5272 }
5273 
5274 /**
5275   * @brief  Enable Alarm A interrupt
5276   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
5277   * @rmtoll RTC_CR           ALRAIE        LL_RTC_EnableIT_ALRA
5278   * @param  RTCx RTC Instance
5279   * @retval None
5280   */
LL_RTC_EnableIT_ALRA(RTC_TypeDef * RTCx)5281 __STATIC_INLINE void LL_RTC_EnableIT_ALRA(RTC_TypeDef *RTCx)
5282 {
5283   SET_BIT(RTCx->CR, RTC_CR_ALRAIE);
5284 }
5285 
5286 /**
5287   * @brief  Disable Alarm A interrupt
5288   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
5289   * @rmtoll RTC_CR           ALRAIE        LL_RTC_DisableIT_ALRA
5290   * @param  RTCx RTC Instance
5291   * @retval None
5292   */
LL_RTC_DisableIT_ALRA(RTC_TypeDef * RTCx)5293 __STATIC_INLINE void LL_RTC_DisableIT_ALRA(RTC_TypeDef *RTCx)
5294 {
5295   CLEAR_BIT(RTCx->CR, RTC_CR_ALRAIE);
5296 }
5297 
5298 /**
5299   * @brief  Enable SSR Underflow interrupt
5300   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
5301   * @rmtoll RTC_CR           SSRUIE        LL_RTC_EnableIT_SSRU
5302   * @param  RTCx RTC Instance
5303   * @retval None
5304   */
LL_RTC_EnableIT_SSRU(RTC_TypeDef * RTCx)5305 __STATIC_INLINE void LL_RTC_EnableIT_SSRU(RTC_TypeDef *RTCx)
5306 {
5307   SET_BIT(RTCx->CR, RTC_CR_SSRUIE);
5308 }
5309 
5310 /**
5311   * @brief  Disable SSR Underflow interrupt
5312   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
5313   * @rmtoll RTC_CR           SSRUIE        LL_RTC_DisableIT_SSRU
5314   * @param  RTCx RTC Instance
5315   * @retval None
5316   */
LL_RTC_DisableIT_SSRU(RTC_TypeDef * RTCx)5317 __STATIC_INLINE void LL_RTC_DisableIT_SSRU(RTC_TypeDef *RTCx)
5318 {
5319   CLEAR_BIT(RTCx->CR, RTC_CR_SSRUIE);
5320 }
5321 
5322 /**
5323   * @brief  Check if Time-stamp interrupt is enabled or not
5324   * @rmtoll RTC_CR           TSIE          LL_RTC_IsEnabledIT_TS
5325   * @param  RTCx RTC Instance
5326   * @retval State of bit (1 or 0).
5327   */
LL_RTC_IsEnabledIT_TS(const RTC_TypeDef * RTCx)5328 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TS(const RTC_TypeDef *RTCx)
5329 {
5330   return ((READ_BIT(RTCx->CR, RTC_CR_TSIE) == (RTC_CR_TSIE)) ? 1U : 0U);
5331 }
5332 
5333 /**
5334   * @brief  Check if Wakeup timer interrupt is enabled or not
5335   * @rmtoll RTC_CR           WUTIE         LL_RTC_IsEnabledIT_WUT
5336   * @param  RTCx RTC Instance
5337   * @retval State of bit (1 or 0).
5338   */
LL_RTC_IsEnabledIT_WUT(const RTC_TypeDef * RTCx)5339 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_WUT(const RTC_TypeDef *RTCx)
5340 {
5341   return ((READ_BIT(RTCx->CR, RTC_CR_WUTIE) == (RTC_CR_WUTIE)) ? 1U : 0U);
5342 }
5343 
5344 /**
5345   * @brief  Check if Alarm B interrupt is enabled or not
5346   * @rmtoll RTC_CR           ALRBIE        LL_RTC_IsEnabledIT_ALRB
5347   * @param  RTCx RTC Instance
5348   * @retval State of bit (1 or 0).
5349   */
LL_RTC_IsEnabledIT_ALRB(const RTC_TypeDef * RTCx)5350 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRB(const RTC_TypeDef *RTCx)
5351 {
5352   return ((READ_BIT(RTCx->CR, RTC_CR_ALRBIE) == (RTC_CR_ALRBIE)) ? 1U : 0U);
5353 }
5354 
5355 /**
5356   * @brief  Check if Alarm A interrupt is enabled or not
5357   * @rmtoll RTC_CR           ALRAIE        LL_RTC_IsEnabledIT_ALRA
5358   * @param  RTCx RTC Instance
5359   * @retval State of bit (1 or 0).
5360   */
LL_RTC_IsEnabledIT_ALRA(const RTC_TypeDef * RTCx)5361 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRA(const RTC_TypeDef *RTCx)
5362 {
5363   return ((READ_BIT(RTCx->CR, RTC_CR_ALRAIE) == (RTC_CR_ALRAIE)) ? 1U : 0U);
5364 }
5365 
5366 /**
5367   * @brief  Check if SSR Underflow interrupt is enabled or not
5368   * @rmtoll RTC_CR           SSRUIE        LL_RTC_IsEnabledIT_SSRU
5369   * @param  RTCx RTC Instance
5370   * @retval State of bit (1 or 0).
5371   */
LL_RTC_IsEnabledIT_SSRU(const RTC_TypeDef * RTCx)5372 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_SSRU(const RTC_TypeDef *RTCx)
5373 {
5374   return ((READ_BIT(RTCx->CR, RTC_CR_SSRUIE) == (RTC_CR_SSRUIE)) ? 1U : 0U);
5375 }
5376 
5377 /**
5378   * @brief  Enable tamper 1 interrupt.
5379   * @rmtoll TAMP_IER           TAMP1IE          LL_RTC_EnableIT_TAMP1
5380   * @param  RTCx RTC Instance
5381   * @retval None
5382   */
LL_RTC_EnableIT_TAMP1(const RTC_TypeDef * RTCx)5383 __STATIC_INLINE void LL_RTC_EnableIT_TAMP1(const RTC_TypeDef *RTCx)
5384 {
5385   UNUSED(RTCx);
5386   SET_BIT(TAMP->IER, TAMP_IER_TAMP1IE);
5387 }
5388 
5389 /**
5390   * @brief  Disable tamper 1 interrupt.
5391   * @rmtoll TAMP_IER           TAMP1IE          LL_RTC_DisableIT_TAMP1
5392   * @param  RTCx RTC Instance
5393   * @retval None
5394   */
LL_RTC_DisableIT_TAMP1(const RTC_TypeDef * RTCx)5395 __STATIC_INLINE void LL_RTC_DisableIT_TAMP1(const RTC_TypeDef *RTCx)
5396 {
5397   UNUSED(RTCx);
5398   CLEAR_BIT(TAMP->IER, TAMP_IER_TAMP1IE);
5399 }
5400 
5401 /**
5402   * @brief  Enable tamper 2 interrupt.
5403   * @rmtoll TAMP_IER           TAMP2IE          LL_RTC_EnableIT_TAMP2
5404   * @param  RTCx RTC Instance
5405   * @retval None
5406   */
LL_RTC_EnableIT_TAMP2(const RTC_TypeDef * RTCx)5407 __STATIC_INLINE void LL_RTC_EnableIT_TAMP2(const RTC_TypeDef *RTCx)
5408 {
5409   UNUSED(RTCx);
5410   SET_BIT(TAMP->IER, TAMP_IER_TAMP2IE);
5411 }
5412 
5413 /**
5414   * @brief  Disable tamper 2 interrupt.
5415   * @rmtoll TAMP_IER           TAMP2IE          LL_RTC_DisableIT_TAMP2
5416   * @param  RTCx RTC Instance
5417   * @retval None
5418   */
LL_RTC_DisableIT_TAMP2(const RTC_TypeDef * RTCx)5419 __STATIC_INLINE void LL_RTC_DisableIT_TAMP2(const RTC_TypeDef *RTCx)
5420 {
5421   UNUSED(RTCx);
5422   CLEAR_BIT(TAMP->IER, TAMP_IER_TAMP2IE);
5423 }
5424 
5425 /**
5426   * @brief  Enable tamper 3 interrupt.
5427   * @rmtoll TAMP_IER           TAMP3IE          LL_RTC_EnableIT_TAMP3
5428   * @param  RTCx RTC Instance
5429   * @retval None
5430   */
LL_RTC_EnableIT_TAMP3(const RTC_TypeDef * RTCx)5431 __STATIC_INLINE void LL_RTC_EnableIT_TAMP3(const RTC_TypeDef *RTCx)
5432 {
5433   UNUSED(RTCx);
5434   SET_BIT(TAMP->IER, TAMP_IER_TAMP3IE);
5435 }
5436 
5437 /**
5438   * @brief  Disable tamper 3 interrupt.
5439   * @rmtoll TAMP_IER           TAMP3IE          LL_RTC_DisableIT_TAMP3
5440   * @param  RTCx RTC Instance
5441   * @retval None
5442   */
LL_RTC_DisableIT_TAMP3(const RTC_TypeDef * RTCx)5443 __STATIC_INLINE void LL_RTC_DisableIT_TAMP3(const RTC_TypeDef *RTCx)
5444 {
5445   UNUSED(RTCx);
5446   CLEAR_BIT(TAMP->IER, TAMP_IER_TAMP3IE);
5447 }
5448 
5449 /**
5450   * @brief  Enable tamper 4 interrupt.
5451   * @rmtoll TAMP_IER           TAMP4IE          LL_RTC_EnableIT_TAMP4
5452   * @param  RTCx RTC Instance
5453   * @retval None
5454   */
LL_RTC_EnableIT_TAMP4(const RTC_TypeDef * RTCx)5455 __STATIC_INLINE void LL_RTC_EnableIT_TAMP4(const RTC_TypeDef *RTCx)
5456 {
5457   UNUSED(RTCx);
5458   SET_BIT(TAMP->IER, TAMP_IER_TAMP4IE);
5459 }
5460 
5461 /**
5462   * @brief  Disable tamper 4 interrupt.
5463   * @rmtoll TAMP_IER           TAMP4IE          LL_RTC_DisableIT_TAMP4
5464   * @param  RTCx RTC Instance
5465   * @retval None
5466   */
LL_RTC_DisableIT_TAMP4(const RTC_TypeDef * RTCx)5467 __STATIC_INLINE void LL_RTC_DisableIT_TAMP4(const RTC_TypeDef *RTCx)
5468 {
5469   UNUSED(RTCx);
5470   CLEAR_BIT(TAMP->IER, TAMP_IER_TAMP4IE);
5471 }
5472 
5473 /**
5474   * @brief  Enable tamper 5 interrupt.
5475   * @rmtoll TAMP_IER           TAMP5IE          LL_RTC_EnableIT_TAMP5
5476   * @param  RTCx RTC Instance
5477   * @retval None
5478   */
LL_RTC_EnableIT_TAMP5(const RTC_TypeDef * RTCx)5479 __STATIC_INLINE void LL_RTC_EnableIT_TAMP5(const RTC_TypeDef *RTCx)
5480 {
5481   UNUSED(RTCx);
5482   SET_BIT(TAMP->IER, TAMP_IER_TAMP5IE);
5483 }
5484 
5485 /**
5486   * @brief  Disable tamper 5 interrupt.
5487   * @rmtoll TAMP_IER           TAMP5IE          LL_RTC_DisableIT_TAMP5
5488   * @param  RTCx RTC Instance
5489   * @retval None
5490   */
LL_RTC_DisableIT_TAMP5(const RTC_TypeDef * RTCx)5491 __STATIC_INLINE void LL_RTC_DisableIT_TAMP5(const RTC_TypeDef *RTCx)
5492 {
5493   UNUSED(RTCx);
5494   CLEAR_BIT(TAMP->IER, TAMP_IER_TAMP5IE);
5495 }
5496 
5497 /**
5498   * @brief  Enable tamper 6 interrupt.
5499   * @rmtoll TAMP_IER           TAMP6IE          LL_RTC_EnableIT_TAMP6
5500   * @param  RTCx RTC Instance
5501   * @retval None
5502   */
LL_RTC_EnableIT_TAMP6(const RTC_TypeDef * RTCx)5503 __STATIC_INLINE void LL_RTC_EnableIT_TAMP6(const RTC_TypeDef *RTCx)
5504 {
5505   UNUSED(RTCx);
5506   SET_BIT(TAMP->IER, TAMP_IER_TAMP6IE);
5507 }
5508 
5509 /**
5510   * @brief  Disable tamper 6 interrupt.
5511   * @rmtoll TAMP_IER           TAMP6IE          LL_RTC_DisableIT_TAMP6
5512   * @param  RTCx RTC Instance
5513   * @retval None
5514   */
LL_RTC_DisableIT_TAMP6(const RTC_TypeDef * RTCx)5515 __STATIC_INLINE void LL_RTC_DisableIT_TAMP6(const RTC_TypeDef *RTCx)
5516 {
5517   UNUSED(RTCx);
5518   CLEAR_BIT(TAMP->IER, TAMP_IER_TAMP6IE);
5519 }
5520 
5521 /**
5522   * @brief  Enable tamper 7 interrupt.
5523   * @rmtoll TAMP_IER           TAMP7IE          LL_RTC_EnableIT_TAMP7
5524   * @param  RTCx RTC Instance
5525   * @retval None
5526   */
LL_RTC_EnableIT_TAMP7(const RTC_TypeDef * RTCx)5527 __STATIC_INLINE void LL_RTC_EnableIT_TAMP7(const RTC_TypeDef *RTCx)
5528 {
5529   UNUSED(RTCx);
5530   SET_BIT(TAMP->IER, TAMP_IER_TAMP7IE);
5531 }
5532 
5533 /**
5534   * @brief  Disable tamper 7 interrupt.
5535   * @rmtoll TAMP_IER           TAMP7IE          LL_RTC_DisableIT_TAMP7
5536   * @param  RTCx RTC Instance
5537   * @retval None
5538   */
LL_RTC_DisableIT_TAMP7(const RTC_TypeDef * RTCx)5539 __STATIC_INLINE void LL_RTC_DisableIT_TAMP7(const RTC_TypeDef *RTCx)
5540 {
5541   UNUSED(RTCx);
5542   CLEAR_BIT(TAMP->IER, TAMP_IER_TAMP7IE);
5543 }
5544 
5545 /**
5546   * @brief  Enable internal tamper 1 interrupt.
5547   * @rmtoll TAMP_IER           ITAMP1IE          LL_RTC_EnableIT_ITAMP1
5548   * @param  RTCx RTC Instance
5549   * @retval None
5550   */
LL_RTC_EnableIT_ITAMP1(const RTC_TypeDef * RTCx)5551 __STATIC_INLINE void LL_RTC_EnableIT_ITAMP1(const RTC_TypeDef *RTCx)
5552 {
5553   UNUSED(RTCx);
5554   SET_BIT(TAMP->IER, TAMP_IER_ITAMP1IE);
5555 }
5556 
5557 /**
5558   * @brief  Disable internal tamper 1 interrupt.
5559   * @rmtoll TAMP_IER           ITAMP1IE          LL_RTC_DisableIT_ITAMP1
5560   * @param  RTCx RTC Instance
5561   * @retval None
5562   */
LL_RTC_DisableIT_ITAMP1(const RTC_TypeDef * RTCx)5563 __STATIC_INLINE void LL_RTC_DisableIT_ITAMP1(const RTC_TypeDef *RTCx)
5564 {
5565   UNUSED(RTCx);
5566   CLEAR_BIT(TAMP->IER, TAMP_IER_ITAMP1IE);
5567 }
5568 
5569 /**
5570   * @brief  Enable internal tamper 2 interrupt.
5571   * @rmtoll TAMP_IER           ITAMP2IE          LL_RTC_EnableIT_ITAMP2
5572   * @param  RTCx RTC Instance
5573   * @retval None
5574   */
LL_RTC_EnableIT_ITAMP2(const RTC_TypeDef * RTCx)5575 __STATIC_INLINE void LL_RTC_EnableIT_ITAMP2(const RTC_TypeDef *RTCx)
5576 {
5577   UNUSED(RTCx);
5578   SET_BIT(TAMP->IER, TAMP_IER_ITAMP2IE);
5579 }
5580 
5581 /**
5582   * @brief  Disable internal tamper 2 interrupt.
5583   * @rmtoll TAMP_IER           ITAMP2IE          LL_RTC_DisableIT_ITAMP2
5584   * @param  RTCx RTC Instance
5585   * @retval None
5586   */
LL_RTC_DisableIT_ITAMP2(const RTC_TypeDef * RTCx)5587 __STATIC_INLINE void LL_RTC_DisableIT_ITAMP2(const RTC_TypeDef *RTCx)
5588 {
5589   UNUSED(RTCx);
5590   CLEAR_BIT(TAMP->IER, TAMP_IER_ITAMP2IE);
5591 }
5592 
5593 /**
5594   * @brief  Enable internal tamper 3 interrupt.
5595   * @rmtoll TAMP_IER           ITAMP3IE          LL_RTC_EnableIT_ITAMP3
5596   * @param  RTCx RTC Instance
5597   * @retval None
5598   */
LL_RTC_EnableIT_ITAMP3(const RTC_TypeDef * RTCx)5599 __STATIC_INLINE void LL_RTC_EnableIT_ITAMP3(const RTC_TypeDef *RTCx)
5600 {
5601   UNUSED(RTCx);
5602   SET_BIT(TAMP->IER, TAMP_IER_ITAMP3IE);
5603 }
5604 
5605 /**
5606   * @brief  Disable internal tamper 3 interrupt.
5607   * @rmtoll TAMP_IER           ITAMP3IE          LL_RTC_DisableIT_ITAMP3
5608   * @param  RTCx RTC Instance
5609   * @retval None
5610   */
LL_RTC_DisableIT_ITAMP3(const RTC_TypeDef * RTCx)5611 __STATIC_INLINE void LL_RTC_DisableIT_ITAMP3(const RTC_TypeDef *RTCx)
5612 {
5613   UNUSED(RTCx);
5614   CLEAR_BIT(TAMP->IER, TAMP_IER_ITAMP3IE);
5615 }
5616 
5617 /**
5618   * @brief  Enable internal tamper 4 interrupt.
5619   * @rmtoll TAMP_IER           ITAMP4IE          LL_RTC_EnableIT_ITAMP4
5620   * @param  RTCx RTC Instance
5621   * @retval None
5622   */
LL_RTC_EnableIT_ITAMP4(const RTC_TypeDef * RTCx)5623 __STATIC_INLINE void LL_RTC_EnableIT_ITAMP4(const RTC_TypeDef *RTCx)
5624 {
5625   UNUSED(RTCx);
5626   SET_BIT(TAMP->IER, TAMP_IER_ITAMP4IE);
5627 }
5628 
5629 /**
5630   * @brief  Disable internal tamper 4 interrupt.
5631   * @rmtoll TAMP_IER           ITAMP4IE          LL_RTC_DisableIT_ITAMP4
5632   * @param  RTCx RTC Instance
5633   * @retval None
5634   */
LL_RTC_DisableIT_ITAMP4(const RTC_TypeDef * RTCx)5635 __STATIC_INLINE void LL_RTC_DisableIT_ITAMP4(const RTC_TypeDef *RTCx)
5636 {
5637   UNUSED(RTCx);
5638   CLEAR_BIT(TAMP->IER, TAMP_IER_ITAMP4IE);
5639 }
5640 
5641 /**
5642   * @brief  Enable internal tamper 5 interrupt.
5643   * @rmtoll TAMP_IER           ITAMP5IE          LL_RTC_EnableIT_ITAMP5
5644   * @param  RTCx RTC Instance
5645   * @retval None
5646   */
LL_RTC_EnableIT_ITAMP5(const RTC_TypeDef * RTCx)5647 __STATIC_INLINE void LL_RTC_EnableIT_ITAMP5(const RTC_TypeDef *RTCx)
5648 {
5649   UNUSED(RTCx);
5650   SET_BIT(TAMP->IER, TAMP_IER_ITAMP5IE);
5651 }
5652 
5653 /**
5654   * @brief  Disable internal tamper 5 interrupt.
5655   * @rmtoll TAMP_IER           ITAMP5IE          LL_RTC_DisableIT_ITAMP5
5656   * @param  RTCx RTC Instance
5657   * @retval None
5658   */
LL_RTC_DisableIT_ITAMP5(const RTC_TypeDef * RTCx)5659 __STATIC_INLINE void LL_RTC_DisableIT_ITAMP5(const RTC_TypeDef *RTCx)
5660 {
5661   UNUSED(RTCx);
5662   CLEAR_BIT(TAMP->IER, TAMP_IER_ITAMP5IE);
5663 }
5664 
5665 /**
5666   * @brief  Enable internal tamper 6 interrupt.
5667   * @rmtoll TAMP_IER           ITAMP6IE          LL_RTC_EnableIT_ITAMP6
5668   * @param  RTCx RTC Instance
5669   * @retval None
5670   */
LL_RTC_EnableIT_ITAMP6(const RTC_TypeDef * RTCx)5671 __STATIC_INLINE void LL_RTC_EnableIT_ITAMP6(const RTC_TypeDef *RTCx)
5672 {
5673   UNUSED(RTCx);
5674   SET_BIT(TAMP->IER, TAMP_IER_ITAMP6IE);
5675 }
5676 
5677 /**
5678   * @brief  Disable internal tamper 6 interrupt.
5679   * @rmtoll TAMP_IER           ITAMP6IE          LL_RTC_DisableIT_ITAMP6
5680   * @param  RTCx RTC Instance
5681   * @retval None
5682   */
LL_RTC_DisableIT_ITAMP6(const RTC_TypeDef * RTCx)5683 __STATIC_INLINE void LL_RTC_DisableIT_ITAMP6(const RTC_TypeDef *RTCx)
5684 {
5685   UNUSED(RTCx);
5686   CLEAR_BIT(TAMP->IER, TAMP_IER_ITAMP6IE);
5687 }
5688 
5689 /**
5690   * @brief  Enable internal tamper 7 interrupt.
5691   * @rmtoll TAMP_IER           ITAMP7IE          LL_RTC_EnableIT_ITAMP7
5692   * @param  RTCx RTC Instance
5693   * @retval None
5694   */
LL_RTC_EnableIT_ITAMP7(const RTC_TypeDef * RTCx)5695 __STATIC_INLINE void LL_RTC_EnableIT_ITAMP7(const RTC_TypeDef *RTCx)
5696 {
5697   UNUSED(RTCx);
5698   SET_BIT(TAMP->IER, TAMP_IER_ITAMP7IE);
5699 }
5700 
5701 /**
5702   * @brief  Disable internal tamper 7 interrupt.
5703   * @rmtoll TAMP_IER           ITAMP7IE          LL_RTC_DisableIT_ITAMP7
5704   * @param  RTCx RTC Instance
5705   * @retval None
5706   */
LL_RTC_DisableIT_ITAMP7(const RTC_TypeDef * RTCx)5707 __STATIC_INLINE void LL_RTC_DisableIT_ITAMP7(const RTC_TypeDef *RTCx)
5708 {
5709   UNUSED(RTCx);
5710   CLEAR_BIT(TAMP->IER, TAMP_IER_ITAMP7IE);
5711 }
5712 
5713 /**
5714   * @brief  Enable internal tamper 8 interrupt.
5715   * @rmtoll TAMP_IER           ITAMP8IE          LL_RTC_EnableIT_ITAMP8
5716   * @param  RTCx RTC Instance
5717   * @retval None
5718   */
LL_RTC_EnableIT_ITAMP8(const RTC_TypeDef * RTCx)5719 __STATIC_INLINE void LL_RTC_EnableIT_ITAMP8(const RTC_TypeDef *RTCx)
5720 {
5721   UNUSED(RTCx);
5722   SET_BIT(TAMP->IER, TAMP_IER_ITAMP8IE);
5723 }
5724 
5725 /**
5726   * @brief  Disable internal tamper 8 interrupt.
5727   * @rmtoll TAMP_IER           ITAMP8IE          LL_RTC_DisableIT_ITAMP8
5728   * @param  RTCx RTC Instance
5729   * @retval None
5730   */
LL_RTC_DisableIT_ITAMP8(const RTC_TypeDef * RTCx)5731 __STATIC_INLINE void LL_RTC_DisableIT_ITAMP8(const RTC_TypeDef *RTCx)
5732 {
5733   UNUSED(RTCx);
5734   CLEAR_BIT(TAMP->IER, TAMP_IER_ITAMP8IE);
5735 }
5736 
5737 /**
5738   * @brief  Enable internal tamper 9 interrupt.
5739   * @rmtoll TAMP_IER           ITAMP9IE          LL_RTC_EnableIT_ITAMP9
5740   * @param  RTCx RTC Instance
5741   * @retval None
5742   */
LL_RTC_EnableIT_ITAMP9(const RTC_TypeDef * RTCx)5743 __STATIC_INLINE void LL_RTC_EnableIT_ITAMP9(const RTC_TypeDef *RTCx)
5744 {
5745   UNUSED(RTCx);
5746   SET_BIT(TAMP->IER, TAMP_IER_ITAMP9IE);
5747 }
5748 
5749 /**
5750   * @brief  Disable internal tamper 9 interrupt.
5751   * @rmtoll TAMP_IER           ITAMP9IE          LL_RTC_DisableIT_ITAMP9
5752   * @param  RTCx RTC Instance
5753   * @retval None
5754   */
LL_RTC_DisableIT_ITAMP9(const RTC_TypeDef * RTCx)5755 __STATIC_INLINE void LL_RTC_DisableIT_ITAMP9(const RTC_TypeDef *RTCx)
5756 {
5757   UNUSED(RTCx);
5758   CLEAR_BIT(TAMP->IER, TAMP_IER_ITAMP9IE);
5759 }
5760 
5761 /**
5762   * @brief  Enable internal tamper 11 interrupt.
5763   * @rmtoll TAMP_IER           ITAMP11IE          LL_RTC_EnableIT_ITAMP11
5764   * @param  RTCx RTC Instance
5765   * @retval None
5766   */
LL_RTC_EnableIT_ITAMP11(const RTC_TypeDef * RTCx)5767 __STATIC_INLINE void LL_RTC_EnableIT_ITAMP11(const RTC_TypeDef *RTCx)
5768 {
5769   UNUSED(RTCx);
5770   SET_BIT(TAMP->IER, TAMP_IER_ITAMP11IE);
5771 }
5772 
5773 /**
5774   * @brief  Disable internal tamper 11 interrupt.
5775   * @rmtoll TAMP_IER           ITAMP11IE          LL_RTC_DisableIT_ITAMP11
5776   * @param  RTCx RTC Instance
5777   * @retval None
5778   */
LL_RTC_DisableIT_ITAMP11(const RTC_TypeDef * RTCx)5779 __STATIC_INLINE void LL_RTC_DisableIT_ITAMP11(const RTC_TypeDef *RTCx)
5780 {
5781   UNUSED(RTCx);
5782   CLEAR_BIT(TAMP->IER, TAMP_IER_ITAMP11IE);
5783 }
5784 
5785 /**
5786   * @brief  Check if tamper 1 interrupt is enabled or not.
5787   * @rmtoll TAMP_IER           TAMP1IE        LL_RTC_IsEnabledIT_TAMP1
5788   * @param  RTCx RTC Instance
5789   * @retval State of bit (1 or 0).
5790   */
LL_RTC_IsEnabledIT_TAMP1(const RTC_TypeDef * RTCx)5791 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP1(const RTC_TypeDef *RTCx)
5792 {
5793   UNUSED(RTCx);
5794   return ((READ_BIT(TAMP->IER, TAMP_IER_TAMP1IE) == (TAMP_IER_TAMP1IE)) ? 1U : 0U);
5795 }
5796 
5797 /**
5798   * @brief  Check if tamper 2 interrupt is enabled or not.
5799   * @rmtoll TAMP_IER           TAMP2IE        LL_RTC_IsEnabledIT_TAMP2
5800   * @param  RTCx RTC Instance
5801   * @retval State of bit (1 or 0).
5802   */
LL_RTC_IsEnabledIT_TAMP2(const RTC_TypeDef * RTCx)5803 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP2(const RTC_TypeDef *RTCx)
5804 {
5805   UNUSED(RTCx);
5806   return ((READ_BIT(TAMP->IER, TAMP_IER_TAMP2IE) == (TAMP_IER_TAMP2IE)) ? 1U : 0U);
5807 }
5808 
5809 /**
5810   * @brief  Check if tamper 3 interrupt is enabled or not.
5811   * @rmtoll TAMP_IER           TAMP3IE        LL_RTC_IsEnabledIT_TAMP3
5812   * @param  RTCx RTC Instance
5813   * @retval State of bit (1 or 0).
5814   */
LL_RTC_IsEnabledIT_TAMP3(const RTC_TypeDef * RTCx)5815 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP3(const RTC_TypeDef *RTCx)
5816 {
5817   UNUSED(RTCx);
5818   return ((READ_BIT(TAMP->IER, TAMP_IER_TAMP3IE) == (TAMP_IER_TAMP3IE)) ? 1U : 0U);
5819 }
5820 
5821 /**
5822   * @brief  Check if tamper 4 interrupt is enabled or not.
5823   * @rmtoll TAMP_IER           TAMP4IE        LL_RTC_IsEnabledIT_TAMP4
5824   * @param  RTCx RTC Instance
5825   * @retval State of bit (1 or 0).
5826   */
LL_RTC_IsEnabledIT_TAMP4(const RTC_TypeDef * RTCx)5827 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP4(const RTC_TypeDef *RTCx)
5828 {
5829   UNUSED(RTCx);
5830   return ((READ_BIT(TAMP->IER, TAMP_IER_TAMP4IE) == (TAMP_IER_TAMP4IE)) ? 1U : 0U);
5831 }
5832 
5833 /**
5834   * @brief  Check if tamper 5 interrupt is enabled or not.
5835   * @rmtoll TAMP_IER           TAMP5IE        LL_RTC_IsEnabledIT_TAMP5
5836   * @param  RTCx RTC Instance
5837   * @retval State of bit (1 or 0).
5838   */
LL_RTC_IsEnabledIT_TAMP5(const RTC_TypeDef * RTCx)5839 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP5(const RTC_TypeDef *RTCx)
5840 {
5841   UNUSED(RTCx);
5842   return ((READ_BIT(TAMP->IER, TAMP_IER_TAMP5IE) == (TAMP_IER_TAMP5IE)) ? 1U : 0U);
5843 }
5844 
5845 /**
5846   * @brief  Check if tamper 6 interrupt is enabled or not.
5847   * @rmtoll TAMP_IER           TAMP6IE        LL_RTC_IsEnabledIT_TAMP6
5848   * @param  RTCx RTC Instance
5849   * @retval State of bit (1 or 0).
5850   */
LL_RTC_IsEnabledIT_TAMP6(const RTC_TypeDef * RTCx)5851 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP6(const RTC_TypeDef *RTCx)
5852 {
5853   UNUSED(RTCx);
5854   return ((READ_BIT(TAMP->IER, TAMP_IER_TAMP6IE) == (TAMP_IER_TAMP6IE)) ? 1U : 0U);
5855 }
5856 
5857 /**
5858   * @brief  Check if tamper 7 interrupt is enabled or not.
5859   * @rmtoll TAMP_IER           TAMP7IE        LL_RTC_IsEnabledIT_TAMP7
5860   * @param  RTCx RTC Instance
5861   * @retval State of bit (1 or 0).
5862   */
LL_RTC_IsEnabledIT_TAMP7(const RTC_TypeDef * RTCx)5863 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP7(const RTC_TypeDef *RTCx)
5864 {
5865   UNUSED(RTCx);
5866   return ((READ_BIT(TAMP->IER, TAMP_IER_TAMP7IE) == (TAMP_IER_TAMP7IE)) ? 1U : 0U);
5867 }
5868 
5869 /**
5870   * @brief  Check if internal tamper 1 interrupt is enabled or not.
5871   * @rmtoll TAMP_IER           ITAMP1IE        LL_RTC_IsEnabledIT_ITAMP1
5872   * @param  RTCx RTC Instance
5873   * @retval State of bit (1 or 0).
5874   */
LL_RTC_IsEnabledIT_ITAMP1(const RTC_TypeDef * RTCx)5875 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ITAMP1(const RTC_TypeDef *RTCx)
5876 {
5877   UNUSED(RTCx);
5878   return ((READ_BIT(TAMP->IER, TAMP_IER_ITAMP1IE) == (TAMP_IER_ITAMP1IE)) ? 1U : 0U);
5879 }
5880 
5881 /**
5882   * @brief  Check if internal tamper 2 interrupt is enabled or not.
5883   * @rmtoll TAMP_IER           ITAMP2IE        LL_RTC_IsEnabledIT_ITAMP2
5884   * @param  RTCx RTC Instance
5885   * @retval State of bit (1 or 0).
5886   */
LL_RTC_IsEnabledIT_ITAMP2(const RTC_TypeDef * RTCx)5887 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ITAMP2(const RTC_TypeDef *RTCx)
5888 {
5889   UNUSED(RTCx);
5890   return ((READ_BIT(TAMP->IER, TAMP_IER_ITAMP2IE) == (TAMP_IER_ITAMP2IE)) ? 1U : 0U);
5891 }
5892 
5893 /**
5894   * @brief  Check if internal tamper 3 interrupt is enabled or not.
5895   * @rmtoll TAMP_IER           ITAMP3IE        LL_RTC_IsEnabledIT_ITAMP3
5896   * @param  RTCx RTC Instance
5897   * @retval State of bit (1 or 0).
5898   */
LL_RTC_IsEnabledIT_ITAMP3(const RTC_TypeDef * RTCx)5899 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ITAMP3(const RTC_TypeDef *RTCx)
5900 {
5901   UNUSED(RTCx);
5902   return ((READ_BIT(TAMP->IER, TAMP_IER_ITAMP3IE) == (TAMP_IER_ITAMP3IE)) ? 1U : 0U);
5903 }
5904 
5905 /**
5906   * @brief  Check if internal tamper 4 interrupt is enabled or not.
5907   * @rmtoll TAMP_IER           ITAMP4IE        LL_RTC_IsEnabledIT_ITAMP4
5908   * @param  RTCx RTC Instance
5909   * @retval State of bit (1 or 0).
5910   */
LL_RTC_IsEnabledIT_ITAMP4(const RTC_TypeDef * RTCx)5911 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ITAMP4(const RTC_TypeDef *RTCx)
5912 {
5913   UNUSED(RTCx);
5914   return ((READ_BIT(TAMP->IER, TAMP_IER_ITAMP4IE) == (TAMP_IER_ITAMP4IE)) ? 1U : 0U);
5915 }
5916 
5917 /**
5918   * @brief  Check if internal tamper 5 interrupt is enabled or not.
5919   * @rmtoll TAMP_IER           ITAMP5IE        LL_RTC_IsEnabledIT_ITAMP5
5920   * @param  RTCx RTC Instance
5921   * @retval State of bit (1 or 0).
5922   */
LL_RTC_IsEnabledIT_ITAMP5(const RTC_TypeDef * RTCx)5923 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ITAMP5(const RTC_TypeDef *RTCx)
5924 {
5925   UNUSED(RTCx);
5926   return ((READ_BIT(TAMP->IER, TAMP_IER_ITAMP5IE) == (TAMP_IER_ITAMP5IE)) ? 1U : 0U);
5927 }
5928 
5929 /**
5930   * @brief  Check if internal tamper 6 interrupt is enabled or not.
5931   * @rmtoll TAMP_IER           ITAMP6IE        LL_RTC_IsEnabledIT_ITAMP6
5932   * @param  RTCx RTC Instance
5933   * @retval State of bit (1 or 0).
5934   */
LL_RTC_IsEnabledIT_ITAMP6(const RTC_TypeDef * RTCx)5935 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ITAMP6(const RTC_TypeDef *RTCx)
5936 {
5937   UNUSED(RTCx);
5938   return ((READ_BIT(TAMP->IER, TAMP_IER_ITAMP6IE) == (TAMP_IER_ITAMP6IE)) ? 1U : 0U);
5939 }
5940 
5941 /**
5942   * @brief  Check if internal tamper 7 interrupt is enabled or not.
5943   * @rmtoll TAMP_IER           ITAMP7IE        LL_RTC_IsEnabledIT_ITAMP7
5944   * @param  RTCx RTC Instance
5945   * @retval State of bit (1 or 0).
5946   */
LL_RTC_IsEnabledIT_ITAMP7(const RTC_TypeDef * RTCx)5947 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ITAMP7(const RTC_TypeDef *RTCx)
5948 {
5949   UNUSED(RTCx);
5950   return ((READ_BIT(TAMP->IER, TAMP_IER_ITAMP7IE) == (TAMP_IER_ITAMP7IE)) ? 1U : 0U);
5951 }
5952 
5953 /**
5954   * @brief  Check if internal tamper 8 interrupt is enabled or not.
5955   * @rmtoll TAMP_IER           ITAMP8IE        LL_RTC_IsEnabledIT_ITAMP8
5956   * @param  RTCx RTC Instance
5957   * @retval State of bit (1 or 0).
5958   */
LL_RTC_IsEnabledIT_ITAMP8(const RTC_TypeDef * RTCx)5959 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ITAMP8(const RTC_TypeDef *RTCx)
5960 {
5961   UNUSED(RTCx);
5962   return ((READ_BIT(TAMP->IER, TAMP_IER_ITAMP8IE) == (TAMP_IER_ITAMP8IE)) ? 1U : 0U);
5963 }
5964 
5965 /**
5966   * @brief  Check if internal tamper 9 interrupt is enabled or not.
5967   * @rmtoll TAMP_IER           ITAMP9IE        LL_RTC_IsEnabledIT_ITAMP9
5968   * @param  RTCx RTC Instance
5969   * @retval State of bit (1 or 0).
5970   */
LL_RTC_IsEnabledIT_ITAMP9(const RTC_TypeDef * RTCx)5971 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ITAMP9(const RTC_TypeDef *RTCx)
5972 {
5973   UNUSED(RTCx);
5974   return ((READ_BIT(TAMP->IER, TAMP_IER_ITAMP9IE) == (TAMP_IER_ITAMP9IE)) ? 1U : 0U);
5975 }
5976 
5977 /**
5978   * @brief  Check if internal tamper 11 interrupt is enabled or not.
5979   * @rmtoll TAMP_IER           ITAMP11IE        LL_RTC_IsEnabledIT_ITAMP11
5980   * @param  RTCx RTC Instance
5981   * @retval State of bit (1 or 0).
5982   */
LL_RTC_IsEnabledIT_ITAMP11(const RTC_TypeDef * RTCx)5983 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ITAMP11(const RTC_TypeDef *RTCx)
5984 {
5985   UNUSED(RTCx);
5986   return ((READ_BIT(TAMP->IER, TAMP_IER_ITAMP11IE) == (TAMP_IER_ITAMP11IE)) ? 1U : 0U);
5987 }
5988 
5989 /**
5990   * @brief  Increment Monotonic counter.
5991   * @rmtoll TAMP_COUNT1R         COUNT        LL_RTC_IncrementMonotonicCounter
5992   * @param  RTCx RTC Instance
5993   * @retval None.
5994   */
LL_RTC_IncrementMonotonicCounter(const RTC_TypeDef * RTCx)5995 __STATIC_INLINE void LL_RTC_IncrementMonotonicCounter(const RTC_TypeDef *RTCx)
5996 {
5997   UNUSED(RTCx);
5998   WRITE_REG(TAMP->COUNT1R, 0U);
5999 }
6000 
6001 /**
6002   * @brief  Increment Monotonic counter.
6003   * @rmtoll TAMP_COUNT1R         COUNT        LL_RTC_GetMonotonicCounter
6004   * @param  RTCx RTC Instance
6005   * @retval Monotonic counter value.
6006   */
LL_RTC_GetMonotonicCounter(const RTC_TypeDef * RTCx)6007 __STATIC_INLINE uint32_t LL_RTC_GetMonotonicCounter(const RTC_TypeDef *RTCx)
6008 {
6009   UNUSED(RTCx);
6010   return READ_REG(TAMP->COUNT1R);
6011 }
6012 
6013 /**
6014   * @}
6015   */
6016 
6017 #if defined(USE_FULL_LL_DRIVER)
6018 /** @defgroup RTC_LL_EF_Init Initialization and de-initialization functions
6019   * @{
6020   */
6021 
6022 ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx);
6023 ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct);
6024 void        LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct);
6025 ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct);
6026 void        LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct);
6027 ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct);
6028 void        LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct);
6029 ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
6030 ErrorStatus LL_RTC_ALMB_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
6031 void        LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
6032 void        LL_RTC_ALMB_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
6033 ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx);
6034 ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx);
6035 ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx);
6036 
6037 /**
6038   * @}
6039   */
6040 #endif /* USE_FULL_LL_DRIVER */
6041 
6042 /**
6043   * @}
6044   */
6045 
6046 /**
6047   * @}
6048   */
6049 
6050 #endif /* defined(RTC) */
6051 
6052 /**
6053   * @}
6054   */
6055 
6056 #ifdef __cplusplus
6057 }
6058 #endif
6059 
6060 #endif /* STM32N6xx_LL_RTC_H */
6061 
6062