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