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