Increment eeprom version
[betaflight.git] / lib / main / STM32F1 / Drivers / STM32F1xx_HAL_Driver / Inc / stm32f1xx_ll_rtc.h
blob8ab869a77e1cc3500878bc00da4a5467716bfb7b
1 /**
2 ******************************************************************************
3 * @file stm32f1xx_ll_rtc.h
4 * @author MCD Application Team
5 * @version V1.1.1
6 * @date 12-May-2017
7 * @brief Header file of RTC LL module.
8 ******************************************************************************
9 * @attention
11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F1xx_LL_RTC_H
40 #define __STM32F1xx_LL_RTC_H
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f1xx.h"
49 /** @addtogroup STM32F1xx_LL_Driver
50 * @{
53 #if defined(RTC)
55 /** @defgroup RTC_LL RTC
56 * @{
59 /* Private types -------------------------------------------------------------*/
60 /* Private variables ---------------------------------------------------------*/
61 /* Private constants ---------------------------------------------------------*/
63 /* Private macros ------------------------------------------------------------*/
64 #if defined(USE_FULL_LL_DRIVER)
65 /** @defgroup RTC_LL_Private_Macros RTC Private Macros
66 * @{
68 /**
69 * @}
71 #endif /*USE_FULL_LL_DRIVER*/
73 /* Exported types ------------------------------------------------------------*/
74 #if defined(USE_FULL_LL_DRIVER)
75 /** @defgroup RTC_LL_ES_INIT RTC Exported Init structure
76 * @{
79 /**
80 * @brief RTC Init structures definition
82 typedef struct
84 uint32_t AsynchPrescaler; /*!< Specifies the RTC Asynchronous Predivider value.
85 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFFF
87 This feature can be modified afterwards using unitary function
88 @ref LL_RTC_SetAsynchPrescaler(). */
90 uint32_t OutPutSource; /*!< Specifies which signal will be routed to the RTC Tamper pin.
91 This parameter can be a value of @ref LL_RTC_Output_Source
93 This feature can be modified afterwards using unitary function
94 @ref LL_RTC_SetOutputSource(). */
96 } LL_RTC_InitTypeDef;
98 /**
99 * @brief RTC Time structure definition
101 typedef struct
103 uint8_t Hours; /*!< Specifies the RTC Time Hours.
104 This parameter must be a number between Min_Data = 0 and Max_Data = 23 */
106 uint8_t Minutes; /*!< Specifies the RTC Time Minutes.
107 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
109 uint8_t Seconds; /*!< Specifies the RTC Time Seconds.
110 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
111 } LL_RTC_TimeTypeDef;
115 * @brief RTC Alarm structure definition
117 typedef struct
119 LL_RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members. */
121 } LL_RTC_AlarmTypeDef;
124 * @}
126 #endif /* USE_FULL_LL_DRIVER */
128 /* Exported constants --------------------------------------------------------*/
129 /** @defgroup RTC_LL_Exported_Constants RTC Exported Constants
130 * @{
133 #if defined(USE_FULL_LL_DRIVER)
134 /** @defgroup RTC_LL_EC_FORMAT FORMAT
135 * @{
137 #define LL_RTC_FORMAT_BIN (0x000000000U) /*!< Binary data format */
138 #define LL_RTC_FORMAT_BCD (0x000000001U) /*!< BCD data format */
140 * @}
142 #endif /* USE_FULL_LL_DRIVER */
144 /** @defgroup RTC_LL_EC_BKP BACKUP
145 * @{
147 #if RTC_BKP_NUMBER > 0
148 #define LL_RTC_BKP_DR1 (0x00000001U)
149 #define LL_RTC_BKP_DR2 (0x00000002U)
150 #define LL_RTC_BKP_DR3 (0x00000003U)
151 #define LL_RTC_BKP_DR4 (0x00000004U)
152 #define LL_RTC_BKP_DR5 (0x00000005U)
153 #define LL_RTC_BKP_DR6 (0x00000006U)
154 #define LL_RTC_BKP_DR7 (0x00000007U)
155 #define LL_RTC_BKP_DR8 (0x00000008U)
156 #define LL_RTC_BKP_DR9 (0x00000009U)
157 #define LL_RTC_BKP_DR10 (0x0000000AU)
158 #endif /* RTC_BKP_NUMBER > 0 */
159 #if RTC_BKP_NUMBER > 10
160 #define LL_RTC_BKP_DR11 (0x0000000BU)
161 #define LL_RTC_BKP_DR12 (0x0000000CU)
162 #define LL_RTC_BKP_DR13 (0x0000000DU)
163 #define LL_RTC_BKP_DR14 (0x0000000EU)
164 #define LL_RTC_BKP_DR15 (0x0000000FU)
165 #define LL_RTC_BKP_DR16 (0x00000010U)
166 #define LL_RTC_BKP_DR17 (0x00000011U)
167 #define LL_RTC_BKP_DR18 (0x00000012U)
168 #define LL_RTC_BKP_DR19 (0x00000013U)
169 #define LL_RTC_BKP_DR20 (0x00000014U)
170 #define LL_RTC_BKP_DR21 (0x00000015U)
171 #define LL_RTC_BKP_DR22 (0x00000016U)
172 #define LL_RTC_BKP_DR23 (0x00000017U)
173 #define LL_RTC_BKP_DR24 (0x00000018U)
174 #define LL_RTC_BKP_DR25 (0x00000019U)
175 #define LL_RTC_BKP_DR26 (0x0000001AU)
176 #define LL_RTC_BKP_DR27 (0x0000001BU)
177 #define LL_RTC_BKP_DR28 (0x0000001CU)
178 #define LL_RTC_BKP_DR29 (0x0000001DU)
179 #define LL_RTC_BKP_DR30 (0x0000001EU)
180 #define LL_RTC_BKP_DR31 (0x0000001FU)
181 #define LL_RTC_BKP_DR32 (0x00000020U)
182 #define LL_RTC_BKP_DR33 (0x00000021U)
183 #define LL_RTC_BKP_DR34 (0x00000022U)
184 #define LL_RTC_BKP_DR35 (0x00000023U)
185 #define LL_RTC_BKP_DR36 (0x00000024U)
186 #define LL_RTC_BKP_DR37 (0x00000025U)
187 #define LL_RTC_BKP_DR38 (0x00000026U)
188 #define LL_RTC_BKP_DR39 (0x00000027U)
189 #define LL_RTC_BKP_DR40 (0x00000028U)
190 #define LL_RTC_BKP_DR41 (0x00000029U)
191 #define LL_RTC_BKP_DR42 (0x0000002AU)
192 #endif /* RTC_BKP_NUMBER > 10 */
195 * @}
198 /** @defgroup RTC_LL_EC_TAMPLEVEL Tamper Active Level
199 * @{
201 #define LL_RTC_TAMPER_ACTIVELEVEL_LOW BKP_CR_TPAL /*!< A high level on the TAMPER pin resets all data backup registers (if TPE bit is set) */
202 #define LL_RTC_TAMPER_ACTIVELEVEL_HIGH (0x00000000U) /*!< A low level on the TAMPER pin resets all data backup registers (if TPE bit is set) */
205 * @}
208 /** @defgroup LL_RTC_Output_Source Clock Source to output on the Tamper Pin
209 * @{
211 #define LL_RTC_CALIB_OUTPUT_NONE (0x00000000U) /*!< Calibration output disabled */
212 #define LL_RTC_CALIB_OUTPUT_RTCCLOCK BKP_RTCCR_CCO /*!< Calibration output is RTC Clock with a frequency divided by 64 on the TAMPER Pin */
213 #define LL_RTC_CALIB_OUTPUT_ALARM BKP_RTCCR_ASOE /*!< Calibration output is Alarm pulse signal on the TAMPER pin */
214 #define LL_RTC_CALIB_OUTPUT_SECOND (BKP_RTCCR_ASOS | BKP_RTCCR_ASOE) /*!< Calibration output is Second pulse signal on the TAMPER pin*/
216 * @}
220 * @}
223 /* Exported macro ------------------------------------------------------------*/
224 /** @defgroup RTC_LL_Exported_Macros RTC Exported Macros
225 * @{
228 /** @defgroup RTC_LL_EM_WRITE_READ Common Write and read registers Macros
229 * @{
233 * @brief Write a value in RTC register
234 * @param __INSTANCE__ RTC Instance
235 * @param __REG__ Register to be written
236 * @param __VALUE__ Value to be written in the register
237 * @retval None
239 #define LL_RTC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
242 * @brief Read a value in RTC register
243 * @param __INSTANCE__ RTC Instance
244 * @param __REG__ Register to be read
245 * @retval Register value
247 #define LL_RTC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
249 * @}
252 /** @defgroup RTC_LL_EM_Convert Convert helper Macros
253 * @{
257 * @brief Helper macro to convert a value from 2 digit decimal format to BCD format
258 * @param __VALUE__ Byte to be converted
259 * @retval Converted byte
261 #define __LL_RTC_CONVERT_BIN2BCD(__VALUE__) (uint8_t)((((__VALUE__) / 10U) << 4U) | ((__VALUE__) % 10U))
264 * @brief Helper macro to convert a value from BCD format to 2 digit decimal format
265 * @param __VALUE__ BCD value to be converted
266 * @retval Converted byte
268 #define __LL_RTC_CONVERT_BCD2BIN(__VALUE__) (uint8_t)(((uint8_t)((__VALUE__) & (uint8_t)0xF0U) >> (uint8_t)0x4U) * 10U + ((__VALUE__) & (uint8_t)0x0FU))
271 * @}
275 * @}
278 /* Exported functions --------------------------------------------------------*/
279 /** @defgroup RTC_LL_Exported_Functions RTC Exported Functions
280 * @{
283 /** @defgroup RTC_LL_EF_Configuration Configuration
284 * @{
288 * @brief Set Asynchronous prescaler factor
289 * @rmtoll PRLH PRL LL_RTC_SetAsynchPrescaler\n
290 * @rmtoll PRLL PRL LL_RTC_SetAsynchPrescaler\n
291 * @param RTCx RTC Instance
292 * @param AsynchPrescaler Value between Min_Data = 0 and Max_Data = 0xFFFFF
293 * @retval None
295 __STATIC_INLINE void LL_RTC_SetAsynchPrescaler(RTC_TypeDef *RTCx, uint32_t AsynchPrescaler)
297 MODIFY_REG(RTCx->PRLH, RTC_PRLH_PRL, (AsynchPrescaler >> 16));
298 MODIFY_REG(RTCx->PRLL, RTC_PRLL_PRL, (AsynchPrescaler & RTC_PRLL_PRL));
302 * @brief Get Asynchronous prescaler factor
303 * @rmtoll DIVH DIV LL_RTC_GetDivider\n
304 * @rmtoll DIVL DIV LL_RTC_GetDivider\n
305 * @param RTCx RTC Instance
306 * @retval Value between Min_Data = 0 and Max_Data = 0xFFFFF
308 __STATIC_INLINE uint32_t LL_RTC_GetDivider(RTC_TypeDef *RTCx)
310 register uint16_t Highprescaler = 0 , Lowprescaler = 0;
311 Highprescaler = READ_REG(RTCx->DIVH & RTC_DIVH_RTC_DIV);
312 Lowprescaler = READ_REG(RTCx->DIVL & RTC_DIVL_RTC_DIV);
314 return (((uint32_t) Highprescaler << 16U) | Lowprescaler);
318 * @brief Set Output Source
319 * @rmtoll RTCCR CCO LL_RTC_SetOutputSource
320 * @rmtoll RTCCR ASOE LL_RTC_SetOutputSource
321 * @rmtoll RTCCR ASOS LL_RTC_SetOutputSource
322 * @param BKPx BKP Instance
323 * @param OutputSource This parameter can be one of the following values:
324 * @arg @ref LL_RTC_CALIB_OUTPUT_NONE
325 * @arg @ref LL_RTC_CALIB_OUTPUT_RTCCLOCK
326 * @arg @ref LL_RTC_CALIB_OUTPUT_ALARM
327 * @arg @ref LL_RTC_CALIB_OUTPUT_SECOND
328 * @retval None
330 __STATIC_INLINE void LL_RTC_SetOutputSource(BKP_TypeDef *BKPx, uint32_t OutputSource)
332 MODIFY_REG(BKPx->RTCCR, (BKP_RTCCR_CCO | BKP_RTCCR_ASOE | BKP_RTCCR_ASOS), OutputSource);
336 * @brief Get Output Source
337 * @rmtoll RTCCR CCO LL_RTC_GetOutPutSource
338 * @rmtoll RTCCR ASOE LL_RTC_GetOutPutSource
339 * @rmtoll RTCCR ASOS LL_RTC_GetOutPutSource
340 * @param BKPx BKP Instance
341 * @retval Returned value can be one of the following values:
342 * @arg @ref LL_RTC_CALIB_OUTPUT_NONE
343 * @arg @ref LL_RTC_CALIB_OUTPUT_RTCCLOCK
344 * @arg @ref LL_RTC_CALIB_OUTPUT_ALARM
345 * @arg @ref LL_RTC_CALIB_OUTPUT_SECOND
347 __STATIC_INLINE uint32_t LL_RTC_GetOutPutSource(BKP_TypeDef *BKPx)
349 return (uint32_t)(READ_BIT(BKPx->RTCCR, (BKP_RTCCR_CCO | BKP_RTCCR_ASOE | BKP_RTCCR_ASOS)));
353 * @brief Enable the write protection for RTC registers.
354 * @rmtoll CRL CNF LL_RTC_EnableWriteProtection
355 * @param RTCx RTC Instance
356 * @retval None
358 __STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx)
360 CLEAR_BIT(RTCx->CRL, RTC_CRL_CNF);
364 * @brief Disable the write protection for RTC registers.
365 * @rmtoll CRL RTC_CRL_CNF LL_RTC_DisableWriteProtection
366 * @param RTCx RTC Instance
367 * @retval None
369 __STATIC_INLINE void LL_RTC_DisableWriteProtection(RTC_TypeDef *RTCx)
371 SET_BIT(RTCx->CRL, RTC_CRL_CNF);
375 * @}
378 /** @defgroup RTC_LL_EF_Time Time
379 * @{
383 * @brief Set time counter in BCD format
384 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
385 * @note It can be written in initialization mode only (@ref LL_RTC_EnterInitMode function)
386 * @rmtoll CNTH CNT LL_RTC_TIME_Set\n
387 * CNTL CNT LL_RTC_TIME_Set\n
388 * @param RTCx RTC Instance
389 * @param TimeCounter Value between Min_Data=0x00 and Max_Data=0xFFFFF
390 * @retval None
392 __STATIC_INLINE void LL_RTC_TIME_Set(RTC_TypeDef *RTCx, uint32_t TimeCounter)
394 /* Set RTC COUNTER MSB word */
395 WRITE_REG(RTCx->CNTH, (TimeCounter >> 16U));
396 /* Set RTC COUNTER LSB word */
397 WRITE_REG(RTCx->CNTL, (TimeCounter & RTC_CNTL_RTC_CNT));
401 * @brief Get time counter in BCD format
402 * @rmtoll CNTH CNT LL_RTC_TIME_Get\n
403 * CNTL CNT LL_RTC_TIME_Get\n
404 * @param RTCx RTC Instance
405 * @retval Value between Min_Data = 0 and Max_Data = 0xFFFFF
407 __STATIC_INLINE uint32_t LL_RTC_TIME_Get(RTC_TypeDef *RTCx)
409 register uint16_t high = 0, low = 0;
411 high = READ_REG(RTCx->CNTH & RTC_CNTH_RTC_CNT);
412 low = READ_REG(RTCx->CNTL & RTC_CNTL_RTC_CNT);
413 return ((uint32_t)(((uint32_t) high << 16U) | low));
417 * @}
420 /** @defgroup RTC_LL_EF_ALARM ALARM
421 * @{
425 * @brief Set Alarm Counter
426 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
427 * @rmtoll ALRH ALR LL_RTC_ALARM_Set\n
428 * @rmtoll ALRL ALR LL_RTC_ALARM_Set\n
429 * @param RTCx RTC Instance
430 * @param AlarmCounter Value between Min_Data=0x00 and Max_Data=0xFFFFF
431 * @retval None
433 __STATIC_INLINE void LL_RTC_ALARM_Set(RTC_TypeDef *RTCx, uint32_t AlarmCounter)
435 /* Set RTC COUNTER MSB word */
436 WRITE_REG(RTCx->ALRH, (AlarmCounter >> 16));
437 /* Set RTC COUNTER LSB word */
438 WRITE_REG(RTCx->ALRL, (AlarmCounter & RTC_ALRL_RTC_ALR));
442 * @brief Get Alarm Counter
443 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
444 * @rmtoll ALRH ALR LL_RTC_ALARM_Get\n
445 * @rmtoll ALRL ALR LL_RTC_ALARM_Get\n
446 * @param RTCx RTC Instance
447 * @retval None
449 __STATIC_INLINE uint32_t LL_RTC_ALARM_Get(RTC_TypeDef *RTCx)
451 register uint16_t high = 0, low = 0;
453 high = READ_REG(RTCx->ALRH & RTC_ALRH_RTC_ALR);
454 low = READ_REG(RTCx->ALRL & RTC_ALRL_RTC_ALR);
456 return (((uint32_t) high << 16U) | low);
460 * @}
463 /** @defgroup RTC_LL_EF_Tamper Tamper
464 * @{
468 * @brief Enable RTC_TAMPx input detection
469 * @rmtoll CR TPE LL_RTC_TAMPER_Enable\n
470 * @retval None
472 __STATIC_INLINE void LL_RTC_TAMPER_Enable(BKP_TypeDef *BKPx)
474 SET_BIT(BKPx->CR, BKP_CR_TPE);
478 * @brief Disable RTC_TAMPx Tamper
479 * @rmtoll CR TPE LL_RTC_TAMPER_Disable\n
480 * @retval None
482 __STATIC_INLINE void LL_RTC_TAMPER_Disable(BKP_TypeDef *BKPx)
484 CLEAR_BIT(BKP->CR, BKP_CR_TPE);
488 * @brief Enable Active level for Tamper input
489 * @rmtoll CR TPAL LL_RTC_TAMPER_SetActiveLevel\n
490 * @param BKPx BKP Instance
491 * @param Tamper This parameter can be a combination of the following values:
492 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_LOW
493 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_HIGH
494 * @retval None
496 __STATIC_INLINE void LL_RTC_TAMPER_SetActiveLevel(BKP_TypeDef *BKPx, uint32_t Tamper)
498 MODIFY_REG(BKPx->CR, BKP_CR_TPAL, Tamper);
502 * @brief Disable Active level for Tamper input
503 * @rmtoll CR TPAL LL_RTC_TAMPER_SetActiveLevel\n
504 * @retval None
506 __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetActiveLevel(BKP_TypeDef *BKPx)
508 return (uint32_t)(READ_BIT(BKPx->CR, BKP_CR_TPAL));
512 * @}
515 /** @defgroup RTC_LL_EF_Backup_Registers Backup_Registers
516 * @{
520 * @brief Writes a data in a specified RTC Backup data register.
521 * @rmtoll BKPDR DR LL_RTC_BKP_SetRegister
522 * @param BKPx BKP Instance
523 * @param BackupRegister This parameter can be one of the following values:
524 * @arg @ref LL_RTC_BKP_DR1
525 * @arg @ref LL_RTC_BKP_DR2
526 * @arg @ref LL_RTC_BKP_DR3
527 * @arg @ref LL_RTC_BKP_DR4
528 * @arg @ref LL_RTC_BKP_DR5
529 * @arg @ref LL_RTC_BKP_DR6
530 * @arg @ref LL_RTC_BKP_DR7
531 * @arg @ref LL_RTC_BKP_DR8
532 * @arg @ref LL_RTC_BKP_DR9
533 * @arg @ref LL_RTC_BKP_DR10
534 * @arg @ref LL_RTC_BKP_DR11 (*)
535 * @arg @ref LL_RTC_BKP_DR12 (*)
536 * @arg @ref LL_RTC_BKP_DR13 (*)
537 * @arg @ref LL_RTC_BKP_DR14 (*)
538 * @arg @ref LL_RTC_BKP_DR15 (*)
539 * @arg @ref LL_RTC_BKP_DR16 (*)
540 * @arg @ref LL_RTC_BKP_DR17 (*)
541 * @arg @ref LL_RTC_BKP_DR18 (*)
542 * @arg @ref LL_RTC_BKP_DR19 (*)
543 * @arg @ref LL_RTC_BKP_DR20 (*)
544 * @arg @ref LL_RTC_BKP_DR21 (*)
545 * @arg @ref LL_RTC_BKP_DR22 (*)
546 * @arg @ref LL_RTC_BKP_DR23 (*)
547 * @arg @ref LL_RTC_BKP_DR24 (*)
548 * @arg @ref LL_RTC_BKP_DR25 (*)
549 * @arg @ref LL_RTC_BKP_DR26 (*)
550 * @arg @ref LL_RTC_BKP_DR27 (*)
551 * @arg @ref LL_RTC_BKP_DR28 (*)
552 * @arg @ref LL_RTC_BKP_DR29 (*)
553 * @arg @ref LL_RTC_BKP_DR30 (*)
554 * @arg @ref LL_RTC_BKP_DR31 (*)
555 * @arg @ref LL_RTC_BKP_DR32 (*)
556 * @arg @ref LL_RTC_BKP_DR33 (*)
557 * @arg @ref LL_RTC_BKP_DR34 (*)
558 * @arg @ref LL_RTC_BKP_DR35 (*)
559 * @arg @ref LL_RTC_BKP_DR36 (*)
560 * @arg @ref LL_RTC_BKP_DR37 (*)
561 * @arg @ref LL_RTC_BKP_DR38 (*)
562 * @arg @ref LL_RTC_BKP_DR39 (*)
563 * @arg @ref LL_RTC_BKP_DR40 (*)
564 * @arg @ref LL_RTC_BKP_DR41 (*)
565 * @arg @ref LL_RTC_BKP_DR42 (*)
566 * (*) value not defined in all devices.
567 * @param Data Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
568 * @retval None
570 __STATIC_INLINE void LL_RTC_BKP_SetRegister(BKP_TypeDef *BKPx, uint32_t BackupRegister, uint32_t Data)
572 register uint32_t tmp = 0U;
574 tmp = (uint32_t)BKP_BASE;
575 tmp += (BackupRegister * 4U);
577 /* Write the specified register */
578 *(__IO uint32_t *)tmp = (uint32_t)Data;
582 * @brief Reads data from the specified RTC Backup data Register.
583 * @rmtoll BKPDR DR LL_RTC_BKP_GetRegister
584 * @param BKPx BKP Instance
585 * @param BackupRegister This parameter can be one of the following values:
586 * @arg @ref LL_RTC_BKP_DR1
587 * @arg @ref LL_RTC_BKP_DR2
588 * @arg @ref LL_RTC_BKP_DR3
589 * @arg @ref LL_RTC_BKP_DR4
590 * @arg @ref LL_RTC_BKP_DR5
591 * @arg @ref LL_RTC_BKP_DR6
592 * @arg @ref LL_RTC_BKP_DR7
593 * @arg @ref LL_RTC_BKP_DR8
594 * @arg @ref LL_RTC_BKP_DR9
595 * @arg @ref LL_RTC_BKP_DR10
596 * @arg @ref LL_RTC_BKP_DR11 (*)
597 * @arg @ref LL_RTC_BKP_DR12 (*)
598 * @arg @ref LL_RTC_BKP_DR13 (*)
599 * @arg @ref LL_RTC_BKP_DR14 (*)
600 * @arg @ref LL_RTC_BKP_DR15 (*)
601 * @arg @ref LL_RTC_BKP_DR16 (*)
602 * @arg @ref LL_RTC_BKP_DR17 (*)
603 * @arg @ref LL_RTC_BKP_DR18 (*)
604 * @arg @ref LL_RTC_BKP_DR19 (*)
605 * @arg @ref LL_RTC_BKP_DR20 (*)
606 * @arg @ref LL_RTC_BKP_DR21 (*)
607 * @arg @ref LL_RTC_BKP_DR22 (*)
608 * @arg @ref LL_RTC_BKP_DR23 (*)
609 * @arg @ref LL_RTC_BKP_DR24 (*)
610 * @arg @ref LL_RTC_BKP_DR25 (*)
611 * @arg @ref LL_RTC_BKP_DR26 (*)
612 * @arg @ref LL_RTC_BKP_DR27 (*)
613 * @arg @ref LL_RTC_BKP_DR28 (*)
614 * @arg @ref LL_RTC_BKP_DR29 (*)
615 * @arg @ref LL_RTC_BKP_DR30 (*)
616 * @arg @ref LL_RTC_BKP_DR31 (*)
617 * @arg @ref LL_RTC_BKP_DR32 (*)
618 * @arg @ref LL_RTC_BKP_DR33 (*)
619 * @arg @ref LL_RTC_BKP_DR34 (*)
620 * @arg @ref LL_RTC_BKP_DR35 (*)
621 * @arg @ref LL_RTC_BKP_DR36 (*)
622 * @arg @ref LL_RTC_BKP_DR37 (*)
623 * @arg @ref LL_RTC_BKP_DR38 (*)
624 * @arg @ref LL_RTC_BKP_DR39 (*)
625 * @arg @ref LL_RTC_BKP_DR40 (*)
626 * @arg @ref LL_RTC_BKP_DR41 (*)
627 * @arg @ref LL_RTC_BKP_DR42 (*)
628 * @retval Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
630 __STATIC_INLINE uint32_t LL_RTC_BKP_GetRegister(BKP_TypeDef *BKPx, uint32_t BackupRegister)
632 register uint32_t tmp = 0U;
634 tmp = (uint32_t)BKP_BASE;
635 tmp += (BackupRegister * 4U);
637 /* Read the specified register */
638 return ((*(__IO uint32_t *)tmp) & BKP_DR1_D);
642 * @}
645 /** @defgroup RTC_LL_EF_Calibration Calibration
646 * @{
650 * @brief Set the coarse digital calibration
651 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
652 * @note It can be written in initialization mode only (@ref LL_RTC_EnterInitMode function)
653 * @rmtoll RTCCR CAL LL_RTC_CAL_SetCoarseDigital\n
654 * @param BKPx RTC Instance
655 * @param Value value of coarse calibration expressed in ppm (coded on 5 bits)
656 * @note This Calibration value should be between 0 and 121 when using positive sign with a 4-ppm step.
657 * @retval None
659 __STATIC_INLINE void LL_RTC_CAL_SetCoarseDigital(BKP_TypeDef* BKPx, uint32_t Value)
661 MODIFY_REG(BKPx->RTCCR,BKP_RTCCR_CAL, Value);
665 * @brief Get the coarse digital calibration value
666 * @rmtoll RTCCR CAL LL_RTC_CAL_SetCoarseDigital\n
667 * @param BKPx BKP Instance
668 * @retval value of coarse calibration expressed in ppm (coded on 5 bits)
670 __STATIC_INLINE uint32_t LL_RTC_CAL_GetCoarseDigital(BKP_TypeDef *BKPx)
672 return (uint32_t)(READ_BIT(BKPx->RTCCR, BKP_RTCCR_CAL));
675 * @}
678 /** @defgroup RTC_LL_EF_FLAG_Management FLAG_Management
679 * @{
683 * @brief Get RTC_TAMPI Interruption detection flag
684 * @rmtoll CSR TIF LL_RTC_IsActiveFlag_TAMPI
685 * @param BKPx BKP Instance
686 * @retval State of bit (1 or 0).
688 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMPI(BKP_TypeDef *BKPx)
690 return (READ_BIT(BKPx->CSR, BKP_CSR_TIF) == (BKP_CSR_TIF));
694 * @brief Clear RTC_TAMP Interruption detection flag
695 * @rmtoll CSR CTI LL_RTC_ClearFlag_TAMPI
696 * @param BKPx BKP Instance
697 * @retval None
699 __STATIC_INLINE void LL_RTC_ClearFlag_TAMPI(BKP_TypeDef *BKPx)
701 SET_BIT(BKPx->CSR, BKP_CSR_CTI);
705 * @brief Get RTC_TAMPE Event detection flag
706 * @rmtoll CSR TEF LL_RTC_IsActiveFlag_TAMPE
707 * @param BKPx BKP Instance
708 * @retval State of bit (1 or 0).
710 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMPE(BKP_TypeDef *BKPx)
712 return (READ_BIT(BKPx->CSR, BKP_CSR_TEF) == (BKP_CSR_TEF));
716 * @brief Clear RTC_TAMPE Even detection flag
717 * @rmtoll CSR CTE LL_RTC_ClearFlag_TAMPE
718 * @param BKPx BKP Instance
719 * @retval None
721 __STATIC_INLINE void LL_RTC_ClearFlag_TAMPE(BKP_TypeDef *BKPx)
723 SET_BIT(BKPx->CSR, BKP_CSR_CTE);
727 * @brief Get Alarm flag
728 * @rmtoll CRL ALRF LL_RTC_IsActiveFlag_ALR
729 * @param RTCx RTC Instance
730 * @retval State of bit (1 or 0).
732 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALR(RTC_TypeDef *RTCx)
734 return (READ_BIT(RTCx->CRL, RTC_CRL_ALRF) == (RTC_CRL_ALRF));
738 * @brief Clear Alarm flag
739 * @rmtoll CRL ALRF LL_RTC_ClearFlag_ALR
740 * @param RTCx RTC Instance
741 * @retval None
743 __STATIC_INLINE void LL_RTC_ClearFlag_ALR(RTC_TypeDef *RTCx)
745 CLEAR_BIT(RTCx->CRL, RTC_CRL_ALRF);
749 * @brief Get Registers synchronization flag
750 * @rmtoll CRL RSF LL_RTC_IsActiveFlag_RS
751 * @param RTCx RTC Instance
752 * @retval State of bit (1 or 0).
754 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(RTC_TypeDef *RTCx)
756 return (READ_BIT(RTCx->CRL, RTC_CRL_RSF) == (RTC_CRL_RSF));
760 * @brief Clear Registers synchronization flag
761 * @rmtoll CRL RSF LL_RTC_ClearFlag_RS
762 * @param RTCx RTC Instance
763 * @retval None
765 __STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx)
767 CLEAR_BIT(RTCx->CRL, RTC_CRL_RSF);
771 * @brief Get Registers OverFlow flag
772 * @rmtoll CRL OWF LL_RTC_IsActiveFlag_OW
773 * @param RTCx RTC Instance
774 * @retval State of bit (1 or 0).
776 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_OW(RTC_TypeDef *RTCx)
778 return (READ_BIT(RTCx->CRL, RTC_CRL_OWF) == (RTC_CRL_OWF));
782 * @brief Clear Registers OverFlow flag
783 * @rmtoll CRL OWF LL_RTC_ClearFlag_OW
784 * @param RTCx RTC Instance
785 * @retval None
787 __STATIC_INLINE void LL_RTC_ClearFlag_OW(RTC_TypeDef *RTCx)
789 CLEAR_BIT(RTCx->CRL, RTC_CRL_OWF);
793 * @brief Get Registers synchronization flag
794 * @rmtoll CRL SECF LL_RTC_IsActiveFlag_SEC
795 * @param RTCx RTC Instance
796 * @retval State of bit (1 or 0).
798 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SEC(RTC_TypeDef *RTCx)
800 return (READ_BIT(RTCx->CRL, RTC_CRL_SECF) == (RTC_CRL_SECF));
804 * @brief Clear Registers synchronization flag
805 * @rmtoll CRL SECF LL_RTC_ClearFlag_SEC
806 * @param RTCx RTC Instance
807 * @retval None
809 __STATIC_INLINE void LL_RTC_ClearFlag_SEC(RTC_TypeDef *RTCx)
811 CLEAR_BIT(RTCx->CRL, RTC_CRL_SECF);
815 * @brief Get RTC Operation OFF status flag
816 * @rmtoll CRL RTOFF LL_RTC_IsActiveFlag_RTOF
817 * @param RTCx RTC Instance
818 * @retval State of bit (1 or 0).
820 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RTOF(RTC_TypeDef *RTCx)
822 return (READ_BIT(RTCx->CRL, RTC_CRL_RTOFF) == (RTC_CRL_RTOFF));
826 * @}
829 /** @defgroup RTC_LL_EF_IT_Management IT_Management
830 * @{
834 * @brief Enable Alarm interrupt
835 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
836 * @rmtoll CRH ALRIE LL_RTC_EnableIT_ALR
837 * @param RTCx RTC Instance
838 * @retval None
840 __STATIC_INLINE void LL_RTC_EnableIT_ALR(RTC_TypeDef *RTCx)
842 SET_BIT(RTCx->CRH, RTC_CRH_ALRIE);
846 * @brief Disable Alarm interrupt
847 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
848 * @rmtoll CRH ALRIE LL_RTC_DisableIT_ALR
849 * @param RTCx RTC Instance
850 * @retval None
852 __STATIC_INLINE void LL_RTC_DisableIT_ALR(RTC_TypeDef *RTCx)
854 CLEAR_BIT(RTCx->CRH, RTC_CRH_ALRIE);
858 * @brief Check if Alarm interrupt is enabled or not
859 * @rmtoll CRH ALRIE LL_RTC_IsEnabledIT_ALR
860 * @param RTCx RTC Instance
861 * @retval State of bit (1 or 0).
863 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALR(RTC_TypeDef *RTCx)
865 return (READ_BIT(RTCx->CRH, RTC_CRH_ALRIE) == (RTC_CRH_ALRIE));
869 * @brief Enable Second Interrupt interrupt
870 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
871 * @rmtoll CRH SECIE LL_RTC_EnableIT_SEC
872 * @param RTCx RTC Instance
873 * @retval None
875 __STATIC_INLINE void LL_RTC_EnableIT_SEC(RTC_TypeDef *RTCx)
877 SET_BIT(RTCx->CRH, RTC_CRH_SECIE);
881 * @brief Disable Second interrupt
882 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
883 * @rmtoll CRH SECIE LL_RTC_DisableIT_SEC
884 * @param RTCx RTC Instance
885 * @retval None
887 __STATIC_INLINE void LL_RTC_DisableIT_SEC(RTC_TypeDef *RTCx)
889 CLEAR_BIT(RTCx->CRH, RTC_CRH_SECIE);
893 * @brief Check if Second interrupt is enabled or not
894 * @rmtoll CRH SECIE LL_RTC_IsEnabledIT_SEC
895 * @param RTCx RTC Instance
896 * @retval State of bit (1 or 0).
898 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_SEC(RTC_TypeDef *RTCx)
900 return (READ_BIT(RTCx->CRH, RTC_CRH_SECIE) == (RTC_CRH_SECIE));
904 * @brief Enable OverFlow interrupt
905 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
906 * @rmtoll CRH OWIE LL_RTC_EnableIT_OW
907 * @param RTCx RTC Instance
908 * @retval None
910 __STATIC_INLINE void LL_RTC_EnableIT_OW(RTC_TypeDef *RTCx)
912 SET_BIT(RTCx->CRH, RTC_CRH_OWIE);
916 * @brief Disable OverFlow interrupt
917 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
918 * @rmtoll CRH OWIE LL_RTC_DisableIT_OW
919 * @param RTCx RTC Instance
920 * @retval None
922 __STATIC_INLINE void LL_RTC_DisableIT_OW(RTC_TypeDef *RTCx)
924 CLEAR_BIT(RTCx->CRH, RTC_CRH_OWIE);
928 * @brief Check if OverFlow interrupt is enabled or not
929 * @rmtoll CRH OWIE LL_RTC_IsEnabledIT_OW
930 * @param RTCx RTC Instance
931 * @retval State of bit (1 or 0).
933 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_OW(RTC_TypeDef *RTCx)
935 return (READ_BIT(RTCx->CRH, RTC_CRH_OWIE) == (RTC_CRH_OWIE));
939 * @brief Enable Tamper interrupt
940 * @rmtoll CSR TPIE LL_RTC_EnableIT_TAMP
941 * @param BKPx BKP Instance
942 * @retval None
944 __STATIC_INLINE void LL_RTC_EnableIT_TAMP(BKP_TypeDef *BKPx)
946 SET_BIT(BKPx->CSR,BKP_CSR_TPIE);
950 * @brief Disable Tamper interrupt
951 * @rmtoll CSR TPIE LL_RTC_EnableIT_TAMP
952 * @param BKPx BKP Instance
953 * @retval None
955 __STATIC_INLINE void LL_RTC_DisableIT_TAMP(BKP_TypeDef *BKPx)
957 CLEAR_BIT(BKPx->CSR,BKP_CSR_TPIE);
961 * @brief Check if all the TAMPER interrupts are enabled or not
962 * @rmtoll CSR TPIE LL_RTC_IsEnabledIT_TAMP
963 * @param BKPx BKP Instance
964 * @retval State of bit (1 or 0).
966 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP(BKP_TypeDef *BKPx)
968 return (READ_BIT(BKPx->CSR,BKP_CSR_TPIE) == BKP_CSR_TPIE);
971 * @}
974 #if defined(USE_FULL_LL_DRIVER)
975 /** @defgroup RTC_LL_EF_Init Initialization and de-initialization functions
976 * @{
979 ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx);
980 ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct);
981 void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct);
982 ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct);
983 void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct);
984 ErrorStatus LL_RTC_ALARM_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
985 void LL_RTC_ALARM_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
986 ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx);
987 ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx);
988 ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx);
989 ErrorStatus LL_RTC_TIME_SetCounter(RTC_TypeDef *RTCx, uint32_t TimeCounter);
990 ErrorStatus LL_RTC_ALARM_SetCounter(RTC_TypeDef *RTCx, uint32_t AlarmCounter);
993 * @}
995 #endif /* USE_FULL_LL_DRIVER */
998 * @}
1002 * @}
1006 * @}
1009 #endif /* defined(RTC) */
1012 * @}
1015 #ifdef __cplusplus
1017 #endif
1019 #endif /* __STM32F1xx_LL_RTC_H */
1021 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/