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