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