]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_M7_STM32F7_STM32756G-EVAL/ST_Library/stm32f7xx_hal_rtc.c
Final V8.2.1 release ready for tagging:
[freertos] / FreeRTOS / Demo / CORTEX_M7_STM32F7_STM32756G-EVAL / ST_Library / stm32f7xx_hal_rtc.c
diff --git a/FreeRTOS/Demo/CORTEX_M7_STM32F7_STM32756G-EVAL/ST_Library/stm32f7xx_hal_rtc.c b/FreeRTOS/Demo/CORTEX_M7_STM32F7_STM32756G-EVAL/ST_Library/stm32f7xx_hal_rtc.c
deleted file mode 100644 (file)
index ea6fb31..0000000
+++ /dev/null
@@ -1,1543 +0,0 @@
-/**\r
-  ******************************************************************************\r
-  * @file    stm32f7xx_hal_rtc.c\r
-  * @author  MCD Application Team\r
-  * @version V0.3.0\r
-  * @date    06-March-2015\r
-  * @brief   RTC HAL module driver.\r
-  *          This file provides firmware functions to manage the following \r
-  *          functionalities of the Real Time Clock (RTC) peripheral:\r
-  *           + Initialization and de-initialization functions\r
-  *           + RTC Time and Date functions\r
-  *           + RTC Alarm functions\r
-  *           + Peripheral Control functions   \r
-  *           + Peripheral State functions\r
-  *         \r
-  @verbatim\r
-  ==============================================================================\r
-              ##### Backup Domain Operating Condition #####\r
-  ==============================================================================\r
-  [..] The real-time clock (RTC), the RTC backup registers, and the backup \r
-       SRAM (BKP SRAM) can be powered from the VBAT voltage when the main \r
-       VDD supply is powered off.\r
-       To retain the content of the RTC backup registers, backup SRAM, and supply \r
-       the RTC when VDD is turned off, VBAT pin can be connected to an optional \r
-       standby voltage supplied by a battery or by another source.\r
-\r
-  [..] To allow the RTC operating even when the main digital supply (VDD) is turned\r
-       off, the VBAT pin powers the following blocks:\r
-    (#) The RTC\r
-    (#) The LSE oscillator\r
-    (#) The backup SRAM when the low power backup regulator is enabled\r
-    (#) PC13 to PC15 I/Os, plus PI8 I/O (when available)\r
-  \r
-  [..] When the backup domain is supplied by VDD (analog switch connected to VDD),\r
-       the following pins are available:\r
-    (#) PC14 and PC15 can be used as either GPIO or LSE pins\r
-    (#) PC13 can be used as a GPIO or as the RTC_AF1 pin\r
-    (#) PI8 can be used as a GPIO or as the RTC_AF2 pin\r
-  \r
-  [..] When the backup domain is supplied by VBAT (analog switch connected to VBAT \r
-       because VDD is not present), the following pins are available:\r
-    (#) PC14 and PC15 can be used as LSE pins only\r
-    (#) PC13 can be used as the RTC_AF1 pin \r
-    (#) PI8 can be used as the RTC_AF2 pin\r
-    (#) PC1 can be used as the RTC_AF3 pin\r
-             \r
-                   ##### Backup Domain Reset #####\r
-  ==================================================================\r
-  [..] The backup domain reset sets all RTC registers and the RCC_BDCR register \r
-       to their reset values. The BKPSRAM is not affected by this reset. The only\r
-       way to reset the BKPSRAM is through the Flash interface by requesting \r
-       a protection level change from 1 to 0.\r
-  [..] A backup domain reset is generated when one of the following events occurs:\r
-    (#) Software reset, triggered by setting the BDRST bit in the \r
-        RCC Backup domain control register (RCC_BDCR). \r
-    (#) VDD or VBAT power on, if both supplies have previously been powered off.  \r
-\r
-                   ##### Backup Domain Access #####\r
-  ==================================================================\r
-  [..] After reset, the backup domain (RTC registers, RTC backup data \r
-       registers and backup SRAM) is protected against possible unwanted write \r
-       accesses. \r
-  [..] To enable access to the RTC Domain and RTC registers, proceed as follows:\r
-    (+) Enable the Power Controller (PWR) APB1 interface clock using the\r
-        __PWR_CLK_ENABLE() function.\r
-    (+) Enable access to RTC domain using the HAL_PWR_EnableBkUpAccess() function.\r
-    (+) Select the RTC clock source using the __HAL_RCC_RTC_CONFIG() function.\r
-    (+) Enable RTC Clock using the __HAL_RCC_RTC_ENABLE() function.\r
-  \r
-  \r
-                  ##### How to use this driver #####\r
-  ==================================================================\r
-  [..] \r
-    (+) Enable the RTC domain access (see description in the section above).\r
-    (+) Configure the RTC Prescaler (Asynchronous and Synchronous) and RTC hour \r
-        format using the HAL_RTC_Init() function.\r
-  \r
-  *** Time and Date configuration ***\r
-  ===================================\r
-  [..] \r
-    (+) To configure the RTC Calendar (Time and Date) use the HAL_RTC_SetTime() \r
-        and HAL_RTC_SetDate() functions.\r
-    (+) To read the RTC Calendar, use the HAL_RTC_GetTime() and HAL_RTC_GetDate() functions. \r
-  \r
-  *** Alarm configuration ***\r
-  ===========================\r
-  [..]\r
-    (+) To configure the RTC Alarm use the HAL_RTC_SetAlarm() function. \r
-        You can also configure the RTC Alarm with interrupt mode using the HAL_RTC_SetAlarm_IT() function.\r
-    (+) To read the RTC Alarm, use the HAL_RTC_GetAlarm() function.\r
-  \r
-                  ##### RTC and low power modes #####\r
-  ==================================================================\r
-  [..] The MCU can be woken up from a low power mode by an RTC alternate \r
-       function.\r
-  [..] The RTC alternate functions are the RTC alarms (Alarm A and Alarm B), \r
-       RTC wakeup, RTC tamper event detection and RTC time stamp event detection.\r
-       These RTC alternate functions can wake up the system from the Stop and \r
-       Standby low power modes.\r
-  [..] The system can also wake up from low power modes without depending \r
-       on an external interrupt (Auto-wakeup mode), by using the RTC alarm \r
-       or the RTC wakeup events.\r
-  [..] The RTC provides a programmable time base for waking up from the \r
-       Stop or Standby mode at regular intervals.\r
-       Wakeup from STOP and STANDBY modes is possible only when the RTC clock source\r
-       is LSE or LSI.\r
-     \r
-   @endverbatim\r
-  ******************************************************************************\r
-  * @attention\r
-  *\r
-  * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>\r
-  *\r
-  * Redistribution and use in source and binary forms, with or without modification,\r
-  * are permitted provided that the following conditions are met:\r
-  *   1. Redistributions of source code must retain the above copyright notice,\r
-  *      this list of conditions and the following disclaimer.\r
-  *   2. Redistributions in binary form must reproduce the above copyright notice,\r
-  *      this list of conditions and the following disclaimer in the documentation\r
-  *      and/or other materials provided with the distribution.\r
-  *   3. Neither the name of STMicroelectronics nor the names of its contributors\r
-  *      may be used to endorse or promote products derived from this software\r
-  *      without specific prior written permission.\r
-  *\r
-  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
-  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
-  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
-  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
-  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
-  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
-  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
-  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
-  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-  *\r
-  ******************************************************************************\r
-  */ \r
-\r
-/* Includes ------------------------------------------------------------------*/\r
-#include "stm32f7xx_hal.h"\r
-\r
-/** @addtogroup STM32F7xx_HAL_Driver\r
-  * @{\r
-  */\r
-\r
-/** @defgroup RTC RTC\r
-  * @brief RTC HAL module driver\r
-  * @{\r
-  */\r
-\r
-#ifdef HAL_RTC_MODULE_ENABLED\r
-\r
-/* Private typedef -----------------------------------------------------------*/\r
-/* Private define ------------------------------------------------------------*/\r
-/* Private macro -------------------------------------------------------------*/\r
-/* Private variables ---------------------------------------------------------*/\r
-/* Private function prototypes -----------------------------------------------*/\r
-/* Private functions ---------------------------------------------------------*/\r
-\r
-/** @defgroup RTC_Exported_Functions RTC Exported Functions\r
-  * @{\r
-  */\r
-  \r
-/** @defgroup RTC_Group1 Initialization and de-initialization functions \r
- *  @brief    Initialization and Configuration functions \r
- *\r
-@verbatim    \r
- ===============================================================================\r
-              ##### Initialization and de-initialization functions #####\r
- ===============================================================================\r
-   [..] This section provides functions allowing to initialize and configure the \r
-         RTC Prescaler (Synchronous and Asynchronous), RTC Hour format, disable \r
-         RTC registers Write protection, enter and exit the RTC initialization mode, \r
-         RTC registers synchronization check and reference clock detection enable.\r
-         (#) The RTC Prescaler is programmed to generate the RTC 1Hz time base. \r
-             It is split into 2 programmable prescalers to minimize power consumption.\r
-             (++) A 7-bit asynchronous prescaler and a 13-bit synchronous prescaler.\r
-             (++) When both prescalers are used, it is recommended to configure the \r
-                 asynchronous prescaler to a high value to minimize power consumption.\r
-         (#) All RTC registers are Write protected. Writing to the RTC registers\r
-             is enabled by writing a key into the Write Protection register, RTC_WPR.\r
-         (#) To configure the RTC Calendar, user application should enter \r
-             initialization mode. In this mode, the calendar counter is stopped \r
-             and its value can be updated. When the initialization sequence is \r
-             complete, the calendar restarts counting after 4 RTCCLK cycles.\r
-         (#) To read the calendar through the shadow registers after Calendar \r
-             initialization, calendar update or after wakeup from low power modes \r
-             the software must first clear the RSF flag. The software must then \r
-             wait until it is set again before reading the calendar, which means \r
-             that the calendar registers have been correctly copied into the \r
-             RTC_TR and RTC_DR shadow registers.The HAL_RTC_WaitForSynchro() function \r
-             implements the above software sequence (RSF clear and RSF check).\r
\r
-@endverbatim\r
-  * @{\r
-  */\r
-\r
-/**\r
-  * @brief  Initializes the RTC peripheral \r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @retval HAL status\r
-  */\r
-HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc)\r
-{\r
-  /* Check the RTC peripheral state */\r
-  if(hrtc == NULL)\r
-  {\r
-     return HAL_ERROR;\r
-  }\r
-  \r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_ALL_INSTANCE(hrtc->Instance));\r
-  assert_param(IS_RTC_HOUR_FORMAT(hrtc->Init.HourFormat));\r
-  assert_param(IS_RTC_ASYNCH_PREDIV(hrtc->Init.AsynchPrediv));\r
-  assert_param(IS_RTC_SYNCH_PREDIV(hrtc->Init.SynchPrediv));\r
-  assert_param (IS_RTC_OUTPUT(hrtc->Init.OutPut));\r
-  assert_param (IS_RTC_OUTPUT_POL(hrtc->Init.OutPutPolarity));\r
-  assert_param(IS_RTC_OUTPUT_TYPE(hrtc->Init.OutPutType));\r
-    \r
-  if(hrtc->State == HAL_RTC_STATE_RESET)\r
-  {\r
-    /* Initialize RTC MSP */\r
-    HAL_RTC_MspInit(hrtc);\r
-  }\r
-  \r
-  /* Set RTC state */  \r
-  hrtc->State = HAL_RTC_STATE_BUSY;  \r
-       \r
-  /* Disable the write protection for RTC registers */\r
-  __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);\r
-\r
-  /* Set Initialization mode */\r
-  if(RTC_EnterInitMode(hrtc) != HAL_OK)\r
-  {\r
-    /* Enable the write protection for RTC registers */\r
-    __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc); \r
-    \r
-    /* Set RTC state */\r
-    hrtc->State = HAL_RTC_STATE_ERROR;\r
-    \r
-    return HAL_ERROR;\r
-  } \r
-  else\r
-  { \r
-    /* Clear RTC_CR FMT, OSEL and POL Bits */\r
-    hrtc->Instance->CR &= ((uint32_t)~(RTC_CR_FMT | RTC_CR_OSEL | RTC_CR_POL));\r
-    /* Set RTC_CR register */\r
-    hrtc->Instance->CR |= (uint32_t)(hrtc->Init.HourFormat | hrtc->Init.OutPut | hrtc->Init.OutPutPolarity);\r
-    \r
-    /* Configure the RTC PRER */\r
-    hrtc->Instance->PRER = (uint32_t)(hrtc->Init.SynchPrediv);\r
-    hrtc->Instance->PRER |= (uint32_t)(hrtc->Init.AsynchPrediv << 16);\r
-    \r
-    /* Exit Initialization mode */\r
-    hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT; \r
-    \r
-    hrtc->Instance->OR &= (uint32_t)~RTC_OR_ALARMTYPE;\r
-    hrtc->Instance->OR |= (uint32_t)(hrtc->Init.OutPutType); \r
-    \r
-    /* Enable the write protection for RTC registers */\r
-    __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc); \r
-    \r
-    /* Set RTC state */\r
-    hrtc->State = HAL_RTC_STATE_READY;\r
-    \r
-    return HAL_OK;\r
-  }\r
-}\r
-\r
-/**\r
-  * @brief  DeInitializes the RTC peripheral \r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @note   This function doesn't reset the RTC Backup Data registers.   \r
-  * @retval HAL status\r
-  */\r
-HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc)\r
-{\r
-  uint32_t tickstart = 0;\r
-  \r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_ALL_INSTANCE(hrtc->Instance));\r
-\r
-  /* Set RTC state */\r
-  hrtc->State = HAL_RTC_STATE_BUSY; \r
-  \r
-  /* Disable the write protection for RTC registers */\r
-  __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);\r
-  \r
-  /* Set Initialization mode */\r
-  if(RTC_EnterInitMode(hrtc) != HAL_OK)\r
-  {\r
-    /* Enable the write protection for RTC registers */\r
-    __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc); \r
-    \r
-    /* Set RTC state */\r
-    hrtc->State = HAL_RTC_STATE_ERROR;\r
-    \r
-    return HAL_ERROR;\r
-  }  \r
-  else\r
-  {\r
-    /* Reset TR, DR and CR registers */\r
-    hrtc->Instance->TR = (uint32_t)0x00000000;\r
-    hrtc->Instance->DR = (uint32_t)0x00002101;\r
-    /* Reset All CR bits except CR[2:0] */\r
-    hrtc->Instance->CR &= (uint32_t)0x00000007;\r
-\r
-    /* Get tick */\r
-    tickstart = HAL_GetTick();\r
-\r
-    /* Wait till WUTWF flag is set and if Time out is reached exit */\r
-    while(((hrtc->Instance->ISR) & RTC_ISR_WUTWF) == (uint32_t)RESET)\r
-    {\r
-      if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)\r
-      { \r
-        /* Enable the write protection for RTC registers */\r
-        __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc); \r
-        \r
-        /* Set RTC state */\r
-        hrtc->State = HAL_RTC_STATE_TIMEOUT;\r
-        \r
-        return HAL_TIMEOUT;\r
-      }      \r
-    }\r
-    \r
-    /* Reset all RTC CR register bits */\r
-    hrtc->Instance->CR &= (uint32_t)0x00000000;\r
-    hrtc->Instance->WUTR = (uint32_t)0x0000FFFF;\r
-    hrtc->Instance->PRER = (uint32_t)0x007F00FF;\r
-    hrtc->Instance->ALRMAR = (uint32_t)0x00000000;\r
-    hrtc->Instance->ALRMBR = (uint32_t)0x00000000;\r
-    hrtc->Instance->SHIFTR = (uint32_t)0x00000000;\r
-    hrtc->Instance->CALR = (uint32_t)0x00000000;\r
-    hrtc->Instance->ALRMASSR = (uint32_t)0x00000000;\r
-    hrtc->Instance->ALRMBSSR = (uint32_t)0x00000000;\r
-    \r
-    /* Reset ISR register and exit initialization mode */\r
-    hrtc->Instance->ISR = (uint32_t)0x00000000;\r
-    \r
-    /* Reset Tamper and alternate functions configuration register */\r
-    hrtc->Instance->TAMPCR = 0x00000000;\r
-    \r
-    /* Reset Option register */\r
-    hrtc->Instance->OR = 0x00000000;\r
-    \r
-    /* If  RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */\r
-    if((hrtc->Instance->CR & RTC_CR_BYPSHAD) == RESET)\r
-    {\r
-      if(HAL_RTC_WaitForSynchro(hrtc) != HAL_OK)\r
-      {\r
-        /* Enable the write protection for RTC registers */\r
-        __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);  \r
-        \r
-        hrtc->State = HAL_RTC_STATE_ERROR;\r
-        \r
-        return HAL_ERROR;\r
-      }\r
-    }    \r
-  }\r
-  \r
-  /* Enable the write protection for RTC registers */\r
-  __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);\r
-  \r
-  /* De-Initialize RTC MSP */\r
-  HAL_RTC_MspDeInit(hrtc);\r
-  \r
-  hrtc->State = HAL_RTC_STATE_RESET; \r
-\r
-  /* Release Lock */\r
-  __HAL_UNLOCK(hrtc);\r
-\r
-  return HAL_OK;\r
-}\r
-\r
-/**\r
-  * @brief  Initializes the RTC MSP.\r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.  \r
-  * @retval None\r
-  */\r
-__weak void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)\r
-{\r
-  /* NOTE : This function Should not be modified, when the callback is needed,\r
-            the HAL_RTC_MspInit could be implemented in the user file\r
-   */ \r
-}\r
-\r
-/**\r
-  * @brief  DeInitializes the RTC MSP.\r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC. \r
-  * @retval None\r
-  */\r
-__weak void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)\r
-{\r
-  /* NOTE : This function Should not be modified, when the callback is needed,\r
-            the HAL_RTC_MspDeInit could be implemented in the user file\r
-   */ \r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-/** @defgroup RTC_Group2 RTC Time and Date functions\r
- *  @brief   RTC Time and Date functions\r
- *\r
-@verbatim   \r
- ===============================================================================\r
-                 ##### RTC Time and Date functions #####\r
- ===============================================================================  \r
\r
- [..] This section provides functions allowing to configure Time and Date features\r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-\r
-/**\r
-  * @brief  Sets RTC current time.\r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @param  sTime: Pointer to Time structure\r
-  * @param  Format: Specifies the format of the entered parameters.\r
-  *          This parameter can be one of the following values:\r
-  *            @arg FORMAT_BIN: Binary data format \r
-  *            @arg FORMAT_BCD: BCD data format\r
-  * @retval HAL status\r
-  */\r
-HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format)\r
-{\r
-  uint32_t tmpreg = 0;\r
-  \r
- /* Check the parameters */\r
-  assert_param(IS_RTC_FORMAT(Format));\r
-  assert_param(IS_RTC_DAYLIGHT_SAVING(sTime->DayLightSaving));\r
-  assert_param(IS_RTC_STORE_OPERATION(sTime->StoreOperation));\r
-  \r
-  /* Process Locked */ \r
-  __HAL_LOCK(hrtc);\r
-  \r
-  hrtc->State = HAL_RTC_STATE_BUSY;\r
-  \r
-  if(Format == RTC_FORMAT_BIN)\r
-  {\r
-    if((hrtc->Instance->CR & RTC_CR_FMT) != (uint32_t)RESET)\r
-    {\r
-      assert_param(IS_RTC_HOUR12(sTime->Hours));\r
-      assert_param(IS_RTC_HOURFORMAT12(sTime->TimeFormat));\r
-    } \r
-    else\r
-    {\r
-      sTime->TimeFormat = 0x00;\r
-      assert_param(IS_RTC_HOUR24(sTime->Hours));\r
-    }\r
-    assert_param(IS_RTC_MINUTES(sTime->Minutes));\r
-    assert_param(IS_RTC_SECONDS(sTime->Seconds));\r
-    \r
-    tmpreg = (uint32_t)(((uint32_t)RTC_ByteToBcd2(sTime->Hours) << 16) | \\r
-                        ((uint32_t)RTC_ByteToBcd2(sTime->Minutes) << 8) | \\r
-                        ((uint32_t)RTC_ByteToBcd2(sTime->Seconds)) | \\r
-                        (((uint32_t)sTime->TimeFormat) << 16));  \r
-  }\r
-  else\r
-  {\r
-    if((hrtc->Instance->CR & RTC_CR_FMT) != (uint32_t)RESET)\r
-    {\r
-      tmpreg = RTC_Bcd2ToByte(sTime->Hours);\r
-      assert_param(IS_RTC_HOUR12(tmpreg));\r
-      assert_param(IS_RTC_HOURFORMAT12(sTime->TimeFormat)); \r
-    } \r
-    else\r
-    {\r
-      sTime->TimeFormat = 0x00;\r
-      assert_param(IS_RTC_HOUR24(RTC_Bcd2ToByte(sTime->Hours)));\r
-    }\r
-    assert_param(IS_RTC_MINUTES(RTC_Bcd2ToByte(sTime->Minutes)));\r
-    assert_param(IS_RTC_SECONDS(RTC_Bcd2ToByte(sTime->Seconds)));\r
-    tmpreg = (((uint32_t)(sTime->Hours) << 16) | \\r
-              ((uint32_t)(sTime->Minutes) << 8) | \\r
-              ((uint32_t)sTime->Seconds) | \\r
-              ((uint32_t)(sTime->TimeFormat) << 16));   \r
-  }\r
-  \r
-  /* Disable the write protection for RTC registers */\r
-  __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);\r
-  \r
-  /* Set Initialization mode */\r
-  if(RTC_EnterInitMode(hrtc) != HAL_OK)\r
-  {\r
-    /* Enable the write protection for RTC registers */\r
-    __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc); \r
-    \r
-    /* Set RTC state */\r
-    hrtc->State = HAL_RTC_STATE_ERROR;\r
-    \r
-    /* Process Unlocked */ \r
-    __HAL_UNLOCK(hrtc);\r
-    \r
-    return HAL_ERROR;\r
-  } \r
-  else\r
-  {\r
-    /* Set the RTC_TR register */\r
-    hrtc->Instance->TR = (uint32_t)(tmpreg & RTC_TR_RESERVED_MASK);\r
-     \r
-    /* Clear the bits to be configured */\r
-    hrtc->Instance->CR &= (uint32_t)~RTC_CR_BCK;\r
-    \r
-    /* Configure the RTC_CR register */\r
-    hrtc->Instance->CR |= (uint32_t)(sTime->DayLightSaving | sTime->StoreOperation);\r
-    \r
-    /* Exit Initialization mode */\r
-    hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;  \r
-    \r
-    /* If  CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */\r
-    if((hrtc->Instance->CR & RTC_CR_BYPSHAD) == RESET)\r
-    {\r
-      if(HAL_RTC_WaitForSynchro(hrtc) != HAL_OK)\r
-      {        \r
-        /* Enable the write protection for RTC registers */\r
-        __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);  \r
-        \r
-        hrtc->State = HAL_RTC_STATE_ERROR;\r
-        \r
-        /* Process Unlocked */ \r
-        __HAL_UNLOCK(hrtc);\r
-        \r
-        return HAL_ERROR;\r
-      }\r
-    }\r
-    \r
-    /* Enable the write protection for RTC registers */\r
-    __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);\r
-    \r
-   hrtc->State = HAL_RTC_STATE_READY;\r
-  \r
-   __HAL_UNLOCK(hrtc); \r
-     \r
-   return HAL_OK;\r
-  }\r
-}\r
-\r
-/**\r
-  * @brief  Gets RTC current time.\r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @param  sTime: Pointer to Time structure\r
-  * @param  Format: Specifies the format of the entered parameters.\r
-  *          This parameter can be one of the following values:\r
-  *            @arg FORMAT_BIN: Binary data format \r
-  *            @arg FORMAT_BCD: BCD data format\r
-  * @note   You must call HAL_RTC_GetDate() after HAL_RTC_GetTime() to unlock the values \r
-  *         in the higher-order calendar shadow registers to ensure consistency between the time and date values.\r
-  *         Reading RTC current time locks the values in calendar shadow registers until Current date is read.  \r
-  * @retval HAL status\r
-  */\r
-HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format)\r
-{\r
-  uint32_t tmpreg = 0;\r
-\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_FORMAT(Format));\r
-  \r
-  /* Get subseconds values from the correspondent registers*/\r
-  sTime->SubSeconds = (uint32_t)(hrtc->Instance->SSR);\r
-\r
-  /* Get the TR register */\r
-  tmpreg = (uint32_t)(hrtc->Instance->TR & RTC_TR_RESERVED_MASK); \r
-  \r
-  /* Fill the structure fields with the read parameters */\r
-  sTime->Hours = (uint8_t)((tmpreg & (RTC_TR_HT | RTC_TR_HU)) >> 16);\r
-  sTime->Minutes = (uint8_t)((tmpreg & (RTC_TR_MNT | RTC_TR_MNU)) >>8);\r
-  sTime->Seconds = (uint8_t)(tmpreg & (RTC_TR_ST | RTC_TR_SU));\r
-  sTime->TimeFormat = (uint8_t)((tmpreg & (RTC_TR_PM)) >> 16); \r
-  \r
-  /* Check the input parameters format */\r
-  if(Format == RTC_FORMAT_BIN)\r
-  {\r
-    /* Convert the time structure parameters to Binary format */\r
-    sTime->Hours = (uint8_t)RTC_Bcd2ToByte(sTime->Hours);\r
-    sTime->Minutes = (uint8_t)RTC_Bcd2ToByte(sTime->Minutes);\r
-    sTime->Seconds = (uint8_t)RTC_Bcd2ToByte(sTime->Seconds);  \r
-  }\r
-  \r
-  return HAL_OK;\r
-}\r
-\r
-/**\r
-  * @brief  Sets RTC current date.\r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @param  sDate: Pointer to date structure\r
-  * @param  Format: specifies the format of the entered parameters.\r
-  *          This parameter can be one of the following values:\r
-  *            @arg FORMAT_BIN: Binary data format \r
-  *            @arg FORMAT_BCD: BCD data format\r
-  * @retval HAL status\r
-  */\r
-HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format)\r
-{\r
-  uint32_t datetmpreg = 0;\r
-  \r
- /* Check the parameters */\r
-  assert_param(IS_RTC_FORMAT(Format));\r
-  \r
- /* Process Locked */ \r
- __HAL_LOCK(hrtc);\r
-  \r
-  hrtc->State = HAL_RTC_STATE_BUSY; \r
-  \r
-  if((Format == RTC_FORMAT_BIN) && ((sDate->Month & 0x10) == 0x10))\r
-  {\r
-    sDate->Month = (uint8_t)((sDate->Month & (uint8_t)~(0x10)) + (uint8_t)0x0A);\r
-  }\r
-  \r
-  assert_param(IS_RTC_WEEKDAY(sDate->WeekDay));\r
-  \r
-  if(Format == RTC_FORMAT_BIN)\r
-  {   \r
-    assert_param(IS_RTC_YEAR(sDate->Year));\r
-    assert_param(IS_RTC_MONTH(sDate->Month));\r
-    assert_param(IS_RTC_DATE(sDate->Date)); \r
-    \r
-   datetmpreg = (((uint32_t)RTC_ByteToBcd2(sDate->Year) << 16) | \\r
-                 ((uint32_t)RTC_ByteToBcd2(sDate->Month) << 8) | \\r
-                 ((uint32_t)RTC_ByteToBcd2(sDate->Date)) | \\r
-                 ((uint32_t)sDate->WeekDay << 13));   \r
-  }\r
-  else\r
-  {   \r
-    assert_param(IS_RTC_YEAR(RTC_Bcd2ToByte(sDate->Year)));\r
-    datetmpreg = RTC_Bcd2ToByte(sDate->Month);\r
-    assert_param(IS_RTC_MONTH(datetmpreg));\r
-    datetmpreg = RTC_Bcd2ToByte(sDate->Date);\r
-    assert_param(IS_RTC_DATE(datetmpreg));\r
-    \r
-    datetmpreg = ((((uint32_t)sDate->Year) << 16) | \\r
-                  (((uint32_t)sDate->Month) << 8) | \\r
-                  ((uint32_t)sDate->Date) | \\r
-                  (((uint32_t)sDate->WeekDay) << 13));  \r
-  }\r
-\r
-  /* Disable the write protection for RTC registers */\r
-  __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);\r
-  \r
-  /* Set Initialization mode */\r
-  if(RTC_EnterInitMode(hrtc) != HAL_OK)\r
-  {\r
-    /* Enable the write protection for RTC registers */\r
-    __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc); \r
-    \r
-    /* Set RTC state*/\r
-    hrtc->State = HAL_RTC_STATE_ERROR;\r
-    \r
-    /* Process Unlocked */ \r
-    __HAL_UNLOCK(hrtc);\r
-    \r
-    return HAL_ERROR;\r
-  } \r
-  else\r
-  {\r
-    /* Set the RTC_DR register */\r
-    hrtc->Instance->DR = (uint32_t)(datetmpreg & RTC_DR_RESERVED_MASK);\r
-    \r
-    /* Exit Initialization mode */\r
-    hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;  \r
-    \r
-    /* If  CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */\r
-    if((hrtc->Instance->CR & RTC_CR_BYPSHAD) == RESET)\r
-    {\r
-      if(HAL_RTC_WaitForSynchro(hrtc) != HAL_OK)\r
-      { \r
-        /* Enable the write protection for RTC registers */\r
-        __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);  \r
-        \r
-        hrtc->State = HAL_RTC_STATE_ERROR;\r
-        \r
-        /* Process Unlocked */ \r
-        __HAL_UNLOCK(hrtc);\r
-        \r
-        return HAL_ERROR;\r
-      }\r
-    }\r
-    \r
-    /* Enable the write protection for RTC registers */\r
-    __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);  \r
-    \r
-    hrtc->State = HAL_RTC_STATE_READY ;\r
-    \r
-    /* Process Unlocked */ \r
-    __HAL_UNLOCK(hrtc);\r
-    \r
-    return HAL_OK;    \r
-  }\r
-}\r
-\r
-/**\r
-  * @brief  Gets RTC current date.\r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @param  sDate: Pointer to Date structure\r
-  * @param  Format: Specifies the format of the entered parameters.\r
-  *          This parameter can be one of the following values:\r
-  *            @arg FORMAT_BIN:  Binary data format \r
-  *            @arg FORMAT_BCD:  BCD data format\r
-  * @retval HAL status\r
-  */\r
-HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format)\r
-{\r
-  uint32_t datetmpreg = 0;\r
-\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_FORMAT(Format));\r
-          \r
-  /* Get the DR register */\r
-  datetmpreg = (uint32_t)(hrtc->Instance->DR & RTC_DR_RESERVED_MASK); \r
-\r
-  /* Fill the structure fields with the read parameters */\r
-  sDate->Year = (uint8_t)((datetmpreg & (RTC_DR_YT | RTC_DR_YU)) >> 16);\r
-  sDate->Month = (uint8_t)((datetmpreg & (RTC_DR_MT | RTC_DR_MU)) >> 8);\r
-  sDate->Date = (uint8_t)(datetmpreg & (RTC_DR_DT | RTC_DR_DU));\r
-  sDate->WeekDay = (uint8_t)((datetmpreg & (RTC_DR_WDU)) >> 13); \r
-\r
-  /* Check the input parameters format */\r
-  if(Format == RTC_FORMAT_BIN)\r
-  {    \r
-    /* Convert the date structure parameters to Binary format */\r
-    sDate->Year = (uint8_t)RTC_Bcd2ToByte(sDate->Year);\r
-    sDate->Month = (uint8_t)RTC_Bcd2ToByte(sDate->Month);\r
-    sDate->Date = (uint8_t)RTC_Bcd2ToByte(sDate->Date);  \r
-  }\r
-  return HAL_OK;\r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-/** @defgroup RTC_Group3 RTC Alarm functions\r
- *  @brief   RTC Alarm functions\r
- *\r
-@verbatim   \r
- ===============================================================================\r
-                 ##### RTC Alarm functions #####\r
- ===============================================================================  \r
\r
- [..] This section provides functions allowing to configure Alarm feature\r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-/**\r
-  * @brief  Sets the specified RTC Alarm.\r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @param  sAlarm: Pointer to Alarm structure\r
-  * @param  Format: Specifies the format of the entered parameters.\r
-  *          This parameter can be one of the following values:\r
-  *             @arg FORMAT_BIN: Binary data format \r
-  *             @arg FORMAT_BCD: BCD data format\r
-  * @retval HAL status\r
-  */\r
-HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format)\r
-{\r
-  uint32_t tickstart = 0;\r
-  uint32_t tmpreg = 0, subsecondtmpreg = 0;\r
-  \r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_FORMAT(Format));\r
-  assert_param(IS_RTC_ALARM(sAlarm->Alarm));\r
-  assert_param(IS_RTC_ALARM_MASK(sAlarm->AlarmMask));\r
-  assert_param(IS_RTC_ALARM_DATE_WEEKDAY_SEL(sAlarm->AlarmDateWeekDaySel));\r
-  assert_param(IS_RTC_ALARM_SUB_SECOND_VALUE(sAlarm->AlarmTime.SubSeconds));\r
-  assert_param(IS_RTC_ALARM_SUB_SECOND_MASK(sAlarm->AlarmSubSecondMask));\r
-  \r
-  /* Process Locked */ \r
-  __HAL_LOCK(hrtc);\r
-  \r
-  hrtc->State = HAL_RTC_STATE_BUSY;\r
-  \r
-  if(Format == RTC_FORMAT_BIN)\r
-  {\r
-    if((hrtc->Instance->CR & RTC_CR_FMT) != (uint32_t)RESET)\r
-    {\r
-      assert_param(IS_RTC_HOUR12(sAlarm->AlarmTime.Hours));\r
-      assert_param(IS_RTC_HOURFORMAT12(sAlarm->AlarmTime.TimeFormat));\r
-    } \r
-    else\r
-    {\r
-      sAlarm->AlarmTime.TimeFormat = 0x00;\r
-      assert_param(IS_RTC_HOUR24(sAlarm->AlarmTime.Hours));\r
-    }\r
-    assert_param(IS_RTC_MINUTES(sAlarm->AlarmTime.Minutes));\r
-    assert_param(IS_RTC_SECONDS(sAlarm->AlarmTime.Seconds));\r
-    \r
-    if(sAlarm->AlarmDateWeekDaySel == RTC_ALARMDATEWEEKDAYSEL_DATE)\r
-    {\r
-      assert_param(IS_RTC_ALARM_DATE_WEEKDAY_DATE(sAlarm->AlarmDateWeekDay));\r
-    }\r
-    else\r
-    {\r
-      assert_param(IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(sAlarm->AlarmDateWeekDay));\r
-    }\r
-    \r
-    tmpreg = (((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Hours) << 16) | \\r
-              ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Minutes) << 8) | \\r
-              ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Seconds)) | \\r
-              ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << 16) | \\r
-              ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmDateWeekDay) << 24) | \\r
-              ((uint32_t)sAlarm->AlarmDateWeekDaySel) | \\r
-              ((uint32_t)sAlarm->AlarmMask)); \r
-  }\r
-  else\r
-  {\r
-    if((hrtc->Instance->CR & RTC_CR_FMT) != (uint32_t)RESET)\r
-    {\r
-      tmpreg = RTC_Bcd2ToByte(sAlarm->AlarmTime.Hours);\r
-      assert_param(IS_RTC_HOUR12(tmpreg));\r
-      assert_param(IS_RTC_HOURFORMAT12(sAlarm->AlarmTime.TimeFormat));\r
-    } \r
-    else\r
-    {\r
-      sAlarm->AlarmTime.TimeFormat = 0x00;\r
-      assert_param(IS_RTC_HOUR24(RTC_Bcd2ToByte(sAlarm->AlarmTime.Hours)));\r
-    }\r
-    \r
-    assert_param(IS_RTC_MINUTES(RTC_Bcd2ToByte(sAlarm->AlarmTime.Minutes)));\r
-    assert_param(IS_RTC_SECONDS(RTC_Bcd2ToByte(sAlarm->AlarmTime.Seconds)));\r
-    \r
-    if(sAlarm->AlarmDateWeekDaySel == RTC_ALARMDATEWEEKDAYSEL_DATE)\r
-    {\r
-      tmpreg = RTC_Bcd2ToByte(sAlarm->AlarmDateWeekDay);\r
-      assert_param(IS_RTC_ALARM_DATE_WEEKDAY_DATE(tmpreg));    \r
-    }\r
-    else\r
-    {\r
-      tmpreg = RTC_Bcd2ToByte(sAlarm->AlarmDateWeekDay);\r
-      assert_param(IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(tmpreg));      \r
-    }  \r
-    \r
-    tmpreg = (((uint32_t)(sAlarm->AlarmTime.Hours) << 16) | \\r
-              ((uint32_t)(sAlarm->AlarmTime.Minutes) << 8) | \\r
-              ((uint32_t) sAlarm->AlarmTime.Seconds) | \\r
-              ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << 16) | \\r
-              ((uint32_t)(sAlarm->AlarmDateWeekDay) << 24) | \\r
-              ((uint32_t)sAlarm->AlarmDateWeekDaySel) | \\r
-              ((uint32_t)sAlarm->AlarmMask));   \r
-  }\r
-  \r
-  /* Configure the Alarm A or Alarm B Sub Second registers */\r
-  subsecondtmpreg = (uint32_t)((uint32_t)(sAlarm->AlarmTime.SubSeconds) | (uint32_t)(sAlarm->AlarmSubSecondMask));\r
-  \r
-  /* Disable the write protection for RTC registers */\r
-  __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);\r
-\r
-  /* Configure the Alarm register */\r
-  if(sAlarm->Alarm == RTC_ALARM_A)\r
-  {\r
-    /* Disable the Alarm A interrupt */\r
-    __HAL_RTC_ALARMA_DISABLE(hrtc);\r
-    \r
-    /* In case of interrupt mode is used, the interrupt source must disabled */ \r
-    __HAL_RTC_ALARM_DISABLE_IT(hrtc, RTC_IT_ALRA);\r
-\r
-    /* Get tick */\r
-    tickstart = HAL_GetTick();\r
-\r
-    /* Wait till RTC ALRAWF flag is set and if Time out is reached exit */\r
-    while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAWF) == RESET)\r
-    {\r
-      if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)\r
-      {\r
-        /* Enable the write protection for RTC registers */\r
-        __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);\r
-        \r
-        hrtc->State = HAL_RTC_STATE_TIMEOUT; \r
-        \r
-        /* Process Unlocked */ \r
-        __HAL_UNLOCK(hrtc);\r
-        \r
-        return HAL_TIMEOUT;\r
-      }   \r
-    }\r
-    \r
-    hrtc->Instance->ALRMAR = (uint32_t)tmpreg;\r
-    /* Configure the Alarm A Sub Second register */\r
-    hrtc->Instance->ALRMASSR = subsecondtmpreg;\r
-    /* Configure the Alarm state: Enable Alarm */\r
-    __HAL_RTC_ALARMA_ENABLE(hrtc);\r
-  }\r
-  else\r
-  {\r
-    /* Disable the Alarm B interrupt */\r
-    __HAL_RTC_ALARMB_DISABLE(hrtc);\r
-    \r
-    /* In case of interrupt mode is used, the interrupt source must disabled */ \r
-    __HAL_RTC_ALARM_DISABLE_IT(hrtc, RTC_IT_ALRB);\r
-\r
-    /* Get tick */\r
-    tickstart = HAL_GetTick();\r
-\r
-    /* Wait till RTC ALRBWF flag is set and if Time out is reached exit */\r
-    while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBWF) == RESET)\r
-    {\r
-      if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)\r
-      {\r
-        /* Enable the write protection for RTC registers */\r
-        __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);\r
-        \r
-        hrtc->State = HAL_RTC_STATE_TIMEOUT; \r
-        \r
-        /* Process Unlocked */ \r
-        __HAL_UNLOCK(hrtc);\r
-        \r
-        return HAL_TIMEOUT;\r
-      }  \r
-    }    \r
-    \r
-    hrtc->Instance->ALRMBR = (uint32_t)tmpreg;\r
-    /* Configure the Alarm B Sub Second register */\r
-    hrtc->Instance->ALRMBSSR = subsecondtmpreg;\r
-    /* Configure the Alarm state: Enable Alarm */\r
-    __HAL_RTC_ALARMB_ENABLE(hrtc); \r
-  }\r
-  \r
-  /* Enable the write protection for RTC registers */\r
-  __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);   \r
-  \r
-  /* Change RTC state */\r
-  hrtc->State = HAL_RTC_STATE_READY; \r
-  \r
-  /* Process Unlocked */ \r
-  __HAL_UNLOCK(hrtc);\r
-  \r
-  return HAL_OK;\r
-}\r
-\r
-/**\r
-  * @brief  Sets the specified RTC Alarm with Interrupt \r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @param  sAlarm: Pointer to Alarm structure\r
-  * @param  Format: Specifies the format of the entered parameters.\r
-  *          This parameter can be one of the following values:\r
-  *             @arg FORMAT_BIN: Binary data format \r
-  *             @arg FORMAT_BCD: BCD data format\r
-  * @note   The Alarm register can only be written when the corresponding Alarm\r
-  *         is disabled (Use the HAL_RTC_DeactivateAlarm()).   \r
-  * @note   The HAL_RTC_SetTime() must be called before enabling the Alarm feature.   \r
-  * @retval HAL status\r
-  */\r
-HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format)\r
-{\r
-  uint32_t tickstart = 0;\r
-  uint32_t tmpreg = 0, subsecondtmpreg = 0;\r
-  \r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_FORMAT(Format));\r
-  assert_param(IS_RTC_ALARM(sAlarm->Alarm));\r
-  assert_param(IS_RTC_ALARM_MASK(sAlarm->AlarmMask));\r
-  assert_param(IS_RTC_ALARM_DATE_WEEKDAY_SEL(sAlarm->AlarmDateWeekDaySel));\r
-  assert_param(IS_RTC_ALARM_SUB_SECOND_VALUE(sAlarm->AlarmTime.SubSeconds));\r
-  assert_param(IS_RTC_ALARM_SUB_SECOND_MASK(sAlarm->AlarmSubSecondMask));\r
-      \r
-  /* Process Locked */ \r
-  __HAL_LOCK(hrtc);\r
-  \r
-  hrtc->State = HAL_RTC_STATE_BUSY;\r
-  \r
-  if(Format == RTC_FORMAT_BIN)\r
-  {\r
-    if((hrtc->Instance->CR & RTC_CR_FMT) != (uint32_t)RESET)\r
-    {\r
-      assert_param(IS_RTC_HOUR12(sAlarm->AlarmTime.Hours));\r
-      assert_param(IS_RTC_HOURFORMAT12(sAlarm->AlarmTime.TimeFormat));\r
-    } \r
-    else\r
-    {\r
-      sAlarm->AlarmTime.TimeFormat = 0x00;\r
-      assert_param(IS_RTC_HOUR24(sAlarm->AlarmTime.Hours));\r
-    }\r
-    assert_param(IS_RTC_MINUTES(sAlarm->AlarmTime.Minutes));\r
-    assert_param(IS_RTC_SECONDS(sAlarm->AlarmTime.Seconds));\r
-    \r
-    if(sAlarm->AlarmDateWeekDaySel == RTC_ALARMDATEWEEKDAYSEL_DATE)\r
-    {\r
-      assert_param(IS_RTC_ALARM_DATE_WEEKDAY_DATE(sAlarm->AlarmDateWeekDay));\r
-    }\r
-    else\r
-    {\r
-      assert_param(IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(sAlarm->AlarmDateWeekDay));\r
-    }\r
-    tmpreg = (((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Hours) << 16) | \\r
-              ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Minutes) << 8) | \\r
-              ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Seconds)) | \\r
-              ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << 16) | \\r
-              ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmDateWeekDay) << 24) | \\r
-              ((uint32_t)sAlarm->AlarmDateWeekDaySel) | \\r
-              ((uint32_t)sAlarm->AlarmMask)); \r
-  }\r
-  else\r
-  {\r
-    if((hrtc->Instance->CR & RTC_CR_FMT) != (uint32_t)RESET)\r
-    {\r
-      tmpreg = RTC_Bcd2ToByte(sAlarm->AlarmTime.Hours);\r
-      assert_param(IS_RTC_HOUR12(tmpreg));\r
-      assert_param(IS_RTC_HOURFORMAT12(sAlarm->AlarmTime.TimeFormat));\r
-    } \r
-    else\r
-    {\r
-      sAlarm->AlarmTime.TimeFormat = 0x00;\r
-      assert_param(IS_RTC_HOUR24(RTC_Bcd2ToByte(sAlarm->AlarmTime.Hours)));\r
-    }\r
-    \r
-    assert_param(IS_RTC_MINUTES(RTC_Bcd2ToByte(sAlarm->AlarmTime.Minutes)));\r
-    assert_param(IS_RTC_SECONDS(RTC_Bcd2ToByte(sAlarm->AlarmTime.Seconds)));\r
-    \r
-    if(sAlarm->AlarmDateWeekDaySel == RTC_ALARMDATEWEEKDAYSEL_DATE)\r
-    {\r
-      tmpreg = RTC_Bcd2ToByte(sAlarm->AlarmDateWeekDay);\r
-      assert_param(IS_RTC_ALARM_DATE_WEEKDAY_DATE(tmpreg));    \r
-    }\r
-    else\r
-    {\r
-      tmpreg = RTC_Bcd2ToByte(sAlarm->AlarmDateWeekDay);\r
-      assert_param(IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(tmpreg));      \r
-    }\r
-    tmpreg = (((uint32_t)(sAlarm->AlarmTime.Hours) << 16) | \\r
-              ((uint32_t)(sAlarm->AlarmTime.Minutes) << 8) | \\r
-              ((uint32_t) sAlarm->AlarmTime.Seconds) | \\r
-              ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << 16) | \\r
-              ((uint32_t)(sAlarm->AlarmDateWeekDay) << 24) | \\r
-              ((uint32_t)sAlarm->AlarmDateWeekDaySel) | \\r
-              ((uint32_t)sAlarm->AlarmMask));     \r
-  }\r
-  /* Configure the Alarm A or Alarm B Sub Second registers */\r
-  subsecondtmpreg = (uint32_t)((uint32_t)(sAlarm->AlarmTime.SubSeconds) | (uint32_t)(sAlarm->AlarmSubSecondMask));\r
-  \r
-  /* Disable the write protection for RTC registers */\r
-  __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);\r
-  \r
-  /* Configure the Alarm register */\r
-  if(sAlarm->Alarm == RTC_ALARM_A)\r
-  {\r
-    /* Disable the Alarm A interrupt */\r
-    __HAL_RTC_ALARMA_DISABLE(hrtc);\r
-\r
-    /* Clear flag alarm A */\r
-    __HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_FLAG_ALRAF);\r
-\r
-    /* Get tick */\r
-    tickstart = HAL_GetTick();\r
-\r
-    /* Wait till RTC ALRAWF flag is set and if Time out is reached exit */\r
-    while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAWF) == RESET)\r
-    {\r
-      if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)\r
-      {\r
-        /* Enable the write protection for RTC registers */\r
-        __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);\r
-        \r
-        hrtc->State = HAL_RTC_STATE_TIMEOUT; \r
-        \r
-        /* Process Unlocked */ \r
-        __HAL_UNLOCK(hrtc);\r
-        \r
-        return HAL_TIMEOUT;\r
-      }  \r
-    }\r
-    \r
-    hrtc->Instance->ALRMAR = (uint32_t)tmpreg;\r
-    /* Configure the Alarm A Sub Second register */\r
-    hrtc->Instance->ALRMASSR = subsecondtmpreg;\r
-    /* Configure the Alarm state: Enable Alarm */\r
-    __HAL_RTC_ALARMA_ENABLE(hrtc);\r
-    /* Configure the Alarm interrupt */\r
-    __HAL_RTC_ALARM_ENABLE_IT(hrtc,RTC_IT_ALRA);\r
-  }\r
-  else\r
-  {\r
-    /* Disable the Alarm B interrupt */\r
-    __HAL_RTC_ALARMB_DISABLE(hrtc);\r
-\r
-    /* Clear flag alarm B */\r
-    __HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_FLAG_ALRBF);\r
-\r
-    /* Get tick */\r
-    tickstart = HAL_GetTick();\r
-\r
-    /* Wait till RTC ALRBWF flag is set and if Time out is reached exit */\r
-    while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBWF) == RESET)\r
-    {\r
-      if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)\r
-      {\r
-        /* Enable the write protection for RTC registers */\r
-        __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);\r
-        \r
-        hrtc->State = HAL_RTC_STATE_TIMEOUT; \r
-        \r
-        /* Process Unlocked */ \r
-        __HAL_UNLOCK(hrtc);\r
-        \r
-        return HAL_TIMEOUT;\r
-      }  \r
-    }\r
-\r
-    hrtc->Instance->ALRMBR = (uint32_t)tmpreg;\r
-    /* Configure the Alarm B Sub Second register */\r
-    hrtc->Instance->ALRMBSSR = subsecondtmpreg;\r
-    /* Configure the Alarm state: Enable Alarm */\r
-    __HAL_RTC_ALARMB_ENABLE(hrtc);\r
-    /* Configure the Alarm interrupt */\r
-    __HAL_RTC_ALARM_ENABLE_IT(hrtc, RTC_IT_ALRB);\r
-  }\r
-\r
-  /* RTC Alarm Interrupt Configuration: EXTI configuration */\r
-  __HAL_RTC_ALARM_EXTI_ENABLE_IT();\r
-  \r
-  EXTI->RTSR |= RTC_EXTI_LINE_ALARM_EVENT;\r
-  \r
-  /* Enable the write protection for RTC registers */\r
-  __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);  \r
-  \r
-  hrtc->State = HAL_RTC_STATE_READY; \r
-  \r
-  /* Process Unlocked */ \r
-  __HAL_UNLOCK(hrtc);  \r
-  \r
-  return HAL_OK;\r
-}\r
-\r
-/**\r
-  * @brief  Deactive the specified RTC Alarm \r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @param  Alarm: Specifies the Alarm.\r
-  *          This parameter can be one of the following values:\r
-  *            @arg RTC_ALARM_A:  AlarmA\r
-  *            @arg RTC_ALARM_B:  AlarmB\r
-  * @retval HAL status\r
-  */\r
-HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm)\r
-{\r
-  uint32_t tickstart = 0;\r
-  \r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_ALARM(Alarm));\r
-  \r
-  /* Process Locked */ \r
-  __HAL_LOCK(hrtc);\r
-  \r
-  hrtc->State = HAL_RTC_STATE_BUSY;\r
-  \r
-  /* Disable the write protection for RTC registers */\r
-  __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);\r
-  \r
-  if(Alarm == RTC_ALARM_A)\r
-  {\r
-    /* AlarmA */\r
-    __HAL_RTC_ALARMA_DISABLE(hrtc);\r
-    \r
-    /* In case of interrupt mode is used, the interrupt source must disabled */ \r
-    __HAL_RTC_ALARM_DISABLE_IT(hrtc, RTC_IT_ALRA);\r
-\r
-    /* Get tick */\r
-    tickstart = HAL_GetTick();\r
-\r
-    /* Wait till RTC ALRxWF flag is set and if Time out is reached exit */\r
-    while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAWF) == RESET)\r
-    {\r
-      if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)\r
-      { \r
-        /* Enable the write protection for RTC registers */\r
-        __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);\r
-        \r
-        hrtc->State = HAL_RTC_STATE_TIMEOUT; \r
-        \r
-        /* Process Unlocked */ \r
-        __HAL_UNLOCK(hrtc);\r
-        \r
-        return HAL_TIMEOUT;\r
-      }      \r
-    }\r
-  }\r
-  else\r
-  {\r
-    /* AlarmB */\r
-    __HAL_RTC_ALARMB_DISABLE(hrtc);\r
-    \r
-    /* In case of interrupt mode is used, the interrupt source must disabled */ \r
-    __HAL_RTC_ALARM_DISABLE_IT(hrtc,RTC_IT_ALRB);\r
-\r
-    /* Get tick */\r
-    tickstart = HAL_GetTick();\r
-\r
-    /* Wait till RTC ALRxWF flag is set and if Time out is reached exit */\r
-    while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBWF) == RESET)\r
-    {\r
-      if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)\r
-      {\r
-        /* Enable the write protection for RTC registers */\r
-        __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);\r
-        \r
-        hrtc->State = HAL_RTC_STATE_TIMEOUT; \r
-        \r
-        /* Process Unlocked */ \r
-        __HAL_UNLOCK(hrtc);\r
-        \r
-        return HAL_TIMEOUT;\r
-      }    \r
-    }\r
-  }\r
-  /* Enable the write protection for RTC registers */\r
-  __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);\r
-  \r
-  hrtc->State = HAL_RTC_STATE_READY; \r
-  \r
-  /* Process Unlocked */ \r
-  __HAL_UNLOCK(hrtc);  \r
-  \r
-  return HAL_OK; \r
-}\r
-           \r
-/**\r
-  * @brief  Gets the RTC Alarm value and masks.\r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @param  sAlarm: Pointer to Date structure\r
-  * @param  Alarm: Specifies the Alarm.\r
-  *          This parameter can be one of the following values:\r
-  *             @arg RTC_ALARM_A: AlarmA\r
-  *             @arg RTC_ALARM_B: AlarmB  \r
-  * @param  Format: Specifies the format of the entered parameters.\r
-  *          This parameter can be one of the following values:\r
-  *             @arg FORMAT_BIN: Binary data format \r
-  *             @arg FORMAT_BCD: BCD data format\r
-  * @retval HAL status\r
-  */\r
-HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format)\r
-{\r
-  uint32_t tmpreg = 0, subsecondtmpreg = 0;\r
-  \r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_FORMAT(Format));\r
-  assert_param(IS_RTC_ALARM(Alarm));\r
-  \r
-  if(Alarm == RTC_ALARM_A)\r
-  {\r
-    /* AlarmA */\r
-    sAlarm->Alarm = RTC_ALARM_A;\r
-    \r
-    tmpreg = (uint32_t)(hrtc->Instance->ALRMAR);\r
-    subsecondtmpreg = (uint32_t)((hrtc->Instance->ALRMASSR ) & RTC_ALRMASSR_SS);\r
-  }\r
-  else\r
-  {\r
-    sAlarm->Alarm = RTC_ALARM_B;\r
-    \r
-    tmpreg = (uint32_t)(hrtc->Instance->ALRMBR);\r
-    subsecondtmpreg = (uint32_t)((hrtc->Instance->ALRMBSSR) & RTC_ALRMBSSR_SS);\r
-  }\r
-    \r
-  /* Fill the structure with the read parameters */\r
-  sAlarm->AlarmTime.Hours = (uint32_t)((tmpreg & (RTC_ALRMAR_HT | RTC_ALRMAR_HU)) >> 16);\r
-  sAlarm->AlarmTime.Minutes = (uint32_t)((tmpreg & (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU)) >> 8);\r
-  sAlarm->AlarmTime.Seconds = (uint32_t)(tmpreg & (RTC_ALRMAR_ST | RTC_ALRMAR_SU));\r
-  sAlarm->AlarmTime.TimeFormat = (uint32_t)((tmpreg & RTC_ALRMAR_PM) >> 16);\r
-  sAlarm->AlarmTime.SubSeconds = (uint32_t) subsecondtmpreg;\r
-  sAlarm->AlarmDateWeekDay = (uint32_t)((tmpreg & (RTC_ALRMAR_DT | RTC_ALRMAR_DU)) >> 24);\r
-  sAlarm->AlarmDateWeekDaySel = (uint32_t)(tmpreg & RTC_ALRMAR_WDSEL);\r
-  sAlarm->AlarmMask = (uint32_t)(tmpreg & RTC_ALARMMASK_ALL);\r
-    \r
-  if(Format == RTC_FORMAT_BIN)\r
-  {\r
-    sAlarm->AlarmTime.Hours = RTC_Bcd2ToByte(sAlarm->AlarmTime.Hours);\r
-    sAlarm->AlarmTime.Minutes = RTC_Bcd2ToByte(sAlarm->AlarmTime.Minutes);\r
-    sAlarm->AlarmTime.Seconds = RTC_Bcd2ToByte(sAlarm->AlarmTime.Seconds);\r
-    sAlarm->AlarmDateWeekDay = RTC_Bcd2ToByte(sAlarm->AlarmDateWeekDay);\r
-  }  \r
-    \r
-  return HAL_OK;\r
-}\r
-\r
-/**\r
-  * @brief  This function handles Alarm interrupt request.\r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @retval None\r
-  */\r
-void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef* hrtc)\r
-{  \r
-  if(__HAL_RTC_ALARM_GET_IT(hrtc, RTC_IT_ALRA))\r
-  {\r
-    /* Get the status of the Interrupt */\r
-    if((uint32_t)(hrtc->Instance->CR & RTC_IT_ALRA) != (uint32_t)RESET)\r
-    {\r
-      /* AlarmA callback */ \r
-      HAL_RTC_AlarmAEventCallback(hrtc);\r
-      \r
-      /* Clear the Alarm interrupt pending bit */\r
-      __HAL_RTC_ALARM_CLEAR_FLAG(hrtc,RTC_FLAG_ALRAF);\r
-    }\r
-  }\r
-  \r
-  if(__HAL_RTC_ALARM_GET_IT(hrtc, RTC_IT_ALRB))\r
-  {\r
-    /* Get the status of the Interrupt */\r
-    if((uint32_t)(hrtc->Instance->CR & RTC_IT_ALRB) != (uint32_t)RESET)\r
-    {\r
-      /* AlarmB callback */ \r
-      HAL_RTCEx_AlarmBEventCallback(hrtc);\r
-      \r
-      /* Clear the Alarm interrupt pending bit */\r
-      __HAL_RTC_ALARM_CLEAR_FLAG(hrtc,RTC_FLAG_ALRBF);\r
-    }\r
-  }\r
-  \r
-  /* Clear the EXTI's line Flag for RTC Alarm */\r
-  __HAL_RTC_ALARM_EXTI_CLEAR_FLAG();\r
-  \r
-  /* Change RTC state */\r
-  hrtc->State = HAL_RTC_STATE_READY;\r
-}\r
-\r
-/**\r
-  * @brief  Alarm A callback.\r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @retval None\r
-  */\r
-__weak void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)\r
-{\r
-  /* NOTE : This function Should not be modified, when the callback is needed,\r
-            the HAL_RTC_AlarmAEventCallback could be implemented in the user file\r
-   */\r
-}\r
-\r
-/**\r
-  * @brief  This function handles AlarmA Polling request.\r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @param  Timeout: Timeout duration\r
-  * @retval HAL status\r
-  */\r
-HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)\r
-{\r
-  uint32_t tickstart = 0; \r
-\r
-    /* Get tick */\r
-    tickstart = HAL_GetTick();\r
-\r
-  while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAF) == RESET)\r
-  {\r
-    if(Timeout != HAL_MAX_DELAY)\r
-    {\r
-      if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))\r
-      {\r
-        hrtc->State = HAL_RTC_STATE_TIMEOUT;\r
-        return HAL_TIMEOUT;\r
-      }\r
-    }\r
-  }\r
-  \r
-  /* Clear the Alarm interrupt pending bit */\r
-  __HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_FLAG_ALRAF);\r
-  \r
-  /* Change RTC state */\r
-  hrtc->State = HAL_RTC_STATE_READY; \r
-  \r
-  return HAL_OK;  \r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-/** @defgroup RTC_Group4 Peripheral Control functions \r
- *  @brief   Peripheral Control functions \r
- *\r
-@verbatim   \r
- ===============================================================================\r
-                     ##### Peripheral Control functions #####\r
- ===============================================================================  \r
-    [..]\r
-    This subsection provides functions allowing to\r
-      (+) Wait for RTC Time and Date Synchronization\r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-\r
-/**\r
-  * @brief  Waits until the RTC Time and Date registers (RTC_TR and RTC_DR) are \r
-  *         synchronized with RTC APB clock.\r
-  * @note   The RTC Resynchronization mode is write protected, use the \r
-  *         __HAL_RTC_WRITEPROTECTION_DISABLE() before calling this function. \r
-  * @note   To read the calendar through the shadow registers after Calendar \r
-  *         initialization, calendar update or after wakeup from low power modes \r
-  *         the software must first clear the RSF flag. \r
-  *         The software must then wait until it is set again before reading \r
-  *         the calendar, which means that the calendar registers have been \r
-  *         correctly copied into the RTC_TR and RTC_DR shadow registers.   \r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @retval HAL status\r
-  */\r
-HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef* hrtc)\r
-{\r
-  uint32_t tickstart = 0;\r
-\r
-  /* Clear RSF flag */\r
-  hrtc->Instance->ISR &= (uint32_t)RTC_RSF_MASK;\r
-\r
-    /* Get tick */\r
-    tickstart = HAL_GetTick();\r
-\r
-  /* Wait the registers to be synchronised */\r
-  while((hrtc->Instance->ISR & RTC_ISR_RSF) == (uint32_t)RESET)\r
-  {\r
-    if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)\r
-    {       \r
-      return HAL_TIMEOUT;\r
-    } \r
-  }\r
-\r
-  return HAL_OK;\r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-  \r
-/** @defgroup RTC_Group5 Peripheral State functions \r
- *  @brief   Peripheral State functions \r
- *\r
-@verbatim   \r
- ===============================================================================\r
-                     ##### Peripheral State functions #####\r
- ===============================================================================  \r
-    [..]\r
-    This subsection provides functions allowing to\r
-      (+) Get RTC state\r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-/**\r
-  * @brief  Returns the RTC state.\r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @retval HAL state\r
-  */\r
-HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef* hrtc)\r
-{\r
-  return hrtc->State;\r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-/**\r
-  * @brief  Enters the RTC Initialization mode.\r
-  * @note   The RTC Initialization mode is write protected, use the\r
-  *         __HAL_RTC_WRITEPROTECTION_DISABLE() before calling this function.\r
-  * @param  hrtc: pointer to a RTC_HandleTypeDef structure that contains\r
-  *                the configuration information for RTC.\r
-  * @retval HAL status\r
-  */\r
-HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef* hrtc)\r
-{\r
-  uint32_t tickstart = 0; \r
-  \r
-  /* Check if the Initialization mode is set */\r
-  if((hrtc->Instance->ISR & RTC_ISR_INITF) == (uint32_t)RESET)\r
-  {\r
-    /* Set the Initialization mode */\r
-    hrtc->Instance->ISR = (uint32_t)RTC_INIT_MASK;\r
-\r
-    /* Get tick */\r
-    tickstart = HAL_GetTick();\r
-\r
-    /* Wait till RTC is in INIT state and if Time out is reached exit */\r
-    while((hrtc->Instance->ISR & RTC_ISR_INITF) == (uint32_t)RESET)\r
-    {\r
-      if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)\r
-      {       \r
-        return HAL_TIMEOUT;\r
-      } \r
-    }\r
-  }\r
-  \r
-  return HAL_OK;  \r
-}\r
-\r
-\r
-/**\r
-  * @brief  Converts a 2 digit decimal to BCD format.\r
-  * @param  Value: Byte to be converted\r
-  * @retval Converted byte\r
-  */\r
-uint8_t RTC_ByteToBcd2(uint8_t Value)\r
-{\r
-  uint32_t bcdhigh = 0;\r
-  \r
-  while(Value >= 10)\r
-  {\r
-    bcdhigh++;\r
-    Value -= 10;\r
-  }\r
-  \r
-  return  ((uint8_t)(bcdhigh << 4) | Value);\r
-}\r
-\r
-/**\r
-  * @brief  Converts from 2 digit BCD to Binary.\r
-  * @param  Value: BCD value to be converted\r
-  * @retval Converted word\r
-  */\r
-uint8_t RTC_Bcd2ToByte(uint8_t Value)\r
-{\r
-  uint32_t tmp = 0;\r
-  tmp = ((uint8_t)(Value & (uint8_t)0xF0) >> (uint8_t)0x4) * 10;\r
-  return (tmp + (Value & (uint8_t)0x0F));\r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-#endif /* HAL_RTC_MODULE_ENABLED */\r
-/**\r
-  * @}\r
-  */\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r