/* Enables or disables the RTC reference clock detection.  */
ErrorStatus RTC_EnableRefClock(FunctionalState Cmd)
/* Enables or disables the RTC reference clock detection.  */
ErrorStatus RTC_EnableRefClock(FunctionalState Cmd)
{
    ErrorStatus status = ERROR;
    assert_param(IS_FUNCTIONAL_STATE(Cmd));
    RTC->WRP = 0xCA;
    RTC->WRP = 0x53;
    if (RTC_EnterInitMode() == ERROR)
    {
       status = ERROR;
    }
    else
    {
       if (Cmd != DISABLE)
       {
          RTC->CTRL |= RTC_CTRL_REFCLKEN;
       }
       else
       {
          RTC->CTRL &= ~RTC_CTRL_REFCLKEN;
       }
       RTC_ExitInitMode();
       status = SUCCESS;
    }
    RTC->WRP = 0xFF;
    return status;
}