Rev 2 | Details | Compare with Previous | 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 | mjames | 5 | * @version V1.0.4 |
6 | * @date 29-April-2016 |
||
2 | mjames | 7 | * @brief Extended RTC HAL module driver. |
8 | * This file provides firmware functions to manage the following |
||
9 | * functionalities of the Real Time Clock (RTC) Extension peripheral: |
||
10 | * + RTC Tamper functions |
||
11 | * + Extension Control functions |
||
12 | * + Extension RTC features functions |
||
13 | * |
||
14 | ****************************************************************************** |
||
15 | * @attention |
||
16 | * |
||
5 | mjames | 17 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
2 | mjames | 18 | * |
19 | * Redistribution and use in source and binary forms, with or without modification, |
||
20 | * are permitted provided that the following conditions are met: |
||
21 | * 1. Redistributions of source code must retain the above copyright notice, |
||
22 | * this list of conditions and the following disclaimer. |
||
23 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
||
24 | * this list of conditions and the following disclaimer in the documentation |
||
25 | * and/or other materials provided with the distribution. |
||
26 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
||
27 | * may be used to endorse or promote products derived from this software |
||
28 | * without specific prior written permission. |
||
29 | * |
||
30 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
31 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
32 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||
33 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||
34 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||
35 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||
36 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||
37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||
38 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||
39 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
40 | * |
||
41 | ****************************************************************************** |
||
42 | */ |
||
43 | |||
44 | /* Includes ------------------------------------------------------------------*/ |
||
45 | #include "stm32f1xx_hal.h" |
||
46 | |||
47 | /** @addtogroup STM32F1xx_HAL_Driver |
||
48 | * @{ |
||
49 | */ |
||
50 | |||
51 | #ifdef HAL_RTC_MODULE_ENABLED |
||
52 | |||
53 | /** @defgroup RTCEx RTCEx |
||
54 | * @brief RTC Extended HAL module driver |
||
55 | * @{ |
||
56 | */ |
||
57 | |||
58 | /* Private typedef -----------------------------------------------------------*/ |
||
59 | /* Private define ------------------------------------------------------------*/ |
||
60 | /* Private macro -------------------------------------------------------------*/ |
||
61 | /** @defgroup RTCEx_Private_Macros RTCEx Private Macros |
||
62 | * @{ |
||
63 | */ |
||
64 | /** |
||
65 | * @} |
||
66 | */ |
||
67 | |||
68 | /* Private variables ---------------------------------------------------------*/ |
||
69 | /* Private function prototypes -----------------------------------------------*/ |
||
70 | /* Private functions ---------------------------------------------------------*/ |
||
71 | |||
72 | /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions |
||
73 | * @{ |
||
74 | */ |
||
75 | |||
76 | /** @defgroup RTCEx_Exported_Functions_Group1 RTC Tamper functions |
||
77 | * @brief RTC Tamper functions |
||
78 | * |
||
79 | @verbatim |
||
80 | =============================================================================== |
||
81 | ##### RTC Tamper functions ##### |
||
82 | =============================================================================== |
||
83 | |||
84 | [..] This section provides functions allowing to configure Tamper feature |
||
85 | |||
86 | @endverbatim |
||
87 | * @{ |
||
88 | */ |
||
89 | |||
90 | /** |
||
91 | * @brief Sets Tamper |
||
92 | * @note By calling this API we disable the tamper interrupt for all tampers. |
||
93 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
94 | * the configuration information for RTC. |
||
95 | * @param sTamper: Pointer to Tamper Structure. |
||
96 | * @note Tamper can be enabled only if ASOE and CCO bit are reset |
||
97 | * @retval HAL status |
||
98 | */ |
||
99 | HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper) |
||
100 | { |
||
101 | /* Check input parameters */ |
||
102 | if((hrtc == NULL) || (sTamper == NULL)) |
||
103 | { |
||
104 | return HAL_ERROR; |
||
105 | } |
||
106 | |||
107 | /* Check the parameters */ |
||
108 | assert_param(IS_RTC_TAMPER(sTamper->Tamper)); |
||
109 | assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger)); |
||
110 | |||
111 | /* Process Locked */ |
||
112 | __HAL_LOCK(hrtc); |
||
113 | |||
114 | hrtc->State = HAL_RTC_STATE_BUSY; |
||
115 | |||
116 | if (HAL_IS_BIT_SET(BKP->RTCCR,(BKP_RTCCR_CCO | BKP_RTCCR_ASOE))) |
||
117 | { |
||
118 | hrtc->State = HAL_RTC_STATE_ERROR; |
||
119 | |||
120 | /* Process Unlocked */ |
||
121 | __HAL_UNLOCK(hrtc); |
||
122 | |||
123 | return HAL_ERROR; |
||
124 | } |
||
125 | |||
126 | MODIFY_REG(BKP->CR, (BKP_CR_TPE | BKP_CR_TPAL), (sTamper->Tamper | (sTamper->Trigger))); |
||
127 | |||
128 | hrtc->State = HAL_RTC_STATE_READY; |
||
129 | |||
130 | /* Process Unlocked */ |
||
131 | __HAL_UNLOCK(hrtc); |
||
132 | |||
133 | return HAL_OK; |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * @brief Sets Tamper with interrupt. |
||
138 | * @note By calling this API we force the tamper interrupt for all tampers. |
||
139 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
140 | * the configuration information for RTC. |
||
141 | * @param sTamper: Pointer to RTC Tamper. |
||
142 | * @note Tamper can be enabled only if ASOE and CCO bit are reset |
||
143 | * @retval HAL status |
||
144 | */ |
||
145 | HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper) |
||
146 | { |
||
147 | /* Check input parameters */ |
||
148 | if((hrtc == NULL) || (sTamper == NULL)) |
||
149 | { |
||
150 | return HAL_ERROR; |
||
151 | } |
||
152 | |||
153 | /* Check the parameters */ |
||
154 | assert_param(IS_RTC_TAMPER(sTamper->Tamper)); |
||
155 | assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger)); |
||
156 | |||
157 | /* Process Locked */ |
||
158 | __HAL_LOCK(hrtc); |
||
159 | |||
160 | hrtc->State = HAL_RTC_STATE_BUSY; |
||
161 | |||
162 | if (HAL_IS_BIT_SET(BKP->RTCCR,(BKP_RTCCR_CCO | BKP_RTCCR_ASOE))) |
||
163 | { |
||
164 | hrtc->State = HAL_RTC_STATE_ERROR; |
||
165 | |||
166 | /* Process Unlocked */ |
||
167 | __HAL_UNLOCK(hrtc); |
||
168 | |||
169 | return HAL_ERROR; |
||
170 | } |
||
171 | |||
172 | MODIFY_REG(BKP->CR, (BKP_CR_TPE | BKP_CR_TPAL), (sTamper->Tamper | (sTamper->Trigger))); |
||
173 | |||
174 | /* Configure the Tamper Interrupt in the BKP->CSR */ |
||
175 | __HAL_RTC_TAMPER_ENABLE_IT(hrtc, RTC_IT_TAMP1); |
||
176 | |||
177 | hrtc->State = HAL_RTC_STATE_READY; |
||
178 | |||
179 | /* Process Unlocked */ |
||
180 | __HAL_UNLOCK(hrtc); |
||
181 | |||
182 | return HAL_OK; |
||
183 | } |
||
184 | |||
185 | /** |
||
186 | * @brief Deactivates Tamper. |
||
187 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
188 | * the configuration information for RTC. |
||
189 | * @param Tamper: Selected tamper pin. |
||
190 | * This parameter can be a value of @ref RTCEx_Tamper_Pins_Definitions |
||
191 | * @retval HAL status |
||
192 | */ |
||
193 | HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper) |
||
194 | { |
||
195 | /* Check input parameters */ |
||
196 | if(hrtc == NULL) |
||
197 | { |
||
198 | return HAL_ERROR; |
||
199 | } |
||
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 | { |
||
5 | mjames | 261 | /* Prevent unused argument(s) compilation warning */ |
262 | UNUSED(hrtc); |
||
2 | mjames | 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 == 0)||((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 | { |
||
5 | mjames | 433 | /* Prevent unused argument(s) compilation warning */ |
434 | UNUSED(hrtc); |
||
2 | mjames | 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 | { |
||
5 | mjames | 448 | /* Prevent unused argument(s) compilation warning */ |
449 | UNUSED(hrtc); |
||
2 | mjames | 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 = 0; |
||
489 | |||
490 | /* Check the parameters */ |
||
491 | assert_param(IS_RTC_BKP(BackupRegister)); |
||
492 | |||
493 | tmp = (uint32_t)BKP_BASE; |
||
494 | tmp += (BackupRegister * 4); |
||
495 | |||
496 | *(__IO uint32_t *) tmp = (Data & BKP_DR1_D); |
||
497 | } |
||
498 | |||
499 | /** |
||
500 | * @brief Reads data from the specified RTC Backup data Register. |
||
501 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
||
502 | * the configuration information for RTC. |
||
503 | * @param BackupRegister: RTC Backup data Register number. |
||
504 | * This parameter can be: RTC_BKP_DRx where x can be from 1 to 10 (or 42) to |
||
505 | * specify the register (depending devices). |
||
506 | * @retval Read value |
||
507 | */ |
||
508 | uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister) |
||
509 | { |
||
510 | uint32_t backupregister = 0; |
||
511 | uint32_t pvalue = 0; |
||
512 | |||
513 | /* Check the parameters */ |
||
514 | assert_param(IS_RTC_BKP(BackupRegister)); |
||
515 | |||
516 | backupregister = (uint32_t)BKP_BASE; |
||
517 | backupregister += (BackupRegister * 4); |
||
518 | |||
519 | pvalue = (*(__IO uint32_t *)(backupregister)) & BKP_DR1_D; |
||
520 | |||
521 | /* Read the specified register */ |
||
522 | return pvalue; |
||
523 | } |
||
524 | |||
525 | |||
526 | /** |
||
527 | * @brief Sets the Smooth calibration parameters. |
||
528 | * @param hrtc: RTC handle |
||
529 | * @param SmoothCalibPeriod: Not used (only present for compatibility with another families) |
||
530 | * @param SmoothCalibPlusPulses: Not used (only present for compatibility with another families) |
||
531 | * @param SmouthCalibMinusPulsesValue: specifies the RTC Clock Calibration value. |
||
532 | * This parameter must be a number between 0 and 0x7F. |
||
533 | * @retval HAL status |
||
534 | */ |
||
535 | HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef* hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmouthCalibMinusPulsesValue) |
||
536 | { |
||
537 | /* Check input parameters */ |
||
538 | if(hrtc == NULL) |
||
539 | { |
||
540 | return HAL_ERROR; |
||
541 | } |
||
542 | |||
543 | /* Check the parameters */ |
||
544 | assert_param(IS_RTC_SMOOTH_CALIB_MINUS(SmouthCalibMinusPulsesValue)); |
||
545 | |||
546 | /* Process Locked */ |
||
547 | __HAL_LOCK(hrtc); |
||
548 | |||
549 | hrtc->State = HAL_RTC_STATE_BUSY; |
||
550 | |||
551 | /* Sets RTC Clock Calibration value.*/ |
||
552 | MODIFY_REG(BKP->RTCCR, BKP_RTCCR_CAL, SmouthCalibMinusPulsesValue); |
||
553 | |||
554 | /* Change RTC state */ |
||
555 | hrtc->State = HAL_RTC_STATE_READY; |
||
556 | |||
557 | /* Process Unlocked */ |
||
558 | __HAL_UNLOCK(hrtc); |
||
559 | |||
560 | return HAL_OK; |
||
561 | } |
||
562 | |||
563 | /** |
||
564 | * @} |
||
565 | */ |
||
566 | |||
567 | /** |
||
568 | * @} |
||
569 | */ |
||
570 | |||
571 | /** |
||
572 | * @} |
||
573 | */ |
||
574 | |||
575 | #endif /* HAL_RTC_MODULE_ENABLED */ |
||
576 | |||
577 | /** |
||
578 | * @} |
||
579 | */ |
||
580 | |||
581 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
||
582 |