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