Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | mjames | 1 | /** |
| 2 | ****************************************************************************** |
||
| 3 | * @file stm32f1xx_ll_rtc.h |
||
| 4 | * @author MCD Application Team |
||
| 5 | * @brief Header file of RTC LL module. |
||
| 6 | ****************************************************************************** |
||
| 7 | * @attention |
||
| 8 | * |
||
| 9 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
||
| 10 | * |
||
| 11 | * Redistribution and use in source and binary forms, with or without modification, |
||
| 12 | * are permitted provided that the following conditions are met: |
||
| 13 | * 1. Redistributions of source code must retain the above copyright notice, |
||
| 14 | * this list of conditions and the following disclaimer. |
||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
||
| 16 | * this list of conditions and the following disclaimer in the documentation |
||
| 17 | * and/or other materials provided with the distribution. |
||
| 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
||
| 19 | * may be used to endorse or promote products derived from this software |
||
| 20 | * without specific prior written permission. |
||
| 21 | * |
||
| 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
| 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
| 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||
| 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||
| 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||
| 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||
| 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||
| 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||
| 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||
| 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
| 32 | * |
||
| 33 | ****************************************************************************** |
||
| 34 | */ |
||
| 35 | |||
| 36 | /* Define to prevent recursive inclusion -------------------------------------*/ |
||
| 37 | #ifndef __STM32F1xx_LL_RTC_H |
||
| 38 | #define __STM32F1xx_LL_RTC_H |
||
| 39 | |||
| 40 | #ifdef __cplusplus |
||
| 41 | extern "C" { |
||
| 42 | #endif |
||
| 43 | |||
| 44 | /* Includes ------------------------------------------------------------------*/ |
||
| 45 | #include "stm32f1xx.h" |
||
| 46 | |||
| 47 | /** @addtogroup STM32F1xx_LL_Driver |
||
| 48 | * @{ |
||
| 49 | */ |
||
| 50 | |||
| 51 | #if defined(RTC) |
||
| 52 | |||
| 53 | /** @defgroup RTC_LL RTC |
||
| 54 | * @{ |
||
| 55 | */ |
||
| 56 | |||
| 57 | /* Private types -------------------------------------------------------------*/ |
||
| 58 | /* Private variables ---------------------------------------------------------*/ |
||
| 59 | /* Private constants ---------------------------------------------------------*/ |
||
| 60 | |||
| 61 | /* Private macros ------------------------------------------------------------*/ |
||
| 62 | #if defined(USE_FULL_LL_DRIVER) |
||
| 63 | /** @defgroup RTC_LL_Private_Macros RTC Private Macros |
||
| 64 | * @{ |
||
| 65 | */ |
||
| 66 | /** |
||
| 67 | * @} |
||
| 68 | */ |
||
| 69 | #endif /*USE_FULL_LL_DRIVER*/ |
||
| 70 | |||
| 71 | /* Exported types ------------------------------------------------------------*/ |
||
| 72 | #if defined(USE_FULL_LL_DRIVER) |
||
| 73 | /** @defgroup RTC_LL_ES_INIT RTC Exported Init structure |
||
| 74 | * @{ |
||
| 75 | */ |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @brief RTC Init structures definition |
||
| 79 | */ |
||
| 80 | typedef struct |
||
| 81 | { |
||
| 82 | uint32_t AsynchPrescaler; /*!< Specifies the RTC Asynchronous Predivider value. |
||
| 83 | This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFFF |
||
| 84 | |||
| 85 | This feature can be modified afterwards using unitary function |
||
| 86 | @ref LL_RTC_SetAsynchPrescaler(). */ |
||
| 87 | |||
| 88 | uint32_t OutPutSource; /*!< Specifies which signal will be routed to the RTC Tamper pin. |
||
| 89 | This parameter can be a value of @ref LL_RTC_Output_Source |
||
| 90 | |||
| 91 | This feature can be modified afterwards using unitary function |
||
| 92 | @ref LL_RTC_SetOutputSource(). */ |
||
| 93 | |||
| 94 | } LL_RTC_InitTypeDef; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @brief RTC Time structure definition |
||
| 98 | */ |
||
| 99 | typedef struct |
||
| 100 | { |
||
| 101 | uint8_t Hours; /*!< Specifies the RTC Time Hours. |
||
| 102 | This parameter must be a number between Min_Data = 0 and Max_Data = 23 */ |
||
| 103 | |||
| 104 | uint8_t Minutes; /*!< Specifies the RTC Time Minutes. |
||
| 105 | This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ |
||
| 106 | |||
| 107 | uint8_t Seconds; /*!< Specifies the RTC Time Seconds. |
||
| 108 | This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ |
||
| 109 | } LL_RTC_TimeTypeDef; |
||
| 110 | |||
| 111 | |||
| 112 | /** |
||
| 113 | * @brief RTC Alarm structure definition |
||
| 114 | */ |
||
| 115 | typedef struct |
||
| 116 | { |
||
| 117 | LL_RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members. */ |
||
| 118 | |||
| 119 | } LL_RTC_AlarmTypeDef; |
||
| 120 | |||
| 121 | /** |
||
| 122 | * @} |
||
| 123 | */ |
||
| 124 | #endif /* USE_FULL_LL_DRIVER */ |
||
| 125 | |||
| 126 | /* Exported constants --------------------------------------------------------*/ |
||
| 127 | /** @defgroup RTC_LL_Exported_Constants RTC Exported Constants |
||
| 128 | * @{ |
||
| 129 | */ |
||
| 130 | |||
| 131 | #if defined(USE_FULL_LL_DRIVER) |
||
| 132 | /** @defgroup RTC_LL_EC_FORMAT FORMAT |
||
| 133 | * @{ |
||
| 134 | */ |
||
| 135 | #define LL_RTC_FORMAT_BIN (0x000000000U) /*!< Binary data format */ |
||
| 136 | #define LL_RTC_FORMAT_BCD (0x000000001U) /*!< BCD data format */ |
||
| 137 | /** |
||
| 138 | * @} |
||
| 139 | */ |
||
| 140 | #endif /* USE_FULL_LL_DRIVER */ |
||
| 141 | |||
| 142 | /** @defgroup RTC_LL_EC_BKP BACKUP |
||
| 143 | * @{ |
||
| 144 | */ |
||
| 145 | #if RTC_BKP_NUMBER > 0 |
||
| 146 | #define LL_RTC_BKP_DR1 (0x00000001U) |
||
| 147 | #define LL_RTC_BKP_DR2 (0x00000002U) |
||
| 148 | #define LL_RTC_BKP_DR3 (0x00000003U) |
||
| 149 | #define LL_RTC_BKP_DR4 (0x00000004U) |
||
| 150 | #define LL_RTC_BKP_DR5 (0x00000005U) |
||
| 151 | #define LL_RTC_BKP_DR6 (0x00000006U) |
||
| 152 | #define LL_RTC_BKP_DR7 (0x00000007U) |
||
| 153 | #define LL_RTC_BKP_DR8 (0x00000008U) |
||
| 154 | #define LL_RTC_BKP_DR9 (0x00000009U) |
||
| 155 | #define LL_RTC_BKP_DR10 (0x0000000AU) |
||
| 156 | #endif /* RTC_BKP_NUMBER > 0 */ |
||
| 157 | #if RTC_BKP_NUMBER > 10 |
||
| 158 | #define LL_RTC_BKP_DR11 (0x0000000BU) |
||
| 159 | #define LL_RTC_BKP_DR12 (0x0000000CU) |
||
| 160 | #define LL_RTC_BKP_DR13 (0x0000000DU) |
||
| 161 | #define LL_RTC_BKP_DR14 (0x0000000EU) |
||
| 162 | #define LL_RTC_BKP_DR15 (0x0000000FU) |
||
| 163 | #define LL_RTC_BKP_DR16 (0x00000010U) |
||
| 164 | #define LL_RTC_BKP_DR17 (0x00000011U) |
||
| 165 | #define LL_RTC_BKP_DR18 (0x00000012U) |
||
| 166 | #define LL_RTC_BKP_DR19 (0x00000013U) |
||
| 167 | #define LL_RTC_BKP_DR20 (0x00000014U) |
||
| 168 | #define LL_RTC_BKP_DR21 (0x00000015U) |
||
| 169 | #define LL_RTC_BKP_DR22 (0x00000016U) |
||
| 170 | #define LL_RTC_BKP_DR23 (0x00000017U) |
||
| 171 | #define LL_RTC_BKP_DR24 (0x00000018U) |
||
| 172 | #define LL_RTC_BKP_DR25 (0x00000019U) |
||
| 173 | #define LL_RTC_BKP_DR26 (0x0000001AU) |
||
| 174 | #define LL_RTC_BKP_DR27 (0x0000001BU) |
||
| 175 | #define LL_RTC_BKP_DR28 (0x0000001CU) |
||
| 176 | #define LL_RTC_BKP_DR29 (0x0000001DU) |
||
| 177 | #define LL_RTC_BKP_DR30 (0x0000001EU) |
||
| 178 | #define LL_RTC_BKP_DR31 (0x0000001FU) |
||
| 179 | #define LL_RTC_BKP_DR32 (0x00000020U) |
||
| 180 | #define LL_RTC_BKP_DR33 (0x00000021U) |
||
| 181 | #define LL_RTC_BKP_DR34 (0x00000022U) |
||
| 182 | #define LL_RTC_BKP_DR35 (0x00000023U) |
||
| 183 | #define LL_RTC_BKP_DR36 (0x00000024U) |
||
| 184 | #define LL_RTC_BKP_DR37 (0x00000025U) |
||
| 185 | #define LL_RTC_BKP_DR38 (0x00000026U) |
||
| 186 | #define LL_RTC_BKP_DR39 (0x00000027U) |
||
| 187 | #define LL_RTC_BKP_DR40 (0x00000028U) |
||
| 188 | #define LL_RTC_BKP_DR41 (0x00000029U) |
||
| 189 | #define LL_RTC_BKP_DR42 (0x0000002AU) |
||
| 190 | #endif /* RTC_BKP_NUMBER > 10 */ |
||
| 191 | |||
| 192 | /** |
||
| 193 | * @} |
||
| 194 | */ |
||
| 195 | |||
| 196 | /** @defgroup RTC_LL_EC_TAMPLEVEL Tamper Active Level |
||
| 197 | * @{ |
||
| 198 | */ |
||
| 199 | #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) */ |
||
| 200 | #define LL_RTC_TAMPER_ACTIVELEVEL_HIGH (0x00000000U) /*!< A low level on the TAMPER pin resets all data backup registers (if TPE bit is set) */ |
||
| 201 | |||
| 202 | /** |
||
| 203 | * @} |
||
| 204 | */ |
||
| 205 | |||
| 206 | /** @defgroup LL_RTC_Output_Source Clock Source to output on the Tamper Pin |
||
| 207 | * @{ |
||
| 208 | */ |
||
| 209 | #define LL_RTC_CALIB_OUTPUT_NONE (0x00000000U) /*!< Calibration output disabled */ |
||
| 210 | #define LL_RTC_CALIB_OUTPUT_RTCCLOCK BKP_RTCCR_CCO /*!< Calibration output is RTC Clock with a frequency divided by 64 on the TAMPER Pin */ |
||
| 211 | #define LL_RTC_CALIB_OUTPUT_ALARM BKP_RTCCR_ASOE /*!< Calibration output is Alarm pulse signal on the TAMPER pin */ |
||
| 212 | #define LL_RTC_CALIB_OUTPUT_SECOND (BKP_RTCCR_ASOS | BKP_RTCCR_ASOE) /*!< Calibration output is Second pulse signal on the TAMPER pin*/ |
||
| 213 | /** |
||
| 214 | * @} |
||
| 215 | */ |
||
| 216 | |||
| 217 | /** |
||
| 218 | * @} |
||
| 219 | */ |
||
| 220 | |||
| 221 | /* Exported macro ------------------------------------------------------------*/ |
||
| 222 | /** @defgroup RTC_LL_Exported_Macros RTC Exported Macros |
||
| 223 | * @{ |
||
| 224 | */ |
||
| 225 | |||
| 226 | /** @defgroup RTC_LL_EM_WRITE_READ Common Write and read registers Macros |
||
| 227 | * @{ |
||
| 228 | */ |
||
| 229 | |||
| 230 | /** |
||
| 231 | * @brief Write a value in RTC register |
||
| 232 | * @param __INSTANCE__ RTC Instance |
||
| 233 | * @param __REG__ Register to be written |
||
| 234 | * @param __VALUE__ Value to be written in the register |
||
| 235 | * @retval None |
||
| 236 | */ |
||
| 237 | #define LL_RTC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) |
||
| 238 | |||
| 239 | /** |
||
| 240 | * @brief Read a value in RTC register |
||
| 241 | * @param __INSTANCE__ RTC Instance |
||
| 242 | * @param __REG__ Register to be read |
||
| 243 | * @retval Register value |
||
| 244 | */ |
||
| 245 | #define LL_RTC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) |
||
| 246 | /** |
||
| 247 | * @} |
||
| 248 | */ |
||
| 249 | |||
| 250 | /** @defgroup RTC_LL_EM_Convert Convert helper Macros |
||
| 251 | * @{ |
||
| 252 | */ |
||
| 253 | |||
| 254 | /** |
||
| 255 | * @brief Helper macro to convert a value from 2 digit decimal format to BCD format |
||
| 256 | * @param __VALUE__ Byte to be converted |
||
| 257 | * @retval Converted byte |
||
| 258 | */ |
||
| 259 | #define __LL_RTC_CONVERT_BIN2BCD(__VALUE__) (uint8_t)((((__VALUE__) / 10U) << 4U) | ((__VALUE__) % 10U)) |
||
| 260 | |||
| 261 | /** |
||
| 262 | * @brief Helper macro to convert a value from BCD format to 2 digit decimal format |
||
| 263 | * @param __VALUE__ BCD value to be converted |
||
| 264 | * @retval Converted byte |
||
| 265 | */ |
||
| 266 | #define __LL_RTC_CONVERT_BCD2BIN(__VALUE__) (uint8_t)(((uint8_t)((__VALUE__) & (uint8_t)0xF0U) >> (uint8_t)0x4U) * 10U + ((__VALUE__) & (uint8_t)0x0FU)) |
||
| 267 | |||
| 268 | /** |
||
| 269 | * @} |
||
| 270 | */ |
||
| 271 | |||
| 272 | /** |
||
| 273 | * @} |
||
| 274 | */ |
||
| 275 | |||
| 276 | /* Exported functions --------------------------------------------------------*/ |
||
| 277 | /** @defgroup RTC_LL_Exported_Functions RTC Exported Functions |
||
| 278 | * @{ |
||
| 279 | */ |
||
| 280 | |||
| 281 | /** @defgroup RTC_LL_EF_Configuration Configuration |
||
| 282 | * @{ |
||
| 283 | */ |
||
| 284 | |||
| 285 | /** |
||
| 286 | * @brief Set Asynchronous prescaler factor |
||
| 287 | * @rmtoll PRLH PRL LL_RTC_SetAsynchPrescaler\n |
||
| 288 | * @rmtoll PRLL PRL LL_RTC_SetAsynchPrescaler\n |
||
| 289 | * @param RTCx RTC Instance |
||
| 290 | * @param AsynchPrescaler Value between Min_Data = 0 and Max_Data = 0xFFFFF |
||
| 291 | * @retval None |
||
| 292 | */ |
||
| 293 | __STATIC_INLINE void LL_RTC_SetAsynchPrescaler(RTC_TypeDef *RTCx, uint32_t AsynchPrescaler) |
||
| 294 | { |
||
| 295 | MODIFY_REG(RTCx->PRLH, RTC_PRLH_PRL, (AsynchPrescaler >> 16)); |
||
| 296 | MODIFY_REG(RTCx->PRLL, RTC_PRLL_PRL, (AsynchPrescaler & RTC_PRLL_PRL)); |
||
| 297 | } |
||
| 298 | |||
| 299 | /** |
||
| 300 | * @brief Get Asynchronous prescaler factor |
||
| 301 | * @rmtoll DIVH DIV LL_RTC_GetDivider\n |
||
| 302 | * @rmtoll DIVL DIV LL_RTC_GetDivider\n |
||
| 303 | * @param RTCx RTC Instance |
||
| 304 | * @retval Value between Min_Data = 0 and Max_Data = 0xFFFFF |
||
| 305 | */ |
||
| 306 | __STATIC_INLINE uint32_t LL_RTC_GetDivider(RTC_TypeDef *RTCx) |
||
| 307 | { |
||
| 308 | register uint16_t Highprescaler = 0 , Lowprescaler = 0; |
||
| 309 | Highprescaler = READ_REG(RTCx->DIVH & RTC_DIVH_RTC_DIV); |
||
| 310 | Lowprescaler = READ_REG(RTCx->DIVL & RTC_DIVL_RTC_DIV); |
||
| 311 | |||
| 312 | return (((uint32_t) Highprescaler << 16U) | Lowprescaler); |
||
| 313 | } |
||
| 314 | |||
| 315 | /** |
||
| 316 | * @brief Set Output Source |
||
| 317 | * @rmtoll RTCCR CCO LL_RTC_SetOutputSource |
||
| 318 | * @rmtoll RTCCR ASOE LL_RTC_SetOutputSource |
||
| 319 | * @rmtoll RTCCR ASOS LL_RTC_SetOutputSource |
||
| 320 | * @param BKPx BKP Instance |
||
| 321 | * @param OutputSource This parameter can be one of the following values: |
||
| 322 | * @arg @ref LL_RTC_CALIB_OUTPUT_NONE |
||
| 323 | * @arg @ref LL_RTC_CALIB_OUTPUT_RTCCLOCK |
||
| 324 | * @arg @ref LL_RTC_CALIB_OUTPUT_ALARM |
||
| 325 | * @arg @ref LL_RTC_CALIB_OUTPUT_SECOND |
||
| 326 | * @retval None |
||
| 327 | */ |
||
| 328 | __STATIC_INLINE void LL_RTC_SetOutputSource(BKP_TypeDef *BKPx, uint32_t OutputSource) |
||
| 329 | { |
||
| 330 | MODIFY_REG(BKPx->RTCCR, (BKP_RTCCR_CCO | BKP_RTCCR_ASOE | BKP_RTCCR_ASOS), OutputSource); |
||
| 331 | } |
||
| 332 | |||
| 333 | /** |
||
| 334 | * @brief Get Output Source |
||
| 335 | * @rmtoll RTCCR CCO LL_RTC_GetOutPutSource |
||
| 336 | * @rmtoll RTCCR ASOE LL_RTC_GetOutPutSource |
||
| 337 | * @rmtoll RTCCR ASOS LL_RTC_GetOutPutSource |
||
| 338 | * @param BKPx BKP Instance |
||
| 339 | * @retval Returned value can be one of the following values: |
||
| 340 | * @arg @ref LL_RTC_CALIB_OUTPUT_NONE |
||
| 341 | * @arg @ref LL_RTC_CALIB_OUTPUT_RTCCLOCK |
||
| 342 | * @arg @ref LL_RTC_CALIB_OUTPUT_ALARM |
||
| 343 | * @arg @ref LL_RTC_CALIB_OUTPUT_SECOND |
||
| 344 | */ |
||
| 345 | __STATIC_INLINE uint32_t LL_RTC_GetOutPutSource(BKP_TypeDef *BKPx) |
||
| 346 | { |
||
| 347 | return (uint32_t)(READ_BIT(BKPx->RTCCR, (BKP_RTCCR_CCO | BKP_RTCCR_ASOE | BKP_RTCCR_ASOS))); |
||
| 348 | } |
||
| 349 | |||
| 350 | /** |
||
| 351 | * @brief Enable the write protection for RTC registers. |
||
| 352 | * @rmtoll CRL CNF LL_RTC_EnableWriteProtection |
||
| 353 | * @param RTCx RTC Instance |
||
| 354 | * @retval None |
||
| 355 | */ |
||
| 356 | __STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx) |
||
| 357 | { |
||
| 358 | CLEAR_BIT(RTCx->CRL, RTC_CRL_CNF); |
||
| 359 | } |
||
| 360 | |||
| 361 | /** |
||
| 362 | * @brief Disable the write protection for RTC registers. |
||
| 363 | * @rmtoll CRL RTC_CRL_CNF LL_RTC_DisableWriteProtection |
||
| 364 | * @param RTCx RTC Instance |
||
| 365 | * @retval None |
||
| 366 | */ |
||
| 367 | __STATIC_INLINE void LL_RTC_DisableWriteProtection(RTC_TypeDef *RTCx) |
||
| 368 | { |
||
| 369 | SET_BIT(RTCx->CRL, RTC_CRL_CNF); |
||
| 370 | } |
||
| 371 | |||
| 372 | /** |
||
| 373 | * @} |
||
| 374 | */ |
||
| 375 | |||
| 376 | /** @defgroup RTC_LL_EF_Time Time |
||
| 377 | * @{ |
||
| 378 | */ |
||
| 379 | |||
| 380 | /** |
||
| 381 | * @brief Set time counter in BCD format |
||
| 382 | * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. |
||
| 383 | * @note It can be written in initialization mode only (@ref LL_RTC_EnterInitMode function) |
||
| 384 | * @rmtoll CNTH CNT LL_RTC_TIME_Set\n |
||
| 385 | * CNTL CNT LL_RTC_TIME_Set\n |
||
| 386 | * @param RTCx RTC Instance |
||
| 387 | * @param TimeCounter Value between Min_Data=0x00 and Max_Data=0xFFFFF |
||
| 388 | * @retval None |
||
| 389 | */ |
||
| 390 | __STATIC_INLINE void LL_RTC_TIME_Set(RTC_TypeDef *RTCx, uint32_t TimeCounter) |
||
| 391 | { |
||
| 392 | /* Set RTC COUNTER MSB word */ |
||
| 393 | WRITE_REG(RTCx->CNTH, (TimeCounter >> 16U)); |
||
| 394 | /* Set RTC COUNTER LSB word */ |
||
| 395 | WRITE_REG(RTCx->CNTL, (TimeCounter & RTC_CNTL_RTC_CNT)); |
||
| 396 | } |
||
| 397 | |||
| 398 | /** |
||
| 399 | * @brief Get time counter in BCD format |
||
| 400 | * @rmtoll CNTH CNT LL_RTC_TIME_Get\n |
||
| 401 | * CNTL CNT LL_RTC_TIME_Get\n |
||
| 402 | * @param RTCx RTC Instance |
||
| 403 | * @retval Value between Min_Data = 0 and Max_Data = 0xFFFFF |
||
| 404 | */ |
||
| 405 | __STATIC_INLINE uint32_t LL_RTC_TIME_Get(RTC_TypeDef *RTCx) |
||
| 406 | { |
||
| 407 | register uint16_t high = 0, low = 0; |
||
| 408 | |||
| 409 | high = READ_REG(RTCx->CNTH & RTC_CNTH_RTC_CNT); |
||
| 410 | low = READ_REG(RTCx->CNTL & RTC_CNTL_RTC_CNT); |
||
| 411 | return ((uint32_t)(((uint32_t) high << 16U) | low)); |
||
| 412 | } |
||
| 413 | |||
| 414 | /** |
||
| 415 | * @} |
||
| 416 | */ |
||
| 417 | |||
| 418 | /** @defgroup RTC_LL_EF_ALARM ALARM |
||
| 419 | * @{ |
||
| 420 | */ |
||
| 421 | |||
| 422 | /** |
||
| 423 | * @brief Set Alarm Counter |
||
| 424 | * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. |
||
| 425 | * @rmtoll ALRH ALR LL_RTC_ALARM_Set\n |
||
| 426 | * @rmtoll ALRL ALR LL_RTC_ALARM_Set\n |
||
| 427 | * @param RTCx RTC Instance |
||
| 428 | * @param AlarmCounter Value between Min_Data=0x00 and Max_Data=0xFFFFF |
||
| 429 | * @retval None |
||
| 430 | */ |
||
| 431 | __STATIC_INLINE void LL_RTC_ALARM_Set(RTC_TypeDef *RTCx, uint32_t AlarmCounter) |
||
| 432 | { |
||
| 433 | /* Set RTC COUNTER MSB word */ |
||
| 434 | WRITE_REG(RTCx->ALRH, (AlarmCounter >> 16)); |
||
| 435 | /* Set RTC COUNTER LSB word */ |
||
| 436 | WRITE_REG(RTCx->ALRL, (AlarmCounter & RTC_ALRL_RTC_ALR)); |
||
| 437 | } |
||
| 438 | |||
| 439 | /** |
||
| 440 | * @brief Get Alarm Counter |
||
| 441 | * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. |
||
| 442 | * @rmtoll ALRH ALR LL_RTC_ALARM_Get\n |
||
| 443 | * @rmtoll ALRL ALR LL_RTC_ALARM_Get\n |
||
| 444 | * @param RTCx RTC Instance |
||
| 445 | * @retval None |
||
| 446 | */ |
||
| 447 | __STATIC_INLINE uint32_t LL_RTC_ALARM_Get(RTC_TypeDef *RTCx) |
||
| 448 | { |
||
| 449 | register uint16_t high = 0, low = 0; |
||
| 450 | |||
| 451 | high = READ_REG(RTCx->ALRH & RTC_ALRH_RTC_ALR); |
||
| 452 | low = READ_REG(RTCx->ALRL & RTC_ALRL_RTC_ALR); |
||
| 453 | |||
| 454 | return (((uint32_t) high << 16U) | low); |
||
| 455 | } |
||
| 456 | |||
| 457 | /** |
||
| 458 | * @} |
||
| 459 | */ |
||
| 460 | |||
| 461 | /** @defgroup RTC_LL_EF_Tamper Tamper |
||
| 462 | * @{ |
||
| 463 | */ |
||
| 464 | |||
| 465 | /** |
||
| 466 | * @brief Enable RTC_TAMPx input detection |
||
| 467 | * @rmtoll CR TPE LL_RTC_TAMPER_Enable\n |
||
| 468 | * @retval None |
||
| 469 | */ |
||
| 470 | __STATIC_INLINE void LL_RTC_TAMPER_Enable(BKP_TypeDef *BKPx) |
||
| 471 | { |
||
| 472 | SET_BIT(BKPx->CR, BKP_CR_TPE); |
||
| 473 | } |
||
| 474 | |||
| 475 | /** |
||
| 476 | * @brief Disable RTC_TAMPx Tamper |
||
| 477 | * @rmtoll CR TPE LL_RTC_TAMPER_Disable\n |
||
| 478 | * @retval None |
||
| 479 | */ |
||
| 480 | __STATIC_INLINE void LL_RTC_TAMPER_Disable(BKP_TypeDef *BKPx) |
||
| 481 | { |
||
| 482 | CLEAR_BIT(BKP->CR, BKP_CR_TPE); |
||
| 483 | } |
||
| 484 | |||
| 485 | /** |
||
| 486 | * @brief Enable Active level for Tamper input |
||
| 487 | * @rmtoll CR TPAL LL_RTC_TAMPER_SetActiveLevel\n |
||
| 488 | * @param BKPx BKP Instance |
||
| 489 | * @param Tamper This parameter can be a combination of the following values: |
||
| 490 | * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_LOW |
||
| 491 | * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_HIGH |
||
| 492 | * @retval None |
||
| 493 | */ |
||
| 494 | __STATIC_INLINE void LL_RTC_TAMPER_SetActiveLevel(BKP_TypeDef *BKPx, uint32_t Tamper) |
||
| 495 | { |
||
| 496 | MODIFY_REG(BKPx->CR, BKP_CR_TPAL, Tamper); |
||
| 497 | } |
||
| 498 | |||
| 499 | /** |
||
| 500 | * @brief Disable Active level for Tamper input |
||
| 501 | * @rmtoll CR TPAL LL_RTC_TAMPER_SetActiveLevel\n |
||
| 502 | * @retval None |
||
| 503 | */ |
||
| 504 | __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetActiveLevel(BKP_TypeDef *BKPx) |
||
| 505 | { |
||
| 506 | return (uint32_t)(READ_BIT(BKPx->CR, BKP_CR_TPAL)); |
||
| 507 | } |
||
| 508 | |||
| 509 | /** |
||
| 510 | * @} |
||
| 511 | */ |
||
| 512 | |||
| 513 | /** @defgroup RTC_LL_EF_Backup_Registers Backup_Registers |
||
| 514 | * @{ |
||
| 515 | */ |
||
| 516 | |||
| 517 | /** |
||
| 518 | * @brief Writes a data in a specified RTC Backup data register. |
||
| 519 | * @rmtoll BKPDR DR LL_RTC_BKP_SetRegister |
||
| 520 | * @param BKPx BKP Instance |
||
| 521 | * @param BackupRegister This parameter can be one of the following values: |
||
| 522 | * @arg @ref LL_RTC_BKP_DR1 |
||
| 523 | * @arg @ref LL_RTC_BKP_DR2 |
||
| 524 | * @arg @ref LL_RTC_BKP_DR3 |
||
| 525 | * @arg @ref LL_RTC_BKP_DR4 |
||
| 526 | * @arg @ref LL_RTC_BKP_DR5 |
||
| 527 | * @arg @ref LL_RTC_BKP_DR6 |
||
| 528 | * @arg @ref LL_RTC_BKP_DR7 |
||
| 529 | * @arg @ref LL_RTC_BKP_DR8 |
||
| 530 | * @arg @ref LL_RTC_BKP_DR9 |
||
| 531 | * @arg @ref LL_RTC_BKP_DR10 |
||
| 532 | * @arg @ref LL_RTC_BKP_DR11 (*) |
||
| 533 | * @arg @ref LL_RTC_BKP_DR12 (*) |
||
| 534 | * @arg @ref LL_RTC_BKP_DR13 (*) |
||
| 535 | * @arg @ref LL_RTC_BKP_DR14 (*) |
||
| 536 | * @arg @ref LL_RTC_BKP_DR15 (*) |
||
| 537 | * @arg @ref LL_RTC_BKP_DR16 (*) |
||
| 538 | * @arg @ref LL_RTC_BKP_DR17 (*) |
||
| 539 | * @arg @ref LL_RTC_BKP_DR18 (*) |
||
| 540 | * @arg @ref LL_RTC_BKP_DR19 (*) |
||
| 541 | * @arg @ref LL_RTC_BKP_DR20 (*) |
||
| 542 | * @arg @ref LL_RTC_BKP_DR21 (*) |
||
| 543 | * @arg @ref LL_RTC_BKP_DR22 (*) |
||
| 544 | * @arg @ref LL_RTC_BKP_DR23 (*) |
||
| 545 | * @arg @ref LL_RTC_BKP_DR24 (*) |
||
| 546 | * @arg @ref LL_RTC_BKP_DR25 (*) |
||
| 547 | * @arg @ref LL_RTC_BKP_DR26 (*) |
||
| 548 | * @arg @ref LL_RTC_BKP_DR27 (*) |
||
| 549 | * @arg @ref LL_RTC_BKP_DR28 (*) |
||
| 550 | * @arg @ref LL_RTC_BKP_DR29 (*) |
||
| 551 | * @arg @ref LL_RTC_BKP_DR30 (*) |
||
| 552 | * @arg @ref LL_RTC_BKP_DR31 (*) |
||
| 553 | * @arg @ref LL_RTC_BKP_DR32 (*) |
||
| 554 | * @arg @ref LL_RTC_BKP_DR33 (*) |
||
| 555 | * @arg @ref LL_RTC_BKP_DR34 (*) |
||
| 556 | * @arg @ref LL_RTC_BKP_DR35 (*) |
||
| 557 | * @arg @ref LL_RTC_BKP_DR36 (*) |
||
| 558 | * @arg @ref LL_RTC_BKP_DR37 (*) |
||
| 559 | * @arg @ref LL_RTC_BKP_DR38 (*) |
||
| 560 | * @arg @ref LL_RTC_BKP_DR39 (*) |
||
| 561 | * @arg @ref LL_RTC_BKP_DR40 (*) |
||
| 562 | * @arg @ref LL_RTC_BKP_DR41 (*) |
||
| 563 | * @arg @ref LL_RTC_BKP_DR42 (*) |
||
| 564 | * (*) value not defined in all devices. |
||
| 565 | * @param Data Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF |
||
| 566 | * @retval None |
||
| 567 | */ |
||
| 568 | __STATIC_INLINE void LL_RTC_BKP_SetRegister(BKP_TypeDef *BKPx, uint32_t BackupRegister, uint32_t Data) |
||
| 569 | { |
||
| 570 | register uint32_t tmp = 0U; |
||
| 571 | |||
| 572 | tmp = (uint32_t)BKP_BASE; |
||
| 573 | tmp += (BackupRegister * 4U); |
||
| 574 | |||
| 575 | /* Write the specified register */ |
||
| 576 | *(__IO uint32_t *)tmp = (uint32_t)Data; |
||
| 577 | } |
||
| 578 | |||
| 579 | /** |
||
| 580 | * @brief Reads data from the specified RTC Backup data Register. |
||
| 581 | * @rmtoll BKPDR DR LL_RTC_BKP_GetRegister |
||
| 582 | * @param BKPx BKP Instance |
||
| 583 | * @param BackupRegister This parameter can be one of the following values: |
||
| 584 | * @arg @ref LL_RTC_BKP_DR1 |
||
| 585 | * @arg @ref LL_RTC_BKP_DR2 |
||
| 586 | * @arg @ref LL_RTC_BKP_DR3 |
||
| 587 | * @arg @ref LL_RTC_BKP_DR4 |
||
| 588 | * @arg @ref LL_RTC_BKP_DR5 |
||
| 589 | * @arg @ref LL_RTC_BKP_DR6 |
||
| 590 | * @arg @ref LL_RTC_BKP_DR7 |
||
| 591 | * @arg @ref LL_RTC_BKP_DR8 |
||
| 592 | * @arg @ref LL_RTC_BKP_DR9 |
||
| 593 | * @arg @ref LL_RTC_BKP_DR10 |
||
| 594 | * @arg @ref LL_RTC_BKP_DR11 (*) |
||
| 595 | * @arg @ref LL_RTC_BKP_DR12 (*) |
||
| 596 | * @arg @ref LL_RTC_BKP_DR13 (*) |
||
| 597 | * @arg @ref LL_RTC_BKP_DR14 (*) |
||
| 598 | * @arg @ref LL_RTC_BKP_DR15 (*) |
||
| 599 | * @arg @ref LL_RTC_BKP_DR16 (*) |
||
| 600 | * @arg @ref LL_RTC_BKP_DR17 (*) |
||
| 601 | * @arg @ref LL_RTC_BKP_DR18 (*) |
||
| 602 | * @arg @ref LL_RTC_BKP_DR19 (*) |
||
| 603 | * @arg @ref LL_RTC_BKP_DR20 (*) |
||
| 604 | * @arg @ref LL_RTC_BKP_DR21 (*) |
||
| 605 | * @arg @ref LL_RTC_BKP_DR22 (*) |
||
| 606 | * @arg @ref LL_RTC_BKP_DR23 (*) |
||
| 607 | * @arg @ref LL_RTC_BKP_DR24 (*) |
||
| 608 | * @arg @ref LL_RTC_BKP_DR25 (*) |
||
| 609 | * @arg @ref LL_RTC_BKP_DR26 (*) |
||
| 610 | * @arg @ref LL_RTC_BKP_DR27 (*) |
||
| 611 | * @arg @ref LL_RTC_BKP_DR28 (*) |
||
| 612 | * @arg @ref LL_RTC_BKP_DR29 (*) |
||
| 613 | * @arg @ref LL_RTC_BKP_DR30 (*) |
||
| 614 | * @arg @ref LL_RTC_BKP_DR31 (*) |
||
| 615 | * @arg @ref LL_RTC_BKP_DR32 (*) |
||
| 616 | * @arg @ref LL_RTC_BKP_DR33 (*) |
||
| 617 | * @arg @ref LL_RTC_BKP_DR34 (*) |
||
| 618 | * @arg @ref LL_RTC_BKP_DR35 (*) |
||
| 619 | * @arg @ref LL_RTC_BKP_DR36 (*) |
||
| 620 | * @arg @ref LL_RTC_BKP_DR37 (*) |
||
| 621 | * @arg @ref LL_RTC_BKP_DR38 (*) |
||
| 622 | * @arg @ref LL_RTC_BKP_DR39 (*) |
||
| 623 | * @arg @ref LL_RTC_BKP_DR40 (*) |
||
| 624 | * @arg @ref LL_RTC_BKP_DR41 (*) |
||
| 625 | * @arg @ref LL_RTC_BKP_DR42 (*) |
||
| 626 | * @retval Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF |
||
| 627 | */ |
||
| 628 | __STATIC_INLINE uint32_t LL_RTC_BKP_GetRegister(BKP_TypeDef *BKPx, uint32_t BackupRegister) |
||
| 629 | { |
||
| 630 | register uint32_t tmp = 0U; |
||
| 631 | |||
| 632 | tmp = (uint32_t)BKP_BASE; |
||
| 633 | tmp += (BackupRegister * 4U); |
||
| 634 | |||
| 635 | /* Read the specified register */ |
||
| 636 | return ((*(__IO uint32_t *)tmp) & BKP_DR1_D); |
||
| 637 | } |
||
| 638 | |||
| 639 | /** |
||
| 640 | * @} |
||
| 641 | */ |
||
| 642 | |||
| 643 | /** @defgroup RTC_LL_EF_Calibration Calibration |
||
| 644 | * @{ |
||
| 645 | */ |
||
| 646 | |||
| 647 | /** |
||
| 648 | * @brief Set the coarse digital calibration |
||
| 649 | * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. |
||
| 650 | * @note It can be written in initialization mode only (@ref LL_RTC_EnterInitMode function) |
||
| 651 | * @rmtoll RTCCR CAL LL_RTC_CAL_SetCoarseDigital\n |
||
| 652 | * @param BKPx RTC Instance |
||
| 653 | * @param Value value of coarse calibration expressed in ppm (coded on 5 bits) |
||
| 654 | * @note This Calibration value should be between 0 and 121 when using positive sign with a 4-ppm step. |
||
| 655 | * @retval None |
||
| 656 | */ |
||
| 657 | __STATIC_INLINE void LL_RTC_CAL_SetCoarseDigital(BKP_TypeDef* BKPx, uint32_t Value) |
||
| 658 | { |
||
| 659 | MODIFY_REG(BKPx->RTCCR,BKP_RTCCR_CAL, Value); |
||
| 660 | } |
||
| 661 | |||
| 662 | /** |
||
| 663 | * @brief Get the coarse digital calibration value |
||
| 664 | * @rmtoll RTCCR CAL LL_RTC_CAL_SetCoarseDigital\n |
||
| 665 | * @param BKPx BKP Instance |
||
| 666 | * @retval value of coarse calibration expressed in ppm (coded on 5 bits) |
||
| 667 | */ |
||
| 668 | __STATIC_INLINE uint32_t LL_RTC_CAL_GetCoarseDigital(BKP_TypeDef *BKPx) |
||
| 669 | { |
||
| 670 | return (uint32_t)(READ_BIT(BKPx->RTCCR, BKP_RTCCR_CAL)); |
||
| 671 | } |
||
| 672 | /** |
||
| 673 | * @} |
||
| 674 | */ |
||
| 675 | |||
| 676 | /** @defgroup RTC_LL_EF_FLAG_Management FLAG_Management |
||
| 677 | * @{ |
||
| 678 | */ |
||
| 679 | |||
| 680 | /** |
||
| 681 | * @brief Get RTC_TAMPI Interruption detection flag |
||
| 682 | * @rmtoll CSR TIF LL_RTC_IsActiveFlag_TAMPI |
||
| 683 | * @param BKPx BKP Instance |
||
| 684 | * @retval State of bit (1 or 0). |
||
| 685 | */ |
||
| 686 | __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMPI(BKP_TypeDef *BKPx) |
||
| 687 | { |
||
| 688 | return (READ_BIT(BKPx->CSR, BKP_CSR_TIF) == (BKP_CSR_TIF)); |
||
| 689 | } |
||
| 690 | |||
| 691 | /** |
||
| 692 | * @brief Clear RTC_TAMP Interruption detection flag |
||
| 693 | * @rmtoll CSR CTI LL_RTC_ClearFlag_TAMPI |
||
| 694 | * @param BKPx BKP Instance |
||
| 695 | * @retval None |
||
| 696 | */ |
||
| 697 | __STATIC_INLINE void LL_RTC_ClearFlag_TAMPI(BKP_TypeDef *BKPx) |
||
| 698 | { |
||
| 699 | SET_BIT(BKPx->CSR, BKP_CSR_CTI); |
||
| 700 | } |
||
| 701 | |||
| 702 | /** |
||
| 703 | * @brief Get RTC_TAMPE Event detection flag |
||
| 704 | * @rmtoll CSR TEF LL_RTC_IsActiveFlag_TAMPE |
||
| 705 | * @param BKPx BKP Instance |
||
| 706 | * @retval State of bit (1 or 0). |
||
| 707 | */ |
||
| 708 | __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMPE(BKP_TypeDef *BKPx) |
||
| 709 | { |
||
| 710 | return (READ_BIT(BKPx->CSR, BKP_CSR_TEF) == (BKP_CSR_TEF)); |
||
| 711 | } |
||
| 712 | |||
| 713 | /** |
||
| 714 | * @brief Clear RTC_TAMPE Even detection flag |
||
| 715 | * @rmtoll CSR CTE LL_RTC_ClearFlag_TAMPE |
||
| 716 | * @param BKPx BKP Instance |
||
| 717 | * @retval None |
||
| 718 | */ |
||
| 719 | __STATIC_INLINE void LL_RTC_ClearFlag_TAMPE(BKP_TypeDef *BKPx) |
||
| 720 | { |
||
| 721 | SET_BIT(BKPx->CSR, BKP_CSR_CTE); |
||
| 722 | } |
||
| 723 | |||
| 724 | /** |
||
| 725 | * @brief Get Alarm flag |
||
| 726 | * @rmtoll CRL ALRF LL_RTC_IsActiveFlag_ALR |
||
| 727 | * @param RTCx RTC Instance |
||
| 728 | * @retval State of bit (1 or 0). |
||
| 729 | */ |
||
| 730 | __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALR(RTC_TypeDef *RTCx) |
||
| 731 | { |
||
| 732 | return (READ_BIT(RTCx->CRL, RTC_CRL_ALRF) == (RTC_CRL_ALRF)); |
||
| 733 | } |
||
| 734 | |||
| 735 | /** |
||
| 736 | * @brief Clear Alarm flag |
||
| 737 | * @rmtoll CRL ALRF LL_RTC_ClearFlag_ALR |
||
| 738 | * @param RTCx RTC Instance |
||
| 739 | * @retval None |
||
| 740 | */ |
||
| 741 | __STATIC_INLINE void LL_RTC_ClearFlag_ALR(RTC_TypeDef *RTCx) |
||
| 742 | { |
||
| 743 | CLEAR_BIT(RTCx->CRL, RTC_CRL_ALRF); |
||
| 744 | } |
||
| 745 | |||
| 746 | /** |
||
| 747 | * @brief Get Registers synchronization flag |
||
| 748 | * @rmtoll CRL RSF LL_RTC_IsActiveFlag_RS |
||
| 749 | * @param RTCx RTC Instance |
||
| 750 | * @retval State of bit (1 or 0). |
||
| 751 | */ |
||
| 752 | __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(RTC_TypeDef *RTCx) |
||
| 753 | { |
||
| 754 | return (READ_BIT(RTCx->CRL, RTC_CRL_RSF) == (RTC_CRL_RSF)); |
||
| 755 | } |
||
| 756 | |||
| 757 | /** |
||
| 758 | * @brief Clear Registers synchronization flag |
||
| 759 | * @rmtoll CRL RSF LL_RTC_ClearFlag_RS |
||
| 760 | * @param RTCx RTC Instance |
||
| 761 | * @retval None |
||
| 762 | */ |
||
| 763 | __STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx) |
||
| 764 | { |
||
| 765 | CLEAR_BIT(RTCx->CRL, RTC_CRL_RSF); |
||
| 766 | } |
||
| 767 | |||
| 768 | /** |
||
| 769 | * @brief Get Registers OverFlow flag |
||
| 770 | * @rmtoll CRL OWF LL_RTC_IsActiveFlag_OW |
||
| 771 | * @param RTCx RTC Instance |
||
| 772 | * @retval State of bit (1 or 0). |
||
| 773 | */ |
||
| 774 | __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_OW(RTC_TypeDef *RTCx) |
||
| 775 | { |
||
| 776 | return (READ_BIT(RTCx->CRL, RTC_CRL_OWF) == (RTC_CRL_OWF)); |
||
| 777 | } |
||
| 778 | |||
| 779 | /** |
||
| 780 | * @brief Clear Registers OverFlow flag |
||
| 781 | * @rmtoll CRL OWF LL_RTC_ClearFlag_OW |
||
| 782 | * @param RTCx RTC Instance |
||
| 783 | * @retval None |
||
| 784 | */ |
||
| 785 | __STATIC_INLINE void LL_RTC_ClearFlag_OW(RTC_TypeDef *RTCx) |
||
| 786 | { |
||
| 787 | CLEAR_BIT(RTCx->CRL, RTC_CRL_OWF); |
||
| 788 | } |
||
| 789 | |||
| 790 | /** |
||
| 791 | * @brief Get Registers synchronization flag |
||
| 792 | * @rmtoll CRL SECF LL_RTC_IsActiveFlag_SEC |
||
| 793 | * @param RTCx RTC Instance |
||
| 794 | * @retval State of bit (1 or 0). |
||
| 795 | */ |
||
| 796 | __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SEC(RTC_TypeDef *RTCx) |
||
| 797 | { |
||
| 798 | return (READ_BIT(RTCx->CRL, RTC_CRL_SECF) == (RTC_CRL_SECF)); |
||
| 799 | } |
||
| 800 | |||
| 801 | /** |
||
| 802 | * @brief Clear Registers synchronization flag |
||
| 803 | * @rmtoll CRL SECF LL_RTC_ClearFlag_SEC |
||
| 804 | * @param RTCx RTC Instance |
||
| 805 | * @retval None |
||
| 806 | */ |
||
| 807 | __STATIC_INLINE void LL_RTC_ClearFlag_SEC(RTC_TypeDef *RTCx) |
||
| 808 | { |
||
| 809 | CLEAR_BIT(RTCx->CRL, RTC_CRL_SECF); |
||
| 810 | } |
||
| 811 | |||
| 812 | /** |
||
| 813 | * @brief Get RTC Operation OFF status flag |
||
| 814 | * @rmtoll CRL RTOFF LL_RTC_IsActiveFlag_RTOF |
||
| 815 | * @param RTCx RTC Instance |
||
| 816 | * @retval State of bit (1 or 0). |
||
| 817 | */ |
||
| 818 | __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RTOF(RTC_TypeDef *RTCx) |
||
| 819 | { |
||
| 820 | return (READ_BIT(RTCx->CRL, RTC_CRL_RTOFF) == (RTC_CRL_RTOFF)); |
||
| 821 | } |
||
| 822 | |||
| 823 | /** |
||
| 824 | * @} |
||
| 825 | */ |
||
| 826 | |||
| 827 | /** @defgroup RTC_LL_EF_IT_Management IT_Management |
||
| 828 | * @{ |
||
| 829 | */ |
||
| 830 | |||
| 831 | /** |
||
| 832 | * @brief Enable Alarm interrupt |
||
| 833 | * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. |
||
| 834 | * @rmtoll CRH ALRIE LL_RTC_EnableIT_ALR |
||
| 835 | * @param RTCx RTC Instance |
||
| 836 | * @retval None |
||
| 837 | */ |
||
| 838 | __STATIC_INLINE void LL_RTC_EnableIT_ALR(RTC_TypeDef *RTCx) |
||
| 839 | { |
||
| 840 | SET_BIT(RTCx->CRH, RTC_CRH_ALRIE); |
||
| 841 | } |
||
| 842 | |||
| 843 | /** |
||
| 844 | * @brief Disable Alarm interrupt |
||
| 845 | * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. |
||
| 846 | * @rmtoll CRH ALRIE LL_RTC_DisableIT_ALR |
||
| 847 | * @param RTCx RTC Instance |
||
| 848 | * @retval None |
||
| 849 | */ |
||
| 850 | __STATIC_INLINE void LL_RTC_DisableIT_ALR(RTC_TypeDef *RTCx) |
||
| 851 | { |
||
| 852 | CLEAR_BIT(RTCx->CRH, RTC_CRH_ALRIE); |
||
| 853 | } |
||
| 854 | |||
| 855 | /** |
||
| 856 | * @brief Check if Alarm interrupt is enabled or not |
||
| 857 | * @rmtoll CRH ALRIE LL_RTC_IsEnabledIT_ALR |
||
| 858 | * @param RTCx RTC Instance |
||
| 859 | * @retval State of bit (1 or 0). |
||
| 860 | */ |
||
| 861 | __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALR(RTC_TypeDef *RTCx) |
||
| 862 | { |
||
| 863 | return (READ_BIT(RTCx->CRH, RTC_CRH_ALRIE) == (RTC_CRH_ALRIE)); |
||
| 864 | } |
||
| 865 | |||
| 866 | /** |
||
| 867 | * @brief Enable Second Interrupt interrupt |
||
| 868 | * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. |
||
| 869 | * @rmtoll CRH SECIE LL_RTC_EnableIT_SEC |
||
| 870 | * @param RTCx RTC Instance |
||
| 871 | * @retval None |
||
| 872 | */ |
||
| 873 | __STATIC_INLINE void LL_RTC_EnableIT_SEC(RTC_TypeDef *RTCx) |
||
| 874 | { |
||
| 875 | SET_BIT(RTCx->CRH, RTC_CRH_SECIE); |
||
| 876 | } |
||
| 877 | |||
| 878 | /** |
||
| 879 | * @brief Disable Second interrupt |
||
| 880 | * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. |
||
| 881 | * @rmtoll CRH SECIE LL_RTC_DisableIT_SEC |
||
| 882 | * @param RTCx RTC Instance |
||
| 883 | * @retval None |
||
| 884 | */ |
||
| 885 | __STATIC_INLINE void LL_RTC_DisableIT_SEC(RTC_TypeDef *RTCx) |
||
| 886 | { |
||
| 887 | CLEAR_BIT(RTCx->CRH, RTC_CRH_SECIE); |
||
| 888 | } |
||
| 889 | |||
| 890 | /** |
||
| 891 | * @brief Check if Second interrupt is enabled or not |
||
| 892 | * @rmtoll CRH SECIE LL_RTC_IsEnabledIT_SEC |
||
| 893 | * @param RTCx RTC Instance |
||
| 894 | * @retval State of bit (1 or 0). |
||
| 895 | */ |
||
| 896 | __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_SEC(RTC_TypeDef *RTCx) |
||
| 897 | { |
||
| 898 | return (READ_BIT(RTCx->CRH, RTC_CRH_SECIE) == (RTC_CRH_SECIE)); |
||
| 899 | } |
||
| 900 | |||
| 901 | /** |
||
| 902 | * @brief Enable OverFlow interrupt |
||
| 903 | * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. |
||
| 904 | * @rmtoll CRH OWIE LL_RTC_EnableIT_OW |
||
| 905 | * @param RTCx RTC Instance |
||
| 906 | * @retval None |
||
| 907 | */ |
||
| 908 | __STATIC_INLINE void LL_RTC_EnableIT_OW(RTC_TypeDef *RTCx) |
||
| 909 | { |
||
| 910 | SET_BIT(RTCx->CRH, RTC_CRH_OWIE); |
||
| 911 | } |
||
| 912 | |||
| 913 | /** |
||
| 914 | * @brief Disable OverFlow interrupt |
||
| 915 | * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before. |
||
| 916 | * @rmtoll CRH OWIE LL_RTC_DisableIT_OW |
||
| 917 | * @param RTCx RTC Instance |
||
| 918 | * @retval None |
||
| 919 | */ |
||
| 920 | __STATIC_INLINE void LL_RTC_DisableIT_OW(RTC_TypeDef *RTCx) |
||
| 921 | { |
||
| 922 | CLEAR_BIT(RTCx->CRH, RTC_CRH_OWIE); |
||
| 923 | } |
||
| 924 | |||
| 925 | /** |
||
| 926 | * @brief Check if OverFlow interrupt is enabled or not |
||
| 927 | * @rmtoll CRH OWIE LL_RTC_IsEnabledIT_OW |
||
| 928 | * @param RTCx RTC Instance |
||
| 929 | * @retval State of bit (1 or 0). |
||
| 930 | */ |
||
| 931 | __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_OW(RTC_TypeDef *RTCx) |
||
| 932 | { |
||
| 933 | return (READ_BIT(RTCx->CRH, RTC_CRH_OWIE) == (RTC_CRH_OWIE)); |
||
| 934 | } |
||
| 935 | |||
| 936 | /** |
||
| 937 | * @brief Enable Tamper interrupt |
||
| 938 | * @rmtoll CSR TPIE LL_RTC_EnableIT_TAMP |
||
| 939 | * @param BKPx BKP Instance |
||
| 940 | * @retval None |
||
| 941 | */ |
||
| 942 | __STATIC_INLINE void LL_RTC_EnableIT_TAMP(BKP_TypeDef *BKPx) |
||
| 943 | { |
||
| 944 | SET_BIT(BKPx->CSR,BKP_CSR_TPIE); |
||
| 945 | } |
||
| 946 | |||
| 947 | /** |
||
| 948 | * @brief Disable Tamper interrupt |
||
| 949 | * @rmtoll CSR TPIE LL_RTC_EnableIT_TAMP |
||
| 950 | * @param BKPx BKP Instance |
||
| 951 | * @retval None |
||
| 952 | */ |
||
| 953 | __STATIC_INLINE void LL_RTC_DisableIT_TAMP(BKP_TypeDef *BKPx) |
||
| 954 | { |
||
| 955 | CLEAR_BIT(BKPx->CSR,BKP_CSR_TPIE); |
||
| 956 | } |
||
| 957 | |||
| 958 | /** |
||
| 959 | * @brief Check if all the TAMPER interrupts are enabled or not |
||
| 960 | * @rmtoll CSR TPIE LL_RTC_IsEnabledIT_TAMP |
||
| 961 | * @param BKPx BKP Instance |
||
| 962 | * @retval State of bit (1 or 0). |
||
| 963 | */ |
||
| 964 | __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP(BKP_TypeDef *BKPx) |
||
| 965 | { |
||
| 966 | return (READ_BIT(BKPx->CSR,BKP_CSR_TPIE) == BKP_CSR_TPIE); |
||
| 967 | } |
||
| 968 | /** |
||
| 969 | * @} |
||
| 970 | */ |
||
| 971 | |||
| 972 | #if defined(USE_FULL_LL_DRIVER) |
||
| 973 | /** @defgroup RTC_LL_EF_Init Initialization and de-initialization functions |
||
| 974 | * @{ |
||
| 975 | */ |
||
| 976 | |||
| 977 | ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx); |
||
| 978 | ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct); |
||
| 979 | void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct); |
||
| 980 | ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct); |
||
| 981 | void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct); |
||
| 982 | ErrorStatus LL_RTC_ALARM_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct); |
||
| 983 | void LL_RTC_ALARM_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct); |
||
| 984 | ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx); |
||
| 985 | ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx); |
||
| 986 | ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx); |
||
| 987 | ErrorStatus LL_RTC_TIME_SetCounter(RTC_TypeDef *RTCx, uint32_t TimeCounter); |
||
| 988 | ErrorStatus LL_RTC_ALARM_SetCounter(RTC_TypeDef *RTCx, uint32_t AlarmCounter); |
||
| 989 | |||
| 990 | /** |
||
| 991 | * @} |
||
| 992 | */ |
||
| 993 | #endif /* USE_FULL_LL_DRIVER */ |
||
| 994 | |||
| 995 | /** |
||
| 996 | * @} |
||
| 997 | */ |
||
| 998 | |||
| 999 | /** |
||
| 1000 | * @} |
||
| 1001 | */ |
||
| 1002 | |||
| 1003 | /** |
||
| 1004 | * @} |
||
| 1005 | */ |
||
| 1006 | |||
| 1007 | #endif /* defined(RTC) */ |
||
| 1008 | |||
| 1009 | /** |
||
| 1010 | * @} |
||
| 1011 | */ |
||
| 1012 | |||
| 1013 | #ifdef __cplusplus |
||
| 1014 | } |
||
| 1015 | #endif |
||
| 1016 | |||
| 1017 | #endif /* __STM32F1xx_LL_RTC_H */ |
||
| 1018 | |||
| 1019 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |