Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 9 | ||
---|---|---|---|
Line 4... | Line 4... | ||
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @brief Header file of RTC LL module. |
5 | * @brief Header file of RTC LL module. |
6 | ****************************************************************************** |
6 | ****************************************************************************** |
7 | * @attention |
7 | * @attention |
8 | * |
8 | * |
9 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
9 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
- | 10 | * All rights reserved.</center></h2> |
|
10 | * |
11 | * |
11 | * Redistribution and use in source and binary forms, with or without modification, |
12 | * This software component is licensed by ST under BSD 3-Clause license, |
12 | * are permitted provided that the following conditions are met: |
13 | * the "License"; You may not use this file except in compliance with the |
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. |
14 | * License. You may obtain a copy of the License at: |
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 |
15 | * opensource.org/licenses/BSD-3-Clause |
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 | * |
16 | * |
33 | ****************************************************************************** |
17 | ****************************************************************************** |
34 | */ |
18 | */ |
35 | 19 | ||
36 | /* Define to prevent recursive inclusion -------------------------------------*/ |
20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
Line 79... | Line 63... | ||
79 | */ |
63 | */ |
80 | typedef struct |
64 | typedef struct |
81 | { |
65 | { |
82 | uint32_t AsynchPrescaler; /*!< Specifies the RTC Asynchronous Predivider value. |
66 | uint32_t AsynchPrescaler; /*!< Specifies the RTC Asynchronous Predivider value. |
83 | This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFFF |
67 | This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFFF |
84 | |
- | |
- | 68 | ||
85 | This feature can be modified afterwards using unitary function |
69 | This feature can be modified afterwards using unitary function |
86 | @ref LL_RTC_SetAsynchPrescaler(). */ |
70 | @ref LL_RTC_SetAsynchPrescaler(). */ |
87 | 71 | ||
88 | uint32_t OutPutSource; /*!< Specifies which signal will be routed to the RTC Tamper pin. |
72 | 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 |
73 | This parameter can be a value of @ref LL_RTC_Output_Source |
90 | |
- | |
- | 74 | ||
91 | This feature can be modified afterwards using unitary function |
75 | This feature can be modified afterwards using unitary function |
92 | @ref LL_RTC_SetOutputSource(). */ |
76 | @ref LL_RTC_SetOutputSource(). */ |
93 | 77 | ||
94 | } LL_RTC_InitTypeDef; |
78 | } LL_RTC_InitTypeDef; |
95 | 79 | ||
Line 193... | Line 177... | ||
193 | * @} |
177 | * @} |
194 | */ |
178 | */ |
195 | 179 | ||
196 | /** @defgroup RTC_LL_EC_TAMPLEVEL Tamper Active Level |
180 | /** @defgroup RTC_LL_EC_TAMPLEVEL Tamper Active Level |
197 | * @{ |
181 | * @{ |
198 | */ |
182 | */ |
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) */ |
183 | #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) */ |
184 | #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 | 185 | ||
202 | /** |
186 | /** |
203 | * @} |
187 | * @} |
Line 303... | Line 287... | ||
303 | * @param RTCx RTC Instance |
287 | * @param RTCx RTC Instance |
304 | * @retval Value between Min_Data = 0 and Max_Data = 0xFFFFF |
288 | * @retval Value between Min_Data = 0 and Max_Data = 0xFFFFF |
305 | */ |
289 | */ |
306 | __STATIC_INLINE uint32_t LL_RTC_GetDivider(RTC_TypeDef *RTCx) |
290 | __STATIC_INLINE uint32_t LL_RTC_GetDivider(RTC_TypeDef *RTCx) |
307 | { |
291 | { |
308 | register uint16_t Highprescaler = 0 , Lowprescaler = 0; |
292 | register uint16_t Highprescaler = 0, Lowprescaler = 0; |
309 | Highprescaler = READ_REG(RTCx->DIVH & RTC_DIVH_RTC_DIV); |
293 | Highprescaler = READ_REG(RTCx->DIVH & RTC_DIVH_RTC_DIV); |
310 | Lowprescaler = READ_REG(RTCx->DIVL & RTC_DIVL_RTC_DIV); |
294 | Lowprescaler = READ_REG(RTCx->DIVL & RTC_DIVL_RTC_DIV); |
311 | 295 | ||
312 | return (((uint32_t) Highprescaler << 16U) | Lowprescaler); |
296 | return (((uint32_t) Highprescaler << 16U) | Lowprescaler); |
313 | } |
297 | } |
314 | 298 | ||
315 | /** |
299 | /** |
316 | * @brief Set Output Source |
300 | * @brief Set Output Source |
Line 353... | Line 337... | ||
353 | * @param RTCx RTC Instance |
337 | * @param RTCx RTC Instance |
354 | * @retval None |
338 | * @retval None |
355 | */ |
339 | */ |
356 | __STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx) |
340 | __STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx) |
357 | { |
341 | { |
358 | CLEAR_BIT(RTCx->CRL, RTC_CRL_CNF); |
342 | CLEAR_BIT(RTCx->CRL, RTC_CRL_CNF); |
359 | } |
343 | } |
360 | 344 | ||
361 | /** |
345 | /** |
362 | * @brief Disable the write protection for RTC registers. |
346 | * @brief Disable the write protection for RTC registers. |
363 | * @rmtoll CRL RTC_CRL_CNF LL_RTC_DisableWriteProtection |
347 | * @rmtoll CRL RTC_CRL_CNF LL_RTC_DisableWriteProtection |
Line 387... | Line 371... | ||
387 | * @param TimeCounter Value between Min_Data=0x00 and Max_Data=0xFFFFF |
371 | * @param TimeCounter Value between Min_Data=0x00 and Max_Data=0xFFFFF |
388 | * @retval None |
372 | * @retval None |
389 | */ |
373 | */ |
390 | __STATIC_INLINE void LL_RTC_TIME_Set(RTC_TypeDef *RTCx, uint32_t TimeCounter) |
374 | __STATIC_INLINE void LL_RTC_TIME_Set(RTC_TypeDef *RTCx, uint32_t TimeCounter) |
391 | { |
375 | { |
392 | /* Set RTC COUNTER MSB word */ |
376 | /* Set RTC COUNTER MSB word */ |
393 | WRITE_REG(RTCx->CNTH, (TimeCounter >> 16U)); |
377 | WRITE_REG(RTCx->CNTH, (TimeCounter >> 16U)); |
394 | /* Set RTC COUNTER LSB word */ |
378 | /* Set RTC COUNTER LSB word */ |
395 | WRITE_REG(RTCx->CNTL, (TimeCounter & RTC_CNTL_RTC_CNT)); |
379 | WRITE_REG(RTCx->CNTL, (TimeCounter & RTC_CNTL_RTC_CNT)); |
396 | } |
380 | } |
397 | 381 | ||
398 | /** |
382 | /** |
399 | * @brief Get time counter in BCD format |
383 | * @brief Get time counter in BCD format |
400 | * @rmtoll CNTH CNT LL_RTC_TIME_Get\n |
384 | * @rmtoll CNTH CNT LL_RTC_TIME_Get\n |
Line 403... | Line 387... | ||
403 | * @retval Value between Min_Data = 0 and Max_Data = 0xFFFFF |
387 | * @retval Value between Min_Data = 0 and Max_Data = 0xFFFFF |
404 | */ |
388 | */ |
405 | __STATIC_INLINE uint32_t LL_RTC_TIME_Get(RTC_TypeDef *RTCx) |
389 | __STATIC_INLINE uint32_t LL_RTC_TIME_Get(RTC_TypeDef *RTCx) |
406 | { |
390 | { |
407 | register uint16_t high = 0, low = 0; |
391 | register uint16_t high = 0, low = 0; |
408 | 392 | ||
409 | high = READ_REG(RTCx->CNTH & RTC_CNTH_RTC_CNT); |
393 | high = READ_REG(RTCx->CNTH & RTC_CNTH_RTC_CNT); |
410 | low = READ_REG(RTCx->CNTL & RTC_CNTL_RTC_CNT); |
394 | low = READ_REG(RTCx->CNTL & RTC_CNTL_RTC_CNT); |
411 | return ((uint32_t)(((uint32_t) high << 16U) | low)); |
395 | return ((uint32_t)(((uint32_t) high << 16U) | low)); |
412 | } |
396 | } |
413 | 397 | ||
Line 521... | Line 505... | ||
521 | * @param BackupRegister This parameter can be one of the following values: |
505 | * @param BackupRegister This parameter can be one of the following values: |
522 | * @arg @ref LL_RTC_BKP_DR1 |
506 | * @arg @ref LL_RTC_BKP_DR1 |
523 | * @arg @ref LL_RTC_BKP_DR2 |
507 | * @arg @ref LL_RTC_BKP_DR2 |
524 | * @arg @ref LL_RTC_BKP_DR3 |
508 | * @arg @ref LL_RTC_BKP_DR3 |
525 | * @arg @ref LL_RTC_BKP_DR4 |
509 | * @arg @ref LL_RTC_BKP_DR4 |
526 | * @arg @ref LL_RTC_BKP_DR5 |
510 | * @arg @ref LL_RTC_BKP_DR5 |
527 | * @arg @ref LL_RTC_BKP_DR6 |
511 | * @arg @ref LL_RTC_BKP_DR6 |
528 | * @arg @ref LL_RTC_BKP_DR7 |
512 | * @arg @ref LL_RTC_BKP_DR7 |
529 | * @arg @ref LL_RTC_BKP_DR8 |
513 | * @arg @ref LL_RTC_BKP_DR8 |
530 | * @arg @ref LL_RTC_BKP_DR9 |
514 | * @arg @ref LL_RTC_BKP_DR9 |
531 | * @arg @ref LL_RTC_BKP_DR10 |
515 | * @arg @ref LL_RTC_BKP_DR10 |
532 | * @arg @ref LL_RTC_BKP_DR11 (*) |
516 | * @arg @ref LL_RTC_BKP_DR11 (*) |
533 | * @arg @ref LL_RTC_BKP_DR12 (*) |
517 | * @arg @ref LL_RTC_BKP_DR12 (*) |
534 | * @arg @ref LL_RTC_BKP_DR13 (*) |
518 | * @arg @ref LL_RTC_BKP_DR13 (*) |
535 | * @arg @ref LL_RTC_BKP_DR14 (*) |
519 | * @arg @ref LL_RTC_BKP_DR14 (*) |
536 | * @arg @ref LL_RTC_BKP_DR15 (*) |
520 | * @arg @ref LL_RTC_BKP_DR15 (*) |
Line 583... | Line 567... | ||
583 | * @param BackupRegister This parameter can be one of the following values: |
567 | * @param BackupRegister This parameter can be one of the following values: |
584 | * @arg @ref LL_RTC_BKP_DR1 |
568 | * @arg @ref LL_RTC_BKP_DR1 |
585 | * @arg @ref LL_RTC_BKP_DR2 |
569 | * @arg @ref LL_RTC_BKP_DR2 |
586 | * @arg @ref LL_RTC_BKP_DR3 |
570 | * @arg @ref LL_RTC_BKP_DR3 |
587 | * @arg @ref LL_RTC_BKP_DR4 |
571 | * @arg @ref LL_RTC_BKP_DR4 |
588 | * @arg @ref LL_RTC_BKP_DR5 |
572 | * @arg @ref LL_RTC_BKP_DR5 |
589 | * @arg @ref LL_RTC_BKP_DR6 |
573 | * @arg @ref LL_RTC_BKP_DR6 |
590 | * @arg @ref LL_RTC_BKP_DR7 |
574 | * @arg @ref LL_RTC_BKP_DR7 |
591 | * @arg @ref LL_RTC_BKP_DR8 |
575 | * @arg @ref LL_RTC_BKP_DR8 |
592 | * @arg @ref LL_RTC_BKP_DR9 |
576 | * @arg @ref LL_RTC_BKP_DR9 |
593 | * @arg @ref LL_RTC_BKP_DR10 |
577 | * @arg @ref LL_RTC_BKP_DR10 |
594 | * @arg @ref LL_RTC_BKP_DR11 (*) |
578 | * @arg @ref LL_RTC_BKP_DR11 (*) |
595 | * @arg @ref LL_RTC_BKP_DR12 (*) |
579 | * @arg @ref LL_RTC_BKP_DR12 (*) |
596 | * @arg @ref LL_RTC_BKP_DR13 (*) |
580 | * @arg @ref LL_RTC_BKP_DR13 (*) |
597 | * @arg @ref LL_RTC_BKP_DR14 (*) |
581 | * @arg @ref LL_RTC_BKP_DR14 (*) |
598 | * @arg @ref LL_RTC_BKP_DR15 (*) |
582 | * @arg @ref LL_RTC_BKP_DR15 (*) |
Line 652... | Line 636... | ||
652 | * @param BKPx RTC Instance |
636 | * @param BKPx RTC Instance |
653 | * @param Value value of coarse calibration expressed in ppm (coded on 5 bits) |
637 | * @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. |
638 | * @note This Calibration value should be between 0 and 121 when using positive sign with a 4-ppm step. |
655 | * @retval None |
639 | * @retval None |
656 | */ |
640 | */ |
657 | __STATIC_INLINE void LL_RTC_CAL_SetCoarseDigital(BKP_TypeDef* BKPx, uint32_t Value) |
641 | __STATIC_INLINE void LL_RTC_CAL_SetCoarseDigital(BKP_TypeDef *BKPx, uint32_t Value) |
658 | { |
642 | { |
659 | MODIFY_REG(BKPx->RTCCR,BKP_RTCCR_CAL, Value); |
643 | MODIFY_REG(BKPx->RTCCR, BKP_RTCCR_CAL, Value); |
660 | } |
644 | } |
661 | 645 | ||
662 | /** |
646 | /** |
663 | * @brief Get the coarse digital calibration value |
647 | * @brief Get the coarse digital calibration value |
664 | * @rmtoll RTCCR CAL LL_RTC_CAL_SetCoarseDigital\n |
648 | * @rmtoll RTCCR CAL LL_RTC_CAL_SetCoarseDigital\n |
Line 939... | Line 923... | ||
939 | * @param BKPx BKP Instance |
923 | * @param BKPx BKP Instance |
940 | * @retval None |
924 | * @retval None |
941 | */ |
925 | */ |
942 | __STATIC_INLINE void LL_RTC_EnableIT_TAMP(BKP_TypeDef *BKPx) |
926 | __STATIC_INLINE void LL_RTC_EnableIT_TAMP(BKP_TypeDef *BKPx) |
943 | { |
927 | { |
944 | SET_BIT(BKPx->CSR,BKP_CSR_TPIE); |
928 | SET_BIT(BKPx->CSR, BKP_CSR_TPIE); |
945 | } |
929 | } |
946 | 930 | ||
947 | /** |
931 | /** |
948 | * @brief Disable Tamper interrupt |
932 | * @brief Disable Tamper interrupt |
949 | * @rmtoll CSR TPIE LL_RTC_EnableIT_TAMP |
933 | * @rmtoll CSR TPIE LL_RTC_EnableIT_TAMP |
950 | * @param BKPx BKP Instance |
934 | * @param BKPx BKP Instance |
951 | * @retval None |
935 | * @retval None |
952 | */ |
936 | */ |
953 | __STATIC_INLINE void LL_RTC_DisableIT_TAMP(BKP_TypeDef *BKPx) |
937 | __STATIC_INLINE void LL_RTC_DisableIT_TAMP(BKP_TypeDef *BKPx) |
954 | { |
938 | { |
955 | CLEAR_BIT(BKPx->CSR,BKP_CSR_TPIE); |
939 | CLEAR_BIT(BKPx->CSR, BKP_CSR_TPIE); |
956 | } |
940 | } |
957 | 941 | ||
958 | /** |
942 | /** |
959 | * @brief Check if all the TAMPER interrupts are enabled or not |
943 | * @brief Check if all the TAMPER interrupts are enabled or not |
960 | * @rmtoll CSR TPIE LL_RTC_IsEnabledIT_TAMP |
944 | * @rmtoll CSR TPIE LL_RTC_IsEnabledIT_TAMP |
961 | * @param BKPx BKP Instance |
945 | * @param BKPx BKP Instance |
962 | * @retval State of bit (1 or 0). |
946 | * @retval State of bit (1 or 0). |
963 | */ |
947 | */ |
964 | __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP(BKP_TypeDef *BKPx) |
948 | __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP(BKP_TypeDef *BKPx) |
965 | { |
949 | { |
966 | return (READ_BIT(BKPx->CSR,BKP_CSR_TPIE) == BKP_CSR_TPIE); |
950 | return (READ_BIT(BKPx->CSR, BKP_CSR_TPIE) == BKP_CSR_TPIE); |
967 | } |
951 | } |
968 | /** |
952 | /** |
969 | * @} |
953 | * @} |
970 | */ |
954 | */ |
971 | 955 |