2 ******************************************************************************
\r
3 * @file stm32f7xx_hal_rtc_ex.c
\r
4 * @author MCD Application Team
\r
6 * @date 24-March-2015
\r
7 * @brief RTC HAL module driver.
\r
8 * This file provides firmware functions to manage the following
\r
9 * functionalities of the Real Time Clock (RTC) Extension peripheral:
\r
10 * + RTC Time Stamp functions
\r
11 * + RTC Tamper functions
\r
12 * + RTC Wake-up functions
\r
13 * + Extension Control functions
\r
14 * + Extension RTC features functions
\r
17 ==============================================================================
\r
18 ##### How to use this driver #####
\r
19 ==============================================================================
\r
21 (+) Enable the RTC domain access.
\r
22 (+) Configure the RTC Prescaler (Asynchronous and Synchronous) and RTC hour
\r
23 format using the HAL_RTC_Init() function.
\r
25 *** RTC Wakeup configuration ***
\r
26 ================================
\r
28 (+) To configure the RTC Wakeup Clock source and Counter use the HAL_RTC_SetWakeUpTimer()
\r
29 function. You can also configure the RTC Wakeup timer in interrupt mode
\r
30 using the HAL_RTC_SetWakeUpTimer_IT() function.
\r
31 (+) To read the RTC WakeUp Counter register, use the HAL_RTC_GetWakeUpTimer()
\r
34 *** TimeStamp configuration ***
\r
35 ===============================
\r
37 (+) Enables the RTC TimeStamp using the HAL_RTC_SetTimeStamp() function.
\r
38 You can also configure the RTC TimeStamp with interrupt mode using the
\r
39 HAL_RTC_SetTimeStamp_IT() function.
\r
40 (+) To read the RTC TimeStamp Time and Date register, use the HAL_RTC_GetTimeStamp()
\r
43 *** Internal TimeStamp configuration ***
\r
44 ===============================
\r
46 (+) Enables the RTC internal TimeStamp using the HAL_RTC_SetInternalTimeStamp() function.
\r
47 (+) To read the RTC TimeStamp Time and Date register, use the HAL_RTC_GetTimeStamp()
\r
50 *** Tamper configuration ***
\r
51 ============================
\r
53 (+) Enable the RTC Tamper and Configure the Tamper filter count, trigger Edge
\r
54 or Level according to the Tamper filter (if equal to 0 Edge else Level)
\r
55 value, sampling frequency, NoErase, MaskFlag, precharge or discharge and
\r
56 Pull-UP using the HAL_RTC_SetTamper() function. You can configure RTC Tamper
\r
57 with interrupt mode using HAL_RTC_SetTamper_IT() function.
\r
58 (+) The default configuration of the Tamper erases the backup registers. To avoid
\r
59 erase, enable the NoErase field on the RTC_TAMPCR register.
\r
61 *** Backup Data Registers configuration ***
\r
62 ===========================================
\r
64 (+) To write to the RTC Backup Data registers, use the HAL_RTC_BKUPWrite()
\r
66 (+) To read the RTC Backup Data registers, use the HAL_RTC_BKUPRead()
\r
70 ******************************************************************************
\r
73 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
\r
75 * Redistribution and use in source and binary forms, with or without modification,
\r
76 * are permitted provided that the following conditions are met:
\r
77 * 1. Redistributions of source code must retain the above copyright notice,
\r
78 * this list of conditions and the following disclaimer.
\r
79 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
80 * this list of conditions and the following disclaimer in the documentation
\r
81 * and/or other materials provided with the distribution.
\r
82 * 3. Neither the name of STMicroelectronics nor the names of its contributors
\r
83 * may be used to endorse or promote products derived from this software
\r
84 * without specific prior written permission.
\r
86 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
87 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
88 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
\r
89 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
\r
90 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
91 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
\r
92 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
\r
93 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
\r
94 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
\r
95 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
97 ******************************************************************************
\r
100 /* Includes ------------------------------------------------------------------*/
\r
101 #include "stm32f7xx_hal.h"
\r
103 /** @addtogroup STM32F7xx_HAL_Driver
\r
107 /** @defgroup RTCEx RTCEx
\r
108 * @brief RTC Extended HAL module driver
\r
112 #ifdef HAL_RTC_MODULE_ENABLED
\r
114 /* Private typedef -----------------------------------------------------------*/
\r
115 /* Private define ------------------------------------------------------------*/
\r
116 /* Private macro -------------------------------------------------------------*/
\r
117 /* Private variables ---------------------------------------------------------*/
\r
118 /* Private function prototypes -----------------------------------------------*/
\r
119 /* Private functions ---------------------------------------------------------*/
\r
121 /** @defgroup RTCEx_Exported_Functions RTC Extended Exported Functions
\r
126 /** @defgroup RTCEx_Group1 RTC TimeStamp and Tamper functions
\r
127 * @brief RTC TimeStamp and Tamper functions
\r
130 ===============================================================================
\r
131 ##### RTC TimeStamp and Tamper functions #####
\r
132 ===============================================================================
\r
134 [..] This section provides functions allowing to configure TimeStamp feature
\r
141 * @brief Sets TimeStamp.
\r
142 * @note This API must be called before enabling the TimeStamp feature.
\r
143 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
144 * the configuration information for RTC.
\r
145 * @param TimeStampEdge: Specifies the pin edge on which the TimeStamp is
\r
147 * This parameter can be one of the following values:
\r
148 * @arg RTC_TIMESTAMPEDGE_RISING: the Time stamp event occurs on the
\r
149 * rising edge of the related pin.
\r
150 * @arg RTC_TIMESTAMPEDGE_FALLING: the Time stamp event occurs on the
\r
151 * falling edge of the related pin.
\r
152 * @param RTC_TimeStampPin: specifies the RTC TimeStamp Pin.
\r
153 * This parameter can be one of the following values:
\r
154 * @arg RTC_TIMESTAMPPIN_PC13: PC13 is selected as RTC TimeStamp Pin.
\r
155 * @arg RTC_TIMESTAMPPIN_PI8: PI8 is selected as RTC TimeStamp Pin.
\r
156 * @arg RTC_TIMESTAMPPIN_PC1: PC1 is selected as RTC TimeStamp Pin.
\r
157 * @retval HAL status
\r
159 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin)
\r
161 uint32_t tmpreg = 0;
\r
163 /* Check the parameters */
\r
164 assert_param(IS_TIMESTAMP_EDGE(TimeStampEdge));
\r
165 assert_param(IS_RTC_TIMESTAMP_PIN(RTC_TimeStampPin));
\r
167 /* Process Locked */
\r
170 hrtc->State = HAL_RTC_STATE_BUSY;
\r
172 /* Get the RTC_CR register and clear the bits to be configured */
\r
173 tmpreg = (uint32_t)(hrtc->Instance->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));
\r
175 tmpreg|= TimeStampEdge;
\r
177 /* Disable the write protection for RTC registers */
\r
178 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
180 hrtc->Instance->OR &= (uint32_t)~RTC_OR_TSINSEL;
\r
181 hrtc->Instance->OR |= (uint32_t)(RTC_TimeStampPin);
\r
183 /* Configure the Time Stamp TSEDGE and Enable bits */
\r
184 hrtc->Instance->CR = (uint32_t)tmpreg;
\r
186 __HAL_RTC_TIMESTAMP_ENABLE(hrtc);
\r
188 /* Enable the write protection for RTC registers */
\r
189 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
191 /* Change RTC state */
\r
192 hrtc->State = HAL_RTC_STATE_READY;
\r
194 /* Process Unlocked */
\r
195 __HAL_UNLOCK(hrtc);
\r
201 * @brief Sets TimeStamp with Interrupt.
\r
202 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
203 * the configuration information for RTC.
\r
204 * @note This API must be called before enabling the TimeStamp feature.
\r
205 * @param TimeStampEdge: Specifies the pin edge on which the TimeStamp is
\r
207 * This parameter can be one of the following values:
\r
208 * @arg RTC_TIMESTAMPEDGE_RISING: the Time stamp event occurs on the
\r
209 * rising edge of the related pin.
\r
210 * @arg RTC_TIMESTAMPEDGE_FALLING: the Time stamp event occurs on the
\r
211 * falling edge of the related pin.
\r
212 * @param RTC_TimeStampPin: Specifies the RTC TimeStamp Pin.
\r
213 * This parameter can be one of the following values:
\r
214 * @arg RTC_TIMESTAMPPIN_PC13: PC13 is selected as RTC TimeStamp Pin.
\r
215 * @arg RTC_TIMESTAMPPIN_PI8: PI8 is selected as RTC TimeStamp Pin.
\r
216 * @arg RTC_TIMESTAMPPIN_PC1: PC1 is selected as RTC TimeStamp Pin.
\r
217 * @retval HAL status
\r
219 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin)
\r
221 uint32_t tmpreg = 0;
\r
223 /* Check the parameters */
\r
224 assert_param(IS_TIMESTAMP_EDGE(TimeStampEdge));
\r
225 assert_param(IS_RTC_TIMESTAMP_PIN(RTC_TimeStampPin));
\r
227 /* Process Locked */
\r
230 hrtc->State = HAL_RTC_STATE_BUSY;
\r
232 /* Get the RTC_CR register and clear the bits to be configured */
\r
233 tmpreg = (uint32_t)(hrtc->Instance->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));
\r
235 tmpreg |= TimeStampEdge;
\r
237 /* Disable the write protection for RTC registers */
\r
238 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
240 /* Configure the Time Stamp TSEDGE and Enable bits */
\r
241 hrtc->Instance->CR = (uint32_t)tmpreg;
\r
243 hrtc->Instance->OR &= (uint32_t)~RTC_OR_TSINSEL;
\r
244 hrtc->Instance->OR |= (uint32_t)(RTC_TimeStampPin);
\r
246 __HAL_RTC_TIMESTAMP_ENABLE(hrtc);
\r
248 /* Enable IT timestamp */
\r
249 __HAL_RTC_TIMESTAMP_ENABLE_IT(hrtc,RTC_IT_TS);
\r
251 /* RTC timestamp Interrupt Configuration: EXTI configuration */
\r
252 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT();
\r
254 EXTI->RTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT;
\r
256 /* Enable the write protection for RTC registers */
\r
257 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
259 hrtc->State = HAL_RTC_STATE_READY;
\r
261 /* Process Unlocked */
\r
262 __HAL_UNLOCK(hrtc);
\r
268 * @brief Deactivates TimeStamp.
\r
269 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
270 * the configuration information for RTC.
\r
271 * @retval HAL status
\r
273 HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc)
\r
275 uint32_t tmpreg = 0;
\r
277 /* Process Locked */
\r
280 hrtc->State = HAL_RTC_STATE_BUSY;
\r
282 /* Disable the write protection for RTC registers */
\r
283 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
285 /* In case of interrupt mode is used, the interrupt source must disabled */
\r
286 __HAL_RTC_TIMESTAMP_DISABLE_IT(hrtc, RTC_IT_TS);
\r
288 /* Get the RTC_CR register and clear the bits to be configured */
\r
289 tmpreg = (uint32_t)(hrtc->Instance->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));
\r
291 /* Configure the Time Stamp TSEDGE and Enable bits */
\r
292 hrtc->Instance->CR = (uint32_t)tmpreg;
\r
294 /* Enable the write protection for RTC registers */
\r
295 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
297 hrtc->State = HAL_RTC_STATE_READY;
\r
299 /* Process Unlocked */
\r
300 __HAL_UNLOCK(hrtc);
\r
306 * @brief Sets Internal TimeStamp.
\r
307 * @note This API must be called before enabling the internal TimeStamp feature.
\r
308 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
309 * the configuration information for RTC.
\r
310 * @retval HAL status
\r
312 HAL_StatusTypeDef HAL_RTCEx_SetInternalTimeStamp(RTC_HandleTypeDef *hrtc)
\r
314 /* Process Locked */
\r
317 hrtc->State = HAL_RTC_STATE_BUSY;
\r
319 /* Disable the write protection for RTC registers */
\r
320 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
322 /* Configure the internal Time Stamp Enable bits */
\r
323 __HAL_RTC_INTERNAL_TIMESTAMP_ENABLE(hrtc);
\r
325 /* Enable the write protection for RTC registers */
\r
326 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
328 /* Change RTC state */
\r
329 hrtc->State = HAL_RTC_STATE_READY;
\r
331 /* Process Unlocked */
\r
332 __HAL_UNLOCK(hrtc);
\r
338 * @brief Deactivates internal TimeStamp.
\r
339 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
340 * the configuration information for RTC.
\r
341 * @retval HAL status
\r
343 HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTimeStamp(RTC_HandleTypeDef *hrtc)
\r
345 /* Process Locked */
\r
348 hrtc->State = HAL_RTC_STATE_BUSY;
\r
350 /* Disable the write protection for RTC registers */
\r
351 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
353 /* Configure the internal Time Stamp Enable bits */
\r
354 __HAL_RTC_INTERNAL_TIMESTAMP_DISABLE(hrtc);
\r
356 /* Enable the write protection for RTC registers */
\r
357 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
359 hrtc->State = HAL_RTC_STATE_READY;
\r
361 /* Process Unlocked */
\r
362 __HAL_UNLOCK(hrtc);
\r
368 * @brief Gets the RTC TimeStamp value.
\r
369 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
370 * the configuration information for RTC.
\r
371 * @param sTimeStamp: Pointer to Time structure
\r
372 * @param sTimeStampDate: Pointer to Date structure
\r
373 * @param Format: specifies the format of the entered parameters.
\r
374 * This parameter can be one of the following values:
\r
375 * FORMAT_BIN: Binary data format
\r
376 * FORMAT_BCD: BCD data format
\r
377 * @retval HAL status
\r
379 HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef* sTimeStamp, RTC_DateTypeDef* sTimeStampDate, uint32_t Format)
\r
381 uint32_t tmptime = 0, tmpdate = 0;
\r
383 /* Check the parameters */
\r
384 assert_param(IS_RTC_FORMAT(Format));
\r
386 /* Get the TimeStamp time and date registers values */
\r
387 tmptime = (uint32_t)(hrtc->Instance->TSTR & RTC_TR_RESERVED_MASK);
\r
388 tmpdate = (uint32_t)(hrtc->Instance->TSDR & RTC_DR_RESERVED_MASK);
\r
390 /* Fill the Time structure fields with the read parameters */
\r
391 sTimeStamp->Hours = (uint8_t)((tmptime & (RTC_TR_HT | RTC_TR_HU)) >> 16);
\r
392 sTimeStamp->Minutes = (uint8_t)((tmptime & (RTC_TR_MNT | RTC_TR_MNU)) >> 8);
\r
393 sTimeStamp->Seconds = (uint8_t)(tmptime & (RTC_TR_ST | RTC_TR_SU));
\r
394 sTimeStamp->TimeFormat = (uint8_t)((tmptime & (RTC_TR_PM)) >> 16);
\r
395 sTimeStamp->SubSeconds = (uint32_t) hrtc->Instance->TSSSR;
\r
397 /* Fill the Date structure fields with the read parameters */
\r
398 sTimeStampDate->Year = 0;
\r
399 sTimeStampDate->Month = (uint8_t)((tmpdate & (RTC_DR_MT | RTC_DR_MU)) >> 8);
\r
400 sTimeStampDate->Date = (uint8_t)(tmpdate & (RTC_DR_DT | RTC_DR_DU));
\r
401 sTimeStampDate->WeekDay = (uint8_t)((tmpdate & (RTC_DR_WDU)) >> 13);
\r
403 /* Check the input parameters format */
\r
404 if(Format == RTC_FORMAT_BIN)
\r
406 /* Convert the TimeStamp structure parameters to Binary format */
\r
407 sTimeStamp->Hours = (uint8_t)RTC_Bcd2ToByte(sTimeStamp->Hours);
\r
408 sTimeStamp->Minutes = (uint8_t)RTC_Bcd2ToByte(sTimeStamp->Minutes);
\r
409 sTimeStamp->Seconds = (uint8_t)RTC_Bcd2ToByte(sTimeStamp->Seconds);
\r
411 /* Convert the DateTimeStamp structure parameters to Binary format */
\r
412 sTimeStampDate->Month = (uint8_t)RTC_Bcd2ToByte(sTimeStampDate->Month);
\r
413 sTimeStampDate->Date = (uint8_t)RTC_Bcd2ToByte(sTimeStampDate->Date);
\r
414 sTimeStampDate->WeekDay = (uint8_t)RTC_Bcd2ToByte(sTimeStampDate->WeekDay);
\r
417 /* Clear the TIMESTAMP Flag */
\r
418 __HAL_RTC_TIMESTAMP_CLEAR_FLAG(hrtc, RTC_FLAG_TSF);
\r
424 * @brief Sets Tamper
\r
425 * @note By calling this API we disable the tamper interrupt for all tampers.
\r
426 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
427 * the configuration information for RTC.
\r
428 * @param sTamper: Pointer to Tamper Structure.
\r
429 * @retval HAL status
\r
431 HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper)
\r
433 uint32_t tmpreg = 0;
\r
435 /* Check the parameters */
\r
436 assert_param(IS_RTC_TAMPER(sTamper->Tamper));
\r
437 assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger));
\r
438 assert_param(IS_RTC_TAMPER_ERASE_MODE(sTamper->NoErase));
\r
439 assert_param(IS_RTC_TAMPER_MASKFLAG_STATE(sTamper->MaskFlag));
\r
440 assert_param(IS_RTC_TAMPER_FILTER(sTamper->Filter));
\r
441 assert_param(IS_RTC_TAMPER_SAMPLING_FREQ(sTamper->SamplingFrequency));
\r
442 assert_param(IS_RTC_TAMPER_PRECHARGE_DURATION(sTamper->PrechargeDuration));
\r
443 assert_param(IS_RTC_TAMPER_PULLUP_STATE(sTamper->TamperPullUp));
\r
444 assert_param(IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(sTamper->TimeStampOnTamperDetection));
\r
446 /* Process Locked */
\r
449 hrtc->State = HAL_RTC_STATE_BUSY;
\r
451 if(sTamper->Trigger != RTC_TAMPERTRIGGER_RISINGEDGE)
\r
453 sTamper->Trigger = (uint32_t)(sTamper->Tamper << 1);
\r
456 if(sTamper->NoErase != RTC_TAMPER_ERASE_BACKUP_ENABLE)
\r
458 sTamper->NoErase = 0;
\r
459 if((sTamper->Tamper & RTC_TAMPER_1) != 0)
\r
461 sTamper->NoErase |= RTC_TAMPCR_TAMP1NOERASE;
\r
463 if((sTamper->Tamper & RTC_TAMPER_2) != 0)
\r
465 sTamper->NoErase |= RTC_TAMPCR_TAMP2NOERASE;
\r
467 if((sTamper->Tamper & RTC_TAMPER_3) != 0)
\r
469 sTamper->NoErase |= RTC_TAMPCR_TAMP3NOERASE;
\r
473 if(sTamper->MaskFlag != RTC_TAMPERMASK_FLAG_DISABLE)
\r
475 sTamper->MaskFlag = 0;
\r
476 if((sTamper->Tamper & RTC_TAMPER_1) != 0)
\r
478 sTamper->MaskFlag |= RTC_TAMPCR_TAMP1MF;
\r
480 if((sTamper->Tamper & RTC_TAMPER_2) != 0)
\r
482 sTamper->MaskFlag |= RTC_TAMPCR_TAMP2MF;
\r
484 if((sTamper->Tamper & RTC_TAMPER_3) != 0)
\r
486 sTamper->MaskFlag |= RTC_TAMPCR_TAMP3MF;
\r
490 tmpreg = ((uint32_t)sTamper->Tamper | (uint32_t)sTamper->Trigger | (uint32_t)sTamper->NoErase |\
\r
491 (uint32_t)sTamper->MaskFlag | (uint32_t)sTamper->Filter | (uint32_t)sTamper->SamplingFrequency |\
\r
492 (uint32_t)sTamper->PrechargeDuration | (uint32_t)sTamper->TamperPullUp | sTamper->TimeStampOnTamperDetection);
\r
494 hrtc->Instance->TAMPCR &= (uint32_t)~((uint32_t)sTamper->Tamper | (uint32_t)(sTamper->Tamper << 1) | (uint32_t)RTC_TAMPCR_TAMPTS |\
\r
495 (uint32_t)RTC_TAMPCR_TAMPFREQ | (uint32_t)RTC_TAMPCR_TAMPFLT | (uint32_t)RTC_TAMPCR_TAMPPRCH |\
\r
496 (uint32_t)RTC_TAMPCR_TAMPPUDIS | (uint32_t)RTC_TAMPCR_TAMPIE | (uint32_t)RTC_TAMPCR_TAMP1IE |\
\r
497 (uint32_t)RTC_TAMPCR_TAMP2IE | (uint32_t)RTC_TAMPCR_TAMP3IE | (uint32_t)RTC_TAMPCR_TAMP1NOERASE |\
\r
498 (uint32_t)RTC_TAMPCR_TAMP2NOERASE | (uint32_t)RTC_TAMPCR_TAMP3NOERASE | (uint32_t)RTC_TAMPCR_TAMP1MF |\
\r
499 (uint32_t)RTC_TAMPCR_TAMP2MF | (uint32_t)RTC_TAMPCR_TAMP3MF);
\r
501 hrtc->Instance->TAMPCR |= tmpreg;
\r
503 hrtc->State = HAL_RTC_STATE_READY;
\r
505 /* Process Unlocked */
\r
506 __HAL_UNLOCK(hrtc);
\r
512 * @brief Sets Tamper with interrupt.
\r
513 * @note By calling this API we force the tamper interrupt for all tampers.
\r
514 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
515 * the configuration information for RTC.
\r
516 * @param sTamper: Pointer to RTC Tamper.
\r
517 * @retval HAL status
\r
519 HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper)
\r
521 uint32_t tmpreg = 0;
\r
523 /* Check the parameters */
\r
524 assert_param(IS_RTC_TAMPER(sTamper->Tamper));
\r
525 assert_param(IS_RTC_TAMPER_INTERRUPT(sTamper->Interrupt));
\r
526 assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger));
\r
527 assert_param(IS_RTC_TAMPER_ERASE_MODE(sTamper->NoErase));
\r
528 assert_param(IS_RTC_TAMPER_MASKFLAG_STATE(sTamper->MaskFlag));
\r
529 assert_param(IS_RTC_TAMPER_FILTER(sTamper->Filter));
\r
530 assert_param(IS_RTC_TAMPER_SAMPLING_FREQ(sTamper->SamplingFrequency));
\r
531 assert_param(IS_RTC_TAMPER_PRECHARGE_DURATION(sTamper->PrechargeDuration));
\r
532 assert_param(IS_RTC_TAMPER_PULLUP_STATE(sTamper->TamperPullUp));
\r
533 assert_param(IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(sTamper->TimeStampOnTamperDetection));
\r
535 /* Process Locked */
\r
538 hrtc->State = HAL_RTC_STATE_BUSY;
\r
540 /* Configure the tamper trigger */
\r
541 if(sTamper->Trigger != RTC_TAMPERTRIGGER_RISINGEDGE)
\r
543 sTamper->Trigger = (uint32_t)(sTamper->Tamper << 1);
\r
546 if(sTamper->NoErase != RTC_TAMPER_ERASE_BACKUP_ENABLE)
\r
548 sTamper->NoErase = 0;
\r
549 if((sTamper->Tamper & RTC_TAMPER_1) != 0)
\r
551 sTamper->NoErase |= RTC_TAMPCR_TAMP1NOERASE;
\r
553 if((sTamper->Tamper & RTC_TAMPER_2) != 0)
\r
555 sTamper->NoErase |= RTC_TAMPCR_TAMP2NOERASE;
\r
557 if((sTamper->Tamper & RTC_TAMPER_3) != 0)
\r
559 sTamper->NoErase |= RTC_TAMPCR_TAMP3NOERASE;
\r
563 if(sTamper->MaskFlag != RTC_TAMPERMASK_FLAG_DISABLE)
\r
565 sTamper->MaskFlag = 0;
\r
566 if((sTamper->Tamper & RTC_TAMPER_1) != 0)
\r
568 sTamper->MaskFlag |= RTC_TAMPCR_TAMP1MF;
\r
570 if((sTamper->Tamper & RTC_TAMPER_2) != 0)
\r
572 sTamper->MaskFlag |= RTC_TAMPCR_TAMP2MF;
\r
574 if((sTamper->Tamper & RTC_TAMPER_3) != 0)
\r
576 sTamper->MaskFlag |= RTC_TAMPCR_TAMP3MF;
\r
580 tmpreg = ((uint32_t)sTamper->Tamper | (uint32_t)sTamper->Interrupt | (uint32_t)sTamper->Trigger | (uint32_t)sTamper->NoErase |\
\r
581 (uint32_t)sTamper->MaskFlag | (uint32_t)sTamper->Filter | (uint32_t)sTamper->SamplingFrequency |\
\r
582 (uint32_t)sTamper->PrechargeDuration | (uint32_t)sTamper->TamperPullUp | sTamper->TimeStampOnTamperDetection);
\r
584 hrtc->Instance->TAMPCR &= (uint32_t)~((uint32_t)sTamper->Tamper | (uint32_t)(sTamper->Tamper << 1) | (uint32_t)RTC_TAMPCR_TAMPTS |\
\r
585 (uint32_t)RTC_TAMPCR_TAMPFREQ | (uint32_t)RTC_TAMPCR_TAMPFLT | (uint32_t)RTC_TAMPCR_TAMPPRCH |\
\r
586 (uint32_t)RTC_TAMPCR_TAMPPUDIS | (uint32_t)RTC_TAMPCR_TAMPIE | (uint32_t)RTC_TAMPCR_TAMP1IE |\
\r
587 (uint32_t)RTC_TAMPCR_TAMP2IE | (uint32_t)RTC_TAMPCR_TAMP3IE | (uint32_t)RTC_TAMPCR_TAMP1NOERASE |\
\r
588 (uint32_t)RTC_TAMPCR_TAMP2NOERASE | (uint32_t)RTC_TAMPCR_TAMP3NOERASE | (uint32_t)RTC_TAMPCR_TAMP1MF |\
\r
589 (uint32_t)RTC_TAMPCR_TAMP2MF | (uint32_t)RTC_TAMPCR_TAMP3MF);
\r
591 hrtc->Instance->TAMPCR |= tmpreg;
\r
593 /* RTC Tamper Interrupt Configuration: EXTI configuration */
\r
594 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT();
\r
596 EXTI->RTSR |= RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT;
\r
598 hrtc->State = HAL_RTC_STATE_READY;
\r
600 /* Process Unlocked */
\r
601 __HAL_UNLOCK(hrtc);
\r
607 * @brief Deactivates Tamper.
\r
608 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
609 * the configuration information for RTC.
\r
610 * @param Tamper: Selected tamper pin.
\r
611 * This parameter can be RTC_Tamper_1 and/or RTC_TAMPER_2.
\r
612 * @retval HAL status
\r
614 HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper)
\r
616 assert_param(IS_RTC_TAMPER(Tamper));
\r
618 /* Process Locked */
\r
621 hrtc->State = HAL_RTC_STATE_BUSY;
\r
623 /* Disable the selected Tamper pin */
\r
624 hrtc->Instance->TAMPCR &= (uint32_t)~Tamper;
\r
626 if ((Tamper & RTC_TAMPER_1) != 0)
\r
628 /* Disable the Tamper1 interrupt */
\r
629 hrtc->Instance->TAMPCR &= (uint32_t)~(RTC_IT_TAMP | RTC_IT_TAMP1);
\r
631 if ((Tamper & RTC_TAMPER_2) != 0)
\r
633 /* Disable the Tamper2 interrupt */
\r
634 hrtc->Instance->TAMPCR &= (uint32_t)~(RTC_IT_TAMP | RTC_IT_TAMP2);
\r
636 if ((Tamper & RTC_TAMPER_3) != 0)
\r
638 /* Disable the Tamper2 interrupt */
\r
639 hrtc->Instance->TAMPCR &= (uint32_t)~(RTC_IT_TAMP | RTC_IT_TAMP3);
\r
642 hrtc->State = HAL_RTC_STATE_READY;
\r
644 /* Process Unlocked */
\r
645 __HAL_UNLOCK(hrtc);
\r
651 * @brief This function handles TimeStamp interrupt request.
\r
652 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
653 * the configuration information for RTC.
\r
656 void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc)
\r
658 if(__HAL_RTC_TIMESTAMP_GET_IT(hrtc, RTC_IT_TS))
\r
660 /* Get the status of the Interrupt */
\r
661 if((uint32_t)(hrtc->Instance->CR & RTC_IT_TS) != (uint32_t)RESET)
\r
663 /* TIMESTAMP callback */
\r
664 HAL_RTCEx_TimeStampEventCallback(hrtc);
\r
666 /* Clear the TIMESTAMP interrupt pending bit */
\r
667 __HAL_RTC_TIMESTAMP_CLEAR_FLAG(hrtc,RTC_FLAG_TSF);
\r
671 /* Get the status of the Interrupt */
\r
672 if(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP1F)== SET)
\r
674 /* Get the TAMPER Interrupt enable bit and pending bit */
\r
675 if((((hrtc->Instance->TAMPCR & RTC_TAMPCR_TAMPIE)) != (uint32_t)RESET) || \
\r
676 (((hrtc->Instance->TAMPCR & RTC_TAMPCR_TAMP1IE)) != (uint32_t)RESET))
\r
678 /* Tamper callback */
\r
679 HAL_RTCEx_Tamper1EventCallback(hrtc);
\r
681 /* Clear the Tamper interrupt pending bit */
\r
682 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc,RTC_FLAG_TAMP1F);
\r
686 /* Get the status of the Interrupt */
\r
687 if(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP2F)== SET)
\r
689 /* Get the TAMPER Interrupt enable bit and pending bit */
\r
690 if((((hrtc->Instance->TAMPCR & RTC_TAMPCR_TAMPIE)) != (uint32_t)RESET) || \
\r
691 (((hrtc->Instance->TAMPCR & RTC_TAMPCR_TAMP2IE)) != (uint32_t)RESET))
\r
693 /* Tamper callback */
\r
694 HAL_RTCEx_Tamper2EventCallback(hrtc);
\r
696 /* Clear the Tamper interrupt pending bit */
\r
697 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP2F);
\r
701 /* Get the status of the Interrupt */
\r
702 if(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP3F)== SET)
\r
704 /* Get the TAMPER Interrupt enable bit and pending bit */
\r
705 if((((hrtc->Instance->TAMPCR & RTC_TAMPCR_TAMPIE)) != (uint32_t)RESET) || \
\r
706 (((hrtc->Instance->TAMPCR & RTC_TAMPCR_TAMP3IE)) != (uint32_t)RESET))
\r
708 /* Tamper callback */
\r
709 HAL_RTCEx_Tamper3EventCallback(hrtc);
\r
711 /* Clear the Tamper interrupt pending bit */
\r
712 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP3F);
\r
716 /* Clear the EXTI's Flag for RTC TimeStamp and Tamper */
\r
717 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG();
\r
719 /* Change RTC state */
\r
720 hrtc->State = HAL_RTC_STATE_READY;
\r
724 * @brief TimeStamp callback.
\r
725 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
726 * the configuration information for RTC.
\r
729 __weak void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc)
\r
731 /* NOTE : This function Should not be modified, when the callback is needed,
\r
732 the HAL_RTC_TimeStampEventCallback could be implemented in the user file
\r
737 * @brief Tamper 1 callback.
\r
738 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
739 * the configuration information for RTC.
\r
742 __weak void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc)
\r
744 /* NOTE : This function Should not be modified, when the callback is needed,
\r
745 the HAL_RTC_Tamper1EventCallback could be implemented in the user file
\r
750 * @brief Tamper 2 callback.
\r
751 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
752 * the configuration information for RTC.
\r
755 __weak void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc)
\r
757 /* NOTE : This function Should not be modified, when the callback is needed,
\r
758 the HAL_RTC_Tamper2EventCallback could be implemented in the user file
\r
763 * @brief Tamper 3 callback.
\r
764 * @param hrtc: RTC handle
\r
767 __weak void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc)
\r
769 /* NOTE : This function Should not be modified, when the callback is needed,
\r
770 the HAL_RTCEx_Tamper3EventCallback could be implemented in the user file
\r
775 * @brief This function handles TimeStamp polling request.
\r
776 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
777 * the configuration information for RTC.
\r
778 * @param Timeout: Timeout duration
\r
779 * @retval HAL status
\r
781 HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
\r
783 uint32_t tickstart = 0;
\r
786 tickstart = HAL_GetTick();
\r
788 while(__HAL_RTC_TIMESTAMP_GET_FLAG(hrtc, RTC_FLAG_TSF) == RESET)
\r
790 if(Timeout != HAL_MAX_DELAY)
\r
792 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
\r
794 hrtc->State = HAL_RTC_STATE_TIMEOUT;
\r
795 return HAL_TIMEOUT;
\r
800 if(__HAL_RTC_TIMESTAMP_GET_FLAG(hrtc, RTC_FLAG_TSOVF) != RESET)
\r
802 /* Clear the TIMESTAMP OverRun Flag */
\r
803 __HAL_RTC_TIMESTAMP_CLEAR_FLAG(hrtc, RTC_FLAG_TSOVF);
\r
805 /* Change TIMESTAMP state */
\r
806 hrtc->State = HAL_RTC_STATE_ERROR;
\r
811 /* Change RTC state */
\r
812 hrtc->State = HAL_RTC_STATE_READY;
\r
818 * @brief This function handles Tamper1 Polling.
\r
819 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
820 * the configuration information for RTC.
\r
821 * @param Timeout: Timeout duration
\r
822 * @retval HAL status
\r
824 HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
\r
826 uint32_t tickstart = 0;
\r
829 tickstart = HAL_GetTick();
\r
831 /* Get the status of the Interrupt */
\r
832 while(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP1F)== RESET)
\r
834 if(Timeout != HAL_MAX_DELAY)
\r
836 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
\r
838 hrtc->State = HAL_RTC_STATE_TIMEOUT;
\r
839 return HAL_TIMEOUT;
\r
844 /* Clear the Tamper Flag */
\r
845 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc,RTC_FLAG_TAMP1F);
\r
847 /* Change RTC state */
\r
848 hrtc->State = HAL_RTC_STATE_READY;
\r
854 * @brief This function handles Tamper2 Polling.
\r
855 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
856 * the configuration information for RTC.
\r
857 * @param Timeout: Timeout duration
\r
858 * @retval HAL status
\r
860 HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
\r
862 uint32_t tickstart = 0;
\r
865 tickstart = HAL_GetTick();
\r
867 /* Get the status of the Interrupt */
\r
868 while(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP2F) == RESET)
\r
870 if(Timeout != HAL_MAX_DELAY)
\r
872 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
\r
874 hrtc->State = HAL_RTC_STATE_TIMEOUT;
\r
875 return HAL_TIMEOUT;
\r
880 /* Clear the Tamper Flag */
\r
881 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc,RTC_FLAG_TAMP2F);
\r
883 /* Change RTC state */
\r
884 hrtc->State = HAL_RTC_STATE_READY;
\r
890 * @brief This function handles Tamper3 Polling.
\r
891 * @param hrtc: RTC handle
\r
892 * @param Timeout: Timeout duration
\r
893 * @retval HAL status
\r
895 HAL_StatusTypeDef HAL_RTCEx_PollForTamper3Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
\r
897 uint32_t tickstart = HAL_GetTick();
\r
899 /* Get the status of the Interrupt */
\r
900 while(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP3F) == RESET)
\r
902 if(Timeout != HAL_MAX_DELAY)
\r
904 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
\r
906 hrtc->State = HAL_RTC_STATE_TIMEOUT;
\r
907 return HAL_TIMEOUT;
\r
912 /* Clear the Tamper Flag */
\r
913 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc,RTC_FLAG_TAMP3F);
\r
915 /* Change RTC state */
\r
916 hrtc->State = HAL_RTC_STATE_READY;
\r
925 /** @defgroup RTCEx_Group2 RTC Wake-up functions
\r
926 * @brief RTC Wake-up functions
\r
929 ===============================================================================
\r
930 ##### RTC Wake-up functions #####
\r
931 ===============================================================================
\r
933 [..] This section provides functions allowing to configure Wake-up feature
\r
940 * @brief Sets wake up timer.
\r
941 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
942 * the configuration information for RTC.
\r
943 * @param WakeUpCounter: Wake up counter
\r
944 * @param WakeUpClock: Wake up clock
\r
945 * @retval HAL status
\r
947 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock)
\r
949 uint32_t tickstart = 0;
\r
951 /* Check the parameters */
\r
952 assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock));
\r
953 assert_param(IS_RTC_WAKEUP_COUNTER(WakeUpCounter));
\r
955 /* Process Locked */
\r
958 hrtc->State = HAL_RTC_STATE_BUSY;
\r
960 /* Disable the write protection for RTC registers */
\r
961 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
963 __HAL_RTC_WAKEUPTIMER_DISABLE(hrtc);
\r
966 tickstart = HAL_GetTick();
\r
968 /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
\r
969 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == RESET)
\r
971 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
\r
973 /* Enable the write protection for RTC registers */
\r
974 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
976 hrtc->State = HAL_RTC_STATE_TIMEOUT;
\r
978 /* Process Unlocked */
\r
979 __HAL_UNLOCK(hrtc);
\r
981 return HAL_TIMEOUT;
\r
985 /* Clear the Wakeup Timer clock source bits in CR register */
\r
986 hrtc->Instance->CR &= (uint32_t)~RTC_CR_WUCKSEL;
\r
988 /* Configure the clock source */
\r
989 hrtc->Instance->CR |= (uint32_t)WakeUpClock;
\r
991 /* Configure the Wakeup Timer counter */
\r
992 hrtc->Instance->WUTR = (uint32_t)WakeUpCounter;
\r
994 /* Enable the Wakeup Timer */
\r
995 __HAL_RTC_WAKEUPTIMER_ENABLE(hrtc);
\r
997 /* Enable the write protection for RTC registers */
\r
998 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1000 hrtc->State = HAL_RTC_STATE_READY;
\r
1002 /* Process Unlocked */
\r
1003 __HAL_UNLOCK(hrtc);
\r
1009 * @brief Sets wake up timer with interrupt
\r
1010 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1011 * the configuration information for RTC.
\r
1012 * @param WakeUpCounter: Wake up counter
\r
1013 * @param WakeUpClock: Wake up clock
\r
1014 * @retval HAL status
\r
1016 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock)
\r
1018 uint32_t tickstart = 0;
\r
1020 /* Check the parameters */
\r
1021 assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock));
\r
1022 assert_param(IS_RTC_WAKEUP_COUNTER(WakeUpCounter));
\r
1024 /* Process Locked */
\r
1027 hrtc->State = HAL_RTC_STATE_BUSY;
\r
1029 /* Disable the write protection for RTC registers */
\r
1030 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
1032 __HAL_RTC_WAKEUPTIMER_DISABLE(hrtc);
\r
1035 tickstart = HAL_GetTick();
\r
1037 /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
\r
1038 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == RESET)
\r
1040 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
\r
1042 /* Enable the write protection for RTC registers */
\r
1043 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1045 hrtc->State = HAL_RTC_STATE_TIMEOUT;
\r
1047 /* Process Unlocked */
\r
1048 __HAL_UNLOCK(hrtc);
\r
1050 return HAL_TIMEOUT;
\r
1054 /* Configure the Wakeup Timer counter */
\r
1055 hrtc->Instance->WUTR = (uint32_t)WakeUpCounter;
\r
1057 /* Clear the Wakeup Timer clock source bits in CR register */
\r
1058 hrtc->Instance->CR &= (uint32_t)~RTC_CR_WUCKSEL;
\r
1060 /* Configure the clock source */
\r
1061 hrtc->Instance->CR |= (uint32_t)WakeUpClock;
\r
1063 /* RTC WakeUpTimer Interrupt Configuration: EXTI configuration */
\r
1064 __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT();
\r
1066 EXTI->RTSR |= RTC_EXTI_LINE_WAKEUPTIMER_EVENT;
\r
1068 /* Configure the Interrupt in the RTC_CR register */
\r
1069 __HAL_RTC_WAKEUPTIMER_ENABLE_IT(hrtc,RTC_IT_WUT);
\r
1071 /* Enable the Wakeup Timer */
\r
1072 __HAL_RTC_WAKEUPTIMER_ENABLE(hrtc);
\r
1074 /* Enable the write protection for RTC registers */
\r
1075 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1077 hrtc->State = HAL_RTC_STATE_READY;
\r
1079 /* Process Unlocked */
\r
1080 __HAL_UNLOCK(hrtc);
\r
1086 * @brief Deactivates wake up timer counter.
\r
1087 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1088 * the configuration information for RTC.
\r
1089 * @retval HAL status
\r
1091 uint32_t HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc)
\r
1093 uint32_t tickstart = 0;
\r
1095 /* Process Locked */
\r
1098 hrtc->State = HAL_RTC_STATE_BUSY;
\r
1100 /* Disable the write protection for RTC registers */
\r
1101 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
1103 /* Disable the Wakeup Timer */
\r
1104 __HAL_RTC_WAKEUPTIMER_DISABLE(hrtc);
\r
1106 /* In case of interrupt mode is used, the interrupt source must disabled */
\r
1107 __HAL_RTC_WAKEUPTIMER_DISABLE_IT(hrtc,RTC_IT_WUT);
\r
1110 tickstart = HAL_GetTick();
\r
1112 /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
\r
1113 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == RESET)
\r
1115 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
\r
1117 /* Enable the write protection for RTC registers */
\r
1118 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1120 hrtc->State = HAL_RTC_STATE_TIMEOUT;
\r
1122 /* Process Unlocked */
\r
1123 __HAL_UNLOCK(hrtc);
\r
1125 return HAL_TIMEOUT;
\r
1129 /* Enable the write protection for RTC registers */
\r
1130 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1132 hrtc->State = HAL_RTC_STATE_READY;
\r
1134 /* Process Unlocked */
\r
1135 __HAL_UNLOCK(hrtc);
\r
1141 * @brief Gets wake up timer counter.
\r
1142 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1143 * the configuration information for RTC.
\r
1144 * @retval Counter value
\r
1146 uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc)
\r
1148 /* Get the counter value */
\r
1149 return ((uint32_t)(hrtc->Instance->WUTR & RTC_WUTR_WUT));
\r
1153 * @brief This function handles Wake Up Timer interrupt request.
\r
1154 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1155 * the configuration information for RTC.
\r
1158 void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc)
\r
1160 if(__HAL_RTC_WAKEUPTIMER_GET_IT(hrtc, RTC_IT_WUT))
\r
1162 /* Get the status of the Interrupt */
\r
1163 if((uint32_t)(hrtc->Instance->CR & RTC_IT_WUT) != (uint32_t)RESET)
\r
1165 /* WAKEUPTIMER callback */
\r
1166 HAL_RTCEx_WakeUpTimerEventCallback(hrtc);
\r
1168 /* Clear the WAKEUPTIMER interrupt pending bit */
\r
1169 __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF);
\r
1173 /* Clear the EXTI's line Flag for RTC WakeUpTimer */
\r
1174 __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG();
\r
1176 /* Change RTC state */
\r
1177 hrtc->State = HAL_RTC_STATE_READY;
\r
1181 * @brief Wake Up Timer callback.
\r
1182 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1183 * the configuration information for RTC.
\r
1186 __weak void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc)
\r
1188 /* NOTE : This function Should not be modified, when the callback is needed,
\r
1189 the HAL_RTC_WakeUpTimerEventCallback could be implemented in the user file
\r
1194 * @brief This function handles Wake Up Timer Polling.
\r
1195 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1196 * the configuration information for RTC.
\r
1197 * @param Timeout: Timeout duration
\r
1198 * @retval HAL status
\r
1200 HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
\r
1202 uint32_t tickstart = 0;
\r
1205 tickstart = HAL_GetTick();
\r
1207 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTF) == RESET)
\r
1209 if(Timeout != HAL_MAX_DELAY)
\r
1211 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
\r
1213 hrtc->State = HAL_RTC_STATE_TIMEOUT;
\r
1215 return HAL_TIMEOUT;
\r
1220 /* Clear the WAKEUPTIMER Flag */
\r
1221 __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF);
\r
1223 /* Change RTC state */
\r
1224 hrtc->State = HAL_RTC_STATE_READY;
\r
1234 /** @defgroup RTCEx_Group3 Extension Peripheral Control functions
\r
1235 * @brief Extension Peripheral Control functions
\r
1238 ===============================================================================
\r
1239 ##### Extension Peripheral Control functions #####
\r
1240 ===============================================================================
\r
1242 This subsection provides functions allowing to
\r
1243 (+) Write a data in a specified RTC Backup data register
\r
1244 (+) Read a data in a specified RTC Backup data register
\r
1245 (+) Set the Coarse calibration parameters.
\r
1246 (+) Deactivate the Coarse calibration parameters
\r
1247 (+) Set the Smooth calibration parameters.
\r
1248 (+) Configure the Synchronization Shift Control Settings.
\r
1249 (+) Configure the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
\r
1250 (+) Deactivate the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
\r
1251 (+) Enable the RTC reference clock detection.
\r
1252 (+) Disable the RTC reference clock detection.
\r
1253 (+) Enable the Bypass Shadow feature.
\r
1254 (+) Disable the Bypass Shadow feature.
\r
1261 * @brief Writes a data in a specified RTC Backup data register.
\r
1262 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1263 * the configuration information for RTC.
\r
1264 * @param BackupRegister: RTC Backup data Register number.
\r
1265 * This parameter can be: RTC_BKP_DRx where x can be from 0 to 19 to
\r
1266 * specify the register.
\r
1267 * @param Data: Data to be written in the specified RTC Backup data register.
\r
1270 void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data)
\r
1274 /* Check the parameters */
\r
1275 assert_param(IS_RTC_BKP(BackupRegister));
\r
1277 tmp = (uint32_t)&(hrtc->Instance->BKP0R);
\r
1278 tmp += (BackupRegister * 4);
\r
1280 /* Write the specified register */
\r
1281 *(__IO uint32_t *)tmp = (uint32_t)Data;
\r
1285 * @brief Reads data from the specified RTC Backup data Register.
\r
1286 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1287 * the configuration information for RTC.
\r
1288 * @param BackupRegister: RTC Backup data Register number.
\r
1289 * This parameter can be: RTC_BKP_DRx where x can be from 0 to 19 to
\r
1290 * specify the register.
\r
1291 * @retval Read value
\r
1293 uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister)
\r
1297 /* Check the parameters */
\r
1298 assert_param(IS_RTC_BKP(BackupRegister));
\r
1300 tmp = (uint32_t)&(hrtc->Instance->BKP0R);
\r
1301 tmp += (BackupRegister * 4);
\r
1303 /* Read the specified register */
\r
1304 return (*(__IO uint32_t *)tmp);
\r
1308 * @brief Sets the Smooth calibration parameters.
\r
1309 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1310 * the configuration information for RTC.
\r
1311 * @param SmoothCalibPeriod: Select the Smooth Calibration Period.
\r
1312 * This parameter can be can be one of the following values :
\r
1313 * @arg RTC_SMOOTHCALIB_PERIOD_32SEC: The smooth calibration period is 32s.
\r
1314 * @arg RTC_SMOOTHCALIB_PERIOD_16SEC: The smooth calibration period is 16s.
\r
1315 * @arg RTC_SMOOTHCALIB_PERIOD_8SEC: The smooth calibration period is 8s.
\r
1316 * @param SmoothCalibPlusPulses: Select to Set or reset the CALP bit.
\r
1317 * This parameter can be one of the following values:
\r
1318 * @arg RTC_SMOOTHCALIB_PLUSPULSES_SET: Add one RTCCLK pulses every 2*11 pulses.
\r
1319 * @arg RTC_SMOOTHCALIB_PLUSPULSES_RESET: No RTCCLK pulses are added.
\r
1320 * @param SmouthCalibMinusPulsesValue: Select the value of CALM[8:0] bits.
\r
1321 * This parameter can be one any value from 0 to 0x000001FF.
\r
1322 * @note To deactivate the smooth calibration, the field SmoothCalibPlusPulses
\r
1323 * must be equal to SMOOTHCALIB_PLUSPULSES_RESET and the field
\r
1324 * SmouthCalibMinusPulsesValue must be equal to 0.
\r
1325 * @retval HAL status
\r
1327 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef* hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmouthCalibMinusPulsesValue)
\r
1329 uint32_t tickstart = 0;
\r
1331 /* Check the parameters */
\r
1332 assert_param(IS_RTC_SMOOTH_CALIB_PERIOD(SmoothCalibPeriod));
\r
1333 assert_param(IS_RTC_SMOOTH_CALIB_PLUS(SmoothCalibPlusPulses));
\r
1334 assert_param(IS_RTC_SMOOTH_CALIB_MINUS(SmouthCalibMinusPulsesValue));
\r
1336 /* Process Locked */
\r
1339 hrtc->State = HAL_RTC_STATE_BUSY;
\r
1341 /* Disable the write protection for RTC registers */
\r
1342 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
1344 /* check if a calibration is pending*/
\r
1345 if((hrtc->Instance->ISR & RTC_ISR_RECALPF) != RESET)
\r
1348 tickstart = HAL_GetTick();
\r
1350 /* check if a calibration is pending*/
\r
1351 while((hrtc->Instance->ISR & RTC_ISR_RECALPF) != RESET)
\r
1353 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
\r
1355 /* Enable the write protection for RTC registers */
\r
1356 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1358 /* Change RTC state */
\r
1359 hrtc->State = HAL_RTC_STATE_TIMEOUT;
\r
1361 /* Process Unlocked */
\r
1362 __HAL_UNLOCK(hrtc);
\r
1364 return HAL_TIMEOUT;
\r
1369 /* Configure the Smooth calibration settings */
\r
1370 hrtc->Instance->CALR = (uint32_t)((uint32_t)SmoothCalibPeriod | (uint32_t)SmoothCalibPlusPulses | (uint32_t)SmouthCalibMinusPulsesValue);
\r
1372 /* Enable the write protection for RTC registers */
\r
1373 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1375 /* Change RTC state */
\r
1376 hrtc->State = HAL_RTC_STATE_READY;
\r
1378 /* Process Unlocked */
\r
1379 __HAL_UNLOCK(hrtc);
\r
1385 * @brief Configures the Synchronization Shift Control Settings.
\r
1386 * @note When REFCKON is set, firmware must not write to Shift control register.
\r
1387 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1388 * the configuration information for RTC.
\r
1389 * @param ShiftAdd1S: Select to add or not 1 second to the time calendar.
\r
1390 * This parameter can be one of the following values :
\r
1391 * @arg RTC_SHIFTADD1S_SET: Add one second to the clock calendar.
\r
1392 * @arg RTC_SHIFTADD1S_RESET: No effect.
\r
1393 * @param ShiftSubFS: Select the number of Second Fractions to substitute.
\r
1394 * This parameter can be one any value from 0 to 0x7FFF.
\r
1395 * @retval HAL status
\r
1397 HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef* hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS)
\r
1399 uint32_t tickstart = 0;
\r
1401 /* Check the parameters */
\r
1402 assert_param(IS_RTC_SHIFT_ADD1S(ShiftAdd1S));
\r
1403 assert_param(IS_RTC_SHIFT_SUBFS(ShiftSubFS));
\r
1405 /* Process Locked */
\r
1408 hrtc->State = HAL_RTC_STATE_BUSY;
\r
1410 /* Disable the write protection for RTC registers */
\r
1411 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
1414 tickstart = HAL_GetTick();
\r
1416 /* Wait until the shift is completed*/
\r
1417 while((hrtc->Instance->ISR & RTC_ISR_SHPF) != RESET)
\r
1419 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
\r
1421 /* Enable the write protection for RTC registers */
\r
1422 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1424 hrtc->State = HAL_RTC_STATE_TIMEOUT;
\r
1426 /* Process Unlocked */
\r
1427 __HAL_UNLOCK(hrtc);
\r
1429 return HAL_TIMEOUT;
\r
1433 /* Check if the reference clock detection is disabled */
\r
1434 if((hrtc->Instance->CR & RTC_CR_REFCKON) == RESET)
\r
1436 /* Configure the Shift settings */
\r
1437 hrtc->Instance->SHIFTR = (uint32_t)(uint32_t)(ShiftSubFS) | (uint32_t)(ShiftAdd1S);
\r
1439 /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */
\r
1440 if((hrtc->Instance->CR & RTC_CR_BYPSHAD) == RESET)
\r
1442 if(HAL_RTC_WaitForSynchro(hrtc) != HAL_OK)
\r
1444 /* Enable the write protection for RTC registers */
\r
1445 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1447 hrtc->State = HAL_RTC_STATE_ERROR;
\r
1449 /* Process Unlocked */
\r
1450 __HAL_UNLOCK(hrtc);
\r
1458 /* Enable the write protection for RTC registers */
\r
1459 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1461 /* Change RTC state */
\r
1462 hrtc->State = HAL_RTC_STATE_ERROR;
\r
1464 /* Process Unlocked */
\r
1465 __HAL_UNLOCK(hrtc);
\r
1470 /* Enable the write protection for RTC registers */
\r
1471 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1473 /* Change RTC state */
\r
1474 hrtc->State = HAL_RTC_STATE_READY;
\r
1476 /* Process Unlocked */
\r
1477 __HAL_UNLOCK(hrtc);
\r
1483 * @brief Configures the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
\r
1484 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1485 * the configuration information for RTC.
\r
1486 * @param CalibOutput: Select the Calibration output Selection .
\r
1487 * This parameter can be one of the following values:
\r
1488 * @arg RTC_CALIBOUTPUT_512HZ: A signal has a regular waveform at 512Hz.
\r
1489 * @arg RTC_CALIBOUTPUT_1HZ: A signal has a regular waveform at 1Hz.
\r
1490 * @retval HAL status
\r
1492 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef* hrtc, uint32_t CalibOutput)
\r
1494 /* Check the parameters */
\r
1495 assert_param(IS_RTC_CALIB_OUTPUT(CalibOutput));
\r
1497 /* Process Locked */
\r
1500 hrtc->State = HAL_RTC_STATE_BUSY;
\r
1502 /* Disable the write protection for RTC registers */
\r
1503 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
1505 /* Clear flags before config */
\r
1506 hrtc->Instance->CR &= (uint32_t)~RTC_CR_COSEL;
\r
1508 /* Configure the RTC_CR register */
\r
1509 hrtc->Instance->CR |= (uint32_t)CalibOutput;
\r
1511 __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(hrtc);
\r
1513 /* Enable the write protection for RTC registers */
\r
1514 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1516 /* Change RTC state */
\r
1517 hrtc->State = HAL_RTC_STATE_READY;
\r
1519 /* Process Unlocked */
\r
1520 __HAL_UNLOCK(hrtc);
\r
1526 * @brief Deactivates the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
\r
1527 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1528 * the configuration information for RTC.
\r
1529 * @retval HAL status
\r
1531 HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef* hrtc)
\r
1533 /* Process Locked */
\r
1536 hrtc->State = HAL_RTC_STATE_BUSY;
\r
1538 /* Disable the write protection for RTC registers */
\r
1539 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
1541 __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(hrtc);
\r
1543 /* Enable the write protection for RTC registers */
\r
1544 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1546 /* Change RTC state */
\r
1547 hrtc->State = HAL_RTC_STATE_READY;
\r
1549 /* Process Unlocked */
\r
1550 __HAL_UNLOCK(hrtc);
\r
1556 * @brief Enables the RTC reference clock detection.
\r
1557 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1558 * the configuration information for RTC.
\r
1559 * @retval HAL status
\r
1561 HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef* hrtc)
\r
1563 /* Process Locked */
\r
1566 hrtc->State = HAL_RTC_STATE_BUSY;
\r
1568 /* Disable the write protection for RTC registers */
\r
1569 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
1571 /* Set Initialization mode */
\r
1572 if(RTC_EnterInitMode(hrtc) != HAL_OK)
\r
1574 /* Enable the write protection for RTC registers */
\r
1575 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1577 /* Set RTC state*/
\r
1578 hrtc->State = HAL_RTC_STATE_ERROR;
\r
1580 /* Process Unlocked */
\r
1581 __HAL_UNLOCK(hrtc);
\r
1587 __HAL_RTC_CLOCKREF_DETECTION_ENABLE(hrtc);
\r
1589 /* Exit Initialization mode */
\r
1590 hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;
\r
1593 /* Enable the write protection for RTC registers */
\r
1594 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1596 /* Change RTC state */
\r
1597 hrtc->State = HAL_RTC_STATE_READY;
\r
1599 /* Process Unlocked */
\r
1600 __HAL_UNLOCK(hrtc);
\r
1606 * @brief Disable the RTC reference clock detection.
\r
1607 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1608 * the configuration information for RTC.
\r
1609 * @retval HAL status
\r
1611 HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef* hrtc)
\r
1613 /* Process Locked */
\r
1616 hrtc->State = HAL_RTC_STATE_BUSY;
\r
1618 /* Disable the write protection for RTC registers */
\r
1619 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
1621 /* Set Initialization mode */
\r
1622 if(RTC_EnterInitMode(hrtc) != HAL_OK)
\r
1624 /* Enable the write protection for RTC registers */
\r
1625 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1627 /* Set RTC state*/
\r
1628 hrtc->State = HAL_RTC_STATE_ERROR;
\r
1630 /* Process Unlocked */
\r
1631 __HAL_UNLOCK(hrtc);
\r
1637 __HAL_RTC_CLOCKREF_DETECTION_DISABLE(hrtc);
\r
1639 /* Exit Initialization mode */
\r
1640 hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;
\r
1643 /* Enable the write protection for RTC registers */
\r
1644 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1646 /* Change RTC state */
\r
1647 hrtc->State = HAL_RTC_STATE_READY;
\r
1649 /* Process Unlocked */
\r
1650 __HAL_UNLOCK(hrtc);
\r
1656 * @brief Enables the Bypass Shadow feature.
\r
1657 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1658 * the configuration information for RTC.
\r
1659 * @note When the Bypass Shadow is enabled the calendar value are taken
\r
1660 * directly from the Calendar counter.
\r
1661 * @retval HAL status
\r
1663 HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef* hrtc)
\r
1665 /* Process Locked */
\r
1668 hrtc->State = HAL_RTC_STATE_BUSY;
\r
1670 /* Disable the write protection for RTC registers */
\r
1671 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
1673 /* Set the BYPSHAD bit */
\r
1674 hrtc->Instance->CR |= (uint8_t)RTC_CR_BYPSHAD;
\r
1676 /* Enable the write protection for RTC registers */
\r
1677 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1679 /* Change RTC state */
\r
1680 hrtc->State = HAL_RTC_STATE_READY;
\r
1682 /* Process Unlocked */
\r
1683 __HAL_UNLOCK(hrtc);
\r
1689 * @brief Disables the Bypass Shadow feature.
\r
1690 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1691 * the configuration information for RTC.
\r
1692 * @note When the Bypass Shadow is enabled the calendar value are taken
\r
1693 * directly from the Calendar counter.
\r
1694 * @retval HAL status
\r
1696 HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef* hrtc)
\r
1698 /* Process Locked */
\r
1701 hrtc->State = HAL_RTC_STATE_BUSY;
\r
1703 /* Disable the write protection for RTC registers */
\r
1704 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
\r
1706 /* Reset the BYPSHAD bit */
\r
1707 hrtc->Instance->CR &= (uint8_t)~RTC_CR_BYPSHAD;
\r
1709 /* Enable the write protection for RTC registers */
\r
1710 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
\r
1712 /* Change RTC state */
\r
1713 hrtc->State = HAL_RTC_STATE_READY;
\r
1715 /* Process Unlocked */
\r
1716 __HAL_UNLOCK(hrtc);
\r
1725 /** @defgroup RTCEx_Group4 Extended features functions
\r
1726 * @brief Extended features functions
\r
1729 ===============================================================================
\r
1730 ##### Extended features functions #####
\r
1731 ===============================================================================
\r
1732 [..] This section provides functions allowing to:
\r
1733 (+) RTC Alram B callback
\r
1734 (+) RTC Poll for Alarm B request
\r
1741 * @brief Alarm B callback.
\r
1742 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1743 * the configuration information for RTC.
\r
1746 __weak void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc)
\r
1748 /* NOTE : This function Should not be modified, when the callback is needed,
\r
1749 the HAL_RTC_AlarmBEventCallback could be implemented in the user file
\r
1754 * @brief This function handles AlarmB Polling request.
\r
1755 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
\r
1756 * the configuration information for RTC.
\r
1757 * @param Timeout: Timeout duration
\r
1758 * @retval HAL status
\r
1760 HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
\r
1762 uint32_t tickstart = 0;
\r
1765 tickstart = HAL_GetTick();
\r
1767 while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBF) == RESET)
\r
1769 if(Timeout != HAL_MAX_DELAY)
\r
1771 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
\r
1773 hrtc->State = HAL_RTC_STATE_TIMEOUT;
\r
1774 return HAL_TIMEOUT;
\r
1779 /* Clear the Alarm Flag */
\r
1780 __HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_FLAG_ALRBF);
\r
1782 /* Change RTC state */
\r
1783 hrtc->State = HAL_RTC_STATE_READY;
\r
1796 #endif /* HAL_RTC_MODULE_ENABLED */
\r
1805 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r