STM32F103xB HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f1xx_ll_rtc.h 00004 * @author MCD Application Team 00005 * @brief Header file of RTC LL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * <h2><center>© Copyright (c) 2016 STMicroelectronics. 00010 * All rights reserved.</center></h2> 00011 * 00012 * This software component is licensed by ST under BSD 3-Clause license, 00013 * the "License"; You may not use this file except in compliance with the 00014 * License. You may obtain a copy of the License at: 00015 * opensource.org/licenses/BSD-3-Clause 00016 * 00017 ****************************************************************************** 00018 */ 00019 00020 /* Define to prevent recursive inclusion -------------------------------------*/ 00021 #ifndef __STM32F1xx_LL_RTC_H 00022 #define __STM32F1xx_LL_RTC_H 00023 00024 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 /* Includes ------------------------------------------------------------------*/ 00029 #include "stm32f1xx.h" 00030 00031 /** @addtogroup STM32F1xx_LL_Driver 00032 * @{ 00033 */ 00034 00035 #if defined(RTC) 00036 00037 /** @defgroup RTC_LL RTC 00038 * @{ 00039 */ 00040 00041 /* Private types -------------------------------------------------------------*/ 00042 /* Private variables ---------------------------------------------------------*/ 00043 /* Private constants ---------------------------------------------------------*/ 00044 00045 /* Private macros ------------------------------------------------------------*/ 00046 #if defined(USE_FULL_LL_DRIVER) 00047 /** @defgroup RTC_LL_Private_Macros RTC Private Macros 00048 * @{ 00049 */ 00050 /** 00051 * @} 00052 */ 00053 #endif /*USE_FULL_LL_DRIVER*/ 00054 00055 /* Exported types ------------------------------------------------------------*/ 00056 #if defined(USE_FULL_LL_DRIVER) 00057 /** @defgroup RTC_LL_ES_INIT RTC Exported Init structure 00058 * @{ 00059 */ 00060 00061 /** 00062 * @brief RTC Init structures definition 00063 */ 00064 typedef struct 00065 { 00066 uint32_t AsynchPrescaler; /*!< Specifies the RTC Asynchronous Predivider value. 00067 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFFF 00068 00069 This feature can be modified afterwards using unitary function 00070 @ref LL_RTC_SetAsynchPrescaler(). */ 00071 00072 uint32_t OutPutSource; /*!< Specifies which signal will be routed to the RTC Tamper pin. 00073 This parameter can be a value of @ref LL_RTC_Output_Source 00074 00075 This feature can be modified afterwards using unitary function 00076 @ref LL_RTC_SetOutputSource(). */ 00077 00078 } LL_RTC_InitTypeDef; 00079 00080 /** 00081 * @brief RTC Time structure definition 00082 */ 00083 typedef struct 00084 { 00085 uint8_t Hours; /*!< Specifies the RTC Time Hours. 00086 This parameter must be a number between Min_Data = 0 and Max_Data = 23 */ 00087 00088 uint8_t Minutes; /*!< Specifies the RTC Time Minutes. 00089 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ 00090 00091 uint8_t Seconds; /*!< Specifies the RTC Time Seconds. 00092 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ 00093 } LL_RTC_TimeTypeDef; 00094 00095 00096 /** 00097 * @brief RTC Alarm structure definition 00098 */ 00099 typedef struct 00100 { 00101 LL_RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members. */ 00102 00103 } LL_RTC_AlarmTypeDef; 00104 00105 /** 00106 * @} 00107 */ 00108 #endif /* USE_FULL_LL_DRIVER */ 00109 00110 /* Exported constants --------------------------------------------------------*/ 00111 /** @defgroup RTC_LL_Exported_Constants RTC Exported Constants 00112 * @{ 00113 */ 00114 00115 #if defined(USE_FULL_LL_DRIVER) 00116 /** @defgroup RTC_LL_EC_FORMAT FORMAT 00117 * @{ 00118 */ 00119 #define LL_RTC_FORMAT_BIN (0x000000000U) /*!< Binary data format */ 00120 #define LL_RTC_FORMAT_BCD (0x000000001U) /*!< BCD data format */ 00121 /** 00122 * @} 00123 */ 00124 #endif /* USE_FULL_LL_DRIVER */ 00125 00126 /** @defgroup RTC_LL_EC_BKP BACKUP 00127 * @{ 00128 */ 00129 #if RTC_BKP_NUMBER > 0 00130 #define LL_RTC_BKP_DR1 (0x00000001U) 00131 #define LL_RTC_BKP_DR2 (0x00000002U) 00132 #define LL_RTC_BKP_DR3 (0x00000003U) 00133 #define LL_RTC_BKP_DR4 (0x00000004U) 00134 #define LL_RTC_BKP_DR5 (0x00000005U) 00135 #define LL_RTC_BKP_DR6 (0x00000006U) 00136 #define LL_RTC_BKP_DR7 (0x00000007U) 00137 #define LL_RTC_BKP_DR8 (0x00000008U) 00138 #define LL_RTC_BKP_DR9 (0x00000009U) 00139 #define LL_RTC_BKP_DR10 (0x0000000AU) 00140 #endif /* RTC_BKP_NUMBER > 0 */ 00141 #if RTC_BKP_NUMBER > 10 00142 #define LL_RTC_BKP_DR11 (0x00000010U) 00143 #define LL_RTC_BKP_DR12 (0x00000011U) 00144 #define LL_RTC_BKP_DR13 (0x00000012U) 00145 #define LL_RTC_BKP_DR14 (0x00000013U) 00146 #define LL_RTC_BKP_DR15 (0x00000014U) 00147 #define LL_RTC_BKP_DR16 (0x00000015U) 00148 #define LL_RTC_BKP_DR17 (0x00000016U) 00149 #define LL_RTC_BKP_DR18 (0x00000017U) 00150 #define LL_RTC_BKP_DR19 (0x00000018U) 00151 #define LL_RTC_BKP_DR20 (0x00000019U) 00152 #define LL_RTC_BKP_DR21 (0x0000001AU) 00153 #define LL_RTC_BKP_DR22 (0x0000001BU) 00154 #define LL_RTC_BKP_DR23 (0x0000001CU) 00155 #define LL_RTC_BKP_DR24 (0x0000001DU) 00156 #define LL_RTC_BKP_DR25 (0x0000001EU) 00157 #define LL_RTC_BKP_DR26 (0x0000001FU) 00158 #define LL_RTC_BKP_DR27 (0x00000020U) 00159 #define LL_RTC_BKP_DR28 (0x00000021U) 00160 #define LL_RTC_BKP_DR29 (0x00000022U) 00161 #define LL_RTC_BKP_DR30 (0x00000023U) 00162 #define LL_RTC_BKP_DR31 (0x00000024U) 00163 #define LL_RTC_BKP_DR32 (0x00000025U) 00164 #define LL_RTC_BKP_DR33 (0x00000026U) 00165 #define LL_RTC_BKP_DR34 (0x00000027U) 00166 #define LL_RTC_BKP_DR35 (0x00000028U) 00167 #define LL_RTC_BKP_DR36 (0x00000029U) 00168 #define LL_RTC_BKP_DR37 (0x0000002AU) 00169 #define LL_RTC_BKP_DR38 (0x0000002BU) 00170 #define LL_RTC_BKP_DR39 (0x0000002CU) 00171 #define LL_RTC_BKP_DR40 (0x0000002DU) 00172 #define LL_RTC_BKP_DR41 (0x0000002EU) 00173 #define LL_RTC_BKP_DR42 (0x0000002FU) 00174 #endif /* RTC_BKP_NUMBER > 10 */ 00175 00176 /** 00177 * @} 00178 */ 00179 00180 /** @defgroup RTC_LL_EC_TAMPLEVEL Tamper Active Level 00181 * @{ 00182 */ 00183 #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) */ 00184 #define LL_RTC_TAMPER_ACTIVELEVEL_HIGH (0x00000000U) /*!< A low level on the TAMPER pin resets all data backup registers (if TPE bit is set) */ 00185 00186 /** 00187 * @} 00188 */ 00189 00190 /** @defgroup LL_RTC_Output_Source Clock Source to output on the Tamper Pin 00191 * @{ 00192 */ 00193 #define LL_RTC_CALIB_OUTPUT_NONE (0x00000000U) /*!< Calibration output disabled */ 00194 #define LL_RTC_CALIB_OUTPUT_RTCCLOCK BKP_RTCCR_CCO /*!< Calibration output is RTC Clock with a frequency divided by 64 on the TAMPER Pin */ 00195 #define LL_RTC_CALIB_OUTPUT_ALARM BKP_RTCCR_ASOE /*!< Calibration output is Alarm pulse signal on the TAMPER pin */ 00196 #define LL_RTC_CALIB_OUTPUT_SECOND (BKP_RTCCR_ASOS | BKP_RTCCR_ASOE) /*!< Calibration output is Second pulse signal on the TAMPER pin*/ 00197 /** 00198 * @} 00199 */ 00200 00201 /** 00202 * @} 00203 */ 00204 00205 /* Exported macro ------------------------------------------------------------*/ 00206 /** @defgroup RTC_LL_Exported_Macros RTC Exported Macros 00207 * @{ 00208 */ 00209 00210 /** @defgroup RTC_LL_EM_WRITE_READ Common Write and read registers Macros 00211 * @{ 00212 */ 00213 00214 /** 00215 * @brief Write a value in RTC register 00216 * @param __INSTANCE__ RTC Instance 00217 * @param __REG__ Register to be written 00218 * @param __VALUE__ Value to be written in the register 00219 * @retval None 00220 */ 00221 #define LL_RTC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) 00222 00223 /** 00224 * @brief Read a value in RTC register 00225 * @param __INSTANCE__ RTC Instance 00226 * @param __REG__ Register to be read 00227 * @retval Register value 00228 */ 00229 #define LL_RTC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 00230 /** 00231 * @} 00232 */ 00233 00234 /** @defgroup RTC_LL_EM_Convert Convert helper Macros 00235 * @{ 00236 */ 00237 00238 /** 00239 * @brief Helper macro to convert a value from 2 digit decimal format to BCD format 00240 * @param __VALUE__ Byte to be converted 00241 * @retval Converted byte 00242 */ 00243 #define __LL_RTC_CONVERT_BIN2BCD(__VALUE__) (uint8_t)((((__VALUE__) / 10U) << 4U) | ((__VALUE__) % 10U)) 00244 00245 /** 00246 * @brief Helper macro to convert a value from BCD format to 2 digit decimal format 00247 * @param __VALUE__ BCD value to be converted 00248 * @retval Converted byte 00249 */ 00250 #define __LL_RTC_CONVERT_BCD2BIN(__VALUE__) (uint8_t)(((uint8_t)((__VALUE__) & (uint8_t)0xF0U) >> (uint8_t)0x4U) * 10U + ((__VALUE__) & (uint8_t)0x0FU)) 00251 00252 /** 00253 * @} 00254 */ 00255 00256 /** 00257 * @} 00258 */ 00259 00260 /* Exported functions --------------------------------------------------------*/ 00261 /** @defgroup RTC_LL_Exported_Functions RTC Exported Functions 00262 * @{ 00263 */ 00264 00265 /** @defgroup RTC_LL_EF_Configuration Configuration 00266 * @{ 00267 */ 00268 00269 /** 00270 * @brief Set Asynchronous prescaler factor 00271 * @rmtoll PRLH PRL LL_RTC_SetAsynchPrescaler\n 00272 * @rmtoll PRLL PRL LL_RTC_SetAsynchPrescaler\n 00273 * @param RTCx RTC Instance 00274 * @param AsynchPrescaler Value between Min_Data = 0 and Max_Data = 0xFFFFF 00275 * @retval None 00276 */ 00277 __STATIC_INLINE void LL_RTC_SetAsynchPrescaler(RTC_TypeDef *RTCx, uint32_t AsynchPrescaler) 00278 { 00279 MODIFY_REG(RTCx->PRLH, RTC_PRLH_PRL, (AsynchPrescaler >> 16)); 00280 MODIFY_REG(RTCx->PRLL, RTC_PRLL_PRL, (AsynchPrescaler & RTC_PRLL_PRL)); 00281 } 00282 00283 /** 00284 * @brief Get Asynchronous prescaler factor 00285 * @rmtoll DIVH DIV LL_RTC_GetDivider\n 00286 * @rmtoll DIVL DIV LL_RTC_GetDivider\n 00287 * @param RTCx RTC Instance 00288 * @retval Value between Min_Data = 0 and Max_Data = 0xFFFFF 00289 */ 00290 __STATIC_INLINE uint32_t LL_RTC_GetDivider(RTC_TypeDef *RTCx) 00291 { 00292 register uint16_t Highprescaler = 0, Lowprescaler = 0; 00293 Highprescaler = READ_REG(RTCx->DIVH & RTC_DIVH_RTC_DIV); 00294 Lowprescaler = READ_REG(RTCx->DIVL & RTC_DIVL_RTC_DIV); 00295 00296 return (((uint32_t) Highprescaler << 16U) | Lowprescaler); 00297 } 00298 00299 /** 00300 * @brief Set Output Source 00301 * @rmtoll RTCCR CCO LL_RTC_SetOutputSource 00302 * @rmtoll RTCCR ASOE LL_RTC_SetOutputSource 00303 * @rmtoll RTCCR ASOS LL_RTC_SetOutputSource 00304 * @param BKPx BKP Instance 00305 * @param OutputSource This parameter can be one of the following values: 00306 * @arg @ref LL_RTC_CALIB_OUTPUT_NONE 00307 * @arg @ref LL_RTC_CALIB_OUTPUT_RTCCLOCK 00308 * @arg @ref LL_RTC_CALIB_OUTPUT_ALARM 00309 * @arg @ref LL_RTC_CALIB_OUTPUT_SECOND 00310 * @retval None 00311 */ 00312 __STATIC_INLINE void LL_RTC_SetOutputSource(BKP_TypeDef *BKPx, uint32_t OutputSource) 00313 { 00314 MODIFY_REG(BKPx->RTCCR, (BKP_RTCCR_CCO | BKP_RTCCR_ASOE | BKP_RTCCR_ASOS), OutputSource); 00315 } 00316 00317 /** 00318 * @brief Get Output Source 00319 * @rmtoll RTCCR CCO LL_RTC_GetOutPutSource 00320 * @rmtoll RTCCR ASOE LL_RTC_GetOutPutSource 00321 * @rmtoll RTCCR ASOS LL_RTC_GetOutPutSource 00322 * @param BKPx BKP Instance 00323 * @retval Returned value can be one of the following values: 00324 * @arg @ref LL_RTC_CALIB_OUTPUT_NONE 00325 * @arg @ref LL_RTC_CALIB_OUTPUT_RTCCLOCK 00326 * @arg @ref LL_RTC_CALIB_OUTPUT_ALARM 00327 * @arg @ref LL_RTC_CALIB_OUTPUT_SECOND 00328 */ 00329 __STATIC_INLINE uint32_t LL_RTC_GetOutPutSource(BKP_TypeDef *BKPx) 00330 { 00331 return (uint32_t)(READ_BIT(BKPx->RTCCR, (BKP_RTCCR_CCO | BKP_RTCCR_ASOE | BKP_RTCCR_ASOS))); 00332 } 00333 00334 /** 00335 * @brief Enable the write protection for RTC registers. 00336 * @rmtoll CRL CNF LL_RTC_EnableWriteProtection 00337 * @param RTCx RTC Instance 00338 * @retval None 00339 */ 00340 __STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx) 00341 { 00342 CLEAR_BIT(RTCx->CRL, RTC_CRL_CNF); 00343 } 00344 00345 /** 00346 * @brief Disable the write protection for RTC registers. 00347 * @rmtoll CRL RTC_CRL_CNF LL_RTC_DisableWriteProtection 00348 * @param RTCx RTC Instance 00349 * @retval None 00350 */ 00351 __STATIC_INLINE void LL_RTC_DisableWriteProtection(RTC_TypeDef *RTCx) 00352 { 00353 SET_BIT(RTCx->CRL, RTC_CRL_CNF); 00354 } 00355 00356 /** 00357 * @} 00358 */ 00359 00360 /** @defgroup RTC_LL_EF_Time Time 00361 * @{ 00362 */ 00363 00364 /** 00365 * @brief Set time counter in BCD format 00366 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. 00367 * @note It can be written in initialization mode only (@ref LL_RTC_EnterInitMode function) 00368 * @rmtoll CNTH CNT LL_RTC_TIME_Set\n 00369 * CNTL CNT LL_RTC_TIME_Set\n 00370 * @param RTCx RTC Instance 00371 * @param TimeCounter Value between Min_Data=0x00 and Max_Data=0xFFFFF 00372 * @retval None 00373 */ 00374 __STATIC_INLINE void LL_RTC_TIME_Set(RTC_TypeDef *RTCx, uint32_t TimeCounter) 00375 { 00376 /* Set RTC COUNTER MSB word */ 00377 WRITE_REG(RTCx->CNTH, (TimeCounter >> 16U)); 00378 /* Set RTC COUNTER LSB word */ 00379 WRITE_REG(RTCx->CNTL, (TimeCounter & RTC_CNTL_RTC_CNT)); 00380 } 00381 00382 /** 00383 * @brief Get time counter in BCD format 00384 * @rmtoll CNTH CNT LL_RTC_TIME_Get\n 00385 * CNTL CNT LL_RTC_TIME_Get\n 00386 * @param RTCx RTC Instance 00387 * @retval Value between Min_Data = 0 and Max_Data = 0xFFFFF 00388 */ 00389 __STATIC_INLINE uint32_t LL_RTC_TIME_Get(RTC_TypeDef *RTCx) 00390 { 00391 register uint16_t high = 0, low = 0; 00392 00393 high = READ_REG(RTCx->CNTH & RTC_CNTH_RTC_CNT); 00394 low = READ_REG(RTCx->CNTL & RTC_CNTL_RTC_CNT); 00395 return ((uint32_t)(((uint32_t) high << 16U) | low)); 00396 } 00397 00398 /** 00399 * @} 00400 */ 00401 00402 /** @defgroup RTC_LL_EF_ALARM ALARM 00403 * @{ 00404 */ 00405 00406 /** 00407 * @brief Set Alarm Counter 00408 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. 00409 * @rmtoll ALRH ALR LL_RTC_ALARM_Set\n 00410 * @rmtoll ALRL ALR LL_RTC_ALARM_Set\n 00411 * @param RTCx RTC Instance 00412 * @param AlarmCounter Value between Min_Data=0x00 and Max_Data=0xFFFFF 00413 * @retval None 00414 */ 00415 __STATIC_INLINE void LL_RTC_ALARM_Set(RTC_TypeDef *RTCx, uint32_t AlarmCounter) 00416 { 00417 /* Set RTC COUNTER MSB word */ 00418 WRITE_REG(RTCx->ALRH, (AlarmCounter >> 16)); 00419 /* Set RTC COUNTER LSB word */ 00420 WRITE_REG(RTCx->ALRL, (AlarmCounter & RTC_ALRL_RTC_ALR)); 00421 } 00422 00423 /** 00424 * @brief Get Alarm Counter 00425 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. 00426 * @rmtoll ALRH ALR LL_RTC_ALARM_Get\n 00427 * @rmtoll ALRL ALR LL_RTC_ALARM_Get\n 00428 * @param RTCx RTC Instance 00429 * @retval None 00430 */ 00431 __STATIC_INLINE uint32_t LL_RTC_ALARM_Get(RTC_TypeDef *RTCx) 00432 { 00433 register uint16_t high = 0, low = 0; 00434 00435 high = READ_REG(RTCx->ALRH & RTC_ALRH_RTC_ALR); 00436 low = READ_REG(RTCx->ALRL & RTC_ALRL_RTC_ALR); 00437 00438 return (((uint32_t) high << 16U) | low); 00439 } 00440 00441 /** 00442 * @} 00443 */ 00444 00445 /** @defgroup RTC_LL_EF_Tamper Tamper 00446 * @{ 00447 */ 00448 00449 /** 00450 * @brief Enable RTC_TAMPx input detection 00451 * @rmtoll CR TPE LL_RTC_TAMPER_Enable\n 00452 * @retval None 00453 */ 00454 __STATIC_INLINE void LL_RTC_TAMPER_Enable(BKP_TypeDef *BKPx) 00455 { 00456 SET_BIT(BKPx->CR, BKP_CR_TPE); 00457 } 00458 00459 /** 00460 * @brief Disable RTC_TAMPx Tamper 00461 * @rmtoll CR TPE LL_RTC_TAMPER_Disable\n 00462 * @retval None 00463 */ 00464 __STATIC_INLINE void LL_RTC_TAMPER_Disable(BKP_TypeDef *BKPx) 00465 { 00466 CLEAR_BIT(BKP->CR, BKP_CR_TPE); 00467 } 00468 00469 /** 00470 * @brief Enable Active level for Tamper input 00471 * @rmtoll CR TPAL LL_RTC_TAMPER_SetActiveLevel\n 00472 * @param BKPx BKP Instance 00473 * @param Tamper This parameter can be a combination of the following values: 00474 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_LOW 00475 * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_HIGH 00476 * @retval None 00477 */ 00478 __STATIC_INLINE void LL_RTC_TAMPER_SetActiveLevel(BKP_TypeDef *BKPx, uint32_t Tamper) 00479 { 00480 MODIFY_REG(BKPx->CR, BKP_CR_TPAL, Tamper); 00481 } 00482 00483 /** 00484 * @brief Disable Active level for Tamper input 00485 * @rmtoll CR TPAL LL_RTC_TAMPER_SetActiveLevel\n 00486 * @retval None 00487 */ 00488 __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetActiveLevel(BKP_TypeDef *BKPx) 00489 { 00490 return (uint32_t)(READ_BIT(BKPx->CR, BKP_CR_TPAL)); 00491 } 00492 00493 /** 00494 * @} 00495 */ 00496 00497 /** @defgroup RTC_LL_EF_Backup_Registers Backup_Registers 00498 * @{ 00499 */ 00500 00501 /** 00502 * @brief Writes a data in a specified RTC Backup data register. 00503 * @rmtoll BKPDR DR LL_RTC_BKP_SetRegister 00504 * @param BKPx BKP Instance 00505 * @param BackupRegister This parameter can be one of the following values: 00506 * @arg @ref LL_RTC_BKP_DR1 00507 * @arg @ref LL_RTC_BKP_DR2 00508 * @arg @ref LL_RTC_BKP_DR3 00509 * @arg @ref LL_RTC_BKP_DR4 00510 * @arg @ref LL_RTC_BKP_DR5 00511 * @arg @ref LL_RTC_BKP_DR6 00512 * @arg @ref LL_RTC_BKP_DR7 00513 * @arg @ref LL_RTC_BKP_DR8 00514 * @arg @ref LL_RTC_BKP_DR9 00515 * @arg @ref LL_RTC_BKP_DR10 00516 * @arg @ref LL_RTC_BKP_DR11 (*) 00517 * @arg @ref LL_RTC_BKP_DR12 (*) 00518 * @arg @ref LL_RTC_BKP_DR13 (*) 00519 * @arg @ref LL_RTC_BKP_DR14 (*) 00520 * @arg @ref LL_RTC_BKP_DR15 (*) 00521 * @arg @ref LL_RTC_BKP_DR16 (*) 00522 * @arg @ref LL_RTC_BKP_DR17 (*) 00523 * @arg @ref LL_RTC_BKP_DR18 (*) 00524 * @arg @ref LL_RTC_BKP_DR19 (*) 00525 * @arg @ref LL_RTC_BKP_DR20 (*) 00526 * @arg @ref LL_RTC_BKP_DR21 (*) 00527 * @arg @ref LL_RTC_BKP_DR22 (*) 00528 * @arg @ref LL_RTC_BKP_DR23 (*) 00529 * @arg @ref LL_RTC_BKP_DR24 (*) 00530 * @arg @ref LL_RTC_BKP_DR25 (*) 00531 * @arg @ref LL_RTC_BKP_DR26 (*) 00532 * @arg @ref LL_RTC_BKP_DR27 (*) 00533 * @arg @ref LL_RTC_BKP_DR28 (*) 00534 * @arg @ref LL_RTC_BKP_DR29 (*) 00535 * @arg @ref LL_RTC_BKP_DR30 (*) 00536 * @arg @ref LL_RTC_BKP_DR31 (*) 00537 * @arg @ref LL_RTC_BKP_DR32 (*) 00538 * @arg @ref LL_RTC_BKP_DR33 (*) 00539 * @arg @ref LL_RTC_BKP_DR34 (*) 00540 * @arg @ref LL_RTC_BKP_DR35 (*) 00541 * @arg @ref LL_RTC_BKP_DR36 (*) 00542 * @arg @ref LL_RTC_BKP_DR37 (*) 00543 * @arg @ref LL_RTC_BKP_DR38 (*) 00544 * @arg @ref LL_RTC_BKP_DR39 (*) 00545 * @arg @ref LL_RTC_BKP_DR40 (*) 00546 * @arg @ref LL_RTC_BKP_DR41 (*) 00547 * @arg @ref LL_RTC_BKP_DR42 (*) 00548 * (*) value not defined in all devices. 00549 * @param Data Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF 00550 * @retval None 00551 */ 00552 __STATIC_INLINE void LL_RTC_BKP_SetRegister(BKP_TypeDef *BKPx, uint32_t BackupRegister, uint32_t Data) 00553 { 00554 register uint32_t tmp = 0U; 00555 00556 tmp = (uint32_t)BKP_BASE; 00557 tmp += (BackupRegister * 4U); 00558 00559 /* Write the specified register */ 00560 *(__IO uint32_t *)tmp = (uint32_t)Data; 00561 } 00562 00563 /** 00564 * @brief Reads data from the specified RTC Backup data Register. 00565 * @rmtoll BKPDR DR LL_RTC_BKP_GetRegister 00566 * @param BKPx BKP Instance 00567 * @param BackupRegister This parameter can be one of the following values: 00568 * @arg @ref LL_RTC_BKP_DR1 00569 * @arg @ref LL_RTC_BKP_DR2 00570 * @arg @ref LL_RTC_BKP_DR3 00571 * @arg @ref LL_RTC_BKP_DR4 00572 * @arg @ref LL_RTC_BKP_DR5 00573 * @arg @ref LL_RTC_BKP_DR6 00574 * @arg @ref LL_RTC_BKP_DR7 00575 * @arg @ref LL_RTC_BKP_DR8 00576 * @arg @ref LL_RTC_BKP_DR9 00577 * @arg @ref LL_RTC_BKP_DR10 00578 * @arg @ref LL_RTC_BKP_DR11 (*) 00579 * @arg @ref LL_RTC_BKP_DR12 (*) 00580 * @arg @ref LL_RTC_BKP_DR13 (*) 00581 * @arg @ref LL_RTC_BKP_DR14 (*) 00582 * @arg @ref LL_RTC_BKP_DR15 (*) 00583 * @arg @ref LL_RTC_BKP_DR16 (*) 00584 * @arg @ref LL_RTC_BKP_DR17 (*) 00585 * @arg @ref LL_RTC_BKP_DR18 (*) 00586 * @arg @ref LL_RTC_BKP_DR19 (*) 00587 * @arg @ref LL_RTC_BKP_DR20 (*) 00588 * @arg @ref LL_RTC_BKP_DR21 (*) 00589 * @arg @ref LL_RTC_BKP_DR22 (*) 00590 * @arg @ref LL_RTC_BKP_DR23 (*) 00591 * @arg @ref LL_RTC_BKP_DR24 (*) 00592 * @arg @ref LL_RTC_BKP_DR25 (*) 00593 * @arg @ref LL_RTC_BKP_DR26 (*) 00594 * @arg @ref LL_RTC_BKP_DR27 (*) 00595 * @arg @ref LL_RTC_BKP_DR28 (*) 00596 * @arg @ref LL_RTC_BKP_DR29 (*) 00597 * @arg @ref LL_RTC_BKP_DR30 (*) 00598 * @arg @ref LL_RTC_BKP_DR31 (*) 00599 * @arg @ref LL_RTC_BKP_DR32 (*) 00600 * @arg @ref LL_RTC_BKP_DR33 (*) 00601 * @arg @ref LL_RTC_BKP_DR34 (*) 00602 * @arg @ref LL_RTC_BKP_DR35 (*) 00603 * @arg @ref LL_RTC_BKP_DR36 (*) 00604 * @arg @ref LL_RTC_BKP_DR37 (*) 00605 * @arg @ref LL_RTC_BKP_DR38 (*) 00606 * @arg @ref LL_RTC_BKP_DR39 (*) 00607 * @arg @ref LL_RTC_BKP_DR40 (*) 00608 * @arg @ref LL_RTC_BKP_DR41 (*) 00609 * @arg @ref LL_RTC_BKP_DR42 (*) 00610 * @retval Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF 00611 */ 00612 __STATIC_INLINE uint32_t LL_RTC_BKP_GetRegister(BKP_TypeDef *BKPx, uint32_t BackupRegister) 00613 { 00614 register uint32_t tmp = 0U; 00615 00616 tmp = (uint32_t)BKP_BASE; 00617 tmp += (BackupRegister * 4U); 00618 00619 /* Read the specified register */ 00620 return ((*(__IO uint32_t *)tmp) & BKP_DR1_D); 00621 } 00622 00623 /** 00624 * @} 00625 */ 00626 00627 /** @defgroup RTC_LL_EF_Calibration Calibration 00628 * @{ 00629 */ 00630 00631 /** 00632 * @brief Set the coarse digital calibration 00633 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. 00634 * @note It can be written in initialization mode only (@ref LL_RTC_EnterInitMode function) 00635 * @rmtoll RTCCR CAL LL_RTC_CAL_SetCoarseDigital\n 00636 * @param BKPx RTC Instance 00637 * @param Value value of coarse calibration expressed in ppm (coded on 5 bits) 00638 * @note This Calibration value should be between 0 and 121 when using positive sign with a 4-ppm step. 00639 * @retval None 00640 */ 00641 __STATIC_INLINE void LL_RTC_CAL_SetCoarseDigital(BKP_TypeDef *BKPx, uint32_t Value) 00642 { 00643 MODIFY_REG(BKPx->RTCCR, BKP_RTCCR_CAL, Value); 00644 } 00645 00646 /** 00647 * @brief Get the coarse digital calibration value 00648 * @rmtoll RTCCR CAL LL_RTC_CAL_SetCoarseDigital\n 00649 * @param BKPx BKP Instance 00650 * @retval value of coarse calibration expressed in ppm (coded on 5 bits) 00651 */ 00652 __STATIC_INLINE uint32_t LL_RTC_CAL_GetCoarseDigital(BKP_TypeDef *BKPx) 00653 { 00654 return (uint32_t)(READ_BIT(BKPx->RTCCR, BKP_RTCCR_CAL)); 00655 } 00656 /** 00657 * @} 00658 */ 00659 00660 /** @defgroup RTC_LL_EF_FLAG_Management FLAG_Management 00661 * @{ 00662 */ 00663 00664 /** 00665 * @brief Get RTC_TAMPI Interruption detection flag 00666 * @rmtoll CSR TIF LL_RTC_IsActiveFlag_TAMPI 00667 * @param BKPx BKP Instance 00668 * @retval State of bit (1 or 0). 00669 */ 00670 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMPI(BKP_TypeDef *BKPx) 00671 { 00672 return (READ_BIT(BKPx->CSR, BKP_CSR_TIF) == (BKP_CSR_TIF)); 00673 } 00674 00675 /** 00676 * @brief Clear RTC_TAMP Interruption detection flag 00677 * @rmtoll CSR CTI LL_RTC_ClearFlag_TAMPI 00678 * @param BKPx BKP Instance 00679 * @retval None 00680 */ 00681 __STATIC_INLINE void LL_RTC_ClearFlag_TAMPI(BKP_TypeDef *BKPx) 00682 { 00683 SET_BIT(BKPx->CSR, BKP_CSR_CTI); 00684 } 00685 00686 /** 00687 * @brief Get RTC_TAMPE Event detection flag 00688 * @rmtoll CSR TEF LL_RTC_IsActiveFlag_TAMPE 00689 * @param BKPx BKP Instance 00690 * @retval State of bit (1 or 0). 00691 */ 00692 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMPE(BKP_TypeDef *BKPx) 00693 { 00694 return (READ_BIT(BKPx->CSR, BKP_CSR_TEF) == (BKP_CSR_TEF)); 00695 } 00696 00697 /** 00698 * @brief Clear RTC_TAMPE Even detection flag 00699 * @rmtoll CSR CTE LL_RTC_ClearFlag_TAMPE 00700 * @param BKPx BKP Instance 00701 * @retval None 00702 */ 00703 __STATIC_INLINE void LL_RTC_ClearFlag_TAMPE(BKP_TypeDef *BKPx) 00704 { 00705 SET_BIT(BKPx->CSR, BKP_CSR_CTE); 00706 } 00707 00708 /** 00709 * @brief Get Alarm flag 00710 * @rmtoll CRL ALRF LL_RTC_IsActiveFlag_ALR 00711 * @param RTCx RTC Instance 00712 * @retval State of bit (1 or 0). 00713 */ 00714 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALR(RTC_TypeDef *RTCx) 00715 { 00716 return (READ_BIT(RTCx->CRL, RTC_CRL_ALRF) == (RTC_CRL_ALRF)); 00717 } 00718 00719 /** 00720 * @brief Clear Alarm flag 00721 * @rmtoll CRL ALRF LL_RTC_ClearFlag_ALR 00722 * @param RTCx RTC Instance 00723 * @retval None 00724 */ 00725 __STATIC_INLINE void LL_RTC_ClearFlag_ALR(RTC_TypeDef *RTCx) 00726 { 00727 CLEAR_BIT(RTCx->CRL, RTC_CRL_ALRF); 00728 } 00729 00730 /** 00731 * @brief Get Registers synchronization flag 00732 * @rmtoll CRL RSF LL_RTC_IsActiveFlag_RS 00733 * @param RTCx RTC Instance 00734 * @retval State of bit (1 or 0). 00735 */ 00736 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(RTC_TypeDef *RTCx) 00737 { 00738 return (READ_BIT(RTCx->CRL, RTC_CRL_RSF) == (RTC_CRL_RSF)); 00739 } 00740 00741 /** 00742 * @brief Clear Registers synchronization flag 00743 * @rmtoll CRL RSF LL_RTC_ClearFlag_RS 00744 * @param RTCx RTC Instance 00745 * @retval None 00746 */ 00747 __STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx) 00748 { 00749 CLEAR_BIT(RTCx->CRL, RTC_CRL_RSF); 00750 } 00751 00752 /** 00753 * @brief Get Registers OverFlow flag 00754 * @rmtoll CRL OWF LL_RTC_IsActiveFlag_OW 00755 * @param RTCx RTC Instance 00756 * @retval State of bit (1 or 0). 00757 */ 00758 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_OW(RTC_TypeDef *RTCx) 00759 { 00760 return (READ_BIT(RTCx->CRL, RTC_CRL_OWF) == (RTC_CRL_OWF)); 00761 } 00762 00763 /** 00764 * @brief Clear Registers OverFlow flag 00765 * @rmtoll CRL OWF LL_RTC_ClearFlag_OW 00766 * @param RTCx RTC Instance 00767 * @retval None 00768 */ 00769 __STATIC_INLINE void LL_RTC_ClearFlag_OW(RTC_TypeDef *RTCx) 00770 { 00771 CLEAR_BIT(RTCx->CRL, RTC_CRL_OWF); 00772 } 00773 00774 /** 00775 * @brief Get Registers synchronization flag 00776 * @rmtoll CRL SECF LL_RTC_IsActiveFlag_SEC 00777 * @param RTCx RTC Instance 00778 * @retval State of bit (1 or 0). 00779 */ 00780 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SEC(RTC_TypeDef *RTCx) 00781 { 00782 return (READ_BIT(RTCx->CRL, RTC_CRL_SECF) == (RTC_CRL_SECF)); 00783 } 00784 00785 /** 00786 * @brief Clear Registers synchronization flag 00787 * @rmtoll CRL SECF LL_RTC_ClearFlag_SEC 00788 * @param RTCx RTC Instance 00789 * @retval None 00790 */ 00791 __STATIC_INLINE void LL_RTC_ClearFlag_SEC(RTC_TypeDef *RTCx) 00792 { 00793 CLEAR_BIT(RTCx->CRL, RTC_CRL_SECF); 00794 } 00795 00796 /** 00797 * @brief Get RTC Operation OFF status flag 00798 * @rmtoll CRL RTOFF LL_RTC_IsActiveFlag_RTOF 00799 * @param RTCx RTC Instance 00800 * @retval State of bit (1 or 0). 00801 */ 00802 __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RTOF(RTC_TypeDef *RTCx) 00803 { 00804 return (READ_BIT(RTCx->CRL, RTC_CRL_RTOFF) == (RTC_CRL_RTOFF)); 00805 } 00806 00807 /** 00808 * @} 00809 */ 00810 00811 /** @defgroup RTC_LL_EF_IT_Management IT_Management 00812 * @{ 00813 */ 00814 00815 /** 00816 * @brief Enable Alarm interrupt 00817 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. 00818 * @rmtoll CRH ALRIE LL_RTC_EnableIT_ALR 00819 * @param RTCx RTC Instance 00820 * @retval None 00821 */ 00822 __STATIC_INLINE void LL_RTC_EnableIT_ALR(RTC_TypeDef *RTCx) 00823 { 00824 SET_BIT(RTCx->CRH, RTC_CRH_ALRIE); 00825 } 00826 00827 /** 00828 * @brief Disable Alarm interrupt 00829 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. 00830 * @rmtoll CRH ALRIE LL_RTC_DisableIT_ALR 00831 * @param RTCx RTC Instance 00832 * @retval None 00833 */ 00834 __STATIC_INLINE void LL_RTC_DisableIT_ALR(RTC_TypeDef *RTCx) 00835 { 00836 CLEAR_BIT(RTCx->CRH, RTC_CRH_ALRIE); 00837 } 00838 00839 /** 00840 * @brief Check if Alarm interrupt is enabled or not 00841 * @rmtoll CRH ALRIE LL_RTC_IsEnabledIT_ALR 00842 * @param RTCx RTC Instance 00843 * @retval State of bit (1 or 0). 00844 */ 00845 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALR(RTC_TypeDef *RTCx) 00846 { 00847 return (READ_BIT(RTCx->CRH, RTC_CRH_ALRIE) == (RTC_CRH_ALRIE)); 00848 } 00849 00850 /** 00851 * @brief Enable Second Interrupt interrupt 00852 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. 00853 * @rmtoll CRH SECIE LL_RTC_EnableIT_SEC 00854 * @param RTCx RTC Instance 00855 * @retval None 00856 */ 00857 __STATIC_INLINE void LL_RTC_EnableIT_SEC(RTC_TypeDef *RTCx) 00858 { 00859 SET_BIT(RTCx->CRH, RTC_CRH_SECIE); 00860 } 00861 00862 /** 00863 * @brief Disable Second interrupt 00864 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. 00865 * @rmtoll CRH SECIE LL_RTC_DisableIT_SEC 00866 * @param RTCx RTC Instance 00867 * @retval None 00868 */ 00869 __STATIC_INLINE void LL_RTC_DisableIT_SEC(RTC_TypeDef *RTCx) 00870 { 00871 CLEAR_BIT(RTCx->CRH, RTC_CRH_SECIE); 00872 } 00873 00874 /** 00875 * @brief Check if Second interrupt is enabled or not 00876 * @rmtoll CRH SECIE LL_RTC_IsEnabledIT_SEC 00877 * @param RTCx RTC Instance 00878 * @retval State of bit (1 or 0). 00879 */ 00880 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_SEC(RTC_TypeDef *RTCx) 00881 { 00882 return (READ_BIT(RTCx->CRH, RTC_CRH_SECIE) == (RTC_CRH_SECIE)); 00883 } 00884 00885 /** 00886 * @brief Enable OverFlow interrupt 00887 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. 00888 * @rmtoll CRH OWIE LL_RTC_EnableIT_OW 00889 * @param RTCx RTC Instance 00890 * @retval None 00891 */ 00892 __STATIC_INLINE void LL_RTC_EnableIT_OW(RTC_TypeDef *RTCx) 00893 { 00894 SET_BIT(RTCx->CRH, RTC_CRH_OWIE); 00895 } 00896 00897 /** 00898 * @brief Disable OverFlow interrupt 00899 * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. 00900 * @rmtoll CRH OWIE LL_RTC_DisableIT_OW 00901 * @param RTCx RTC Instance 00902 * @retval None 00903 */ 00904 __STATIC_INLINE void LL_RTC_DisableIT_OW(RTC_TypeDef *RTCx) 00905 { 00906 CLEAR_BIT(RTCx->CRH, RTC_CRH_OWIE); 00907 } 00908 00909 /** 00910 * @brief Check if OverFlow interrupt is enabled or not 00911 * @rmtoll CRH OWIE LL_RTC_IsEnabledIT_OW 00912 * @param RTCx RTC Instance 00913 * @retval State of bit (1 or 0). 00914 */ 00915 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_OW(RTC_TypeDef *RTCx) 00916 { 00917 return (READ_BIT(RTCx->CRH, RTC_CRH_OWIE) == (RTC_CRH_OWIE)); 00918 } 00919 00920 /** 00921 * @brief Enable Tamper interrupt 00922 * @rmtoll CSR TPIE LL_RTC_EnableIT_TAMP 00923 * @param BKPx BKP Instance 00924 * @retval None 00925 */ 00926 __STATIC_INLINE void LL_RTC_EnableIT_TAMP(BKP_TypeDef *BKPx) 00927 { 00928 SET_BIT(BKPx->CSR, BKP_CSR_TPIE); 00929 } 00930 00931 /** 00932 * @brief Disable Tamper interrupt 00933 * @rmtoll CSR TPIE LL_RTC_EnableIT_TAMP 00934 * @param BKPx BKP Instance 00935 * @retval None 00936 */ 00937 __STATIC_INLINE void LL_RTC_DisableIT_TAMP(BKP_TypeDef *BKPx) 00938 { 00939 CLEAR_BIT(BKPx->CSR, BKP_CSR_TPIE); 00940 } 00941 00942 /** 00943 * @brief Check if all the TAMPER interrupts are enabled or not 00944 * @rmtoll CSR TPIE LL_RTC_IsEnabledIT_TAMP 00945 * @param BKPx BKP Instance 00946 * @retval State of bit (1 or 0). 00947 */ 00948 __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP(BKP_TypeDef *BKPx) 00949 { 00950 return (READ_BIT(BKPx->CSR, BKP_CSR_TPIE) == BKP_CSR_TPIE); 00951 } 00952 /** 00953 * @} 00954 */ 00955 00956 #if defined(USE_FULL_LL_DRIVER) 00957 /** @defgroup RTC_LL_EF_Init Initialization and de-initialization functions 00958 * @{ 00959 */ 00960 00961 ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx); 00962 ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct); 00963 void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct); 00964 ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct); 00965 void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct); 00966 ErrorStatus LL_RTC_ALARM_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct); 00967 void LL_RTC_ALARM_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct); 00968 ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx); 00969 ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx); 00970 ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx); 00971 ErrorStatus LL_RTC_TIME_SetCounter(RTC_TypeDef *RTCx, uint32_t TimeCounter); 00972 ErrorStatus LL_RTC_ALARM_SetCounter(RTC_TypeDef *RTCx, uint32_t AlarmCounter); 00973 00974 /** 00975 * @} 00976 */ 00977 #endif /* USE_FULL_LL_DRIVER */ 00978 00979 /** 00980 * @} 00981 */ 00982 00983 /** 00984 * @} 00985 */ 00986 00987 /** 00988 * @} 00989 */ 00990 00991 #endif /* defined(RTC) */ 00992 00993 /** 00994 * @} 00995 */ 00996 00997 #ifdef __cplusplus 00998 } 00999 #endif 01000 01001 #endif /* __STM32F1xx_LL_RTC_H */ 01002 01003 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/