/* Initializes the RTC registers according to the specified parameters in RTC_InitStruct.  */
ErrorStatus RTC_Init(RTC_InitTypeDef *RTC_InitStruct)
/* Initializes the RTC registers according to the specified parameters in RTC_InitStruct.  */
ErrorStatus RTC_Init(RTC_InitTypeDef *RTC_InitStruct)
{
  ErrorStatus status = ERROR;
  assert_param(IS_RTC_HOUR_FORMAT(RTC_InitStruct->RTC_HourFormat));
  assert_param(IS_RTC_ASYNCH_PREDIV(RTC_InitStruct->RTC_AsynchPrediv));
  assert_param(IS_RTC_SYNCH_PREDIV(RTC_InitStruct->RTC_SynchPrediv));
  RTC->WPR = 0xCA;
  RTC->WPR = 0x53;
  if (RTC_EnterInitMode() == ERROR)
  {
    status = ERROR;
  }
  else
  {
    RTC->CR &= ((uint32_t)~(RTC_CR_FMT));
    RTC->CR |=  ((uint32_t)(RTC_InitStruct->RTC_HourFormat));
    RTC->PRER = (uint32_t)(RTC_InitStruct->RTC_SynchPrediv);
    RTC->PRER |= (uint32_t)(RTC_InitStruct->RTC_AsynchPrediv << 16);
    RTC_ExitInitMode();
    status = SUCCESS;
  }
  RTC->WPR = 0xFF;
  return status;
}