Rev 61 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 61 | Rev 77 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /** |
1 | /** |
2 | ****************************************************************************** |
2 | ****************************************************************************** |
3 | * @file stm32l1xx_ll_rtc.c |
3 | * @file stm32l1xx_ll_rtc.c |
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @brief RTC LL module driver. |
5 | * @brief RTC LL module driver. |
6 | ****************************************************************************** |
6 | ****************************************************************************** |
7 | * @attention |
7 | * @attention |
8 | * |
8 | * |
9 | * <h2><center>© Copyright (c) 2017 STMicroelectronics. |
9 | * Copyright (c) 2016 STMicroelectronics. |
10 | * All rights reserved.</center></h2> |
10 | * All rights reserved. |
11 | * |
11 | * |
12 | * This software component is licensed by ST under BSD 3-Clause license, |
12 | * This software is licensed under terms that can be found in the LICENSE file |
13 | * the "License"; You may not use this file except in compliance with the |
13 | * in the root directory of this software component. |
14 | * License. You may obtain a copy of the License at: |
14 | * If no LICENSE file comes with this software, it is provided AS-IS. |
15 | * opensource.org/licenses/BSD-3-Clause |
15 | * |
16 | * |
16 | ****************************************************************************** |
17 | ****************************************************************************** |
17 | */ |
18 | */ |
18 | #if defined(USE_FULL_LL_DRIVER) |
19 | #if defined(USE_FULL_LL_DRIVER) |
19 | |
20 | 20 | /* Includes ------------------------------------------------------------------*/ |
|
21 | /* Includes ------------------------------------------------------------------*/ |
21 | #include "stm32l1xx_ll_rtc.h" |
22 | #include "stm32l1xx_ll_rtc.h" |
22 | #include "stm32l1xx_ll_cortex.h" |
23 | #include "stm32l1xx_ll_cortex.h" |
23 | #ifdef USE_FULL_ASSERT |
24 | #ifdef USE_FULL_ASSERT |
24 | #include "stm32_assert.h" |
25 | #include "stm32_assert.h" |
25 | #else |
26 | #else |
26 | #define assert_param(expr) ((void)0U) |
27 | #define assert_param(expr) ((void)0U) |
27 | #endif |
28 | #endif |
28 | |
29 | 29 | /** @addtogroup STM32L1xx_LL_Driver |
|
30 | /** @addtogroup STM32L1xx_LL_Driver |
30 | * @{ |
31 | * @{ |
31 | */ |
32 | */ |
32 | |
33 | 33 | #if defined(RTC) |
|
34 | #if defined(RTC) |
34 | |
35 | 35 | /** @addtogroup RTC_LL |
|
36 | /** @addtogroup RTC_LL |
36 | * @{ |
37 | * @{ |
37 | */ |
38 | */ |
38 | |
39 | 39 | /* Private types -------------------------------------------------------------*/ |
|
40 | /* Private types -------------------------------------------------------------*/ |
40 | /* Private variables ---------------------------------------------------------*/ |
41 | /* Private variables ---------------------------------------------------------*/ |
41 | /* Private constants ---------------------------------------------------------*/ |
42 | /* Private constants ---------------------------------------------------------*/ |
42 | /** @addtogroup RTC_LL_Private_Constants |
43 | /** @addtogroup RTC_LL_Private_Constants |
43 | * @{ |
44 | * @{ |
44 | */ |
45 | */ |
45 | /* Default values used for prescaler */ |
46 | /* Default values used for prescaler */ |
46 | #define RTC_ASYNCH_PRESC_DEFAULT 0x0000007FU |
47 | #define RTC_ASYNCH_PRESC_DEFAULT 0x0000007FU |
47 | #define RTC_SYNCH_PRESC_DEFAULT 0x000000FFU |
48 | #define RTC_SYNCH_PRESC_DEFAULT 0x000000FFU |
48 | |
49 | 49 | /* Values used for timeout */ |
|
50 | /* Values used for timeout */ |
50 | #define RTC_INITMODE_TIMEOUT 1000U /* 1s when tick set to 1ms */ |
51 | #define RTC_INITMODE_TIMEOUT 1000U /* 1s when tick set to 1ms */ |
51 | #define RTC_SYNCHRO_TIMEOUT 1000U /* 1s when tick set to 1ms */ |
52 | #define RTC_SYNCHRO_TIMEOUT 1000U /* 1s when tick set to 1ms */ |
52 | /** |
53 | /** |
53 | * @} |
54 | * @} |
54 | */ |
55 | */ |
55 | |
56 | 56 | /* Private macros ------------------------------------------------------------*/ |
|
57 | /* Private macros ------------------------------------------------------------*/ |
57 | /** @addtogroup RTC_LL_Private_Macros |
58 | /** @addtogroup RTC_LL_Private_Macros |
58 | * @{ |
59 | * @{ |
59 | */ |
60 | */ |
60 | |
61 | 61 | #define IS_LL_RTC_HOURFORMAT(__VALUE__) (((__VALUE__) == LL_RTC_HOURFORMAT_24HOUR) \ |
|
62 | #define IS_LL_RTC_HOURFORMAT(__VALUE__) (((__VALUE__) == LL_RTC_HOURFORMAT_24HOUR) \ |
62 | || ((__VALUE__) == LL_RTC_HOURFORMAT_AMPM)) |
63 | || ((__VALUE__) == LL_RTC_HOURFORMAT_AMPM)) |
63 | |
64 | 64 | #define IS_LL_RTC_ASYNCH_PREDIV(__VALUE__) ((__VALUE__) <= 0x7FU) |
|
65 | #define IS_LL_RTC_ASYNCH_PREDIV(__VALUE__) ((__VALUE__) <= 0x7FU) |
65 | |
66 | 66 | #define IS_LL_RTC_SYNCH_PREDIV(__VALUE__) ((__VALUE__) <= 0x7FFFU) |
|
67 | #define IS_LL_RTC_SYNCH_PREDIV(__VALUE__) ((__VALUE__) <= 0x7FFFU) |
67 | |
68 | 68 | #define IS_LL_RTC_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_FORMAT_BIN) \ |
|
69 | #define IS_LL_RTC_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_FORMAT_BIN) \ |
69 | || ((__VALUE__) == LL_RTC_FORMAT_BCD)) |
70 | || ((__VALUE__) == LL_RTC_FORMAT_BCD)) |
70 | |
71 | 71 | #define IS_LL_RTC_TIME_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_TIME_FORMAT_AM_OR_24) \ |
|
72 | #define IS_LL_RTC_TIME_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_TIME_FORMAT_AM_OR_24) \ |
72 | || ((__VALUE__) == LL_RTC_TIME_FORMAT_PM)) |
73 | || ((__VALUE__) == LL_RTC_TIME_FORMAT_PM)) |
73 | |
74 | 74 | #define IS_LL_RTC_HOUR12(__HOUR__) (((__HOUR__) > 0U) && ((__HOUR__) <= 12U)) |
|
75 | #define IS_LL_RTC_HOUR12(__HOUR__) (((__HOUR__) > 0U) && ((__HOUR__) <= 12U)) |
75 | #define IS_LL_RTC_HOUR24(__HOUR__) ((__HOUR__) <= 23U) |
76 | #define IS_LL_RTC_HOUR24(__HOUR__) ((__HOUR__) <= 23U) |
76 | #define IS_LL_RTC_MINUTES(__MINUTES__) ((__MINUTES__) <= 59U) |
77 | #define IS_LL_RTC_MINUTES(__MINUTES__) ((__MINUTES__) <= 59U) |
77 | #define IS_LL_RTC_SECONDS(__SECONDS__) ((__SECONDS__) <= 59U) |
78 | #define IS_LL_RTC_SECONDS(__SECONDS__) ((__SECONDS__) <= 59U) |
78 | |
79 | 79 | #define IS_LL_RTC_WEEKDAY(__VALUE__) (((__VALUE__) == LL_RTC_WEEKDAY_MONDAY) \ |
|
80 | #define IS_LL_RTC_WEEKDAY(__VALUE__) (((__VALUE__) == LL_RTC_WEEKDAY_MONDAY) \ |
80 | || ((__VALUE__) == LL_RTC_WEEKDAY_TUESDAY) \ |
81 | || ((__VALUE__) == LL_RTC_WEEKDAY_TUESDAY) \ |
81 | || ((__VALUE__) == LL_RTC_WEEKDAY_WEDNESDAY) \ |
82 | || ((__VALUE__) == LL_RTC_WEEKDAY_WEDNESDAY) \ |
82 | || ((__VALUE__) == LL_RTC_WEEKDAY_THURSDAY) \ |
83 | || ((__VALUE__) == LL_RTC_WEEKDAY_THURSDAY) \ |
83 | || ((__VALUE__) == LL_RTC_WEEKDAY_FRIDAY) \ |
84 | || ((__VALUE__) == LL_RTC_WEEKDAY_FRIDAY) \ |
84 | || ((__VALUE__) == LL_RTC_WEEKDAY_SATURDAY) \ |
85 | || ((__VALUE__) == LL_RTC_WEEKDAY_SATURDAY) \ |
85 | || ((__VALUE__) == LL_RTC_WEEKDAY_SUNDAY)) |
86 | || ((__VALUE__) == LL_RTC_WEEKDAY_SUNDAY)) |
86 | |
87 | 87 | #define IS_LL_RTC_DAY(__DAY__) (((__DAY__) >= 1U) && ((__DAY__) <= 31U)) |
|
88 | #define IS_LL_RTC_DAY(__DAY__) (((__DAY__) >= 1U) && ((__DAY__) <= 31U)) |
88 | |
89 | 89 | #define IS_LL_RTC_MONTH(__MONTH__) (((__MONTH__) >= 1U) && ((__MONTH__) <= 12U)) |
|
90 | #define IS_LL_RTC_MONTH(__MONTH__) (((__MONTH__) >= 1U) && ((__MONTH__) <= 12U)) |
90 | |
91 | 91 | #define IS_LL_RTC_YEAR(__YEAR__) ((__YEAR__) <= 99U) |
|
92 | #define IS_LL_RTC_YEAR(__YEAR__) ((__YEAR__) <= 99U) |
92 | |
93 | 93 | #define IS_LL_RTC_ALMA_MASK(__VALUE__) (((__VALUE__) == LL_RTC_ALMA_MASK_NONE) \ |
|
94 | #define IS_LL_RTC_ALMA_MASK(__VALUE__) (((__VALUE__) == LL_RTC_ALMA_MASK_NONE) \ |
94 | || ((__VALUE__) == LL_RTC_ALMA_MASK_DATEWEEKDAY) \ |
95 | || ((__VALUE__) == LL_RTC_ALMA_MASK_DATEWEEKDAY) \ |
95 | || ((__VALUE__) == LL_RTC_ALMA_MASK_HOURS) \ |
96 | || ((__VALUE__) == LL_RTC_ALMA_MASK_HOURS) \ |
96 | || ((__VALUE__) == LL_RTC_ALMA_MASK_MINUTES) \ |
97 | || ((__VALUE__) == LL_RTC_ALMA_MASK_MINUTES) \ |
97 | || ((__VALUE__) == LL_RTC_ALMA_MASK_SECONDS) \ |
98 | || ((__VALUE__) == LL_RTC_ALMA_MASK_SECONDS) \ |
98 | || ((__VALUE__) == LL_RTC_ALMA_MASK_ALL)) |
99 | || ((__VALUE__) == LL_RTC_ALMA_MASK_ALL)) |
99 | |
100 | 100 | #define IS_LL_RTC_ALMB_MASK(__VALUE__) (((__VALUE__) == LL_RTC_ALMB_MASK_NONE) \ |
|
101 | #define IS_LL_RTC_ALMB_MASK(__VALUE__) (((__VALUE__) == LL_RTC_ALMB_MASK_NONE) \ |
101 | || ((__VALUE__) == LL_RTC_ALMB_MASK_DATEWEEKDAY) \ |
102 | || ((__VALUE__) == LL_RTC_ALMB_MASK_DATEWEEKDAY) \ |
102 | || ((__VALUE__) == LL_RTC_ALMB_MASK_HOURS) \ |
103 | || ((__VALUE__) == LL_RTC_ALMB_MASK_HOURS) \ |
103 | || ((__VALUE__) == LL_RTC_ALMB_MASK_MINUTES) \ |
104 | || ((__VALUE__) == LL_RTC_ALMB_MASK_MINUTES) \ |
104 | || ((__VALUE__) == LL_RTC_ALMB_MASK_SECONDS) \ |
105 | || ((__VALUE__) == LL_RTC_ALMB_MASK_SECONDS) \ |
105 | || ((__VALUE__) == LL_RTC_ALMB_MASK_ALL)) |
106 | || ((__VALUE__) == LL_RTC_ALMB_MASK_ALL)) |
106 | |
107 | 107 | #define IS_LL_RTC_ALMA_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) || \ |
|
108 | 108 | ((__SEL__) == LL_RTC_ALMA_DATEWEEKDAYSEL_WEEKDAY)) |
|
109 | #define IS_LL_RTC_ALMA_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) || \ |
109 | |
110 | ((__SEL__) == LL_RTC_ALMA_DATEWEEKDAYSEL_WEEKDAY)) |
110 | #define IS_LL_RTC_ALMB_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) || \ |
111 | 111 | ((__SEL__) == LL_RTC_ALMB_DATEWEEKDAYSEL_WEEKDAY)) |
|
112 | #define IS_LL_RTC_ALMB_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) || \ |
112 | |
113 | ((__SEL__) == LL_RTC_ALMB_DATEWEEKDAYSEL_WEEKDAY)) |
113 | /** |
114 | 114 | * @} |
|
115 | 115 | */ |
|
116 | /** |
116 | /* Private function prototypes -----------------------------------------------*/ |
117 | * @} |
117 | /* Exported functions --------------------------------------------------------*/ |
118 | */ |
118 | /** @addtogroup RTC_LL_Exported_Functions |
119 | /* Private function prototypes -----------------------------------------------*/ |
119 | * @{ |
120 | /* Exported functions --------------------------------------------------------*/ |
120 | */ |
121 | /** @addtogroup RTC_LL_Exported_Functions |
121 | |
122 | * @{ |
122 | /** @addtogroup RTC_LL_EF_Init |
123 | */ |
123 | * @{ |
124 | 124 | */ |
|
125 | /** @addtogroup RTC_LL_EF_Init |
125 | |
126 | * @{ |
126 | /** |
127 | */ |
127 | * @brief De-Initializes the RTC registers to their default reset values. |
128 | 128 | * @note This function does not reset the RTC Clock source and RTC Backup Data |
|
129 | /** |
129 | * registers. |
130 | * @brief De-Initializes the RTC registers to their default reset values. |
130 | * @param RTCx RTC Instance |
131 | * @note This function does not reset the RTC Clock source and RTC Backup Data |
131 | * @retval An ErrorStatus enumeration value: |
132 | * registers. |
132 | * - SUCCESS: RTC registers are de-initialized |
133 | * @param RTCx RTC Instance |
133 | * - ERROR: RTC registers are not de-initialized |
134 | * @retval An ErrorStatus enumeration value: |
134 | */ |
135 | * - SUCCESS: RTC registers are de-initialized |
135 | ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx) |
136 | * - ERROR: RTC registers are not de-initialized |
136 | { |
137 | */ |
137 | ErrorStatus status = ERROR; |
138 | ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx) |
138 | |
139 | { |
139 | /* Check the parameter */ |
140 | ErrorStatus status = ERROR; |
140 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
141 | 141 | ||
142 | /* Check the parameter */ |
142 | /* Disable the write protection for RTC registers */ |
143 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
143 | LL_RTC_DisableWriteProtection(RTCx); |
144 | 144 | ||
145 | /* Disable the write protection for RTC registers */ |
145 | /* Set Initialization mode */ |
146 | LL_RTC_DisableWriteProtection(RTCx); |
146 | if (LL_RTC_EnterInitMode(RTCx) != ERROR) |
147 | 147 | { |
|
148 | /* Set Initialization mode */ |
148 | /* Reset TR, DR and CR registers */ |
149 | if (LL_RTC_EnterInitMode(RTCx) != ERROR) |
149 | LL_RTC_WriteReg(RTCx, TR, 0x00000000U); |
150 | { |
150 | LL_RTC_WriteReg(RTCx, WUTR, RTC_WUTR_WUT); |
151 | /* Reset TR, DR and CR registers */ |
151 | LL_RTC_WriteReg(RTCx, DR, (RTC_DR_WDU_0 | RTC_DR_MU_0 | RTC_DR_DU_0)); |
152 | LL_RTC_WriteReg(RTCx, TR, 0x00000000U); |
152 | |
153 | #if defined(RTC_WAKEUP_SUPPORT) |
153 | /* Reset All CR bits except CR[2:0] */ |
154 | LL_RTC_WriteReg(RTCx, WUTR, RTC_WUTR_WUT); |
154 | LL_RTC_WriteReg(RTCx, CR, (LL_RTC_ReadReg(RTCx, CR) & RTC_CR_WUCKSEL)); |
155 | #endif /* RTC_WAKEUP_SUPPORT */ |
155 | |
156 | LL_RTC_WriteReg(RTCx, DR, (RTC_DR_WDU_0 | RTC_DR_MU_0 | RTC_DR_DU_0)); |
156 | LL_RTC_WriteReg(RTCx, PRER, (RTC_PRER_PREDIV_A | RTC_SYNCH_PRESC_DEFAULT)); |
157 | /* Reset All CR bits except CR[2:0] */ |
157 | LL_RTC_WriteReg(RTCx, ALRMAR, 0x00000000U); |
158 | #if defined(RTC_WAKEUP_SUPPORT) |
158 | LL_RTC_WriteReg(RTCx, ALRMBR, 0x00000000U); |
159 | LL_RTC_WriteReg(RTCx, CR, (LL_RTC_ReadReg(RTCx, CR) & RTC_CR_WUCKSEL)); |
159 | #if defined(RTC_SMOOTHCALIB_SUPPORT) |
160 | #else |
160 | LL_RTC_WriteReg(RTCx, CALR, 0x00000000U); |
161 | LL_RTC_WriteReg(RTCx, CR, 0x00000000U); |
161 | #endif /* RTC_SMOOTHCALIB_SUPPORT */ |
162 | #endif /* RTC_WAKEUP_SUPPORT */ |
162 | #if defined(RTC_SUBSECOND_SUPPORT) |
163 | LL_RTC_WriteReg(RTCx, PRER, (RTC_PRER_PREDIV_A | RTC_SYNCH_PRESC_DEFAULT)); |
163 | LL_RTC_WriteReg(RTCx, SHIFTR, 0x00000000U); |
164 | LL_RTC_WriteReg(RTCx, ALRMAR, 0x00000000U); |
164 | LL_RTC_WriteReg(RTCx, ALRMASSR, 0x00000000U); |
165 | LL_RTC_WriteReg(RTCx, ALRMBR, 0x00000000U); |
165 | LL_RTC_WriteReg(RTCx, ALRMBSSR, 0x00000000U); |
166 | #if defined(RTC_SHIFTR_ADD1S) |
166 | #endif /* RTC_SUBSECOND_SUPPORT */ |
167 | LL_RTC_WriteReg(RTCx, SHIFTR, 0x00000000U); |
167 | |
168 | #endif /* RTC_SHIFTR_ADD1S */ |
168 | /* Reset ISR register and exit initialization mode */ |
169 | #if defined(RTC_SMOOTHCALIB_SUPPORT) |
169 | LL_RTC_WriteReg(RTCx, ISR, 0x00000000U); |
170 | LL_RTC_WriteReg(RTCx, CALR, 0x00000000U); |
170 | |
171 | #endif /* RTC_SMOOTHCALIB_SUPPORT */ |
171 | /* Reset Tamper and alternate functions configuration register */ |
172 | #if defined(RTC_SUBSECOND_SUPPORT) |
172 | LL_RTC_WriteReg(RTCx, TAFCR, 0x00000000U); |
173 | LL_RTC_WriteReg(RTCx, ALRMASSR, 0x00000000U); |
173 | |
174 | LL_RTC_WriteReg(RTCx, ALRMBSSR, 0x00000000U); |
174 | /* Wait till the RTC RSF flag is set */ |
175 | #endif /* RTC_SUBSECOND_SUPPORT */ |
175 | status = LL_RTC_WaitForSynchro(RTCx); |
176 | 176 | } |
|
177 | /* Reset ISR register and exit initialization mode */ |
177 | |
178 | LL_RTC_WriteReg(RTCx, ISR, 0x00000000U); |
178 | /* Enable the write protection for RTC registers */ |
179 | 179 | LL_RTC_EnableWriteProtection(RTCx); |
|
180 | /* Reset Tamper and alternate functions configuration register */ |
180 | |
181 | LL_RTC_WriteReg(RTCx, TAFCR, 0x00000000U); |
181 | return status; |
182 | 182 | } |
|
183 | /* Wait till the RTC RSF flag is set */ |
183 | |
184 | status = LL_RTC_WaitForSynchro(RTCx); |
184 | /** |
185 | } |
185 | * @brief Initializes the RTC registers according to the specified parameters |
186 | 186 | * in RTC_InitStruct. |
|
187 | /* Enable the write protection for RTC registers */ |
187 | * @param RTCx RTC Instance |
188 | LL_RTC_EnableWriteProtection(RTCx); |
188 | * @param RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure that contains |
189 | 189 | * the configuration information for the RTC peripheral. |
|
190 | return status; |
190 | * @note The RTC Prescaler register is write protected and can be written in |
191 | } |
191 | * initialization mode only. |
192 | 192 | * @retval An ErrorStatus enumeration value: |
|
193 | /** |
193 | * - SUCCESS: RTC registers are initialized |
194 | * @brief Initializes the RTC registers according to the specified parameters |
194 | * - ERROR: RTC registers are not initialized |
195 | * in RTC_InitStruct. |
195 | */ |
196 | * @param RTCx RTC Instance |
196 | ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct) |
197 | * @param RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure that contains |
197 | { |
198 | * the configuration information for the RTC peripheral. |
198 | ErrorStatus status = ERROR; |
199 | * @note The RTC Prescaler register is write protected and can be written in |
199 | |
200 | * initialization mode only. |
200 | /* Check the parameters */ |
201 | * @retval An ErrorStatus enumeration value: |
201 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
202 | * - SUCCESS: RTC registers are initialized |
202 | assert_param(IS_LL_RTC_HOURFORMAT(RTC_InitStruct->HourFormat)); |
203 | * - ERROR: RTC registers are not initialized |
203 | assert_param(IS_LL_RTC_ASYNCH_PREDIV(RTC_InitStruct->AsynchPrescaler)); |
204 | */ |
204 | assert_param(IS_LL_RTC_SYNCH_PREDIV(RTC_InitStruct->SynchPrescaler)); |
205 | ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct) |
205 | |
206 | { |
206 | /* Disable the write protection for RTC registers */ |
207 | ErrorStatus status = ERROR; |
207 | LL_RTC_DisableWriteProtection(RTCx); |
208 | 208 | ||
209 | /* Check the parameters */ |
209 | /* Set Initialization mode */ |
210 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
210 | if (LL_RTC_EnterInitMode(RTCx) != ERROR) |
211 | assert_param(IS_LL_RTC_HOURFORMAT(RTC_InitStruct->HourFormat)); |
211 | { |
212 | assert_param(IS_LL_RTC_ASYNCH_PREDIV(RTC_InitStruct->AsynchPrescaler)); |
212 | /* Set Hour Format */ |
213 | assert_param(IS_LL_RTC_SYNCH_PREDIV(RTC_InitStruct->SynchPrescaler)); |
213 | LL_RTC_SetHourFormat(RTCx, RTC_InitStruct->HourFormat); |
214 | 214 | ||
215 | /* Disable the write protection for RTC registers */ |
215 | /* Configure Synchronous and Asynchronous prescaler factor */ |
216 | LL_RTC_DisableWriteProtection(RTCx); |
216 | LL_RTC_SetSynchPrescaler(RTCx, RTC_InitStruct->SynchPrescaler); |
217 | 217 | LL_RTC_SetAsynchPrescaler(RTCx, RTC_InitStruct->AsynchPrescaler); |
|
218 | /* Set Initialization mode */ |
218 | |
219 | if (LL_RTC_EnterInitMode(RTCx) != ERROR) |
219 | /* Exit Initialization mode */ |
220 | { |
220 | LL_RTC_DisableInitMode(RTCx); |
221 | /* Set Hour Format */ |
221 | |
222 | LL_RTC_SetHourFormat(RTCx, RTC_InitStruct->HourFormat); |
222 | status = SUCCESS; |
223 | 223 | } |
|
224 | /* Configure Synchronous and Asynchronous prescaler factor */ |
224 | /* Enable the write protection for RTC registers */ |
225 | LL_RTC_SetSynchPrescaler(RTCx, RTC_InitStruct->SynchPrescaler); |
225 | LL_RTC_EnableWriteProtection(RTCx); |
226 | LL_RTC_SetAsynchPrescaler(RTCx, RTC_InitStruct->AsynchPrescaler); |
226 | |
227 | 227 | return status; |
|
228 | /* Exit Initialization mode */ |
228 | } |
229 | LL_RTC_DisableInitMode(RTCx); |
229 | |
230 | 230 | /** |
|
231 | status = SUCCESS; |
231 | * @brief Set each @ref LL_RTC_InitTypeDef field to default value. |
232 | } |
232 | * @param RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure which will be initialized. |
233 | /* Enable the write protection for RTC registers */ |
233 | * @retval None |
234 | LL_RTC_EnableWriteProtection(RTCx); |
234 | */ |
235 | 235 | void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct) |
|
236 | return status; |
236 | { |
237 | } |
237 | /* Set RTC_InitStruct fields to default values */ |
238 | 238 | RTC_InitStruct->HourFormat = LL_RTC_HOURFORMAT_24HOUR; |
|
239 | /** |
239 | RTC_InitStruct->AsynchPrescaler = RTC_ASYNCH_PRESC_DEFAULT; |
240 | * @brief Set each @ref LL_RTC_InitTypeDef field to default value. |
240 | RTC_InitStruct->SynchPrescaler = RTC_SYNCH_PRESC_DEFAULT; |
241 | * @param RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure which will be initialized. |
241 | } |
242 | * @retval None |
242 | |
243 | */ |
243 | /** |
244 | void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct) |
244 | * @brief Set the RTC current time. |
245 | { |
245 | * @param RTCx RTC Instance |
246 | /* Set RTC_InitStruct fields to default values */ |
246 | * @param RTC_Format This parameter can be one of the following values: |
247 | RTC_InitStruct->HourFormat = LL_RTC_HOURFORMAT_24HOUR; |
247 | * @arg @ref LL_RTC_FORMAT_BIN |
248 | RTC_InitStruct->AsynchPrescaler = RTC_ASYNCH_PRESC_DEFAULT; |
248 | * @arg @ref LL_RTC_FORMAT_BCD |
249 | RTC_InitStruct->SynchPrescaler = RTC_SYNCH_PRESC_DEFAULT; |
249 | * @param RTC_TimeStruct pointer to a RTC_TimeTypeDef structure that contains |
250 | } |
250 | * the time configuration information for the RTC. |
251 | 251 | * @retval An ErrorStatus enumeration value: |
|
252 | /** |
252 | * - SUCCESS: RTC Time register is configured |
253 | * @brief Set the RTC current time. |
253 | * - ERROR: RTC Time register is not configured |
254 | * @param RTCx RTC Instance |
254 | */ |
255 | * @param RTC_Format This parameter can be one of the following values: |
255 | ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct) |
256 | * @arg @ref LL_RTC_FORMAT_BIN |
256 | { |
257 | * @arg @ref LL_RTC_FORMAT_BCD |
257 | ErrorStatus status = ERROR; |
258 | * @param RTC_TimeStruct pointer to a RTC_TimeTypeDef structure that contains |
258 | |
259 | * the time configuration information for the RTC. |
259 | /* Check the parameters */ |
260 | * @retval An ErrorStatus enumeration value: |
260 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
261 | * - SUCCESS: RTC Time register is configured |
261 | assert_param(IS_LL_RTC_FORMAT(RTC_Format)); |
262 | * - ERROR: RTC Time register is not configured |
262 | |
263 | */ |
263 | if (RTC_Format == LL_RTC_FORMAT_BIN) |
264 | ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct) |
264 | { |
265 | { |
265 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
266 | ErrorStatus status = ERROR; |
266 | { |
267 | 267 | assert_param(IS_LL_RTC_HOUR12(RTC_TimeStruct->Hours)); |
|
268 | /* Check the parameters */ |
268 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_TimeStruct->TimeFormat)); |
269 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
269 | } |
270 | assert_param(IS_LL_RTC_FORMAT(RTC_Format)); |
270 | else |
271 | 271 | { |
|
272 | if (RTC_Format == LL_RTC_FORMAT_BIN) |
272 | RTC_TimeStruct->TimeFormat = 0x00U; |
273 | { |
273 | assert_param(IS_LL_RTC_HOUR24(RTC_TimeStruct->Hours)); |
274 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
274 | } |
275 | { |
275 | assert_param(IS_LL_RTC_MINUTES(RTC_TimeStruct->Minutes)); |
276 | assert_param(IS_LL_RTC_HOUR12(RTC_TimeStruct->Hours)); |
276 | assert_param(IS_LL_RTC_SECONDS(RTC_TimeStruct->Seconds)); |
277 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_TimeStruct->TimeFormat)); |
277 | } |
278 | } |
278 | else |
279 | else |
279 | { |
280 | { |
280 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
281 | RTC_TimeStruct->TimeFormat = 0x00U; |
281 | { |
282 | assert_param(IS_LL_RTC_HOUR24(RTC_TimeStruct->Hours)); |
282 | assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours))); |
283 | } |
283 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_TimeStruct->TimeFormat)); |
284 | assert_param(IS_LL_RTC_MINUTES(RTC_TimeStruct->Minutes)); |
284 | } |
285 | assert_param(IS_LL_RTC_SECONDS(RTC_TimeStruct->Seconds)); |
285 | else |
286 | } |
286 | { |
287 | else |
287 | RTC_TimeStruct->TimeFormat = 0x00U; |
288 | { |
288 | assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours))); |
289 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
289 | } |
290 | { |
290 | assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Minutes))); |
291 | assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours))); |
291 | assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Seconds))); |
292 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_TimeStruct->TimeFormat)); |
292 | } |
293 | } |
293 | |
294 | else |
294 | /* Disable the write protection for RTC registers */ |
295 | { |
295 | LL_RTC_DisableWriteProtection(RTCx); |
296 | RTC_TimeStruct->TimeFormat = 0x00U; |
296 | |
297 | assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours))); |
297 | /* Set Initialization mode */ |
298 | } |
298 | if (LL_RTC_EnterInitMode(RTCx) != ERROR) |
299 | assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Minutes))); |
299 | { |
300 | assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Seconds))); |
300 | /* Check the input parameters format */ |
301 | } |
301 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
302 | 302 | { |
|
303 | /* Disable the write protection for RTC registers */ |
303 | LL_RTC_TIME_Config(RTCx, RTC_TimeStruct->TimeFormat, RTC_TimeStruct->Hours, |
304 | LL_RTC_DisableWriteProtection(RTCx); |
304 | RTC_TimeStruct->Minutes, RTC_TimeStruct->Seconds); |
305 | 305 | } |
|
306 | /* Set Initialization mode */ |
306 | else |
307 | if (LL_RTC_EnterInitMode(RTCx) != ERROR) |
307 | { |
308 | { |
308 | LL_RTC_TIME_Config(RTCx, RTC_TimeStruct->TimeFormat, __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Hours), |
309 | /* Check the input parameters format */ |
309 | __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Minutes), |
310 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
310 | __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Seconds)); |
311 | { |
311 | } |
312 | LL_RTC_TIME_Config(RTCx, RTC_TimeStruct->TimeFormat, RTC_TimeStruct->Hours, |
312 | |
313 | RTC_TimeStruct->Minutes, RTC_TimeStruct->Seconds); |
313 | /* Exit Initialization mode */ |
314 | } |
314 | LL_RTC_DisableInitMode(RTCx); |
315 | else |
315 | |
316 | { |
316 | #if defined(RTC_CR_BYPSHAD) |
317 | LL_RTC_TIME_Config(RTCx, RTC_TimeStruct->TimeFormat, __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Hours), |
317 | /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */ |
318 | __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Minutes), |
318 | if (LL_RTC_IsShadowRegBypassEnabled(RTCx) == 0U) |
319 | __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Seconds)); |
319 | { |
320 | } |
320 | status = LL_RTC_WaitForSynchro(RTCx); |
321 | 321 | } |
|
322 | /* Exit Initialization mode */ |
322 | else |
323 | LL_RTC_DisableInitMode(RTCx); |
323 | { |
324 | 324 | status = SUCCESS; |
|
325 | #if defined(RTC_CR_BYPSHAD) |
325 | } |
326 | /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */ |
326 | #else /* RTC_CR_BYPSHAD */ |
327 | if (LL_RTC_IsShadowRegBypassEnabled(RTCx) == 0U) |
327 | status = SUCCESS; |
328 | { |
328 | #endif /* RTC_CR_BYPSHAD */ |
329 | status = LL_RTC_WaitForSynchro(RTCx); |
329 | } |
330 | } |
330 | /* Enable the write protection for RTC registers */ |
331 | else |
331 | LL_RTC_EnableWriteProtection(RTCx); |
332 | { |
332 | |
333 | status = SUCCESS; |
333 | return status; |
334 | } |
334 | } |
335 | #else |
335 | |
336 | status = SUCCESS; |
336 | /** |
337 | #endif /* RTC_CR_BYPSHAD */ |
337 | * @brief Set each @ref LL_RTC_TimeTypeDef field to default value (Time = 00h:00min:00sec). |
338 | } |
338 | * @param RTC_TimeStruct pointer to a @ref LL_RTC_TimeTypeDef structure which will be initialized. |
339 | /* Enable the write protection for RTC registers */ |
339 | * @retval None |
340 | LL_RTC_EnableWriteProtection(RTCx); |
340 | */ |
341 | 341 | void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct) |
|
342 | return status; |
342 | { |
343 | } |
343 | /* Time = 00h:00min:00sec */ |
344 | 344 | RTC_TimeStruct->TimeFormat = LL_RTC_TIME_FORMAT_AM_OR_24; |
|
345 | /** |
345 | RTC_TimeStruct->Hours = 0U; |
346 | * @brief Set each @ref LL_RTC_TimeTypeDef field to default value (Time = 00h:00min:00sec). |
346 | RTC_TimeStruct->Minutes = 0U; |
347 | * @param RTC_TimeStruct pointer to a @ref LL_RTC_TimeTypeDef structure which will be initialized. |
347 | RTC_TimeStruct->Seconds = 0U; |
348 | * @retval None |
348 | } |
349 | */ |
349 | |
350 | void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct) |
350 | /** |
351 | { |
351 | * @brief Set the RTC current date. |
352 | /* Time = 00h:00min:00sec */ |
352 | * @param RTCx RTC Instance |
353 | RTC_TimeStruct->TimeFormat = LL_RTC_TIME_FORMAT_AM_OR_24; |
353 | * @param RTC_Format This parameter can be one of the following values: |
354 | RTC_TimeStruct->Hours = 0U; |
354 | * @arg @ref LL_RTC_FORMAT_BIN |
355 | RTC_TimeStruct->Minutes = 0U; |
355 | * @arg @ref LL_RTC_FORMAT_BCD |
356 | RTC_TimeStruct->Seconds = 0U; |
356 | * @param RTC_DateStruct pointer to a RTC_DateTypeDef structure that contains |
357 | } |
357 | * the date configuration information for the RTC. |
358 | 358 | * @retval An ErrorStatus enumeration value: |
|
359 | /** |
359 | * - SUCCESS: RTC Day register is configured |
360 | * @brief Set the RTC current date. |
360 | * - ERROR: RTC Day register is not configured |
361 | * @param RTCx RTC Instance |
361 | */ |
362 | * @param RTC_Format This parameter can be one of the following values: |
362 | ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct) |
363 | * @arg @ref LL_RTC_FORMAT_BIN |
363 | { |
364 | * @arg @ref LL_RTC_FORMAT_BCD |
364 | ErrorStatus status = ERROR; |
365 | * @param RTC_DateStruct pointer to a RTC_DateTypeDef structure that contains |
365 | |
366 | * the date configuration information for the RTC. |
366 | /* Check the parameters */ |
367 | * @retval An ErrorStatus enumeration value: |
367 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
368 | * - SUCCESS: RTC Day register is configured |
368 | assert_param(IS_LL_RTC_FORMAT(RTC_Format)); |
369 | * - ERROR: RTC Day register is not configured |
369 | |
370 | */ |
370 | if ((RTC_Format == LL_RTC_FORMAT_BIN) && ((RTC_DateStruct->Month & 0x10U) == 0x10U)) |
371 | ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct) |
371 | { |
372 | { |
372 | RTC_DateStruct->Month = (uint8_t)(RTC_DateStruct->Month & (uint8_t)~(0x10U)) + 0x0AU; |
373 | ErrorStatus status = ERROR; |
373 | } |
374 | 374 | if (RTC_Format == LL_RTC_FORMAT_BIN) |
|
375 | /* Check the parameters */ |
375 | { |
376 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
376 | assert_param(IS_LL_RTC_YEAR(RTC_DateStruct->Year)); |
377 | assert_param(IS_LL_RTC_FORMAT(RTC_Format)); |
377 | assert_param(IS_LL_RTC_MONTH(RTC_DateStruct->Month)); |
378 | 378 | assert_param(IS_LL_RTC_DAY(RTC_DateStruct->Day)); |
|
379 | if ((RTC_Format == LL_RTC_FORMAT_BIN) && ((RTC_DateStruct->Month & 0x10U) == 0x10U)) |
379 | } |
380 | { |
380 | else |
381 | RTC_DateStruct->Month = ((RTC_DateStruct->Month & (uint8_t)~(0x10U)) + 0x0AU); |
381 | { |
382 | } |
382 | assert_param(IS_LL_RTC_YEAR(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Year))); |
383 | if (RTC_Format == LL_RTC_FORMAT_BIN) |
383 | assert_param(IS_LL_RTC_MONTH(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Month))); |
384 | { |
384 | assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Day))); |
385 | assert_param(IS_LL_RTC_YEAR(RTC_DateStruct->Year)); |
385 | } |
386 | assert_param(IS_LL_RTC_MONTH(RTC_DateStruct->Month)); |
386 | assert_param(IS_LL_RTC_WEEKDAY(RTC_DateStruct->WeekDay)); |
387 | assert_param(IS_LL_RTC_DAY(RTC_DateStruct->Day)); |
387 | |
388 | } |
388 | /* Disable the write protection for RTC registers */ |
389 | else |
389 | LL_RTC_DisableWriteProtection(RTCx); |
390 | { |
390 | |
391 | assert_param(IS_LL_RTC_YEAR(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Year))); |
391 | /* Set Initialization mode */ |
392 | assert_param(IS_LL_RTC_MONTH(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Month))); |
392 | if (LL_RTC_EnterInitMode(RTCx) != ERROR) |
393 | assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Day))); |
393 | { |
394 | } |
394 | /* Check the input parameters format */ |
395 | assert_param(IS_LL_RTC_WEEKDAY(RTC_DateStruct->WeekDay)); |
395 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
396 | 396 | { |
|
397 | /* Disable the write protection for RTC registers */ |
397 | LL_RTC_DATE_Config(RTCx, RTC_DateStruct->WeekDay, RTC_DateStruct->Day, RTC_DateStruct->Month, RTC_DateStruct->Year); |
398 | LL_RTC_DisableWriteProtection(RTCx); |
398 | } |
399 | 399 | else |
|
400 | /* Set Initialization mode */ |
400 | { |
401 | if (LL_RTC_EnterInitMode(RTCx) != ERROR) |
401 | LL_RTC_DATE_Config(RTCx, RTC_DateStruct->WeekDay, __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Day), |
402 | { |
402 | __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Month), __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Year)); |
403 | /* Check the input parameters format */ |
403 | } |
404 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
404 | |
405 | { |
405 | /* Exit Initialization mode */ |
406 | LL_RTC_DATE_Config(RTCx, RTC_DateStruct->WeekDay, RTC_DateStruct->Day, RTC_DateStruct->Month, RTC_DateStruct->Year); |
406 | LL_RTC_DisableInitMode(RTCx); |
407 | } |
407 | |
408 | else |
408 | #if defined(RTC_CR_BYPSHAD) |
409 | { |
409 | /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */ |
410 | LL_RTC_DATE_Config(RTCx, RTC_DateStruct->WeekDay, __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Day), |
410 | if (LL_RTC_IsShadowRegBypassEnabled(RTCx) == 0U) |
411 | __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Month), __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Year)); |
411 | { |
412 | } |
412 | status = LL_RTC_WaitForSynchro(RTCx); |
413 | 413 | } |
|
414 | /* Exit Initialization mode */ |
414 | else |
415 | LL_RTC_DisableInitMode(RTCx); |
415 | { |
416 | 416 | status = SUCCESS; |
|
417 | #if defined(RTC_CR_BYPSHAD) |
417 | } |
418 | /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */ |
418 | #else /* RTC_CR_BYPSHAD */ |
419 | if (LL_RTC_IsShadowRegBypassEnabled(RTCx) == 0U) |
419 | status = SUCCESS; |
420 | { |
420 | #endif /* RTC_CR_BYPSHAD */ |
421 | status = LL_RTC_WaitForSynchro(RTCx); |
421 | } |
422 | } |
422 | /* Enable the write protection for RTC registers */ |
423 | else |
423 | LL_RTC_EnableWriteProtection(RTCx); |
424 | { |
424 | |
425 | status = SUCCESS; |
425 | return status; |
426 | } |
426 | } |
427 | #else |
427 | |
428 | status = SUCCESS; |
428 | /** |
429 | #endif /* RTC_CR_BYPSHAD */ |
429 | * @brief Set each @ref LL_RTC_DateTypeDef field to default value (date = Monday, January 01 xx00) |
430 | } |
430 | * @param RTC_DateStruct pointer to a @ref LL_RTC_DateTypeDef structure which will be initialized. |
431 | /* Enable the write protection for RTC registers */ |
431 | * @retval None |
432 | LL_RTC_EnableWriteProtection(RTCx); |
432 | */ |
433 | 433 | void LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct) |
|
434 | return status; |
434 | { |
435 | } |
435 | /* Monday, January 01 xx00 */ |
436 | 436 | RTC_DateStruct->WeekDay = LL_RTC_WEEKDAY_MONDAY; |
|
437 | /** |
437 | RTC_DateStruct->Day = 1U; |
438 | * @brief Set each @ref LL_RTC_DateTypeDef field to default value (date = Monday, January 01 xx00) |
438 | RTC_DateStruct->Month = LL_RTC_MONTH_JANUARY; |
439 | * @param RTC_DateStruct pointer to a @ref LL_RTC_DateTypeDef structure which will be initialized. |
439 | RTC_DateStruct->Year = 0U; |
440 | * @retval None |
440 | } |
441 | */ |
441 | |
442 | void LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct) |
442 | /** |
443 | { |
443 | * @brief Set the RTC Alarm A. |
444 | /* Monday, January 01 xx00 */ |
444 | * @note The Alarm register can only be written when the corresponding Alarm |
445 | RTC_DateStruct->WeekDay = LL_RTC_WEEKDAY_MONDAY; |
445 | * is disabled (Use @ref LL_RTC_ALMA_Disable function). |
446 | RTC_DateStruct->Day = 1U; |
446 | * @param RTCx RTC Instance |
447 | RTC_DateStruct->Month = LL_RTC_MONTH_JANUARY; |
447 | * @param RTC_Format This parameter can be one of the following values: |
448 | RTC_DateStruct->Year = 0U; |
448 | * @arg @ref LL_RTC_FORMAT_BIN |
449 | } |
449 | * @arg @ref LL_RTC_FORMAT_BCD |
450 | 450 | * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure that |
|
451 | /** |
451 | * contains the alarm configuration parameters. |
452 | * @brief Set the RTC Alarm A. |
452 | * @retval An ErrorStatus enumeration value: |
453 | * @note The Alarm register can only be written when the corresponding Alarm |
453 | * - SUCCESS: ALARMA registers are configured |
454 | * is disabled (Use @ref LL_RTC_ALMA_Disable function). |
454 | * - ERROR: ALARMA registers are not configured |
455 | * @param RTCx RTC Instance |
455 | */ |
456 | * @param RTC_Format This parameter can be one of the following values: |
456 | ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct) |
457 | * @arg @ref LL_RTC_FORMAT_BIN |
457 | { |
458 | * @arg @ref LL_RTC_FORMAT_BCD |
458 | /* Check the parameters */ |
459 | * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure that |
459 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
460 | * contains the alarm configuration parameters. |
460 | assert_param(IS_LL_RTC_FORMAT(RTC_Format)); |
461 | * @retval An ErrorStatus enumeration value: |
461 | assert_param(IS_LL_RTC_ALMA_MASK(RTC_AlarmStruct->AlarmMask)); |
462 | * - SUCCESS: ALARMA registers are configured |
462 | assert_param(IS_LL_RTC_ALMA_DATE_WEEKDAY_SEL(RTC_AlarmStruct->AlarmDateWeekDaySel)); |
463 | * - ERROR: ALARMA registers are not configured |
463 | |
464 | */ |
464 | if (RTC_Format == LL_RTC_FORMAT_BIN) |
465 | ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct) |
465 | { |
466 | { |
466 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
467 | /* Check the parameters */ |
467 | { |
468 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
468 | assert_param(IS_LL_RTC_HOUR12(RTC_AlarmStruct->AlarmTime.Hours)); |
469 | assert_param(IS_LL_RTC_FORMAT(RTC_Format)); |
469 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); |
470 | assert_param(IS_LL_RTC_ALMA_MASK(RTC_AlarmStruct->AlarmMask)); |
470 | } |
471 | assert_param(IS_LL_RTC_ALMA_DATE_WEEKDAY_SEL(RTC_AlarmStruct->AlarmDateWeekDaySel)); |
471 | else |
472 | 472 | { |
|
473 | if (RTC_Format == LL_RTC_FORMAT_BIN) |
473 | RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; |
474 | { |
474 | assert_param(IS_LL_RTC_HOUR24(RTC_AlarmStruct->AlarmTime.Hours)); |
475 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
475 | } |
476 | { |
476 | assert_param(IS_LL_RTC_MINUTES(RTC_AlarmStruct->AlarmTime.Minutes)); |
477 | assert_param(IS_LL_RTC_HOUR12(RTC_AlarmStruct->AlarmTime.Hours)); |
477 | assert_param(IS_LL_RTC_SECONDS(RTC_AlarmStruct->AlarmTime.Seconds)); |
478 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); |
478 | |
479 | } |
479 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) |
480 | else |
480 | { |
481 | { |
481 | assert_param(IS_LL_RTC_DAY(RTC_AlarmStruct->AlarmDateWeekDay)); |
482 | RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; |
482 | } |
483 | assert_param(IS_LL_RTC_HOUR24(RTC_AlarmStruct->AlarmTime.Hours)); |
483 | else |
484 | } |
484 | { |
485 | assert_param(IS_LL_RTC_MINUTES(RTC_AlarmStruct->AlarmTime.Minutes)); |
485 | assert_param(IS_LL_RTC_WEEKDAY(RTC_AlarmStruct->AlarmDateWeekDay)); |
486 | assert_param(IS_LL_RTC_SECONDS(RTC_AlarmStruct->AlarmTime.Seconds)); |
486 | } |
487 | 487 | } |
|
488 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) |
488 | else |
489 | { |
489 | { |
490 | assert_param(IS_LL_RTC_DAY(RTC_AlarmStruct->AlarmDateWeekDay)); |
490 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
491 | } |
491 | { |
492 | else |
492 | assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); |
493 | { |
493 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); |
494 | assert_param(IS_LL_RTC_WEEKDAY(RTC_AlarmStruct->AlarmDateWeekDay)); |
494 | } |
495 | } |
495 | else |
496 | } |
496 | { |
497 | else |
497 | RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; |
498 | { |
498 | assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); |
499 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
499 | } |
500 | { |
500 | |
501 | assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); |
501 | assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes))); |
502 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); |
502 | assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds))); |
503 | } |
503 | |
504 | else |
504 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) |
505 | { |
505 | { |
506 | RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; |
506 | assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); |
507 | assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); |
507 | } |
508 | } |
508 | else |
509 | 509 | { |
|
510 | assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes))); |
510 | assert_param(IS_LL_RTC_WEEKDAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); |
511 | assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds))); |
511 | } |
512 | 512 | } |
|
513 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) |
513 | |
514 | { |
514 | /* Disable the write protection for RTC registers */ |
515 | assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); |
515 | LL_RTC_DisableWriteProtection(RTCx); |
516 | } |
516 | |
517 | else |
517 | /* Select weekday selection */ |
518 | { |
518 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) |
519 | assert_param(IS_LL_RTC_WEEKDAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); |
519 | { |
520 | } |
520 | /* Set the date for ALARM */ |
521 | } |
521 | LL_RTC_ALMA_DisableWeekday(RTCx); |
522 | 522 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
|
523 | /* Disable the write protection for RTC registers */ |
523 | { |
524 | LL_RTC_DisableWriteProtection(RTCx); |
524 | LL_RTC_ALMA_SetDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); |
525 | 525 | } |
|
526 | /* Select weekday selection */ |
526 | else |
527 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) |
527 | { |
528 | { |
528 | LL_RTC_ALMA_SetDay(RTCx, __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmDateWeekDay)); |
529 | /* Set the date for ALARM */ |
529 | } |
530 | LL_RTC_ALMA_DisableWeekday(RTCx); |
530 | } |
531 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
531 | else |
532 | { |
532 | { |
533 | LL_RTC_ALMA_SetDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); |
533 | /* Set the week day for ALARM */ |
534 | } |
534 | LL_RTC_ALMA_EnableWeekday(RTCx); |
535 | else |
535 | LL_RTC_ALMA_SetWeekDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); |
536 | { |
536 | } |
537 | LL_RTC_ALMA_SetDay(RTCx, __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmDateWeekDay)); |
537 | |
538 | } |
538 | /* Configure the Alarm register */ |
539 | } |
539 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
540 | else |
540 | { |
541 | { |
541 | LL_RTC_ALMA_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, RTC_AlarmStruct->AlarmTime.Hours, |
542 | /* Set the week day for ALARM */ |
542 | RTC_AlarmStruct->AlarmTime.Minutes, RTC_AlarmStruct->AlarmTime.Seconds); |
543 | LL_RTC_ALMA_EnableWeekday(RTCx); |
543 | } |
544 | LL_RTC_ALMA_SetWeekDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); |
544 | else |
545 | } |
545 | { |
546 | 546 | LL_RTC_ALMA_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, |
|
547 | /* Configure the Alarm register */ |
547 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Hours), |
548 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
548 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Minutes), |
549 | { |
549 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Seconds)); |
550 | LL_RTC_ALMA_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, RTC_AlarmStruct->AlarmTime.Hours, |
550 | } |
551 | RTC_AlarmStruct->AlarmTime.Minutes, RTC_AlarmStruct->AlarmTime.Seconds); |
551 | /* Set ALARM mask */ |
552 | } |
552 | LL_RTC_ALMA_SetMask(RTCx, RTC_AlarmStruct->AlarmMask); |
553 | else |
553 | |
554 | { |
554 | /* Enable the write protection for RTC registers */ |
555 | LL_RTC_ALMA_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, |
555 | LL_RTC_EnableWriteProtection(RTCx); |
556 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Hours), |
556 | |
557 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Minutes), |
557 | return SUCCESS; |
558 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Seconds)); |
558 | } |
559 | } |
559 | |
560 | /* Set ALARM mask */ |
560 | /** |
561 | LL_RTC_ALMA_SetMask(RTCx, RTC_AlarmStruct->AlarmMask); |
561 | * @brief Set the RTC Alarm B. |
562 | 562 | * @note The Alarm register can only be written when the corresponding Alarm |
|
563 | /* Enable the write protection for RTC registers */ |
563 | * is disabled (@ref LL_RTC_ALMB_Disable function). |
564 | LL_RTC_EnableWriteProtection(RTCx); |
564 | * @param RTCx RTC Instance |
565 | 565 | * @param RTC_Format This parameter can be one of the following values: |
|
566 | return SUCCESS; |
566 | * @arg @ref LL_RTC_FORMAT_BIN |
567 | } |
567 | * @arg @ref LL_RTC_FORMAT_BCD |
568 | 568 | * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure that |
|
569 | /** |
569 | * contains the alarm configuration parameters. |
570 | * @brief Set the RTC Alarm B. |
570 | * @retval An ErrorStatus enumeration value: |
571 | * @note The Alarm register can only be written when the corresponding Alarm |
571 | * - SUCCESS: ALARMB registers are configured |
572 | * is disabled (@ref LL_RTC_ALMB_Disable function). |
572 | * - ERROR: ALARMB registers are not configured |
573 | * @param RTCx RTC Instance |
573 | */ |
574 | * @param RTC_Format This parameter can be one of the following values: |
574 | ErrorStatus LL_RTC_ALMB_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct) |
575 | * @arg @ref LL_RTC_FORMAT_BIN |
575 | { |
576 | * @arg @ref LL_RTC_FORMAT_BCD |
576 | /* Check the parameters */ |
577 | * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure that |
577 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
578 | * contains the alarm configuration parameters. |
578 | assert_param(IS_LL_RTC_FORMAT(RTC_Format)); |
579 | * @retval An ErrorStatus enumeration value: |
579 | assert_param(IS_LL_RTC_ALMB_MASK(RTC_AlarmStruct->AlarmMask)); |
580 | * - SUCCESS: ALARMB registers are configured |
580 | assert_param(IS_LL_RTC_ALMB_DATE_WEEKDAY_SEL(RTC_AlarmStruct->AlarmDateWeekDaySel)); |
581 | * - ERROR: ALARMB registers are not configured |
581 | |
582 | */ |
582 | if (RTC_Format == LL_RTC_FORMAT_BIN) |
583 | ErrorStatus LL_RTC_ALMB_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct) |
583 | { |
584 | { |
584 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
585 | /* Check the parameters */ |
585 | { |
586 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
586 | assert_param(IS_LL_RTC_HOUR12(RTC_AlarmStruct->AlarmTime.Hours)); |
587 | assert_param(IS_LL_RTC_FORMAT(RTC_Format)); |
587 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); |
588 | assert_param(IS_LL_RTC_ALMB_MASK(RTC_AlarmStruct->AlarmMask)); |
588 | } |
589 | assert_param(IS_LL_RTC_ALMB_DATE_WEEKDAY_SEL(RTC_AlarmStruct->AlarmDateWeekDaySel)); |
589 | else |
590 | 590 | { |
|
591 | if (RTC_Format == LL_RTC_FORMAT_BIN) |
591 | RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; |
592 | { |
592 | assert_param(IS_LL_RTC_HOUR24(RTC_AlarmStruct->AlarmTime.Hours)); |
593 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
593 | } |
594 | { |
594 | assert_param(IS_LL_RTC_MINUTES(RTC_AlarmStruct->AlarmTime.Minutes)); |
595 | assert_param(IS_LL_RTC_HOUR12(RTC_AlarmStruct->AlarmTime.Hours)); |
595 | assert_param(IS_LL_RTC_SECONDS(RTC_AlarmStruct->AlarmTime.Seconds)); |
596 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); |
596 | |
597 | } |
597 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) |
598 | else |
598 | { |
599 | { |
599 | assert_param(IS_LL_RTC_DAY(RTC_AlarmStruct->AlarmDateWeekDay)); |
600 | RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; |
600 | } |
601 | assert_param(IS_LL_RTC_HOUR24(RTC_AlarmStruct->AlarmTime.Hours)); |
601 | else |
602 | } |
602 | { |
603 | assert_param(IS_LL_RTC_MINUTES(RTC_AlarmStruct->AlarmTime.Minutes)); |
603 | assert_param(IS_LL_RTC_WEEKDAY(RTC_AlarmStruct->AlarmDateWeekDay)); |
604 | assert_param(IS_LL_RTC_SECONDS(RTC_AlarmStruct->AlarmTime.Seconds)); |
604 | } |
605 | 605 | } |
|
606 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) |
606 | else |
607 | { |
607 | { |
608 | assert_param(IS_LL_RTC_DAY(RTC_AlarmStruct->AlarmDateWeekDay)); |
608 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
609 | } |
609 | { |
610 | else |
610 | assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); |
611 | { |
611 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); |
612 | assert_param(IS_LL_RTC_WEEKDAY(RTC_AlarmStruct->AlarmDateWeekDay)); |
612 | } |
613 | } |
613 | else |
614 | } |
614 | { |
615 | else |
615 | RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; |
616 | { |
616 | assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); |
617 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
617 | } |
618 | { |
618 | |
619 | assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); |
619 | assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes))); |
620 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); |
620 | assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds))); |
621 | } |
621 | |
622 | else |
622 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) |
623 | { |
623 | { |
624 | RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; |
624 | assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); |
625 | assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); |
625 | } |
626 | } |
626 | else |
627 | 627 | { |
|
628 | assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes))); |
628 | assert_param(IS_LL_RTC_WEEKDAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); |
629 | assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds))); |
629 | } |
630 | 630 | } |
|
631 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) |
631 | |
632 | { |
632 | /* Disable the write protection for RTC registers */ |
633 | assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); |
633 | LL_RTC_DisableWriteProtection(RTCx); |
634 | } |
634 | |
635 | else |
635 | /* Select weekday selection */ |
636 | { |
636 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) |
637 | assert_param(IS_LL_RTC_WEEKDAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); |
637 | { |
638 | } |
638 | /* Set the date for ALARM */ |
639 | } |
639 | LL_RTC_ALMB_DisableWeekday(RTCx); |
640 | 640 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
|
641 | /* Disable the write protection for RTC registers */ |
641 | { |
642 | LL_RTC_DisableWriteProtection(RTCx); |
642 | LL_RTC_ALMB_SetDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); |
643 | 643 | } |
|
644 | /* Select weekday selection */ |
644 | else |
645 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) |
645 | { |
646 | { |
646 | LL_RTC_ALMB_SetDay(RTCx, __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmDateWeekDay)); |
647 | /* Set the date for ALARM */ |
647 | } |
648 | LL_RTC_ALMB_DisableWeekday(RTCx); |
648 | } |
649 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
649 | else |
650 | { |
650 | { |
651 | LL_RTC_ALMB_SetDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); |
651 | /* Set the week day for ALARM */ |
652 | } |
652 | LL_RTC_ALMB_EnableWeekday(RTCx); |
653 | else |
653 | LL_RTC_ALMB_SetWeekDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); |
654 | { |
654 | } |
655 | LL_RTC_ALMB_SetDay(RTCx, __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmDateWeekDay)); |
655 | |
656 | } |
656 | /* Configure the Alarm register */ |
657 | } |
657 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
658 | else |
658 | { |
659 | { |
659 | LL_RTC_ALMB_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, RTC_AlarmStruct->AlarmTime.Hours, |
660 | /* Set the week day for ALARM */ |
660 | RTC_AlarmStruct->AlarmTime.Minutes, RTC_AlarmStruct->AlarmTime.Seconds); |
661 | LL_RTC_ALMB_EnableWeekday(RTCx); |
661 | } |
662 | LL_RTC_ALMB_SetWeekDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); |
662 | else |
663 | } |
663 | { |
664 | 664 | LL_RTC_ALMB_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, |
|
665 | /* Configure the Alarm register */ |
665 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Hours), |
666 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
666 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Minutes), |
667 | { |
667 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Seconds)); |
668 | LL_RTC_ALMB_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, RTC_AlarmStruct->AlarmTime.Hours, |
668 | } |
669 | RTC_AlarmStruct->AlarmTime.Minutes, RTC_AlarmStruct->AlarmTime.Seconds); |
669 | /* Set ALARM mask */ |
670 | } |
670 | LL_RTC_ALMB_SetMask(RTCx, RTC_AlarmStruct->AlarmMask); |
671 | else |
671 | |
672 | { |
672 | /* Enable the write protection for RTC registers */ |
673 | LL_RTC_ALMB_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, |
673 | LL_RTC_EnableWriteProtection(RTCx); |
674 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Hours), |
674 | |
675 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Minutes), |
675 | return SUCCESS; |
676 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Seconds)); |
676 | } |
677 | } |
677 | |
678 | /* Set ALARM mask */ |
678 | /** |
679 | LL_RTC_ALMB_SetMask(RTCx, RTC_AlarmStruct->AlarmMask); |
679 | * @brief Set each @ref LL_RTC_AlarmTypeDef of ALARMA field to default value (Time = 00h:00mn:00sec / |
680 | 680 | * Day = 1st day of the month/Mask = all fields are masked). |
|
681 | /* Enable the write protection for RTC registers */ |
681 | * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure which will be initialized. |
682 | LL_RTC_EnableWriteProtection(RTCx); |
682 | * @retval None |
683 | 683 | */ |
|
684 | return SUCCESS; |
684 | void LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct) |
685 | } |
685 | { |
686 | 686 | /* Alarm Time Settings : Time = 00h:00mn:00sec */ |
|
687 | /** |
687 | RTC_AlarmStruct->AlarmTime.TimeFormat = LL_RTC_ALMA_TIME_FORMAT_AM; |
688 | * @brief Set each @ref LL_RTC_AlarmTypeDef of ALARMA field to default value (Time = 00h:00mn:00sec / |
688 | RTC_AlarmStruct->AlarmTime.Hours = 0U; |
689 | * Day = 1st day of the month/Mask = all fields are masked). |
689 | RTC_AlarmStruct->AlarmTime.Minutes = 0U; |
690 | * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure which will be initialized. |
690 | RTC_AlarmStruct->AlarmTime.Seconds = 0U; |
691 | * @retval None |
691 | |
692 | */ |
692 | /* Alarm Day Settings : Day = 1st day of the month */ |
693 | void LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct) |
693 | RTC_AlarmStruct->AlarmDateWeekDaySel = LL_RTC_ALMA_DATEWEEKDAYSEL_DATE; |
694 | { |
694 | RTC_AlarmStruct->AlarmDateWeekDay = 1U; |
695 | /* Alarm Time Settings : Time = 00h:00mn:00sec */ |
695 | |
696 | RTC_AlarmStruct->AlarmTime.TimeFormat = LL_RTC_ALMA_TIME_FORMAT_AM; |
696 | /* Alarm Masks Settings : Mask = all fields are not masked */ |
697 | RTC_AlarmStruct->AlarmTime.Hours = 0U; |
697 | RTC_AlarmStruct->AlarmMask = LL_RTC_ALMA_MASK_NONE; |
698 | RTC_AlarmStruct->AlarmTime.Minutes = 0U; |
698 | } |
699 | RTC_AlarmStruct->AlarmTime.Seconds = 0U; |
699 | |
700 | 700 | /** |
|
701 | /* Alarm Day Settings : Day = 1st day of the month */ |
701 | * @brief Set each @ref LL_RTC_AlarmTypeDef of ALARMA field to default value (Time = 00h:00mn:00sec / |
702 | RTC_AlarmStruct->AlarmDateWeekDaySel = LL_RTC_ALMA_DATEWEEKDAYSEL_DATE; |
702 | * Day = 1st day of the month/Mask = all fields are masked). |
703 | RTC_AlarmStruct->AlarmDateWeekDay = 1U; |
703 | * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure which will be initialized. |
704 | 704 | * @retval None |
|
705 | /* Alarm Masks Settings : Mask = all fields are not masked */ |
705 | */ |
706 | RTC_AlarmStruct->AlarmMask = LL_RTC_ALMA_MASK_NONE; |
706 | void LL_RTC_ALMB_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct) |
707 | } |
707 | { |
708 | 708 | /* Alarm Time Settings : Time = 00h:00mn:00sec */ |
|
709 | /** |
709 | RTC_AlarmStruct->AlarmTime.TimeFormat = LL_RTC_ALMB_TIME_FORMAT_AM; |
710 | * @brief Set each @ref LL_RTC_AlarmTypeDef of ALARMA field to default value (Time = 00h:00mn:00sec / |
710 | RTC_AlarmStruct->AlarmTime.Hours = 0U; |
711 | * Day = 1st day of the month/Mask = all fields are masked). |
711 | RTC_AlarmStruct->AlarmTime.Minutes = 0U; |
712 | * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure which will be initialized. |
712 | RTC_AlarmStruct->AlarmTime.Seconds = 0U; |
713 | * @retval None |
713 | |
714 | */ |
714 | /* Alarm Day Settings : Day = 1st day of the month */ |
715 | void LL_RTC_ALMB_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct) |
715 | RTC_AlarmStruct->AlarmDateWeekDaySel = LL_RTC_ALMB_DATEWEEKDAYSEL_DATE; |
716 | { |
716 | RTC_AlarmStruct->AlarmDateWeekDay = 1U; |
717 | /* Alarm Time Settings : Time = 00h:00mn:00sec */ |
717 | |
718 | RTC_AlarmStruct->AlarmTime.TimeFormat = LL_RTC_ALMB_TIME_FORMAT_AM; |
718 | /* Alarm Masks Settings : Mask = all fields are not masked */ |
719 | RTC_AlarmStruct->AlarmTime.Hours = 0U; |
719 | RTC_AlarmStruct->AlarmMask = LL_RTC_ALMB_MASK_NONE; |
720 | RTC_AlarmStruct->AlarmTime.Minutes = 0U; |
720 | } |
721 | RTC_AlarmStruct->AlarmTime.Seconds = 0U; |
721 | |
722 | 722 | /** |
|
723 | /* Alarm Day Settings : Day = 1st day of the month */ |
723 | * @brief Enters the RTC Initialization mode. |
724 | RTC_AlarmStruct->AlarmDateWeekDaySel = LL_RTC_ALMB_DATEWEEKDAYSEL_DATE; |
724 | * @note The RTC Initialization mode is write protected, use the |
725 | RTC_AlarmStruct->AlarmDateWeekDay = 1U; |
725 | * @ref LL_RTC_DisableWriteProtection before calling this function. |
726 | 726 | * @param RTCx RTC Instance |
|
727 | /* Alarm Masks Settings : Mask = all fields are not masked */ |
727 | * @retval An ErrorStatus enumeration value: |
728 | RTC_AlarmStruct->AlarmMask = LL_RTC_ALMB_MASK_NONE; |
728 | * - SUCCESS: RTC is in Init mode |
729 | } |
729 | * - ERROR: RTC is not in Init mode |
730 | 730 | */ |
|
731 | /** |
731 | ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx) |
732 | * @brief Enters the RTC Initialization mode. |
732 | { |
733 | * @note The RTC Initialization mode is write protected, use the |
733 | __IO uint32_t timeout = RTC_INITMODE_TIMEOUT; |
734 | * @ref LL_RTC_DisableWriteProtection before calling this function. |
734 | ErrorStatus status = SUCCESS; |
735 | * @param RTCx RTC Instance |
735 | uint32_t tmp = 0U; |
736 | * @retval An ErrorStatus enumeration value: |
736 | |
737 | * - SUCCESS: RTC is in Init mode |
737 | /* Check the parameter */ |
738 | * - ERROR: RTC is not in Init mode |
738 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
739 | */ |
739 | |
740 | ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx) |
740 | /* Check if the Initialization mode is set */ |
741 | { |
741 | if (LL_RTC_IsActiveFlag_INIT(RTCx) == 0U) |
742 | __IO uint32_t timeout = RTC_INITMODE_TIMEOUT; |
742 | { |
743 | ErrorStatus status = SUCCESS; |
743 | /* Set the Initialization mode */ |
744 | uint32_t tmp; |
744 | LL_RTC_EnableInitMode(RTCx); |
745 | 745 | ||
746 | /* Check the parameter */ |
746 | /* Wait till RTC is in INIT state and if Time out is reached exit */ |
747 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
747 | tmp = LL_RTC_IsActiveFlag_INIT(RTCx); |
748 | 748 | while ((timeout != 0U) && (tmp != 1U)) |
|
749 | /* Check if the Initialization mode is set */ |
749 | { |
750 | if (LL_RTC_IsActiveFlag_INIT(RTCx) == 0U) |
750 | if (LL_SYSTICK_IsActiveCounterFlag() == 1U) |
751 | { |
751 | { |
752 | /* Set the Initialization mode */ |
752 | timeout --; |
753 | LL_RTC_EnableInitMode(RTCx); |
753 | } |
754 | 754 | tmp = LL_RTC_IsActiveFlag_INIT(RTCx); |
|
755 | /* Wait till RTC is in INIT state and if Time out is reached exit */ |
755 | if (timeout == 0U) |
756 | tmp = LL_RTC_IsActiveFlag_INIT(RTCx); |
756 | { |
757 | while ((timeout != 0U) && (tmp != 1U)) |
757 | status = ERROR; |
758 | { |
758 | } |
759 | if (LL_SYSTICK_IsActiveCounterFlag() == 1U) |
759 | } |
760 | { |
760 | } |
761 | timeout --; |
761 | return status; |
762 | } |
762 | } |
763 | tmp = LL_RTC_IsActiveFlag_INIT(RTCx); |
763 | |
764 | if (timeout == 0U) |
764 | /** |
765 | { |
765 | * @brief Exit the RTC Initialization mode. |
766 | status = ERROR; |
766 | * @note When the initialization sequence is complete, the calendar restarts |
767 | } |
767 | * counting after 4 RTCCLK cycles. |
768 | } |
768 | * @note The RTC Initialization mode is write protected, use the |
769 | } |
769 | * @ref LL_RTC_DisableWriteProtection before calling this function. |
770 | return status; |
770 | * @param RTCx RTC Instance |
771 | } |
771 | * @retval An ErrorStatus enumeration value: |
772 | 772 | * - SUCCESS: RTC exited from in Init mode |
|
773 | /** |
773 | * - ERROR: Not applicable |
774 | * @brief Exit the RTC Initialization mode. |
774 | */ |
775 | * @note When the initialization sequence is complete, the calendar restarts |
775 | ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx) |
776 | * counting after 4 RTCCLK cycles. |
776 | { |
777 | * @note The RTC Initialization mode is write protected, use the |
777 | /* Check the parameter */ |
778 | * @ref LL_RTC_DisableWriteProtection before calling this function. |
778 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
779 | * @param RTCx RTC Instance |
779 | |
780 | * @retval An ErrorStatus enumeration value: |
780 | /* Disable initialization mode */ |
781 | * - SUCCESS: RTC exited from in Init mode |
781 | LL_RTC_DisableInitMode(RTCx); |
782 | * - ERROR: Not applicable |
782 | |
783 | */ |
783 | return SUCCESS; |
784 | ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx) |
784 | } |
785 | { |
785 | |
786 | /* Check the parameter */ |
786 | /** |
787 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
787 | * @brief Waits until the RTC Time and Day registers (RTC_TR and RTC_DR) are |
788 | 788 | * synchronized with RTC APB clock. |
|
789 | /* Disable initialization mode */ |
789 | * @note The RTC Resynchronization mode is write protected, use the |
790 | LL_RTC_DisableInitMode(RTCx); |
790 | * @ref LL_RTC_DisableWriteProtection before calling this function. |
791 | 791 | * @note To read the calendar through the shadow registers after calendar |
|
792 | return SUCCESS; |
792 | * initialization, calendar update or after wakeup from low power modes |
793 | } |
793 | * the software must first clear the RSF flag. |
794 | 794 | * The software must then wait until it is set again before reading |
|
795 | /** |
795 | * the calendar, which means that the calendar registers have been |
796 | * @brief Waits until the RTC Time and Day registers (RTC_TR and RTC_DR) are |
796 | * correctly copied into the RTC_TR and RTC_DR shadow registers. |
797 | * synchronized with RTC APB clock. |
797 | * @param RTCx RTC Instance |
798 | * @note The RTC Resynchronization mode is write protected, use the |
798 | * @retval An ErrorStatus enumeration value: |
799 | * @ref LL_RTC_DisableWriteProtection before calling this function. |
799 | * - SUCCESS: RTC registers are synchronised |
800 | * @note To read the calendar through the shadow registers after Calendar |
800 | * - ERROR: RTC registers are not synchronised |
801 | * initialization, calendar update or after wakeup from low power modes |
801 | */ |
802 | * the software must first clear the RSF flag. |
802 | ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx) |
803 | * The software must then wait until it is set again before reading |
803 | { |
804 | * the calendar, which means that the calendar registers have been |
804 | __IO uint32_t timeout = RTC_SYNCHRO_TIMEOUT; |
805 | * correctly copied into the RTC_TR and RTC_DR shadow registers. |
805 | ErrorStatus status = SUCCESS; |
806 | * @param RTCx RTC Instance |
806 | uint32_t tmp = 0U; |
807 | * @retval An ErrorStatus enumeration value: |
807 | |
808 | * - SUCCESS: RTC registers are synchronised |
808 | /* Check the parameter */ |
809 | * - ERROR: RTC registers are not synchronised |
809 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
810 | */ |
810 | |
811 | ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx) |
811 | /* Clear RSF flag */ |
812 | { |
812 | LL_RTC_ClearFlag_RS(RTCx); |
813 | __IO uint32_t timeout = RTC_SYNCHRO_TIMEOUT; |
813 | |
814 | ErrorStatus status = SUCCESS; |
814 | /* Wait the registers to be synchronised */ |
815 | uint32_t tmp; |
815 | tmp = LL_RTC_IsActiveFlag_RS(RTCx); |
816 | 816 | while ((timeout != 0U) && (tmp != 1U)) |
|
817 | /* Check the parameter */ |
817 | { |
818 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
818 | if (LL_SYSTICK_IsActiveCounterFlag() == 1U) |
819 | 819 | { |
|
820 | /* Clear RSF flag */ |
820 | timeout--; |
821 | LL_RTC_ClearFlag_RS(RTCx); |
821 | } |
822 | 822 | tmp = LL_RTC_IsActiveFlag_RS(RTCx); |
|
823 | /* Wait the registers to be synchronised */ |
823 | if (timeout == 0U) |
824 | tmp = LL_RTC_IsActiveFlag_RS(RTCx); |
824 | { |
825 | while ((timeout != 0U) && (tmp != 1U)) |
825 | status = ERROR; |
826 | { |
826 | } |
827 | if (LL_SYSTICK_IsActiveCounterFlag() == 1U) |
827 | } |
828 | { |
828 | |
829 | timeout--; |
829 | return (status); |
830 | } |
830 | } |
831 | tmp = LL_RTC_IsActiveFlag_RS(RTCx); |
831 | |
832 | if (timeout == 0U) |
832 | /** |
833 | { |
833 | * @} |
834 | status = ERROR; |
834 | */ |
835 | } |
835 | |
836 | } |
836 | /** |
837 | 837 | * @} |
|
838 | return (status); |
838 | */ |
839 | } |
839 | |
840 | 840 | /** |
|
841 | /** |
841 | * @} |
842 | * @} |
842 | */ |
843 | */ |
843 | |
844 | 844 | #endif /* defined(RTC) */ |
|
845 | /** |
845 | |
846 | * @} |
846 | /** |
847 | */ |
847 | * @} |
848 | 848 | */ |
|
849 | /** |
849 | |
850 | * @} |
850 | #endif /* USE_FULL_LL_DRIVER */ |
851 | */ |
- | |
852 | - | ||
853 | #endif /* defined(RTC) */ |
- | |
854 | - | ||
855 | /** |
- | |
856 | * @} |
- | |
857 | */ |
- | |
858 | - | ||
859 | #endif /* USE_FULL_LL_DRIVER */ |
- | |
860 | - | ||
861 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
- |