1 /**
2 ******************************************************************************
3 * @file stm32wbxx_ll_rtc.h
4 * @author MCD Application Team
5 * @brief Header file of RTC LL module.
6 ******************************************************************************
7 * @attention
8 *
9 * Copyright (c) 2019 STMicroelectronics.
10 * All rights reserved.
11 *
12 * This software is licensed under terms that can be found in the LICENSE file
13 * in the root directory of this software component.
14 * If no LICENSE file comes with this software, it is provided AS-IS.
15 *
16 ******************************************************************************
17 */
18
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32WBxx_LL_RTC_H
21 #define STM32WBxx_LL_RTC_H
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32wbxx.h"
29
30 /** @addtogroup STM32WBxx_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
47 /* Write protection defines */
48 #define RTC_WRITE_PROTECTION_DISABLE ((uint8_t)0xFFU)
49 #define RTC_WRITE_PROTECTION_ENABLE_1 ((uint8_t)0xCAU)
50 #define RTC_WRITE_PROTECTION_ENABLE_2 ((uint8_t)0x53U)
51
52 /* Defines used to combine date & time */
53 #define RTC_OFFSET_WEEKDAY (uint32_t)24U
54 #define RTC_OFFSET_DAY (uint32_t)16U
55 #define RTC_OFFSET_MONTH (uint32_t)8U
56 #define RTC_OFFSET_HOUR (uint32_t)16U
57 #define RTC_OFFSET_MINUTE (uint32_t)8U
58
59 /**
60 * @}
61 */
62
63 /* Private macros ------------------------------------------------------------*/
64 #if defined(USE_FULL_LL_DRIVER)
65 /** @defgroup RTC_LL_Private_Macros RTC Private Macros
66 * @{
67 */
68 /**
69 * @}
70 */
71 #endif /*USE_FULL_LL_DRIVER*/
72
73 /* Exported types ------------------------------------------------------------*/
74 #if defined(USE_FULL_LL_DRIVER)
75 /** @defgroup RTC_LL_ES_INIT RTC Exported Init structure
76 * @{
77 */
78
79 /**
80 * @brief RTC Init structures definition
81 */
82 typedef struct
83 {
84 uint32_t HourFormat; /*!< Specifies the RTC Hours Format.
85 This parameter can be a value of @ref RTC_LL_EC_HOURFORMAT
86
87 This feature can be modified afterwards using unitary function
88 @ref LL_RTC_SetHourFormat(). */
89
90 uint32_t AsynchPrescaler; /*!< Specifies the RTC Asynchronous Predivider value.
91 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F
92
93 This feature can be modified afterwards using unitary function
94 @ref LL_RTC_SetAsynchPrescaler(). */
95
96 uint32_t SynchPrescaler; /*!< Specifies the RTC Synchronous Predivider value.
97 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF
98
99 This feature can be modified afterwards using unitary function
100 @ref LL_RTC_SetSynchPrescaler(). */
101 } LL_RTC_InitTypeDef;
102
103 /**
104 * @brief RTC Time structure definition
105 */
106 typedef struct
107 {
108 uint32_t TimeFormat; /*!< Specifies the RTC AM/PM Time.
109 This parameter can be a value of @ref RTC_LL_EC_TIME_FORMAT
110
111 This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetFormat(). */
112
113 uint8_t Hours; /*!< Specifies the RTC Time Hours.
114 This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the @ref LL_RTC_TIME_FORMAT_PM is selected.
115 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.
116
117 This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetHour(). */
118
119 uint8_t Minutes; /*!< Specifies the RTC Time Minutes.
120 This parameter must be a number between Min_Data = 0 and Max_Data = 59
121
122 This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetMinute(). */
123
124 uint8_t Seconds; /*!< Specifies the RTC Time Seconds.
125 This parameter must be a number between Min_Data = 0 and Max_Data = 59
126
127 This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetSecond(). */
128 } LL_RTC_TimeTypeDef;
129
130 /**
131 * @brief RTC Date structure definition
132 */
133 typedef struct
134 {
135 uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay.
136 This parameter can be a value of @ref RTC_LL_EC_WEEKDAY
137
138 This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetWeekDay(). */
139
140 uint8_t Month; /*!< Specifies the RTC Date Month.
141 This parameter can be a value of @ref RTC_LL_EC_MONTH
142
143 This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetMonth(). */
144
145 uint8_t Day; /*!< Specifies the RTC Date Day.
146 This parameter must be a number between Min_Data = 1 and Max_Data = 31
147
148 This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetDay(). */
149
150 uint8_t Year; /*!< Specifies the RTC Date Year.
151 This parameter must be a number between Min_Data = 0 and Max_Data = 99
152
153 This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetYear(). */
154 } LL_RTC_DateTypeDef;
155
156 /**
157 * @brief RTC Alarm structure definition
158 */
159 typedef struct
160 {
161 LL_RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members. */
162
163 uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks.
164 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.
165
166 This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetMask() for ALARM A
167 or @ref LL_RTC_ALMB_SetMask() for ALARM B
168 */
169
170 uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on day or WeekDay.
171 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
172
173 This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_EnableWeekday() or @ref LL_RTC_ALMA_DisableWeekday()
174 for ALARM A or @ref LL_RTC_ALMB_EnableWeekday() or @ref LL_RTC_ALMB_DisableWeekday() for ALARM B
175 */
176
177 uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Day/WeekDay.
178 If AlarmDateWeekDaySel set to day, this parameter must be a number between Min_Data = 1 and Max_Data = 31.
179
180 This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetDay()
181 for ALARM A or @ref LL_RTC_ALMB_SetDay() for ALARM B.
182
183 If AlarmDateWeekDaySel set to Weekday, this parameter can be a value of @ref RTC_LL_EC_WEEKDAY.
184
185 This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetWeekDay()
186 for ALARM A or @ref LL_RTC_ALMB_SetWeekDay() for ALARM B.
187 */
188 } LL_RTC_AlarmTypeDef;
189
190 /**
191 * @}
192 */
193 #endif /* USE_FULL_LL_DRIVER */
194
195 /* Exported constants --------------------------------------------------------*/
196 /** @defgroup RTC_LL_Exported_Constants RTC Exported Constants
197 * @{
198 */
199
200 #if defined(USE_FULL_LL_DRIVER)
201 /** @defgroup RTC_LL_EC_FORMAT FORMAT
202 * @{
203 */
204 #define LL_RTC_FORMAT_BIN 0x000000000U /*!< Binary data format */
205 #define LL_RTC_FORMAT_BCD 0x000000001U /*!< BCD data format */
206 /**
207 * @}
208 */
209
210 /** @defgroup RTC_LL_EC_ALMA_WEEKDAY_SELECTION RTC Alarm A Date WeekDay
211 * @{
212 */
213 #define LL_RTC_ALMA_DATEWEEKDAYSEL_DATE 0x00000000U /*!< Alarm A Date is selected */
214 #define LL_RTC_ALMA_DATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL /*!< Alarm A WeekDay is selected */
215 /**
216 * @}
217 */
218
219 /** @defgroup RTC_LL_EC_ALMB_WEEKDAY_SELECTION RTC Alarm B Date WeekDay
220 * @{
221 */
222 #define LL_RTC_ALMB_DATEWEEKDAYSEL_DATE 0x00000000U /*!< Alarm B Date is selected */
223 #define LL_RTC_ALMB_DATEWEEKDAYSEL_WEEKDAY RTC_ALRMBR_WDSEL /*!< Alarm B WeekDay is selected */
224 /**
225 * @}
226 */
227
228 #endif /* USE_FULL_LL_DRIVER */
229
230 /** @defgroup RTC_LL_EC_GET_FLAG Get Flags Defines
231 * @brief Flags defines which can be used with LL_RTC_ReadReg function
232 * @{
233 */
234 #define LL_RTC_ISR_ITSF RTC_ISR_ITSF
235 #define LL_RTC_ISR_RECALPF RTC_ISR_RECALPF
236 #if defined(RTC_TAMPER3_SUPPORT)
237 #define LL_RTC_ISR_TAMP3F RTC_ISR_TAMP3F
238 #endif /* RTC_TAMPER3_SUPPORT */
239 #if defined(RTC_TAMPER2_SUPPORT)
240 #define LL_RTC_ISR_TAMP2F RTC_ISR_TAMP2F
241 #endif /* RTC_TAMPER2_SUPPORT */
242 #if defined(RTC_TAMPER1_SUPPORT)
243 #define LL_RTC_ISR_TAMP1F RTC_ISR_TAMP1F
244 #endif /* RTC_TAMPER1_SUPPORT */
245 #define LL_RTC_ISR_TSOVF RTC_ISR_TSOVF
246 #define LL_RTC_ISR_TSF RTC_ISR_TSF
247 #define LL_RTC_ISR_WUTF RTC_ISR_WUTF
248 #define LL_RTC_ISR_ALRBF RTC_ISR_ALRBF
249 #define LL_RTC_ISR_ALRAF RTC_ISR_ALRAF
250 #define LL_RTC_ISR_INITF RTC_ISR_INITF
251 #define LL_RTC_ISR_RSF RTC_ISR_RSF
252 #define LL_RTC_ISR_INITS RTC_ISR_INITS
253 #define LL_RTC_ISR_SHPF RTC_ISR_SHPF
254 #define LL_RTC_ISR_WUTWF RTC_ISR_WUTWF
255 #define LL_RTC_ISR_ALRBWF RTC_ISR_ALRBWF
256 #define LL_RTC_ISR_ALRAWF RTC_ISR_ALRAWF
257 /**
258 * @}
259 */
260
261 /** @defgroup RTC_LL_EC_IT IT Defines
262 * @brief IT defines which can be used with LL_RTC_ReadReg and LL_RTC_WriteReg functions
263 * @{
264 */
265 #define LL_RTC_CR_TSIE RTC_CR_TSIE
266 #define LL_RTC_CR_WUTIE RTC_CR_WUTIE
267 #define LL_RTC_CR_ALRBIE RTC_CR_ALRBIE
268 #define LL_RTC_CR_ALRAIE RTC_CR_ALRAIE
269 #if defined(RTC_TAMPER3_SUPPORT)
270 #define LL_RTC_TAMPCR_TAMP3IE RTC_TAMPCR_TAMP3IE
271 #endif /* RTC_TAMPER3_SUPPORT */
272 #if defined(RTC_TAMPER2_SUPPORT)
273 #define LL_RTC_TAMPCR_TAMP2IE RTC_TAMPCR_TAMP2IE
274 #endif /* RTC_TAMPER2_SUPPORT */
275 #if defined(RTC_TAMPER1_SUPPORT)
276 #define LL_RTC_TAMPCR_TAMP1IE RTC_TAMPCR_TAMP1IE
277 #endif /* RTC_TAMPER1_SUPPORT */
278 #define LL_RTC_TAMPCR_TAMPIE RTC_TAMPCR_TAMPIE
279 /**
280 * @}
281 */
282
283 /** @defgroup RTC_LL_EC_WEEKDAY WEEK DAY
284 * @{
285 */
286 #define LL_RTC_WEEKDAY_MONDAY ((uint8_t)0x01U) /*!< Monday */
287 #define LL_RTC_WEEKDAY_TUESDAY ((uint8_t)0x02U) /*!< Tuesday */
288 #define LL_RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03U) /*!< Wednesday */
289 #define LL_RTC_WEEKDAY_THURSDAY ((uint8_t)0x04U) /*!< Thrusday */
290 #define LL_RTC_WEEKDAY_FRIDAY ((uint8_t)0x05U) /*!< Friday */
291 #define LL_RTC_WEEKDAY_SATURDAY ((uint8_t)0x06U) /*!< Saturday */
292 #define LL_RTC_WEEKDAY_SUNDAY ((uint8_t)0x07U) /*!< Sunday */
293 /**
294 * @}
295 */
296
297 /** @defgroup RTC_LL_EC_MONTH MONTH
298 * @{
299 */
300 #define LL_RTC_MONTH_JANUARY ((uint8_t)0x01U) /*!< January */
301 #define LL_RTC_MONTH_FEBRUARY ((uint8_t)0x02U) /*!< February */
302 #define LL_RTC_MONTH_MARCH ((uint8_t)0x03U) /*!< March */
303 #define LL_RTC_MONTH_APRIL ((uint8_t)0x04U) /*!< April */
304 #define LL_RTC_MONTH_MAY ((uint8_t)0x05U) /*!< May */
305 #define LL_RTC_MONTH_JUNE ((uint8_t)0x06U) /*!< June */
306 #define LL_RTC_MONTH_JULY ((uint8_t)0x07U) /*!< July */
307 #define LL_RTC_MONTH_AUGUST ((uint8_t)0x08U) /*!< August */
308 #define LL_RTC_MONTH_SEPTEMBER ((uint8_t)0x09U) /*!< September */
309 #define LL_RTC_MONTH_OCTOBER ((uint8_t)0x10U) /*!< October */
310 #define LL_RTC_MONTH_NOVEMBER ((uint8_t)0x11U) /*!< November */
311 #define LL_RTC_MONTH_DECEMBER ((uint8_t)0x12U) /*!< December */
312 /**
313 * @}
314 */
315
316 /** @defgroup RTC_LL_EC_HOURFORMAT HOUR FORMAT
317 * @{
318 */
319 #define LL_RTC_HOURFORMAT_24HOUR 0x00000000U /*!< 24 hour/day format */
320 #define LL_RTC_HOURFORMAT_AMPM RTC_CR_FMT /*!< AM/PM hour format */
321 /**
322 * @}
323 */
324
325 /** @defgroup RTC_LL_EC_ALARMOUT ALARM OUTPUT
326 * @{
327 */
328 #define LL_RTC_ALARMOUT_DISABLE 0x00000000U /*!< Output disabled */
329 #define LL_RTC_ALARMOUT_ALMA RTC_CR_OSEL_0 /*!< Alarm A output enabled */
330 #define LL_RTC_ALARMOUT_ALMB RTC_CR_OSEL_1 /*!< Alarm B output enabled */
331 #define LL_RTC_ALARMOUT_WAKEUP RTC_CR_OSEL /*!< Wakeup output enabled */
332 /**
333 * @}
334 */
335
336 #if defined(RTC_OR_ALARMOUTTYPE)
337 /** @defgroup RTC_LL_EC_ALARM_OUTPUTTYPE ALARM OUTPUT TYPE
338 * @{
339 */
340 #define LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN 0x00000000U /*!< RTC_ALARM, when mapped on PC13, is open-drain output */
341 #define LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL RTC_OR_ALARMOUTTYPE /*!< RTC_ALARM, when mapped on PC13, is push-pull output */
342 /**
343 * @}
344 */
345 #endif /* RTC_OR_ALARMOUTTYPE */
346
347 /** @defgroup RTC_LL_EC_OUTPUTPOLARITY_PIN OUTPUT POLARITY PIN
348 * @{
349 */
350 #define LL_RTC_OUTPUTPOLARITY_PIN_HIGH 0x00000000U /*!< Pin is high when ALRAF/ALRBF/WUTF is asserted (depending on OSEL)*/
351 #define LL_RTC_OUTPUTPOLARITY_PIN_LOW RTC_CR_POL /*!< Pin is low when ALRAF/ALRBF/WUTF is asserted (depending on OSEL) */
352 /**
353 * @}
354 */
355
356 /** @defgroup RTC_LL_EC_TIME_FORMAT TIME FORMAT
357 * @{
358 */
359 #define LL_RTC_TIME_FORMAT_AM_OR_24 0x00000000U /*!< AM or 24-hour format */
360 #define LL_RTC_TIME_FORMAT_PM RTC_TR_PM /*!< PM */
361 /**
362 * @}
363 */
364
365 /** @defgroup RTC_LL_EC_SHIFT_SECOND SHIFT SECOND
366 * @{
367 */
368 #define LL_RTC_SHIFT_SECOND_DELAY 0x00000000U /* Delay (seconds) = SUBFS / (PREDIV_S + 1) */
369 #define LL_RTC_SHIFT_SECOND_ADVANCE RTC_SHIFTR_ADD1S /* Advance (seconds) = (1 - (SUBFS / (PREDIV_S + 1))) */
370 /**
371 * @}
372 */
373
374 /** @defgroup RTC_LL_EC_ALMA_MASK ALARMA MASK
375 * @{
376 */
377 #define LL_RTC_ALMA_MASK_NONE 0x00000000U /*!< No masks applied on Alarm A*/
378 #define LL_RTC_ALMA_MASK_DATEWEEKDAY RTC_ALRMAR_MSK4 /*!< Date/day do not care in Alarm A comparison */
379 #define LL_RTC_ALMA_MASK_HOURS RTC_ALRMAR_MSK3 /*!< Hours do not care in Alarm A comparison */
380 #define LL_RTC_ALMA_MASK_MINUTES RTC_ALRMAR_MSK2 /*!< Minutes do not care in Alarm A comparison */
381 #define LL_RTC_ALMA_MASK_SECONDS RTC_ALRMAR_MSK1 /*!< Seconds do not care in Alarm A comparison */
382 #define LL_RTC_ALMA_MASK_ALL (RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1) /*!< Masks all */
383 /**
384 * @}
385 */
386
387 /** @defgroup RTC_LL_EC_ALMA_TIME_FORMAT ALARMA TIME FORMAT
388 * @{
389 */
390 #define LL_RTC_ALMA_TIME_FORMAT_AM 0x00000000U /*!< AM or 24-hour format */
391 #define LL_RTC_ALMA_TIME_FORMAT_PM RTC_ALRMAR_PM /*!< PM */
392 /**
393 * @}
394 */
395
396 /** @defgroup RTC_LL_EC_ALMB_MASK ALARMB MASK
397 * @{
398 */
399 #define LL_RTC_ALMB_MASK_NONE 0x00000000U /*!< No masks applied on Alarm B*/
400 #define LL_RTC_ALMB_MASK_DATEWEEKDAY RTC_ALRMBR_MSK4 /*!< Date/day do not care in Alarm B comparison */
401 #define LL_RTC_ALMB_MASK_HOURS RTC_ALRMBR_MSK3 /*!< Hours do not care in Alarm B comparison */
402 #define LL_RTC_ALMB_MASK_MINUTES RTC_ALRMBR_MSK2 /*!< Minutes do not care in Alarm B comparison */
403 #define LL_RTC_ALMB_MASK_SECONDS RTC_ALRMBR_MSK1 /*!< Seconds do not care in Alarm B comparison */
404 #define LL_RTC_ALMB_MASK_ALL (RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1) /*!< Masks all */
405 /**
406 * @}
407 */
408
409 /** @defgroup RTC_LL_EC_ALMB_TIME_FORMAT ALARMB TIME FORMAT
410 * @{
411 */
412 #define LL_RTC_ALMB_TIME_FORMAT_AM 0x00000000U /*!< AM or 24-hour format */
413 #define LL_RTC_ALMB_TIME_FORMAT_PM RTC_ALRMBR_PM /*!< PM */
414 /**
415 * @}
416 */
417
418 /** @defgroup RTC_LL_EC_TIMESTAMP_EDGE TIMESTAMP EDGE
419 * @{
420 */
421 #define LL_RTC_TIMESTAMP_EDGE_RISING 0x00000000U /*!< RTC_TS input rising edge generates a time-stamp event */
422 #define LL_RTC_TIMESTAMP_EDGE_FALLING RTC_CR_TSEDGE /*!< RTC_TS input falling edge generates a time-stamp event */
423 /**
424 * @}
425 */
426
427 /** @defgroup RTC_LL_EC_TS_TIME_FORMAT TIMESTAMP TIME FORMAT
428 * @{
429 */
430 #define LL_RTC_TS_TIME_FORMAT_AM 0x00000000U /*!< AM or 24-hour format */
431 #define LL_RTC_TS_TIME_FORMAT_PM RTC_TSTR_PM /*!< PM */
432 /**
433 * @}
434 */
435
436 /** @defgroup RTC_LL_EC_TAMPER TAMPER
437 * @{
438 */
439 #if defined(RTC_TAMPER1_SUPPORT)
440 #define LL_RTC_TAMPER_1 RTC_TAMPCR_TAMP1E /*!< RTC_TAMP1 input detection */
441 #endif /* RTC_TAMPER1_SUPPORT */
442 #if defined(RTC_TAMPER2_SUPPORT)
443 #define LL_RTC_TAMPER_2 RTC_TAMPCR_TAMP2E /*!< RTC_TAMP2 input detection */
444 #endif /* RTC_TAMPER2_SUPPORT */
445 #if defined(RTC_TAMPER3_SUPPORT)
446 #define LL_RTC_TAMPER_3 RTC_TAMPCR_TAMP3E /*!< RTC_TAMP3 input detection */
447 #endif /* RTC_TAMPER3_SUPPORT */
448 /**
449 * @}
450 */
451
452 /** @defgroup RTC_LL_EC_TAMPER_MASK TAMPER MASK
453 * @{
454 */
455 #if defined(RTC_TAMPER1_SUPPORT)
456 #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 */
457 #endif /* RTC_TAMPER1_SUPPORT */
458 #if defined(RTC_TAMPER2_SUPPORT)
459 #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. */
460 #endif /* RTC_TAMPER2_SUPPORT */
461 #if defined(RTC_TAMPER3_SUPPORT)
462 #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 */
463 #endif /* RTC_TAMPER3_SUPPORT */
464 /**
465 * @}
466 */
467
468 /** @defgroup RTC_LL_EC_TAMPER_NOERASE TAMPER NO ERASE
469 * @{
470 */
471 #if defined(RTC_TAMPER1_SUPPORT)
472 #define LL_RTC_TAMPER_NOERASE_TAMPER1 RTC_TAMPCR_TAMP1NOERASE /*!< Tamper 1 event does not erase the backup registers. */
473 #endif /* RTC_TAMPER1_SUPPORT */
474 #if defined(RTC_TAMPER2_SUPPORT)
475 #define LL_RTC_TAMPER_NOERASE_TAMPER2 RTC_TAMPCR_TAMP2NOERASE /*!< Tamper 2 event does not erase the backup registers. */
476 #endif /* RTC_TAMPER2_SUPPORT */
477 #if defined(RTC_TAMPER3_SUPPORT)
478 #define LL_RTC_TAMPER_NOERASE_TAMPER3 RTC_TAMPCR_TAMP3NOERASE /*!< Tamper 3 event does not erase the backup registers. */
479 #endif /* RTC_TAMPER3_SUPPORT */
480 /**
481 * @}
482 */
483
484 #if defined(RTC_TAMPCR_TAMPPRCH)
485 /** @defgroup RTC_LL_EC_TAMPER_DURATION TAMPER DURATION
486 * @{
487 */
488 #define LL_RTC_TAMPER_DURATION_1RTCCLK 0x00000000U /*!< Tamper pins are pre-charged before sampling during 1 RTCCLK cycle */
489 #define LL_RTC_TAMPER_DURATION_2RTCCLK RTC_TAMPCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before sampling during 2 RTCCLK cycles */
490 #define LL_RTC_TAMPER_DURATION_4RTCCLK RTC_TAMPCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before sampling during 4 RTCCLK cycles */
491 #define LL_RTC_TAMPER_DURATION_8RTCCLK RTC_TAMPCR_TAMPPRCH /*!< Tamper pins are pre-charged before sampling during 8 RTCCLK cycles */
492 /**
493 * @}
494 */
495 #endif /* RTC_TAMPCR_TAMPPRCH */
496
497 #if defined(RTC_TAMPCR_TAMPFLT)
498 /** @defgroup RTC_LL_EC_TAMPER_FILTER TAMPER FILTER
499 * @{
500 */
501 #define LL_RTC_TAMPER_FILTER_DISABLE 0x00000000U /*!< Tamper filter is disabled */
502 #define LL_RTC_TAMPER_FILTER_2SAMPLE RTC_TAMPCR_TAMPFLT_0 /*!< Tamper is activated after 2 consecutive samples at the active level */
503 #define LL_RTC_TAMPER_FILTER_4SAMPLE RTC_TAMPCR_TAMPFLT_1 /*!< Tamper is activated after 4 consecutive samples at the active level */
504 #define LL_RTC_TAMPER_FILTER_8SAMPLE RTC_TAMPCR_TAMPFLT /*!< Tamper is activated after 8 consecutive samples at the active level. */
505 /**
506 * @}
507 */
508 #endif /* RTC_TAMPCR_TAMPFLT */
509
510 #if defined(RTC_TAMPCR_TAMPFREQ)
511 /** @defgroup RTC_LL_EC_TAMPER_SAMPLFREQDIV TAMPER SAMPLING FREQUENCY DIVIDER
512 * @{
513 */
514 #define LL_RTC_TAMPER_SAMPLFREQDIV_32768 0x00000000U /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 32768 */
515 #define LL_RTC_TAMPER_SAMPLFREQDIV_16384 RTC_TAMPCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 16384 */
516 #define LL_RTC_TAMPER_SAMPLFREQDIV_8192 RTC_TAMPCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 8192 */
517 #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 */
518 #define LL_RTC_TAMPER_SAMPLFREQDIV_2048 RTC_TAMPCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 2048 */
519 #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 */
520 #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 */
521 #define LL_RTC_TAMPER_SAMPLFREQDIV_256 RTC_TAMPCR_TAMPFREQ /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 256 */
522 /**
523 * @}
524 */
525 #endif /* RTC_TAMPCR_TAMPFREQ */
526
527 /** @defgroup RTC_LL_EC_TAMPER_ACTIVELEVEL TAMPER ACTIVE LEVEL
528 * @{
529 */
530 #if defined(RTC_TAMPER1_SUPPORT)
531 #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*/
532 #endif /* RTC_TAMPER1_SUPPORT */
533 #if defined(RTC_TAMPER2_SUPPORT)
534 #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*/
535 #endif /* RTC_TAMPER2_SUPPORT */
536 #if defined(RTC_TAMPER3_SUPPORT)
537 #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*/
538 #endif /* RTC_TAMPER3_SUPPORT */
539 /**
540 * @}
541 */
542
543 /** @defgroup RTC_LL_EC_WAKEUPCLOCK_DIV WAKEUP CLOCK DIV
544 * @{
545 */
546 #define LL_RTC_WAKEUPCLOCK_DIV_16 0x00000000U /*!< RTC/16 clock is selected */
547 #define LL_RTC_WAKEUPCLOCK_DIV_8 (RTC_CR_WUCKSEL_0) /*!< RTC/8 clock is selected */
548 #define LL_RTC_WAKEUPCLOCK_DIV_4 (RTC_CR_WUCKSEL_1) /*!< RTC/4 clock is selected */
549 #define LL_RTC_WAKEUPCLOCK_DIV_2 (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_0) /*!< RTC/2 clock is selected */
550 #define LL_RTC_WAKEUPCLOCK_CKSPRE (RTC_CR_WUCKSEL_2) /*!< ck_spre (usually 1 Hz) clock is selected */
551 #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*/
552 /**
553 * @}
554 */
555
556 #if defined(RTC_BACKUP_SUPPORT)
557 /** @defgroup RTC_LL_EC_BKP BACKUP
558 * @{
559 */
560 #define LL_RTC_BKP_DR0 0x00000000U
561 #define LL_RTC_BKP_DR1 0x00000001U
562 #define LL_RTC_BKP_DR2 0x00000002U
563 #define LL_RTC_BKP_DR3 0x00000003U
564 #define LL_RTC_BKP_DR4 0x00000004U
565 #if RTC_BKP_NUMBER > 5
566 #define LL_RTC_BKP_DR5 0x00000005U
567 #define LL_RTC_BKP_DR6 0x00000006U
568 #define LL_RTC_BKP_DR7 0x00000007U
569 #define LL_RTC_BKP_DR8 0x00000008U
570 #define LL_RTC_BKP_DR9 0x00000009U
571 #define LL_RTC_BKP_DR10 0x0000000AU
572 #define LL_RTC_BKP_DR11 0x0000000BU
573 #define LL_RTC_BKP_DR12 0x0000000CU
574 #define LL_RTC_BKP_DR13 0x0000000DU
575 #define LL_RTC_BKP_DR14 0x0000000EU
576 #define LL_RTC_BKP_DR15 0x0000000FU
577 #endif /* RTC_BKP_NUMBER > 5 */
578
579 #if RTC_BKP_NUMBER > 16
580 #define LL_RTC_BKP_DR16 0x00000010U
581 #define LL_RTC_BKP_DR17 0x00000011U
582 #define LL_RTC_BKP_DR18 0x00000012U
583 #define LL_RTC_BKP_DR19 0x00000013U
584 #endif /* RTC_BKP_NUMBER > 16 */
585 /**
586 * @}
587 */
588 #endif /* RTC_BACKUP_SUPPORT */
589
590 /** @defgroup RTC_LL_EC_CALIB_OUTPUT Calibration output
591 * @{
592 */
593 #define LL_RTC_CALIB_OUTPUT_NONE 0x00000000U /*!< Calibration output disabled */
594 #define LL_RTC_CALIB_OUTPUT_1HZ (RTC_CR_COE | RTC_CR_COSEL) /*!< Calibration output is 512 Hz */
595 #define LL_RTC_CALIB_OUTPUT_512HZ (RTC_CR_COE) /*!< Calibration output is 1 Hz */
596 /**
597 * @}
598 */
599
600 /** @defgroup RTC_LL_EC_CALIB_INSERTPULSE Calibration pulse insertion
601 * @{
602 */
603 #define LL_RTC_CALIB_INSERTPULSE_NONE 0x00000000U /*!< No RTCCLK pulses are added */
604 #define LL_RTC_CALIB_INSERTPULSE_SET RTC_CALR_CALP /*!< One RTCCLK pulse is effectively inserted every 2exp11 pulses (frequency increased by 488.5 ppm) */
605 /**
606 * @}
607 */
608
609 /** @defgroup RTC_LL_EC_CALIB_PERIOD Calibration period
610 * @{
611 */
612 #define LL_RTC_CALIB_PERIOD_32SEC 0x00000000U /*!< Use a 32-second calibration cycle period */
613 #define LL_RTC_CALIB_PERIOD_16SEC RTC_CALR_CALW16 /*!< Use a 16-second calibration cycle period */
614 #define LL_RTC_CALIB_PERIOD_8SEC RTC_CALR_CALW8 /*!< Use a 8-second calibration cycle period */
615 /**
616 * @}
617 */
618
619 /**
620 * @}
621 */
622
623 /* Exported macro ------------------------------------------------------------*/
624 /** @defgroup RTC_LL_Exported_Macros RTC Exported Macros
625 * @{
626 */
627
628 /** @defgroup RTC_LL_EM_WRITE_READ Common Write and read registers Macros
629 * @{
630 */
631
632 /**
633 * @brief Write a value in RTC register
634 * @param __INSTANCE__ RTC Instance
635 * @param __REG__ Register to be written
636 * @param __VALUE__ Value to be written in the register
637 * @retval None
638 */
639 #define LL_RTC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
640
641 /**
642 * @brief Read a value in RTC register
643 * @param __INSTANCE__ RTC Instance
644 * @param __REG__ Register to be read
645 * @retval Register value
646 */
647 #define LL_RTC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
648 /**
649 * @}
650 */
651
652 /** @defgroup RTC_LL_EM_Convert Convert helper Macros
653 * @{
654 */
655
656 /**
657 * @brief Helper macro to convert a value from 2 digit decimal format to BCD format
658 * @param __VALUE__ Byte to be converted
659 * @retval Converted byte
660 */
661 #define __LL_RTC_CONVERT_BIN2BCD(__VALUE__) (uint8_t)((((__VALUE__) / 10U) << 4U) | ((__VALUE__) % 10U))
662
663 /**
664 * @brief Helper macro to convert a value from BCD format to 2 digit decimal format
665 * @param __VALUE__ BCD value to be converted
666 * @retval Converted byte
667 */
668 #define __LL_RTC_CONVERT_BCD2BIN(__VALUE__) (uint8_t)((((uint8_t)((__VALUE__)\
669 & (uint8_t)0xF0U) >> (uint8_t)0x4U) * 10U ) + ((__VALUE__) & (uint8_t)0x0FU))
670
671 /**
672 * @}
673 */
674
675 /** @defgroup RTC_LL_EM_Date Date helper Macros
676 * @{
677 */
678
679 /**
680 * @brief Helper macro to retrieve weekday.
681 * @param __RTC_DATE__ Date returned by @ref LL_RTC_DATE_Get function.
682 * @retval Returned value can be one of the following values:
683 * @arg @ref LL_RTC_WEEKDAY_MONDAY
684 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
685 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
686 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
687 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
688 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
689 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
690 */
691 #define __LL_RTC_GET_WEEKDAY(__RTC_DATE__) (((__RTC_DATE__) >> RTC_OFFSET_WEEKDAY) & 0x000000FFU)
692
693 /**
694 * @brief Helper macro to retrieve Year in BCD format
695 * @param __RTC_DATE__ Value returned by @ref LL_RTC_DATE_Get
696 * @retval Year in BCD format (0x00 . . . 0x99)
697 */
698 #define __LL_RTC_GET_YEAR(__RTC_DATE__) ((__RTC_DATE__) & 0x000000FFU)
699
700 /**
701 * @brief Helper macro to retrieve Month in BCD format
702 * @param __RTC_DATE__ Value returned by @ref LL_RTC_DATE_Get
703 * @retval Returned value can be one of the following values:
704 * @arg @ref LL_RTC_MONTH_JANUARY
705 * @arg @ref LL_RTC_MONTH_FEBRUARY
706 * @arg @ref LL_RTC_MONTH_MARCH
707 * @arg @ref LL_RTC_MONTH_APRIL
708 * @arg @ref LL_RTC_MONTH_MAY
709 * @arg @ref LL_RTC_MONTH_JUNE
710 * @arg @ref LL_RTC_MONTH_JULY
711 * @arg @ref LL_RTC_MONTH_AUGUST
712 * @arg @ref LL_RTC_MONTH_SEPTEMBER
713 * @arg @ref LL_RTC_MONTH_OCTOBER
714 * @arg @ref LL_RTC_MONTH_NOVEMBER
715 * @arg @ref LL_RTC_MONTH_DECEMBER
716 */
717 #define __LL_RTC_GET_MONTH(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_MONTH) & 0x000000FFU)
718
719 /**
720 * @brief Helper macro to retrieve Day in BCD format
721 * @param __RTC_DATE__ Value returned by @ref LL_RTC_DATE_Get
722 * @retval Day in BCD format (0x01 . . . 0x31)
723 */
724 #define __LL_RTC_GET_DAY(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_DAY) & 0x000000FFU)
725
726 /**
727 * @}
728 */
729
730 /** @defgroup RTC_LL_EM_Time Time helper Macros
731 * @{
732 */
733
734 /**
735 * @brief Helper macro to retrieve hour in BCD format
736 * @param __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
737 * @retval Hours in BCD format (0x01. . .0x12 or between Min_Data=0x00 and Max_Data=0x23)
738 */
739 #define __LL_RTC_GET_HOUR(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_HOUR) & 0x000000FFU)
740
741 /**
742 * @brief Helper macro to retrieve minute in BCD format
743 * @param __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
744 * @retval Minutes in BCD format (0x00. . .0x59)
745 */
746 #define __LL_RTC_GET_MINUTE(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_MINUTE) & 0x000000FFU)
747
748 /**
749 * @brief Helper macro to retrieve second in BCD format
750 * @param __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
751 * @retval Seconds in format (0x00. . .0x59)
752 */
753 #define __LL_RTC_GET_SECOND(__RTC_TIME__) ((__RTC_TIME__) & 0x000000FFU)
754
755 /**
756 * @}
757 */
758
759 /**
760 * @}
761 */
762
763 /* Exported functions --------------------------------------------------------*/
764 /** @defgroup RTC_LL_Exported_Functions RTC Exported Functions
765 * @{
766 */
767
768 /** @defgroup RTC_LL_EF_Configuration Configuration
769 * @{
770 */
771
772 /**
773 * @brief Set Hours format (24 hour/day or AM/PM hour format)
774 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
775 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
776 * @rmtoll CR FMT LL_RTC_SetHourFormat
777 * @param RTCx RTC Instance
778 * @param HourFormat This parameter can be one of the following values:
779 * @arg @ref LL_RTC_HOURFORMAT_24HOUR
780 * @arg @ref LL_RTC_HOURFORMAT_AMPM
781 * @retval None
782 */
LL_RTC_SetHourFormat(RTC_TypeDef * RTCx,uint32_t HourFormat)783 __STATIC_INLINE void LL_RTC_SetHourFormat(RTC_TypeDef *RTCx, uint32_t HourFormat)
784 {
785 MODIFY_REG(RTCx->CR, RTC_CR_FMT, HourFormat);
786 }
787
788 /**
789 * @brief Get Hours format (24 hour/day or AM/PM hour format)
790 * @rmtoll CR FMT LL_RTC_GetHourFormat
791 * @param RTCx RTC Instance
792 * @retval Returned value can be one of the following values:
793 * @arg @ref LL_RTC_HOURFORMAT_24HOUR
794 * @arg @ref LL_RTC_HOURFORMAT_AMPM
795 */
LL_RTC_GetHourFormat(RTC_TypeDef * RTCx)796 __STATIC_INLINE uint32_t LL_RTC_GetHourFormat(RTC_TypeDef *RTCx)
797 {
798 return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_FMT));
799 }
800
801 /**
802 * @brief Select the flag to be routed to RTC_ALARM output
803 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
804 * @rmtoll CR OSEL LL_RTC_SetAlarmOutEvent
805 * @param RTCx RTC Instance
806 * @param AlarmOutput This parameter can be one of the following values:
807 * @arg @ref LL_RTC_ALARMOUT_DISABLE
808 * @arg @ref LL_RTC_ALARMOUT_ALMA
809 * @arg @ref LL_RTC_ALARMOUT_ALMB
810 * @arg @ref LL_RTC_ALARMOUT_WAKEUP
811 * @retval None
812 */
LL_RTC_SetAlarmOutEvent(RTC_TypeDef * RTCx,uint32_t AlarmOutput)813 __STATIC_INLINE void LL_RTC_SetAlarmOutEvent(RTC_TypeDef *RTCx, uint32_t AlarmOutput)
814 {
815 MODIFY_REG(RTCx->CR, RTC_CR_OSEL, AlarmOutput);
816 }
817
818 /**
819 * @brief Get the flag to be routed to RTC_ALARM output
820 * @rmtoll CR OSEL LL_RTC_GetAlarmOutEvent
821 * @param RTCx RTC Instance
822 * @retval Returned value can be one of the following values:
823 * @arg @ref LL_RTC_ALARMOUT_DISABLE
824 * @arg @ref LL_RTC_ALARMOUT_ALMA
825 * @arg @ref LL_RTC_ALARMOUT_ALMB
826 * @arg @ref LL_RTC_ALARMOUT_WAKEUP
827 */
LL_RTC_GetAlarmOutEvent(RTC_TypeDef * RTCx)828 __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutEvent(RTC_TypeDef *RTCx)
829 {
830 return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_OSEL));
831 }
832
833 #if defined(RTC_OR_ALARMOUTTYPE)
834 /**
835 * @brief Set RTC_ALARM output type (ALARM in push-pull or open-drain output)
836 * @note Used only when RTC_ALARM is mapped on PC13
837 * @rmtoll OR ALARMOUTTYPE LL_RTC_SetAlarmOutputType
838 * @param RTCx RTC Instance
839 * @param Output This parameter can be one of the following values:
840 * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
841 * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
842 * @retval None
843 */
LL_RTC_SetAlarmOutputType(RTC_TypeDef * RTCx,uint32_t Output)844 __STATIC_INLINE void LL_RTC_SetAlarmOutputType(RTC_TypeDef *RTCx, uint32_t Output)
845 {
846 MODIFY_REG(RTCx->OR, RTC_OR_ALARMOUTTYPE, Output);
847 }
848
849 /**
850 * @brief Get RTC_ALARM output type (ALARM in push-pull or open-drain output)
851 * @note used only when RTC_ALARM is mapped on PC13
852 * @rmtoll OR ALARMOUTTYPE LL_RTC_GetAlarmOutputType
853 * @param RTCx RTC Instance
854 * @retval Returned value can be one of the following values:
855 * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
856 * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
857 */
LL_RTC_GetAlarmOutputType(RTC_TypeDef * RTCx)858 __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutputType(RTC_TypeDef *RTCx)
859 {
860 return (uint32_t)(READ_BIT(RTCx->OR, RTC_OR_ALARMOUTTYPE));
861 }
862 #endif /* RTC_OR_ALARMOUTTYPE */
863
864 /**
865 * @brief Enable initialization mode
866 * @note Initialization mode is used to program time and date register (RTC_TR and RTC_DR)
867 * and prescaler register (RTC_PRER).
868 * Counters are stopped and start counting from the new value when INIT is reset.
869 * @rmtoll ISR INIT LL_RTC_EnableInitMode
870 * @param RTCx RTC Instance
871 * @retval None
872 */
LL_RTC_EnableInitMode(RTC_TypeDef * RTCx)873 __STATIC_INLINE void LL_RTC_EnableInitMode(RTC_TypeDef *RTCx)
874 {
875 /* Set the Initialization mode */
876 WRITE_REG(RTCx->ISR, 0xFFFFFFFFU);
877 }
878
879 /**
880 * @brief Disable initialization mode (Free running mode)
881 * @rmtoll ISR INIT LL_RTC_DisableInitMode
882 * @param RTCx RTC Instance
883 * @retval None
884 */
LL_RTC_DisableInitMode(RTC_TypeDef * RTCx)885 __STATIC_INLINE void LL_RTC_DisableInitMode(RTC_TypeDef *RTCx)
886 {
887 /* Exit Initialization mode */
888 WRITE_REG(RTCx->ISR, (uint32_t)~RTC_ISR_INIT);
889 }
890
891 /**
892 * @brief Set Output polarity (pin is low when ALRAF/ALRBF/WUTF is asserted)
893 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
894 * @rmtoll CR POL LL_RTC_SetOutputPolarity
895 * @param RTCx RTC Instance
896 * @param Polarity This parameter can be one of the following values:
897 * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
898 * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
899 * @retval None
900 */
LL_RTC_SetOutputPolarity(RTC_TypeDef * RTCx,uint32_t Polarity)901 __STATIC_INLINE void LL_RTC_SetOutputPolarity(RTC_TypeDef *RTCx, uint32_t Polarity)
902 {
903 MODIFY_REG(RTCx->CR, RTC_CR_POL, Polarity);
904 }
905
906 /**
907 * @brief Get Output polarity
908 * @rmtoll CR POL LL_RTC_GetOutputPolarity
909 * @param RTCx RTC Instance
910 * @retval Returned value can be one of the following values:
911 * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
912 * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
913 */
LL_RTC_GetOutputPolarity(RTC_TypeDef * RTCx)914 __STATIC_INLINE uint32_t LL_RTC_GetOutputPolarity(RTC_TypeDef *RTCx)
915 {
916 return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_POL));
917 }
918
919 /**
920 * @brief Enable Bypass the shadow registers
921 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
922 * @rmtoll CR BYPSHAD LL_RTC_EnableShadowRegBypass
923 * @param RTCx RTC Instance
924 * @retval None
925 */
LL_RTC_EnableShadowRegBypass(RTC_TypeDef * RTCx)926 __STATIC_INLINE void LL_RTC_EnableShadowRegBypass(RTC_TypeDef *RTCx)
927 {
928 SET_BIT(RTCx->CR, RTC_CR_BYPSHAD);
929 }
930
931 /**
932 * @brief Disable Bypass the shadow registers
933 * @rmtoll CR BYPSHAD LL_RTC_DisableShadowRegBypass
934 * @param RTCx RTC Instance
935 * @retval None
936 */
LL_RTC_DisableShadowRegBypass(RTC_TypeDef * RTCx)937 __STATIC_INLINE void LL_RTC_DisableShadowRegBypass(RTC_TypeDef *RTCx)
938 {
939 CLEAR_BIT(RTCx->CR, RTC_CR_BYPSHAD);
940 }
941
942 /**
943 * @brief Check if Shadow registers bypass is enabled or not.
944 * @rmtoll CR BYPSHAD LL_RTC_IsShadowRegBypassEnabled
945 * @param RTCx RTC Instance
946 * @retval State of bit (1 or 0).
947 */
LL_RTC_IsShadowRegBypassEnabled(RTC_TypeDef * RTCx)948 __STATIC_INLINE uint32_t LL_RTC_IsShadowRegBypassEnabled(RTC_TypeDef *RTCx)
949 {
950 return ((READ_BIT(RTCx->CR, RTC_CR_BYPSHAD) == (RTC_CR_BYPSHAD)) ? 1UL : 0UL);
951 }
952
953 /**
954 * @brief Enable RTC_REFIN reference clock detection (50 or 60 Hz)
955 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
956 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
957 * @rmtoll CR REFCKON LL_RTC_EnableRefClock
958 * @param RTCx RTC Instance
959 * @retval None
960 */
LL_RTC_EnableRefClock(RTC_TypeDef * RTCx)961 __STATIC_INLINE void LL_RTC_EnableRefClock(RTC_TypeDef *RTCx)
962 {
963 SET_BIT(RTCx->CR, RTC_CR_REFCKON);
964 }
965
966 /**
967 * @brief Disable RTC_REFIN reference clock detection (50 or 60 Hz)
968 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
969 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
970 * @rmtoll CR REFCKON LL_RTC_DisableRefClock
971 * @param RTCx RTC Instance
972 * @retval None
973 */
LL_RTC_DisableRefClock(RTC_TypeDef * RTCx)974 __STATIC_INLINE void LL_RTC_DisableRefClock(RTC_TypeDef *RTCx)
975 {
976 CLEAR_BIT(RTCx->CR, RTC_CR_REFCKON);
977 }
978
979 /**
980 * @brief Set Asynchronous prescaler factor
981 * @rmtoll PRER PREDIV_A LL_RTC_SetAsynchPrescaler
982 * @param RTCx RTC Instance
983 * @param AsynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7F
984 * @retval None
985 */
LL_RTC_SetAsynchPrescaler(RTC_TypeDef * RTCx,uint32_t AsynchPrescaler)986 __STATIC_INLINE void LL_RTC_SetAsynchPrescaler(RTC_TypeDef *RTCx, uint32_t AsynchPrescaler)
987 {
988 MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_A, AsynchPrescaler << RTC_PRER_PREDIV_A_Pos);
989 }
990
991 /**
992 * @brief Set Synchronous prescaler factor
993 * @rmtoll PRER PREDIV_S LL_RTC_SetSynchPrescaler
994 * @param RTCx RTC Instance
995 * @param SynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7FFF
996 * @retval None
997 */
LL_RTC_SetSynchPrescaler(RTC_TypeDef * RTCx,uint32_t SynchPrescaler)998 __STATIC_INLINE void LL_RTC_SetSynchPrescaler(RTC_TypeDef *RTCx, uint32_t SynchPrescaler)
999 {
1000 MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_S, SynchPrescaler);
1001 }
1002
1003 /**
1004 * @brief Get Asynchronous prescaler factor
1005 * @rmtoll PRER PREDIV_A LL_RTC_GetAsynchPrescaler
1006 * @param RTCx RTC Instance
1007 * @retval Value between Min_Data = 0 and Max_Data = 0x7F
1008 */
LL_RTC_GetAsynchPrescaler(RTC_TypeDef * RTCx)1009 __STATIC_INLINE uint32_t LL_RTC_GetAsynchPrescaler(RTC_TypeDef *RTCx)
1010 {
1011 return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_A) >> RTC_PRER_PREDIV_A_Pos);
1012 }
1013
1014 /**
1015 * @brief Get Synchronous prescaler factor
1016 * @rmtoll PRER PREDIV_S LL_RTC_GetSynchPrescaler
1017 * @param RTCx RTC Instance
1018 * @retval Value between Min_Data = 0 and Max_Data = 0x7FFF
1019 */
LL_RTC_GetSynchPrescaler(RTC_TypeDef * RTCx)1020 __STATIC_INLINE uint32_t LL_RTC_GetSynchPrescaler(RTC_TypeDef *RTCx)
1021 {
1022 return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_S));
1023 }
1024
1025 /**
1026 * @brief Enable the write protection for RTC registers.
1027 * @rmtoll WPR KEY LL_RTC_EnableWriteProtection
1028 * @param RTCx RTC Instance
1029 * @retval None
1030 */
LL_RTC_EnableWriteProtection(RTC_TypeDef * RTCx)1031 __STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx)
1032 {
1033 WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_DISABLE);
1034 }
1035
1036 /**
1037 * @brief Disable the write protection for RTC registers.
1038 * @rmtoll WPR KEY LL_RTC_DisableWriteProtection
1039 * @param RTCx RTC Instance
1040 * @retval None
1041 */
LL_RTC_DisableWriteProtection(RTC_TypeDef * RTCx)1042 __STATIC_INLINE void LL_RTC_DisableWriteProtection(RTC_TypeDef *RTCx)
1043 {
1044 WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_1);
1045 WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_2);
1046 }
1047
1048 /**
1049 * @brief Enable RTC_OUT remap
1050 * @rmtoll OR OUT_RMP LL_RTC_EnableOutRemap
1051 * @param RTCx RTC Instance
1052 * @retval None
1053 */
LL_RTC_EnableOutRemap(RTC_TypeDef * RTCx)1054 __STATIC_INLINE void LL_RTC_EnableOutRemap(RTC_TypeDef *RTCx)
1055 {
1056 SET_BIT(RTCx->OR, RTC_OR_OUT_RMP);
1057 }
1058
1059 /**
1060 * @brief Disable RTC_OUT remap
1061 * @rmtoll OR OUT_RMP LL_RTC_DisableOutRemap
1062 * @param RTCx RTC Instance
1063 * @retval None
1064 */
LL_RTC_DisableOutRemap(RTC_TypeDef * RTCx)1065 __STATIC_INLINE void LL_RTC_DisableOutRemap(RTC_TypeDef *RTCx)
1066 {
1067 CLEAR_BIT(RTCx->OR, RTC_OR_OUT_RMP);
1068 }
1069
1070 /**
1071 * @}
1072 */
1073
1074 /** @defgroup RTC_LL_EF_Time Time
1075 * @{
1076 */
1077
1078 /**
1079 * @brief Set time format (AM/24-hour or PM notation)
1080 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1081 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1082 * @rmtoll TR PM LL_RTC_TIME_SetFormat
1083 * @param RTCx RTC Instance
1084 * @param TimeFormat This parameter can be one of the following values:
1085 * @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
1086 * @arg @ref LL_RTC_TIME_FORMAT_PM
1087 * @retval None
1088 */
LL_RTC_TIME_SetFormat(RTC_TypeDef * RTCx,uint32_t TimeFormat)1089 __STATIC_INLINE void LL_RTC_TIME_SetFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
1090 {
1091 MODIFY_REG(RTCx->TR, RTC_TR_PM, TimeFormat);
1092 }
1093
1094 /**
1095 * @brief Get time format (AM or PM notation)
1096 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1097 * before reading this bit
1098 * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1099 * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1100 * @rmtoll TR PM LL_RTC_TIME_GetFormat
1101 * @param RTCx RTC Instance
1102 * @retval Returned value can be one of the following values:
1103 * @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
1104 * @arg @ref LL_RTC_TIME_FORMAT_PM
1105 */
LL_RTC_TIME_GetFormat(RTC_TypeDef * RTCx)1106 __STATIC_INLINE uint32_t LL_RTC_TIME_GetFormat(RTC_TypeDef *RTCx)
1107 {
1108 return (uint32_t)(READ_BIT(RTCx->TR, RTC_TR_PM));
1109 }
1110
1111 /**
1112 * @brief Set Hours in BCD format
1113 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1114 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1115 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert hour from binary to BCD format
1116 * @rmtoll TR HT LL_RTC_TIME_SetHour\n
1117 * TR HU LL_RTC_TIME_SetHour
1118 * @param RTCx RTC Instance
1119 * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1120 * @retval None
1121 */
LL_RTC_TIME_SetHour(RTC_TypeDef * RTCx,uint32_t Hours)1122 __STATIC_INLINE void LL_RTC_TIME_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
1123 {
1124 MODIFY_REG(RTCx->TR, (RTC_TR_HT | RTC_TR_HU),
1125 (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)));
1126 }
1127
1128 /**
1129 * @brief Get Hours in BCD format
1130 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1131 * before reading this bit
1132 * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1133 * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1134 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert hour from BCD to
1135 * Binary format
1136 * @rmtoll TR HT LL_RTC_TIME_GetHour\n
1137 * TR HU LL_RTC_TIME_GetHour
1138 * @param RTCx RTC Instance
1139 * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1140 */
LL_RTC_TIME_GetHour(RTC_TypeDef * RTCx)1141 __STATIC_INLINE uint32_t LL_RTC_TIME_GetHour(RTC_TypeDef *RTCx)
1142 {
1143 uint32_t temp;
1144
1145 temp = READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU));
1146 return (uint32_t)((((temp & RTC_TR_HT) >> RTC_TR_HT_Pos) << 4U) | ((temp & RTC_TR_HU) >> RTC_TR_HU_Pos));
1147 }
1148
1149 /**
1150 * @brief Set Minutes in BCD format
1151 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1152 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1153 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
1154 * @rmtoll TR MNT LL_RTC_TIME_SetMinute\n
1155 * TR MNU LL_RTC_TIME_SetMinute
1156 * @param RTCx RTC Instance
1157 * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
1158 * @retval None
1159 */
LL_RTC_TIME_SetMinute(RTC_TypeDef * RTCx,uint32_t Minutes)1160 __STATIC_INLINE void LL_RTC_TIME_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
1161 {
1162 MODIFY_REG(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU),
1163 (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)));
1164 }
1165
1166 /**
1167 * @brief Get Minutes in BCD format
1168 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1169 * before reading this bit
1170 * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1171 * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1172 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert minute from BCD
1173 * to Binary format
1174 * @rmtoll TR MNT LL_RTC_TIME_GetMinute\n
1175 * TR MNU LL_RTC_TIME_GetMinute
1176 * @param RTCx RTC Instance
1177 * @retval Value between Min_Data=0x00 and Max_Data=0x59
1178 */
LL_RTC_TIME_GetMinute(RTC_TypeDef * RTCx)1179 __STATIC_INLINE uint32_t LL_RTC_TIME_GetMinute(RTC_TypeDef *RTCx)
1180 {
1181 uint32_t temp;
1182
1183 temp = READ_BIT(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU));
1184 return (uint32_t)((((temp & RTC_TR_MNT) >> RTC_TR_MNT_Pos) << 4U) | ((temp & RTC_TR_MNU) >> RTC_TR_MNU_Pos));
1185 }
1186
1187 /**
1188 * @brief Set Seconds in BCD format
1189 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1190 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1191 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
1192 * @rmtoll TR ST LL_RTC_TIME_SetSecond\n
1193 * TR SU LL_RTC_TIME_SetSecond
1194 * @param RTCx RTC Instance
1195 * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
1196 * @retval None
1197 */
LL_RTC_TIME_SetSecond(RTC_TypeDef * RTCx,uint32_t Seconds)1198 __STATIC_INLINE void LL_RTC_TIME_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
1199 {
1200 MODIFY_REG(RTCx->TR, (RTC_TR_ST | RTC_TR_SU),
1201 (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos)));
1202 }
1203
1204 /**
1205 * @brief Get Seconds in BCD format
1206 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1207 * before reading this bit
1208 * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1209 * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1210 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD
1211 * to Binary format
1212 * @rmtoll TR ST LL_RTC_TIME_GetSecond\n
1213 * TR SU LL_RTC_TIME_GetSecond
1214 * @param RTCx RTC Instance
1215 * @retval Value between Min_Data=0x00 and Max_Data=0x59
1216 */
LL_RTC_TIME_GetSecond(RTC_TypeDef * RTCx)1217 __STATIC_INLINE uint32_t LL_RTC_TIME_GetSecond(RTC_TypeDef *RTCx)
1218 {
1219 uint32_t temp;
1220
1221 temp = READ_BIT(RTCx->TR, (RTC_TR_ST | RTC_TR_SU));
1222 return (uint32_t)((((temp & RTC_TR_ST) >> RTC_TR_ST_Pos) << 4U) | ((temp & RTC_TR_SU) >> RTC_TR_SU_Pos));
1223 }
1224
1225 /**
1226 * @brief Set time (hour, minute and second) in BCD format
1227 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1228 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1229 * @note TimeFormat and Hours should follow the same format
1230 * @rmtoll TR PM LL_RTC_TIME_Config\n
1231 * TR HT LL_RTC_TIME_Config\n
1232 * TR HU LL_RTC_TIME_Config\n
1233 * TR MNT LL_RTC_TIME_Config\n
1234 * TR MNU LL_RTC_TIME_Config\n
1235 * TR ST LL_RTC_TIME_Config\n
1236 * TR SU LL_RTC_TIME_Config
1237 * @param RTCx RTC Instance
1238 * @param Format12_24 This parameter can be one of the following values:
1239 * @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
1240 * @arg @ref LL_RTC_TIME_FORMAT_PM
1241 * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1242 * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
1243 * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
1244 * @retval None
1245 */
LL_RTC_TIME_Config(RTC_TypeDef * RTCx,uint32_t Format12_24,uint32_t Hours,uint32_t Minutes,uint32_t Seconds)1246 __STATIC_INLINE void LL_RTC_TIME_Config(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes,
1247 uint32_t Seconds)
1248 {
1249 uint32_t temp;
1250
1251 temp = Format12_24 | \
1252 (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)) | \
1253 (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)) | \
1254 (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos));
1255 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);
1256 }
1257
1258 /**
1259 * @brief Get time (hour, minute and second) in BCD format
1260 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1261 * before reading this bit
1262 * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1263 * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1264 * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
1265 * are available to get independently each parameter.
1266 * @rmtoll TR HT LL_RTC_TIME_Get\n
1267 * TR HU LL_RTC_TIME_Get\n
1268 * TR MNT LL_RTC_TIME_Get\n
1269 * TR MNU LL_RTC_TIME_Get\n
1270 * TR ST LL_RTC_TIME_Get\n
1271 * TR SU LL_RTC_TIME_Get
1272 * @param RTCx RTC Instance
1273 * @retval Combination of hours, minutes and seconds (Format: 0x00HHMMSS).
1274 */
LL_RTC_TIME_Get(RTC_TypeDef * RTCx)1275 __STATIC_INLINE uint32_t LL_RTC_TIME_Get(RTC_TypeDef *RTCx)
1276 {
1277 uint32_t temp;
1278
1279 temp = READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU | RTC_TR_MNT | RTC_TR_MNU | RTC_TR_ST | RTC_TR_SU));
1280 return (uint32_t)((((((temp & RTC_TR_HT) >> RTC_TR_HT_Pos) << 4U) | ((temp & RTC_TR_HU) >> RTC_TR_HU_Pos)) << RTC_OFFSET_HOUR) | \
1281 (((((temp & RTC_TR_MNT) >> RTC_TR_MNT_Pos) << 4U) | ((temp & RTC_TR_MNU) >> RTC_TR_MNU_Pos)) << RTC_OFFSET_MINUTE) | \
1282 ((((temp & RTC_TR_ST) >> RTC_TR_ST_Pos) << 4U) | ((temp & RTC_TR_SU) >> RTC_TR_SU_Pos)));
1283 }
1284
1285 /**
1286 * @brief Memorize whether the daylight saving time change has been performed
1287 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1288 * @rmtoll CR BKP LL_RTC_TIME_EnableDayLightStore
1289 * @param RTCx RTC Instance
1290 * @retval None
1291 */
LL_RTC_TIME_EnableDayLightStore(RTC_TypeDef * RTCx)1292 __STATIC_INLINE void LL_RTC_TIME_EnableDayLightStore(RTC_TypeDef *RTCx)
1293 {
1294 SET_BIT(RTCx->CR, RTC_CR_BKP);
1295 }
1296
1297 /**
1298 * @brief Disable memorization whether the daylight saving time change has been performed.
1299 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1300 * @rmtoll CR BKP LL_RTC_TIME_DisableDayLightStore
1301 * @param RTCx RTC Instance
1302 * @retval None
1303 */
LL_RTC_TIME_DisableDayLightStore(RTC_TypeDef * RTCx)1304 __STATIC_INLINE void LL_RTC_TIME_DisableDayLightStore(RTC_TypeDef *RTCx)
1305 {
1306 CLEAR_BIT(RTCx->CR, RTC_CR_BKP);
1307 }
1308
1309 /**
1310 * @brief Check if RTC Day Light Saving stored operation has been enabled or not
1311 * @rmtoll CR BKP LL_RTC_TIME_IsDayLightStoreEnabled
1312 * @param RTCx RTC Instance
1313 * @retval State of bit (1 or 0).
1314 */
LL_RTC_TIME_IsDayLightStoreEnabled(RTC_TypeDef * RTCx)1315 __STATIC_INLINE uint32_t LL_RTC_TIME_IsDayLightStoreEnabled(RTC_TypeDef *RTCx)
1316 {
1317 return ((READ_BIT(RTCx->CR, RTC_CR_BKP) == (RTC_CR_BKP)) ? 1UL : 0UL);
1318 }
1319
1320 /**
1321 * @brief Subtract 1 hour (winter time change)
1322 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1323 * @rmtoll CR SUB1H LL_RTC_TIME_DecHour
1324 * @param RTCx RTC Instance
1325 * @retval None
1326 */
LL_RTC_TIME_DecHour(RTC_TypeDef * RTCx)1327 __STATIC_INLINE void LL_RTC_TIME_DecHour(RTC_TypeDef *RTCx)
1328 {
1329 SET_BIT(RTCx->CR, RTC_CR_SUB1H);
1330 }
1331
1332 /**
1333 * @brief Add 1 hour (summer time change)
1334 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1335 * @rmtoll CR ADD1H LL_RTC_TIME_IncHour
1336 * @param RTCx RTC Instance
1337 * @retval None
1338 */
LL_RTC_TIME_IncHour(RTC_TypeDef * RTCx)1339 __STATIC_INLINE void LL_RTC_TIME_IncHour(RTC_TypeDef *RTCx)
1340 {
1341 SET_BIT(RTCx->CR, RTC_CR_ADD1H);
1342 }
1343
1344 /**
1345 * @brief Get Sub second value in the synchronous prescaler counter.
1346 * @note You can use both SubSeconds value and SecondFraction (PREDIV_S through
1347 * LL_RTC_GetSynchPrescaler function) terms returned to convert Calendar
1348 * SubSeconds value in second fraction ratio with time unit following
1349 * generic formula:
1350 * ==> Seconds fraction ratio * time_unit= [(SecondFraction-SubSeconds)/(SecondFraction+1)] * time_unit
1351 * This conversion can be performed only if no shift operation is pending
1352 * (ie. SHFP=0) when PREDIV_S >= SS.
1353 * @rmtoll SSR SS LL_RTC_TIME_GetSubSecond
1354 * @param RTCx RTC Instance
1355 * @retval Sub second value (number between 0 and 65535)
1356 */
LL_RTC_TIME_GetSubSecond(RTC_TypeDef * RTCx)1357 __STATIC_INLINE uint32_t LL_RTC_TIME_GetSubSecond(RTC_TypeDef *RTCx)
1358 {
1359 return (uint32_t)(READ_BIT(RTCx->SSR, RTC_SSR_SS));
1360 }
1361
1362 /**
1363 * @brief Synchronize to a remote clock with a high degree of precision.
1364 * @note This operation effectively subtracts from (delays) or advance the clock of a fraction of a second.
1365 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1366 * @note When REFCKON is set, firmware must not write to Shift control register.
1367 * @rmtoll SHIFTR ADD1S LL_RTC_TIME_Synchronize\n
1368 * SHIFTR SUBFS LL_RTC_TIME_Synchronize
1369 * @param RTCx RTC Instance
1370 * @param ShiftSecond This parameter can be one of the following values:
1371 * @arg @ref LL_RTC_SHIFT_SECOND_DELAY
1372 * @arg @ref LL_RTC_SHIFT_SECOND_ADVANCE
1373 * @param Fraction Number of Seconds Fractions (any value from 0 to 0x7FFF)
1374 * @retval None
1375 */
LL_RTC_TIME_Synchronize(RTC_TypeDef * RTCx,uint32_t ShiftSecond,uint32_t Fraction)1376 __STATIC_INLINE void LL_RTC_TIME_Synchronize(RTC_TypeDef *RTCx, uint32_t ShiftSecond, uint32_t Fraction)
1377 {
1378 WRITE_REG(RTCx->SHIFTR, ShiftSecond | Fraction);
1379 }
1380
1381 /**
1382 * @}
1383 */
1384
1385 /** @defgroup RTC_LL_EF_Date Date
1386 * @{
1387 */
1388
1389 /**
1390 * @brief Set Year in BCD format
1391 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Year from binary to BCD format
1392 * @rmtoll DR YT LL_RTC_DATE_SetYear\n
1393 * DR YU LL_RTC_DATE_SetYear
1394 * @param RTCx RTC Instance
1395 * @param Year Value between Min_Data=0x00 and Max_Data=0x99
1396 * @retval None
1397 */
LL_RTC_DATE_SetYear(RTC_TypeDef * RTCx,uint32_t Year)1398 __STATIC_INLINE void LL_RTC_DATE_SetYear(RTC_TypeDef *RTCx, uint32_t Year)
1399 {
1400 MODIFY_REG(RTCx->DR, (RTC_DR_YT | RTC_DR_YU),
1401 (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos)));
1402 }
1403
1404 /**
1405 * @brief Get Year in BCD format
1406 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1407 * before reading this bit
1408 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Year from BCD to Binary format
1409 * @rmtoll DR YT LL_RTC_DATE_GetYear\n
1410 * DR YU LL_RTC_DATE_GetYear
1411 * @param RTCx RTC Instance
1412 * @retval Value between Min_Data=0x00 and Max_Data=0x99
1413 */
LL_RTC_DATE_GetYear(RTC_TypeDef * RTCx)1414 __STATIC_INLINE uint32_t LL_RTC_DATE_GetYear(RTC_TypeDef *RTCx)
1415 {
1416 uint32_t temp;
1417
1418 temp = READ_BIT(RTCx->DR, (RTC_DR_YT | RTC_DR_YU));
1419 return (uint32_t)((((temp & RTC_DR_YT) >> RTC_DR_YT_Pos) << 4U) | ((temp & RTC_DR_YU) >> RTC_DR_YU_Pos));
1420 }
1421
1422 /**
1423 * @brief Set Week day
1424 * @rmtoll DR WDU LL_RTC_DATE_SetWeekDay
1425 * @param RTCx RTC Instance
1426 * @param WeekDay This parameter can be one of the following values:
1427 * @arg @ref LL_RTC_WEEKDAY_MONDAY
1428 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
1429 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1430 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
1431 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
1432 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
1433 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
1434 * @retval None
1435 */
LL_RTC_DATE_SetWeekDay(RTC_TypeDef * RTCx,uint32_t WeekDay)1436 __STATIC_INLINE void LL_RTC_DATE_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
1437 {
1438 MODIFY_REG(RTCx->DR, RTC_DR_WDU, WeekDay << RTC_DR_WDU_Pos);
1439 }
1440
1441 /**
1442 * @brief Get Week day
1443 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1444 * before reading this bit
1445 * @rmtoll DR WDU LL_RTC_DATE_GetWeekDay
1446 * @param RTCx RTC Instance
1447 * @retval Returned value can be one of the following values:
1448 * @arg @ref LL_RTC_WEEKDAY_MONDAY
1449 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
1450 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1451 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
1452 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
1453 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
1454 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
1455 */
LL_RTC_DATE_GetWeekDay(RTC_TypeDef * RTCx)1456 __STATIC_INLINE uint32_t LL_RTC_DATE_GetWeekDay(RTC_TypeDef *RTCx)
1457 {
1458 return (uint32_t)(READ_BIT(RTCx->DR, RTC_DR_WDU) >> RTC_DR_WDU_Pos);
1459 }
1460
1461 /**
1462 * @brief Set Month in BCD format
1463 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Month from binary to BCD format
1464 * @rmtoll DR MT LL_RTC_DATE_SetMonth\n
1465 * DR MU LL_RTC_DATE_SetMonth
1466 * @param RTCx RTC Instance
1467 * @param Month This parameter can be one of the following values:
1468 * @arg @ref LL_RTC_MONTH_JANUARY
1469 * @arg @ref LL_RTC_MONTH_FEBRUARY
1470 * @arg @ref LL_RTC_MONTH_MARCH
1471 * @arg @ref LL_RTC_MONTH_APRIL
1472 * @arg @ref LL_RTC_MONTH_MAY
1473 * @arg @ref LL_RTC_MONTH_JUNE
1474 * @arg @ref LL_RTC_MONTH_JULY
1475 * @arg @ref LL_RTC_MONTH_AUGUST
1476 * @arg @ref LL_RTC_MONTH_SEPTEMBER
1477 * @arg @ref LL_RTC_MONTH_OCTOBER
1478 * @arg @ref LL_RTC_MONTH_NOVEMBER
1479 * @arg @ref LL_RTC_MONTH_DECEMBER
1480 * @retval None
1481 */
LL_RTC_DATE_SetMonth(RTC_TypeDef * RTCx,uint32_t Month)1482 __STATIC_INLINE void LL_RTC_DATE_SetMonth(RTC_TypeDef *RTCx, uint32_t Month)
1483 {
1484 MODIFY_REG(RTCx->DR, (RTC_DR_MT | RTC_DR_MU),
1485 (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)));
1486 }
1487
1488 /**
1489 * @brief Get Month in BCD format
1490 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1491 * before reading this bit
1492 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
1493 * @rmtoll DR MT LL_RTC_DATE_GetMonth\n
1494 * DR MU LL_RTC_DATE_GetMonth
1495 * @param RTCx RTC Instance
1496 * @retval Returned value can be one of the following values:
1497 * @arg @ref LL_RTC_MONTH_JANUARY
1498 * @arg @ref LL_RTC_MONTH_FEBRUARY
1499 * @arg @ref LL_RTC_MONTH_MARCH
1500 * @arg @ref LL_RTC_MONTH_APRIL
1501 * @arg @ref LL_RTC_MONTH_MAY
1502 * @arg @ref LL_RTC_MONTH_JUNE
1503 * @arg @ref LL_RTC_MONTH_JULY
1504 * @arg @ref LL_RTC_MONTH_AUGUST
1505 * @arg @ref LL_RTC_MONTH_SEPTEMBER
1506 * @arg @ref LL_RTC_MONTH_OCTOBER
1507 * @arg @ref LL_RTC_MONTH_NOVEMBER
1508 * @arg @ref LL_RTC_MONTH_DECEMBER
1509 */
LL_RTC_DATE_GetMonth(RTC_TypeDef * RTCx)1510 __STATIC_INLINE uint32_t LL_RTC_DATE_GetMonth(RTC_TypeDef *RTCx)
1511 {
1512 uint32_t temp;
1513
1514 temp = READ_BIT(RTCx->DR, (RTC_DR_MT | RTC_DR_MU));
1515 return (uint32_t)((((temp & RTC_DR_MT) >> RTC_DR_MT_Pos) << 4U) | ((temp & RTC_DR_MU) >> RTC_DR_MU_Pos));
1516 }
1517
1518 /**
1519 * @brief Set Day in BCD format
1520 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
1521 * @rmtoll DR DT LL_RTC_DATE_SetDay\n
1522 * DR DU LL_RTC_DATE_SetDay
1523 * @param RTCx RTC Instance
1524 * @param Day Value between Min_Data=0x01 and Max_Data=0x31
1525 * @retval None
1526 */
LL_RTC_DATE_SetDay(RTC_TypeDef * RTCx,uint32_t Day)1527 __STATIC_INLINE void LL_RTC_DATE_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
1528 {
1529 MODIFY_REG(RTCx->DR, (RTC_DR_DT | RTC_DR_DU),
1530 (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos)));
1531 }
1532
1533 /**
1534 * @brief Get Day in BCD format
1535 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1536 * before reading this bit
1537 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
1538 * @rmtoll DR DT LL_RTC_DATE_GetDay\n
1539 * DR DU LL_RTC_DATE_GetDay
1540 * @param RTCx RTC Instance
1541 * @retval Value between Min_Data=0x01 and Max_Data=0x31
1542 */
LL_RTC_DATE_GetDay(RTC_TypeDef * RTCx)1543 __STATIC_INLINE uint32_t LL_RTC_DATE_GetDay(RTC_TypeDef *RTCx)
1544 {
1545 uint32_t temp;
1546
1547 temp = READ_BIT(RTCx->DR, (RTC_DR_DT | RTC_DR_DU));
1548 return (uint32_t)((((temp & RTC_DR_DT) >> RTC_DR_DT_Pos) << 4U) | ((temp & RTC_DR_DU) >> RTC_DR_DU_Pos));
1549 }
1550
1551 /**
1552 * @brief Set date (WeekDay, Day, Month and Year) in BCD format
1553 * @rmtoll DR WDU LL_RTC_DATE_Config\n
1554 * DR MT LL_RTC_DATE_Config\n
1555 * DR MU LL_RTC_DATE_Config\n
1556 * DR DT LL_RTC_DATE_Config\n
1557 * DR DU LL_RTC_DATE_Config\n
1558 * DR YT LL_RTC_DATE_Config\n
1559 * DR YU LL_RTC_DATE_Config
1560 * @param RTCx RTC Instance
1561 * @param WeekDay This parameter can be one of the following values:
1562 * @arg @ref LL_RTC_WEEKDAY_MONDAY
1563 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
1564 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1565 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
1566 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
1567 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
1568 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
1569 * @param Day Value between Min_Data=0x01 and Max_Data=0x31
1570 * @param Month This parameter can be one of the following values:
1571 * @arg @ref LL_RTC_MONTH_JANUARY
1572 * @arg @ref LL_RTC_MONTH_FEBRUARY
1573 * @arg @ref LL_RTC_MONTH_MARCH
1574 * @arg @ref LL_RTC_MONTH_APRIL
1575 * @arg @ref LL_RTC_MONTH_MAY
1576 * @arg @ref LL_RTC_MONTH_JUNE
1577 * @arg @ref LL_RTC_MONTH_JULY
1578 * @arg @ref LL_RTC_MONTH_AUGUST
1579 * @arg @ref LL_RTC_MONTH_SEPTEMBER
1580 * @arg @ref LL_RTC_MONTH_OCTOBER
1581 * @arg @ref LL_RTC_MONTH_NOVEMBER
1582 * @arg @ref LL_RTC_MONTH_DECEMBER
1583 * @param Year Value between Min_Data=0x00 and Max_Data=0x99
1584 * @retval None
1585 */
LL_RTC_DATE_Config(RTC_TypeDef * RTCx,uint32_t WeekDay,uint32_t Day,uint32_t Month,uint32_t Year)1586 __STATIC_INLINE void LL_RTC_DATE_Config(RTC_TypeDef *RTCx, uint32_t WeekDay, uint32_t Day, uint32_t Month,
1587 uint32_t Year)
1588 {
1589 uint32_t temp;
1590
1591 temp = (WeekDay << RTC_DR_WDU_Pos) | \
1592 (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos)) | \
1593 (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)) | \
1594 (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos));
1595
1596 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);
1597 }
1598
1599 /**
1600 * @brief Get date (WeekDay, Day, Month and Year) in BCD format
1601 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1602 * before reading this bit
1603 * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_YEAR, __LL_RTC_GET_MONTH,
1604 * and __LL_RTC_GET_DAY are available to get independently each parameter.
1605 * @rmtoll DR WDU LL_RTC_DATE_Get\n
1606 * DR MT LL_RTC_DATE_Get\n
1607 * DR MU LL_RTC_DATE_Get\n
1608 * DR DT LL_RTC_DATE_Get\n
1609 * DR DU LL_RTC_DATE_Get\n
1610 * DR YT LL_RTC_DATE_Get\n
1611 * DR YU LL_RTC_DATE_Get
1612 * @param RTCx RTC Instance
1613 * @retval Combination of WeekDay, Day, Month and Year (Format: 0xWWDDMMYY).
1614 */
LL_RTC_DATE_Get(RTC_TypeDef * RTCx)1615 __STATIC_INLINE uint32_t LL_RTC_DATE_Get(RTC_TypeDef *RTCx)
1616 {
1617 uint32_t temp;
1618
1619 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));
1620 return (uint32_t)((((temp & RTC_DR_WDU) >> RTC_DR_WDU_Pos) << RTC_OFFSET_WEEKDAY) | \
1621 (((((temp & RTC_DR_DT) >> RTC_DR_DT_Pos) << 4U) | ((temp & RTC_DR_DU) >> RTC_DR_DU_Pos)) << RTC_OFFSET_DAY) | \
1622 (((((temp & RTC_DR_MT) >> RTC_DR_MT_Pos) << 4U) | ((temp & RTC_DR_MU) >> RTC_DR_MU_Pos)) << RTC_OFFSET_MONTH) | \
1623 ((((temp & RTC_DR_YT) >> RTC_DR_YT_Pos) << 4U) | ((temp & RTC_DR_YU) >> RTC_DR_YU_Pos)));
1624 }
1625
1626 /**
1627 * @}
1628 */
1629
1630 /** @defgroup RTC_LL_EF_ALARMA ALARMA
1631 * @{
1632 */
1633
1634 /**
1635 * @brief Enable Alarm A
1636 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1637 * @rmtoll CR ALRAE LL_RTC_ALMA_Enable
1638 * @param RTCx RTC Instance
1639 * @retval None
1640 */
LL_RTC_ALMA_Enable(RTC_TypeDef * RTCx)1641 __STATIC_INLINE void LL_RTC_ALMA_Enable(RTC_TypeDef *RTCx)
1642 {
1643 SET_BIT(RTCx->CR, RTC_CR_ALRAE);
1644 }
1645
1646 /**
1647 * @brief Disable Alarm A
1648 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1649 * @rmtoll CR ALRAE LL_RTC_ALMA_Disable
1650 * @param RTCx RTC Instance
1651 * @retval None
1652 */
LL_RTC_ALMA_Disable(RTC_TypeDef * RTCx)1653 __STATIC_INLINE void LL_RTC_ALMA_Disable(RTC_TypeDef *RTCx)
1654 {
1655 CLEAR_BIT(RTCx->CR, RTC_CR_ALRAE);
1656 }
1657
1658 /**
1659 * @brief Specify the Alarm A masks.
1660 * @rmtoll ALRMAR MSK4 LL_RTC_ALMA_SetMask\n
1661 * ALRMAR MSK3 LL_RTC_ALMA_SetMask\n
1662 * ALRMAR MSK2 LL_RTC_ALMA_SetMask\n
1663 * ALRMAR MSK1 LL_RTC_ALMA_SetMask
1664 * @param RTCx RTC Instance
1665 * @param Mask This parameter can be a combination of the following values:
1666 * @arg @ref LL_RTC_ALMA_MASK_NONE
1667 * @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
1668 * @arg @ref LL_RTC_ALMA_MASK_HOURS
1669 * @arg @ref LL_RTC_ALMA_MASK_MINUTES
1670 * @arg @ref LL_RTC_ALMA_MASK_SECONDS
1671 * @arg @ref LL_RTC_ALMA_MASK_ALL
1672 * @retval None
1673 */
LL_RTC_ALMA_SetMask(RTC_TypeDef * RTCx,uint32_t Mask)1674 __STATIC_INLINE void LL_RTC_ALMA_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
1675 {
1676 MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1, Mask);
1677 }
1678
1679 /**
1680 * @brief Get the Alarm A masks.
1681 * @rmtoll ALRMAR MSK4 LL_RTC_ALMA_GetMask\n
1682 * ALRMAR MSK3 LL_RTC_ALMA_GetMask\n
1683 * ALRMAR MSK2 LL_RTC_ALMA_GetMask\n
1684 * ALRMAR MSK1 LL_RTC_ALMA_GetMask
1685 * @param RTCx RTC Instance
1686 * @retval Returned value can be can be a combination of the following values:
1687 * @arg @ref LL_RTC_ALMA_MASK_NONE
1688 * @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
1689 * @arg @ref LL_RTC_ALMA_MASK_HOURS
1690 * @arg @ref LL_RTC_ALMA_MASK_MINUTES
1691 * @arg @ref LL_RTC_ALMA_MASK_SECONDS
1692 * @arg @ref LL_RTC_ALMA_MASK_ALL
1693 */
LL_RTC_ALMA_GetMask(RTC_TypeDef * RTCx)1694 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMask(RTC_TypeDef *RTCx)
1695 {
1696 return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1));
1697 }
1698
1699 /**
1700 * @brief Enable AlarmA Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
1701 * @rmtoll ALRMAR WDSEL LL_RTC_ALMA_EnableWeekday
1702 * @param RTCx RTC Instance
1703 * @retval None
1704 */
LL_RTC_ALMA_EnableWeekday(RTC_TypeDef * RTCx)1705 __STATIC_INLINE void LL_RTC_ALMA_EnableWeekday(RTC_TypeDef *RTCx)
1706 {
1707 SET_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
1708 }
1709
1710 /**
1711 * @brief Disable AlarmA Week day selection (DU[3:0] represents the date )
1712 * @rmtoll ALRMAR WDSEL LL_RTC_ALMA_DisableWeekday
1713 * @param RTCx RTC Instance
1714 * @retval None
1715 */
LL_RTC_ALMA_DisableWeekday(RTC_TypeDef * RTCx)1716 __STATIC_INLINE void LL_RTC_ALMA_DisableWeekday(RTC_TypeDef *RTCx)
1717 {
1718 CLEAR_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
1719 }
1720
1721 /**
1722 * @brief Set ALARM A Day in BCD format
1723 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
1724 * @rmtoll ALRMAR DT LL_RTC_ALMA_SetDay\n
1725 * ALRMAR DU LL_RTC_ALMA_SetDay
1726 * @param RTCx RTC Instance
1727 * @param Day Value between Min_Data=0x01 and Max_Data=0x31
1728 * @retval None
1729 */
LL_RTC_ALMA_SetDay(RTC_TypeDef * RTCx,uint32_t Day)1730 __STATIC_INLINE void LL_RTC_ALMA_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
1731 {
1732 MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU),
1733 (((Day & 0xF0U) << (RTC_ALRMAR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMAR_DU_Pos)));
1734 }
1735
1736 /**
1737 * @brief Get ALARM A Day in BCD format
1738 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
1739 * @rmtoll ALRMAR DT LL_RTC_ALMA_GetDay\n
1740 * ALRMAR DU LL_RTC_ALMA_GetDay
1741 * @param RTCx RTC Instance
1742 * @retval Value between Min_Data=0x01 and Max_Data=0x31
1743 */
LL_RTC_ALMA_GetDay(RTC_TypeDef * RTCx)1744 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetDay(RTC_TypeDef *RTCx)
1745 {
1746 uint32_t temp;
1747
1748 temp = READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU));
1749 return (uint32_t)((((temp & RTC_ALRMAR_DT) >> RTC_ALRMAR_DT_Pos) << 4U) | ((temp & RTC_ALRMAR_DU) >> RTC_ALRMAR_DU_Pos));
1750 }
1751
1752 /**
1753 * @brief Set ALARM A Weekday
1754 * @rmtoll ALRMAR DU LL_RTC_ALMA_SetWeekDay
1755 * @param RTCx RTC Instance
1756 * @param WeekDay This parameter can be one of the following values:
1757 * @arg @ref LL_RTC_WEEKDAY_MONDAY
1758 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
1759 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1760 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
1761 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
1762 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
1763 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
1764 * @retval None
1765 */
LL_RTC_ALMA_SetWeekDay(RTC_TypeDef * RTCx,uint32_t WeekDay)1766 __STATIC_INLINE void LL_RTC_ALMA_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
1767 {
1768 MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_DU, WeekDay << RTC_ALRMAR_DU_Pos);
1769 }
1770
1771 /**
1772 * @brief Get ALARM A Weekday
1773 * @rmtoll ALRMAR DU LL_RTC_ALMA_GetWeekDay
1774 * @param RTCx RTC Instance
1775 * @retval Returned value can be one of the following values:
1776 * @arg @ref LL_RTC_WEEKDAY_MONDAY
1777 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
1778 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1779 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
1780 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
1781 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
1782 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
1783 */
LL_RTC_ALMA_GetWeekDay(RTC_TypeDef * RTCx)1784 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetWeekDay(RTC_TypeDef *RTCx)
1785 {
1786 return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_DU) >> RTC_ALRMAR_DU_Pos);
1787 }
1788
1789 /**
1790 * @brief Set Alarm A time format (AM/24-hour or PM notation)
1791 * @rmtoll ALRMAR PM LL_RTC_ALMA_SetTimeFormat
1792 * @param RTCx RTC Instance
1793 * @param TimeFormat This parameter can be one of the following values:
1794 * @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
1795 * @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
1796 * @retval None
1797 */
LL_RTC_ALMA_SetTimeFormat(RTC_TypeDef * RTCx,uint32_t TimeFormat)1798 __STATIC_INLINE void LL_RTC_ALMA_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
1799 {
1800 MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_PM, TimeFormat);
1801 }
1802
1803 /**
1804 * @brief Get Alarm A time format (AM or PM notation)
1805 * @rmtoll ALRMAR PM LL_RTC_ALMA_GetTimeFormat
1806 * @param RTCx RTC Instance
1807 * @retval Returned value can be one of the following values:
1808 * @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
1809 * @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
1810 */
LL_RTC_ALMA_GetTimeFormat(RTC_TypeDef * RTCx)1811 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTimeFormat(RTC_TypeDef *RTCx)
1812 {
1813 return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_PM));
1814 }
1815
1816 /**
1817 * @brief Set ALARM A Hours in BCD format
1818 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
1819 * @rmtoll ALRMAR HT LL_RTC_ALMA_SetHour\n
1820 * ALRMAR HU LL_RTC_ALMA_SetHour
1821 * @param RTCx RTC Instance
1822 * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1823 * @retval None
1824 */
LL_RTC_ALMA_SetHour(RTC_TypeDef * RTCx,uint32_t Hours)1825 __STATIC_INLINE void LL_RTC_ALMA_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
1826 {
1827 MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU),
1828 (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos)));
1829 }
1830
1831 /**
1832 * @brief Get ALARM A Hours in BCD format
1833 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
1834 * @rmtoll ALRMAR HT LL_RTC_ALMA_GetHour\n
1835 * ALRMAR HU LL_RTC_ALMA_GetHour
1836 * @param RTCx RTC Instance
1837 * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1838 */
LL_RTC_ALMA_GetHour(RTC_TypeDef * RTCx)1839 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetHour(RTC_TypeDef *RTCx)
1840 {
1841 uint32_t temp;
1842
1843 temp = READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU));
1844 return (uint32_t)((((temp & RTC_ALRMAR_HT) >> RTC_ALRMAR_HT_Pos) << 4U) | ((temp & RTC_ALRMAR_HU) >> RTC_ALRMAR_HU_Pos));
1845 }
1846
1847 /**
1848 * @brief Set ALARM A Minutes in BCD format
1849 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
1850 * @rmtoll ALRMAR MNT LL_RTC_ALMA_SetMinute\n
1851 * ALRMAR MNU LL_RTC_ALMA_SetMinute
1852 * @param RTCx RTC Instance
1853 * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
1854 * @retval None
1855 */
LL_RTC_ALMA_SetMinute(RTC_TypeDef * RTCx,uint32_t Minutes)1856 __STATIC_INLINE void LL_RTC_ALMA_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
1857 {
1858 MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU),
1859 (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)));
1860 }
1861
1862 /**
1863 * @brief Get ALARM A Minutes in BCD format
1864 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
1865 * @rmtoll ALRMAR MNT LL_RTC_ALMA_GetMinute\n
1866 * ALRMAR MNU LL_RTC_ALMA_GetMinute
1867 * @param RTCx RTC Instance
1868 * @retval Value between Min_Data=0x00 and Max_Data=0x59
1869 */
LL_RTC_ALMA_GetMinute(RTC_TypeDef * RTCx)1870 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMinute(RTC_TypeDef *RTCx)
1871 {
1872 uint32_t temp;
1873
1874 temp = READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU));
1875 return (uint32_t)((((temp & RTC_ALRMAR_MNT) >> RTC_ALRMAR_MNT_Pos) << 4U) | ((temp & RTC_ALRMAR_MNU) >> RTC_ALRMAR_MNU_Pos));
1876 }
1877
1878 /**
1879 * @brief Set ALARM A Seconds in BCD format
1880 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
1881 * @rmtoll ALRMAR ST LL_RTC_ALMA_SetSecond\n
1882 * ALRMAR SU LL_RTC_ALMA_SetSecond
1883 * @param RTCx RTC Instance
1884 * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
1885 * @retval None
1886 */
LL_RTC_ALMA_SetSecond(RTC_TypeDef * RTCx,uint32_t Seconds)1887 __STATIC_INLINE void LL_RTC_ALMA_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
1888 {
1889 MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU),
1890 (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos)));
1891 }
1892
1893 /**
1894 * @brief Get ALARM A Seconds in BCD format
1895 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
1896 * @rmtoll ALRMAR ST LL_RTC_ALMA_GetSecond\n
1897 * ALRMAR SU LL_RTC_ALMA_GetSecond
1898 * @param RTCx RTC Instance
1899 * @retval Value between Min_Data=0x00 and Max_Data=0x59
1900 */
LL_RTC_ALMA_GetSecond(RTC_TypeDef * RTCx)1901 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSecond(RTC_TypeDef *RTCx)
1902 {
1903 uint32_t temp;
1904
1905 temp = READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU));
1906 return (uint32_t)((((temp & RTC_ALRMAR_ST) >> RTC_ALRMAR_ST_Pos) << 4U) | ((temp & RTC_ALRMAR_SU) >> RTC_ALRMAR_SU_Pos));
1907 }
1908
1909 /**
1910 * @brief Set Alarm A Time (hour, minute and second) in BCD format
1911 * @rmtoll ALRMAR PM LL_RTC_ALMA_ConfigTime\n
1912 * ALRMAR HT LL_RTC_ALMA_ConfigTime\n
1913 * ALRMAR HU LL_RTC_ALMA_ConfigTime\n
1914 * ALRMAR MNT LL_RTC_ALMA_ConfigTime\n
1915 * ALRMAR MNU LL_RTC_ALMA_ConfigTime\n
1916 * ALRMAR ST LL_RTC_ALMA_ConfigTime\n
1917 * ALRMAR SU LL_RTC_ALMA_ConfigTime
1918 * @param RTCx RTC Instance
1919 * @param Format12_24 This parameter can be one of the following values:
1920 * @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
1921 * @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
1922 * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1923 * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
1924 * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
1925 * @retval None
1926 */
LL_RTC_ALMA_ConfigTime(RTC_TypeDef * RTCx,uint32_t Format12_24,uint32_t Hours,uint32_t Minutes,uint32_t Seconds)1927 __STATIC_INLINE void LL_RTC_ALMA_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes,
1928 uint32_t Seconds)
1929 {
1930 uint32_t temp;
1931
1932 temp = Format12_24 | (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos)) | \
1933 (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)) | \
1934 (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos));
1935
1936 MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_PM | RTC_ALRMAR_HT | RTC_ALRMAR_HU | RTC_ALRMAR_MNT | RTC_ALRMAR_MNU | RTC_ALRMAR_ST
1937 | RTC_ALRMAR_SU, temp);
1938 }
1939
1940 /**
1941 * @brief Get Alarm B Time (hour, minute and second) in BCD format
1942 * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
1943 * are available to get independently each parameter.
1944 * @rmtoll ALRMAR HT LL_RTC_ALMA_GetTime\n
1945 * ALRMAR HU LL_RTC_ALMA_GetTime\n
1946 * ALRMAR MNT LL_RTC_ALMA_GetTime\n
1947 * ALRMAR MNU LL_RTC_ALMA_GetTime\n
1948 * ALRMAR ST LL_RTC_ALMA_GetTime\n
1949 * ALRMAR SU LL_RTC_ALMA_GetTime
1950 * @param RTCx RTC Instance
1951 * @retval Combination of hours, minutes and seconds.
1952 */
LL_RTC_ALMA_GetTime(RTC_TypeDef * RTCx)1953 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTime(RTC_TypeDef *RTCx)
1954 {
1955 return (uint32_t)((LL_RTC_ALMA_GetHour(RTCx) << RTC_OFFSET_HOUR) | (LL_RTC_ALMA_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMA_GetSecond(RTCx));
1956 }
1957
1958 /**
1959 * @brief Set Alarm A Mask the most-significant bits starting at this bit
1960 * @note This register can be written only when ALRAE is reset in RTC_CR register,
1961 * or in initialization mode.
1962 * @rmtoll ALRMASSR MASKSS LL_RTC_ALMA_SetSubSecondMask
1963 * @param RTCx RTC Instance
1964 * @param Mask Value between Min_Data=0x00 and Max_Data=0xF
1965 * @retval None
1966 */
LL_RTC_ALMA_SetSubSecondMask(RTC_TypeDef * RTCx,uint32_t Mask)1967 __STATIC_INLINE void LL_RTC_ALMA_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
1968 {
1969 MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS, Mask << RTC_ALRMASSR_MASKSS_Pos);
1970 }
1971
1972 /**
1973 * @brief Get Alarm A Mask the most-significant bits starting at this bit
1974 * @rmtoll ALRMASSR MASKSS LL_RTC_ALMA_GetSubSecondMask
1975 * @param RTCx RTC Instance
1976 * @retval Value between Min_Data=0x00 and Max_Data=0xF
1977 */
LL_RTC_ALMA_GetSubSecondMask(RTC_TypeDef * RTCx)1978 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecondMask(RTC_TypeDef *RTCx)
1979 {
1980 return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS) >> RTC_ALRMASSR_MASKSS_Pos);
1981 }
1982
1983 /**
1984 * @brief Set Alarm A Sub seconds value
1985 * @rmtoll ALRMASSR SS LL_RTC_ALMA_SetSubSecond
1986 * @param RTCx RTC Instance
1987 * @param Subsecond Value between Min_Data=0x00 and Max_Data=0x7FFF
1988 * @retval None
1989 */
LL_RTC_ALMA_SetSubSecond(RTC_TypeDef * RTCx,uint32_t Subsecond)1990 __STATIC_INLINE void LL_RTC_ALMA_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
1991 {
1992 MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_SS, Subsecond);
1993 }
1994
1995 /**
1996 * @brief Get Alarm A Sub seconds value
1997 * @rmtoll ALRMASSR SS LL_RTC_ALMA_GetSubSecond
1998 * @param RTCx RTC Instance
1999 * @retval Value between Min_Data=0x00 and Max_Data=0x7FFF
2000 */
LL_RTC_ALMA_GetSubSecond(RTC_TypeDef * RTCx)2001 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecond(RTC_TypeDef *RTCx)
2002 {
2003 return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_SS));
2004 }
2005
2006 /**
2007 * @}
2008 */
2009
2010 /** @defgroup RTC_LL_EF_ALARMB ALARMB
2011 * @{
2012 */
2013
2014 /**
2015 * @brief Enable Alarm B
2016 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2017 * @rmtoll CR ALRBE LL_RTC_ALMB_Enable
2018 * @param RTCx RTC Instance
2019 * @retval None
2020 */
LL_RTC_ALMB_Enable(RTC_TypeDef * RTCx)2021 __STATIC_INLINE void LL_RTC_ALMB_Enable(RTC_TypeDef *RTCx)
2022 {
2023 SET_BIT(RTCx->CR, RTC_CR_ALRBE);
2024 }
2025
2026 /**
2027 * @brief Disable Alarm B
2028 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2029 * @rmtoll CR ALRBE LL_RTC_ALMB_Disable
2030 * @param RTCx RTC Instance
2031 * @retval None
2032 */
LL_RTC_ALMB_Disable(RTC_TypeDef * RTCx)2033 __STATIC_INLINE void LL_RTC_ALMB_Disable(RTC_TypeDef *RTCx)
2034 {
2035 CLEAR_BIT(RTCx->CR, RTC_CR_ALRBE);
2036 }
2037
2038 /**
2039 * @brief Specify the Alarm B masks.
2040 * @rmtoll ALRMBR MSK4 LL_RTC_ALMB_SetMask\n
2041 * ALRMBR MSK3 LL_RTC_ALMB_SetMask\n
2042 * ALRMBR MSK2 LL_RTC_ALMB_SetMask\n
2043 * ALRMBR MSK1 LL_RTC_ALMB_SetMask
2044 * @param RTCx RTC Instance
2045 * @param Mask This parameter can be a combination of the following values:
2046 * @arg @ref LL_RTC_ALMB_MASK_NONE
2047 * @arg @ref LL_RTC_ALMB_MASK_DATEWEEKDAY
2048 * @arg @ref LL_RTC_ALMB_MASK_HOURS
2049 * @arg @ref LL_RTC_ALMB_MASK_MINUTES
2050 * @arg @ref LL_RTC_ALMB_MASK_SECONDS
2051 * @arg @ref LL_RTC_ALMB_MASK_ALL
2052 * @retval None
2053 */
LL_RTC_ALMB_SetMask(RTC_TypeDef * RTCx,uint32_t Mask)2054 __STATIC_INLINE void LL_RTC_ALMB_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
2055 {
2056 MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1, Mask);
2057 }
2058
2059 /**
2060 * @brief Get the Alarm B masks.
2061 * @rmtoll ALRMBR MSK4 LL_RTC_ALMB_GetMask\n
2062 * ALRMBR MSK3 LL_RTC_ALMB_GetMask\n
2063 * ALRMBR MSK2 LL_RTC_ALMB_GetMask\n
2064 * ALRMBR MSK1 LL_RTC_ALMB_GetMask
2065 * @param RTCx RTC Instance
2066 * @retval Returned value can be can be a combination of the following values:
2067 * @arg @ref LL_RTC_ALMB_MASK_NONE
2068 * @arg @ref LL_RTC_ALMB_MASK_DATEWEEKDAY
2069 * @arg @ref LL_RTC_ALMB_MASK_HOURS
2070 * @arg @ref LL_RTC_ALMB_MASK_MINUTES
2071 * @arg @ref LL_RTC_ALMB_MASK_SECONDS
2072 * @arg @ref LL_RTC_ALMB_MASK_ALL
2073 */
LL_RTC_ALMB_GetMask(RTC_TypeDef * RTCx)2074 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetMask(RTC_TypeDef *RTCx)
2075 {
2076 return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1));
2077 }
2078
2079 /**
2080 * @brief Enable AlarmB Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
2081 * @rmtoll ALRMBR WDSEL LL_RTC_ALMB_EnableWeekday
2082 * @param RTCx RTC Instance
2083 * @retval None
2084 */
LL_RTC_ALMB_EnableWeekday(RTC_TypeDef * RTCx)2085 __STATIC_INLINE void LL_RTC_ALMB_EnableWeekday(RTC_TypeDef *RTCx)
2086 {
2087 SET_BIT(RTCx->ALRMBR, RTC_ALRMBR_WDSEL);
2088 }
2089
2090 /**
2091 * @brief Disable AlarmB Week day selection (DU[3:0] represents the date )
2092 * @rmtoll ALRMBR WDSEL LL_RTC_ALMB_DisableWeekday
2093 * @param RTCx RTC Instance
2094 * @retval None
2095 */
LL_RTC_ALMB_DisableWeekday(RTC_TypeDef * RTCx)2096 __STATIC_INLINE void LL_RTC_ALMB_DisableWeekday(RTC_TypeDef *RTCx)
2097 {
2098 CLEAR_BIT(RTCx->ALRMBR, RTC_ALRMBR_WDSEL);
2099 }
2100
2101 /**
2102 * @brief Set ALARM B Day in BCD format
2103 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
2104 * @rmtoll ALRMBR DT LL_RTC_ALMB_SetDay\n
2105 * ALRMBR DU LL_RTC_ALMB_SetDay
2106 * @param RTCx RTC Instance
2107 * @param Day Value between Min_Data=0x01 and Max_Data=0x31
2108 * @retval None
2109 */
LL_RTC_ALMB_SetDay(RTC_TypeDef * RTCx,uint32_t Day)2110 __STATIC_INLINE void LL_RTC_ALMB_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
2111 {
2112 MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_DT | RTC_ALRMBR_DU),
2113 (((Day & 0xF0U) << (RTC_ALRMBR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMBR_DU_Pos)));
2114 }
2115
2116 /**
2117 * @brief Get ALARM B Day in BCD format
2118 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
2119 * @rmtoll ALRMBR DT LL_RTC_ALMB_GetDay\n
2120 * ALRMBR DU LL_RTC_ALMB_GetDay
2121 * @param RTCx RTC Instance
2122 * @retval Value between Min_Data=0x01 and Max_Data=0x31
2123 */
LL_RTC_ALMB_GetDay(RTC_TypeDef * RTCx)2124 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetDay(RTC_TypeDef *RTCx)
2125 {
2126 uint32_t temp;
2127
2128 temp = READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_DT | RTC_ALRMBR_DU));
2129 return (uint32_t)((((temp & RTC_ALRMBR_DT) >> RTC_ALRMBR_DT_Pos) << 4U) | ((temp & RTC_ALRMBR_DU) >> RTC_ALRMBR_DU_Pos));
2130 }
2131
2132 /**
2133 * @brief Set ALARM B Weekday
2134 * @rmtoll ALRMBR DU LL_RTC_ALMB_SetWeekDay
2135 * @param RTCx RTC Instance
2136 * @param WeekDay This parameter can be one of the following values:
2137 * @arg @ref LL_RTC_WEEKDAY_MONDAY
2138 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
2139 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
2140 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
2141 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
2142 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
2143 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
2144 * @retval None
2145 */
LL_RTC_ALMB_SetWeekDay(RTC_TypeDef * RTCx,uint32_t WeekDay)2146 __STATIC_INLINE void LL_RTC_ALMB_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
2147 {
2148 MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_DU, WeekDay << RTC_ALRMBR_DU_Pos);
2149 }
2150
2151 /**
2152 * @brief Get ALARM B Weekday
2153 * @rmtoll ALRMBR DU LL_RTC_ALMB_GetWeekDay
2154 * @param RTCx RTC Instance
2155 * @retval Returned value can be one of the following values:
2156 * @arg @ref LL_RTC_WEEKDAY_MONDAY
2157 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
2158 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
2159 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
2160 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
2161 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
2162 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
2163 */
LL_RTC_ALMB_GetWeekDay(RTC_TypeDef * RTCx)2164 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetWeekDay(RTC_TypeDef *RTCx)
2165 {
2166 return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_DU) >> RTC_ALRMBR_DU_Pos);
2167 }
2168
2169 /**
2170 * @brief Set ALARM B time format (AM/24-hour or PM notation)
2171 * @rmtoll ALRMBR PM LL_RTC_ALMB_SetTimeFormat
2172 * @param RTCx RTC Instance
2173 * @param TimeFormat This parameter can be one of the following values:
2174 * @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
2175 * @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
2176 * @retval None
2177 */
LL_RTC_ALMB_SetTimeFormat(RTC_TypeDef * RTCx,uint32_t TimeFormat)2178 __STATIC_INLINE void LL_RTC_ALMB_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
2179 {
2180 MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_PM, TimeFormat);
2181 }
2182
2183 /**
2184 * @brief Get ALARM B time format (AM or PM notation)
2185 * @rmtoll ALRMBR PM LL_RTC_ALMB_GetTimeFormat
2186 * @param RTCx RTC Instance
2187 * @retval Returned value can be one of the following values:
2188 * @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
2189 * @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
2190 */
LL_RTC_ALMB_GetTimeFormat(RTC_TypeDef * RTCx)2191 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetTimeFormat(RTC_TypeDef *RTCx)
2192 {
2193 return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_PM));
2194 }
2195
2196 /**
2197 * @brief Set ALARM B Hours in BCD format
2198 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
2199 * @rmtoll ALRMBR HT LL_RTC_ALMB_SetHour\n
2200 * ALRMBR HU LL_RTC_ALMB_SetHour
2201 * @param RTCx RTC Instance
2202 * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2203 * @retval None
2204 */
LL_RTC_ALMB_SetHour(RTC_TypeDef * RTCx,uint32_t Hours)2205 __STATIC_INLINE void LL_RTC_ALMB_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
2206 {
2207 MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_HT | RTC_ALRMBR_HU),
2208 (((Hours & 0xF0U) << (RTC_ALRMBR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMBR_HU_Pos)));
2209 }
2210
2211 /**
2212 * @brief Get ALARM B Hours in BCD format
2213 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
2214 * @rmtoll ALRMBR HT LL_RTC_ALMB_GetHour\n
2215 * ALRMBR HU LL_RTC_ALMB_GetHour
2216 * @param RTCx RTC Instance
2217 * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2218 */
LL_RTC_ALMB_GetHour(RTC_TypeDef * RTCx)2219 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetHour(RTC_TypeDef *RTCx)
2220 {
2221 uint32_t temp;
2222
2223 temp = READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_HT | RTC_ALRMBR_HU));
2224 return (uint32_t)((((temp & RTC_ALRMBR_HT) >> RTC_ALRMBR_HT_Pos) << 4U) | ((temp & RTC_ALRMBR_HU) >> RTC_ALRMBR_HU_Pos));
2225 }
2226
2227 /**
2228 * @brief Set ALARM B Minutes in BCD format
2229 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
2230 * @rmtoll ALRMBR MNT LL_RTC_ALMB_SetMinute\n
2231 * ALRMBR MNU LL_RTC_ALMB_SetMinute
2232 * @param RTCx RTC Instance
2233 * @param Minutes between Min_Data=0x00 and Max_Data=0x59
2234 * @retval None
2235 */
LL_RTC_ALMB_SetMinute(RTC_TypeDef * RTCx,uint32_t Minutes)2236 __STATIC_INLINE void LL_RTC_ALMB_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
2237 {
2238 MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_MNT | RTC_ALRMBR_MNU),
2239 (((Minutes & 0xF0U) << (RTC_ALRMBR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMBR_MNU_Pos)));
2240 }
2241
2242 /**
2243 * @brief Get ALARM B Minutes in BCD format
2244 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
2245 * @rmtoll ALRMBR MNT LL_RTC_ALMB_GetMinute\n
2246 * ALRMBR MNU LL_RTC_ALMB_GetMinute
2247 * @param RTCx RTC Instance
2248 * @retval Value between Min_Data=0x00 and Max_Data=0x59
2249 */
LL_RTC_ALMB_GetMinute(RTC_TypeDef * RTCx)2250 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetMinute(RTC_TypeDef *RTCx)
2251 {
2252 uint32_t temp;
2253
2254 temp = READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_MNT | RTC_ALRMBR_MNU));
2255 return (uint32_t)((((temp & RTC_ALRMBR_MNT) >> RTC_ALRMBR_MNT_Pos) << 4U) | ((temp & RTC_ALRMBR_MNU) >> RTC_ALRMBR_MNU_Pos));
2256 }
2257
2258 /**
2259 * @brief Set ALARM B Seconds in BCD format
2260 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
2261 * @rmtoll ALRMBR ST LL_RTC_ALMB_SetSecond\n
2262 * ALRMBR SU LL_RTC_ALMB_SetSecond
2263 * @param RTCx RTC Instance
2264 * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
2265 * @retval None
2266 */
LL_RTC_ALMB_SetSecond(RTC_TypeDef * RTCx,uint32_t Seconds)2267 __STATIC_INLINE void LL_RTC_ALMB_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
2268 {
2269 MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_ST | RTC_ALRMBR_SU),
2270 (((Seconds & 0xF0U) << (RTC_ALRMBR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMBR_SU_Pos)));
2271 }
2272
2273 /**
2274 * @brief Get ALARM B Seconds in BCD format
2275 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
2276 * @rmtoll ALRMBR ST LL_RTC_ALMB_GetSecond\n
2277 * ALRMBR SU LL_RTC_ALMB_GetSecond
2278 * @param RTCx RTC Instance
2279 * @retval Value between Min_Data=0x00 and Max_Data=0x59
2280 */
LL_RTC_ALMB_GetSecond(RTC_TypeDef * RTCx)2281 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSecond(RTC_TypeDef *RTCx)
2282 {
2283 uint32_t temp;
2284
2285 temp = READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_ST | RTC_ALRMBR_SU));
2286 return (uint32_t)((((temp & RTC_ALRMBR_ST) >> RTC_ALRMBR_ST_Pos) << 4U) | ((temp & RTC_ALRMBR_SU) >> RTC_ALRMBR_SU_Pos));
2287 }
2288
2289 /**
2290 * @brief Set Alarm B Time (hour, minute and second) in BCD format
2291 * @rmtoll ALRMBR PM LL_RTC_ALMB_ConfigTime\n
2292 * ALRMBR HT LL_RTC_ALMB_ConfigTime\n
2293 * ALRMBR HU LL_RTC_ALMB_ConfigTime\n
2294 * ALRMBR MNT LL_RTC_ALMB_ConfigTime\n
2295 * ALRMBR MNU LL_RTC_ALMB_ConfigTime\n
2296 * ALRMBR ST LL_RTC_ALMB_ConfigTime\n
2297 * ALRMBR SU LL_RTC_ALMB_ConfigTime
2298 * @param RTCx RTC Instance
2299 * @param Format12_24 This parameter can be one of the following values:
2300 * @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
2301 * @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
2302 * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2303 * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
2304 * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
2305 * @retval None
2306 */
LL_RTC_ALMB_ConfigTime(RTC_TypeDef * RTCx,uint32_t Format12_24,uint32_t Hours,uint32_t Minutes,uint32_t Seconds)2307 __STATIC_INLINE void LL_RTC_ALMB_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes,
2308 uint32_t Seconds)
2309 {
2310 uint32_t temp;
2311
2312 temp = Format12_24 | (((Hours & 0xF0U) << (RTC_ALRMBR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMBR_HU_Pos)) | \
2313 (((Minutes & 0xF0U) << (RTC_ALRMBR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMBR_MNU_Pos)) | \
2314 (((Seconds & 0xF0U) << (RTC_ALRMBR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMBR_SU_Pos));
2315
2316 MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_PM | RTC_ALRMBR_HT | RTC_ALRMBR_HU | RTC_ALRMBR_MNT | RTC_ALRMBR_MNU | RTC_ALRMBR_ST
2317 | RTC_ALRMBR_SU, temp);
2318 }
2319
2320 /**
2321 * @brief Get Alarm B Time (hour, minute and second) in BCD format
2322 * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
2323 * are available to get independently each parameter.
2324 * @rmtoll ALRMBR HT LL_RTC_ALMB_GetTime\n
2325 * ALRMBR HU LL_RTC_ALMB_GetTime\n
2326 * ALRMBR MNT LL_RTC_ALMB_GetTime\n
2327 * ALRMBR MNU LL_RTC_ALMB_GetTime\n
2328 * ALRMBR ST LL_RTC_ALMB_GetTime\n
2329 * ALRMBR SU LL_RTC_ALMB_GetTime
2330 * @param RTCx RTC Instance
2331 * @retval Combination of hours, minutes and seconds.
2332 */
LL_RTC_ALMB_GetTime(RTC_TypeDef * RTCx)2333 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetTime(RTC_TypeDef *RTCx)
2334 {
2335 return (uint32_t)((LL_RTC_ALMB_GetHour(RTCx) << RTC_OFFSET_HOUR) | (LL_RTC_ALMB_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMB_GetSecond(RTCx));
2336 }
2337
2338 /**
2339 * @brief Set Alarm B Mask the most-significant bits starting at this bit
2340 * @note This register can be written only when ALRBE is reset in RTC_CR register,
2341 * or in initialization mode.
2342 * @rmtoll ALRMBSSR MASKSS LL_RTC_ALMB_SetSubSecondMask
2343 * @param RTCx RTC Instance
2344 * @param Mask Value between Min_Data=0x00 and Max_Data=0xF
2345 * @retval None
2346 */
LL_RTC_ALMB_SetSubSecondMask(RTC_TypeDef * RTCx,uint32_t Mask)2347 __STATIC_INLINE void LL_RTC_ALMB_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
2348 {
2349 MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_MASKSS, Mask << RTC_ALRMBSSR_MASKSS_Pos);
2350 }
2351
2352 /**
2353 * @brief Get Alarm B Mask the most-significant bits starting at this bit
2354 * @rmtoll ALRMBSSR MASKSS LL_RTC_ALMB_GetSubSecondMask
2355 * @param RTCx RTC Instance
2356 * @retval Value between Min_Data=0x00 and Max_Data=0xF
2357 */
LL_RTC_ALMB_GetSubSecondMask(RTC_TypeDef * RTCx)2358 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSubSecondMask(RTC_TypeDef *RTCx)
2359 {
2360 return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_MASKSS) >> RTC_ALRMBSSR_MASKSS_Pos);
2361 }
2362
2363 /**
2364 * @brief Set Alarm B Sub seconds value
2365 * @rmtoll ALRMBSSR SS LL_RTC_ALMB_SetSubSecond
2366 * @param RTCx RTC Instance
2367 * @param Subsecond Value between Min_Data=0x00 and Max_Data=0x7FFF
2368 * @retval None
2369 */
LL_RTC_ALMB_SetSubSecond(RTC_TypeDef * RTCx,uint32_t Subsecond)2370 __STATIC_INLINE void LL_RTC_ALMB_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
2371 {
2372 MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_SS, Subsecond);
2373 }
2374
2375 /**
2376 * @brief Get Alarm B Sub seconds value
2377 * @rmtoll ALRMBSSR SS LL_RTC_ALMB_GetSubSecond
2378 * @param RTCx RTC Instance
2379 * @retval Value between Min_Data=0x00 and Max_Data=0x7FFF
2380 */
LL_RTC_ALMB_GetSubSecond(RTC_TypeDef * RTCx)2381 __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSubSecond(RTC_TypeDef *RTCx)
2382 {
2383 return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_SS));
2384 }
2385
2386 /**
2387 * @}
2388 */
2389
2390 /** @defgroup RTC_LL_EF_Timestamp Timestamp
2391 * @{
2392 */
2393
2394 /**
2395 * @brief Enable internal event timestamp
2396 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2397 * @rmtoll CR ITSE LL_RTC_TS_EnableInternalEvent
2398 * @param RTCx RTC Instance
2399 * @retval None
2400 */
LL_RTC_TS_EnableInternalEvent(RTC_TypeDef * RTCx)2401 __STATIC_INLINE void LL_RTC_TS_EnableInternalEvent(RTC_TypeDef *RTCx)
2402 {
2403 SET_BIT(RTCx->CR, RTC_CR_ITSE);
2404 }
2405
2406 /**
2407 * @brief Disable internal event timestamp
2408 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2409 * @rmtoll CR ITSE LL_RTC_TS_DisableInternalEvent
2410 * @param RTCx RTC Instance
2411 * @retval None
2412 */
LL_RTC_TS_DisableInternalEvent(RTC_TypeDef * RTCx)2413 __STATIC_INLINE void LL_RTC_TS_DisableInternalEvent(RTC_TypeDef *RTCx)
2414 {
2415 CLEAR_BIT(RTCx->CR, RTC_CR_ITSE);
2416 }
2417
2418 /**
2419 * @brief Enable Timestamp
2420 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2421 * @rmtoll CR TSE LL_RTC_TS_Enable
2422 * @param RTCx RTC Instance
2423 * @retval None
2424 */
LL_RTC_TS_Enable(RTC_TypeDef * RTCx)2425 __STATIC_INLINE void LL_RTC_TS_Enable(RTC_TypeDef *RTCx)
2426 {
2427 SET_BIT(RTCx->CR, RTC_CR_TSE);
2428 }
2429
2430 /**
2431 * @brief Disable Timestamp
2432 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2433 * @rmtoll CR TSE LL_RTC_TS_Disable
2434 * @param RTCx RTC Instance
2435 * @retval None
2436 */
LL_RTC_TS_Disable(RTC_TypeDef * RTCx)2437 __STATIC_INLINE void LL_RTC_TS_Disable(RTC_TypeDef *RTCx)
2438 {
2439 CLEAR_BIT(RTCx->CR, RTC_CR_TSE);
2440 }
2441
2442 /**
2443 * @brief Set Time-stamp event active edge
2444 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2445 * @note TSE must be reset when TSEDGE is changed to avoid unwanted TSF setting
2446 * @rmtoll CR TSEDGE LL_RTC_TS_SetActiveEdge
2447 * @param RTCx RTC Instance
2448 * @param Edge This parameter can be one of the following values:
2449 * @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
2450 * @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
2451 * @retval None
2452 */
LL_RTC_TS_SetActiveEdge(RTC_TypeDef * RTCx,uint32_t Edge)2453 __STATIC_INLINE void LL_RTC_TS_SetActiveEdge(RTC_TypeDef *RTCx, uint32_t Edge)
2454 {
2455 MODIFY_REG(RTCx->CR, RTC_CR_TSEDGE, Edge);
2456 }
2457
2458 /**
2459 * @brief Get Time-stamp event active edge
2460 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2461 * @rmtoll CR TSEDGE LL_RTC_TS_GetActiveEdge
2462 * @param RTCx RTC Instance
2463 * @retval Returned value can be one of the following values:
2464 * @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
2465 * @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
2466 */
LL_RTC_TS_GetActiveEdge(RTC_TypeDef * RTCx)2467 __STATIC_INLINE uint32_t LL_RTC_TS_GetActiveEdge(RTC_TypeDef *RTCx)
2468 {
2469 return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_TSEDGE));
2470 }
2471
2472 /**
2473 * @brief Get Timestamp AM/PM notation (AM or 24-hour format)
2474 * @rmtoll TSTR PM LL_RTC_TS_GetTimeFormat
2475 * @param RTCx RTC Instance
2476 * @retval Returned value can be one of the following values:
2477 * @arg @ref LL_RTC_TS_TIME_FORMAT_AM
2478 * @arg @ref LL_RTC_TS_TIME_FORMAT_PM
2479 */
LL_RTC_TS_GetTimeFormat(RTC_TypeDef * RTCx)2480 __STATIC_INLINE uint32_t LL_RTC_TS_GetTimeFormat(RTC_TypeDef *RTCx)
2481 {
2482 return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_PM));
2483 }
2484
2485 /**
2486 * @brief Get Timestamp Hours in BCD format
2487 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
2488 * @rmtoll TSTR HT LL_RTC_TS_GetHour\n
2489 * TSTR HU LL_RTC_TS_GetHour
2490 * @param RTCx RTC Instance
2491 * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
2492 */
LL_RTC_TS_GetHour(RTC_TypeDef * RTCx)2493 __STATIC_INLINE uint32_t LL_RTC_TS_GetHour(RTC_TypeDef *RTCx)
2494 {
2495 return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_HT | RTC_TSTR_HU) >> RTC_TSTR_HU_Pos);
2496 }
2497
2498 /**
2499 * @brief Get Timestamp Minutes in BCD format
2500 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
2501 * @rmtoll TSTR MNT LL_RTC_TS_GetMinute\n
2502 * TSTR MNU LL_RTC_TS_GetMinute
2503 * @param RTCx RTC Instance
2504 * @retval Value between Min_Data=0x00 and Max_Data=0x59
2505 */
LL_RTC_TS_GetMinute(RTC_TypeDef * RTCx)2506 __STATIC_INLINE uint32_t LL_RTC_TS_GetMinute(RTC_TypeDef *RTCx)
2507 {
2508 return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_MNT | RTC_TSTR_MNU) >> RTC_TSTR_MNU_Pos);
2509 }
2510
2511 /**
2512 * @brief Get Timestamp Seconds in BCD format
2513 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
2514 * @rmtoll TSTR ST LL_RTC_TS_GetSecond\n
2515 * TSTR SU LL_RTC_TS_GetSecond
2516 * @param RTCx RTC Instance
2517 * @retval Value between Min_Data=0x00 and Max_Data=0x59
2518 */
LL_RTC_TS_GetSecond(RTC_TypeDef * RTCx)2519 __STATIC_INLINE uint32_t LL_RTC_TS_GetSecond(RTC_TypeDef *RTCx)
2520 {
2521 return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_ST | RTC_TSTR_SU));
2522 }
2523
2524 /**
2525 * @brief Get Timestamp time (hour, minute and second) in BCD format
2526 * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
2527 * are available to get independently each parameter.
2528 * @rmtoll TSTR HT LL_RTC_TS_GetTime\n
2529 * TSTR HU LL_RTC_TS_GetTime\n
2530 * TSTR MNT LL_RTC_TS_GetTime\n
2531 * TSTR MNU LL_RTC_TS_GetTime\n
2532 * TSTR ST LL_RTC_TS_GetTime\n
2533 * TSTR SU LL_RTC_TS_GetTime
2534 * @param RTCx RTC Instance
2535 * @retval Combination of hours, minutes and seconds.
2536 */
LL_RTC_TS_GetTime(RTC_TypeDef * RTCx)2537 __STATIC_INLINE uint32_t LL_RTC_TS_GetTime(RTC_TypeDef *RTCx)
2538 {
2539 return (uint32_t)(READ_BIT(RTCx->TSTR,
2540 RTC_TSTR_HT | RTC_TSTR_HU | RTC_TSTR_MNT | RTC_TSTR_MNU | RTC_TSTR_ST | RTC_TSTR_SU));
2541 }
2542
2543 /**
2544 * @brief Get Timestamp Week day
2545 * @rmtoll TSDR WDU LL_RTC_TS_GetWeekDay
2546 * @param RTCx RTC Instance
2547 * @retval Returned value can be one of the following values:
2548 * @arg @ref LL_RTC_WEEKDAY_MONDAY
2549 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
2550 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
2551 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
2552 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
2553 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
2554 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
2555 */
LL_RTC_TS_GetWeekDay(RTC_TypeDef * RTCx)2556 __STATIC_INLINE uint32_t LL_RTC_TS_GetWeekDay(RTC_TypeDef *RTCx)
2557 {
2558 return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU) >> RTC_TSDR_WDU_Pos);
2559 }
2560
2561 /**
2562 * @brief Get Timestamp Month in BCD format
2563 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
2564 * @rmtoll TSDR MT LL_RTC_TS_GetMonth\n
2565 * TSDR MU LL_RTC_TS_GetMonth
2566 * @param RTCx RTC Instance
2567 * @retval Returned value can be one of the following values:
2568 * @arg @ref LL_RTC_MONTH_JANUARY
2569 * @arg @ref LL_RTC_MONTH_FEBRUARY
2570 * @arg @ref LL_RTC_MONTH_MARCH
2571 * @arg @ref LL_RTC_MONTH_APRIL
2572 * @arg @ref LL_RTC_MONTH_MAY
2573 * @arg @ref LL_RTC_MONTH_JUNE
2574 * @arg @ref LL_RTC_MONTH_JULY
2575 * @arg @ref LL_RTC_MONTH_AUGUST
2576 * @arg @ref LL_RTC_MONTH_SEPTEMBER
2577 * @arg @ref LL_RTC_MONTH_OCTOBER
2578 * @arg @ref LL_RTC_MONTH_NOVEMBER
2579 * @arg @ref LL_RTC_MONTH_DECEMBER
2580 */
LL_RTC_TS_GetMonth(RTC_TypeDef * RTCx)2581 __STATIC_INLINE uint32_t LL_RTC_TS_GetMonth(RTC_TypeDef *RTCx)
2582 {
2583 return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_MT | RTC_TSDR_MU) >> RTC_TSDR_MU_Pos);
2584 }
2585
2586 /**
2587 * @brief Get Timestamp Day in BCD format
2588 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
2589 * @rmtoll TSDR DT LL_RTC_TS_GetDay\n
2590 * TSDR DU LL_RTC_TS_GetDay
2591 * @param RTCx RTC Instance
2592 * @retval Value between Min_Data=0x01 and Max_Data=0x31
2593 */
LL_RTC_TS_GetDay(RTC_TypeDef * RTCx)2594 __STATIC_INLINE uint32_t LL_RTC_TS_GetDay(RTC_TypeDef *RTCx)
2595 {
2596 return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_DT | RTC_TSDR_DU));
2597 }
2598
2599 /**
2600 * @brief Get Timestamp date (WeekDay, Day and Month) in BCD format
2601 * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_MONTH,
2602 * and __LL_RTC_GET_DAY are available to get independently each parameter.
2603 * @rmtoll TSDR WDU LL_RTC_TS_GetDate\n
2604 * TSDR MT LL_RTC_TS_GetDate\n
2605 * TSDR MU LL_RTC_TS_GetDate\n
2606 * TSDR DT LL_RTC_TS_GetDate\n
2607 * TSDR DU LL_RTC_TS_GetDate
2608 * @param RTCx RTC Instance
2609 * @retval Combination of Weekday, Day and Month
2610 */
LL_RTC_TS_GetDate(RTC_TypeDef * RTCx)2611 __STATIC_INLINE uint32_t LL_RTC_TS_GetDate(RTC_TypeDef *RTCx)
2612 {
2613 return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU | RTC_TSDR_MT | RTC_TSDR_MU | RTC_TSDR_DT | RTC_TSDR_DU));
2614 }
2615
2616 /**
2617 * @brief Get time-stamp sub second value
2618 * @rmtoll TSSSR SS LL_RTC_TS_GetSubSecond
2619 * @param RTCx RTC Instance
2620 * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF
2621 */
LL_RTC_TS_GetSubSecond(RTC_TypeDef * RTCx)2622 __STATIC_INLINE uint32_t LL_RTC_TS_GetSubSecond(RTC_TypeDef *RTCx)
2623 {
2624 return (uint32_t)(READ_BIT(RTCx->TSSSR, RTC_TSSSR_SS));
2625 }
2626
2627 #if defined(RTC_TAMPCR_TAMPTS)
2628 /**
2629 * @brief Activate timestamp on tamper detection event
2630 * @rmtoll TAMPCR TAMPTS LL_RTC_TS_EnableOnTamper
2631 * @param RTCx RTC Instance
2632 * @retval None
2633 */
LL_RTC_TS_EnableOnTamper(RTC_TypeDef * RTCx)2634 __STATIC_INLINE void LL_RTC_TS_EnableOnTamper(RTC_TypeDef *RTCx)
2635 {
2636 SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPTS);
2637 }
2638
2639 /**
2640 * @brief Disable timestamp on tamper detection event
2641 * @rmtoll TAMPCR TAMPTS LL_RTC_TS_DisableOnTamper
2642 * @param RTCx RTC Instance
2643 * @retval None
2644 */
LL_RTC_TS_DisableOnTamper(RTC_TypeDef * RTCx)2645 __STATIC_INLINE void LL_RTC_TS_DisableOnTamper(RTC_TypeDef *RTCx)
2646 {
2647 CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPTS);
2648 }
2649 #endif /* RTC_TAMPCR_TAMPTS */
2650
2651 /**
2652 * @}
2653 */
2654
2655 /** @defgroup RTC_LL_EF_Tamper Tamper
2656 * @{
2657 */
2658
2659 /**
2660 * @brief Enable RTC_TAMPx input detection
2661 * @rmtoll TAMPCR TAMP1E LL_RTC_TAMPER_Enable\n
2662 * TAMPCR TAMP2E LL_RTC_TAMPER_Enable\n
2663 * TAMPCR TAMP3E LL_RTC_TAMPER_Enable
2664 * @param RTCx RTC Instance
2665 * @param Tamper This parameter can be a combination of the following values:
2666 * @arg @ref LL_RTC_TAMPER_1 (*)
2667 * @arg @ref LL_RTC_TAMPER_2
2668 * @arg @ref LL_RTC_TAMPER_3 (*)
2669 *
2670 * (*) Value not defined in all devices. \n
2671 *
2672 * @retval None
2673 */
LL_RTC_TAMPER_Enable(RTC_TypeDef * RTCx,uint32_t Tamper)2674 __STATIC_INLINE void LL_RTC_TAMPER_Enable(RTC_TypeDef *RTCx, uint32_t Tamper)
2675 {
2676 SET_BIT(RTCx->TAMPCR, Tamper);
2677 }
2678
2679 /**
2680 * @brief Clear RTC_TAMPx input detection
2681 * @rmtoll TAMPCR TAMP1E LL_RTC_TAMPER_Disable\n
2682 * TAMPCR TAMP2E LL_RTC_TAMPER_Disable\n
2683 * TAMPCR TAMP3E LL_RTC_TAMPER_Disable
2684 * @param RTCx RTC Instance
2685 * @param Tamper This parameter can be a combination of the following values:
2686 * @arg @ref LL_RTC_TAMPER_1 (*)
2687 * @arg @ref LL_RTC_TAMPER_2
2688 * @arg @ref LL_RTC_TAMPER_3 (*)
2689 *
2690 * (*) Value not defined in all devices. \n
2691 *
2692 * @retval None
2693 */
LL_RTC_TAMPER_Disable(RTC_TypeDef * RTCx,uint32_t Tamper)2694 __STATIC_INLINE void LL_RTC_TAMPER_Disable(RTC_TypeDef *RTCx, uint32_t Tamper)
2695 {
2696 CLEAR_BIT(RTCx->TAMPCR, Tamper);
2697 }
2698
2699 /**
2700 * @brief Enable Tamper mask flag
2701 * @note Associated Tamper IT must not enabled when tamper mask is set.
2702 * @rmtoll TAMPCR TAMP1MF LL_RTC_TAMPER_EnableMask\n
2703 * TAMPCR TAMP2MF LL_RTC_TAMPER_EnableMask\n
2704 * TAMPCR TAMP3MF LL_RTC_TAMPER_EnableMask
2705 * @param RTCx RTC Instance
2706 * @param Mask This parameter can be a combination of the following values:
2707 * @arg @ref LL_RTC_TAMPER_MASK_TAMPER1 (*)
2708 * @arg @ref LL_RTC_TAMPER_MASK_TAMPER2
2709 * @arg @ref LL_RTC_TAMPER_MASK_TAMPER3 (*)
2710 *
2711 * (*) Value not defined in all devices. \n
2712 *
2713 * @retval None
2714 */
LL_RTC_TAMPER_EnableMask(RTC_TypeDef * RTCx,uint32_t Mask)2715 __STATIC_INLINE void LL_RTC_TAMPER_EnableMask(RTC_TypeDef *RTCx, uint32_t Mask)
2716 {
2717 SET_BIT(RTCx->TAMPCR, Mask);
2718 }
2719
2720 /**
2721 * @brief Disable Tamper mask flag
2722 * @rmtoll TAMPCR TAMP1MF LL_RTC_TAMPER_DisableMask\n
2723 * TAMPCR TAMP2MF LL_RTC_TAMPER_DisableMask\n
2724 * TAMPCR TAMP3MF LL_RTC_TAMPER_DisableMask
2725 * @param RTCx RTC Instance
2726 * @param Mask This parameter can be a combination of the following values:
2727 * @arg @ref LL_RTC_TAMPER_MASK_TAMPER1 (*)
2728 * @arg @ref LL_RTC_TAMPER_MASK_TAMPER2
2729 * @arg @ref LL_RTC_TAMPER_MASK_TAMPER3 (*)
2730 *
2731 * (*) Value not defined in all devices. \n
2732 *
2733 * @retval None
2734 */
LL_RTC_TAMPER_DisableMask(RTC_TypeDef * RTCx,uint32_t Mask)2735 __STATIC_INLINE void LL_RTC_TAMPER_DisableMask(RTC_TypeDef *RTCx, uint32_t Mask)
2736 {
2737 CLEAR_BIT(RTCx->TAMPCR, Mask);
2738 }
2739
2740 /**
2741 * @brief Enable backup register erase after Tamper event detection
2742 * @rmtoll TAMPCR TAMP1NOERASE LL_RTC_TAMPER_EnableEraseBKP\n
2743 * TAMPCR TAMP2NOERASE LL_RTC_TAMPER_EnableEraseBKP\n
2744 * TAMPCR TAMP3NOERASE LL_RTC_TAMPER_EnableEraseBKP
2745 * @param RTCx RTC Instance
2746 * @param Tamper This parameter can be a combination of the following values:
2747 * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER1 (*)
2748 * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER2
2749 * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER3 (*)
2750 *
2751 * (*) Value not defined in all devices. \n
2752 *
2753 * @retval None
2754 */
LL_RTC_TAMPER_EnableEraseBKP(RTC_TypeDef * RTCx,uint32_t Tamper)2755 __STATIC_INLINE void LL_RTC_TAMPER_EnableEraseBKP(RTC_TypeDef *RTCx, uint32_t Tamper)
2756 {
2757 CLEAR_BIT(RTCx->TAMPCR, Tamper);
2758 }
2759
2760 /**
2761 * @brief Disable backup register erase after Tamper event detection
2762 * @rmtoll TAMPCR TAMP1NOERASE LL_RTC_TAMPER_DisableEraseBKP\n
2763 * TAMPCR TAMP2NOERASE LL_RTC_TAMPER_DisableEraseBKP\n
2764 * TAMPCR TAMP3NOERASE LL_RTC_TAMPER_DisableEraseBKP
2765 * @param RTCx RTC Instance
2766 * @param Tamper This parameter can be a combination of the following values:
2767 * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER1 (*)
2768 * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER2
2769 * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER3 (*)
2770 *
2771 * (*) Value not defined in all devices. \n
2772 *
2773 * @retval None
2774 */
LL_RTC_TAMPER_DisableEraseBKP(RTC_TypeDef * RTCx,uint32_t Tamper)2775 __STATIC_INLINE void LL_RTC_TAMPER_DisableEraseBKP(RTC_TypeDef *RTCx, uint32_t Tamper)
2776 {
2777 SET_BIT(RTCx->TAMPCR, Tamper);
2778 }
2779
2780 #if defined(RTC_TAMPCR_TAMPPUDIS)
2781 /**
2782 * @brief Disable RTC_TAMPx pull-up disable (Disable precharge of RTC_TAMPx pins)
2783 * @rmtoll TAMPCR TAMPPUDIS LL_RTC_TAMPER_DisablePullUp
2784 * @param RTCx RTC Instance
2785 * @retval None
2786 */
LL_RTC_TAMPER_DisablePullUp(RTC_TypeDef * RTCx)2787 __STATIC_INLINE void LL_RTC_TAMPER_DisablePullUp(RTC_TypeDef *RTCx)
2788 {
2789 SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPPUDIS);
2790 }
2791
2792 /**
2793 * @brief Enable RTC_TAMPx pull-up disable ( Precharge RTC_TAMPx pins before sampling)
2794 * @rmtoll TAMPCR TAMPPUDIS LL_RTC_TAMPER_EnablePullUp
2795 * @param RTCx RTC Instance
2796 * @retval None
2797 */
LL_RTC_TAMPER_EnablePullUp(RTC_TypeDef * RTCx)2798 __STATIC_INLINE void LL_RTC_TAMPER_EnablePullUp(RTC_TypeDef *RTCx)
2799 {
2800 CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPPUDIS);
2801 }
2802 #endif /* RTC_TAMPCR_TAMPPUDIS */
2803
2804 #if defined(RTC_TAMPCR_TAMPPRCH)
2805 /**
2806 * @brief Set RTC_TAMPx precharge duration
2807 * @rmtoll TAMPCR TAMPPRCH LL_RTC_TAMPER_SetPrecharge
2808 * @param RTCx RTC Instance
2809 * @param Duration This parameter can be one of the following values:
2810 * @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
2811 * @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
2812 * @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
2813 * @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
2814 * @retval None
2815 */
LL_RTC_TAMPER_SetPrecharge(RTC_TypeDef * RTCx,uint32_t Duration)2816 __STATIC_INLINE void LL_RTC_TAMPER_SetPrecharge(RTC_TypeDef *RTCx, uint32_t Duration)
2817 {
2818 MODIFY_REG(RTCx->TAMPCR, RTC_TAMPCR_TAMPPRCH, Duration);
2819 }
2820
2821 /**
2822 * @brief Get RTC_TAMPx precharge duration
2823 * @rmtoll TAMPCR TAMPPRCH LL_RTC_TAMPER_GetPrecharge
2824 * @param RTCx RTC Instance
2825 * @retval Returned value can be one of the following values:
2826 * @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
2827 * @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
2828 * @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
2829 * @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
2830 */
LL_RTC_TAMPER_GetPrecharge(RTC_TypeDef * RTCx)2831 __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetPrecharge(RTC_TypeDef *RTCx)
2832 {
2833 return (uint32_t)(READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPPRCH));
2834 }
2835 #endif /* RTC_TAMPCR_TAMPPRCH */
2836
2837 #if defined(RTC_TAMPCR_TAMPFLT)
2838 /**
2839 * @brief Set RTC_TAMPx filter count
2840 * @rmtoll TAMPCR TAMPFLT LL_RTC_TAMPER_SetFilterCount
2841 * @param RTCx RTC Instance
2842 * @param FilterCount This parameter can be one of the following values:
2843 * @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
2844 * @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
2845 * @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
2846 * @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
2847 * @retval None
2848 */
LL_RTC_TAMPER_SetFilterCount(RTC_TypeDef * RTCx,uint32_t FilterCount)2849 __STATIC_INLINE void LL_RTC_TAMPER_SetFilterCount(RTC_TypeDef *RTCx, uint32_t FilterCount)
2850 {
2851 MODIFY_REG(RTCx->TAMPCR, RTC_TAMPCR_TAMPFLT, FilterCount);
2852 }
2853
2854 /**
2855 * @brief Get RTC_TAMPx filter count
2856 * @rmtoll TAMPCR TAMPFLT LL_RTC_TAMPER_GetFilterCount
2857 * @param RTCx RTC Instance
2858 * @retval Returned value can be one of the following values:
2859 * @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
2860 * @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
2861 * @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
2862 * @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
2863 */
LL_RTC_TAMPER_GetFilterCount(RTC_TypeDef * RTCx)2864 __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetFilterCount(RTC_TypeDef *RTCx)
2865 {
2866 return (uint32_t)(READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPFLT));
2867 }
2868 #endif /* RTC_TAMPCR_TAMPFLT */
2869
2870 #if defined(RTC_TAMPCR_TAMPFREQ)
2871 /**
2872 * @brief Set Tamper sampling frequency
2873 * @rmtoll TAMPCR TAMPFREQ LL_RTC_TAMPER_SetSamplingFreq
2874 * @param RTCx RTC Instance
2875 * @param SamplingFreq This parameter can be one of the following values:
2876 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
2877 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
2878 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
2879 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
2880 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
2881 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
2882 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
2883 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
2884 * @retval None
2885 */
LL_RTC_TAMPER_SetSamplingFreq(RTC_TypeDef * RTCx,uint32_t SamplingFreq)2886 __STATIC_INLINE void LL_RTC_TAMPER_SetSamplingFreq(RTC_TypeDef *RTCx, uint32_t SamplingFreq)
2887 {
2888 MODIFY_REG(RTCx->TAMPCR, RTC_TAMPCR_TAMPFREQ, SamplingFreq);
2889 }
2890
2891 /**
2892 * @brief Get Tamper sampling frequency
2893 * @rmtoll TAMPCR TAMPFREQ LL_RTC_TAMPER_GetSamplingFreq
2894 * @param RTCx RTC Instance
2895 * @retval Returned value can be one of the following values:
2896 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
2897 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
2898 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
2899 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
2900 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
2901 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
2902 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
2903 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
2904 */
LL_RTC_TAMPER_GetSamplingFreq(RTC_TypeDef * RTCx)2905 __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetSamplingFreq(RTC_TypeDef *RTCx)
2906 {
2907 return (uint32_t)(READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPFREQ));
2908 }
2909 #endif /* RTC_TAMPCR_TAMPFREQ */
2910
2911 /**
2912 * @brief Enable Active level for Tamper input
2913 * @rmtoll TAMPCR TAMP1TRG LL_RTC_TAMPER_EnableActiveLevel\n
2914 * TAMPCR TAMP2TRG LL_RTC_TAMPER_EnableActiveLevel\n
2915 * TAMPCR TAMP3TRG LL_RTC_TAMPER_EnableActiveLevel
2916 * @param RTCx RTC Instance
2917 * @param Tamper This parameter can be a combination of the following values:
2918 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1
2919 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2
2920 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP3
2921 *
2922 * @retval None
2923 */
LL_RTC_TAMPER_EnableActiveLevel(RTC_TypeDef * RTCx,uint32_t Tamper)2924 __STATIC_INLINE void LL_RTC_TAMPER_EnableActiveLevel(RTC_TypeDef *RTCx, uint32_t Tamper)
2925 {
2926 SET_BIT(RTCx->TAMPCR, Tamper);
2927 }
2928
2929 /**
2930 * @brief Disable Active level for Tamper input
2931 * @rmtoll TAMPCR TAMP1TRG LL_RTC_TAMPER_DisableActiveLevel\n
2932 * TAMPCR TAMP2TRG LL_RTC_TAMPER_DisableActiveLevel\n
2933 * TAMPCR TAMP3TRG LL_RTC_TAMPER_DisableActiveLevel
2934 * @param RTCx RTC Instance
2935 * @param Tamper This parameter can be a combination of the following values:
2936 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1
2937 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2
2938 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP3
2939 *
2940 * @retval None
2941 */
LL_RTC_TAMPER_DisableActiveLevel(RTC_TypeDef * RTCx,uint32_t Tamper)2942 __STATIC_INLINE void LL_RTC_TAMPER_DisableActiveLevel(RTC_TypeDef *RTCx, uint32_t Tamper)
2943 {
2944 CLEAR_BIT(RTCx->TAMPCR, Tamper);
2945 }
2946
2947 /**
2948 * @}
2949 */
2950
2951 #if defined(RTC_WAKEUP_SUPPORT)
2952 /** @defgroup RTC_LL_EF_Wakeup Wakeup
2953 * @{
2954 */
2955
2956 /**
2957 * @brief Enable Wakeup timer
2958 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2959 * @rmtoll CR WUTE LL_RTC_WAKEUP_Enable
2960 * @param RTCx RTC Instance
2961 * @retval None
2962 */
LL_RTC_WAKEUP_Enable(RTC_TypeDef * RTCx)2963 __STATIC_INLINE void LL_RTC_WAKEUP_Enable(RTC_TypeDef *RTCx)
2964 {
2965 SET_BIT(RTCx->CR, RTC_CR_WUTE);
2966 }
2967
2968 /**
2969 * @brief Disable Wakeup timer
2970 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2971 * @rmtoll CR WUTE LL_RTC_WAKEUP_Disable
2972 * @param RTCx RTC Instance
2973 * @retval None
2974 */
LL_RTC_WAKEUP_Disable(RTC_TypeDef * RTCx)2975 __STATIC_INLINE void LL_RTC_WAKEUP_Disable(RTC_TypeDef *RTCx)
2976 {
2977 CLEAR_BIT(RTCx->CR, RTC_CR_WUTE);
2978 }
2979
2980 /**
2981 * @brief Check if Wakeup timer is enabled or not
2982 * @rmtoll CR WUTE LL_RTC_WAKEUP_IsEnabled
2983 * @param RTCx RTC Instance
2984 * @retval State of bit (1 or 0).
2985 */
LL_RTC_WAKEUP_IsEnabled(RTC_TypeDef * RTCx)2986 __STATIC_INLINE uint32_t LL_RTC_WAKEUP_IsEnabled(RTC_TypeDef *RTCx)
2987 {
2988 return ((READ_BIT(RTCx->CR, RTC_CR_WUTE) == (RTC_CR_WUTE)) ? 1UL : 0UL);
2989 }
2990
2991 /**
2992 * @brief Select Wakeup clock
2993 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2994 * @note Bit can be written only when RTC_CR WUTE bit = 0 and RTC_ISR WUTWF bit = 1
2995 * @rmtoll CR WUCKSEL LL_RTC_WAKEUP_SetClock
2996 * @param RTCx RTC Instance
2997 * @param WakeupClock This parameter can be one of the following values:
2998 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
2999 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
3000 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
3001 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
3002 * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
3003 * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
3004 * @retval None
3005 */
LL_RTC_WAKEUP_SetClock(RTC_TypeDef * RTCx,uint32_t WakeupClock)3006 __STATIC_INLINE void LL_RTC_WAKEUP_SetClock(RTC_TypeDef *RTCx, uint32_t WakeupClock)
3007 {
3008 MODIFY_REG(RTCx->CR, RTC_CR_WUCKSEL, WakeupClock);
3009 }
3010
3011 /**
3012 * @brief Get Wakeup clock
3013 * @rmtoll CR WUCKSEL LL_RTC_WAKEUP_GetClock
3014 * @param RTCx RTC Instance
3015 * @retval Returned value can be one of the following values:
3016 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
3017 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
3018 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
3019 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
3020 * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
3021 * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
3022 */
LL_RTC_WAKEUP_GetClock(RTC_TypeDef * RTCx)3023 __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetClock(RTC_TypeDef *RTCx)
3024 {
3025 return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_WUCKSEL));
3026 }
3027
3028 /**
3029 * @brief Set Wakeup auto-reload value
3030 * @note Bit can be written only when WUTWF is set to 1 in RTC_ISR
3031 * @rmtoll WUTR WUT LL_RTC_WAKEUP_SetAutoReload
3032 * @param RTCx RTC Instance
3033 * @param Value Value between Min_Data=0x00 and Max_Data=0xFFFF
3034 * @retval None
3035 */
LL_RTC_WAKEUP_SetAutoReload(RTC_TypeDef * RTCx,uint32_t Value)3036 __STATIC_INLINE void LL_RTC_WAKEUP_SetAutoReload(RTC_TypeDef *RTCx, uint32_t Value)
3037 {
3038 MODIFY_REG(RTCx->WUTR, RTC_WUTR_WUT, Value);
3039 }
3040
3041 /**
3042 * @brief Get Wakeup auto-reload value
3043 * @rmtoll WUTR WUT LL_RTC_WAKEUP_GetAutoReload
3044 * @param RTCx RTC Instance
3045 * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF
3046 */
LL_RTC_WAKEUP_GetAutoReload(RTC_TypeDef * RTCx)3047 __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetAutoReload(RTC_TypeDef *RTCx)
3048 {
3049 return (uint32_t)(READ_BIT(RTCx->WUTR, RTC_WUTR_WUT));
3050 }
3051
3052 /**
3053 * @}
3054 */
3055 #endif /* RTC_WAKEUP_SUPPORT */
3056
3057 #if defined(RTC_BACKUP_SUPPORT)
3058 /** @defgroup RTC_LL_EF_Backup_Registers Backup_Registers
3059 * @{
3060 */
3061
3062 /**
3063 * @brief Writes a data in a specified RTC Backup data register.
3064 * @rmtoll BKPxR BKP LL_RTC_BAK_SetRegister
3065 * @param RTCx RTC Instance
3066 * @param BackupRegister This parameter can be one of the following values:
3067 * @arg @ref LL_RTC_BKP_DR0
3068 * @arg @ref LL_RTC_BKP_DR1
3069 * @arg @ref LL_RTC_BKP_DR2
3070 * @arg @ref LL_RTC_BKP_DR3
3071 * @arg @ref LL_RTC_BKP_DR4
3072 * @arg @ref LL_RTC_BKP_DR5
3073 * @arg @ref LL_RTC_BKP_DR6
3074 * @arg @ref LL_RTC_BKP_DR7
3075 * @arg @ref LL_RTC_BKP_DR8
3076 * @arg @ref LL_RTC_BKP_DR9
3077 * @arg @ref LL_RTC_BKP_DR10
3078 * @arg @ref LL_RTC_BKP_DR11
3079 * @arg @ref LL_RTC_BKP_DR12
3080 * @arg @ref LL_RTC_BKP_DR13
3081 * @arg @ref LL_RTC_BKP_DR14
3082 * @arg @ref LL_RTC_BKP_DR15
3083 * @arg @ref LL_RTC_BKP_DR16
3084 * @arg @ref LL_RTC_BKP_DR17
3085 * @arg @ref LL_RTC_BKP_DR18
3086 * @arg @ref LL_RTC_BKP_DR19
3087 * @param Data Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
3088 * @retval None
3089 */
LL_RTC_BAK_SetRegister(RTC_TypeDef * RTCx,uint32_t BackupRegister,uint32_t Data)3090 __STATIC_INLINE void LL_RTC_BAK_SetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister, uint32_t Data)
3091 {
3092 __IO uint32_t *tmp;
3093
3094 tmp = &(RTCx->BKP0R) + BackupRegister;
3095
3096 *tmp = Data;
3097 }
3098
3099 /**
3100 * @brief Reads data from the specified RTC Backup data Register.
3101 * @rmtoll BKPxR BKP LL_RTC_BAK_GetRegister
3102 * @param RTCx RTC Instance
3103 * @param BackupRegister This parameter can be one of the following values:
3104 * @arg @ref LL_RTC_BKP_DR0
3105 * @arg @ref LL_RTC_BKP_DR1
3106 * @arg @ref LL_RTC_BKP_DR2
3107 * @arg @ref LL_RTC_BKP_DR3
3108 * @arg @ref LL_RTC_BKP_DR4
3109 * @arg @ref LL_RTC_BKP_DR5
3110 * @arg @ref LL_RTC_BKP_DR6
3111 * @arg @ref LL_RTC_BKP_DR7
3112 * @arg @ref LL_RTC_BKP_DR8
3113 * @arg @ref LL_RTC_BKP_DR9
3114 * @arg @ref LL_RTC_BKP_DR10
3115 * @arg @ref LL_RTC_BKP_DR11
3116 * @arg @ref LL_RTC_BKP_DR12
3117 * @arg @ref LL_RTC_BKP_DR13
3118 * @arg @ref LL_RTC_BKP_DR14
3119 * @arg @ref LL_RTC_BKP_DR15
3120 * @arg @ref LL_RTC_BKP_DR16
3121 * @arg @ref LL_RTC_BKP_DR17
3122 * @arg @ref LL_RTC_BKP_DR18
3123 * @arg @ref LL_RTC_BKP_DR19
3124 * @retval Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
3125 */
LL_RTC_BAK_GetRegister(RTC_TypeDef * RTCx,uint32_t BackupRegister)3126 __STATIC_INLINE uint32_t LL_RTC_BAK_GetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister)
3127 {
3128 const __IO uint32_t *tmp;
3129
3130 tmp = &(RTCx->BKP0R) + BackupRegister;
3131
3132 /* Read the specified register */
3133 return *tmp;
3134 }
3135
3136 /**
3137 * @}
3138 */
3139 #endif /* RTC_BACKUP_SUPPORT */
3140
3141 /** @defgroup RTC_LL_EF_Calibration Calibration
3142 * @{
3143 */
3144
3145 /**
3146 * @brief Set Calibration output frequency (1 Hz or 512 Hz)
3147 * @note Bits are write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3148 * @rmtoll CR COE LL_RTC_CAL_SetOutputFreq\n
3149 * CR COSEL LL_RTC_CAL_SetOutputFreq
3150 * @param RTCx RTC Instance
3151 * @param Frequency This parameter can be one of the following values:
3152 * @arg @ref LL_RTC_CALIB_OUTPUT_NONE
3153 * @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
3154 * @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
3155 * @retval None
3156 */
LL_RTC_CAL_SetOutputFreq(RTC_TypeDef * RTCx,uint32_t Frequency)3157 __STATIC_INLINE void LL_RTC_CAL_SetOutputFreq(RTC_TypeDef *RTCx, uint32_t Frequency)
3158 {
3159 MODIFY_REG(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL, Frequency);
3160 }
3161
3162 /**
3163 * @brief Get Calibration output frequency (1 Hz or 512 Hz)
3164 * @rmtoll CR COE LL_RTC_CAL_GetOutputFreq\n
3165 * CR COSEL LL_RTC_CAL_GetOutputFreq
3166 * @param RTCx RTC Instance
3167 * @retval Returned value can be one of the following values:
3168 * @arg @ref LL_RTC_CALIB_OUTPUT_NONE
3169 * @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
3170 * @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
3171 */
LL_RTC_CAL_GetOutputFreq(RTC_TypeDef * RTCx)3172 __STATIC_INLINE uint32_t LL_RTC_CAL_GetOutputFreq(RTC_TypeDef *RTCx)
3173 {
3174 return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL));
3175 }
3176
3177 /**
3178 * @brief Insert or not One RTCCLK pulse every 2exp11 pulses (frequency increased by 488.5 ppm)
3179 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3180 * @note Bit can be written only when RECALPF is set to 0 in RTC_ISR
3181 * @rmtoll CALR CALP LL_RTC_CAL_SetPulse
3182 * @param RTCx RTC Instance
3183 * @param Pulse This parameter can be one of the following values:
3184 * @arg @ref LL_RTC_CALIB_INSERTPULSE_NONE
3185 * @arg @ref LL_RTC_CALIB_INSERTPULSE_SET
3186 * @retval None
3187 */
LL_RTC_CAL_SetPulse(RTC_TypeDef * RTCx,uint32_t Pulse)3188 __STATIC_INLINE void LL_RTC_CAL_SetPulse(RTC_TypeDef *RTCx, uint32_t Pulse)
3189 {
3190 MODIFY_REG(RTCx->CALR, RTC_CALR_CALP, Pulse);
3191 }
3192
3193 /**
3194 * @brief Check if one RTCCLK has been inserted or not every 2exp11 pulses (frequency increased by 488.5 ppm)
3195 * @rmtoll CALR CALP LL_RTC_CAL_IsPulseInserted
3196 * @param RTCx RTC Instance
3197 * @retval State of bit (1 or 0).
3198 */
LL_RTC_CAL_IsPulseInserted(RTC_TypeDef * RTCx)3199 __STATIC_INLINE uint32_t LL_RTC_CAL_IsPulseInserted(RTC_TypeDef *RTCx)
3200 {
3201 return ((READ_BIT(RTCx->CALR, RTC_CALR_CALP) == (RTC_CALR_CALP)) ? 1UL : 0UL);
3202 }
3203
3204 /**
3205 * @brief Set the calibration cycle period
3206 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3207 * @note Bit can be written only when RECALPF is set to 0 in RTC_ISR
3208 * @rmtoll CALR CALW8 LL_RTC_CAL_SetPeriod\n
3209 * CALR CALW16 LL_RTC_CAL_SetPeriod
3210 * @param RTCx RTC Instance
3211 * @param Period This parameter can be one of the following values:
3212 * @arg @ref LL_RTC_CALIB_PERIOD_32SEC
3213 * @arg @ref LL_RTC_CALIB_PERIOD_16SEC
3214 * @arg @ref LL_RTC_CALIB_PERIOD_8SEC
3215 * @retval None
3216 */
LL_RTC_CAL_SetPeriod(RTC_TypeDef * RTCx,uint32_t Period)3217 __STATIC_INLINE void LL_RTC_CAL_SetPeriod(RTC_TypeDef *RTCx, uint32_t Period)
3218 {
3219 MODIFY_REG(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16, Period);
3220 }
3221
3222 /**
3223 * @brief Get the calibration cycle period
3224 * @rmtoll CALR CALW8 LL_RTC_CAL_GetPeriod\n
3225 * CALR CALW16 LL_RTC_CAL_GetPeriod
3226 * @param RTCx RTC Instance
3227 * @retval Returned value can be one of the following values:
3228 * @arg @ref LL_RTC_CALIB_PERIOD_32SEC
3229 * @arg @ref LL_RTC_CALIB_PERIOD_16SEC
3230 * @arg @ref LL_RTC_CALIB_PERIOD_8SEC
3231 */
LL_RTC_CAL_GetPeriod(RTC_TypeDef * RTCx)3232 __STATIC_INLINE uint32_t LL_RTC_CAL_GetPeriod(RTC_TypeDef *RTCx)
3233 {
3234 return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16));
3235 }
3236
3237 /**
3238 * @brief Set Calibration minus
3239 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3240 * @note Bit can be written only when RECALPF is set to 0 in RTC_ISR
3241 * @rmtoll CALR CALM LL_RTC_CAL_SetMinus
3242 * @param RTCx RTC Instance
3243 * @param CalibMinus Value between Min_Data=0x00 and Max_Data=0x1FF
3244 * @retval None
3245 */
LL_RTC_CAL_SetMinus(RTC_TypeDef * RTCx,uint32_t CalibMinus)3246 __STATIC_INLINE void LL_RTC_CAL_SetMinus(RTC_TypeDef *RTCx, uint32_t CalibMinus)
3247 {
3248 MODIFY_REG(RTCx->CALR, RTC_CALR_CALM, CalibMinus);
3249 }
3250
3251 /**
3252 * @brief Get Calibration minus
3253 * @rmtoll CALR CALM LL_RTC_CAL_GetMinus
3254 * @param RTCx RTC Instance
3255 * @retval Value between Min_Data=0x00 and Max_Data= 0x1FF
3256 */
LL_RTC_CAL_GetMinus(RTC_TypeDef * RTCx)3257 __STATIC_INLINE uint32_t LL_RTC_CAL_GetMinus(RTC_TypeDef *RTCx)
3258 {
3259 return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALM));
3260 }
3261
3262 /**
3263 * @}
3264 */
3265
3266 /** @defgroup RTC_LL_EF_FLAG_Management FLAG_Management
3267 * @{
3268 */
3269
3270 /**
3271 * @brief Get Internal Time-stamp flag
3272 * @rmtoll ISR ITSF LL_RTC_IsActiveFlag_ITS
3273 * @param RTCx RTC Instance
3274 * @retval State of bit (1 or 0).
3275 */
LL_RTC_IsActiveFlag_ITS(RTC_TypeDef * RTCx)3276 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITS(RTC_TypeDef *RTCx)
3277 {
3278 return ((READ_BIT(RTCx->ISR, RTC_ISR_ITSF) == (RTC_ISR_ITSF)) ? 1UL : 0UL);
3279 }
3280
3281 /**
3282 * @brief Get Recalibration pending Flag
3283 * @rmtoll ISR RECALPF LL_RTC_IsActiveFlag_RECALP
3284 * @param RTCx RTC Instance
3285 * @retval State of bit (1 or 0).
3286 */
LL_RTC_IsActiveFlag_RECALP(RTC_TypeDef * RTCx)3287 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RECALP(RTC_TypeDef *RTCx)
3288 {
3289 return ((READ_BIT(RTCx->ISR, RTC_ISR_RECALPF) == (RTC_ISR_RECALPF)) ? 1UL : 0UL);
3290 }
3291
3292 #if defined(RTC_TAMPER3_SUPPORT)
3293 /**
3294 * @brief Get RTC_TAMP3 detection flag
3295 * @rmtoll ISR TAMP3F LL_RTC_IsActiveFlag_TAMP3
3296 * @param RTCx RTC Instance
3297 * @retval State of bit (1 or 0).
3298 */
LL_RTC_IsActiveFlag_TAMP3(RTC_TypeDef * RTCx)3299 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP3(RTC_TypeDef *RTCx)
3300 {
3301 return ((READ_BIT(RTCx->ISR, RTC_ISR_TAMP3F) == (RTC_ISR_TAMP3F)) ? 1UL : 0UL);
3302 }
3303 #endif /* RTC_TAMPER3_SUPPORT */
3304
3305 #if defined(RTC_TAMPER2_SUPPORT)
3306 /**
3307 * @brief Get RTC_TAMP2 detection flag
3308 * @rmtoll ISR TAMP2F LL_RTC_IsActiveFlag_TAMP2
3309 * @param RTCx RTC Instance
3310 * @retval State of bit (1 or 0).
3311 */
LL_RTC_IsActiveFlag_TAMP2(RTC_TypeDef * RTCx)3312 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP2(RTC_TypeDef *RTCx)
3313 {
3314 return ((READ_BIT(RTCx->ISR, RTC_ISR_TAMP2F) == (RTC_ISR_TAMP2F)) ? 1UL : 0UL);
3315 }
3316 #endif /* RTC_TAMPER2_SUPPORT */
3317
3318 #if defined(RTC_TAMPER1_SUPPORT)
3319 /**
3320 * @brief Get RTC_TAMP1 detection flag
3321 * @rmtoll ISR TAMP1F LL_RTC_IsActiveFlag_TAMP1
3322 * @param RTCx RTC Instance
3323 * @retval State of bit (1 or 0).
3324 */
LL_RTC_IsActiveFlag_TAMP1(RTC_TypeDef * RTCx)3325 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP1(RTC_TypeDef *RTCx)
3326 {
3327 return ((READ_BIT(RTCx->ISR, RTC_ISR_TAMP1F) == (RTC_ISR_TAMP1F)) ? 1UL : 0UL);
3328 }
3329 #endif /* RTC_TAMPER1_SUPPORT */
3330
3331 /**
3332 * @brief Get Time-stamp overflow flag
3333 * @rmtoll ISR TSOVF LL_RTC_IsActiveFlag_TSOV
3334 * @param RTCx RTC Instance
3335 * @retval State of bit (1 or 0).
3336 */
LL_RTC_IsActiveFlag_TSOV(RTC_TypeDef * RTCx)3337 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSOV(RTC_TypeDef *RTCx)
3338 {
3339 return ((READ_BIT(RTCx->ISR, RTC_ISR_TSOVF) == (RTC_ISR_TSOVF)) ? 1UL : 0UL);
3340 }
3341
3342 /**
3343 * @brief Get Time-stamp flag
3344 * @rmtoll ISR TSF LL_RTC_IsActiveFlag_TS
3345 * @param RTCx RTC Instance
3346 * @retval State of bit (1 or 0).
3347 */
LL_RTC_IsActiveFlag_TS(RTC_TypeDef * RTCx)3348 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TS(RTC_TypeDef *RTCx)
3349 {
3350 return ((READ_BIT(RTCx->ISR, RTC_ISR_TSF) == (RTC_ISR_TSF)) ? 1UL : 0UL);
3351 }
3352
3353 #if defined(RTC_WAKEUP_SUPPORT)
3354 /**
3355 * @brief Get Wakeup timer flag
3356 * @rmtoll ISR WUTF LL_RTC_IsActiveFlag_WUT
3357 * @param RTCx RTC Instance
3358 * @retval State of bit (1 or 0).
3359 */
LL_RTC_IsActiveFlag_WUT(RTC_TypeDef * RTCx)3360 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUT(RTC_TypeDef *RTCx)
3361 {
3362 return ((READ_BIT(RTCx->ISR, RTC_ISR_WUTF) == (RTC_ISR_WUTF)) ? 1UL : 0UL);
3363 }
3364 #endif /* RTC_WAKEUP_SUPPORT */
3365
3366 /**
3367 * @brief Get Alarm B flag
3368 * @rmtoll ISR ALRBF LL_RTC_IsActiveFlag_ALRB
3369 * @param RTCx RTC Instance
3370 * @retval State of bit (1 or 0).
3371 */
LL_RTC_IsActiveFlag_ALRB(RTC_TypeDef * RTCx)3372 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRB(RTC_TypeDef *RTCx)
3373 {
3374 return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRBF) == (RTC_ISR_ALRBF)) ? 1UL : 0UL);
3375 }
3376
3377 /**
3378 * @brief Get Alarm A flag
3379 * @rmtoll ISR ALRAF LL_RTC_IsActiveFlag_ALRA
3380 * @param RTCx RTC Instance
3381 * @retval State of bit (1 or 0).
3382 */
LL_RTC_IsActiveFlag_ALRA(RTC_TypeDef * RTCx)3383 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRA(RTC_TypeDef *RTCx)
3384 {
3385 return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRAF) == (RTC_ISR_ALRAF)) ? 1UL : 0UL);
3386 }
3387
3388 /**
3389 * @brief Clear Internal Time-stamp flag
3390 * @rmtoll ISR ITSF LL_RTC_ClearFlag_ITS
3391 * @param RTCx RTC Instance
3392 * @retval None
3393 */
LL_RTC_ClearFlag_ITS(RTC_TypeDef * RTCx)3394 __STATIC_INLINE void LL_RTC_ClearFlag_ITS(RTC_TypeDef *RTCx)
3395 {
3396 WRITE_REG(RTCx->ISR, (~((RTC_ISR_ITSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
3397 }
3398
3399 #if defined(RTC_TAMPER3_SUPPORT)
3400 /**
3401 * @brief Clear RTC_TAMP3 detection flag
3402 * @rmtoll ISR TAMP3F LL_RTC_ClearFlag_TAMP3
3403 * @param RTCx RTC Instance
3404 * @retval None
3405 */
LL_RTC_ClearFlag_TAMP3(RTC_TypeDef * RTCx)3406 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP3(RTC_TypeDef *RTCx)
3407 {
3408 WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP3F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
3409 }
3410 #endif /* RTC_TAMPER3_SUPPORT */
3411
3412 #if defined(RTC_TAMPER2_SUPPORT)
3413 /**
3414 * @brief Clear RTC_TAMP2 detection flag
3415 * @rmtoll ISR TAMP2F LL_RTC_ClearFlag_TAMP2
3416 * @param RTCx RTC Instance
3417 * @retval None
3418 */
LL_RTC_ClearFlag_TAMP2(RTC_TypeDef * RTCx)3419 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP2(RTC_TypeDef *RTCx)
3420 {
3421 WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP2F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
3422 }
3423 #endif /* RTC_TAMPER2_SUPPORT */
3424
3425 #if defined(RTC_TAMPER1_SUPPORT)
3426 /**
3427 * @brief Clear RTC_TAMP1 detection flag
3428 * @rmtoll ISR TAMP1F LL_RTC_ClearFlag_TAMP1
3429 * @param RTCx RTC Instance
3430 * @retval None
3431 */
LL_RTC_ClearFlag_TAMP1(RTC_TypeDef * RTCx)3432 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP1(RTC_TypeDef *RTCx)
3433 {
3434 WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP1F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
3435 }
3436 #endif /* RTC_TAMPER1_SUPPORT */
3437
3438 /**
3439 * @brief Clear Time-stamp overflow flag
3440 * @rmtoll ISR TSOVF LL_RTC_ClearFlag_TSOV
3441 * @param RTCx RTC Instance
3442 * @retval None
3443 */
LL_RTC_ClearFlag_TSOV(RTC_TypeDef * RTCx)3444 __STATIC_INLINE void LL_RTC_ClearFlag_TSOV(RTC_TypeDef *RTCx)
3445 {
3446 WRITE_REG(RTCx->ISR, (~((RTC_ISR_TSOVF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
3447 }
3448
3449 /**
3450 * @brief Clear Time-stamp flag
3451 * @rmtoll ISR TSF LL_RTC_ClearFlag_TS
3452 * @param RTCx RTC Instance
3453 * @retval None
3454 */
LL_RTC_ClearFlag_TS(RTC_TypeDef * RTCx)3455 __STATIC_INLINE void LL_RTC_ClearFlag_TS(RTC_TypeDef *RTCx)
3456 {
3457 WRITE_REG(RTCx->ISR, (~((RTC_ISR_TSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
3458 }
3459
3460 #if defined(RTC_WAKEUP_SUPPORT)
3461 /**
3462 * @brief Clear Wakeup timer flag
3463 * @rmtoll ISR WUTF LL_RTC_ClearFlag_WUT
3464 * @param RTCx RTC Instance
3465 * @retval None
3466 */
LL_RTC_ClearFlag_WUT(RTC_TypeDef * RTCx)3467 __STATIC_INLINE void LL_RTC_ClearFlag_WUT(RTC_TypeDef *RTCx)
3468 {
3469 WRITE_REG(RTCx->ISR, (~((RTC_ISR_WUTF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
3470 }
3471 #endif /* RTC_WAKEUP_SUPPORT */
3472
3473 /**
3474 * @brief Clear Alarm B flag
3475 * @rmtoll ISR ALRBF LL_RTC_ClearFlag_ALRB
3476 * @param RTCx RTC Instance
3477 * @retval None
3478 */
LL_RTC_ClearFlag_ALRB(RTC_TypeDef * RTCx)3479 __STATIC_INLINE void LL_RTC_ClearFlag_ALRB(RTC_TypeDef *RTCx)
3480 {
3481 WRITE_REG(RTCx->ISR, (~((RTC_ISR_ALRBF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
3482 }
3483
3484 /**
3485 * @brief Clear Alarm A flag
3486 * @rmtoll ISR ALRAF LL_RTC_ClearFlag_ALRA
3487 * @param RTCx RTC Instance
3488 * @retval None
3489 */
LL_RTC_ClearFlag_ALRA(RTC_TypeDef * RTCx)3490 __STATIC_INLINE void LL_RTC_ClearFlag_ALRA(RTC_TypeDef *RTCx)
3491 {
3492 WRITE_REG(RTCx->ISR, (~((RTC_ISR_ALRAF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
3493 }
3494
3495 /**
3496 * @brief Get Initialization flag
3497 * @rmtoll ISR INITF LL_RTC_IsActiveFlag_INIT
3498 * @param RTCx RTC Instance
3499 * @retval State of bit (1 or 0).
3500 */
LL_RTC_IsActiveFlag_INIT(RTC_TypeDef * RTCx)3501 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INIT(RTC_TypeDef *RTCx)
3502 {
3503 return ((READ_BIT(RTCx->ISR, RTC_ISR_INITF) == (RTC_ISR_INITF)) ? 1UL : 0UL);
3504 }
3505
3506 /**
3507 * @brief Get Registers synchronization flag
3508 * @rmtoll ISR RSF LL_RTC_IsActiveFlag_RS
3509 * @param RTCx RTC Instance
3510 * @retval State of bit (1 or 0).
3511 */
LL_RTC_IsActiveFlag_RS(RTC_TypeDef * RTCx)3512 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(RTC_TypeDef *RTCx)
3513 {
3514 return ((READ_BIT(RTCx->ISR, RTC_ISR_RSF) == (RTC_ISR_RSF)) ? 1UL : 0UL);
3515 }
3516
3517 /**
3518 * @brief Clear Registers synchronization flag
3519 * @rmtoll ISR RSF LL_RTC_ClearFlag_RS
3520 * @param RTCx RTC Instance
3521 * @retval None
3522 */
LL_RTC_ClearFlag_RS(RTC_TypeDef * RTCx)3523 __STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx)
3524 {
3525 WRITE_REG(RTCx->ISR, (~((RTC_ISR_RSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
3526 }
3527
3528 /**
3529 * @brief Get Initialization status flag
3530 * @rmtoll ISR INITS LL_RTC_IsActiveFlag_INITS
3531 * @param RTCx RTC Instance
3532 * @retval State of bit (1 or 0).
3533 */
LL_RTC_IsActiveFlag_INITS(RTC_TypeDef * RTCx)3534 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INITS(RTC_TypeDef *RTCx)
3535 {
3536 return ((READ_BIT(RTCx->ISR, RTC_ISR_INITS) == (RTC_ISR_INITS)) ? 1UL : 0UL);
3537 }
3538
3539 /**
3540 * @brief Get Shift operation pending flag
3541 * @rmtoll ISR SHPF LL_RTC_IsActiveFlag_SHP
3542 * @param RTCx RTC Instance
3543 * @retval State of bit (1 or 0).
3544 */
LL_RTC_IsActiveFlag_SHP(RTC_TypeDef * RTCx)3545 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SHP(RTC_TypeDef *RTCx)
3546 {
3547 return ((READ_BIT(RTCx->ISR, RTC_ISR_SHPF) == (RTC_ISR_SHPF)) ? 1UL : 0UL);
3548 }
3549
3550 #if defined(RTC_WAKEUP_SUPPORT)
3551 /**
3552 * @brief Get Wakeup timer write flag
3553 * @rmtoll ISR WUTWF LL_RTC_IsActiveFlag_WUTW
3554 * @param RTCx RTC Instance
3555 * @retval State of bit (1 or 0).
3556 */
LL_RTC_IsActiveFlag_WUTW(RTC_TypeDef * RTCx)3557 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUTW(RTC_TypeDef *RTCx)
3558 {
3559 return ((READ_BIT(RTCx->ISR, RTC_ISR_WUTWF) == (RTC_ISR_WUTWF)) ? 1UL : 0UL);
3560 }
3561 #endif /* RTC_WAKEUP_SUPPORT */
3562
3563 /**
3564 * @brief Get Alarm B write flag
3565 * @rmtoll ISR ALRBWF LL_RTC_IsActiveFlag_ALRBW
3566 * @param RTCx RTC Instance
3567 * @retval State of bit (1 or 0).
3568 */
LL_RTC_IsActiveFlag_ALRBW(RTC_TypeDef * RTCx)3569 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRBW(RTC_TypeDef *RTCx)
3570 {
3571 return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRBWF) == (RTC_ISR_ALRBWF)) ? 1UL : 0UL);
3572 }
3573
3574 /**
3575 * @brief Get Alarm A write flag
3576 * @rmtoll ISR ALRAWF LL_RTC_IsActiveFlag_ALRAW
3577 * @param RTCx RTC Instance
3578 * @retval State of bit (1 or 0).
3579 */
LL_RTC_IsActiveFlag_ALRAW(RTC_TypeDef * RTCx)3580 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRAW(RTC_TypeDef *RTCx)
3581 {
3582 return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRAWF) == (RTC_ISR_ALRAWF)) ? 1UL : 0UL);
3583 }
3584
3585 /**
3586 * @}
3587 */
3588
3589 /** @defgroup RTC_LL_EF_IT_Management IT_Management
3590 * @{
3591 */
3592
3593 /**
3594 * @brief Enable Time-stamp interrupt
3595 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3596 * @rmtoll CR TSIE LL_RTC_EnableIT_TS
3597 * @param RTCx RTC Instance
3598 * @retval None
3599 */
LL_RTC_EnableIT_TS(RTC_TypeDef * RTCx)3600 __STATIC_INLINE void LL_RTC_EnableIT_TS(RTC_TypeDef *RTCx)
3601 {
3602 SET_BIT(RTCx->CR, RTC_CR_TSIE);
3603 }
3604
3605 /**
3606 * @brief Disable Time-stamp interrupt
3607 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3608 * @rmtoll CR TSIE LL_RTC_DisableIT_TS
3609 * @param RTCx RTC Instance
3610 * @retval None
3611 */
LL_RTC_DisableIT_TS(RTC_TypeDef * RTCx)3612 __STATIC_INLINE void LL_RTC_DisableIT_TS(RTC_TypeDef *RTCx)
3613 {
3614 CLEAR_BIT(RTCx->CR, RTC_CR_TSIE);
3615 }
3616
3617 #if defined(RTC_WAKEUP_SUPPORT)
3618 /**
3619 * @brief Enable Wakeup timer interrupt
3620 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3621 * @rmtoll CR WUTIE LL_RTC_EnableIT_WUT
3622 * @param RTCx RTC Instance
3623 * @retval None
3624 */
LL_RTC_EnableIT_WUT(RTC_TypeDef * RTCx)3625 __STATIC_INLINE void LL_RTC_EnableIT_WUT(RTC_TypeDef *RTCx)
3626 {
3627 SET_BIT(RTCx->CR, RTC_CR_WUTIE);
3628 }
3629
3630 /**
3631 * @brief Disable Wakeup timer interrupt
3632 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3633 * @rmtoll CR WUTIE LL_RTC_DisableIT_WUT
3634 * @param RTCx RTC Instance
3635 * @retval None
3636 */
LL_RTC_DisableIT_WUT(RTC_TypeDef * RTCx)3637 __STATIC_INLINE void LL_RTC_DisableIT_WUT(RTC_TypeDef *RTCx)
3638 {
3639 CLEAR_BIT(RTCx->CR, RTC_CR_WUTIE);
3640 }
3641 #endif /* RTC_WAKEUP_SUPPORT */
3642
3643 /**
3644 * @brief Enable Alarm B interrupt
3645 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3646 * @rmtoll CR ALRBIE LL_RTC_EnableIT_ALRB
3647 * @param RTCx RTC Instance
3648 * @retval None
3649 */
LL_RTC_EnableIT_ALRB(RTC_TypeDef * RTCx)3650 __STATIC_INLINE void LL_RTC_EnableIT_ALRB(RTC_TypeDef *RTCx)
3651 {
3652 SET_BIT(RTCx->CR, RTC_CR_ALRBIE);
3653 }
3654
3655 /**
3656 * @brief Disable Alarm B interrupt
3657 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3658 * @rmtoll CR ALRBIE LL_RTC_DisableIT_ALRB
3659 * @param RTCx RTC Instance
3660 * @retval None
3661 */
LL_RTC_DisableIT_ALRB(RTC_TypeDef * RTCx)3662 __STATIC_INLINE void LL_RTC_DisableIT_ALRB(RTC_TypeDef *RTCx)
3663 {
3664 CLEAR_BIT(RTCx->CR, RTC_CR_ALRBIE);
3665 }
3666
3667 /**
3668 * @brief Enable Alarm A interrupt
3669 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3670 * @rmtoll CR ALRAIE LL_RTC_EnableIT_ALRA
3671 * @param RTCx RTC Instance
3672 * @retval None
3673 */
LL_RTC_EnableIT_ALRA(RTC_TypeDef * RTCx)3674 __STATIC_INLINE void LL_RTC_EnableIT_ALRA(RTC_TypeDef *RTCx)
3675 {
3676 SET_BIT(RTCx->CR, RTC_CR_ALRAIE);
3677 }
3678
3679 /**
3680 * @brief Disable Alarm A interrupt
3681 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
3682 * @rmtoll CR ALRAIE LL_RTC_DisableIT_ALRA
3683 * @param RTCx RTC Instance
3684 * @retval None
3685 */
LL_RTC_DisableIT_ALRA(RTC_TypeDef * RTCx)3686 __STATIC_INLINE void LL_RTC_DisableIT_ALRA(RTC_TypeDef *RTCx)
3687 {
3688 CLEAR_BIT(RTCx->CR, RTC_CR_ALRAIE);
3689 }
3690
3691 #if defined(RTC_TAMPER3_SUPPORT)
3692 /**
3693 * @brief Enable Tamper 3 interrupt
3694 * @rmtoll TAMPCR TAMP3IE LL_RTC_EnableIT_TAMP3
3695 * @param RTCx RTC Instance
3696 * @retval None
3697 */
LL_RTC_EnableIT_TAMP3(RTC_TypeDef * RTCx)3698 __STATIC_INLINE void LL_RTC_EnableIT_TAMP3(RTC_TypeDef *RTCx)
3699 {
3700 SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP3IE);
3701 }
3702
3703 /**
3704 * @brief Disable Tamper 3 interrupt
3705 * @rmtoll TAMPCR TAMP3IE LL_RTC_DisableIT_TAMP3
3706 * @param RTCx RTC Instance
3707 * @retval None
3708 */
LL_RTC_DisableIT_TAMP3(RTC_TypeDef * RTCx)3709 __STATIC_INLINE void LL_RTC_DisableIT_TAMP3(RTC_TypeDef *RTCx)
3710 {
3711 CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP3IE);
3712 }
3713 #endif /* RTC_TAMPER3_SUPPORT */
3714
3715 #if defined(RTC_TAMPER2_SUPPORT)
3716 /**
3717 * @brief Enable Tamper 2 interrupt
3718 * @rmtoll TAMPCR TAMP2IE LL_RTC_EnableIT_TAMP2
3719 * @param RTCx RTC Instance
3720 * @retval None
3721 */
LL_RTC_EnableIT_TAMP2(RTC_TypeDef * RTCx)3722 __STATIC_INLINE void LL_RTC_EnableIT_TAMP2(RTC_TypeDef *RTCx)
3723 {
3724 SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP2IE);
3725 }
3726
3727 /**
3728 * @brief Disable Tamper 2 interrupt
3729 * @rmtoll TAMPCR TAMP2IE LL_RTC_DisableIT_TAMP2
3730 * @param RTCx RTC Instance
3731 * @retval None
3732 */
LL_RTC_DisableIT_TAMP2(RTC_TypeDef * RTCx)3733 __STATIC_INLINE void LL_RTC_DisableIT_TAMP2(RTC_TypeDef *RTCx)
3734 {
3735 CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP2IE);
3736 }
3737 #endif /* RTC_TAMPER2_SUPPORT */
3738
3739 #if defined(RTC_TAMPER1_SUPPORT)
3740 /**
3741 * @brief Enable Tamper 1 interrupt
3742 * @rmtoll TAMPCR TAMP1IE LL_RTC_EnableIT_TAMP1
3743 * @param RTCx RTC Instance
3744 * @retval None
3745 */
LL_RTC_EnableIT_TAMP1(RTC_TypeDef * RTCx)3746 __STATIC_INLINE void LL_RTC_EnableIT_TAMP1(RTC_TypeDef *RTCx)
3747 {
3748 SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP1IE);
3749 }
3750
3751 /**
3752 * @brief Disable Tamper 1 interrupt
3753 * @rmtoll TAMPCR TAMP1IE LL_RTC_DisableIT_TAMP1
3754 * @param RTCx RTC Instance
3755 * @retval None
3756 */
LL_RTC_DisableIT_TAMP1(RTC_TypeDef * RTCx)3757 __STATIC_INLINE void LL_RTC_DisableIT_TAMP1(RTC_TypeDef *RTCx)
3758 {
3759 CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP1IE);
3760 }
3761 #endif /* RTC_TAMPER1_SUPPORT */
3762
3763 /**
3764 * @brief Enable all Tamper Interrupt
3765 * @rmtoll TAMPCR TAMPIE LL_RTC_EnableIT_TAMP
3766 * @param RTCx RTC Instance
3767 * @retval None
3768 */
LL_RTC_EnableIT_TAMP(RTC_TypeDef * RTCx)3769 __STATIC_INLINE void LL_RTC_EnableIT_TAMP(RTC_TypeDef *RTCx)
3770 {
3771 SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPIE);
3772 }
3773
3774 /**
3775 * @brief Disable all Tamper Interrupt
3776 * @rmtoll TAMPCR TAMPIE LL_RTC_DisableIT_TAMP
3777 * @param RTCx RTC Instance
3778 * @retval None
3779 */
LL_RTC_DisableIT_TAMP(RTC_TypeDef * RTCx)3780 __STATIC_INLINE void LL_RTC_DisableIT_TAMP(RTC_TypeDef *RTCx)
3781 {
3782 CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPIE);
3783 }
3784
3785 /**
3786 * @brief Check if Time-stamp interrupt is enabled or not
3787 * @rmtoll CR TSIE LL_RTC_IsEnabledIT_TS
3788 * @param RTCx RTC Instance
3789 * @retval State of bit (1 or 0).
3790 */
LL_RTC_IsEnabledIT_TS(RTC_TypeDef * RTCx)3791 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TS(RTC_TypeDef *RTCx)
3792 {
3793 return ((READ_BIT(RTCx->CR, RTC_CR_TSIE) == (RTC_CR_TSIE)) ? 1UL : 0UL);
3794 }
3795
3796 #if defined(RTC_WAKEUP_SUPPORT)
3797 /**
3798 * @brief Check if Wakeup timer interrupt is enabled or not
3799 * @rmtoll CR WUTIE LL_RTC_IsEnabledIT_WUT
3800 * @param RTCx RTC Instance
3801 * @retval State of bit (1 or 0).
3802 */
LL_RTC_IsEnabledIT_WUT(RTC_TypeDef * RTCx)3803 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_WUT(RTC_TypeDef *RTCx)
3804 {
3805 return ((READ_BIT(RTCx->CR, RTC_CR_WUTIE) == (RTC_CR_WUTIE)) ? 1UL : 0UL);
3806 }
3807 #endif /* RTC_WAKEUP_SUPPORT */
3808
3809 /**
3810 * @brief Check if Alarm B interrupt is enabled or not
3811 * @rmtoll CR ALRBIE LL_RTC_IsEnabledIT_ALRB
3812 * @param RTCx RTC Instance
3813 * @retval State of bit (1 or 0).
3814 */
LL_RTC_IsEnabledIT_ALRB(RTC_TypeDef * RTCx)3815 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRB(RTC_TypeDef *RTCx)
3816 {
3817 return ((READ_BIT(RTCx->CR, RTC_CR_ALRBIE) == (RTC_CR_ALRBIE)) ? 1UL : 0UL);
3818 }
3819
3820 /**
3821 * @brief Check if Alarm A interrupt is enabled or not
3822 * @rmtoll CR ALRAIE LL_RTC_IsEnabledIT_ALRA
3823 * @param RTCx RTC Instance
3824 * @retval State of bit (1 or 0).
3825 */
LL_RTC_IsEnabledIT_ALRA(RTC_TypeDef * RTCx)3826 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRA(RTC_TypeDef *RTCx)
3827 {
3828 return ((READ_BIT(RTCx->CR, RTC_CR_ALRAIE) == (RTC_CR_ALRAIE)) ? 1UL : 0UL);
3829 }
3830
3831 #if defined(RTC_TAMPER3_SUPPORT)
3832 /**
3833 * @brief Check if Tamper 3 interrupt is enabled or not
3834 * @rmtoll TAMPCR TAMP3IE LL_RTC_IsEnabledIT_TAMP3
3835 * @param RTCx RTC Instance
3836 * @retval State of bit (1 or 0).
3837 */
LL_RTC_IsEnabledIT_TAMP3(RTC_TypeDef * RTCx)3838 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP3(RTC_TypeDef *RTCx)
3839 {
3840 return ((READ_BIT(RTCx->TAMPCR,
3841 RTC_TAMPCR_TAMP3IE) == (RTC_TAMPCR_TAMP3IE)) ? 1UL : 0UL);
3842 }
3843 #endif /* RTC_TAMPER3_SUPPORT */
3844
3845 #if defined(RTC_TAMPER2_SUPPORT)
3846 /**
3847 * @brief Check if Tamper 2 interrupt is enabled or not
3848 * @rmtoll TAMPCR TAMP2IE LL_RTC_IsEnabledIT_TAMP2
3849 * @param RTCx RTC Instance
3850 * @retval State of bit (1 or 0).
3851 */
LL_RTC_IsEnabledIT_TAMP2(RTC_TypeDef * RTCx)3852 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP2(RTC_TypeDef *RTCx)
3853 {
3854 return ((READ_BIT(RTCx->TAMPCR,
3855 RTC_TAMPCR_TAMP2IE) == (RTC_TAMPCR_TAMP2IE)) ? 1UL : 0UL);
3856
3857 }
3858 #endif /* RTC_TAMPER2_SUPPORT */
3859
3860 #if defined(RTC_TAMPER1_SUPPORT)
3861 /**
3862 * @brief Check if Tamper 1 interrupt is enabled or not
3863 * @rmtoll TAMPCR TAMP1IE LL_RTC_IsEnabledIT_TAMP1
3864 * @param RTCx RTC Instance
3865 * @retval State of bit (1 or 0).
3866 */
LL_RTC_IsEnabledIT_TAMP1(RTC_TypeDef * RTCx)3867 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP1(RTC_TypeDef *RTCx)
3868 {
3869 return ((READ_BIT(RTCx->TAMPCR,
3870 RTC_TAMPCR_TAMP1IE) == (RTC_TAMPCR_TAMP1IE)) ? 1UL : 0UL);
3871 }
3872 #endif /* RTC_TAMPER1_SUPPORT */
3873
3874 /**
3875 * @brief Check if all the TAMPER interrupts are enabled or not
3876 * @rmtoll TAMPCR TAMPIE LL_RTC_IsEnabledIT_TAMP
3877 * @param RTCx RTC Instance
3878 * @retval State of bit (1 or 0).
3879 */
LL_RTC_IsEnabledIT_TAMP(RTC_TypeDef * RTCx)3880 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP(RTC_TypeDef *RTCx)
3881 {
3882 return ((READ_BIT(RTCx->TAMPCR,
3883 RTC_TAMPCR_TAMPIE) == (RTC_TAMPCR_TAMPIE)) ? 1UL : 0UL);
3884 }
3885
3886 /**
3887 * @}
3888 */
3889
3890 #if defined(USE_FULL_LL_DRIVER)
3891 /** @defgroup RTC_LL_EF_Init Initialization and de-initialization functions
3892 * @{
3893 */
3894
3895 ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx);
3896 ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct);
3897 void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct);
3898 ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct);
3899 void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct);
3900 ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct);
3901 void LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct);
3902 ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
3903 ErrorStatus LL_RTC_ALMB_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
3904 void LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
3905 void LL_RTC_ALMB_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
3906 ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx);
3907 ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx);
3908 ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx);
3909
3910 /**
3911 * @}
3912 */
3913 #endif /* USE_FULL_LL_DRIVER */
3914
3915 /**
3916 * @}
3917 */
3918
3919 /**
3920 * @}
3921 */
3922
3923 #endif /* defined(RTC) */
3924
3925 /**
3926 * @}
3927 */
3928
3929 #ifdef __cplusplus
3930 }
3931 #endif
3932
3933 #endif /* STM32WBxx_LL_RTC_H */
3934