Restructure libs source to support multi platform
[fw/stlink] / example / libstm32l_discovery / src / stm32l1xx_rtc.c
diff --git a/example/libstm32l_discovery/src/stm32l1xx_rtc.c b/example/libstm32l_discovery/src/stm32l1xx_rtc.c
deleted file mode 100644 (file)
index fbcf679..0000000
+++ /dev/null
@@ -1,2138 +0,0 @@
-/**\r
-  ******************************************************************************\r
-  * @file    stm32l1xx_rtc.c\r
-  * @author  MCD Application Team\r
-  * @version V1.0.0\r
-  * @date    31-December-2010\r
-  * @brief   This file provides firmware functions to manage the following \r
-  *          functionalities of the Real-Time Clock (RTC) peripheral:           \r
-  *           - Initialization\r
-  *           - Calendar (Time and Date) configuration\r
-  *           - Alarms (Alarm A and Alarm B) configuration\r
-  *           - WakeUp Timer configuration\r
-  *           - Daylight Saving configuration\r
-  *           - Output pin Configuration\r
-  *           - Digital Calibration configuration\r
-  *           - TimeStamp configuration\r
-  *           - Tampers configuration\r
-  *           - Backup Data Registers configuration\r
-  *           - Output Type Config configuration\r
-  *           - Interrupts and flags management       \r
-  *                     \r
-  *  @verbatim\r
-  *       \r
-  *          ===================================================================      \r
-  *                                    RTC Domain Reset\r
-  *          ===================================================================          \r
-  *          After power-on reset, the RTC domain (RTC clock source configuration,\r
-  *          RTC registers and RTC Backup data registers) is reset. You can also\r
-  *          reset this domain by software using the RCC_RTCResetCmd() function.        \r
-  *         \r
-  *          ===================================================================      \r
-  *                                  RTC Operating Condition\r
-  *          ===================================================================            \r
-  *          As long as the supply voltage remains in the operating range, \r
-  *          the RTC never stops, regardless of the device status (Run mode, \r
-  *          low power modes or under reset).\r
-  *              \r
-  *          ===================================================================      \r
-  *                                   RTC Domain Access\r
-  *          ===================================================================          \r
-  *          After reset, the RTC domain (RTC clock source configuration,\r
-  *          RTC registers and RTC Backup data registers) are protected against \r
-  *          possible stray write 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
-  *              RCC_APB1PeriphClockCmd() function.\r
-  *            - Enable access to RTC domain using the PWR_RTCAccessCmd() function.\r
-  *            - Select the RTC clock source using the RCC_RTCCLKConfig() function.\r
-  *            - Enable RTC Clock using the RCC_RTCCLKCmd() function.\r
-  *              \r
-  *          ===================================================================      \r
-  *                                   RTC Driver: how to use it\r
-  *          ===================================================================          \r
-  *            - Enable the RTC domain access (see description in the section above)\r
-  *            - Configure the RTC Prescaler (Asynchronous and Synchronous) and\r
-  *              RTC hour format using the RTC_Init() function.\r
-  *                \r
-  *          Time and Date configuration\r
-  *          ===========================    \r
-  *            - To configure the RTC Calendar (Time and Date) use the RTC_SetTime()\r
-  *              and RTC_SetDate() functions.\r
-  *            - To read the RTC Calendar, use the RTC_GetTime() and RTC_GetDate()\r
-  *              functions.\r
-  *            - Use the RTC_DayLightSavingConfig() function to add or sub one\r
-  *              hour to the RTC Calendar.    \r
-  *                \r
-  *          Alarm configuration\r
-  *          ===================    \r
-  *            - To configure the RTC Alarm use the RTC_SetAlarm() function.\r
-  *            - Enable the selected RTC Alarm using the RTC_AlarmCmd() function  \r
-  *            - To read the RTC Alarm, use the RTC_GetAlarm() function.\r
-  *              \r
-  *          RTC Wakeup configuration\r
-  *          ========================    \r
-  *            - Configure the RTC Wakeup Clock source use the RTC_WakeUpClockConfig()\r
-  *              function.\r
-  *            - Configure the RTC WakeUp Counter using the RTC_SetWakeUpCounter() \r
-  *              function  \r
-  *            - Enable the RTC WakeUp using the RTC_WakeUpCmd() function  \r
-  *            - To read the RTC WakeUp Counter register, use the RTC_GetWakeUpCounter() \r
-  *              function.\r
-  *                \r
-  *          Outputs configuration\r
-  *          =====================  \r
-  *          The RTC has 2 different outputs:\r
-  *            - AFO_ALARM: this output is used to manage the RTC Alarm A, Alarm B\r
-  *              and WaKeUp signals.          \r
-  *              To output the selected RTC signal on RTC_AF1 pin, use the \r
-  *              RTC_OutputConfig() function.                \r
-  *            - AFO_CALIB: this output is used to manage the RTC Clock divided \r
-  *              by 64 (512Hz) signal.\r
-  *              To output the RTC Clock on RTC_AF1 pin, use the RTC_CalibOutputCmd()\r
-  *              function.                \r
-  *                                                           \r
-  *          Digital Calibration configuration\r
-  *          =================================    \r
-  *            - Configure the RTC Digital Calibration Value and the corresponding\r
-  *              sign using the RTC_DigitalCalibConfig() function.\r
-  *            - Enable the RTC Digital Calibration using the RTC_DigitalCalibCmd() \r
-  *              function  \r
-  *                \r
-  *          TimeStamp configuration\r
-  *          =======================    \r
-  *            - Configure the RTC_AF1 trigger and enables the RTC TimeStamp \r
-  *              using the RTC_TimeStampCmd() function.\r
-  *            - To read the RTC TimeStamp Time and Date register, use the \r
-  *              RTC_GetTimeStamp() function.  \r
-  *\r
-  *          Tamper configuration\r
-  *          ====================    \r
-  *            - Configure the RTC Tamper trigger using the RTC_TamperConfig() \r
-  *              function.\r
-  *            - Enable the RTC Tamper using the RTC_TamperCmd() function.\r
-  *\r
-  *          Backup Data Registers configuration\r
-  *          ===================================    \r
-  *            - To write to the RTC Backup Data registers, use the RTC_WriteBackupRegister()\r
-  *              function.  \r
-  *            - To read the RTC Backup Data registers, use the RTC_ReadBackupRegister()\r
-  *              function.  \r
-  *                                  \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 \r
-  *           and Standby lowpower 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 \r
-  *           clock source is LSE or LSI.\r
-  *           \r
-  *          ===================================================================      \r
-  *                            Selection of RTC_AF1 alternate functions\r
-  *          ===================================================================     \r
-  *          The RTC_AF1 pin (PC13) can be used for the following purposes:\r
-  *            - Wakeup pin 2 (WKUP2) using the PWR_WakeUpPinCmd() function.\r
-  *            - AFO_ALARM output       \r
-  *            - AFO_CALIB output\r
-  *            - AFI_TAMPER\r
-  *            - AFI_TIMESTAMP\r
-  *                         \r
-  * +------------------------------------------------------------------------------------------+     \r
-  * |     Pin         |AFO_ALARM |AFO_CALIB |AFI_TAMPER |AFI_TIMESTAMP | WKUP2  |ALARMOUTTYPE  |\r
-  * |  configuration  | ENABLED  | ENABLED  |  ENABLED  |   ENABLED    |ENABLED |  AFO_ALARM   |\r
-  * |  and function   |          |          |           |              |        |Configuration |\r
-  * |-----------------|----------|----------|-----------|--------------|--------|--------------|             \r
-  * |   Alarm out     |          |          |           |              | Don't  |              |\r
-  * |   output OD     |     1    |    0     |Don't care | Don't care   | care   |      0       |\r
-  * |-----------------|----------|----------|-----------|--------------|--------|--------------|  \r
-  * |   Alarm out     |          |          |           |              | Don't  |              |\r
-  * |   output PP     |     1    |    0     |Don't care | Don't care   | care   |      1       |\r
-  * |-----------------|----------|----------|-----------|--------------|--------|--------------|  \r
-  * | Calibration out |          |          |           |              | Don't  |              |\r
-  * |   output PP     |     0    |    1     |Don't care | Don't care   | care   |  Don't care  |\r
-  * |-----------------|----------|----------|-----------|--------------|--------|--------------|  \r
-  * |  TAMPER input   |          |          |           |              | Don't  |              | \r
-  * |   floating      |     0    |    0     |     1     |      0       | care   |  Don't care  |\r
-  * |-----------------|----------|----------|-----------|--------------|--------|--------------|  \r
-  * |  TIMESTAMP and  |          |          |           |              | Don't  |              |\r
-  * |  TAMPER input   |     0    |    0     |     1     |      1       | care   |  Don't care  |\r
-  * |   floating      |          |          |           |              |        |              |                 \r
-  * |-----------------|----------|----------|-----------|--------------|--------|--------------|  \r
-  * | TIMESTAMP input |          |          |           |              | Don't  |              | \r
-  * |    floating     |     0    |    0     |     0     |      1       | care   |  Don't care  |                 \r
-  * |-----------------|----------|----------|-----------|--------------|--------|--------------|  \r
-  * |  Wakeup Pin 2   |     0    |    0     |     0     |      0       |   1    |  Don't care  |                 \r
-  * |-----------------|----------|----------|-----------|--------------|--------|--------------|  \r
-  * |  Standard GPIO  |     0    |    0     |     0     |      0       |   0    |  Don't care  |             \r
-  * +------------------------------------------------------------------------------------------+  \r
-  *\r
-  *  @endverbatim\r
-  *                      \r
-  ******************************************************************************\r
-  * @attention\r
-  *\r
-  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
-  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE\r
-  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY\r
-  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING\r
-  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE\r
-  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
-  *\r
-  * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>\r
-  ******************************************************************************  \r
-  */ \r
-\r
-/* Includes ------------------------------------------------------------------*/\r
-#include "stm32l1xx_rtc.h"\r
-#include "stm32l1xx_rcc.h"\r
-\r
-/** @addtogroup STM32L1xx_StdPeriph_Driver\r
-  * @{\r
-  */\r
-\r
-/** @defgroup RTC \r
-  * @brief RTC driver modules\r
-  * @{\r
-  */\r
-\r
-/* Private typedef -----------------------------------------------------------*/\r
-/* Private define ------------------------------------------------------------*/\r
-\r
-/* Masks Definition */\r
-#define RTC_TR_RESERVED_MASK    ((uint32_t)0x007F7F7F)\r
-#define RTC_DR_RESERVED_MASK    ((uint32_t)0x00FFFF3F) \r
-#define RTC_INIT_MASK           ((uint32_t)0xFFFFFFFF)  \r
-#define RTC_RSF_MASK            ((uint32_t)0xFFFFFF5F)\r
-#define RTC_FLAGS_MASK          ((uint32_t)(RTC_FLAG_TSOVF | RTC_FLAG_TSF | RTC_FLAG_WUTF | \\r
-                                            RTC_FLAG_ALRBF | RTC_FLAG_ALRAF | RTC_FLAG_INITF | \\r
-                                            RTC_FLAG_RSF | RTC_FLAG_INITS | RTC_FLAG_WUTWF | \\r
-                                            RTC_FLAG_ALRBWF | RTC_FLAG_ALRAWF | RTC_FLAG_TAMP1F ))\r
-\r
-#define INITMODE_TIMEOUT         ((uint32_t) 0x00002000)\r
-#define SYNCHRO_TIMEOUT          ((uint32_t) 0x00001000)\r
-\r
-/* Private macro -------------------------------------------------------------*/\r
-/* Private variables ---------------------------------------------------------*/\r
-/* Private function prototypes -----------------------------------------------*/\r
-static uint8_t RTC_ByteToBcd2(uint8_t Value);\r
-static uint8_t RTC_Bcd2ToByte(uint8_t Value);\r
-\r
-/* Private functions ---------------------------------------------------------*/\r
-\r
-/** @defgroup RTC_Private_Functions\r
-  * @{\r
-  */ \r
-\r
-/** @defgroup RTC_Group1 Initialization and Configuration functions\r
- *  @brief   Initialization and Configuration functions \r
- *\r
-@verbatim   \r
- ===============================================================================\r
-                 Initialization and Configuration functions\r
- ===============================================================================  \r
-\r
-  This section provide functions allowing to initialize and configure the RTC\r
-  Prescaler (Synchronous and Asynchronous), RTC Hour format, disable RTC registers\r
-  Write protection, enter and exit the RTC initialization mode, RTC registers\r
-  synchronization check and reference clock detection enable.\r
-  \r
-  1. The RTC Prescaler is programmed to generate the RTC 1Hz time base. It is\r
-     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 asynchronous\r
-       prescaler to a high value to minimize consumption.\r
-\r
-  2. 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
-\r
-  3. To Configure the RTC Calendar, user application should enter initialization\r
-     mode. In this mode, the calendar counter is stopped and its value can be \r
-     updated. When the initialization sequence is complete, the calendar restarts \r
-     counting after 4 RTCCLK cycles.\r
-\r
-  4. To read the calendar through the shadow registers after Calendar initialization,\r
-     calendar update or after wakeup from low power modes the software must first \r
-     clear the RSF flag. The software must then wait until it is set again before \r
-     reading the calendar, which means that the calendar registers have been \r
-     correctly copied into the RTC_TR and RTC_DR shadow registers.\r
-     The RTC_WaitForSynchro() function implements the above software sequence \r
-     (RSF clear and RSF check).\r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-\r
-/**\r
-  * @brief  Deinitializes the RTC registers to their default reset values.\r
-  * @note   This function doesn't reset the RTC Clock source and RTC Backup Data\r
-  *         registers.       \r
-  * @param  None\r
-  * @retval An ErrorStatus enumeration value:\r
-  *          - SUCCESS: RTC registers are deinitialized\r
-  *          - ERROR: RTC registers are not deinitialized\r
-  */\r
-ErrorStatus RTC_DeInit(void)\r
-{\r
-  __IO uint32_t wutcounter = 0x00;\r
-  uint32_t wutwfstatus = 0x00;\r
-  ErrorStatus status = ERROR;\r
-  \r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-\r
-  /* Set Initialization mode */\r
-  if (RTC_EnterInitMode() == ERROR)\r
-  {\r
-    status = ERROR;\r
-  }  \r
-  else\r
-  {\r
-    /* Reset TR, DR and CR registers */\r
-    RTC->TR = (uint32_t)0x00000000;\r
-    RTC->DR = (uint32_t)0x00002101;\r
-    /* Reset All CR bits except CR[2:0] */\r
-    RTC->CR &= (uint32_t)0x00000007;\r
-  \r
-    /* Wait till RTC WUTWF flag is set and if Time out is reached exit */\r
-    do\r
-    {\r
-      wutwfstatus = RTC->ISR & RTC_ISR_WUTWF;\r
-      wutcounter++;  \r
-    } while((wutcounter != INITMODE_TIMEOUT) && (wutwfstatus == 0x00));\r
-    \r
-    if ((RTC->ISR & RTC_ISR_WUTWF) == RESET)\r
-    {\r
-      status = ERROR;\r
-    }\r
-    else\r
-    {\r
-      /* Reset all RTC CR register bits */\r
-      RTC->CR &= (uint32_t)0x00000000;\r
-      RTC->WUTR = (uint32_t)0x0000FFFF;\r
-      RTC->PRER = (uint32_t)0x007F00FF;\r
-      RTC->CALIBR = (uint32_t)0x00000000;\r
-      RTC->ALRMAR = (uint32_t)0x00000000;        \r
-      RTC->ALRMBR = (uint32_t)0x00000000;\r
-      \r
-      /* Reset ISR register and exit initialization mode */\r
-      RTC->ISR = (uint32_t)0x00000000;\r
-      \r
-      /* Reset Tamper and alternate functions configuration register */\r
-      RTC->TAFCR = 0x00000000;\r
-  \r
-      if(RTC_WaitForSynchro() == ERROR)\r
-      {\r
-        status = ERROR;\r
-      }\r
-      else\r
-      {\r
-        status = SUCCESS;      \r
-      }\r
-    }\r
-  }\r
-  \r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF;  \r
-  \r
-  return status;\r
-}\r
-\r
-/**\r
-  * @brief  Initializes the RTC registers according to the specified parameters \r
-  *         in RTC_InitStruct.\r
-  * @param  RTC_InitStruct: pointer to a RTC_InitTypeDef structure that contains \r
-  *         the configuration information for the RTC peripheral.\r
-  * @note   The RTC Prescaler register is write protected and can be written in \r
-  *         initialization mode only.  \r
-  * @retval An ErrorStatus enumeration value:\r
-  *          - SUCCESS: RTC registers are initialized\r
-  *          - ERROR: RTC registers are not initialized  \r
-  */\r
-ErrorStatus RTC_Init(RTC_InitTypeDef* RTC_InitStruct)\r
-{\r
-  ErrorStatus status = ERROR;\r
-  \r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_HOUR_FORMAT(RTC_InitStruct->RTC_HourFormat));\r
-  assert_param(IS_RTC_ASYNCH_PREDIV(RTC_InitStruct->RTC_AsynchPrediv));\r
-  assert_param(IS_RTC_SYNCH_PREDIV(RTC_InitStruct->RTC_SynchPrediv));\r
-\r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-\r
-  /* Set Initialization mode */\r
-  if (RTC_EnterInitMode() == ERROR)\r
-  {\r
-    status = ERROR;\r
-  } \r
-  else\r
-  {\r
-    /* Clear RTC CR FMT Bit */\r
-    RTC->CR &= ((uint32_t)~(RTC_CR_FMT));\r
-    /* Set RTC_CR register */\r
-    RTC->CR |=  ((uint32_t)(RTC_InitStruct->RTC_HourFormat));\r
-  \r
-    /* Configure the RTC PRER */\r
-    RTC->PRER = (uint32_t)(RTC_InitStruct->RTC_SynchPrediv);\r
-    RTC->PRER |= (uint32_t)(RTC_InitStruct->RTC_AsynchPrediv << 16);\r
-\r
-    /* Exit Initialization mode */\r
-    RTC_ExitInitMode();\r
-\r
-    status = SUCCESS;    \r
-  }\r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF; \r
-  \r
-  return status;\r
-}\r
-\r
-/**\r
-  * @brief  Fills each RTC_InitStruct member with its default value.\r
-  * @param  RTC_InitStruct: pointer to a RTC_InitTypeDef structure which will be \r
-  *         initialized.\r
-  * @retval None\r
-  */\r
-void RTC_StructInit(RTC_InitTypeDef* RTC_InitStruct)\r
-{\r
-  /* Initialize the RTC_HourFormat member */\r
-  RTC_InitStruct->RTC_HourFormat = RTC_HourFormat_24;\r
-    \r
-  /* Initialize the RTC_AsynchPrediv member */\r
-  RTC_InitStruct->RTC_AsynchPrediv = (uint32_t)0x7F;\r
-\r
-  /* Initialize the RTC_SynchPrediv member */\r
-  RTC_InitStruct->RTC_SynchPrediv = (uint32_t)0xFF; \r
-}\r
-\r
-/**\r
-  * @brief  Enables or disables the RTC registers write protection.\r
-  * @note   All the RTC registers are write protected except for RTC_ISR[13:8], \r
-  *         RTC_TAFCR and RTC_BKPxR.\r
-  * @note   Writing a wrong key reactivates the write protection.\r
-  * @note   The protection mechanism is not affected by system reset.  \r
-  * @param  NewState: new state of the write protection.\r
-  *   This parameter can be: ENABLE or DISABLE.\r
-  * @retval None\r
-  */\r
-void RTC_WriteProtectionCmd(FunctionalState NewState)\r
-{\r
-  /* Check the parameters */\r
-  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
-    \r
-  if (NewState != DISABLE)\r
-  {\r
-    /* Enable the write protection for RTC registers */\r
-    RTC->WPR = 0xFF;   \r
-  }\r
-  else\r
-  {\r
-    /* Disable the write protection for RTC registers */\r
-    RTC->WPR = 0xCA;\r
-    RTC->WPR = 0x53;    \r
-  }\r
-}\r
-\r
-/**\r
-  * @brief  Enters the RTC Initialization mode.\r
-  * @note   The RTC Initialization mode is write protected, use the \r
-  *         RTC_WriteProtectionCmd(DISABLE) before calling this function.    \r
-  * @param  None\r
-  * @retval An ErrorStatus enumeration value:\r
-  *          - SUCCESS: RTC is in Init mode\r
-  *          - ERROR: RTC is not in Init mode  \r
-  */\r
-ErrorStatus RTC_EnterInitMode(void)\r
-{\r
-  __IO uint32_t initcounter = 0x00;\r
-  ErrorStatus status = ERROR;\r
-  uint32_t initstatus = 0x00;\r
-     \r
-  /* Check if the Initialization mode is set */\r
-  if ((RTC->ISR & RTC_ISR_INITF) == (uint32_t)RESET)\r
-  {\r
-    /* Set the Initialization mode */\r
-    RTC->ISR = (uint32_t)RTC_INIT_MASK;\r
-    \r
-    /* Wait till RTC is in INIT state and if Time out is reached exit */\r
-    do\r
-    {\r
-      initstatus = RTC->ISR & RTC_ISR_INITF;\r
-      initcounter++;  \r
-    } while((initcounter != INITMODE_TIMEOUT) && (initstatus == 0x00));\r
-    \r
-    if ((RTC->ISR & RTC_ISR_INITF) != RESET)\r
-    {\r
-      status = SUCCESS;\r
-    }\r
-    else\r
-    {\r
-      status = ERROR;\r
-    }        \r
-  }\r
-  else\r
-  {\r
-    status = SUCCESS;  \r
-  } \r
-    \r
-  return (status);  \r
-}\r
-\r
-/**\r
-  * @brief  Exits the RTC Initialization mode.\r
-  * @note   When the initialization sequence is complete, the calendar restarts \r
-  *         counting after 4 RTCCLK cycles.  \r
-  * @note   The RTC Initialization mode is write protected, use the \r
-  *         RTC_WriteProtectionCmd(DISABLE) before calling this function.      \r
-  * @param  None\r
-  * @retval None\r
-  */\r
-void RTC_ExitInitMode(void)\r
-{ \r
-  /* Exit Initialization mode */\r
-  RTC->ISR &= (uint32_t)~RTC_ISR_INIT;  \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
-  *         RTC_WriteProtectionCmd(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  None\r
-  * @retval An ErrorStatus enumeration value:\r
-  *          - SUCCESS: RTC registers are synchronised\r
-  *          - ERROR: RTC registers are not synchronised\r
-  */\r
-ErrorStatus RTC_WaitForSynchro(void)\r
-{\r
-  __IO uint32_t synchrocounter = 0;\r
-  ErrorStatus status = ERROR;\r
-  uint32_t synchrostatus = 0x00;\r
-\r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-    \r
-  /* Clear RSF flag */\r
-  RTC->ISR &= (uint32_t)RTC_RSF_MASK;\r
-    \r
-  /* Wait the registers to be synchronised */\r
-  do\r
-  {\r
-    synchrostatus = RTC->ISR & RTC_ISR_RSF;\r
-    synchrocounter++;  \r
-  } while((synchrocounter != SYNCHRO_TIMEOUT) && (synchrostatus == 0x00));\r
-    \r
-  if ((RTC->ISR & RTC_ISR_RSF) != RESET)\r
-  {\r
-    status = SUCCESS;\r
-  }\r
-  else\r
-  {\r
-    status = ERROR;\r
-  }        \r
-\r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF; \r
-    \r
-  return (status); \r
-}\r
-\r
-/**\r
-  * @brief  Enables or disables the RTC reference clock detection.\r
-  * @param  NewState: new state of the RTC reference clock.\r
-  *   This parameter can be: ENABLE or DISABLE.\r
-  * @retval An ErrorStatus enumeration value:\r
-  *          - SUCCESS: RTC reference clock detection is enabled\r
-  *          - ERROR: RTC reference clock detection is disabled  \r
-  */\r
-ErrorStatus RTC_RefClockCmd(FunctionalState NewState)\r
-{ \r
-  ErrorStatus status = ERROR;\r
-  \r
-  /* Check the parameters */\r
-  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
-  \r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-    \r
-  /* Set Initialization mode */\r
-  if (RTC_EnterInitMode() == ERROR)\r
-  {\r
-    status = ERROR;\r
-  } \r
-  else\r
-  {  \r
-    if (NewState != DISABLE)\r
-    {\r
-      /* Enable the RTC reference clock detection */\r
-      RTC->CR |= RTC_CR_REFCKON;   \r
-    }\r
-    else\r
-    {\r
-      /* Disable the RTC reference clock detection */\r
-      RTC->CR &= ~RTC_CR_REFCKON;    \r
-    }\r
-    /* Exit Initialization mode */\r
-    RTC_ExitInitMode();\r
-    \r
-    status = SUCCESS;\r
-  }\r
-  \r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF;  \r
-  \r
-  return status; \r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-/** @defgroup RTC_Group2 Time and Date configuration functions\r
- *  @brief   Time and Date configuration functions \r
- *\r
-@verbatim   \r
- ===============================================================================\r
-                   Time and Date configuration functions\r
- ===============================================================================  \r
-\r
-  This section provide functions allowing to program and read the RTC Calendar\r
-  (Time and Date).\r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-\r
-/**\r
-  * @brief  Set the RTC current time.\r
-  * @param  RTC_Format: specifies the format of the entered parameters.\r
-  *   This parameter can be  one of the following values:\r
-  *     @arg RTC_Format_BIN:  Binary data format \r
-  *     @arg RTC_Format_BCD:  BCD data format\r
-  * @param  RTC_TimeStruct: pointer to a RTC_TimeTypeDef structure that contains \r
-  *                        the time configuration information for the RTC.     \r
-  * @retval An ErrorStatus enumeration value:\r
-  *          - SUCCESS: RTC Time register is configured\r
-  *          - ERROR: RTC Time register is not configured\r
-  */\r
-ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct)\r
-{\r
-  uint32_t tmpreg = 0;\r
-  ErrorStatus status = ERROR;\r
-    \r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_FORMAT(RTC_Format));\r
-  \r
-  if (RTC_Format == RTC_Format_BIN)\r
-  {\r
-    if ((RTC->CR & RTC_CR_FMT) != (uint32_t)RESET)\r
-    {\r
-      assert_param(IS_RTC_HOUR12(RTC_TimeStruct->RTC_Hours));\r
-      assert_param(IS_RTC_H12(RTC_TimeStruct->RTC_H12));\r
-    } \r
-    else\r
-    {\r
-      RTC_TimeStruct->RTC_H12 = 0x00;\r
-      assert_param(IS_RTC_HOUR24(RTC_TimeStruct->RTC_Hours));\r
-    }\r
-    assert_param(IS_RTC_MINUTES(RTC_TimeStruct->RTC_Minutes));\r
-    assert_param(IS_RTC_SECONDS(RTC_TimeStruct->RTC_Seconds));\r
-  }\r
-  else\r
-  {\r
-    if ((RTC->CR & RTC_CR_FMT) != (uint32_t)RESET)\r
-    {\r
-      tmpreg = RTC_Bcd2ToByte(RTC_TimeStruct->RTC_Hours);\r
-      assert_param(IS_RTC_HOUR12(tmpreg));\r
-      assert_param(IS_RTC_H12(RTC_TimeStruct->RTC_H12)); \r
-    } \r
-    else\r
-    {\r
-      RTC_TimeStruct->RTC_H12 = 0x00;\r
-      assert_param(IS_RTC_HOUR24(RTC_Bcd2ToByte(RTC_TimeStruct->RTC_Hours)));\r
-    }\r
-    assert_param(IS_RTC_MINUTES(RTC_Bcd2ToByte(RTC_TimeStruct->RTC_Minutes)));\r
-    assert_param(IS_RTC_SECONDS(RTC_Bcd2ToByte(RTC_TimeStruct->RTC_Seconds)));\r
-  }\r
-  \r
-  /* Check the input parameters format */\r
-  if (RTC_Format != RTC_Format_BIN)\r
-  {\r
-    tmpreg = (((uint32_t)(RTC_TimeStruct->RTC_Hours) << 16) | \\r
-             ((uint32_t)(RTC_TimeStruct->RTC_Minutes) << 8) | \\r
-             ((uint32_t)RTC_TimeStruct->RTC_Seconds) | \\r
-             ((uint32_t)(RTC_TimeStruct->RTC_H12) << 16)); \r
-  }  \r
-  else\r
-  {\r
-    tmpreg = (uint32_t)(((uint32_t)RTC_ByteToBcd2(RTC_TimeStruct->RTC_Hours) << 16) | \\r
-                   ((uint32_t)RTC_ByteToBcd2(RTC_TimeStruct->RTC_Minutes) << 8) | \\r
-                   ((uint32_t)RTC_ByteToBcd2(RTC_TimeStruct->RTC_Seconds)) | \\r
-                   (((uint32_t)RTC_TimeStruct->RTC_H12) << 16));\r
-  }  \r
-\r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-\r
-  /* Set Initialization mode */\r
-  if (RTC_EnterInitMode() == ERROR)\r
-  {\r
-    status = ERROR;\r
-  } \r
-  else\r
-  {\r
-    /* Set the RTC_TR register */\r
-    RTC->TR = (uint32_t)(tmpreg & RTC_TR_RESERVED_MASK);\r
-\r
-    /* Exit Initialization mode */\r
-    RTC_ExitInitMode(); \r
-\r
-    if(RTC_WaitForSynchro() == ERROR)\r
-    {\r
-      status = ERROR;\r
-    }\r
-    else\r
-    {\r
-      status = SUCCESS;\r
-    }\r
-  \r
-  }\r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF; \r
-    \r
-  return status;\r
-}\r
-\r
-/**\r
-  * @brief  Fills each RTC_TimeStruct member with its default value\r
-  *         (Time = 00h:00min:00sec).\r
-  * @param  RTC_TimeStruct: pointer to a RTC_TimeTypeDef structure which will be \r
-  *         initialized.\r
-  * @retval None\r
-  */\r
-void RTC_TimeStructInit(RTC_TimeTypeDef* RTC_TimeStruct)\r
-{\r
-  /* Time = 00h:00min:00sec */\r
-  RTC_TimeStruct->RTC_H12 = RTC_H12_AM;\r
-  RTC_TimeStruct->RTC_Hours = 0;\r
-  RTC_TimeStruct->RTC_Minutes = 0;\r
-  RTC_TimeStruct->RTC_Seconds = 0; \r
-}\r
-\r
-/**\r
-  * @brief  Get the RTC current Time.\r
-  * @param  RTC_Format: specifies the format of the returned parameters.\r
-  *   This parameter can be  one of the following values:\r
-  *     @arg RTC_Format_BIN:  Binary data format \r
-  *     @arg RTC_Format_BCD:  BCD data format\r
-  * @param RTC_TimeStruct: pointer to a RTC_TimeTypeDef structure that will \r
-  *                        contain the returned current time configuration.     \r
-  * @retval None\r
-  */\r
-void RTC_GetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct)\r
-{\r
-  uint32_t tmpreg = 0;\r
-\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_FORMAT(RTC_Format));\r
-\r
-  /* Get the RTC_TR register */\r
-  tmpreg = (uint32_t)(RTC->TR & RTC_TR_RESERVED_MASK); \r
-  \r
-  /* Fill the structure fields with the read parameters */\r
-  RTC_TimeStruct->RTC_Hours = (uint8_t)((tmpreg & (RTC_TR_HT | RTC_TR_HU)) >> 16);\r
-  RTC_TimeStruct->RTC_Minutes = (uint8_t)((tmpreg & (RTC_TR_MNT | RTC_TR_MNU)) >>8);\r
-  RTC_TimeStruct->RTC_Seconds = (uint8_t)(tmpreg & (RTC_TR_ST | RTC_TR_SU));\r
-  RTC_TimeStruct->RTC_H12 = (uint8_t)((tmpreg & (RTC_TR_PM)) >> 16);  \r
-\r
-  /* Check the input parameters format */\r
-  if (RTC_Format == RTC_Format_BIN)\r
-  {\r
-    /* Convert the structure parameters to Binary format */\r
-    RTC_TimeStruct->RTC_Hours = (uint8_t)RTC_Bcd2ToByte(RTC_TimeStruct->RTC_Hours);\r
-    RTC_TimeStruct->RTC_Minutes = (uint8_t)RTC_Bcd2ToByte(RTC_TimeStruct->RTC_Minutes);\r
-    RTC_TimeStruct->RTC_Seconds = (uint8_t)RTC_Bcd2ToByte(RTC_TimeStruct->RTC_Seconds);   \r
-  }\r
-}\r
-\r
-/**\r
-  * @brief  Set the RTC current date.\r
-  * @param  RTC_Format: specifies the format of the entered parameters.\r
-  *   This parameter can be  one of the following values:\r
-  *     @arg RTC_Format_BIN:  Binary data format \r
-  *     @arg RTC_Format_BCD:  BCD data format\r
-  * @param  RTC_DateStruct: pointer to a RTC_DateTypeDef structure that contains \r
-  *                         the date configuration information for the RTC.\r
-  * @retval An ErrorStatus enumeration value:\r
-  *          - SUCCESS: RTC Date register is configured\r
-  *          - ERROR: RTC Date register is not configured\r
-  */\r
-ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct)\r
-{\r
-  uint32_t tmpreg = 0;\r
-  ErrorStatus status = ERROR;\r
-  \r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_FORMAT(RTC_Format));\r
-\r
-  if ((RTC_Format == RTC_Format_BIN) && ((RTC_DateStruct->RTC_Month & 0x10) == 0x10))\r
-  {\r
-    RTC_DateStruct->RTC_Month = (RTC_DateStruct->RTC_Month & (uint32_t)~(0x10)) + 0x0A;\r
-  }  \r
-  if (RTC_Format == RTC_Format_BIN)\r
-  {\r
-    assert_param(IS_RTC_YEAR(RTC_DateStruct->RTC_Year));\r
-    assert_param(IS_RTC_MONTH(RTC_DateStruct->RTC_Month));\r
-    assert_param(IS_RTC_DATE(RTC_DateStruct->RTC_Date));\r
-  }\r
-  else\r
-  {\r
-    assert_param(IS_RTC_YEAR(RTC_Bcd2ToByte(RTC_DateStruct->RTC_Year)));\r
-    tmpreg = RTC_Bcd2ToByte(RTC_DateStruct->RTC_Month);\r
-    assert_param(IS_RTC_MONTH(tmpreg));\r
-    tmpreg = RTC_Bcd2ToByte(RTC_DateStruct->RTC_Date);\r
-    assert_param(IS_RTC_DATE(tmpreg));\r
-  }\r
-  assert_param(IS_RTC_WEEKDAY(RTC_DateStruct->RTC_WeekDay));\r
-\r
-  /* Check the input parameters format */\r
-  if (RTC_Format != RTC_Format_BIN)\r
-  {\r
-    tmpreg = ((((uint32_t)RTC_DateStruct->RTC_Year) << 16) | \\r
-              (((uint32_t)RTC_DateStruct->RTC_Month) << 8) | \\r
-              ((uint32_t)RTC_DateStruct->RTC_Date) | \\r
-              (((uint32_t)RTC_DateStruct->RTC_WeekDay) << 13)); \r
-  }  \r
-  else\r
-  {\r
-    tmpreg = (((uint32_t)RTC_ByteToBcd2(RTC_DateStruct->RTC_Year) << 16) | \\r
-              ((uint32_t)RTC_ByteToBcd2(RTC_DateStruct->RTC_Month) << 8) | \\r
-              ((uint32_t)RTC_ByteToBcd2(RTC_DateStruct->RTC_Date)) | \\r
-              ((uint32_t)RTC_DateStruct->RTC_WeekDay << 13));\r
-  }\r
-\r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-\r
-  /* Set Initialization mode */\r
-  if (RTC_EnterInitMode() == ERROR)\r
-  {\r
-    status = ERROR;\r
-  } \r
-  else\r
-  {\r
-    /* Set the RTC_DR register */\r
-    RTC->DR = (uint32_t)(tmpreg & RTC_DR_RESERVED_MASK);\r
-\r
-    /* Exit Initialization mode */\r
-    RTC_ExitInitMode(); \r
-\r
-    if(RTC_WaitForSynchro() == ERROR)\r
-    {\r
-      status = ERROR;\r
-    }\r
-    else\r
-    {\r
-      status = SUCCESS;\r
-    }\r
-  }\r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF;   \r
-  \r
-  return status;\r
-}\r
-\r
-/**\r
-  * @brief  Fills each RTC_DateStruct member with its default value\r
-  *         (Monday, January 01 xx00).\r
-  * @param  RTC_DateStruct: pointer to a RTC_DateTypeDef structure which will be \r
-  *         initialized.\r
-  * @retval None\r
-  */\r
-void RTC_DateStructInit(RTC_DateTypeDef* RTC_DateStruct)\r
-{\r
-  /* Monday, January 01 xx00 */\r
-  RTC_DateStruct->RTC_WeekDay = RTC_Weekday_Monday;\r
-  RTC_DateStruct->RTC_Date = 1;\r
-  RTC_DateStruct->RTC_Month = RTC_Month_January;\r
-  RTC_DateStruct->RTC_Year = 0;\r
-}\r
-\r
-/**\r
-  * @brief  Get the RTC current date. \r
-  * @param  RTC_Format: specifies the format of the returned parameters.\r
-  *   This parameter can be one of the following values:\r
-  *     @arg RTC_Format_BIN: Binary data format \r
-  *     @arg RTC_Format_BCD: BCD data format\r
-  * @param RTC_DateStruct: pointer to a RTC_DateTypeDef structure that will \r
-  *                        contain the returned current date configuration.     \r
-  * @retval None\r
-  */\r
-void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct)\r
-{\r
-  uint32_t tmpreg = 0;\r
-\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_FORMAT(RTC_Format));\r
-  \r
-  /* Get the RTC_TR register */\r
-  tmpreg = (uint32_t)(RTC->DR & RTC_DR_RESERVED_MASK); \r
-\r
-  /* Fill the structure fields with the read parameters */\r
-  RTC_DateStruct->RTC_Year = (uint8_t)((tmpreg & (RTC_DR_YT | RTC_DR_YU)) >> 16);\r
-  RTC_DateStruct->RTC_Month = (uint8_t)((tmpreg & (RTC_DR_MT | RTC_DR_MU)) >> 8);\r
-  RTC_DateStruct->RTC_Date = (uint8_t)(tmpreg & (RTC_DR_DT | RTC_DR_DU));\r
-  RTC_DateStruct->RTC_WeekDay = (uint8_t)((tmpreg & (RTC_DR_WDU)) >> 13);  \r
-\r
-  /* Check the input parameters format */\r
-  if (RTC_Format == RTC_Format_BIN)\r
-  {\r
-    /* Convert the structure parameters to Binary format */\r
-    RTC_DateStruct->RTC_Year = (uint8_t)RTC_Bcd2ToByte(RTC_DateStruct->RTC_Year);\r
-    RTC_DateStruct->RTC_Month = (uint8_t)RTC_Bcd2ToByte(RTC_DateStruct->RTC_Month);\r
-    RTC_DateStruct->RTC_Date = (uint8_t)RTC_Bcd2ToByte(RTC_DateStruct->RTC_Date);\r
-    RTC_DateStruct->RTC_WeekDay = (uint8_t)(RTC_DateStruct->RTC_WeekDay);   \r
-  }\r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-/** @defgroup RTC_Group3 Alarms configuration functions\r
- *  @brief   Alarms (Alarm A and Alarm B) configuration functions \r
- *\r
-@verbatim   \r
- ===============================================================================\r
-              Alarms (Alarm A and Alarm B) configuration functions\r
- ===============================================================================  \r
-\r
-  This section provide functions allowing to program and read the RTC Alarms.\r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-\r
-/**\r
-  * @brief  Set the specified RTC Alarm.\r
-  * @note   The Alarm register can only be written when the corresponding Alarm\r
-  *         is disabled (Use the RTC_AlarmCmd(DISABLE)).    \r
-  * @param  RTC_Format: specifies the format of the returned parameters.\r
-  *   This parameter can be one of the following values:\r
-  *     @arg RTC_Format_BIN: Binary data format \r
-  *     @arg RTC_Format_BCD: BCD data format\r
-  * @param  RTC_Alarm: specifies the alarm to be configured.\r
-  *   This parameter can be one of the following values:\r
-  *     @arg RTC_Alarm_A: to select Alarm A\r
-  *     @arg RTC_Alarm_B: to select Alarm B  \r
-  * @param  RTC_AlarmStruct: pointer to a RTC_AlarmTypeDef structure that \r
-  *                          contains the alarm configuration parameters.     \r
-  * @retval None\r
-  */\r
-void RTC_SetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct)\r
-{\r
-  uint32_t tmpreg = 0;\r
-  \r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_FORMAT(RTC_Format));\r
-  assert_param(IS_RTC_ALARM(RTC_Alarm));\r
-  assert_param(IS_ALARM_MASK(RTC_AlarmStruct->RTC_AlarmMask));\r
-  assert_param(IS_RTC_ALARM_DATE_WEEKDAY_SEL(RTC_AlarmStruct->RTC_AlarmDateWeekDaySel));\r
-\r
-  if (RTC_Format == RTC_Format_BIN)\r
-  {\r
-    if ((RTC->CR & RTC_CR_FMT) != (uint32_t)RESET)\r
-    {\r
-      assert_param(IS_RTC_HOUR12(RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours));\r
-      assert_param(IS_RTC_H12(RTC_AlarmStruct->RTC_AlarmTime.RTC_H12));\r
-    } \r
-    else\r
-    {\r
-      RTC_AlarmStruct->RTC_AlarmTime.RTC_H12 = 0x00;\r
-      assert_param(IS_RTC_HOUR24(RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours));\r
-    }\r
-    assert_param(IS_RTC_MINUTES(RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes));\r
-    assert_param(IS_RTC_SECONDS(RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds));\r
-    \r
-    if(RTC_AlarmStruct->RTC_AlarmDateWeekDaySel == RTC_AlarmDateWeekDaySel_Date)\r
-    {\r
-      assert_param(IS_RTC_ALARM_DATE_WEEKDAY_DATE(RTC_AlarmStruct->RTC_AlarmDateWeekDay));\r
-    }\r
-    else\r
-    {\r
-      assert_param(IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(RTC_AlarmStruct->RTC_AlarmDateWeekDay));\r
-    }\r
-  }\r
-  else\r
-  {\r
-    if ((RTC->CR & RTC_CR_FMT) != (uint32_t)RESET)\r
-    {\r
-      tmpreg = RTC_Bcd2ToByte(RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours);\r
-      assert_param(IS_RTC_HOUR12(tmpreg));\r
-      assert_param(IS_RTC_H12(RTC_AlarmStruct->RTC_AlarmTime.RTC_H12));\r
-    } \r
-    else\r
-    {\r
-      RTC_AlarmStruct->RTC_AlarmTime.RTC_H12 = 0x00;\r
-      assert_param(IS_RTC_HOUR24(RTC_Bcd2ToByte(RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours)));\r
-    }\r
-    \r
-    assert_param(IS_RTC_MINUTES(RTC_Bcd2ToByte(RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes)));\r
-    assert_param(IS_RTC_SECONDS(RTC_Bcd2ToByte(RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds)));\r
-    \r
-    if(RTC_AlarmStruct->RTC_AlarmDateWeekDaySel == RTC_AlarmDateWeekDaySel_Date)\r
-    {\r
-      tmpreg = RTC_Bcd2ToByte(RTC_AlarmStruct->RTC_AlarmDateWeekDay);\r
-      assert_param(IS_RTC_ALARM_DATE_WEEKDAY_DATE(tmpreg));    \r
-    }\r
-    else\r
-    {\r
-      tmpreg = RTC_Bcd2ToByte(RTC_AlarmStruct->RTC_AlarmDateWeekDay);\r
-      assert_param(IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(tmpreg));      \r
-    }    \r
-  }\r
-\r
-  /* Check the input parameters format */\r
-  if (RTC_Format != RTC_Format_BIN)\r
-  {\r
-    tmpreg = (((uint32_t)(RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours) << 16) | \\r
-              ((uint32_t)(RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes) << 8) | \\r
-              ((uint32_t)RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds) | \\r
-              ((uint32_t)(RTC_AlarmStruct->RTC_AlarmTime.RTC_H12) << 16) | \\r
-              ((uint32_t)(RTC_AlarmStruct->RTC_AlarmDateWeekDay) << 24) | \\r
-              ((uint32_t)RTC_AlarmStruct->RTC_AlarmDateWeekDaySel) | \\r
-              ((uint32_t)RTC_AlarmStruct->RTC_AlarmMask)); \r
-  }  \r
-  else\r
-  {\r
-    tmpreg = (((uint32_t)RTC_ByteToBcd2(RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours) << 16) | \\r
-              ((uint32_t)RTC_ByteToBcd2(RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes) << 8) | \\r
-              ((uint32_t)RTC_ByteToBcd2(RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds)) | \\r
-              ((uint32_t)(RTC_AlarmStruct->RTC_AlarmTime.RTC_H12) << 16) | \\r
-              ((uint32_t)RTC_ByteToBcd2(RTC_AlarmStruct->RTC_AlarmDateWeekDay) << 24) | \\r
-              ((uint32_t)RTC_AlarmStruct->RTC_AlarmDateWeekDaySel) | \\r
-              ((uint32_t)RTC_AlarmStruct->RTC_AlarmMask)); \r
-  } \r
-\r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-\r
-  /* Configure the Alarm register */\r
-  if (RTC_Alarm == RTC_Alarm_A)\r
-  {\r
-    RTC->ALRMAR = (uint32_t)tmpreg;\r
-  }\r
-  else\r
-  {\r
-    RTC->ALRMBR = (uint32_t)tmpreg;\r
-  }\r
-\r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF;   \r
-}\r
-\r
-/**\r
-  * @brief  Fills each RTC_AlarmStruct member with its default value\r
-  *         (Time = 00h:00mn:00sec / Date = 1st day of the month/Mask =\r
-  *         all fields are masked).\r
-  * @param  RTC_AlarmStruct: pointer to a @ref RTC_AlarmTypeDef structure which\r
-  *         will be initialized.\r
-  * @retval None\r
-  */\r
-void RTC_AlarmStructInit(RTC_AlarmTypeDef* RTC_AlarmStruct)\r
-{\r
-  /* Alarm Time Settings : Time = 00h:00mn:00sec */\r
-  RTC_AlarmStruct->RTC_AlarmTime.RTC_H12 = RTC_H12_AM;\r
-  RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours = 0;\r
-  RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes = 0;\r
-  RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds = 0;\r
-\r
-  /* Alarm Date Settings : Date = 1st day of the month */\r
-  RTC_AlarmStruct->RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date;\r
-  RTC_AlarmStruct->RTC_AlarmDateWeekDay = 1;\r
-\r
-  /* Alarm Masks Settings : Mask =  all fields are not masked */\r
-  RTC_AlarmStruct->RTC_AlarmMask = RTC_AlarmMask_None;\r
-}\r
-\r
-/**\r
-  * @brief  Get the RTC Alarm value and masks.\r
-  * @param  RTC_Format: specifies the format of the output parameters.\r
-  *   This parameter can be one of the following values:\r
-  *     @arg RTC_Format_BIN: Binary data format \r
-  *     @arg RTC_Format_BCD: BCD data format\r
-  * @param  RTC_Alarm: specifies the alarm to be read.\r
-  *   This parameter can be one of the following values:\r
-  *     @arg RTC_Alarm_A: to select Alarm A\r
-  *     @arg RTC_Alarm_B: to select Alarm B  \r
-  * @param  RTC_AlarmStruct: pointer to a RTC_AlarmTypeDef structure that will \r
-  *                          contains the output alarm configuration values.     \r
-  * @retval None\r
-  */\r
-void RTC_GetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct)\r
-{\r
-  uint32_t tmpreg = 0;\r
-\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_FORMAT(RTC_Format));\r
-  assert_param(IS_RTC_ALARM(RTC_Alarm)); \r
-\r
-  /* Get the RTC_ALRMxR register */\r
-  if (RTC_Alarm == RTC_Alarm_A)\r
-  {\r
-    tmpreg = (uint32_t)(RTC->ALRMAR);\r
-  }\r
-  else\r
-  {\r
-    tmpreg = (uint32_t)(RTC->ALRMBR);\r
-  }\r
-\r
-  /* Fill the structure with the read parameters */\r
-  RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours = (uint32_t)((tmpreg & (RTC_ALRMAR_HT | \\r
-                                                     RTC_ALRMAR_HU)) >> 16);\r
-  RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes = (uint32_t)((tmpreg & (RTC_ALRMAR_MNT | \\r
-                                                     RTC_ALRMAR_MNU)) >> 8);\r
-  RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds = (uint32_t)(tmpreg & (RTC_ALRMAR_ST | \\r
-                                                     RTC_ALRMAR_SU));\r
-  RTC_AlarmStruct->RTC_AlarmTime.RTC_H12 = (uint32_t)((tmpreg & RTC_ALRMAR_PM) >> 16);\r
-  RTC_AlarmStruct->RTC_AlarmDateWeekDay = (uint32_t)((tmpreg & (RTC_ALRMAR_DT | RTC_ALRMAR_DU)) >> 24);\r
-  RTC_AlarmStruct->RTC_AlarmDateWeekDaySel = (uint32_t)(tmpreg & RTC_ALRMAR_WDSEL);\r
-  RTC_AlarmStruct->RTC_AlarmMask = (uint32_t)(tmpreg & RTC_AlarmMask_All);\r
-\r
-  if (RTC_Format == RTC_Format_BIN)\r
-  {\r
-    RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours = RTC_Bcd2ToByte(RTC_AlarmStruct-> \\r
-                                                        RTC_AlarmTime.RTC_Hours);\r
-    RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes = RTC_Bcd2ToByte(RTC_AlarmStruct-> \\r
-                                                        RTC_AlarmTime.RTC_Minutes);\r
-    RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds = RTC_Bcd2ToByte(RTC_AlarmStruct-> \\r
-                                                        RTC_AlarmTime.RTC_Seconds);\r
-    RTC_AlarmStruct->RTC_AlarmDateWeekDay = RTC_Bcd2ToByte(RTC_AlarmStruct->RTC_AlarmDateWeekDay);\r
-  }  \r
-}\r
-\r
-/**\r
-  * @brief  Enables or disables the specified RTC Alarm.\r
-  * @param  RTC_Alarm: specifies the alarm to be configured.\r
-  *   This parameter can be any combination of the following values:\r
-  *     @arg RTC_Alarm_A: to select Alarm A\r
-  *     @arg RTC_Alarm_B: to select Alarm B  \r
-  * @param  NewState: new state of the specified alarm.\r
-  *   This parameter can be: ENABLE or DISABLE.\r
-  * @retval An ErrorStatus enumeration value:\r
-  *          - SUCCESS: RTC Alarm is enabled/disabled\r
-  *          - ERROR: RTC Alarm is not enabled/disabled  \r
-  */\r
-ErrorStatus RTC_AlarmCmd(uint32_t RTC_Alarm, FunctionalState NewState)\r
-{\r
-  __IO uint32_t alarmcounter = 0x00;\r
-  uint32_t alarmstatus = 0x00;\r
-  ErrorStatus status = ERROR;\r
-    \r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_CMD_ALARM(RTC_Alarm));\r
-  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
-\r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-\r
-  /* Configure the Alarm state */\r
-  if (NewState != DISABLE)\r
-  {\r
-    RTC->CR |= (uint32_t)RTC_Alarm;\r
-\r
-    status = SUCCESS;    \r
-  }\r
-  else\r
-  { \r
-    /* Disable the Alarm in RTC_CR register */\r
-    RTC->CR &= (uint32_t)~RTC_Alarm;\r
-   \r
-    /* Wait till RTC ALRxWF flag is set and if Time out is reached exit */\r
-    do\r
-    {\r
-      alarmstatus = RTC->ISR & (RTC_Alarm >> 8);\r
-      alarmcounter++;  \r
-    } while((alarmcounter != INITMODE_TIMEOUT) && (alarmstatus == 0x00));\r
-    \r
-    if ((RTC->ISR & (RTC_Alarm >> 8)) == RESET)\r
-    {\r
-      status = ERROR;\r
-    } \r
-    else\r
-    {\r
-      status = SUCCESS;\r
-    }        \r
-  } \r
-\r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF; \r
-  \r
-  return status;\r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-/** @defgroup RTC_Group4 WakeUp Timer configuration functions\r
- *  @brief   WakeUp Timer configuration functions \r
- *\r
-@verbatim   \r
- ===============================================================================\r
-                     WakeUp Timer configuration functions\r
- ===============================================================================  \r
-\r
-  This section provide functions allowing to program and read the RTC WakeUp.\r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-\r
-/**\r
-  * @brief  Configures the RTC Wakeup clock source.\r
-  * @note   The WakeUp Clock source can only be changed when the RTC WakeUp\r
-  *         is disabled (Use the RTC_WakeUpCmd(DISABLE)).      \r
-  * @param  RTC_WakeUpClock: Wakeup Clock source.\r
-  *   This parameter can be one of the following values:\r
-  *     @arg RTC_WakeUpClock_RTCCLK_Div16\r
-  *     @arg RTC_WakeUpClock_RTCCLK_Div8\r
-  *     @arg RTC_WakeUpClock_RTCCLK_Div4\r
-  *     @arg RTC_WakeUpClock_RTCCLK_Div2\r
-  *     @arg RTC_WakeUpClock_CK_SPRE_16bits\r
-  *     @arg RTC_WakeUpClock_CK_SPRE_17bits\r
-  * @retval None\r
-  */\r
-void RTC_WakeUpClockConfig(uint32_t RTC_WakeUpClock)\r
-{\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_WAKEUP_CLOCK(RTC_WakeUpClock));\r
-\r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-\r
-  /* Clear the Wakeup Timer clock source bits in CR register */\r
-  RTC->CR &= (uint32_t)~RTC_CR_WUCKSEL;\r
-\r
-  /* Configure the clock source */\r
-  RTC->CR |= (uint32_t)RTC_WakeUpClock;\r
-  \r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF; \r
-}\r
-\r
-/**\r
-  * @brief  Configures the RTC Wakeup counter.\r
-  * @note   The RTC WakeUp counter can only be written when the RTC WakeUp\r
-  *         is disabled (Use the RTC_WakeUpCmd(DISABLE)).        \r
-  * @param  RTC_WakeUpCounter: specifies the WakeUp counter.\r
-  *   This parameter can be a value from 0x0000 to 0xFFFF. \r
-  * @retval None\r
-  */\r
-void RTC_SetWakeUpCounter(uint32_t RTC_WakeUpCounter)\r
-{\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_WAKEUP_COUNTER(RTC_WakeUpCounter));\r
-  \r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-  \r
-  /* Configure the Wakeup Timer counter */\r
-  RTC->WUTR = (uint32_t)RTC_WakeUpCounter;\r
-  \r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF; \r
-}\r
-\r
-/**\r
-  * @brief  Returns the RTC WakeUp timer counter value.\r
-  * @param  None\r
-  * @retval The RTC WakeUp Counter value.\r
-  */\r
-uint32_t RTC_GetWakeUpCounter(void)\r
-{\r
-  /* Get the counter value */\r
-  return ((uint32_t)(RTC->WUTR & RTC_WUTR_WUT));\r
-}\r
-\r
-/**\r
-  * @brief  Enables or Disables the RTC WakeUp timer.\r
-  * @param  NewState: new state of the WakeUp timer.\r
-  *   This parameter can be: ENABLE or DISABLE.\r
-  * @retval None\r
-  */\r
-ErrorStatus RTC_WakeUpCmd(FunctionalState NewState)\r
-{\r
-  __IO uint32_t wutcounter = 0x00;\r
-  uint32_t wutwfstatus = 0x00;\r
-  ErrorStatus status = ERROR;\r
-  \r
-  /* Check the parameters */\r
-  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
-\r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-\r
-  if (NewState != DISABLE)\r
-  {\r
-    /* Enable the Wakeup Timer */\r
-    RTC->CR |= (uint32_t)RTC_CR_WUTE;\r
-    status = SUCCESS;    \r
-  }\r
-  else\r
-  {\r
-    /* Disable the Wakeup Timer */\r
-    RTC->CR &= (uint32_t)~RTC_CR_WUTE;\r
-    /* Wait till RTC WUTWF flag is set and if Time out is reached exit */\r
-    do\r
-    {\r
-      wutwfstatus = RTC->ISR & RTC_ISR_WUTWF;\r
-      wutcounter++;  \r
-    } while((wutcounter != INITMODE_TIMEOUT) && (wutwfstatus == 0x00));\r
-    \r
-    if ((RTC->ISR & RTC_ISR_WUTWF) == RESET)\r
-    {\r
-      status = ERROR;\r
-    }\r
-    else\r
-    {\r
-      status = SUCCESS;\r
-    }    \r
-  }\r
-\r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF; \r
-  \r
-  return status;\r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-/** @defgroup RTC_Group5 Daylight Saving configuration functions\r
- *  @brief   Daylight Saving configuration functions \r
- *\r
-@verbatim   \r
- ===============================================================================\r
-                    Daylight Saving configuration functions\r
- ===============================================================================  \r
-\r
-  This section provide functions allowing to configure the RTC DayLight Saving.\r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-\r
-/**\r
-  * @brief  Adds or substract one hour from the current time.\r
-  * @param  RTC_DayLightSaveOperation: the value of hour adjustment. \r
-  *   This parameter can be one of the following values:\r
-  *     @arg RTC_DayLightSaving_SUB1H: Substract one hour (winter time)\r
-  *     @arg RTC_DayLightSaving_ADD1H: Add one hour (summer time)\r
-  * @param  RTC_StoreOperation: Specifies the value to be written in the BCK bit \r
-  *                            in CR register to store the operation.\r
-  *   This parameter can be one of the following values:\r
-  *     @arg RTC_StoreOperation_Reset\r
-  *     @arg RTC_StoreOperation_Set\r
-  * @retval None\r
-  */\r
-void RTC_DayLightSavingConfig(uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation)\r
-{\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_DAYLIGHT_SAVING(RTC_DayLightSaving));\r
-  assert_param(IS_RTC_STORE_OPERATION(RTC_StoreOperation));\r
-\r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-\r
-  /* Clear the bits to be configured */\r
-  RTC->CR &= (uint32_t)~(RTC_CR_BCK);\r
-\r
-  /* Configure the RTC_CR register */\r
-  RTC->CR |= (uint32_t)(RTC_DayLightSaving | RTC_StoreOperation);\r
-\r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF; \r
-}\r
-\r
-/**\r
-  * @brief  Returns the RTC Day Light Saving stored operation.\r
-  * @param  None\r
-  * @retval RTC Day Light Saving stored operation.\r
-  *          - RTC_StoreOperation_Reset\r
-  *          - RTC_StoreOperation_Set       \r
-  */\r
-uint32_t RTC_GetStoreOperation(void)\r
-{\r
-  return (RTC->CR & RTC_CR_BCK);\r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-/** @defgroup RTC_Group6 Output pin Configuration function\r
- *  @brief   Output pin Configuration function \r
- *\r
-@verbatim   \r
- ===============================================================================\r
-                         Output pin Configuration function\r
- ===============================================================================  \r
-\r
-  This section provide functions allowing to configure the RTC Output source.\r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-\r
-/**\r
-  * @brief  Configures the RTC output source (AFO_ALARM).\r
-  * @param  RTC_Output: Specifies which signal will be routed to the RTC output. \r
-  *   This parameter can be one of the following values:\r
-  *     @arg RTC_Output_Disable: No output selected\r
-  *     @arg RTC_Output_AlarmA: signal of AlarmA mapped to output\r
-  *     @arg RTC_Output_AlarmB: signal of AlarmB mapped to output\r
-  *     @arg RTC_Output_WakeUp: signal of WakeUp mapped to output\r
-  * @param  RTC_OutputPolarity: Specifies the polarity of the output signal. \r
-  *   This parameter can be one of the following:\r
-  *     @arg RTC_OutputPolarity_High: The output pin is high when the \r
-  *                                 ALRAF/ALRBF/WUTF is high (depending on OSEL)\r
-  *     @arg RTC_OutputPolarity_Low: The output pin is low when the \r
-  *                                 ALRAF/ALRBF/WUTF is high (depending on OSEL)\r
-  * @retval None\r
-  */\r
-void RTC_OutputConfig(uint32_t RTC_Output, uint32_t RTC_OutputPolarity)\r
-{\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_OUTPUT(RTC_Output));\r
-  assert_param(IS_RTC_OUTPUT_POL(RTC_OutputPolarity));\r
-\r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-\r
-  /* Clear the bits to be configured */\r
-  RTC->CR &= (uint32_t)~(RTC_CR_OSEL | RTC_CR_POL);\r
-\r
-  /* Configure the output selection and polarity */\r
-  RTC->CR |= (uint32_t)(RTC_Output | RTC_OutputPolarity);\r
-\r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF; \r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-/** @defgroup RTC_Group7 Digital Calibration configuration functions\r
- *  @brief   Digital Calibration configuration functions \r
- *\r
-@verbatim   \r
- ===============================================================================\r
-                  Digital Calibration configuration functions\r
- ===============================================================================  \r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-\r
-/**\r
-  * @brief  Configures the digital calibration parameters.\r
-  * @param  RTC_CalibSign: specifies the sign of the calibration value.\r
-  *   This parameter can be  one of the following values:\r
-  *     @arg RTC_CalibSign_Positive: The value sign is positive \r
-  *     @arg RTC_CalibSign_Negative: The value sign is negative\r
-  * @param  Value: value of calibration expressed in ppm (coded on 5 bits) \r
-  *             - This value should be between 0 and 63 when using negative sign\r
-  *               with a 2-ppm step.\r
-  *             - This value should be between 0 and 126 when using positive sign\r
-  *               with a 4-ppm step.\r
-  * @retval An ErrorStatus enumeration value:\r
-  *          - SUCCESS: RTC digital calibration are initialized\r
-  *          - ERROR: RTC digital calibration are not initialized     \r
-  */\r
-ErrorStatus RTC_DigitalCalibConfig(uint32_t RTC_CalibSign, uint32_t Value)\r
-{\r
-  ErrorStatus status = ERROR;\r
-   \r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_CALIB_SIGN(RTC_CalibSign));\r
-  assert_param(IS_RTC_CALIB_VALUE(Value)); \r
-\r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-\r
-  /* Set Initialization mode */\r
-  if (RTC_EnterInitMode() == ERROR)\r
-  {\r
-    status = ERROR;\r
-  } \r
-  else\r
-  {\r
-    /* Set the calibration value */\r
-    RTC->CALIBR = (uint32_t)(RTC_CalibSign | Value);\r
-    /* Exit Initialization mode */\r
-    RTC_ExitInitMode();\r
-    \r
-    status = SUCCESS;\r
-  } \r
-\r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF; \r
-  \r
-  return status;\r
-}\r
-\r
-/**\r
-  * @brief  Enables or disables the digital calibration process.\r
-  * @param  NewState: new state of the digital calibration.\r
-  *   This parameter can be: ENABLE or DISABLE.\r
-  * @retval An ErrorStatus enumeration value:\r
-  *          - SUCCESS: RTC digital calibration are enabled/disabled\r
-  *          - ERROR: RTC digital calibration are not enabled/disabled    \r
-  */\r
-ErrorStatus RTC_DigitalCalibCmd(FunctionalState NewState)\r
-{\r
-  ErrorStatus status = ERROR;\r
-  \r
-  /* Check the parameters */\r
-  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
-\r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-  \r
-  /* Set Initialization mode */\r
-  if (RTC_EnterInitMode() == ERROR)\r
-  {\r
-    status =  ERROR;\r
-  }\r
-  else\r
-  {\r
-    if (NewState != DISABLE)\r
-    {\r
-      /* Enable the Digital Calibration */\r
-      RTC->CR |= (uint32_t)RTC_CR_DCE;\r
-    }\r
-    else\r
-    { \r
-      /* Disable the Digital Calibration */\r
-      RTC->CR &= (uint32_t)~RTC_CR_DCE;\r
-    }\r
-    /* Exit Initialization mode */\r
-    RTC_ExitInitMode();\r
-    \r
-    status = SUCCESS;\r
-  } \r
-  \r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF; \r
-  \r
-  return status;\r
-}\r
-\r
-/**\r
-  * @brief  Enables or disables the RTC clock to be output through the relative \r
-  *         pin.\r
-  * @param  NewState: new state of the digital calibration Output.\r
-  *   This parameter can be: ENABLE or DISABLE.\r
-  * @retval None\r
-  */\r
-void RTC_CalibOutputCmd(FunctionalState NewState)\r
-{\r
-  /* Check the parameters */\r
-  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
-  \r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-  \r
-  if (NewState != DISABLE)\r
-  {\r
-    /* Enable the RTC clock output */\r
-    RTC->CR |= (uint32_t)RTC_CR_COE;\r
-  }\r
-  else\r
-  { \r
-    /* Disable the RTC clock output */\r
-    RTC->CR &= (uint32_t)~RTC_CR_COE;\r
-  }\r
-  \r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF; \r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-\r
-/** @defgroup RTC_Group8 TimeStamp configuration functions\r
- *  @brief   TimeStamp configuration functions \r
- *\r
-@verbatim   \r
- ===============================================================================\r
-                       TimeStamp configuration functions\r
- ===============================================================================  \r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-\r
-/**\r
-  * @brief  Enables or Disables the RTC TimeStamp functionality with the \r
-  *         specified time stamp pin stimulating edge.\r
-  * @param  RTC_TimeStampEdge: Specifies the pin edge on which the TimeStamp is \r
-  *         activated.\r
-  *   This parameter can be one of the following:\r
-  *     @arg RTC_TimeStampEdge_Rising: the Time stamp event occurs on the rising \r
-  *                                    edge of the related pin.\r
-  *     @arg RTC_TimeStampEdge_Falling: the Time stamp event occurs on the \r
-  *                                     falling edge of the related pin.\r
-  * @param  NewState: new state of the TimeStamp.\r
-  *   This parameter can be: ENABLE or DISABLE.\r
-  * @retval None\r
-  */\r
-void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState)\r
-{\r
-  uint32_t tmpreg = 0;\r
-\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_TIMESTAMP_EDGE(RTC_TimeStampEdge));\r
-  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
-\r
-  /* Get the RTC_CR register and clear the bits to be configured */\r
-  tmpreg = (uint32_t)(RTC->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));\r
-\r
-  /* Get the new configuration */\r
-  if (NewState != DISABLE)\r
-  {\r
-    tmpreg |= (uint32_t)(RTC_TimeStampEdge | RTC_CR_TSE);\r
-  }\r
-  else\r
-  {\r
-    tmpreg |= (uint32_t)(RTC_TimeStampEdge);\r
-  }\r
-\r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-\r
-  /* Configure the Time Stamp TSEDGE and Enable bits */\r
-  RTC->CR = (uint32_t)tmpreg;\r
-\r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF; \r
-}\r
-\r
-/**\r
-  * @brief  Get the RTC TimeStamp value and masks.\r
-  * @param  RTC_Format: specifies the format of the output parameters.\r
-  *   This parameter can be one of the following values:\r
-  *     @arg RTC_Format_BIN: Binary data format \r
-  *     @arg RTC_Format_BCD: BCD data format\r
-  * @param RTC_StampTimeStruct: pointer to a RTC_TimeTypeDef structure that will \r
-  *                             contains the TimeStamp time values. \r
-  * @param RTC_StampDateStruct: pointer to a RTC_DateTypeDef structure that will \r
-  *                             contains the TimeStamp date values.     \r
-  * @retval None\r
-  */\r
-void RTC_GetTimeStamp(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_StampTimeStruct, \r
-                                      RTC_DateTypeDef* RTC_StampDateStruct)\r
-{\r
-  uint32_t tmptime = 0, tmpdate = 0;\r
-\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_FORMAT(RTC_Format));\r
-\r
-  /* Get the TimeStamp time and date registers values */\r
-  tmptime = (uint32_t)(RTC->TSTR & RTC_TR_RESERVED_MASK);\r
-  tmpdate = (uint32_t)(RTC->TSDR & RTC_DR_RESERVED_MASK);\r
-\r
-  /* Fill the Time structure fields with the read parameters */\r
-  RTC_StampTimeStruct->RTC_Hours = (uint8_t)((tmptime & (RTC_TR_HT | RTC_TR_HU)) >> 16);\r
-  RTC_StampTimeStruct->RTC_Minutes = (uint8_t)((tmptime & (RTC_TR_MNT | RTC_TR_MNU)) >> 8);\r
-  RTC_StampTimeStruct->RTC_Seconds = (uint8_t)(tmptime & (RTC_TR_ST | RTC_TR_SU));\r
-  RTC_StampTimeStruct->RTC_H12 = (uint8_t)((tmptime & (RTC_TR_PM)) >> 16);  \r
-\r
-  /* Fill the Date structure fields with the read parameters */\r
-  RTC_StampDateStruct->RTC_Year = 0;\r
-  RTC_StampDateStruct->RTC_Month = (uint8_t)((tmpdate & (RTC_DR_MT | RTC_DR_MU)) >> 8);\r
-  RTC_StampDateStruct->RTC_Date = (uint8_t)(tmpdate & (RTC_DR_DT | RTC_DR_DU));\r
-  RTC_StampDateStruct->RTC_WeekDay = (uint8_t)((tmpdate & (RTC_DR_WDU)) >> 13);\r
-\r
-  /* Check the input parameters format */\r
-  if (RTC_Format == RTC_Format_BIN)\r
-  {\r
-    /* Convert the Time structure parameters to Binary format */\r
-    RTC_StampTimeStruct->RTC_Hours = (uint8_t)RTC_Bcd2ToByte(RTC_StampTimeStruct->RTC_Hours);\r
-    RTC_StampTimeStruct->RTC_Minutes = (uint8_t)RTC_Bcd2ToByte(RTC_StampTimeStruct->RTC_Minutes);\r
-    RTC_StampTimeStruct->RTC_Seconds = (uint8_t)RTC_Bcd2ToByte(RTC_StampTimeStruct->RTC_Seconds);\r
-\r
-    /* Convert the Date structure parameters to Binary format */\r
-    RTC_StampDateStruct->RTC_Month = (uint8_t)RTC_Bcd2ToByte(RTC_StampDateStruct->RTC_Month);\r
-    RTC_StampDateStruct->RTC_Date = (uint8_t)RTC_Bcd2ToByte(RTC_StampDateStruct->RTC_Date);\r
-    RTC_StampDateStruct->RTC_WeekDay = (uint8_t)RTC_Bcd2ToByte(RTC_StampDateStruct->RTC_WeekDay);\r
-  }\r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-/** @defgroup RTC_Group9 Tampers configuration functions\r
- *  @brief   Tampers configuration functions \r
- *\r
-@verbatim   \r
- ===============================================================================\r
-                       Tampers configuration functions\r
- ===============================================================================  \r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-\r
-/**\r
-  * @brief  Configures the select Tamper pin edge.\r
-  * @param  RTC_Tamper: Selected tamper pin.\r
-  *   This parameter can be RTC_Tamper_1.\r
-  * @param  RTC_TamperTrigger: Specifies the trigger on the tamper pin that \r
-  *         stimulates tamper event. \r
-  *   This parameter can be one of the following values:\r
-  *     @arg RTC_TamperTrigger_RisingEdge: Rising Edge of the tamper pin causes tamper event.\r
-  *     @arg RTC_TamperTrigger_FallingEdge: Falling Edge of the tamper pin causes tamper event.                         \r
-  * @retval None\r
-  */\r
-void RTC_TamperTriggerConfig(uint32_t RTC_Tamper, uint32_t RTC_TamperTrigger)\r
-{\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_TAMPER(RTC_Tamper)); \r
-  assert_param(IS_RTC_TAMPER_TRIGGER(RTC_TamperTrigger));\r
\r
-  if (RTC_TamperTrigger == RTC_TamperTrigger_RisingEdge)\r
-  {  \r
-    /* Configure the RTC_TAFCR register */\r
-    RTC->TAFCR &= (uint32_t)((uint32_t)~(RTC_Tamper << 1));    \r
-  }\r
-  else\r
-  { \r
-    /* Configure the RTC_TAFCR register */\r
-    RTC->TAFCR |= (uint32_t)(RTC_Tamper << 1);  \r
-  }  \r
-}\r
-\r
-/**\r
-  * @brief  Enables or Disables the Tamper detection.\r
-  * @param  RTC_Tamper: Selected tamper pin.\r
-  *   This parameter can be RTC_Tamper_1.\r
-  * @param  NewState: new state of the tamper pin.\r
-  *   This parameter can be: ENABLE or DISABLE.                   \r
-  * @retval None\r
-  */\r
-void RTC_TamperCmd(uint32_t RTC_Tamper, FunctionalState NewState)\r
-{\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_TAMPER(RTC_Tamper));  \r
-  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
-  \r
-  if (NewState != DISABLE)\r
-  {\r
-    /* Enable the selected Tamper pin */\r
-    RTC->TAFCR |= (uint32_t)RTC_Tamper;\r
-  }\r
-  else\r
-  {\r
-    /* Disable the selected Tamper pin */\r
-    RTC->TAFCR &= (uint32_t)~RTC_Tamper;    \r
-  }  \r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-/** @defgroup RTC_Group10 Backup Data Registers configuration functions\r
- *  @brief   Backup Data Registers configuration functions  \r
- *\r
-@verbatim   \r
- ===============================================================================\r
-                       Backup Data Registers configuration functions \r
- ===============================================================================  \r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-\r
-/**\r
-  * @brief  Writes a data in a specified RTC Backup data register.\r
-  * @param  RTC_BKP_DR: RTC Backup data Register number.\r
-  *   This parameter can be: RTC_BKP_DRx where x can be from 0 to 19 to \r
-  *                          specify the register.\r
-  * @param  Data: Data to be written in the specified RTC Backup data register.                     \r
-  * @retval None\r
-  */\r
-void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data)\r
-{\r
-  __IO uint32_t tmp = 0;\r
-  \r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_BKP(RTC_BKP_DR));\r
-\r
-  tmp = RTC_BASE + 0x50;\r
-  tmp += (RTC_BKP_DR * 4);\r
-\r
-  /* Write the specified register */\r
-  *(__IO uint32_t *)tmp = (uint32_t)Data;\r
-}\r
-\r
-/**\r
-  * @brief  Reads data from the specified RTC Backup data Register.\r
-  * @param  RTC_BKP_DR: RTC Backup data Register number.\r
-  *   This parameter can be: RTC_BKP_DRx where x can be from 0 to 19 to \r
-  *                          specify the register.                   \r
-  * @retval None\r
-  */\r
-uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR)\r
-{\r
-  __IO uint32_t tmp = 0;\r
-  \r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_BKP(RTC_BKP_DR));\r
-\r
-  tmp = RTC_BASE + 0x50;\r
-  tmp += (RTC_BKP_DR * 4);\r
-  \r
-  /* Read the specified register */\r
-  return (*(__IO uint32_t *)tmp);\r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-/** @defgroup RTC_Group11 Output Type Config configuration functions\r
- *  @brief   Output Type Config configuration functions  \r
- *\r
-@verbatim   \r
- ===============================================================================\r
-                       Output Type Config configuration functions \r
- ===============================================================================  \r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-\r
-/**\r
-  * @brief  Configures the RTC Output Pin mode. \r
-  * @param  RTC_OutputType: specifies the RTC Output (PC13) pin mode.\r
-  *   This parameter can be one of the following values:\r
-  *     @arg RTC_OutputType_OpenDrain: RTC Output (PC13) is configured in \r
-  *                                    Open Drain mode.\r
-  *     @arg RTC_OutputType_PushPull:  RTC Output (PC13) is configured in \r
-  *                                    Push Pull mode.    \r
-  * @retval None\r
-  */\r
-void RTC_OutputTypeConfig(uint32_t RTC_OutputType)\r
-{\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_OUTPUT_TYPE(RTC_OutputType));\r
-  \r
-  RTC->TAFCR &= (uint32_t)~(RTC_TAFCR_ALARMOUTTYPE);\r
-  RTC->TAFCR |= (uint32_t)(RTC_OutputType);  \r
-}\r
-\r
-/**\r
-  * @}\r
-  */\r
-\r
-/** @defgroup RTC_Group12 Interrupts and flags management functions\r
- *  @brief   Interrupts and flags management functions  \r
- *\r
-@verbatim   \r
- ===============================================================================\r
-                       Interrupts and flags management functions\r
- ===============================================================================  \r
- All RTC interrupts are connected to the EXTI controller.\r
\r
- - To enable the RTC Alarm interrupt, the following sequence is required:\r
-   - Configure and enable the EXTI Line 17 in interrupt mode and select the rising \r
-     edge sensitivity using the EXTI_Init() function.\r
-   - Configure and enable the RTC_Alarm IRQ channel in the NVIC using the NVIC_Init()\r
-     function.\r
-   - Configure the RTC to generate RTC alarms (Alarm A and/or Alarm B) using\r
-     the RTC_SetAlarm() and RTC_AlarmCmd() functions.\r
-\r
- - To enable the RTC Wakeup interrupt, the following sequence is required:\r
-   - Configure and enable the EXTI Line 20 in interrupt mode and select the rising \r
-     edge sensitivity using the EXTI_Init() function.\r
-   - Configure and enable the RTC_WKUP IRQ channel in the NVIC using the NVIC_Init()\r
-     function.\r
-   - Configure the RTC to generate the RTC wakeup timer event using the \r
-     RTC_WakeUpClockConfig(), RTC_SetWakeUpCounter() and RTC_WakeUpCmd() functions.\r
-\r
- - To enable the RTC Tamper interrupt, the following sequence is required:\r
-   - Configure and enable the EXTI Line 19 in interrupt mode and select the rising \r
-     edge sensitivity using the EXTI_Init() function.\r
-   - Configure and enable the TAMP_STAMP IRQ channel in the NVIC using the NVIC_Init()\r
-     function.\r
-   - Configure the RTC to detect the RTC tamper event using the \r
-     RTC_TamperTriggerConfig() and RTC_TamperCmd() functions.\r
-\r
- - To enable the RTC TimeStamp interrupt, the following sequence is required:\r
-   - Configure and enable the EXTI Line 19 in interrupt mode and select the rising \r
-     edge sensitivity using the EXTI_Init() function.\r
-   - Configure and enable the TAMP_STAMP IRQ channel in the NVIC using the NVIC_Init()\r
-     function.\r
-   - Configure the RTC to detect the RTC time-stamp event using the \r
-     RTC_TimeStampCmd() functions.\r
-\r
-@endverbatim\r
-  * @{\r
-  */\r
-\r
-/**\r
-  * @brief  Enables or disables the specified RTC interrupts.\r
-  * @param  RTC_IT: specifies the RTC interrupt sources to be enabled or disabled. \r
-  *   This parameter can be any combination of the following values:\r
-  *     @arg RTC_IT_TS:  Time Stamp interrupt mask\r
-  *     @arg RTC_IT_WUT:  WakeUp Timer interrupt mask\r
-  *     @arg RTC_IT_ALRB:  Alarm B interrupt mask\r
-  *     @arg RTC_IT_ALRA:  Alarm A interrupt mask\r
-  *     @arg RTC_IT_TAMP: Tamper event interrupt mask\r
-  * @param  NewState: new state of the specified RTC interrupts.\r
-  *   This parameter can be: ENABLE or DISABLE.\r
-  * @retval None\r
-  */\r
-void RTC_ITConfig(uint32_t RTC_IT, FunctionalState NewState)\r
-{\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_CONFIG_IT(RTC_IT));\r
-  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
-\r
-  /* Disable the write protection for RTC registers */\r
-  RTC->WPR = 0xCA;\r
-  RTC->WPR = 0x53;\r
-\r
-  if (NewState != DISABLE)\r
-  {\r
-    /* Configure the Interrupts in the RTC_CR register */\r
-    RTC->CR |= (uint32_t)(RTC_IT & ~RTC_TAFCR_TAMPIE);\r
-    /* Configure the Tamper Interrupt in the RTC_TAFCR */\r
-    RTC->TAFCR |= (uint32_t)(RTC_IT & RTC_TAFCR_TAMPIE);\r
-  }\r
-  else\r
-  {\r
-    /* Configure the Interrupts in the RTC_CR register */\r
-    RTC->CR &= (uint32_t)~(RTC_IT & (uint32_t)~RTC_TAFCR_TAMPIE);\r
-    /* Configure the Tamper Interrupt in the RTC_TAFCR */\r
-    RTC->TAFCR &= (uint32_t)~(RTC_IT & RTC_TAFCR_TAMPIE);\r
-  }\r
-  /* Enable the write protection for RTC registers */\r
-  RTC->WPR = 0xFF; \r
-}\r
-\r
-/**\r
-  * @brief  Checks whether the specified RTC flag is set or not.\r
-  * @param  RTC_FLAG: specifies the flag to check.\r
-  *   This parameter can be one of the following values:\r
-  *     @arg RTC_FLAG_TAMP1F: Tamper 1 event flag\r
-  *     @arg RTC_FLAG_TSOVF: Time Stamp OverFlow flag\r
-  *     @arg RTC_FLAG_TSF: Time Stamp event flag\r
-  *     @arg RTC_FLAG_WUTF: WakeUp Timer flag\r
-  *     @arg RTC_FLAG_ALRBF: Alarm B flag\r
-  *     @arg RTC_FLAG_ALRAF: Alarm A flag\r
-  *     @arg RTC_FLAG_INITF: Initialization mode flag\r
-  *     @arg RTC_FLAG_RSF: Registers Synchronized flag\r
-  *     @arg RTC_FLAG_INITS: Registers Configured flag\r
-  *     @arg RTC_FLAG_WUTWF: WakeUp Timer Write flag\r
-  *     @arg RTC_FLAG_ALRBWF: Alarm B Write flag\r
-  *     @arg RTC_FLAG_ALRAWF: Alarm A write flag\r
-  * @retval The new state of RTC_FLAG (SET or RESET).\r
-  */\r
-FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG)\r
-{\r
-  FlagStatus bitstatus = RESET;\r
-  uint32_t tmpreg = 0;\r
-  \r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_GET_FLAG(RTC_FLAG));\r
-  \r
-  /* Get all the flags */\r
-  tmpreg = (uint32_t)(RTC->ISR & RTC_FLAGS_MASK);\r
-  \r
-  /* Return the status of the flag */\r
-  if ((tmpreg & RTC_FLAG) != (uint32_t)RESET)\r
-  {\r
-    bitstatus = SET;\r
-  }\r
-  else\r
-  {\r
-    bitstatus = RESET;\r
-  }\r
-  return bitstatus;\r
-}\r
-\r
-/**\r
-  * @brief  Clears the RTC's pending flags.\r
-  * @param  RTC_FLAG: specifies the RTC flag to clear.\r
-  *   This parameter can be any combination of the following values:\r
-  *     @arg RTC_FLAG_TAMP1F: Tamper 1 event flag\r
-  *     @arg RTC_FLAG_TSOVF: Time Stamp Overflow flag \r
-  *     @arg RTC_FLAG_TSF: Time Stamp event flag\r
-  *     @arg RTC_FLAG_WUTF: WakeUp Timer flag\r
-  *     @arg RTC_FLAG_ALRBF: Alarm B flag\r
-  *     @arg RTC_FLAG_ALRAF: Alarm A flag\r
-  *     @arg RTC_FLAG_RSF: Registers Synchronized flag\r
-  * @retval None\r
-  */\r
-void RTC_ClearFlag(uint32_t RTC_FLAG)\r
-{\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_CLEAR_FLAG(RTC_FLAG));\r
-\r
-  /* Clear the Flags in the RTC_ISR register */\r
-  RTC->ISR = (uint32_t)((uint32_t)(~((RTC_FLAG | RTC_ISR_INIT)& 0x0000FFFF) | (uint32_t)(RTC->ISR & RTC_ISR_INIT)));  \r
-}\r
-\r
-/**\r
-  * @brief  Checks whether the specified RTC interrupt has occurred or not.\r
-  * @param  RTC_IT: specifies the RTC interrupt source to check.\r
-  *   This parameter can be one of the following values:\r
-  *     @arg RTC_IT_TS: Time Stamp interrupt \r
-  *     @arg RTC_IT_WUT: WakeUp Timer interrupt \r
-  *     @arg RTC_IT_ALRB: Alarm B interrupt \r
-  *     @arg RTC_IT_ALRA: Alarm A interrupt \r
-  *     @arg RTC_IT_TAMP1: Tamper 1 event interrupt \r
-  * @retval The new state of RTC_IT (SET or RESET).\r
-  */\r
-ITStatus RTC_GetITStatus(uint32_t RTC_IT)\r
-{\r
-  ITStatus bitstatus = RESET;\r
-  uint32_t tmpreg = 0, enablestatus = 0;\r
\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_GET_IT(RTC_IT));\r
-  \r
-  /* Get the TAMPER Interrupt enable bit and pending bit */\r
-  tmpreg = (uint32_t)(RTC->TAFCR & (RTC_TAFCR_TAMPIE));\r
\r
-  /* Get the Interrupt enable Status */\r
-  enablestatus = (uint32_t)((RTC->CR & RTC_IT) | (tmpreg & (RTC_IT >> 15)));\r
-  \r
-  /* Get the Interrupt pending bit */\r
-  tmpreg = (uint32_t)((RTC->ISR & (uint32_t)(RTC_IT >> 4)));\r
-  \r
-  /* Get the status of the Interrupt */\r
-  if ((enablestatus != (uint32_t)RESET) && ((tmpreg & 0x0000FFFF) != (uint32_t)RESET))\r
-  {\r
-    bitstatus = SET;\r
-  }\r
-  else\r
-  {\r
-    bitstatus = RESET;\r
-  }\r
-  return bitstatus;\r
-}\r
-\r
-/**\r
-  * @brief  Clears the RTC's interrupt pending bits.\r
-  * @param  RTC_IT: specifies the RTC interrupt pending bit to clear.\r
-  *   This parameter can be any combination of the following values:\r
-  *     @arg RTC_IT_TS: Time Stamp interrupt \r
-  *     @arg RTC_IT_WUT: WakeUp Timer interrupt \r
-  *     @arg RTC_IT_ALRB: Alarm B interrupt \r
-  *     @arg RTC_IT_ALRA: Alarm A interrupt \r
-  *     @arg RTC_IT_TAMP1: Tamper 1 event interrupt \r
-  * @retval None\r
-  */\r
-void RTC_ClearITPendingBit(uint32_t RTC_IT)\r
-{\r
-  uint32_t tmpreg = 0;\r
-\r
-  /* Check the parameters */\r
-  assert_param(IS_RTC_CLEAR_IT(RTC_IT));\r
-\r
-  /* Get the RTC_ISR Interrupt pending bits mask */\r
-  tmpreg = (uint32_t)(RTC_IT >> 4);\r
-\r
-  /* Clear the interrupt pending bits in the RTC_ISR register */\r
-  RTC->ISR = (uint32_t)((uint32_t)(~((tmpreg | RTC_ISR_INIT)& 0x0000FFFF) | (uint32_t)(RTC->ISR & RTC_ISR_INIT))); \r
-}\r
-\r
-/**\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
-static uint8_t RTC_ByteToBcd2(uint8_t Value)\r
-{\r
-  uint8_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  Convert from 2 digit BCD to Binary.\r
-  * @param  Value: BCD value to be converted.\r
-  * @retval Converted word\r
-  */\r
-static uint8_t RTC_Bcd2ToByte(uint8_t Value)\r
-{\r
-  uint8_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
-/**\r
-  * @}\r
-  */ \r
-\r
-/**\r
-  * @}\r
-  */ \r
-\r
-/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/\r