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