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