/* reset most of the RTC registers 
, V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */
ErrStatus rtc_deinit(void)
/* reset most of the RTC registers 
, V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */
ErrStatus rtc_deinit(void)
{
    ErrStatus error_status = ERROR;
    RTC_TAMP = RTC_REGISTER_RESET;
    RTC_WPK = RTC_UNLOCK_KEY1;
    RTC_WPK = RTC_UNLOCK_KEY2;
    RTC_CTL &= RTC_REGISTER_RESET;
    error_status = rtc_init_mode_enter();
    if(ERROR != error_status){
        RTC_TIME = RTC_REGISTER_RESET;
        RTC_DATE = RTC_DATE_RESET;
        RTC_PSC = RTC_PSC_RESET;
        RTC_STAT = RTC_STAT_RESET;
        RTC_ALRM0TD = RTC_REGISTER_RESET;
        RTC_ALRM0SS = RTC_REGISTER_RESET;
        RTC_SHIFTCTL   = RTC_REGISTER_RESET;       
        RTC_HRFC       = RTC_REGISTER_RESET;
        error_status = rtc_register_sync_wait();  
    }
    RTC_WPK = RTC_LOCK_KEY;
    return error_status;
}