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