Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | /** |
2 | ****************************************************************************** |
||
3 | * @file stm32f1xx_hal_rtc_ex.c |
||
4 | * @author MCD Application Team |
||
5 | * @brief Extended RTC HAL module driver. |
||
6 | * This file provides firmware functions to manage the following |
||
7 | * functionalities of the Real Time Clock (RTC) Extension peripheral: |
||
8 | * + RTC Tamper functions |
||
9 | * + Extension Control functions |
||
10 | * + Extension RTC features functions |
||
11 | * |
||
12 | ****************************************************************************** |
||
13 | * @attention |
||
14 | * |
||
15 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
||
16 | * |
||
17 | * Redistribution and use in source and binary forms, with or without modification, |
||
18 | * are permitted provided that the following conditions are met: |
||
19 | * 1. Redistributions of source code must retain the above copyright notice, |
||
20 | * this list of conditions and the following disclaimer. |
||
21 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
||
22 | * this list of conditions and the following disclaimer in the documentation |
||
23 | * and/or other materials provided with the distribution. |
||
24 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
||
25 | * may be used to endorse or promote products derived from this software |
||
26 | * without specific prior written permission. |
||
27 | * |
||
28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||
31 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||
32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||
33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||
34 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||
35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||
36 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||
37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
38 | * |
||
39 | ****************************************************************************** |
||
40 | */ |
||
41 | |||
42 | /* Includes ------------------------------------------------------------------*/ |
||
43 | #include "stm32f1xx_hal.h" |
||
44 | |||
45 | /** @addtogroup STM32F1xx_HAL_Driver |
||
46 | * @{ |
||
47 | */ |
||
48 | |||
49 | #ifdef HAL_RTC_MODULE_ENABLED |
||
50 | |||
51 | /** @defgroup RTCEx RTCEx |
||
52 | * @brief RTC Extended HAL module driver |
||
53 | * @{ |
||
54 | */ |
||
55 | |||
56 | /* Private typedef -----------------------------------------------------------*/ |
||
57 | /* Private define ------------------------------------------------------------*/ |
||
58 | /* Private macro -------------------------------------------------------------*/ |
||
59 | /** @defgroup RTCEx_Private_Macros RTCEx Private Macros |
||
60 | * @{ |
||
61 | */ |
||
62 | /** |
||
63 | * @} |
||
64 | */ |
||
65 | |||
66 | /* Private variables ---------------------------------------------------------*/ |
||
67 | /* Private function prototypes -----------------------------------------------*/ |
||
68 | /* Private functions ---------------------------------------------------------*/ |
||
69 | |||
70 | /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions |
||
71 | * @{ |
||
72 | */ |
||
73 | |||
74 | /** @defgroup RTCEx_Exported_Functions_Group1 RTC Tamper functions |
||
75 | * @brief RTC Tamper functions |
||
76 | * |
||
77 | @verbatim |
||
78 | =============================================================================== |
||
79 | ##### RTC Tamper functions ##### |
||
80 | =============================================================================== |
||
81 | |||
82 | [..] This section provides functions allowing to configure Tamper feature |
||
83 | |||
84 | @endverbatim |
||
85 | * @{ |
||
86 | */ |
||
87 | |||
88 | /** |
||
89 | * @brief Sets Tamper |
||
90 | * @note By calling this API we disable the tamper interrupt for all tampers. |
||
91 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
92 | * the configuration information for RTC. |
||
93 | * @param sTamper: Pointer to Tamper Structure. |
||
94 | * @note Tamper can be enabled only if ASOE and CCO bit are reset |
||
95 | * @retval HAL status |
||
96 | */ |
||
97 | HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper) |
||
98 | { |
||
99 | /* Check input parameters */ |
||
100 | if((hrtc == NULL) || (sTamper == NULL)) |
||
101 | { |
||
102 | return HAL_ERROR; |
||
103 | } |
||
104 | |||
105 | /* Check the parameters */ |
||
106 | assert_param(IS_RTC_TAMPER(sTamper->Tamper)); |
||
107 | assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger)); |
||
108 | |||
109 | /* Process Locked */ |
||
110 | __HAL_LOCK(hrtc); |
||
111 | |||
112 | hrtc->State = HAL_RTC_STATE_BUSY; |
||
113 | |||
114 | if (HAL_IS_BIT_SET(BKP->RTCCR,(BKP_RTCCR_CCO | BKP_RTCCR_ASOE))) |
||
115 | { |
||
116 | hrtc->State = HAL_RTC_STATE_ERROR; |
||
117 | |||
118 | /* Process Unlocked */ |
||
119 | __HAL_UNLOCK(hrtc); |
||
120 | |||
121 | return HAL_ERROR; |
||
122 | } |
||
123 | |||
124 | MODIFY_REG(BKP->CR, (BKP_CR_TPE | BKP_CR_TPAL), (sTamper->Tamper | (sTamper->Trigger))); |
||
125 | |||
126 | hrtc->State = HAL_RTC_STATE_READY; |
||
127 | |||
128 | /* Process Unlocked */ |
||
129 | __HAL_UNLOCK(hrtc); |
||
130 | |||
131 | return HAL_OK; |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * @brief Sets Tamper with interrupt. |
||
136 | * @note By calling this API we force the tamper interrupt for all tampers. |
||
137 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
138 | * the configuration information for RTC. |
||
139 | * @param sTamper: Pointer to RTC Tamper. |
||
140 | * @note Tamper can be enabled only if ASOE and CCO bit are reset |
||
141 | * @retval HAL status |
||
142 | */ |
||
143 | HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper) |
||
144 | { |
||
145 | /* Check input parameters */ |
||
146 | if((hrtc == NULL) || (sTamper == NULL)) |
||
147 | { |
||
148 | return HAL_ERROR; |
||
149 | } |
||
150 | |||
151 | /* Check the parameters */ |
||
152 | assert_param(IS_RTC_TAMPER(sTamper->Tamper)); |
||
153 | assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger)); |
||
154 | |||
155 | /* Process Locked */ |
||
156 | __HAL_LOCK(hrtc); |
||
157 | |||
158 | hrtc->State = HAL_RTC_STATE_BUSY; |
||
159 | |||
160 | if (HAL_IS_BIT_SET(BKP->RTCCR,(BKP_RTCCR_CCO | BKP_RTCCR_ASOE))) |
||
161 | { |
||
162 | hrtc->State = HAL_RTC_STATE_ERROR; |
||
163 | |||
164 | /* Process Unlocked */ |
||
165 | __HAL_UNLOCK(hrtc); |
||
166 | |||
167 | return HAL_ERROR; |
||
168 | } |
||
169 | |||
170 | MODIFY_REG(BKP->CR, (BKP_CR_TPE | BKP_CR_TPAL), (sTamper->Tamper | (sTamper->Trigger))); |
||
171 | |||
172 | /* Configure the Tamper Interrupt in the BKP->CSR */ |
||
173 | __HAL_RTC_TAMPER_ENABLE_IT(hrtc, RTC_IT_TAMP1); |
||
174 | |||
175 | hrtc->State = HAL_RTC_STATE_READY; |
||
176 | |||
177 | /* Process Unlocked */ |
||
178 | __HAL_UNLOCK(hrtc); |
||
179 | |||
180 | return HAL_OK; |
||
181 | } |
||
182 | |||
183 | /** |
||
184 | * @brief Deactivates Tamper. |
||
185 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
186 | * the configuration information for RTC. |
||
187 | * @param Tamper: Selected tamper pin. |
||
188 | * This parameter can be a value of @ref RTCEx_Tamper_Pins_Definitions |
||
189 | * @retval HAL status |
||
190 | */ |
||
191 | HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper) |
||
192 | { |
||
193 | /* Check input parameters */ |
||
194 | if(hrtc == NULL) |
||
195 | { |
||
196 | return HAL_ERROR; |
||
197 | } |
||
198 | /* Prevent unused argument(s) compilation warning */ |
||
199 | UNUSED(Tamper); |
||
200 | |||
201 | assert_param(IS_RTC_TAMPER(Tamper)); |
||
202 | |||
203 | /* Process Locked */ |
||
204 | __HAL_LOCK(hrtc); |
||
205 | |||
206 | hrtc->State = HAL_RTC_STATE_BUSY; |
||
207 | |||
208 | /* Disable the selected Tamper pin */ |
||
209 | CLEAR_BIT(BKP->CR, BKP_CR_TPE); |
||
210 | |||
211 | /* Disable the Tamper Interrupt in the BKP->CSR */ |
||
212 | /* Configure the Tamper Interrupt in the BKP->CSR */ |
||
213 | __HAL_RTC_TAMPER_DISABLE_IT(hrtc, RTC_IT_TAMP1); |
||
214 | |||
215 | /* Clear the Tamper interrupt pending bit */ |
||
216 | __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP1F); |
||
217 | SET_BIT(BKP->CSR, BKP_CSR_CTE); |
||
218 | |||
219 | hrtc->State = HAL_RTC_STATE_READY; |
||
220 | |||
221 | /* Process Unlocked */ |
||
222 | __HAL_UNLOCK(hrtc); |
||
223 | |||
224 | return HAL_OK; |
||
225 | } |
||
226 | |||
227 | /** |
||
228 | * @brief This function handles Tamper interrupt request. |
||
229 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
230 | * the configuration information for RTC. |
||
231 | * @retval None |
||
232 | */ |
||
233 | void HAL_RTCEx_TamperIRQHandler(RTC_HandleTypeDef *hrtc) |
||
234 | { |
||
235 | /* Get the status of the Interrupt */ |
||
236 | if(__HAL_RTC_TAMPER_GET_IT_SOURCE(hrtc, RTC_IT_TAMP1)) |
||
237 | { |
||
238 | /* Get the TAMPER Interrupt enable bit and pending bit */ |
||
239 | if(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP1F) != (uint32_t)RESET) |
||
240 | { |
||
241 | /* Tamper callback */ |
||
242 | HAL_RTCEx_Tamper1EventCallback(hrtc); |
||
243 | |||
244 | /* Clear the Tamper interrupt pending bit */ |
||
245 | __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc,RTC_FLAG_TAMP1F); |
||
246 | } |
||
247 | } |
||
248 | |||
249 | /* Change RTC state */ |
||
250 | hrtc->State = HAL_RTC_STATE_READY; |
||
251 | } |
||
252 | |||
253 | /** |
||
254 | * @brief Tamper 1 callback. |
||
255 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
256 | * the configuration information for RTC. |
||
257 | * @retval None |
||
258 | */ |
||
259 | __weak void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc) |
||
260 | { |
||
261 | /* Prevent unused argument(s) compilation warning */ |
||
262 | UNUSED(hrtc); |
||
263 | /* NOTE : This function Should not be modified, when the callback is needed, |
||
264 | the HAL_RTCEx_Tamper1EventCallback could be implemented in the user file |
||
265 | */ |
||
266 | } |
||
267 | |||
268 | /** |
||
269 | * @brief This function handles Tamper1 Polling. |
||
270 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
271 | * the configuration information for RTC. |
||
272 | * @param Timeout: Timeout duration |
||
273 | * @retval HAL status |
||
274 | */ |
||
275 | HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout) |
||
276 | { |
||
277 | uint32_t tickstart = HAL_GetTick(); |
||
278 | |||
279 | /* Check input parameters */ |
||
280 | if(hrtc == NULL) |
||
281 | { |
||
282 | return HAL_ERROR; |
||
283 | } |
||
284 | |||
285 | /* Get the status of the Interrupt */ |
||
286 | while(__HAL_RTC_TAMPER_GET_FLAG(hrtc,RTC_FLAG_TAMP1F)== RESET) |
||
287 | { |
||
288 | if(Timeout != HAL_MAX_DELAY) |
||
289 | { |
||
290 | if((Timeout == 0U)||((HAL_GetTick() - tickstart ) > Timeout)) |
||
291 | { |
||
292 | hrtc->State = HAL_RTC_STATE_TIMEOUT; |
||
293 | return HAL_TIMEOUT; |
||
294 | } |
||
295 | } |
||
296 | } |
||
297 | |||
298 | /* Clear the Tamper Flag */ |
||
299 | __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc,RTC_FLAG_TAMP1F); |
||
300 | |||
301 | /* Change RTC state */ |
||
302 | hrtc->State = HAL_RTC_STATE_READY; |
||
303 | |||
304 | return HAL_OK; |
||
305 | } |
||
306 | |||
307 | /** |
||
308 | * @} |
||
309 | */ |
||
310 | |||
311 | /** @defgroup RTCEx_Exported_Functions_Group2 RTC Second functions |
||
312 | * @brief RTC Second functions |
||
313 | * |
||
314 | @verbatim |
||
315 | =============================================================================== |
||
316 | ##### RTC Second functions ##### |
||
317 | =============================================================================== |
||
318 | |||
319 | [..] This section provides functions implementing second interupt handlers |
||
320 | |||
321 | @endverbatim |
||
322 | * @{ |
||
323 | */ |
||
324 | |||
325 | /** |
||
326 | * @brief Sets Interrupt for second |
||
327 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
328 | * the configuration information for RTC. |
||
329 | * @retval HAL status |
||
330 | */ |
||
331 | HAL_StatusTypeDef HAL_RTCEx_SetSecond_IT(RTC_HandleTypeDef *hrtc) |
||
332 | { |
||
333 | /* Check input parameters */ |
||
334 | if(hrtc == NULL) |
||
335 | { |
||
336 | return HAL_ERROR; |
||
337 | } |
||
338 | |||
339 | /* Process Locked */ |
||
340 | __HAL_LOCK(hrtc); |
||
341 | |||
342 | hrtc->State = HAL_RTC_STATE_BUSY; |
||
343 | |||
344 | /* Enable Second interuption */ |
||
345 | __HAL_RTC_SECOND_ENABLE_IT(hrtc, RTC_IT_SEC); |
||
346 | |||
347 | hrtc->State = HAL_RTC_STATE_READY; |
||
348 | |||
349 | /* Process Unlocked */ |
||
350 | __HAL_UNLOCK(hrtc); |
||
351 | |||
352 | return HAL_OK; |
||
353 | } |
||
354 | |||
355 | /** |
||
356 | * @brief Deactivates Second. |
||
357 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
358 | * the configuration information for RTC. |
||
359 | * @retval HAL status |
||
360 | */ |
||
361 | HAL_StatusTypeDef HAL_RTCEx_DeactivateSecond(RTC_HandleTypeDef *hrtc) |
||
362 | { |
||
363 | /* Check input parameters */ |
||
364 | if(hrtc == NULL) |
||
365 | { |
||
366 | return HAL_ERROR; |
||
367 | } |
||
368 | |||
369 | /* Process Locked */ |
||
370 | __HAL_LOCK(hrtc); |
||
371 | |||
372 | hrtc->State = HAL_RTC_STATE_BUSY; |
||
373 | |||
374 | /* Deactivate Second interuption*/ |
||
375 | __HAL_RTC_SECOND_DISABLE_IT(hrtc, RTC_IT_SEC); |
||
376 | |||
377 | hrtc->State = HAL_RTC_STATE_READY; |
||
378 | |||
379 | /* Process Unlocked */ |
||
380 | __HAL_UNLOCK(hrtc); |
||
381 | |||
382 | return HAL_OK; |
||
383 | } |
||
384 | |||
385 | /** |
||
386 | * @brief This function handles second interrupt request. |
||
387 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
388 | * the configuration information for RTC. |
||
389 | * @retval None |
||
390 | */ |
||
391 | void HAL_RTCEx_RTCIRQHandler(RTC_HandleTypeDef* hrtc) |
||
392 | { |
||
393 | if(__HAL_RTC_SECOND_GET_IT_SOURCE(hrtc, RTC_IT_SEC)) |
||
394 | { |
||
395 | /* Get the status of the Interrupt */ |
||
396 | if(__HAL_RTC_SECOND_GET_FLAG(hrtc, RTC_FLAG_SEC)) |
||
397 | { |
||
398 | /* Check if Overrun occurred */ |
||
399 | if (__HAL_RTC_SECOND_GET_FLAG(hrtc, RTC_FLAG_OW)) |
||
400 | { |
||
401 | /* Second error callback */ |
||
402 | HAL_RTCEx_RTCEventErrorCallback(hrtc); |
||
403 | |||
404 | /* Clear flag Second */ |
||
405 | __HAL_RTC_OVERFLOW_CLEAR_FLAG(hrtc, RTC_FLAG_OW); |
||
406 | |||
407 | /* Change RTC state */ |
||
408 | hrtc->State = HAL_RTC_STATE_ERROR; |
||
409 | } |
||
410 | else |
||
411 | { |
||
412 | /* Second callback */ |
||
413 | HAL_RTCEx_RTCEventCallback(hrtc); |
||
414 | |||
415 | /* Change RTC state */ |
||
416 | hrtc->State = HAL_RTC_STATE_READY; |
||
417 | } |
||
418 | |||
419 | /* Clear flag Second */ |
||
420 | __HAL_RTC_SECOND_CLEAR_FLAG(hrtc, RTC_FLAG_SEC); |
||
421 | } |
||
422 | } |
||
423 | } |
||
424 | |||
425 | /** |
||
426 | * @brief Second event callback. |
||
427 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
428 | * the configuration information for RTC. |
||
429 | * @retval None |
||
430 | */ |
||
431 | __weak void HAL_RTCEx_RTCEventCallback(RTC_HandleTypeDef *hrtc) |
||
432 | { |
||
433 | /* Prevent unused argument(s) compilation warning */ |
||
434 | UNUSED(hrtc); |
||
435 | /* NOTE : This function Should not be modified, when the callback is needed, |
||
436 | the HAL_RTCEx_RTCEventCallback could be implemented in the user file |
||
437 | */ |
||
438 | } |
||
439 | |||
440 | /** |
||
441 | * @brief Second event error callback. |
||
442 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
443 | * the configuration information for RTC. |
||
444 | * @retval None |
||
445 | */ |
||
446 | __weak void HAL_RTCEx_RTCEventErrorCallback(RTC_HandleTypeDef *hrtc) |
||
447 | { |
||
448 | /* Prevent unused argument(s) compilation warning */ |
||
449 | UNUSED(hrtc); |
||
450 | /* NOTE : This function Should not be modified, when the callback is needed, |
||
451 | the HAL_RTCEx_RTCEventErrorCallback could be implemented in the user file |
||
452 | */ |
||
453 | } |
||
454 | |||
455 | /** |
||
456 | * @} |
||
457 | */ |
||
458 | |||
459 | /** @defgroup RTCEx_Exported_Functions_Group3 Extended Peripheral Control functions |
||
460 | * @brief Extended Peripheral Control functions |
||
461 | * |
||
462 | @verbatim |
||
463 | =============================================================================== |
||
464 | ##### Extension Peripheral Control functions ##### |
||
465 | =============================================================================== |
||
466 | [..] |
||
467 | This subsection provides functions allowing to |
||
468 | (+) Writes a data in a specified RTC Backup data register |
||
469 | (+) Read a data in a specified RTC Backup data register |
||
470 | (+) Sets the Smooth calibration parameters. |
||
471 | |||
472 | @endverbatim |
||
473 | * @{ |
||
474 | */ |
||
475 | |||
476 | /** |
||
477 | * @brief Writes a data in a specified RTC Backup data register. |
||
478 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
479 | * the configuration information for RTC. |
||
480 | * @param BackupRegister: RTC Backup data Register number. |
||
481 | * This parameter can be: RTC_BKP_DRx where x can be from 1 to 10 (or 42) to |
||
482 | * specify the register (depending devices). |
||
483 | * @param Data: Data to be written in the specified RTC Backup data register. |
||
484 | * @retval None |
||
485 | */ |
||
486 | void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data) |
||
487 | { |
||
488 | uint32_t tmp = 0U; |
||
489 | |||
490 | /* Prevent unused argument(s) compilation warning */ |
||
491 | UNUSED(hrtc); |
||
492 | |||
493 | /* Check the parameters */ |
||
494 | assert_param(IS_RTC_BKP(BackupRegister)); |
||
495 | |||
496 | tmp = (uint32_t)BKP_BASE; |
||
497 | tmp += (BackupRegister * 4U); |
||
498 | |||
499 | *(__IO uint32_t *) tmp = (Data & BKP_DR1_D); |
||
500 | } |
||
501 | |||
502 | /** |
||
503 | * @brief Reads data from the specified RTC Backup data Register. |
||
504 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
505 | * the configuration information for RTC. |
||
506 | * @param BackupRegister: RTC Backup data Register number. |
||
507 | * This parameter can be: RTC_BKP_DRx where x can be from 1 to 10 (or 42) to |
||
508 | * specify the register (depending devices). |
||
509 | * @retval Read value |
||
510 | */ |
||
511 | uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister) |
||
512 | { |
||
513 | uint32_t backupregister = 0U; |
||
514 | uint32_t pvalue = 0U; |
||
515 | |||
516 | /* Prevent unused argument(s) compilation warning */ |
||
517 | UNUSED(hrtc); |
||
518 | |||
519 | /* Check the parameters */ |
||
520 | assert_param(IS_RTC_BKP(BackupRegister)); |
||
521 | |||
522 | backupregister = (uint32_t)BKP_BASE; |
||
523 | backupregister += (BackupRegister * 4U); |
||
524 | |||
525 | pvalue = (*(__IO uint32_t *)(backupregister)) & BKP_DR1_D; |
||
526 | |||
527 | /* Read the specified register */ |
||
528 | return pvalue; |
||
529 | } |
||
530 | |||
531 | |||
532 | /** |
||
533 | * @brief Sets the Smooth calibration parameters. |
||
534 | * @param hrtc: RTC handle |
||
535 | * @param SmoothCalibPeriod: Not used (only present for compatibility with another families) |
||
536 | * @param SmoothCalibPlusPulses: Not used (only present for compatibility with another families) |
||
537 | * @param SmouthCalibMinusPulsesValue: specifies the RTC Clock Calibration value. |
||
538 | * This parameter must be a number between 0 and 0x7F. |
||
539 | * @retval HAL status |
||
540 | */ |
||
541 | HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef* hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmouthCalibMinusPulsesValue) |
||
542 | { |
||
543 | /* Check input parameters */ |
||
544 | if(hrtc == NULL) |
||
545 | { |
||
546 | return HAL_ERROR; |
||
547 | } |
||
548 | /* Prevent unused argument(s) compilation warning */ |
||
549 | UNUSED(SmoothCalibPeriod); |
||
550 | UNUSED(SmoothCalibPlusPulses); |
||
551 | |||
552 | /* Check the parameters */ |
||
553 | assert_param(IS_RTC_SMOOTH_CALIB_MINUS(SmouthCalibMinusPulsesValue)); |
||
554 | |||
555 | /* Process Locked */ |
||
556 | __HAL_LOCK(hrtc); |
||
557 | |||
558 | hrtc->State = HAL_RTC_STATE_BUSY; |
||
559 | |||
560 | /* Sets RTC Clock Calibration value.*/ |
||
561 | MODIFY_REG(BKP->RTCCR, BKP_RTCCR_CAL, SmouthCalibMinusPulsesValue); |
||
562 | |||
563 | /* Change RTC state */ |
||
564 | hrtc->State = HAL_RTC_STATE_READY; |
||
565 | |||
566 | /* Process Unlocked */ |
||
567 | __HAL_UNLOCK(hrtc); |
||
568 | |||
569 | return HAL_OK; |
||
570 | } |
||
571 | |||
572 | /** |
||
573 | * @} |
||
574 | */ |
||
575 | |||
576 | /** |
||
577 | * @} |
||
578 | */ |
||
579 | |||
580 | /** |
||
581 | * @} |
||
582 | */ |
||
583 | |||
584 | #endif /* HAL_RTC_MODULE_ENABLED */ |
||
585 | |||
586 | /** |
||
587 | * @} |
||
588 | */ |
||
589 | |||
590 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
||
591 |