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