1 /**
2 ******************************************************************************
3 * @file stm32f0xx_ll_rtc.h
4 * @author MCD Application Team
5 * @brief Header file of RTC LL module.
6 ******************************************************************************
7 * @attention
8 *
9 * Copyright (c) 2016 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 STM32F0xx_LL_RTC_H
21 #define STM32F0xx_LL_RTC_H
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32f0xx.h"
29
30 /** @addtogroup STM32F0xx_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.
168
169 This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetMask().
170 */
171
172 uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on day or WeekDay.
173 This parameter can be a value of @ref RTC_LL_EC_ALMA_WEEKDAY_SELECTION for ALARM A.
174
175 This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_EnableWeekday() or @ref LL_RTC_ALMA_DisableWeekday().
176 */
177
178 uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Day/WeekDay.
179 If AlarmDateWeekDaySel set to day, this parameter must be a number between Min_Data = 1 and Max_Data = 31.
180
181 This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetDay().
182
183 If AlarmDateWeekDaySel set to Weekday, this parameter can be a value of @ref RTC_LL_EC_WEEKDAY.
184
185 This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetWeekDay().
186 */
187 } LL_RTC_AlarmTypeDef;
188
189 /**
190 * @}
191 */
192 #endif /* USE_FULL_LL_DRIVER */
193
194 /* Exported constants --------------------------------------------------------*/
195 /** @defgroup RTC_LL_Exported_Constants RTC Exported Constants
196 * @{
197 */
198
199 #if defined(USE_FULL_LL_DRIVER)
200 /** @defgroup RTC_LL_EC_FORMAT FORMAT
201 * @{
202 */
203 #define LL_RTC_FORMAT_BIN 0x00000000U /*!< Binary data format */
204 #define LL_RTC_FORMAT_BCD 0x00000001U /*!< BCD data format */
205 /**
206 * @}
207 */
208
209 /** @defgroup RTC_LL_EC_ALMA_WEEKDAY_SELECTION RTC Alarm A Date WeekDay
210 * @{
211 */
212 #define LL_RTC_ALMA_DATEWEEKDAYSEL_DATE 0x00000000U /*!< Alarm A Date is selected */
213 #define LL_RTC_ALMA_DATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL /*!< Alarm A WeekDay is selected */
214 /**
215 * @}
216 */
217
218 #endif /* USE_FULL_LL_DRIVER */
219
220 /** @defgroup RTC_LL_EC_GET_FLAG Get Flags Defines
221 * @brief Flags defines which can be used with LL_RTC_ReadReg function
222 * @{
223 */
224 #define LL_RTC_ISR_RECALPF RTC_ISR_RECALPF
225 #if defined(RTC_TAMPER3_SUPPORT)
226 #define LL_RTC_ISR_TAMP3F RTC_ISR_TAMP3F
227 #endif /* RTC_TAMPER3_SUPPORT */
228 #define LL_RTC_ISR_TAMP2F RTC_ISR_TAMP2F
229 #define LL_RTC_ISR_TAMP1F RTC_ISR_TAMP1F
230 #define LL_RTC_ISR_TSOVF RTC_ISR_TSOVF
231 #define LL_RTC_ISR_TSF RTC_ISR_TSF
232 #define LL_RTC_ISR_WUTF RTC_ISR_WUTF
233 #define LL_RTC_ISR_ALRAF RTC_ISR_ALRAF
234 #define LL_RTC_ISR_INITF RTC_ISR_INITF
235 #define LL_RTC_ISR_RSF RTC_ISR_RSF
236 #define LL_RTC_ISR_INITS RTC_ISR_INITS
237 #define LL_RTC_ISR_SHPF RTC_ISR_SHPF
238 #define LL_RTC_ISR_WUTWF RTC_ISR_WUTWF
239 #define LL_RTC_ISR_ALRAWF RTC_ISR_ALRAWF
240 /**
241 * @}
242 */
243
244 /** @defgroup RTC_LL_EC_IT IT Defines
245 * @brief IT defines which can be used with LL_RTC_ReadReg and LL_RTC_WriteReg functions
246 * @{
247 */
248 #define LL_RTC_CR_TSIE RTC_CR_TSIE
249 #define LL_RTC_CR_WUTIE RTC_CR_WUTIE
250 #define LL_RTC_CR_ALRAIE RTC_CR_ALRAIE
251 #define LL_RTC_TAFCR_TAMPIE RTC_TAFCR_TAMPIE
252 /**
253 * @}
254 */
255
256 /** @defgroup RTC_LL_EC_WEEKDAY WEEK DAY
257 * @{
258 */
259 #define LL_RTC_WEEKDAY_MONDAY ((uint8_t)0x01U) /*!< Monday */
260 #define LL_RTC_WEEKDAY_TUESDAY ((uint8_t)0x02U) /*!< Tuesday */
261 #define LL_RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03U) /*!< Wednesday */
262 #define LL_RTC_WEEKDAY_THURSDAY ((uint8_t)0x04U) /*!< Thrusday */
263 #define LL_RTC_WEEKDAY_FRIDAY ((uint8_t)0x05U) /*!< Friday */
264 #define LL_RTC_WEEKDAY_SATURDAY ((uint8_t)0x06U) /*!< Saturday */
265 #define LL_RTC_WEEKDAY_SUNDAY ((uint8_t)0x07U) /*!< Sunday */
266 /**
267 * @}
268 */
269
270 /** @defgroup RTC_LL_EC_MONTH MONTH
271 * @{
272 */
273 #define LL_RTC_MONTH_JANUARY ((uint8_t)0x01U) /*!< January */
274 #define LL_RTC_MONTH_FEBRUARY ((uint8_t)0x02U) /*!< February */
275 #define LL_RTC_MONTH_MARCH ((uint8_t)0x03U) /*!< March */
276 #define LL_RTC_MONTH_APRIL ((uint8_t)0x04U) /*!< April */
277 #define LL_RTC_MONTH_MAY ((uint8_t)0x05U) /*!< May */
278 #define LL_RTC_MONTH_JUNE ((uint8_t)0x06U) /*!< June */
279 #define LL_RTC_MONTH_JULY ((uint8_t)0x07U) /*!< July */
280 #define LL_RTC_MONTH_AUGUST ((uint8_t)0x08U) /*!< August */
281 #define LL_RTC_MONTH_SEPTEMBER ((uint8_t)0x09U) /*!< September */
282 #define LL_RTC_MONTH_OCTOBER ((uint8_t)0x10U) /*!< October */
283 #define LL_RTC_MONTH_NOVEMBER ((uint8_t)0x11U) /*!< November */
284 #define LL_RTC_MONTH_DECEMBER ((uint8_t)0x12U) /*!< December */
285 /**
286 * @}
287 */
288
289 /** @defgroup RTC_LL_EC_HOURFORMAT HOUR FORMAT
290 * @{
291 */
292 #define LL_RTC_HOURFORMAT_24HOUR 0x00000000U /*!< 24 hour/day format */
293 #define LL_RTC_HOURFORMAT_AMPM RTC_CR_FMT /*!< AM/PM hour format */
294 /**
295 * @}
296 */
297
298 /** @defgroup RTC_LL_EC_ALARMOUT ALARM OUTPUT
299 * @{
300 */
301 #define LL_RTC_ALARMOUT_DISABLE 0x00000000U /*!< Output disabled */
302 #define LL_RTC_ALARMOUT_ALMA RTC_CR_OSEL_0 /*!< Alarm A output enabled */
303 #define LL_RTC_ALARMOUT_ALMB RTC_CR_OSEL_1 /*!< Alarm B output enabled */
304 #define LL_RTC_ALARMOUT_WAKEUP RTC_CR_OSEL /*!< Wakeup output enabled */
305 /**
306 * @}
307 */
308
309 /** @defgroup RTC_LL_EC_ALARM_OUTPUTTYPE ALARM OUTPUT TYPE
310 * @{
311 */
312 #define LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN 0x00000000U /*!< RTC_ALARM, when mapped on PC13, is open-drain output */
313 #define LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL RTC_TAFCR_ALARMOUTTYPE /*!< RTC_ALARM, when mapped on PC13, is push-pull output */
314 /**
315 * @}
316 */
317
318 /** @defgroup RTC_LL_EC_PIN PIN
319 * @{
320 */
321 #define LL_RTC_PIN_PC13 RTC_TAFCR_PC13MODE /*!< PC13 is forced to push-pull output if all RTC alternate functions are disabled */
322 #define LL_RTC_PIN_PC14 RTC_TAFCR_PC14MODE /*!< PC14 is forced to push-pull output if LSE is disabled */
323 #define LL_RTC_PIN_PC15 RTC_TAFCR_PC15MODE /*!< PC15 is forced to push-pull output if LSE is disabled */
324 /**
325 * @}
326 */
327
328 /** @defgroup RTC_LL_EC_OUTPUTPOLARITY_PIN OUTPUT POLARITY PIN
329 * @{
330 */
331 #define LL_RTC_OUTPUTPOLARITY_PIN_HIGH 0x00000000U /*!< Pin is high when ALRAF/ALRBF/WUTF is asserted (depending on OSEL)*/
332 #define LL_RTC_OUTPUTPOLARITY_PIN_LOW RTC_CR_POL /*!< Pin is low when ALRAF/ALRBF/WUTF is asserted (depending on OSEL) */
333 /**
334 * @}
335 */
336
337 /** @defgroup RTC_LL_EC_TIME_FORMAT TIME FORMAT
338 * @{
339 */
340 #define LL_RTC_TIME_FORMAT_AM_OR_24 0x00000000U /*!< AM or 24-hour format */
341 #define LL_RTC_TIME_FORMAT_PM RTC_TR_PM /*!< PM */
342 /**
343 * @}
344 */
345
346 /** @defgroup RTC_LL_EC_SHIFT_SECOND SHIFT SECOND
347 * @{
348 */
349 #define LL_RTC_SHIFT_SECOND_DELAY 0x00000000U /* Delay (seconds) = SUBFS / (PREDIV_S + 1) */
350 #define LL_RTC_SHIFT_SECOND_ADVANCE RTC_SHIFTR_ADD1S /* Advance (seconds) = (1 - (SUBFS / (PREDIV_S + 1))) */
351 /**
352 * @}
353 */
354
355 /** @defgroup RTC_LL_EC_ALMA_MASK ALARMA MASK
356 * @{
357 */
358 #define LL_RTC_ALMA_MASK_NONE 0x00000000U /*!< No masks applied on Alarm A*/
359 #define LL_RTC_ALMA_MASK_DATEWEEKDAY RTC_ALRMAR_MSK4 /*!< Date/day do not care in Alarm A comparison */
360 #define LL_RTC_ALMA_MASK_HOURS RTC_ALRMAR_MSK3 /*!< Hours do not care in Alarm A comparison */
361 #define LL_RTC_ALMA_MASK_MINUTES RTC_ALRMAR_MSK2 /*!< Minutes do not care in Alarm A comparison */
362 #define LL_RTC_ALMA_MASK_SECONDS RTC_ALRMAR_MSK1 /*!< Seconds do not care in Alarm A comparison */
363 #define LL_RTC_ALMA_MASK_ALL (RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1) /*!< Masks all */
364 /**
365 * @}
366 */
367
368 /** @defgroup RTC_LL_EC_ALMA_TIME_FORMAT ALARMA TIME FORMAT
369 * @{
370 */
371 #define LL_RTC_ALMA_TIME_FORMAT_AM 0x00000000U /*!< AM or 24-hour format */
372 #define LL_RTC_ALMA_TIME_FORMAT_PM RTC_ALRMAR_PM /*!< PM */
373 /**
374 * @}
375 */
376
377 /** @defgroup RTC_LL_EC_TIMESTAMP_EDGE TIMESTAMP EDGE
378 * @{
379 */
380 #define LL_RTC_TIMESTAMP_EDGE_RISING 0x00000000U /*!< RTC_TS input rising edge generates a time-stamp event */
381 #define LL_RTC_TIMESTAMP_EDGE_FALLING RTC_CR_TSEDGE /*!< RTC_TS input falling edge generates a time-stamp even */
382 /**
383 * @}
384 */
385
386 /** @defgroup RTC_LL_EC_TS_TIME_FORMAT TIMESTAMP TIME FORMAT
387 * @{
388 */
389 #define LL_RTC_TS_TIME_FORMAT_AM 0x00000000U /*!< AM or 24-hour format */
390 #define LL_RTC_TS_TIME_FORMAT_PM RTC_TSTR_PM /*!< PM */
391 /**
392 * @}
393 */
394
395 /** @defgroup RTC_LL_EC_TAMPER TAMPER
396 * @{
397 */
398 #define LL_RTC_TAMPER_1 RTC_TAFCR_TAMP1E /*!< RTC_TAMP1 input detection */
399 #define LL_RTC_TAMPER_2 RTC_TAFCR_TAMP2E /*!< RTC_TAMP2 input detection */
400 #if defined(RTC_TAMPER3_SUPPORT)
401 #define LL_RTC_TAMPER_3 RTC_TAFCR_TAMP3E /*!< RTC_TAMP3 input detection */
402 #endif /* RTC_TAMPER3_SUPPORT */
403 /**
404 * @}
405 */
406
407 /** @defgroup RTC_LL_EC_TAMPER_DURATION TAMPER DURATION
408 * @{
409 */
410 #define LL_RTC_TAMPER_DURATION_1RTCCLK 0x00000000U /*!< Tamper pins are pre-charged before sampling during 1 RTCCLK cycle */
411 #define LL_RTC_TAMPER_DURATION_2RTCCLK RTC_TAFCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before sampling during 2 RTCCLK cycles */
412 #define LL_RTC_TAMPER_DURATION_4RTCCLK RTC_TAFCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before sampling during 4 RTCCLK cycles */
413 #define LL_RTC_TAMPER_DURATION_8RTCCLK RTC_TAFCR_TAMPPRCH /*!< Tamper pins are pre-charged before sampling during 8 RTCCLK cycles */
414 /**
415 * @}
416 */
417
418 /** @defgroup RTC_LL_EC_TAMPER_FILTER TAMPER FILTER
419 * @{
420 */
421 #define LL_RTC_TAMPER_FILTER_DISABLE 0x00000000U /*!< Tamper filter is disabled */
422 #define LL_RTC_TAMPER_FILTER_2SAMPLE RTC_TAFCR_TAMPFLT_0 /*!< Tamper is activated after 2 consecutive samples at the active level */
423 #define LL_RTC_TAMPER_FILTER_4SAMPLE RTC_TAFCR_TAMPFLT_1 /*!< Tamper is activated after 4 consecutive samples at the active level */
424 #define LL_RTC_TAMPER_FILTER_8SAMPLE RTC_TAFCR_TAMPFLT /*!< Tamper is activated after 8 consecutive samples at the active level. */
425 /**
426 * @}
427 */
428
429 /** @defgroup RTC_LL_EC_TAMPER_SAMPLFREQDIV TAMPER SAMPLING FREQUENCY DIVIDER
430 * @{
431 */
432 #define LL_RTC_TAMPER_SAMPLFREQDIV_32768 0x00000000U /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 32768 */
433 #define LL_RTC_TAMPER_SAMPLFREQDIV_16384 RTC_TAFCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 16384 */
434 #define LL_RTC_TAMPER_SAMPLFREQDIV_8192 RTC_TAFCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 8192 */
435 #define LL_RTC_TAMPER_SAMPLFREQDIV_4096 (RTC_TAFCR_TAMPFREQ_1 | RTC_TAFCR_TAMPFREQ_0) /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 4096 */
436 #define LL_RTC_TAMPER_SAMPLFREQDIV_2048 RTC_TAFCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 2048 */
437 #define LL_RTC_TAMPER_SAMPLFREQDIV_1024 (RTC_TAFCR_TAMPFREQ_2 | RTC_TAFCR_TAMPFREQ_0) /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 1024 */
438 #define LL_RTC_TAMPER_SAMPLFREQDIV_512 (RTC_TAFCR_TAMPFREQ_2 | RTC_TAFCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 512 */
439 #define LL_RTC_TAMPER_SAMPLFREQDIV_256 RTC_TAFCR_TAMPFREQ /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 256 */
440 /**
441 * @}
442 */
443
444 /** @defgroup RTC_LL_EC_TAMPER_ACTIVELEVEL TAMPER ACTIVE LEVEL
445 * @{
446 */
447 #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP1 RTC_TAFCR_TAMP1TRG /*!< RTC_TAMP1 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
448 #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP2 RTC_TAFCR_TAMP2TRG /*!< RTC_TAMP2 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
449 #if defined(RTC_TAMPER3_SUPPORT)
450 #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP3 RTC_TAFCR_TAMP3TRG /*!< RTC_TAMP3 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
451 #endif /* RTC_TAMPER3_SUPPORT */
452 /**
453 * @}
454 */
455
456 #if defined(RTC_WAKEUP_SUPPORT)
457 /** @defgroup RTC_LL_EC_WAKEUPCLOCK_DIV WAKEUP CLOCK DIV
458 * @{
459 */
460 #define LL_RTC_WAKEUPCLOCK_DIV_16 0x00000000U /*!< RTC/16 clock is selected */
461 #define LL_RTC_WAKEUPCLOCK_DIV_8 (RTC_CR_WUCKSEL_0) /*!< RTC/8 clock is selected */
462 #define LL_RTC_WAKEUPCLOCK_DIV_4 (RTC_CR_WUCKSEL_1) /*!< RTC/4 clock is selected */
463 #define LL_RTC_WAKEUPCLOCK_DIV_2 (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_0) /*!< RTC/2 clock is selected */
464 #define LL_RTC_WAKEUPCLOCK_CKSPRE (RTC_CR_WUCKSEL_2) /*!< ck_spre (usually 1 Hz) clock is selected */
465 #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*/
466 /**
467 * @}
468 */
469 #endif /* RTC_WAKEUP_SUPPORT */
470
471 #if defined(RTC_BACKUP_SUPPORT)
472 /** @defgroup RTC_LL_EC_BKP BACKUP
473 * @{
474 */
475 #define LL_RTC_BKP_DR0 0x00000000U
476 #define LL_RTC_BKP_DR1 0x00000001U
477 #define LL_RTC_BKP_DR2 0x00000002U
478 #define LL_RTC_BKP_DR3 0x00000003U
479 #define LL_RTC_BKP_DR4 0x00000004U
480 /**
481 * @}
482 */
483 #endif /* RTC_BACKUP_SUPPORT */
484
485 /** @defgroup RTC_LL_EC_CALIB_OUTPUT Calibration output
486 * @{
487 */
488 #define LL_RTC_CALIB_OUTPUT_NONE 0x00000000U /*!< Calibration output disabled */
489 #define LL_RTC_CALIB_OUTPUT_1HZ (RTC_CR_COE | RTC_CR_COSEL) /*!< Calibration output is 1 Hz */
490 #define LL_RTC_CALIB_OUTPUT_512HZ (RTC_CR_COE) /*!< Calibration output is 512 Hz */
491 /**
492 * @}
493 */
494
495 /** @defgroup RTC_LL_EC_CALIB_INSERTPULSE Calibration pulse insertion
496 * @{
497 */
498 #define LL_RTC_CALIB_INSERTPULSE_NONE 0x00000000U /*!< No RTCCLK pulses are added */
499 #define LL_RTC_CALIB_INSERTPULSE_SET RTC_CALR_CALP /*!< One RTCCLK pulse is effectively inserted every 2exp11 pulses (frequency increased by 488.5 ppm) */
500 /**
501 * @}
502 */
503
504 /** @defgroup RTC_LL_EC_CALIB_PERIOD Calibration period
505 * @{
506 */
507 #define LL_RTC_CALIB_PERIOD_32SEC 0x00000000U /*!< Use a 32-second calibration cycle period */
508 #define LL_RTC_CALIB_PERIOD_16SEC RTC_CALR_CALW16 /*!< Use a 16-second calibration cycle period */
509 #define LL_RTC_CALIB_PERIOD_8SEC RTC_CALR_CALW8 /*!< Use a 8-second calibration cycle period */
510 /**
511 * @}
512 */
513
514 /**
515 * @}
516 */
517
518 /* Exported macro ------------------------------------------------------------*/
519 /** @defgroup RTC_LL_Exported_Macros RTC Exported Macros
520 * @{
521 */
522
523 /** @defgroup RTC_LL_EM_WRITE_READ Common Write and read registers Macros
524 * @{
525 */
526
527 /**
528 * @brief Write a value in RTC register
529 * @param __INSTANCE__ RTC Instance
530 * @param __REG__ Register to be written
531 * @param __VALUE__ Value to be written in the register
532 * @retval None
533 */
534 #define LL_RTC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
535
536 /**
537 * @brief Read a value in RTC register
538 * @param __INSTANCE__ RTC Instance
539 * @param __REG__ Register to be read
540 * @retval Register value
541 */
542 #define LL_RTC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
543 /**
544 * @}
545 */
546
547 /** @defgroup RTC_LL_EM_Convert Convert helper Macros
548 * @{
549 */
550
551 /**
552 * @brief Helper macro to convert a value from 2 digit decimal format to BCD format
553 * @param __VALUE__ Byte to be converted
554 * @retval Converted byte
555 */
556 #define __LL_RTC_CONVERT_BIN2BCD(__VALUE__) (uint8_t)((((__VALUE__) / 10U) << 4U) | ((__VALUE__) % 10U))
557
558 /**
559 * @brief Helper macro to convert a value from BCD format to 2 digit decimal format
560 * @param __VALUE__ BCD value to be converted
561 * @retval Converted byte
562 */
563 #define __LL_RTC_CONVERT_BCD2BIN(__VALUE__) (uint8_t)(((uint8_t)((__VALUE__) & (uint8_t)0xF0U) >> (uint8_t)0x4U) * 10U + ((__VALUE__) & (uint8_t)0x0FU))
564
565 /**
566 * @}
567 */
568
569 /** @defgroup RTC_LL_EM_Date Date helper Macros
570 * @{
571 */
572
573 /**
574 * @brief Helper macro to retrieve weekday.
575 * @param __RTC_DATE__ Date returned by @ref LL_RTC_DATE_Get function.
576 * @retval Returned value can be one of the following values:
577 * @arg @ref LL_RTC_WEEKDAY_MONDAY
578 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
579 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
580 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
581 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
582 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
583 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
584 */
585 #define __LL_RTC_GET_WEEKDAY(__RTC_DATE__) (((__RTC_DATE__) >> RTC_OFFSET_WEEKDAY) & 0x000000FFU)
586
587 /**
588 * @brief Helper macro to retrieve Year in BCD format
589 * @param __RTC_DATE__ Value returned by @ref LL_RTC_DATE_Get
590 * @retval Year in BCD format (0x00 . . . 0x99)
591 */
592 #define __LL_RTC_GET_YEAR(__RTC_DATE__) ((__RTC_DATE__) & 0x000000FFU)
593
594 /**
595 * @brief Helper macro to retrieve Month in BCD format
596 * @param __RTC_DATE__ Value returned by @ref LL_RTC_DATE_Get
597 * @retval Returned value can be one of the following values:
598 * @arg @ref LL_RTC_MONTH_JANUARY
599 * @arg @ref LL_RTC_MONTH_FEBRUARY
600 * @arg @ref LL_RTC_MONTH_MARCH
601 * @arg @ref LL_RTC_MONTH_APRIL
602 * @arg @ref LL_RTC_MONTH_MAY
603 * @arg @ref LL_RTC_MONTH_JUNE
604 * @arg @ref LL_RTC_MONTH_JULY
605 * @arg @ref LL_RTC_MONTH_AUGUST
606 * @arg @ref LL_RTC_MONTH_SEPTEMBER
607 * @arg @ref LL_RTC_MONTH_OCTOBER
608 * @arg @ref LL_RTC_MONTH_NOVEMBER
609 * @arg @ref LL_RTC_MONTH_DECEMBER
610 */
611 #define __LL_RTC_GET_MONTH(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_MONTH) & 0x000000FFU)
612
613 /**
614 * @brief Helper macro to retrieve Day in BCD format
615 * @param __RTC_DATE__ Value returned by @ref LL_RTC_DATE_Get
616 * @retval Day in BCD format (0x01 . . . 0x31)
617 */
618 #define __LL_RTC_GET_DAY(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_DAY) & 0x000000FFU)
619
620 /**
621 * @}
622 */
623
624 /** @defgroup RTC_LL_EM_Time Time helper Macros
625 * @{
626 */
627
628 /**
629 * @brief Helper macro to retrieve hour in BCD format
630 * @param __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
631 * @retval Hours in BCD format (0x01. . .0x12 or between Min_Data=0x00 and Max_Data=0x23)
632 */
633 #define __LL_RTC_GET_HOUR(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_HOUR) & 0x000000FFU)
634
635 /**
636 * @brief Helper macro to retrieve minute in BCD format
637 * @param __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
638 * @retval Minutes in BCD format (0x00. . .0x59)
639 */
640 #define __LL_RTC_GET_MINUTE(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_MINUTE) & 0x000000FFU)
641
642 /**
643 * @brief Helper macro to retrieve second in BCD format
644 * @param __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
645 * @retval Seconds in format (0x00. . .0x59)
646 */
647 #define __LL_RTC_GET_SECOND(__RTC_TIME__) ((__RTC_TIME__) & 0x000000FFU)
648
649 /**
650 * @}
651 */
652
653 /**
654 * @}
655 */
656
657 /* Exported functions --------------------------------------------------------*/
658 /** @defgroup RTC_LL_Exported_Functions RTC Exported Functions
659 * @{
660 */
661
662 /** @defgroup RTC_LL_EF_Configuration Configuration
663 * @{
664 */
665
666 /**
667 * @brief Set Hours format (24 hour/day or AM/PM hour format)
668 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
669 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
670 * @rmtoll CR FMT LL_RTC_SetHourFormat
671 * @param RTCx RTC Instance
672 * @param HourFormat This parameter can be one of the following values:
673 * @arg @ref LL_RTC_HOURFORMAT_24HOUR
674 * @arg @ref LL_RTC_HOURFORMAT_AMPM
675 * @retval None
676 */
LL_RTC_SetHourFormat(RTC_TypeDef * RTCx,uint32_t HourFormat)677 __STATIC_INLINE void LL_RTC_SetHourFormat(RTC_TypeDef *RTCx, uint32_t HourFormat)
678 {
679 MODIFY_REG(RTCx->CR, RTC_CR_FMT, HourFormat);
680 }
681
682 /**
683 * @brief Get Hours format (24 hour/day or AM/PM hour format)
684 * @rmtoll CR FMT LL_RTC_GetHourFormat
685 * @param RTCx RTC Instance
686 * @retval Returned value can be one of the following values:
687 * @arg @ref LL_RTC_HOURFORMAT_24HOUR
688 * @arg @ref LL_RTC_HOURFORMAT_AMPM
689 */
LL_RTC_GetHourFormat(RTC_TypeDef * RTCx)690 __STATIC_INLINE uint32_t LL_RTC_GetHourFormat(RTC_TypeDef *RTCx)
691 {
692 return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_FMT));
693 }
694
695 /**
696 * @brief Select the flag to be routed to RTC_ALARM output
697 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
698 * @rmtoll CR OSEL LL_RTC_SetAlarmOutEvent
699 * @param RTCx RTC Instance
700 * @param AlarmOutput This parameter can be one of the following values:
701 * @arg @ref LL_RTC_ALARMOUT_DISABLE
702 * @arg @ref LL_RTC_ALARMOUT_ALMA
703 * @arg @ref LL_RTC_ALARMOUT_ALMB
704 * @arg @ref LL_RTC_ALARMOUT_WAKEUP
705 * @retval None
706 */
LL_RTC_SetAlarmOutEvent(RTC_TypeDef * RTCx,uint32_t AlarmOutput)707 __STATIC_INLINE void LL_RTC_SetAlarmOutEvent(RTC_TypeDef *RTCx, uint32_t AlarmOutput)
708 {
709 MODIFY_REG(RTCx->CR, RTC_CR_OSEL, AlarmOutput);
710 }
711
712 /**
713 * @brief Get the flag to be routed to RTC_ALARM output
714 * @rmtoll CR OSEL LL_RTC_GetAlarmOutEvent
715 * @param RTCx RTC Instance
716 * @retval Returned value can be one of the following values:
717 * @arg @ref LL_RTC_ALARMOUT_DISABLE
718 * @arg @ref LL_RTC_ALARMOUT_ALMA
719 * @arg @ref LL_RTC_ALARMOUT_ALMB
720 * @arg @ref LL_RTC_ALARMOUT_WAKEUP
721 */
LL_RTC_GetAlarmOutEvent(RTC_TypeDef * RTCx)722 __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutEvent(RTC_TypeDef *RTCx)
723 {
724 return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_OSEL));
725 }
726
727 /**
728 * @brief Set RTC_ALARM output type (ALARM in push-pull or open-drain output)
729 * @note Used only when RTC_ALARM is mapped on PC13
730 * @note If all RTC alternate functions are disabled and PC13MODE = 1, PC13VALUE configures the
731 * PC13 output data
732 * @rmtoll TAFCR ALARMOUTTYPE LL_RTC_SetAlarmOutputType
733 * @param RTCx RTC Instance
734 * @param Output This parameter can be one of the following values:
735 * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
736 * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
737 * @retval None
738 */
LL_RTC_SetAlarmOutputType(RTC_TypeDef * RTCx,uint32_t Output)739 __STATIC_INLINE void LL_RTC_SetAlarmOutputType(RTC_TypeDef *RTCx, uint32_t Output)
740 {
741 MODIFY_REG(RTCx->TAFCR, RTC_TAFCR_ALARMOUTTYPE, Output);
742 }
743
744 /**
745 * @brief Get RTC_ALARM output type (ALARM in push-pull or open-drain output)
746 * @note used only when RTC_ALARM is mapped on PC13
747 * @note If all RTC alternate functions are disabled and PC13MODE = 1, PC13VALUE configures the
748 * PC13 output data
749 * @rmtoll TAFCR ALARMOUTTYPE LL_RTC_GetAlarmOutputType
750 * @param RTCx RTC Instance
751 * @retval Returned value can be one of the following values:
752 * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
753 * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
754 */
LL_RTC_GetAlarmOutputType(RTC_TypeDef * RTCx)755 __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutputType(RTC_TypeDef *RTCx)
756 {
757 return (uint32_t)(READ_BIT(RTCx->TAFCR, RTC_TAFCR_ALARMOUTTYPE));
758 }
759
760 /**
761 * @brief Enable push-pull output on PC13, PC14 and/or PC15
762 * @note PC13 forced to push-pull output if all RTC alternate functions are disabled
763 * @note PC14 and PC15 forced to push-pull output if LSE is disabled
764 * @rmtoll TAFCR PC13MODE LL_RTC_EnablePushPullMode\n
765 * TAFCR PC14MODE LL_RTC_EnablePushPullMode\n
766 * TAFCR PC15MODE LL_RTC_EnablePushPullMode
767 * @param RTCx RTC Instance
768 * @param PinMask This parameter can be a combination of the following values:
769 * @arg @ref LL_RTC_PIN_PC13
770 * @arg @ref LL_RTC_PIN_PC14
771 * @arg @ref LL_RTC_PIN_PC15
772 * @retval None
773 */
LL_RTC_EnablePushPullMode(RTC_TypeDef * RTCx,uint32_t PinMask)774 __STATIC_INLINE void LL_RTC_EnablePushPullMode(RTC_TypeDef *RTCx, uint32_t PinMask)
775 {
776 SET_BIT(RTCx->TAFCR, PinMask);
777 }
778
779 /**
780 * @brief Disable push-pull output on PC13, PC14 and/or PC15
781 * @note PC13, PC14 and/or PC15 are controlled by the GPIO configuration registers.
782 * Consequently PC13, PC14 and/or PC15 are floating in Standby mode.
783 * @rmtoll TAFCR PC13MODE LL_RTC_DisablePushPullMode\n
784 * TAFCR PC14MODE LL_RTC_DisablePushPullMode\n
785 * TAFCR PC15MODE LL_RTC_DisablePushPullMode
786 * @param RTCx RTC Instance
787 * @param PinMask This parameter can be a combination of the following values:
788 * @arg @ref LL_RTC_PIN_PC13
789 * @arg @ref LL_RTC_PIN_PC14
790 * @arg @ref LL_RTC_PIN_PC15
791 * @retval None
792 */
LL_RTC_DisablePushPullMode(RTC_TypeDef * RTCx,uint32_t PinMask)793 __STATIC_INLINE void LL_RTC_DisablePushPullMode(RTC_TypeDef *RTCx, uint32_t PinMask)
794 {
795 CLEAR_BIT(RTCx->TAFCR, PinMask);
796 }
797
798 /**
799 * @brief Set PC14 and/or PC15 to high level.
800 * @note Output data configuration is possible if the LSE is disabled and PushPull output is enabled (through @ref LL_RTC_EnablePushPullMode)
801 * @rmtoll TAFCR PC14VALUE LL_RTC_SetOutputPin\n
802 * TAFCR PC15VALUE LL_RTC_SetOutputPin
803 * @param RTCx RTC Instance
804 * @param PinMask This parameter can be a combination of the following values:
805 * @arg @ref LL_RTC_PIN_PC14
806 * @arg @ref LL_RTC_PIN_PC15
807 * @retval None
808 */
LL_RTC_SetOutputPin(RTC_TypeDef * RTCx,uint32_t PinMask)809 __STATIC_INLINE void LL_RTC_SetOutputPin(RTC_TypeDef *RTCx, uint32_t PinMask)
810 {
811 SET_BIT(RTCx->TAFCR, (PinMask >> 1));
812 }
813
814 /**
815 * @brief Set PC14 and/or PC15 to low level.
816 * @note Output data configuration is possible if the LSE is disabled and PushPull output is enabled (through @ref LL_RTC_EnablePushPullMode)
817 * @rmtoll TAFCR PC14VALUE LL_RTC_ResetOutputPin\n
818 * TAFCR PC15VALUE LL_RTC_ResetOutputPin
819 * @param RTCx RTC Instance
820 * @param PinMask This parameter can be a combination of the following values:
821 * @arg @ref LL_RTC_PIN_PC14
822 * @arg @ref LL_RTC_PIN_PC15
823 * @retval None
824 */
LL_RTC_ResetOutputPin(RTC_TypeDef * RTCx,uint32_t PinMask)825 __STATIC_INLINE void LL_RTC_ResetOutputPin(RTC_TypeDef *RTCx, uint32_t PinMask)
826 {
827 CLEAR_BIT(RTCx->TAFCR, (PinMask >> 1));
828 }
829
830 /**
831 * @brief Enable initialization mode
832 * @note Initialization mode is used to program time and date register (RTC_TR and RTC_DR)
833 * and prescaler register (RTC_PRER).
834 * Counters are stopped and start counting from the new value when INIT is reset.
835 * @rmtoll ISR INIT LL_RTC_EnableInitMode
836 * @param RTCx RTC Instance
837 * @retval None
838 */
LL_RTC_EnableInitMode(RTC_TypeDef * RTCx)839 __STATIC_INLINE void LL_RTC_EnableInitMode(RTC_TypeDef *RTCx)
840 {
841 /* Set the Initialization mode */
842 WRITE_REG(RTCx->ISR, RTC_INIT_MASK);
843 }
844
845 /**
846 * @brief Disable initialization mode (Free running mode)
847 * @rmtoll ISR INIT LL_RTC_DisableInitMode
848 * @param RTCx RTC Instance
849 * @retval None
850 */
LL_RTC_DisableInitMode(RTC_TypeDef * RTCx)851 __STATIC_INLINE void LL_RTC_DisableInitMode(RTC_TypeDef *RTCx)
852 {
853 /* Exit Initialization mode */
854 WRITE_REG(RTCx->ISR, (uint32_t)~RTC_ISR_INIT);
855 }
856
857 /**
858 * @brief Set Output polarity (pin is low when ALRAF/ALRBF/WUTF is asserted)
859 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
860 * @rmtoll CR POL LL_RTC_SetOutputPolarity
861 * @param RTCx RTC Instance
862 * @param Polarity This parameter can be one of the following values:
863 * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
864 * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
865 * @retval None
866 */
LL_RTC_SetOutputPolarity(RTC_TypeDef * RTCx,uint32_t Polarity)867 __STATIC_INLINE void LL_RTC_SetOutputPolarity(RTC_TypeDef *RTCx, uint32_t Polarity)
868 {
869 MODIFY_REG(RTCx->CR, RTC_CR_POL, Polarity);
870 }
871
872 /**
873 * @brief Get Output polarity
874 * @rmtoll CR POL LL_RTC_GetOutputPolarity
875 * @param RTCx RTC Instance
876 * @retval Returned value can be one of the following values:
877 * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
878 * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
879 */
LL_RTC_GetOutputPolarity(RTC_TypeDef * RTCx)880 __STATIC_INLINE uint32_t LL_RTC_GetOutputPolarity(RTC_TypeDef *RTCx)
881 {
882 return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_POL));
883 }
884
885 /**
886 * @brief Enable Bypass the shadow registers
887 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
888 * @rmtoll CR BYPSHAD LL_RTC_EnableShadowRegBypass
889 * @param RTCx RTC Instance
890 * @retval None
891 */
LL_RTC_EnableShadowRegBypass(RTC_TypeDef * RTCx)892 __STATIC_INLINE void LL_RTC_EnableShadowRegBypass(RTC_TypeDef *RTCx)
893 {
894 SET_BIT(RTCx->CR, RTC_CR_BYPSHAD);
895 }
896
897 /**
898 * @brief Disable Bypass the shadow registers
899 * @rmtoll CR BYPSHAD LL_RTC_DisableShadowRegBypass
900 * @param RTCx RTC Instance
901 * @retval None
902 */
LL_RTC_DisableShadowRegBypass(RTC_TypeDef * RTCx)903 __STATIC_INLINE void LL_RTC_DisableShadowRegBypass(RTC_TypeDef *RTCx)
904 {
905 CLEAR_BIT(RTCx->CR, RTC_CR_BYPSHAD);
906 }
907
908 /**
909 * @brief Check if Shadow registers bypass is enabled or not.
910 * @rmtoll CR BYPSHAD LL_RTC_IsShadowRegBypassEnabled
911 * @param RTCx RTC Instance
912 * @retval State of bit (1 or 0).
913 */
LL_RTC_IsShadowRegBypassEnabled(RTC_TypeDef * RTCx)914 __STATIC_INLINE uint32_t LL_RTC_IsShadowRegBypassEnabled(RTC_TypeDef *RTCx)
915 {
916 return ((READ_BIT(RTCx->CR, RTC_CR_BYPSHAD) == (RTC_CR_BYPSHAD)) ? 1UL : 0UL);
917 }
918
919 /**
920 * @brief Enable RTC_REFIN reference clock detection (50 or 60 Hz)
921 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
922 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
923 * @rmtoll CR REFCKON LL_RTC_EnableRefClock
924 * @param RTCx RTC Instance
925 * @retval None
926 */
LL_RTC_EnableRefClock(RTC_TypeDef * RTCx)927 __STATIC_INLINE void LL_RTC_EnableRefClock(RTC_TypeDef *RTCx)
928 {
929 SET_BIT(RTCx->CR, RTC_CR_REFCKON);
930 }
931
932 /**
933 * @brief Disable RTC_REFIN reference clock detection (50 or 60 Hz)
934 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
935 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
936 * @rmtoll CR REFCKON LL_RTC_DisableRefClock
937 * @param RTCx RTC Instance
938 * @retval None
939 */
LL_RTC_DisableRefClock(RTC_TypeDef * RTCx)940 __STATIC_INLINE void LL_RTC_DisableRefClock(RTC_TypeDef *RTCx)
941 {
942 CLEAR_BIT(RTCx->CR, RTC_CR_REFCKON);
943 }
944
945 /**
946 * @brief Set Asynchronous prescaler factor
947 * @rmtoll PRER PREDIV_A LL_RTC_SetAsynchPrescaler
948 * @param RTCx RTC Instance
949 * @param AsynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7F
950 * @retval None
951 */
LL_RTC_SetAsynchPrescaler(RTC_TypeDef * RTCx,uint32_t AsynchPrescaler)952 __STATIC_INLINE void LL_RTC_SetAsynchPrescaler(RTC_TypeDef *RTCx, uint32_t AsynchPrescaler)
953 {
954 MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_A, AsynchPrescaler << RTC_PRER_PREDIV_A_Pos);
955 }
956
957 /**
958 * @brief Set Synchronous prescaler factor
959 * @rmtoll PRER PREDIV_S LL_RTC_SetSynchPrescaler
960 * @param RTCx RTC Instance
961 * @param SynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7FFF
962 * @retval None
963 */
LL_RTC_SetSynchPrescaler(RTC_TypeDef * RTCx,uint32_t SynchPrescaler)964 __STATIC_INLINE void LL_RTC_SetSynchPrescaler(RTC_TypeDef *RTCx, uint32_t SynchPrescaler)
965 {
966 MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_S, SynchPrescaler);
967 }
968
969 /**
970 * @brief Get Asynchronous prescaler factor
971 * @rmtoll PRER PREDIV_A LL_RTC_GetAsynchPrescaler
972 * @param RTCx RTC Instance
973 * @retval Value between Min_Data = 0 and Max_Data = 0x7F
974 */
LL_RTC_GetAsynchPrescaler(RTC_TypeDef * RTCx)975 __STATIC_INLINE uint32_t LL_RTC_GetAsynchPrescaler(RTC_TypeDef *RTCx)
976 {
977 return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_A) >> RTC_PRER_PREDIV_A_Pos);
978 }
979
980 /**
981 * @brief Get Synchronous prescaler factor
982 * @rmtoll PRER PREDIV_S LL_RTC_GetSynchPrescaler
983 * @param RTCx RTC Instance
984 * @retval Value between Min_Data = 0 and Max_Data = 0x7FFF
985 */
LL_RTC_GetSynchPrescaler(RTC_TypeDef * RTCx)986 __STATIC_INLINE uint32_t LL_RTC_GetSynchPrescaler(RTC_TypeDef *RTCx)
987 {
988 return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_S));
989 }
990
991 /**
992 * @brief Enable the write protection for RTC registers.
993 * @rmtoll WPR KEY LL_RTC_EnableWriteProtection
994 * @param RTCx RTC Instance
995 * @retval None
996 */
LL_RTC_EnableWriteProtection(RTC_TypeDef * RTCx)997 __STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx)
998 {
999 WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_DISABLE);
1000 }
1001
1002 /**
1003 * @brief Disable the write protection for RTC registers.
1004 * @rmtoll WPR KEY LL_RTC_DisableWriteProtection
1005 * @param RTCx RTC Instance
1006 * @retval None
1007 */
LL_RTC_DisableWriteProtection(RTC_TypeDef * RTCx)1008 __STATIC_INLINE void LL_RTC_DisableWriteProtection(RTC_TypeDef *RTCx)
1009 {
1010 WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_1);
1011 WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_2);
1012 }
1013
1014 /**
1015 * @}
1016 */
1017
1018 /** @defgroup RTC_LL_EF_Time Time
1019 * @{
1020 */
1021
1022 /**
1023 * @brief Set time format (AM/24-hour or PM notation)
1024 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1025 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1026 * @rmtoll TR PM LL_RTC_TIME_SetFormat
1027 * @param RTCx RTC Instance
1028 * @param TimeFormat This parameter can be one of the following values:
1029 * @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
1030 * @arg @ref LL_RTC_TIME_FORMAT_PM
1031 * @retval None
1032 */
LL_RTC_TIME_SetFormat(RTC_TypeDef * RTCx,uint32_t TimeFormat)1033 __STATIC_INLINE void LL_RTC_TIME_SetFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
1034 {
1035 MODIFY_REG(RTCx->TR, RTC_TR_PM, TimeFormat);
1036 }
1037
1038 /**
1039 * @brief Get time format (AM or PM notation)
1040 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1041 * before reading this bit
1042 * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1043 * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1044 * @rmtoll TR PM LL_RTC_TIME_GetFormat
1045 * @param RTCx RTC Instance
1046 * @retval Returned value can be one of the following values:
1047 * @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
1048 * @arg @ref LL_RTC_TIME_FORMAT_PM
1049 */
LL_RTC_TIME_GetFormat(RTC_TypeDef * RTCx)1050 __STATIC_INLINE uint32_t LL_RTC_TIME_GetFormat(RTC_TypeDef *RTCx)
1051 {
1052 return (uint32_t)(READ_BIT(RTCx->TR, RTC_TR_PM));
1053 }
1054
1055 /**
1056 * @brief Set Hours in BCD format
1057 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1058 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1059 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert hour from binary to BCD format
1060 * @rmtoll TR HT LL_RTC_TIME_SetHour\n
1061 * TR HU LL_RTC_TIME_SetHour
1062 * @param RTCx RTC Instance
1063 * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1064 * @retval None
1065 */
LL_RTC_TIME_SetHour(RTC_TypeDef * RTCx,uint32_t Hours)1066 __STATIC_INLINE void LL_RTC_TIME_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
1067 {
1068 MODIFY_REG(RTCx->TR, (RTC_TR_HT | RTC_TR_HU),
1069 (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)));
1070 }
1071
1072 /**
1073 * @brief Get Hours in BCD format
1074 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1075 * before reading this bit
1076 * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1077 * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1078 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert hour from BCD to
1079 * Binary format
1080 * @rmtoll TR HT LL_RTC_TIME_GetHour\n
1081 * TR HU LL_RTC_TIME_GetHour
1082 * @param RTCx RTC Instance
1083 * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1084 */
LL_RTC_TIME_GetHour(RTC_TypeDef * RTCx)1085 __STATIC_INLINE uint32_t LL_RTC_TIME_GetHour(RTC_TypeDef *RTCx)
1086 {
1087 return (uint32_t)((READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU))) >> RTC_TR_HU_Pos);
1088 }
1089
1090 /**
1091 * @brief Set Minutes in BCD format
1092 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1093 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1094 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
1095 * @rmtoll TR MNT LL_RTC_TIME_SetMinute\n
1096 * TR MNU LL_RTC_TIME_SetMinute
1097 * @param RTCx RTC Instance
1098 * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
1099 * @retval None
1100 */
LL_RTC_TIME_SetMinute(RTC_TypeDef * RTCx,uint32_t Minutes)1101 __STATIC_INLINE void LL_RTC_TIME_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
1102 {
1103 MODIFY_REG(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU),
1104 (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)));
1105 }
1106
1107 /**
1108 * @brief Get Minutes in BCD format
1109 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1110 * before reading this bit
1111 * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1112 * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1113 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert minute from BCD
1114 * to Binary format
1115 * @rmtoll TR MNT LL_RTC_TIME_GetMinute\n
1116 * TR MNU LL_RTC_TIME_GetMinute
1117 * @param RTCx RTC Instance
1118 * @retval Value between Min_Data=0x00 and Max_Data=0x59
1119 */
LL_RTC_TIME_GetMinute(RTC_TypeDef * RTCx)1120 __STATIC_INLINE uint32_t LL_RTC_TIME_GetMinute(RTC_TypeDef *RTCx)
1121 {
1122 return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU)) >> RTC_TR_MNU_Pos);
1123 }
1124
1125 /**
1126 * @brief Set Seconds in BCD format
1127 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1128 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1129 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
1130 * @rmtoll TR ST LL_RTC_TIME_SetSecond\n
1131 * TR SU LL_RTC_TIME_SetSecond
1132 * @param RTCx RTC Instance
1133 * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
1134 * @retval None
1135 */
LL_RTC_TIME_SetSecond(RTC_TypeDef * RTCx,uint32_t Seconds)1136 __STATIC_INLINE void LL_RTC_TIME_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
1137 {
1138 MODIFY_REG(RTCx->TR, (RTC_TR_ST | RTC_TR_SU),
1139 (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos)));
1140 }
1141
1142 /**
1143 * @brief Get Seconds in BCD format
1144 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1145 * before reading this bit
1146 * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1147 * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1148 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD
1149 * to Binary format
1150 * @rmtoll TR ST LL_RTC_TIME_GetSecond\n
1151 * TR SU LL_RTC_TIME_GetSecond
1152 * @param RTCx RTC Instance
1153 * @retval Value between Min_Data=0x00 and Max_Data=0x59
1154 */
LL_RTC_TIME_GetSecond(RTC_TypeDef * RTCx)1155 __STATIC_INLINE uint32_t LL_RTC_TIME_GetSecond(RTC_TypeDef *RTCx)
1156 {
1157 return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_ST | RTC_TR_SU)) >> RTC_TR_SU_Pos);
1158 }
1159
1160 /**
1161 * @brief Set time (hour, minute and second) in BCD format
1162 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1163 * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
1164 * @note TimeFormat and Hours should follow the same format
1165 * @rmtoll TR PM LL_RTC_TIME_Config\n
1166 * TR HT LL_RTC_TIME_Config\n
1167 * TR HU LL_RTC_TIME_Config\n
1168 * TR MNT LL_RTC_TIME_Config\n
1169 * TR MNU LL_RTC_TIME_Config\n
1170 * TR ST LL_RTC_TIME_Config\n
1171 * TR SU LL_RTC_TIME_Config
1172 * @param RTCx RTC Instance
1173 * @param Format12_24 This parameter can be one of the following values:
1174 * @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
1175 * @arg @ref LL_RTC_TIME_FORMAT_PM
1176 * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1177 * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
1178 * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
1179 * @retval None
1180 */
LL_RTC_TIME_Config(RTC_TypeDef * RTCx,uint32_t Format12_24,uint32_t Hours,uint32_t Minutes,uint32_t Seconds)1181 __STATIC_INLINE void LL_RTC_TIME_Config(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
1182 {
1183 uint32_t temp;
1184
1185 temp = Format12_24 | \
1186 (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)) | \
1187 (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)) | \
1188 (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos));
1189 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);
1190 }
1191
1192 /**
1193 * @brief Get time (hour, minute and second) in BCD format
1194 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1195 * before reading this bit
1196 * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
1197 * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
1198 * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
1199 * are available to get independently each parameter.
1200 * @rmtoll TR HT LL_RTC_TIME_Get\n
1201 * TR HU LL_RTC_TIME_Get\n
1202 * TR MNT LL_RTC_TIME_Get\n
1203 * TR MNU LL_RTC_TIME_Get\n
1204 * TR ST LL_RTC_TIME_Get\n
1205 * TR SU LL_RTC_TIME_Get
1206 * @param RTCx RTC Instance
1207 * @retval Combination of hours, minutes and seconds (Format: 0x00HHMMSS).
1208 */
LL_RTC_TIME_Get(RTC_TypeDef * RTCx)1209 __STATIC_INLINE uint32_t LL_RTC_TIME_Get(RTC_TypeDef *RTCx)
1210 {
1211 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)));
1212 }
1213
1214 /**
1215 * @brief Memorize whether the daylight saving time change has been performed
1216 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1217 * @rmtoll CR BKP LL_RTC_TIME_EnableDayLightStore
1218 * @param RTCx RTC Instance
1219 * @retval None
1220 */
LL_RTC_TIME_EnableDayLightStore(RTC_TypeDef * RTCx)1221 __STATIC_INLINE void LL_RTC_TIME_EnableDayLightStore(RTC_TypeDef *RTCx)
1222 {
1223 SET_BIT(RTCx->CR, RTC_CR_BKP);
1224 }
1225
1226 /**
1227 * @brief Disable memorization whether the daylight saving time change has been performed.
1228 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1229 * @rmtoll CR BKP LL_RTC_TIME_DisableDayLightStore
1230 * @param RTCx RTC Instance
1231 * @retval None
1232 */
LL_RTC_TIME_DisableDayLightStore(RTC_TypeDef * RTCx)1233 __STATIC_INLINE void LL_RTC_TIME_DisableDayLightStore(RTC_TypeDef *RTCx)
1234 {
1235 CLEAR_BIT(RTCx->CR, RTC_CR_BKP);
1236 }
1237
1238 /**
1239 * @brief Check if RTC Day Light Saving stored operation has been enabled or not
1240 * @rmtoll CR BKP LL_RTC_TIME_IsDayLightStoreEnabled
1241 * @param RTCx RTC Instance
1242 * @retval State of bit (1 or 0).
1243 */
LL_RTC_TIME_IsDayLightStoreEnabled(RTC_TypeDef * RTCx)1244 __STATIC_INLINE uint32_t LL_RTC_TIME_IsDayLightStoreEnabled(RTC_TypeDef *RTCx)
1245 {
1246 return ((READ_BIT(RTCx->CR, RTC_CR_BKP) == (RTC_CR_BKP)) ? 1UL : 0UL);
1247 }
1248
1249 /**
1250 * @brief Subtract 1 hour (winter time change)
1251 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1252 * @rmtoll CR SUB1H LL_RTC_TIME_DecHour
1253 * @param RTCx RTC Instance
1254 * @retval None
1255 */
LL_RTC_TIME_DecHour(RTC_TypeDef * RTCx)1256 __STATIC_INLINE void LL_RTC_TIME_DecHour(RTC_TypeDef *RTCx)
1257 {
1258 SET_BIT(RTCx->CR, RTC_CR_SUB1H);
1259 }
1260
1261 /**
1262 * @brief Add 1 hour (summer time change)
1263 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1264 * @rmtoll CR ADD1H LL_RTC_TIME_IncHour
1265 * @param RTCx RTC Instance
1266 * @retval None
1267 */
LL_RTC_TIME_IncHour(RTC_TypeDef * RTCx)1268 __STATIC_INLINE void LL_RTC_TIME_IncHour(RTC_TypeDef *RTCx)
1269 {
1270 SET_BIT(RTCx->CR, RTC_CR_ADD1H);
1271 }
1272
1273 /**
1274 * @brief Get subseconds value in the synchronous prescaler counter.
1275 * @note You can use both SubSeconds value and SecondFraction (PREDIV_S through
1276 * LL_RTC_GetSynchPrescaler function) terms returned to convert Calendar
1277 * SubSeconds value in second fraction ratio with time unit following
1278 * generic formula:
1279 * ==> Seconds fraction ratio * time_unit =
1280 * [(SecondFraction-SubSeconds)/(SecondFraction+1)] * time_unit
1281 * This conversion can be performed only if no shift operation is pending
1282 * (ie. SHFP=0) when PREDIV_S >= SS.
1283 * @rmtoll SSR SS LL_RTC_TIME_GetSubSecond
1284 * @param RTCx RTC Instance
1285 * @retval Subseconds value (number between 0 and 65535)
1286 */
LL_RTC_TIME_GetSubSecond(RTC_TypeDef * RTCx)1287 __STATIC_INLINE uint32_t LL_RTC_TIME_GetSubSecond(RTC_TypeDef *RTCx)
1288 {
1289 return (uint32_t)(READ_BIT(RTCx->SSR, RTC_SSR_SS));
1290 }
1291
1292 /**
1293 * @brief Synchronize to a remote clock with a high degree of precision.
1294 * @note This operation effectively subtracts from (delays) or advance the clock of a fraction of a second.
1295 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1296 * @note When REFCKON is set, firmware must not write to Shift control register.
1297 * @rmtoll SHIFTR ADD1S LL_RTC_TIME_Synchronize\n
1298 * SHIFTR SUBFS LL_RTC_TIME_Synchronize
1299 * @param RTCx RTC Instance
1300 * @param ShiftSecond This parameter can be one of the following values:
1301 * @arg @ref LL_RTC_SHIFT_SECOND_DELAY
1302 * @arg @ref LL_RTC_SHIFT_SECOND_ADVANCE
1303 * @param Fraction Number of Seconds Fractions (any value from 0 to 0x7FFF)
1304 * @retval None
1305 */
LL_RTC_TIME_Synchronize(RTC_TypeDef * RTCx,uint32_t ShiftSecond,uint32_t Fraction)1306 __STATIC_INLINE void LL_RTC_TIME_Synchronize(RTC_TypeDef *RTCx, uint32_t ShiftSecond, uint32_t Fraction)
1307 {
1308 WRITE_REG(RTCx->SHIFTR, ShiftSecond | Fraction);
1309 }
1310
1311 /**
1312 * @}
1313 */
1314
1315 /** @defgroup RTC_LL_EF_Date Date
1316 * @{
1317 */
1318
1319 /**
1320 * @brief Set Year in BCD format
1321 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Year from binary to BCD format
1322 * @rmtoll DR YT LL_RTC_DATE_SetYear\n
1323 * DR YU LL_RTC_DATE_SetYear
1324 * @param RTCx RTC Instance
1325 * @param Year Value between Min_Data=0x00 and Max_Data=0x99
1326 * @retval None
1327 */
LL_RTC_DATE_SetYear(RTC_TypeDef * RTCx,uint32_t Year)1328 __STATIC_INLINE void LL_RTC_DATE_SetYear(RTC_TypeDef *RTCx, uint32_t Year)
1329 {
1330 MODIFY_REG(RTCx->DR, (RTC_DR_YT | RTC_DR_YU),
1331 (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos)));
1332 }
1333
1334 /**
1335 * @brief Get Year in BCD format
1336 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1337 * before reading this bit
1338 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Year from BCD to Binary format
1339 * @rmtoll DR YT LL_RTC_DATE_GetYear\n
1340 * DR YU LL_RTC_DATE_GetYear
1341 * @param RTCx RTC Instance
1342 * @retval Value between Min_Data=0x00 and Max_Data=0x99
1343 */
LL_RTC_DATE_GetYear(RTC_TypeDef * RTCx)1344 __STATIC_INLINE uint32_t LL_RTC_DATE_GetYear(RTC_TypeDef *RTCx)
1345 {
1346 return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_YT | RTC_DR_YU))) >> RTC_DR_YU_Pos);
1347 }
1348
1349 /**
1350 * @brief Set Week day
1351 * @rmtoll DR WDU LL_RTC_DATE_SetWeekDay
1352 * @param RTCx RTC Instance
1353 * @param WeekDay This parameter can be one of the following values:
1354 * @arg @ref LL_RTC_WEEKDAY_MONDAY
1355 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
1356 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1357 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
1358 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
1359 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
1360 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
1361 * @retval None
1362 */
LL_RTC_DATE_SetWeekDay(RTC_TypeDef * RTCx,uint32_t WeekDay)1363 __STATIC_INLINE void LL_RTC_DATE_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
1364 {
1365 MODIFY_REG(RTCx->DR, RTC_DR_WDU, WeekDay << RTC_DR_WDU_Pos);
1366 }
1367
1368 /**
1369 * @brief Get Week day
1370 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1371 * before reading this bit
1372 * @rmtoll DR WDU LL_RTC_DATE_GetWeekDay
1373 * @param RTCx RTC Instance
1374 * @retval Returned value can be one of the following values:
1375 * @arg @ref LL_RTC_WEEKDAY_MONDAY
1376 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
1377 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1378 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
1379 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
1380 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
1381 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
1382 */
LL_RTC_DATE_GetWeekDay(RTC_TypeDef * RTCx)1383 __STATIC_INLINE uint32_t LL_RTC_DATE_GetWeekDay(RTC_TypeDef *RTCx)
1384 {
1385 return (uint32_t)(READ_BIT(RTCx->DR, RTC_DR_WDU) >> RTC_DR_WDU_Pos);
1386 }
1387
1388 /**
1389 * @brief Set Month in BCD format
1390 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Month from binary to BCD format
1391 * @rmtoll DR MT LL_RTC_DATE_SetMonth\n
1392 * DR MU LL_RTC_DATE_SetMonth
1393 * @param RTCx RTC Instance
1394 * @param Month This parameter can be one of the following values:
1395 * @arg @ref LL_RTC_MONTH_JANUARY
1396 * @arg @ref LL_RTC_MONTH_FEBRUARY
1397 * @arg @ref LL_RTC_MONTH_MARCH
1398 * @arg @ref LL_RTC_MONTH_APRIL
1399 * @arg @ref LL_RTC_MONTH_MAY
1400 * @arg @ref LL_RTC_MONTH_JUNE
1401 * @arg @ref LL_RTC_MONTH_JULY
1402 * @arg @ref LL_RTC_MONTH_AUGUST
1403 * @arg @ref LL_RTC_MONTH_SEPTEMBER
1404 * @arg @ref LL_RTC_MONTH_OCTOBER
1405 * @arg @ref LL_RTC_MONTH_NOVEMBER
1406 * @arg @ref LL_RTC_MONTH_DECEMBER
1407 * @retval None
1408 */
LL_RTC_DATE_SetMonth(RTC_TypeDef * RTCx,uint32_t Month)1409 __STATIC_INLINE void LL_RTC_DATE_SetMonth(RTC_TypeDef *RTCx, uint32_t Month)
1410 {
1411 MODIFY_REG(RTCx->DR, (RTC_DR_MT | RTC_DR_MU),
1412 (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)));
1413 }
1414
1415 /**
1416 * @brief Get Month in BCD format
1417 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1418 * before reading this bit
1419 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
1420 * @rmtoll DR MT LL_RTC_DATE_GetMonth\n
1421 * DR MU LL_RTC_DATE_GetMonth
1422 * @param RTCx RTC Instance
1423 * @retval Returned value can be one of the following values:
1424 * @arg @ref LL_RTC_MONTH_JANUARY
1425 * @arg @ref LL_RTC_MONTH_FEBRUARY
1426 * @arg @ref LL_RTC_MONTH_MARCH
1427 * @arg @ref LL_RTC_MONTH_APRIL
1428 * @arg @ref LL_RTC_MONTH_MAY
1429 * @arg @ref LL_RTC_MONTH_JUNE
1430 * @arg @ref LL_RTC_MONTH_JULY
1431 * @arg @ref LL_RTC_MONTH_AUGUST
1432 * @arg @ref LL_RTC_MONTH_SEPTEMBER
1433 * @arg @ref LL_RTC_MONTH_OCTOBER
1434 * @arg @ref LL_RTC_MONTH_NOVEMBER
1435 * @arg @ref LL_RTC_MONTH_DECEMBER
1436 */
LL_RTC_DATE_GetMonth(RTC_TypeDef * RTCx)1437 __STATIC_INLINE uint32_t LL_RTC_DATE_GetMonth(RTC_TypeDef *RTCx)
1438 {
1439 return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_MT | RTC_DR_MU))) >> RTC_DR_MU_Pos);
1440 }
1441
1442 /**
1443 * @brief Set Day in BCD format
1444 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
1445 * @rmtoll DR DT LL_RTC_DATE_SetDay\n
1446 * DR DU LL_RTC_DATE_SetDay
1447 * @param RTCx RTC Instance
1448 * @param Day Value between Min_Data=0x01 and Max_Data=0x31
1449 * @retval None
1450 */
LL_RTC_DATE_SetDay(RTC_TypeDef * RTCx,uint32_t Day)1451 __STATIC_INLINE void LL_RTC_DATE_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
1452 {
1453 MODIFY_REG(RTCx->DR, (RTC_DR_DT | RTC_DR_DU),
1454 (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos)));
1455 }
1456
1457 /**
1458 * @brief Get Day in BCD format
1459 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1460 * before reading this bit
1461 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
1462 * @rmtoll DR DT LL_RTC_DATE_GetDay\n
1463 * DR DU LL_RTC_DATE_GetDay
1464 * @param RTCx RTC Instance
1465 * @retval Value between Min_Data=0x01 and Max_Data=0x31
1466 */
LL_RTC_DATE_GetDay(RTC_TypeDef * RTCx)1467 __STATIC_INLINE uint32_t LL_RTC_DATE_GetDay(RTC_TypeDef *RTCx)
1468 {
1469 return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_DT | RTC_DR_DU))) >> RTC_DR_DU_Pos);
1470 }
1471
1472 /**
1473 * @brief Set date (WeekDay, Day, Month and Year) in BCD format
1474 * @rmtoll DR WDU LL_RTC_DATE_Config\n
1475 * DR MT LL_RTC_DATE_Config\n
1476 * DR MU LL_RTC_DATE_Config\n
1477 * DR DT LL_RTC_DATE_Config\n
1478 * DR DU LL_RTC_DATE_Config\n
1479 * DR YT LL_RTC_DATE_Config\n
1480 * DR YU LL_RTC_DATE_Config
1481 * @param RTCx RTC Instance
1482 * @param WeekDay This parameter can be one of the following values:
1483 * @arg @ref LL_RTC_WEEKDAY_MONDAY
1484 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
1485 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1486 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
1487 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
1488 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
1489 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
1490 * @param Day Value between Min_Data=0x01 and Max_Data=0x31
1491 * @param Month This parameter can be one of the following values:
1492 * @arg @ref LL_RTC_MONTH_JANUARY
1493 * @arg @ref LL_RTC_MONTH_FEBRUARY
1494 * @arg @ref LL_RTC_MONTH_MARCH
1495 * @arg @ref LL_RTC_MONTH_APRIL
1496 * @arg @ref LL_RTC_MONTH_MAY
1497 * @arg @ref LL_RTC_MONTH_JUNE
1498 * @arg @ref LL_RTC_MONTH_JULY
1499 * @arg @ref LL_RTC_MONTH_AUGUST
1500 * @arg @ref LL_RTC_MONTH_SEPTEMBER
1501 * @arg @ref LL_RTC_MONTH_OCTOBER
1502 * @arg @ref LL_RTC_MONTH_NOVEMBER
1503 * @arg @ref LL_RTC_MONTH_DECEMBER
1504 * @param Year Value between Min_Data=0x00 and Max_Data=0x99
1505 * @retval None
1506 */
LL_RTC_DATE_Config(RTC_TypeDef * RTCx,uint32_t WeekDay,uint32_t Day,uint32_t Month,uint32_t Year)1507 __STATIC_INLINE void LL_RTC_DATE_Config(RTC_TypeDef *RTCx, uint32_t WeekDay, uint32_t Day, uint32_t Month, uint32_t Year)
1508 {
1509 uint32_t temp;
1510
1511 temp = ( WeekDay << RTC_DR_WDU_Pos) | \
1512 (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos)) | \
1513 (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)) | \
1514 (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos));
1515
1516 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);
1517 }
1518
1519 /**
1520 * @brief Get date (WeekDay, Day, Month and Year) in BCD format
1521 * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
1522 * before reading this bit
1523 * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_YEAR, __LL_RTC_GET_MONTH,
1524 * and __LL_RTC_GET_DAY are available to get independently each parameter.
1525 * @rmtoll DR WDU LL_RTC_DATE_Get\n
1526 * DR MT LL_RTC_DATE_Get\n
1527 * DR MU LL_RTC_DATE_Get\n
1528 * DR DT LL_RTC_DATE_Get\n
1529 * DR DU LL_RTC_DATE_Get\n
1530 * DR YT LL_RTC_DATE_Get\n
1531 * DR YU LL_RTC_DATE_Get
1532 * @param RTCx RTC Instance
1533 * @retval Combination of WeekDay, Day, Month and Year (Format: 0xWWDDMMYY).
1534 */
LL_RTC_DATE_Get(RTC_TypeDef * RTCx)1535 __STATIC_INLINE uint32_t LL_RTC_DATE_Get(RTC_TypeDef *RTCx)
1536 {
1537 uint32_t temp;
1538
1539 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));
1540
1541 return (uint32_t)((((temp & RTC_DR_WDU) >> RTC_DR_WDU_Pos) << RTC_OFFSET_WEEKDAY) | \
1542 (((temp & (RTC_DR_DT | RTC_DR_DU)) >> RTC_DR_DU_Pos) << RTC_OFFSET_DAY) | \
1543 (((temp & (RTC_DR_MT | RTC_DR_MU)) >> RTC_DR_MU_Pos) << RTC_OFFSET_MONTH) | \
1544 ((temp & (RTC_DR_YT | RTC_DR_YU)) >> RTC_DR_YU_Pos));
1545 }
1546
1547 /**
1548 * @}
1549 */
1550
1551 /** @defgroup RTC_LL_EF_ALARMA ALARMA
1552 * @{
1553 */
1554
1555 /**
1556 * @brief Enable Alarm A
1557 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1558 * @rmtoll CR ALRAE LL_RTC_ALMA_Enable
1559 * @param RTCx RTC Instance
1560 * @retval None
1561 */
LL_RTC_ALMA_Enable(RTC_TypeDef * RTCx)1562 __STATIC_INLINE void LL_RTC_ALMA_Enable(RTC_TypeDef *RTCx)
1563 {
1564 SET_BIT(RTCx->CR, RTC_CR_ALRAE);
1565 }
1566
1567 /**
1568 * @brief Disable Alarm A
1569 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1570 * @rmtoll CR ALRAE LL_RTC_ALMA_Disable
1571 * @param RTCx RTC Instance
1572 * @retval None
1573 */
LL_RTC_ALMA_Disable(RTC_TypeDef * RTCx)1574 __STATIC_INLINE void LL_RTC_ALMA_Disable(RTC_TypeDef *RTCx)
1575 {
1576 CLEAR_BIT(RTCx->CR, RTC_CR_ALRAE);
1577 }
1578
1579 /**
1580 * @brief Specify the Alarm A masks.
1581 * @rmtoll ALRMAR MSK4 LL_RTC_ALMA_SetMask\n
1582 * ALRMAR MSK3 LL_RTC_ALMA_SetMask\n
1583 * ALRMAR MSK2 LL_RTC_ALMA_SetMask\n
1584 * ALRMAR MSK1 LL_RTC_ALMA_SetMask
1585 * @param RTCx RTC Instance
1586 * @param Mask This parameter can be a combination of the following values:
1587 * @arg @ref LL_RTC_ALMA_MASK_NONE
1588 * @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
1589 * @arg @ref LL_RTC_ALMA_MASK_HOURS
1590 * @arg @ref LL_RTC_ALMA_MASK_MINUTES
1591 * @arg @ref LL_RTC_ALMA_MASK_SECONDS
1592 * @arg @ref LL_RTC_ALMA_MASK_ALL
1593 * @retval None
1594 */
LL_RTC_ALMA_SetMask(RTC_TypeDef * RTCx,uint32_t Mask)1595 __STATIC_INLINE void LL_RTC_ALMA_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
1596 {
1597 MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1, Mask);
1598 }
1599
1600 /**
1601 * @brief Get the Alarm A masks.
1602 * @rmtoll ALRMAR MSK4 LL_RTC_ALMA_GetMask\n
1603 * ALRMAR MSK3 LL_RTC_ALMA_GetMask\n
1604 * ALRMAR MSK2 LL_RTC_ALMA_GetMask\n
1605 * ALRMAR MSK1 LL_RTC_ALMA_GetMask
1606 * @param RTCx RTC Instance
1607 * @retval Returned value can be can be a combination of the following values:
1608 * @arg @ref LL_RTC_ALMA_MASK_NONE
1609 * @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
1610 * @arg @ref LL_RTC_ALMA_MASK_HOURS
1611 * @arg @ref LL_RTC_ALMA_MASK_MINUTES
1612 * @arg @ref LL_RTC_ALMA_MASK_SECONDS
1613 * @arg @ref LL_RTC_ALMA_MASK_ALL
1614 */
LL_RTC_ALMA_GetMask(RTC_TypeDef * RTCx)1615 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMask(RTC_TypeDef *RTCx)
1616 {
1617 return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1));
1618 }
1619
1620 /**
1621 * @brief Enable AlarmA Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
1622 * @rmtoll ALRMAR WDSEL LL_RTC_ALMA_EnableWeekday
1623 * @param RTCx RTC Instance
1624 * @retval None
1625 */
LL_RTC_ALMA_EnableWeekday(RTC_TypeDef * RTCx)1626 __STATIC_INLINE void LL_RTC_ALMA_EnableWeekday(RTC_TypeDef *RTCx)
1627 {
1628 SET_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
1629 }
1630
1631 /**
1632 * @brief Disable AlarmA Week day selection (DU[3:0] represents the date )
1633 * @rmtoll ALRMAR WDSEL LL_RTC_ALMA_DisableWeekday
1634 * @param RTCx RTC Instance
1635 * @retval None
1636 */
LL_RTC_ALMA_DisableWeekday(RTC_TypeDef * RTCx)1637 __STATIC_INLINE void LL_RTC_ALMA_DisableWeekday(RTC_TypeDef *RTCx)
1638 {
1639 CLEAR_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
1640 }
1641
1642 /**
1643 * @brief Set ALARM A Day in BCD format
1644 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
1645 * @rmtoll ALRMAR DT LL_RTC_ALMA_SetDay\n
1646 * ALRMAR DU LL_RTC_ALMA_SetDay
1647 * @param RTCx RTC Instance
1648 * @param Day Value between Min_Data=0x01 and Max_Data=0x31
1649 * @retval None
1650 */
LL_RTC_ALMA_SetDay(RTC_TypeDef * RTCx,uint32_t Day)1651 __STATIC_INLINE void LL_RTC_ALMA_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
1652 {
1653 MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU),
1654 (((Day & 0xF0U) << (RTC_ALRMAR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMAR_DU_Pos)));
1655 }
1656
1657 /**
1658 * @brief Get ALARM A Day in BCD format
1659 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
1660 * @rmtoll ALRMAR DT LL_RTC_ALMA_GetDay\n
1661 * ALRMAR DU LL_RTC_ALMA_GetDay
1662 * @param RTCx RTC Instance
1663 * @retval Value between Min_Data=0x01 and Max_Data=0x31
1664 */
LL_RTC_ALMA_GetDay(RTC_TypeDef * RTCx)1665 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetDay(RTC_TypeDef *RTCx)
1666 {
1667 return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU))) >> RTC_ALRMAR_DU_Pos);
1668 }
1669
1670 /**
1671 * @brief Set ALARM A Weekday
1672 * @rmtoll ALRMAR DU LL_RTC_ALMA_SetWeekDay
1673 * @param RTCx RTC Instance
1674 * @param WeekDay This parameter can be one of the following values:
1675 * @arg @ref LL_RTC_WEEKDAY_MONDAY
1676 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
1677 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1678 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
1679 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
1680 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
1681 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
1682 * @retval None
1683 */
LL_RTC_ALMA_SetWeekDay(RTC_TypeDef * RTCx,uint32_t WeekDay)1684 __STATIC_INLINE void LL_RTC_ALMA_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
1685 {
1686 MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_DU, WeekDay << RTC_ALRMAR_DU_Pos);
1687 }
1688
1689 /**
1690 * @brief Get ALARM A Weekday
1691 * @rmtoll ALRMAR DU LL_RTC_ALMA_GetWeekDay
1692 * @param RTCx RTC Instance
1693 * @retval Returned value can be one of the following values:
1694 * @arg @ref LL_RTC_WEEKDAY_MONDAY
1695 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
1696 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
1697 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
1698 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
1699 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
1700 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
1701 */
LL_RTC_ALMA_GetWeekDay(RTC_TypeDef * RTCx)1702 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetWeekDay(RTC_TypeDef *RTCx)
1703 {
1704 return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_DU) >> RTC_ALRMAR_DU_Pos);
1705 }
1706
1707 /**
1708 * @brief Set Alarm A time format (AM/24-hour or PM notation)
1709 * @rmtoll ALRMAR PM LL_RTC_ALMA_SetTimeFormat
1710 * @param RTCx RTC Instance
1711 * @param TimeFormat This parameter can be one of the following values:
1712 * @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
1713 * @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
1714 * @retval None
1715 */
LL_RTC_ALMA_SetTimeFormat(RTC_TypeDef * RTCx,uint32_t TimeFormat)1716 __STATIC_INLINE void LL_RTC_ALMA_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
1717 {
1718 MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_PM, TimeFormat);
1719 }
1720
1721 /**
1722 * @brief Get Alarm A time format (AM or PM notation)
1723 * @rmtoll ALRMAR PM LL_RTC_ALMA_GetTimeFormat
1724 * @param RTCx RTC Instance
1725 * @retval Returned value can be one of the following values:
1726 * @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
1727 * @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
1728 */
LL_RTC_ALMA_GetTimeFormat(RTC_TypeDef * RTCx)1729 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTimeFormat(RTC_TypeDef *RTCx)
1730 {
1731 return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_PM));
1732 }
1733
1734 /**
1735 * @brief Set ALARM A Hours in BCD format
1736 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
1737 * @rmtoll ALRMAR HT LL_RTC_ALMA_SetHour\n
1738 * ALRMAR HU LL_RTC_ALMA_SetHour
1739 * @param RTCx RTC Instance
1740 * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1741 * @retval None
1742 */
LL_RTC_ALMA_SetHour(RTC_TypeDef * RTCx,uint32_t Hours)1743 __STATIC_INLINE void LL_RTC_ALMA_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
1744 {
1745 MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU),
1746 (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos)));
1747 }
1748
1749 /**
1750 * @brief Get ALARM A Hours in BCD format
1751 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
1752 * @rmtoll ALRMAR HT LL_RTC_ALMA_GetHour\n
1753 * ALRMAR HU LL_RTC_ALMA_GetHour
1754 * @param RTCx RTC Instance
1755 * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1756 */
LL_RTC_ALMA_GetHour(RTC_TypeDef * RTCx)1757 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetHour(RTC_TypeDef *RTCx)
1758 {
1759 return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU))) >> RTC_ALRMAR_HU_Pos);
1760 }
1761
1762 /**
1763 * @brief Set ALARM A Minutes in BCD format
1764 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
1765 * @rmtoll ALRMAR MNT LL_RTC_ALMA_SetMinute\n
1766 * ALRMAR MNU LL_RTC_ALMA_SetMinute
1767 * @param RTCx RTC Instance
1768 * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
1769 * @retval None
1770 */
LL_RTC_ALMA_SetMinute(RTC_TypeDef * RTCx,uint32_t Minutes)1771 __STATIC_INLINE void LL_RTC_ALMA_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
1772 {
1773 MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU),
1774 (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)));
1775 }
1776
1777 /**
1778 * @brief Get ALARM A Minutes in BCD format
1779 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
1780 * @rmtoll ALRMAR MNT LL_RTC_ALMA_GetMinute\n
1781 * ALRMAR MNU LL_RTC_ALMA_GetMinute
1782 * @param RTCx RTC Instance
1783 * @retval Value between Min_Data=0x00 and Max_Data=0x59
1784 */
LL_RTC_ALMA_GetMinute(RTC_TypeDef * RTCx)1785 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMinute(RTC_TypeDef *RTCx)
1786 {
1787 return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU))) >> RTC_ALRMAR_MNU_Pos);
1788 }
1789
1790 /**
1791 * @brief Set ALARM A Seconds in BCD format
1792 * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
1793 * @rmtoll ALRMAR ST LL_RTC_ALMA_SetSecond\n
1794 * ALRMAR SU LL_RTC_ALMA_SetSecond
1795 * @param RTCx RTC Instance
1796 * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
1797 * @retval None
1798 */
LL_RTC_ALMA_SetSecond(RTC_TypeDef * RTCx,uint32_t Seconds)1799 __STATIC_INLINE void LL_RTC_ALMA_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
1800 {
1801 MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU),
1802 (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos)));
1803 }
1804
1805 /**
1806 * @brief Get ALARM A Seconds in BCD format
1807 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
1808 * @rmtoll ALRMAR ST LL_RTC_ALMA_GetSecond\n
1809 * ALRMAR SU LL_RTC_ALMA_GetSecond
1810 * @param RTCx RTC Instance
1811 * @retval Value between Min_Data=0x00 and Max_Data=0x59
1812 */
LL_RTC_ALMA_GetSecond(RTC_TypeDef * RTCx)1813 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSecond(RTC_TypeDef *RTCx)
1814 {
1815 return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU))) >> RTC_ALRMAR_SU_Pos);
1816 }
1817
1818 /**
1819 * @brief Set Alarm A Time (hour, minute and second) in BCD format
1820 * @rmtoll ALRMAR PM LL_RTC_ALMA_ConfigTime\n
1821 * ALRMAR HT LL_RTC_ALMA_ConfigTime\n
1822 * ALRMAR HU LL_RTC_ALMA_ConfigTime\n
1823 * ALRMAR MNT LL_RTC_ALMA_ConfigTime\n
1824 * ALRMAR MNU LL_RTC_ALMA_ConfigTime\n
1825 * ALRMAR ST LL_RTC_ALMA_ConfigTime\n
1826 * ALRMAR SU LL_RTC_ALMA_ConfigTime
1827 * @param RTCx RTC Instance
1828 * @param Format12_24 This parameter can be one of the following values:
1829 * @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
1830 * @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
1831 * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1832 * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
1833 * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
1834 * @retval None
1835 */
LL_RTC_ALMA_ConfigTime(RTC_TypeDef * RTCx,uint32_t Format12_24,uint32_t Hours,uint32_t Minutes,uint32_t Seconds)1836 __STATIC_INLINE void LL_RTC_ALMA_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
1837 {
1838 uint32_t temp;
1839
1840 temp = Format12_24 | \
1841 (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos)) | \
1842 (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)) | \
1843 (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos));
1844
1845 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);
1846 }
1847
1848 /**
1849 * @brief Get Alarm B Time (hour, minute and second) in BCD format
1850 * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
1851 * are available to get independently each parameter.
1852 * @rmtoll ALRMAR HT LL_RTC_ALMA_GetTime\n
1853 * ALRMAR HU LL_RTC_ALMA_GetTime\n
1854 * ALRMAR MNT LL_RTC_ALMA_GetTime\n
1855 * ALRMAR MNU LL_RTC_ALMA_GetTime\n
1856 * ALRMAR ST LL_RTC_ALMA_GetTime\n
1857 * ALRMAR SU LL_RTC_ALMA_GetTime
1858 * @param RTCx RTC Instance
1859 * @retval Combination of hours, minutes and seconds.
1860 */
LL_RTC_ALMA_GetTime(RTC_TypeDef * RTCx)1861 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTime(RTC_TypeDef *RTCx)
1862 {
1863 return (uint32_t)((LL_RTC_ALMA_GetHour(RTCx) << RTC_OFFSET_HOUR) | (LL_RTC_ALMA_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMA_GetSecond(RTCx));
1864 }
1865
1866 /**
1867 * @brief Mask the most-significant bits of the subseconds field starting from
1868 * the bit specified in parameter Mask
1869 * @note This register can be written only when ALRAE is reset in RTC_CR register,
1870 * or in initialization mode.
1871 * @rmtoll ALRMASSR MASKSS LL_RTC_ALMA_SetSubSecondMask
1872 * @param RTCx RTC Instance
1873 * @param Mask Value between Min_Data=0x00 and Max_Data=0xF
1874 * @retval None
1875 */
LL_RTC_ALMA_SetSubSecondMask(RTC_TypeDef * RTCx,uint32_t Mask)1876 __STATIC_INLINE void LL_RTC_ALMA_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
1877 {
1878 MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS, Mask << RTC_ALRMASSR_MASKSS_Pos);
1879 }
1880
1881 /**
1882 * @brief Get Alarm A subseconds mask
1883 * @rmtoll ALRMASSR MASKSS LL_RTC_ALMA_GetSubSecondMask
1884 * @param RTCx RTC Instance
1885 * @retval Value between Min_Data=0x00 and Max_Data=0xF
1886 */
LL_RTC_ALMA_GetSubSecondMask(RTC_TypeDef * RTCx)1887 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecondMask(RTC_TypeDef *RTCx)
1888 {
1889 return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS) >> RTC_ALRMASSR_MASKSS_Pos);
1890 }
1891
1892 /**
1893 * @brief Set Alarm A subseconds value
1894 * @rmtoll ALRMASSR SS LL_RTC_ALMA_SetSubSecond
1895 * @param RTCx RTC Instance
1896 * @param Subsecond Value between Min_Data=0x00 and Max_Data=0x7FFF
1897 * @retval None
1898 */
LL_RTC_ALMA_SetSubSecond(RTC_TypeDef * RTCx,uint32_t Subsecond)1899 __STATIC_INLINE void LL_RTC_ALMA_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
1900 {
1901 MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_SS, Subsecond);
1902 }
1903
1904 /**
1905 * @brief Get Alarm A subseconds value
1906 * @rmtoll ALRMASSR SS LL_RTC_ALMA_GetSubSecond
1907 * @param RTCx RTC Instance
1908 * @retval Value between Min_Data=0x00 and Max_Data=0x7FFF
1909 */
LL_RTC_ALMA_GetSubSecond(RTC_TypeDef * RTCx)1910 __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecond(RTC_TypeDef *RTCx)
1911 {
1912 return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_SS));
1913 }
1914
1915 /**
1916 * @}
1917 */
1918
1919 /** @defgroup RTC_LL_EF_Timestamp Timestamp
1920 * @{
1921 */
1922
1923 /**
1924 * @brief Enable Timestamp
1925 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1926 * @rmtoll CR TSE LL_RTC_TS_Enable
1927 * @param RTCx RTC Instance
1928 * @retval None
1929 */
LL_RTC_TS_Enable(RTC_TypeDef * RTCx)1930 __STATIC_INLINE void LL_RTC_TS_Enable(RTC_TypeDef *RTCx)
1931 {
1932 SET_BIT(RTCx->CR, RTC_CR_TSE);
1933 }
1934
1935 /**
1936 * @brief Disable Timestamp
1937 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1938 * @rmtoll CR TSE LL_RTC_TS_Disable
1939 * @param RTCx RTC Instance
1940 * @retval None
1941 */
LL_RTC_TS_Disable(RTC_TypeDef * RTCx)1942 __STATIC_INLINE void LL_RTC_TS_Disable(RTC_TypeDef *RTCx)
1943 {
1944 CLEAR_BIT(RTCx->CR, RTC_CR_TSE);
1945 }
1946
1947 /**
1948 * @brief Set Time-stamp event active edge
1949 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1950 * @note TSE must be reset when TSEDGE is changed to avoid unwanted TSF setting
1951 * @rmtoll CR TSEDGE LL_RTC_TS_SetActiveEdge
1952 * @param RTCx RTC Instance
1953 * @param Edge This parameter can be one of the following values:
1954 * @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
1955 * @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
1956 * @retval None
1957 */
LL_RTC_TS_SetActiveEdge(RTC_TypeDef * RTCx,uint32_t Edge)1958 __STATIC_INLINE void LL_RTC_TS_SetActiveEdge(RTC_TypeDef *RTCx, uint32_t Edge)
1959 {
1960 MODIFY_REG(RTCx->CR, RTC_CR_TSEDGE, Edge);
1961 }
1962
1963 /**
1964 * @brief Get Time-stamp event active edge
1965 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
1966 * @rmtoll CR TSEDGE LL_RTC_TS_GetActiveEdge
1967 * @param RTCx RTC Instance
1968 * @retval Returned value can be one of the following values:
1969 * @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
1970 * @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
1971 */
LL_RTC_TS_GetActiveEdge(RTC_TypeDef * RTCx)1972 __STATIC_INLINE uint32_t LL_RTC_TS_GetActiveEdge(RTC_TypeDef *RTCx)
1973 {
1974 return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_TSEDGE));
1975 }
1976
1977 /**
1978 * @brief Get Timestamp AM/PM notation (AM or 24-hour format)
1979 * @rmtoll TSTR PM LL_RTC_TS_GetTimeFormat
1980 * @param RTCx RTC Instance
1981 * @retval Returned value can be one of the following values:
1982 * @arg @ref LL_RTC_TS_TIME_FORMAT_AM
1983 * @arg @ref LL_RTC_TS_TIME_FORMAT_PM
1984 */
LL_RTC_TS_GetTimeFormat(RTC_TypeDef * RTCx)1985 __STATIC_INLINE uint32_t LL_RTC_TS_GetTimeFormat(RTC_TypeDef *RTCx)
1986 {
1987 return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_PM));
1988 }
1989
1990 /**
1991 * @brief Get Timestamp Hours in BCD format
1992 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
1993 * @rmtoll TSTR HT LL_RTC_TS_GetHour\n
1994 * TSTR HU LL_RTC_TS_GetHour
1995 * @param RTCx RTC Instance
1996 * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
1997 */
LL_RTC_TS_GetHour(RTC_TypeDef * RTCx)1998 __STATIC_INLINE uint32_t LL_RTC_TS_GetHour(RTC_TypeDef *RTCx)
1999 {
2000 return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_HT | RTC_TSTR_HU) >> RTC_TSTR_HU_Pos);
2001 }
2002
2003 /**
2004 * @brief Get Timestamp Minutes in BCD format
2005 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
2006 * @rmtoll TSTR MNT LL_RTC_TS_GetMinute\n
2007 * TSTR MNU LL_RTC_TS_GetMinute
2008 * @param RTCx RTC Instance
2009 * @retval Value between Min_Data=0x00 and Max_Data=0x59
2010 */
LL_RTC_TS_GetMinute(RTC_TypeDef * RTCx)2011 __STATIC_INLINE uint32_t LL_RTC_TS_GetMinute(RTC_TypeDef *RTCx)
2012 {
2013 return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_MNT | RTC_TSTR_MNU) >> RTC_TSTR_MNU_Pos);
2014 }
2015
2016 /**
2017 * @brief Get Timestamp Seconds in BCD format
2018 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
2019 * @rmtoll TSTR ST LL_RTC_TS_GetSecond\n
2020 * TSTR SU LL_RTC_TS_GetSecond
2021 * @param RTCx RTC Instance
2022 * @retval Value between Min_Data=0x00 and Max_Data=0x59
2023 */
LL_RTC_TS_GetSecond(RTC_TypeDef * RTCx)2024 __STATIC_INLINE uint32_t LL_RTC_TS_GetSecond(RTC_TypeDef *RTCx)
2025 {
2026 return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_ST | RTC_TSTR_SU));
2027 }
2028
2029 /**
2030 * @brief Get Timestamp time (hour, minute and second) in BCD format
2031 * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
2032 * are available to get independently each parameter.
2033 * @rmtoll TSTR HT LL_RTC_TS_GetTime\n
2034 * TSTR HU LL_RTC_TS_GetTime\n
2035 * TSTR MNT LL_RTC_TS_GetTime\n
2036 * TSTR MNU LL_RTC_TS_GetTime\n
2037 * TSTR ST LL_RTC_TS_GetTime\n
2038 * TSTR SU LL_RTC_TS_GetTime
2039 * @param RTCx RTC Instance
2040 * @retval Combination of hours, minutes and seconds.
2041 */
LL_RTC_TS_GetTime(RTC_TypeDef * RTCx)2042 __STATIC_INLINE uint32_t LL_RTC_TS_GetTime(RTC_TypeDef *RTCx)
2043 {
2044 return (uint32_t)(READ_BIT(RTCx->TSTR,
2045 RTC_TSTR_HT | RTC_TSTR_HU | RTC_TSTR_MNT | RTC_TSTR_MNU | RTC_TSTR_ST | RTC_TSTR_SU));
2046 }
2047
2048 /**
2049 * @brief Get Timestamp Week day
2050 * @rmtoll TSDR WDU LL_RTC_TS_GetWeekDay
2051 * @param RTCx RTC Instance
2052 * @retval Returned value can be one of the following values:
2053 * @arg @ref LL_RTC_WEEKDAY_MONDAY
2054 * @arg @ref LL_RTC_WEEKDAY_TUESDAY
2055 * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
2056 * @arg @ref LL_RTC_WEEKDAY_THURSDAY
2057 * @arg @ref LL_RTC_WEEKDAY_FRIDAY
2058 * @arg @ref LL_RTC_WEEKDAY_SATURDAY
2059 * @arg @ref LL_RTC_WEEKDAY_SUNDAY
2060 */
LL_RTC_TS_GetWeekDay(RTC_TypeDef * RTCx)2061 __STATIC_INLINE uint32_t LL_RTC_TS_GetWeekDay(RTC_TypeDef *RTCx)
2062 {
2063 return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU) >> RTC_TSDR_WDU_Pos);
2064 }
2065
2066 /**
2067 * @brief Get Timestamp Month in BCD format
2068 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
2069 * @rmtoll TSDR MT LL_RTC_TS_GetMonth\n
2070 * TSDR MU LL_RTC_TS_GetMonth
2071 * @param RTCx RTC Instance
2072 * @retval Returned value can be one of the following values:
2073 * @arg @ref LL_RTC_MONTH_JANUARY
2074 * @arg @ref LL_RTC_MONTH_FEBRUARY
2075 * @arg @ref LL_RTC_MONTH_MARCH
2076 * @arg @ref LL_RTC_MONTH_APRIL
2077 * @arg @ref LL_RTC_MONTH_MAY
2078 * @arg @ref LL_RTC_MONTH_JUNE
2079 * @arg @ref LL_RTC_MONTH_JULY
2080 * @arg @ref LL_RTC_MONTH_AUGUST
2081 * @arg @ref LL_RTC_MONTH_SEPTEMBER
2082 * @arg @ref LL_RTC_MONTH_OCTOBER
2083 * @arg @ref LL_RTC_MONTH_NOVEMBER
2084 * @arg @ref LL_RTC_MONTH_DECEMBER
2085 */
LL_RTC_TS_GetMonth(RTC_TypeDef * RTCx)2086 __STATIC_INLINE uint32_t LL_RTC_TS_GetMonth(RTC_TypeDef *RTCx)
2087 {
2088 return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_MT | RTC_TSDR_MU) >> RTC_TSDR_MU_Pos);
2089 }
2090
2091 /**
2092 * @brief Get Timestamp Day in BCD format
2093 * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
2094 * @rmtoll TSDR DT LL_RTC_TS_GetDay\n
2095 * TSDR DU LL_RTC_TS_GetDay
2096 * @param RTCx RTC Instance
2097 * @retval Value between Min_Data=0x01 and Max_Data=0x31
2098 */
LL_RTC_TS_GetDay(RTC_TypeDef * RTCx)2099 __STATIC_INLINE uint32_t LL_RTC_TS_GetDay(RTC_TypeDef *RTCx)
2100 {
2101 return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_DT | RTC_TSDR_DU));
2102 }
2103
2104 /**
2105 * @brief Get Timestamp date (WeekDay, Day and Month) in BCD format
2106 * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_MONTH,
2107 * and __LL_RTC_GET_DAY are available to get independently each parameter.
2108 * @rmtoll TSDR WDU LL_RTC_TS_GetDate\n
2109 * TSDR MT LL_RTC_TS_GetDate\n
2110 * TSDR MU LL_RTC_TS_GetDate\n
2111 * TSDR DT LL_RTC_TS_GetDate\n
2112 * TSDR DU LL_RTC_TS_GetDate
2113 * @param RTCx RTC Instance
2114 * @retval Combination of Weekday, Day and Month
2115 */
LL_RTC_TS_GetDate(RTC_TypeDef * RTCx)2116 __STATIC_INLINE uint32_t LL_RTC_TS_GetDate(RTC_TypeDef *RTCx)
2117 {
2118 return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU | RTC_TSDR_MT | RTC_TSDR_MU | RTC_TSDR_DT | RTC_TSDR_DU));
2119 }
2120
2121 /**
2122 * @brief Get time-stamp subseconds value
2123 * @rmtoll TSSSR SS LL_RTC_TS_GetSubSecond
2124 * @param RTCx RTC Instance
2125 * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF
2126 */
LL_RTC_TS_GetSubSecond(RTC_TypeDef * RTCx)2127 __STATIC_INLINE uint32_t LL_RTC_TS_GetSubSecond(RTC_TypeDef *RTCx)
2128 {
2129 return (uint32_t)(READ_BIT(RTCx->TSSSR, RTC_TSSSR_SS));
2130 }
2131
2132 #if defined(RTC_TAFCR_TAMPTS)
2133 /**
2134 * @brief Activate timestamp on tamper detection event
2135 * @rmtoll TAFCR TAMPTS LL_RTC_TS_EnableOnTamper
2136 * @param RTCx RTC Instance
2137 * @retval None
2138 */
LL_RTC_TS_EnableOnTamper(RTC_TypeDef * RTCx)2139 __STATIC_INLINE void LL_RTC_TS_EnableOnTamper(RTC_TypeDef *RTCx)
2140 {
2141 SET_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPTS);
2142 }
2143
2144 /**
2145 * @brief Disable timestamp on tamper detection event
2146 * @rmtoll TAFCR TAMPTS LL_RTC_TS_DisableOnTamper
2147 * @param RTCx RTC Instance
2148 * @retval None
2149 */
LL_RTC_TS_DisableOnTamper(RTC_TypeDef * RTCx)2150 __STATIC_INLINE void LL_RTC_TS_DisableOnTamper(RTC_TypeDef *RTCx)
2151 {
2152 CLEAR_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPTS);
2153 }
2154 #endif /* RTC_TAFCR_TAMPTS */
2155
2156 /**
2157 * @}
2158 */
2159
2160 /** @defgroup RTC_LL_EF_Tamper Tamper
2161 * @{
2162 */
2163
2164 /**
2165 * @brief Enable RTC_TAMPx input detection
2166 * @rmtoll TAFCR TAMP1E LL_RTC_TAMPER_Enable\n
2167 * TAFCR TAMP2E LL_RTC_TAMPER_Enable\n
2168 * TAFCR TAMP3E LL_RTC_TAMPER_Enable
2169 * @param RTCx RTC Instance
2170 * @param Tamper This parameter can be a combination of the following values:
2171 * @arg @ref LL_RTC_TAMPER_1
2172 * @arg @ref LL_RTC_TAMPER_2
2173 * @arg @ref LL_RTC_TAMPER_3 (*)
2174 *
2175 * (*) value not applicable to all devices.
2176 * @retval None
2177 */
LL_RTC_TAMPER_Enable(RTC_TypeDef * RTCx,uint32_t Tamper)2178 __STATIC_INLINE void LL_RTC_TAMPER_Enable(RTC_TypeDef *RTCx, uint32_t Tamper)
2179 {
2180 SET_BIT(RTCx->TAFCR, Tamper);
2181 }
2182
2183 /**
2184 * @brief Clear RTC_TAMPx input detection
2185 * @rmtoll TAFCR TAMP1E LL_RTC_TAMPER_Disable\n
2186 * TAFCR TAMP2E LL_RTC_TAMPER_Disable\n
2187 * TAFCR TAMP3E LL_RTC_TAMPER_Disable
2188 * @param RTCx RTC Instance
2189 * @param Tamper This parameter can be a combination of the following values:
2190 * @arg @ref LL_RTC_TAMPER_1
2191 * @arg @ref LL_RTC_TAMPER_2
2192 * @arg @ref LL_RTC_TAMPER_3 (*)
2193 *
2194 * (*) value not applicable to all devices.
2195 * @retval None
2196 */
LL_RTC_TAMPER_Disable(RTC_TypeDef * RTCx,uint32_t Tamper)2197 __STATIC_INLINE void LL_RTC_TAMPER_Disable(RTC_TypeDef *RTCx, uint32_t Tamper)
2198 {
2199 CLEAR_BIT(RTCx->TAFCR, Tamper);
2200 }
2201
2202 /**
2203 * @brief Disable RTC_TAMPx pull-up disable (Disable precharge of RTC_TAMPx pins)
2204 * @rmtoll TAFCR TAMPPUDIS LL_RTC_TAMPER_DisablePullUp
2205 * @param RTCx RTC Instance
2206 * @retval None
2207 */
LL_RTC_TAMPER_DisablePullUp(RTC_TypeDef * RTCx)2208 __STATIC_INLINE void LL_RTC_TAMPER_DisablePullUp(RTC_TypeDef *RTCx)
2209 {
2210 SET_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPPUDIS);
2211 }
2212
2213 /**
2214 * @brief Enable RTC_TAMPx pull-up disable ( Precharge RTC_TAMPx pins before sampling)
2215 * @rmtoll TAFCR TAMPPUDIS LL_RTC_TAMPER_EnablePullUp
2216 * @param RTCx RTC Instance
2217 * @retval None
2218 */
LL_RTC_TAMPER_EnablePullUp(RTC_TypeDef * RTCx)2219 __STATIC_INLINE void LL_RTC_TAMPER_EnablePullUp(RTC_TypeDef *RTCx)
2220 {
2221 CLEAR_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPPUDIS);
2222 }
2223
2224 /**
2225 * @brief Set RTC_TAMPx precharge duration
2226 * @rmtoll TAFCR TAMPPRCH LL_RTC_TAMPER_SetPrecharge
2227 * @param RTCx RTC Instance
2228 * @param Duration This parameter can be one of the following values:
2229 * @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
2230 * @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
2231 * @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
2232 * @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
2233 * @retval None
2234 */
LL_RTC_TAMPER_SetPrecharge(RTC_TypeDef * RTCx,uint32_t Duration)2235 __STATIC_INLINE void LL_RTC_TAMPER_SetPrecharge(RTC_TypeDef *RTCx, uint32_t Duration)
2236 {
2237 MODIFY_REG(RTCx->TAFCR, RTC_TAFCR_TAMPPRCH, Duration);
2238 }
2239
2240 /**
2241 * @brief Get RTC_TAMPx precharge duration
2242 * @rmtoll TAFCR TAMPPRCH LL_RTC_TAMPER_GetPrecharge
2243 * @param RTCx RTC Instance
2244 * @retval Returned value can be one of the following values:
2245 * @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
2246 * @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
2247 * @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
2248 * @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
2249 */
LL_RTC_TAMPER_GetPrecharge(RTC_TypeDef * RTCx)2250 __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetPrecharge(RTC_TypeDef *RTCx)
2251 {
2252 return (uint32_t)(READ_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPPRCH));
2253 }
2254
2255 /**
2256 * @brief Set RTC_TAMPx filter count
2257 * @rmtoll TAFCR TAMPFLT LL_RTC_TAMPER_SetFilterCount
2258 * @param RTCx RTC Instance
2259 * @param FilterCount This parameter can be one of the following values:
2260 * @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
2261 * @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
2262 * @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
2263 * @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
2264 * @retval None
2265 */
LL_RTC_TAMPER_SetFilterCount(RTC_TypeDef * RTCx,uint32_t FilterCount)2266 __STATIC_INLINE void LL_RTC_TAMPER_SetFilterCount(RTC_TypeDef *RTCx, uint32_t FilterCount)
2267 {
2268 MODIFY_REG(RTCx->TAFCR, RTC_TAFCR_TAMPFLT, FilterCount);
2269 }
2270
2271 /**
2272 * @brief Get RTC_TAMPx filter count
2273 * @rmtoll TAFCR TAMPFLT LL_RTC_TAMPER_GetFilterCount
2274 * @param RTCx RTC Instance
2275 * @retval Returned value can be one of the following values:
2276 * @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
2277 * @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
2278 * @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
2279 * @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
2280 */
LL_RTC_TAMPER_GetFilterCount(RTC_TypeDef * RTCx)2281 __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetFilterCount(RTC_TypeDef *RTCx)
2282 {
2283 return (uint32_t)(READ_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPFLT));
2284 }
2285
2286 /**
2287 * @brief Set Tamper sampling frequency
2288 * @rmtoll TAFCR TAMPFREQ LL_RTC_TAMPER_SetSamplingFreq
2289 * @param RTCx RTC Instance
2290 * @param SamplingFreq This parameter can be one of the following values:
2291 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
2292 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
2293 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
2294 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
2295 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
2296 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
2297 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
2298 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
2299 * @retval None
2300 */
LL_RTC_TAMPER_SetSamplingFreq(RTC_TypeDef * RTCx,uint32_t SamplingFreq)2301 __STATIC_INLINE void LL_RTC_TAMPER_SetSamplingFreq(RTC_TypeDef *RTCx, uint32_t SamplingFreq)
2302 {
2303 MODIFY_REG(RTCx->TAFCR, RTC_TAFCR_TAMPFREQ, SamplingFreq);
2304 }
2305
2306 /**
2307 * @brief Get Tamper sampling frequency
2308 * @rmtoll TAFCR TAMPFREQ LL_RTC_TAMPER_GetSamplingFreq
2309 * @param RTCx RTC Instance
2310 * @retval Returned value can be one of the following values:
2311 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
2312 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
2313 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
2314 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
2315 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
2316 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
2317 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
2318 * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
2319 */
LL_RTC_TAMPER_GetSamplingFreq(RTC_TypeDef * RTCx)2320 __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetSamplingFreq(RTC_TypeDef *RTCx)
2321 {
2322 return (uint32_t)(READ_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPFREQ));
2323 }
2324
2325 /**
2326 * @brief Enable Active level for Tamper input
2327 * @rmtoll TAFCR TAMP1TRG LL_RTC_TAMPER_EnableActiveLevel\n
2328 * TAFCR TAMP2TRG LL_RTC_TAMPER_EnableActiveLevel\n
2329 * TAFCR TAMP3TRG LL_RTC_TAMPER_EnableActiveLevel
2330 * @param RTCx RTC Instance
2331 * @param Tamper This parameter can be a combination of the following values:
2332 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1
2333 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2
2334 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP3 (*)
2335 *
2336 * (*) value not applicable to all devices.
2337 * @retval None
2338 */
LL_RTC_TAMPER_EnableActiveLevel(RTC_TypeDef * RTCx,uint32_t Tamper)2339 __STATIC_INLINE void LL_RTC_TAMPER_EnableActiveLevel(RTC_TypeDef *RTCx, uint32_t Tamper)
2340 {
2341 SET_BIT(RTCx->TAFCR, Tamper);
2342 }
2343
2344 /**
2345 * @brief Disable Active level for Tamper input
2346 * @rmtoll TAFCR TAMP1TRG LL_RTC_TAMPER_DisableActiveLevel\n
2347 * TAFCR TAMP2TRG LL_RTC_TAMPER_DisableActiveLevel\n
2348 * TAFCR TAMP3TRG LL_RTC_TAMPER_DisableActiveLevel
2349 * @param RTCx RTC Instance
2350 * @param Tamper This parameter can be a combination of the following values:
2351 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1
2352 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2
2353 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP3 (*)
2354 *
2355 * (*) value not applicable to all devices.
2356 * @retval None
2357 */
LL_RTC_TAMPER_DisableActiveLevel(RTC_TypeDef * RTCx,uint32_t Tamper)2358 __STATIC_INLINE void LL_RTC_TAMPER_DisableActiveLevel(RTC_TypeDef *RTCx, uint32_t Tamper)
2359 {
2360 CLEAR_BIT(RTCx->TAFCR, Tamper);
2361 }
2362
2363 /**
2364 * @}
2365 */
2366
2367 #if defined(RTC_WAKEUP_SUPPORT)
2368 /** @defgroup RTC_LL_EF_Wakeup Wakeup
2369 * @{
2370 */
2371
2372 /**
2373 * @brief Enable Wakeup timer
2374 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2375 * @rmtoll CR WUTE LL_RTC_WAKEUP_Enable
2376 * @param RTCx RTC Instance
2377 * @retval None
2378 */
LL_RTC_WAKEUP_Enable(RTC_TypeDef * RTCx)2379 __STATIC_INLINE void LL_RTC_WAKEUP_Enable(RTC_TypeDef *RTCx)
2380 {
2381 SET_BIT(RTCx->CR, RTC_CR_WUTE);
2382 }
2383
2384 /**
2385 * @brief Disable Wakeup timer
2386 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2387 * @rmtoll CR WUTE LL_RTC_WAKEUP_Disable
2388 * @param RTCx RTC Instance
2389 * @retval None
2390 */
LL_RTC_WAKEUP_Disable(RTC_TypeDef * RTCx)2391 __STATIC_INLINE void LL_RTC_WAKEUP_Disable(RTC_TypeDef *RTCx)
2392 {
2393 CLEAR_BIT(RTCx->CR, RTC_CR_WUTE);
2394 }
2395
2396 /**
2397 * @brief Check if Wakeup timer is enabled or not
2398 * @rmtoll CR WUTE LL_RTC_WAKEUP_IsEnabled
2399 * @param RTCx RTC Instance
2400 * @retval State of bit (1 or 0).
2401 */
LL_RTC_WAKEUP_IsEnabled(RTC_TypeDef * RTCx)2402 __STATIC_INLINE uint32_t LL_RTC_WAKEUP_IsEnabled(RTC_TypeDef *RTCx)
2403 {
2404 return ((READ_BIT(RTCx->CR, RTC_CR_WUTE) == (RTC_CR_WUTE)) ? 1UL : 0UL);
2405 }
2406
2407 /**
2408 * @brief Select Wakeup clock
2409 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2410 * @note Bit can be written only when RTC_CR WUTE bit = 0 and RTC_ISR WUTWF bit = 1
2411 * @rmtoll CR WUCKSEL LL_RTC_WAKEUP_SetClock
2412 * @param RTCx RTC Instance
2413 * @param WakeupClock This parameter can be one of the following values:
2414 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
2415 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
2416 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
2417 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
2418 * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
2419 * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
2420 * @retval None
2421 */
LL_RTC_WAKEUP_SetClock(RTC_TypeDef * RTCx,uint32_t WakeupClock)2422 __STATIC_INLINE void LL_RTC_WAKEUP_SetClock(RTC_TypeDef *RTCx, uint32_t WakeupClock)
2423 {
2424 MODIFY_REG(RTCx->CR, RTC_CR_WUCKSEL, WakeupClock);
2425 }
2426
2427 /**
2428 * @brief Get Wakeup clock
2429 * @rmtoll CR WUCKSEL LL_RTC_WAKEUP_GetClock
2430 * @param RTCx RTC Instance
2431 * @retval Returned value can be one of the following values:
2432 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
2433 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
2434 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
2435 * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
2436 * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
2437 * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
2438 */
LL_RTC_WAKEUP_GetClock(RTC_TypeDef * RTCx)2439 __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetClock(RTC_TypeDef *RTCx)
2440 {
2441 return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_WUCKSEL));
2442 }
2443
2444 /**
2445 * @brief Set Wakeup auto-reload value
2446 * @note Bit can be written only when WUTWF is set to 1 in RTC_ISR
2447 * @rmtoll WUTR WUT LL_RTC_WAKEUP_SetAutoReload
2448 * @param RTCx RTC Instance
2449 * @param Value Value between Min_Data=0x00 and Max_Data=0xFFFF
2450 * @retval None
2451 */
LL_RTC_WAKEUP_SetAutoReload(RTC_TypeDef * RTCx,uint32_t Value)2452 __STATIC_INLINE void LL_RTC_WAKEUP_SetAutoReload(RTC_TypeDef *RTCx, uint32_t Value)
2453 {
2454 MODIFY_REG(RTCx->WUTR, RTC_WUTR_WUT, Value);
2455 }
2456
2457 /**
2458 * @brief Get Wakeup auto-reload value
2459 * @rmtoll WUTR WUT LL_RTC_WAKEUP_GetAutoReload
2460 * @param RTCx RTC Instance
2461 * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF
2462 */
LL_RTC_WAKEUP_GetAutoReload(RTC_TypeDef * RTCx)2463 __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetAutoReload(RTC_TypeDef *RTCx)
2464 {
2465 return (uint32_t)(READ_BIT(RTCx->WUTR, RTC_WUTR_WUT));
2466 }
2467
2468 /**
2469 * @}
2470 */
2471 #endif /* RTC_WAKEUP_SUPPORT */
2472
2473 #if defined(RTC_BACKUP_SUPPORT)
2474 /** @defgroup RTC_LL_EF_Backup_Registers Backup_Registers
2475 * @{
2476 */
2477
2478 /**
2479 * @brief Writes a data in a specified RTC Backup data register.
2480 * @rmtoll BKPxR BKP LL_RTC_BAK_SetRegister
2481 * @param RTCx RTC Instance
2482 * @param BackupRegister This parameter can be one of the following values:
2483 * @arg @ref LL_RTC_BKP_DR0
2484 * @arg @ref LL_RTC_BKP_DR1
2485 * @arg @ref LL_RTC_BKP_DR2
2486 * @arg @ref LL_RTC_BKP_DR3
2487 * @arg @ref LL_RTC_BKP_DR4
2488 * @param Data Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
2489 * @retval None
2490 */
LL_RTC_BAK_SetRegister(RTC_TypeDef * RTCx,uint32_t BackupRegister,uint32_t Data)2491 __STATIC_INLINE void LL_RTC_BAK_SetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister, uint32_t Data)
2492 {
2493 uint32_t temp;
2494
2495 temp = (uint32_t)(&(RTCx->BKP0R));
2496 temp += (BackupRegister * 4U);
2497
2498 /* Write the specified register */
2499 *(__IO uint32_t *)temp = (uint32_t)Data;
2500 }
2501
2502 /**
2503 * @brief Reads data from the specified RTC Backup data Register.
2504 * @rmtoll BKPxR BKP LL_RTC_BAK_GetRegister
2505 * @param RTCx RTC Instance
2506 * @param BackupRegister This parameter can be one of the following values:
2507 * @arg @ref LL_RTC_BKP_DR0
2508 * @arg @ref LL_RTC_BKP_DR1
2509 * @arg @ref LL_RTC_BKP_DR2
2510 * @arg @ref LL_RTC_BKP_DR3
2511 * @arg @ref LL_RTC_BKP_DR4
2512 * @retval Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
2513 */
LL_RTC_BAK_GetRegister(RTC_TypeDef * RTCx,uint32_t BackupRegister)2514 __STATIC_INLINE uint32_t LL_RTC_BAK_GetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister)
2515 {
2516 uint32_t temp;
2517
2518 temp = (uint32_t)(&(RTCx->BKP0R));
2519 temp += (BackupRegister * 4U);
2520
2521 /* Read the specified register */
2522 return (*(__IO uint32_t *)temp);
2523 }
2524
2525 /**
2526 * @}
2527 */
2528 #endif /* RTC_BACKUP_SUPPORT */
2529
2530 /** @defgroup RTC_LL_EF_Calibration Calibration
2531 * @{
2532 */
2533
2534 /**
2535 * @brief Set Calibration output frequency (1 Hz or 512 Hz)
2536 * @note Bits are write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2537 * @rmtoll CR COE LL_RTC_CAL_SetOutputFreq\n
2538 * CR COSEL LL_RTC_CAL_SetOutputFreq
2539 * @param RTCx RTC Instance
2540 * @param Frequency This parameter can be one of the following values:
2541 * @arg @ref LL_RTC_CALIB_OUTPUT_NONE
2542 * @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
2543 * @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
2544 *
2545 * @retval None
2546 */
LL_RTC_CAL_SetOutputFreq(RTC_TypeDef * RTCx,uint32_t Frequency)2547 __STATIC_INLINE void LL_RTC_CAL_SetOutputFreq(RTC_TypeDef *RTCx, uint32_t Frequency)
2548 {
2549 MODIFY_REG(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL, Frequency);
2550 }
2551
2552 /**
2553 * @brief Get Calibration output frequency (1 Hz or 512 Hz)
2554 * @rmtoll CR COE LL_RTC_CAL_GetOutputFreq\n
2555 * CR COSEL LL_RTC_CAL_GetOutputFreq
2556 * @param RTCx RTC Instance
2557 * @retval Returned value can be one of the following values:
2558 * @arg @ref LL_RTC_CALIB_OUTPUT_NONE
2559 * @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
2560 * @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
2561 *
2562 */
LL_RTC_CAL_GetOutputFreq(RTC_TypeDef * RTCx)2563 __STATIC_INLINE uint32_t LL_RTC_CAL_GetOutputFreq(RTC_TypeDef *RTCx)
2564 {
2565 return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL));
2566 }
2567
2568 /**
2569 * @brief Insert or not One RTCCLK pulse every 2exp11 pulses (frequency increased by 488.5 ppm)
2570 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2571 * @note Bit can be written only when RECALPF is set to 0 in RTC_ISR
2572 * @rmtoll CALR CALP LL_RTC_CAL_SetPulse
2573 * @param RTCx RTC Instance
2574 * @param Pulse This parameter can be one of the following values:
2575 * @arg @ref LL_RTC_CALIB_INSERTPULSE_NONE
2576 * @arg @ref LL_RTC_CALIB_INSERTPULSE_SET
2577 * @retval None
2578 */
LL_RTC_CAL_SetPulse(RTC_TypeDef * RTCx,uint32_t Pulse)2579 __STATIC_INLINE void LL_RTC_CAL_SetPulse(RTC_TypeDef *RTCx, uint32_t Pulse)
2580 {
2581 MODIFY_REG(RTCx->CALR, RTC_CALR_CALP, Pulse);
2582 }
2583
2584 /**
2585 * @brief Check if one RTCCLK has been inserted or not every 2exp11 pulses (frequency increased by 488.5 ppm)
2586 * @rmtoll CALR CALP LL_RTC_CAL_IsPulseInserted
2587 * @param RTCx RTC Instance
2588 * @retval State of bit (1 or 0).
2589 */
LL_RTC_CAL_IsPulseInserted(RTC_TypeDef * RTCx)2590 __STATIC_INLINE uint32_t LL_RTC_CAL_IsPulseInserted(RTC_TypeDef *RTCx)
2591 {
2592 return ((READ_BIT(RTCx->CALR, RTC_CALR_CALP) == (RTC_CALR_CALP)) ? 1UL : 0UL);
2593 }
2594
2595 /**
2596 * @brief Set smooth calibration cycle period
2597 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2598 * @note Bit can be written only when RECALPF is set to 0 in RTC_ISR
2599 * @rmtoll CALR CALW8 LL_RTC_CAL_SetPeriod\n
2600 * CALR CALW16 LL_RTC_CAL_SetPeriod
2601 * @param RTCx RTC Instance
2602 * @param Period This parameter can be one of the following values:
2603 * @arg @ref LL_RTC_CALIB_PERIOD_32SEC
2604 * @arg @ref LL_RTC_CALIB_PERIOD_16SEC
2605 * @arg @ref LL_RTC_CALIB_PERIOD_8SEC
2606 * @retval None
2607 */
LL_RTC_CAL_SetPeriod(RTC_TypeDef * RTCx,uint32_t Period)2608 __STATIC_INLINE void LL_RTC_CAL_SetPeriod(RTC_TypeDef *RTCx, uint32_t Period)
2609 {
2610 MODIFY_REG(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16, Period);
2611 }
2612
2613 /**
2614 * @brief Get smooth calibration cycle period
2615 * @rmtoll CALR CALW8 LL_RTC_CAL_GetPeriod\n
2616 * CALR CALW16 LL_RTC_CAL_GetPeriod
2617 * @param RTCx RTC Instance
2618 * @retval Returned value can be one of the following values:
2619 * @arg @ref LL_RTC_CALIB_PERIOD_32SEC
2620 * @arg @ref LL_RTC_CALIB_PERIOD_16SEC
2621 * @arg @ref LL_RTC_CALIB_PERIOD_8SEC
2622 */
LL_RTC_CAL_GetPeriod(RTC_TypeDef * RTCx)2623 __STATIC_INLINE uint32_t LL_RTC_CAL_GetPeriod(RTC_TypeDef *RTCx)
2624 {
2625 return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16));
2626 }
2627
2628 /**
2629 * @brief Set smooth Calibration minus
2630 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2631 * @note Bit can be written only when RECALPF is set to 0 in RTC_ISR
2632 * @rmtoll CALR CALM LL_RTC_CAL_SetMinus
2633 * @param RTCx RTC Instance
2634 * @param CalibMinus Value between Min_Data=0x00 and Max_Data=0x1FF
2635 * @retval None
2636 */
LL_RTC_CAL_SetMinus(RTC_TypeDef * RTCx,uint32_t CalibMinus)2637 __STATIC_INLINE void LL_RTC_CAL_SetMinus(RTC_TypeDef *RTCx, uint32_t CalibMinus)
2638 {
2639 MODIFY_REG(RTCx->CALR, RTC_CALR_CALM, CalibMinus);
2640 }
2641
2642 /**
2643 * @brief Get smooth Calibration minus
2644 * @rmtoll CALR CALM LL_RTC_CAL_GetMinus
2645 * @param RTCx RTC Instance
2646 * @retval Value between Min_Data=0x00 and Max_Data= 0x1FF
2647 */
LL_RTC_CAL_GetMinus(RTC_TypeDef * RTCx)2648 __STATIC_INLINE uint32_t LL_RTC_CAL_GetMinus(RTC_TypeDef *RTCx)
2649 {
2650 return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALM));
2651 }
2652
2653 /**
2654 * @}
2655 */
2656
2657 /** @defgroup RTC_LL_EF_FLAG_Management FLAG_Management
2658 * @{
2659 */
2660
2661 /**
2662 * @brief Get Recalibration pending Flag
2663 * @rmtoll ISR RECALPF LL_RTC_IsActiveFlag_RECALP
2664 * @param RTCx RTC Instance
2665 * @retval State of bit (1 or 0).
2666 */
LL_RTC_IsActiveFlag_RECALP(RTC_TypeDef * RTCx)2667 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RECALP(RTC_TypeDef *RTCx)
2668 {
2669 return ((READ_BIT(RTCx->ISR, RTC_ISR_RECALPF) == (RTC_ISR_RECALPF)) ? 1UL : 0UL);
2670 }
2671
2672 #if defined(RTC_TAMPER3_SUPPORT)
2673 /**
2674 * @brief Get RTC_TAMP3 detection flag
2675 * @rmtoll ISR TAMP3F LL_RTC_IsActiveFlag_TAMP3
2676 * @param RTCx RTC Instance
2677 * @retval State of bit (1 or 0).
2678 */
LL_RTC_IsActiveFlag_TAMP3(RTC_TypeDef * RTCx)2679 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP3(RTC_TypeDef *RTCx)
2680 {
2681 return ((READ_BIT(RTCx->ISR, RTC_ISR_TAMP3F) == (RTC_ISR_TAMP3F)) ? 1UL : 0UL);
2682 }
2683 #endif /* RTC_TAMPER3_SUPPORT */
2684
2685 /**
2686 * @brief Get RTC_TAMP2 detection flag
2687 * @rmtoll ISR TAMP2F LL_RTC_IsActiveFlag_TAMP2
2688 * @param RTCx RTC Instance
2689 * @retval State of bit (1 or 0).
2690 */
LL_RTC_IsActiveFlag_TAMP2(RTC_TypeDef * RTCx)2691 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP2(RTC_TypeDef *RTCx)
2692 {
2693 return ((READ_BIT(RTCx->ISR, RTC_ISR_TAMP2F) == (RTC_ISR_TAMP2F)) ? 1UL : 0UL);
2694 }
2695
2696 /**
2697 * @brief Get RTC_TAMP1 detection flag
2698 * @rmtoll ISR TAMP1F LL_RTC_IsActiveFlag_TAMP1
2699 * @param RTCx RTC Instance
2700 * @retval State of bit (1 or 0).
2701 */
LL_RTC_IsActiveFlag_TAMP1(RTC_TypeDef * RTCx)2702 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP1(RTC_TypeDef *RTCx)
2703 {
2704 return ((READ_BIT(RTCx->ISR, RTC_ISR_TAMP1F) == (RTC_ISR_TAMP1F)) ? 1UL : 0UL);
2705 }
2706
2707 /**
2708 * @brief Get Time-stamp overflow flag
2709 * @rmtoll ISR TSOVF LL_RTC_IsActiveFlag_TSOV
2710 * @param RTCx RTC Instance
2711 * @retval State of bit (1 or 0).
2712 */
LL_RTC_IsActiveFlag_TSOV(RTC_TypeDef * RTCx)2713 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSOV(RTC_TypeDef *RTCx)
2714 {
2715 return ((READ_BIT(RTCx->ISR, RTC_ISR_TSOVF) == (RTC_ISR_TSOVF)) ? 1UL : 0UL);
2716 }
2717
2718 /**
2719 * @brief Get Time-stamp flag
2720 * @rmtoll ISR TSF LL_RTC_IsActiveFlag_TS
2721 * @param RTCx RTC Instance
2722 * @retval State of bit (1 or 0).
2723 */
LL_RTC_IsActiveFlag_TS(RTC_TypeDef * RTCx)2724 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TS(RTC_TypeDef *RTCx)
2725 {
2726 return ((READ_BIT(RTCx->ISR, RTC_ISR_TSF) == (RTC_ISR_TSF)) ? 1UL : 0UL);
2727 }
2728
2729 #if defined(RTC_WAKEUP_SUPPORT)
2730 /**
2731 * @brief Get Wakeup timer flag
2732 * @rmtoll ISR WUTF LL_RTC_IsActiveFlag_WUT
2733 * @param RTCx RTC Instance
2734 * @retval State of bit (1 or 0).
2735 */
LL_RTC_IsActiveFlag_WUT(RTC_TypeDef * RTCx)2736 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUT(RTC_TypeDef *RTCx)
2737 {
2738 return ((READ_BIT(RTCx->ISR, RTC_ISR_WUTF) == (RTC_ISR_WUTF)) ? 1UL : 0UL);
2739 }
2740 #endif /* RTC_WAKEUP_SUPPORT */
2741
2742 /**
2743 * @brief Get Alarm A flag
2744 * @rmtoll ISR ALRAF LL_RTC_IsActiveFlag_ALRA
2745 * @param RTCx RTC Instance
2746 * @retval State of bit (1 or 0).
2747 */
LL_RTC_IsActiveFlag_ALRA(RTC_TypeDef * RTCx)2748 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRA(RTC_TypeDef *RTCx)
2749 {
2750 return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRAF) == (RTC_ISR_ALRAF)) ? 1UL : 0UL);
2751 }
2752
2753 #if defined(RTC_TAMPER3_SUPPORT)
2754 /**
2755 * @brief Clear RTC_TAMP3 detection flag
2756 * @rmtoll ISR TAMP3F LL_RTC_ClearFlag_TAMP3
2757 * @param RTCx RTC Instance
2758 * @retval None
2759 */
LL_RTC_ClearFlag_TAMP3(RTC_TypeDef * RTCx)2760 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP3(RTC_TypeDef *RTCx)
2761 {
2762 WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP3F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
2763 }
2764 #endif /* RTC_TAMPER3_SUPPORT */
2765
2766 /**
2767 * @brief Clear RTC_TAMP2 detection flag
2768 * @rmtoll ISR TAMP2F LL_RTC_ClearFlag_TAMP2
2769 * @param RTCx RTC Instance
2770 * @retval None
2771 */
LL_RTC_ClearFlag_TAMP2(RTC_TypeDef * RTCx)2772 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP2(RTC_TypeDef *RTCx)
2773 {
2774 WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP2F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
2775 }
2776
2777 /**
2778 * @brief Clear RTC_TAMP1 detection flag
2779 * @rmtoll ISR TAMP1F LL_RTC_ClearFlag_TAMP1
2780 * @param RTCx RTC Instance
2781 * @retval None
2782 */
LL_RTC_ClearFlag_TAMP1(RTC_TypeDef * RTCx)2783 __STATIC_INLINE void LL_RTC_ClearFlag_TAMP1(RTC_TypeDef *RTCx)
2784 {
2785 WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP1F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
2786 }
2787
2788 /**
2789 * @brief Clear Time-stamp overflow flag
2790 * @rmtoll ISR TSOVF LL_RTC_ClearFlag_TSOV
2791 * @param RTCx RTC Instance
2792 * @retval None
2793 */
LL_RTC_ClearFlag_TSOV(RTC_TypeDef * RTCx)2794 __STATIC_INLINE void LL_RTC_ClearFlag_TSOV(RTC_TypeDef *RTCx)
2795 {
2796 WRITE_REG(RTCx->ISR, (~((RTC_ISR_TSOVF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
2797 }
2798
2799 /**
2800 * @brief Clear Time-stamp flag
2801 * @rmtoll ISR TSF LL_RTC_ClearFlag_TS
2802 * @param RTCx RTC Instance
2803 * @retval None
2804 */
LL_RTC_ClearFlag_TS(RTC_TypeDef * RTCx)2805 __STATIC_INLINE void LL_RTC_ClearFlag_TS(RTC_TypeDef *RTCx)
2806 {
2807 WRITE_REG(RTCx->ISR, (~((RTC_ISR_TSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
2808 }
2809
2810 #if defined(RTC_WAKEUP_SUPPORT)
2811 /**
2812 * @brief Clear Wakeup timer flag
2813 * @rmtoll ISR WUTF LL_RTC_ClearFlag_WUT
2814 * @param RTCx RTC Instance
2815 * @retval None
2816 */
LL_RTC_ClearFlag_WUT(RTC_TypeDef * RTCx)2817 __STATIC_INLINE void LL_RTC_ClearFlag_WUT(RTC_TypeDef *RTCx)
2818 {
2819 WRITE_REG(RTCx->ISR, (~((RTC_ISR_WUTF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
2820 }
2821 #endif /* RTC_WAKEUP_SUPPORT */
2822
2823 /**
2824 * @brief Clear Alarm A flag
2825 * @rmtoll ISR ALRAF LL_RTC_ClearFlag_ALRA
2826 * @param RTCx RTC Instance
2827 * @retval None
2828 */
LL_RTC_ClearFlag_ALRA(RTC_TypeDef * RTCx)2829 __STATIC_INLINE void LL_RTC_ClearFlag_ALRA(RTC_TypeDef *RTCx)
2830 {
2831 WRITE_REG(RTCx->ISR, (~((RTC_ISR_ALRAF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
2832 }
2833
2834 /**
2835 * @brief Get Initialization flag
2836 * @rmtoll ISR INITF LL_RTC_IsActiveFlag_INIT
2837 * @param RTCx RTC Instance
2838 * @retval State of bit (1 or 0).
2839 */
LL_RTC_IsActiveFlag_INIT(RTC_TypeDef * RTCx)2840 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INIT(RTC_TypeDef *RTCx)
2841 {
2842 return ((READ_BIT(RTCx->ISR, RTC_ISR_INITF) == (RTC_ISR_INITF)) ? 1UL : 0UL);
2843 }
2844
2845 /**
2846 * @brief Get Registers synchronization flag
2847 * @rmtoll ISR RSF LL_RTC_IsActiveFlag_RS
2848 * @param RTCx RTC Instance
2849 * @retval State of bit (1 or 0).
2850 */
LL_RTC_IsActiveFlag_RS(RTC_TypeDef * RTCx)2851 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(RTC_TypeDef *RTCx)
2852 {
2853 return ((READ_BIT(RTCx->ISR, RTC_ISR_RSF) == (RTC_ISR_RSF)) ? 1UL : 0UL);
2854 }
2855
2856 /**
2857 * @brief Clear Registers synchronization flag
2858 * @rmtoll ISR RSF LL_RTC_ClearFlag_RS
2859 * @param RTCx RTC Instance
2860 * @retval None
2861 */
LL_RTC_ClearFlag_RS(RTC_TypeDef * RTCx)2862 __STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx)
2863 {
2864 WRITE_REG(RTCx->ISR, (~((RTC_ISR_RSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
2865 }
2866
2867 /**
2868 * @brief Get Initialization status flag
2869 * @rmtoll ISR INITS LL_RTC_IsActiveFlag_INITS
2870 * @param RTCx RTC Instance
2871 * @retval State of bit (1 or 0).
2872 */
LL_RTC_IsActiveFlag_INITS(RTC_TypeDef * RTCx)2873 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INITS(RTC_TypeDef *RTCx)
2874 {
2875 return ((READ_BIT(RTCx->ISR, RTC_ISR_INITS) == (RTC_ISR_INITS)) ? 1UL : 0UL);
2876 }
2877
2878 /**
2879 * @brief Get Shift operation pending flag
2880 * @rmtoll ISR SHPF LL_RTC_IsActiveFlag_SHP
2881 * @param RTCx RTC Instance
2882 * @retval State of bit (1 or 0).
2883 */
LL_RTC_IsActiveFlag_SHP(RTC_TypeDef * RTCx)2884 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SHP(RTC_TypeDef *RTCx)
2885 {
2886 return ((READ_BIT(RTCx->ISR, RTC_ISR_SHPF) == (RTC_ISR_SHPF)) ? 1UL : 0UL);
2887 }
2888
2889 #if defined(RTC_WAKEUP_SUPPORT)
2890 /**
2891 * @brief Get Wakeup timer write flag
2892 * @rmtoll ISR WUTWF LL_RTC_IsActiveFlag_WUTW
2893 * @param RTCx RTC Instance
2894 * @retval State of bit (1 or 0).
2895 */
LL_RTC_IsActiveFlag_WUTW(RTC_TypeDef * RTCx)2896 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUTW(RTC_TypeDef *RTCx)
2897 {
2898 return ((READ_BIT(RTCx->ISR, RTC_ISR_WUTWF) == (RTC_ISR_WUTWF)) ? 1UL : 0UL);
2899 }
2900 #endif /* RTC_WAKEUP_SUPPORT */
2901
2902 /**
2903 * @brief Get Alarm A write flag
2904 * @rmtoll ISR ALRAWF LL_RTC_IsActiveFlag_ALRAW
2905 * @param RTCx RTC Instance
2906 * @retval State of bit (1 or 0).
2907 */
LL_RTC_IsActiveFlag_ALRAW(RTC_TypeDef * RTCx)2908 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRAW(RTC_TypeDef *RTCx)
2909 {
2910 return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRAWF) == (RTC_ISR_ALRAWF)) ? 1UL : 0UL);
2911 }
2912
2913 /**
2914 * @}
2915 */
2916
2917 /** @defgroup RTC_LL_EF_IT_Management IT_Management
2918 * @{
2919 */
2920
2921 /**
2922 * @brief Enable Time-stamp interrupt
2923 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2924 * @rmtoll CR TSIE LL_RTC_EnableIT_TS
2925 * @param RTCx RTC Instance
2926 * @retval None
2927 */
LL_RTC_EnableIT_TS(RTC_TypeDef * RTCx)2928 __STATIC_INLINE void LL_RTC_EnableIT_TS(RTC_TypeDef *RTCx)
2929 {
2930 SET_BIT(RTCx->CR, RTC_CR_TSIE);
2931 }
2932
2933 /**
2934 * @brief Disable Time-stamp interrupt
2935 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2936 * @rmtoll CR TSIE LL_RTC_DisableIT_TS
2937 * @param RTCx RTC Instance
2938 * @retval None
2939 */
LL_RTC_DisableIT_TS(RTC_TypeDef * RTCx)2940 __STATIC_INLINE void LL_RTC_DisableIT_TS(RTC_TypeDef *RTCx)
2941 {
2942 CLEAR_BIT(RTCx->CR, RTC_CR_TSIE);
2943 }
2944
2945 #if defined(RTC_WAKEUP_SUPPORT)
2946 /**
2947 * @brief Enable Wakeup timer interrupt
2948 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2949 * @rmtoll CR WUTIE LL_RTC_EnableIT_WUT
2950 * @param RTCx RTC Instance
2951 * @retval None
2952 */
LL_RTC_EnableIT_WUT(RTC_TypeDef * RTCx)2953 __STATIC_INLINE void LL_RTC_EnableIT_WUT(RTC_TypeDef *RTCx)
2954 {
2955 SET_BIT(RTCx->CR, RTC_CR_WUTIE);
2956 }
2957
2958 /**
2959 * @brief Disable Wakeup timer interrupt
2960 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2961 * @rmtoll CR WUTIE LL_RTC_DisableIT_WUT
2962 * @param RTCx RTC Instance
2963 * @retval None
2964 */
LL_RTC_DisableIT_WUT(RTC_TypeDef * RTCx)2965 __STATIC_INLINE void LL_RTC_DisableIT_WUT(RTC_TypeDef *RTCx)
2966 {
2967 CLEAR_BIT(RTCx->CR, RTC_CR_WUTIE);
2968 }
2969 #endif /* RTC_WAKEUP_SUPPORT */
2970
2971 /**
2972 * @brief Enable Alarm A interrupt
2973 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2974 * @rmtoll CR ALRAIE LL_RTC_EnableIT_ALRA
2975 * @param RTCx RTC Instance
2976 * @retval None
2977 */
LL_RTC_EnableIT_ALRA(RTC_TypeDef * RTCx)2978 __STATIC_INLINE void LL_RTC_EnableIT_ALRA(RTC_TypeDef *RTCx)
2979 {
2980 SET_BIT(RTCx->CR, RTC_CR_ALRAIE);
2981 }
2982
2983 /**
2984 * @brief Disable Alarm A interrupt
2985 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
2986 * @rmtoll CR ALRAIE LL_RTC_DisableIT_ALRA
2987 * @param RTCx RTC Instance
2988 * @retval None
2989 */
LL_RTC_DisableIT_ALRA(RTC_TypeDef * RTCx)2990 __STATIC_INLINE void LL_RTC_DisableIT_ALRA(RTC_TypeDef *RTCx)
2991 {
2992 CLEAR_BIT(RTCx->CR, RTC_CR_ALRAIE);
2993 }
2994
2995 /**
2996 * @brief Enable all Tamper Interrupt
2997 * @rmtoll TAFCR TAMPIE LL_RTC_EnableIT_TAMP
2998 * @param RTCx RTC Instance
2999 * @retval None
3000 */
LL_RTC_EnableIT_TAMP(RTC_TypeDef * RTCx)3001 __STATIC_INLINE void LL_RTC_EnableIT_TAMP(RTC_TypeDef *RTCx)
3002 {
3003 SET_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPIE);
3004 }
3005
3006 /**
3007 * @brief Disable all Tamper Interrupt
3008 * @rmtoll TAFCR TAMPIE LL_RTC_DisableIT_TAMP
3009 * @param RTCx RTC Instance
3010 * @retval None
3011 */
LL_RTC_DisableIT_TAMP(RTC_TypeDef * RTCx)3012 __STATIC_INLINE void LL_RTC_DisableIT_TAMP(RTC_TypeDef *RTCx)
3013 {
3014 CLEAR_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPIE);
3015 }
3016
3017 /**
3018 * @brief Check if Time-stamp interrupt is enabled or not
3019 * @rmtoll CR TSIE LL_RTC_IsEnabledIT_TS
3020 * @param RTCx RTC Instance
3021 * @retval State of bit (1 or 0).
3022 */
LL_RTC_IsEnabledIT_TS(RTC_TypeDef * RTCx)3023 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TS(RTC_TypeDef *RTCx)
3024 {
3025 return ((READ_BIT(RTCx->CR, RTC_CR_TSIE) == (RTC_CR_TSIE)) ? 1UL : 0UL);
3026 }
3027
3028 #if defined(RTC_WAKEUP_SUPPORT)
3029 /**
3030 * @brief Check if Wakeup timer interrupt is enabled or not
3031 * @rmtoll CR WUTIE LL_RTC_IsEnabledIT_WUT
3032 * @param RTCx RTC Instance
3033 * @retval State of bit (1 or 0).
3034 */
LL_RTC_IsEnabledIT_WUT(RTC_TypeDef * RTCx)3035 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_WUT(RTC_TypeDef *RTCx)
3036 {
3037 return ((READ_BIT(RTCx->CR, RTC_CR_WUTIE) == (RTC_CR_WUTIE)) ? 1UL : 0UL);
3038 }
3039 #endif /* RTC_WAKEUP_SUPPORT */
3040
3041 /**
3042 * @brief Check if Alarm A interrupt is enabled or not
3043 * @rmtoll CR ALRAIE LL_RTC_IsEnabledIT_ALRA
3044 * @param RTCx RTC Instance
3045 * @retval State of bit (1 or 0).
3046 */
LL_RTC_IsEnabledIT_ALRA(RTC_TypeDef * RTCx)3047 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRA(RTC_TypeDef *RTCx)
3048 {
3049 return ((READ_BIT(RTCx->CR, RTC_CR_ALRAIE) == (RTC_CR_ALRAIE)) ? 1UL : 0UL);
3050 }
3051
3052 /**
3053 * @brief Check if all the TAMPER interrupts are enabled or not
3054 * @rmtoll TAFCR TAMPIE LL_RTC_IsEnabledIT_TAMP
3055 * @param RTCx RTC Instance
3056 * @retval State of bit (1 or 0).
3057 */
LL_RTC_IsEnabledIT_TAMP(RTC_TypeDef * RTCx)3058 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP(RTC_TypeDef *RTCx)
3059 {
3060 return ((READ_BIT(RTCx->TAFCR,
3061 RTC_TAFCR_TAMPIE) == (RTC_TAFCR_TAMPIE)) ? 1UL : 0UL);
3062 }
3063
3064 /**
3065 * @}
3066 */
3067
3068 #if defined(USE_FULL_LL_DRIVER)
3069 /** @defgroup RTC_LL_EF_Init Initialization and de-initialization functions
3070 * @{
3071 */
3072
3073 ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx);
3074 ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct);
3075 void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct);
3076 ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct);
3077 void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct);
3078 ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct);
3079 void LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct);
3080 ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
3081 void LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
3082 ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx);
3083 ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx);
3084 ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx);
3085
3086 /**
3087 * @}
3088 */
3089 #endif /* USE_FULL_LL_DRIVER */
3090
3091 /**
3092 * @}
3093 */
3094
3095 /**
3096 * @}
3097 */
3098
3099 #endif /* defined(RTC) */
3100
3101 /**
3102 * @}
3103 */
3104
3105 #ifdef __cplusplus
3106 }
3107 #endif
3108
3109 #endif /* STM32F0xx_LL_RTC_H */
3110