/* Initializes the RTC registers according to the specified parameters in RTC_InitStruct.  */
ErrorStatus RTC_Init(RTC_InitType *RTC_InitStruct)
/* Initializes the RTC registers according to the specified parameters in RTC_InitStruct.  */
ErrorStatus RTC_Init(RTC_InitType *RTC_InitStruct)
{
    ErrorStatus status = ERROR;
    assert_param(IS_RTC_HOUR_FORMAT(RTC_InitStruct->RTC_HourFormat));
    assert_param(IS_RTC_PREDIV_ASYNCH(RTC_InitStruct->RTC_AsynchPrediv));
    assert_param(IS_RTC_PREDIV_SYNCH(RTC_InitStruct->RTC_SynchPrediv));
    RTC->WRP = 0xCA;
    RTC->WRP = 0x53;
    if (RTC_EnterInitMode() == ERROR)
    {
        status = ERROR;
    }
    else
    {
        RTC->CTRL &= ((uint32_t) ~(RTC_CTRL_HFMT));
        RTC->CTRL |= ((uint32_t)(RTC_InitStruct->RTC_HourFormat));
        RTC->PRE = (uint32_t)(RTC_InitStruct->RTC_SynchPrediv);
        RTC->PRE |= (uint32_t)(RTC_InitStruct->RTC_AsynchPrediv << 16);
        RTC_ExitInitMode();
        status = SUCCESS;
    }
    RTC->WRP = 0xFF;
    return status;
}