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