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