#include "common_include.h"

volatile uint32_t Timer1msCnts = 0;
volatile uint32_t ClusterValidTimerCnts = 0;
uint32_t Timer10msCnts;
volatile uint32_t Timer100usCnts;
FREQUENCE Frequeice;
FREQUENCE BackLight;
uint8_t ADTime;
uint8_t Time_1s_Flag,Time_2s_Flag,Time_Charge_1s,Time_Charge_500ms;
uint32_t Buzz_Timer;
uint8_t Trans_Err_Timer;
uint8_t CANSendEnable;
volatile uint8_t Time_500ms_Flag;
uint16_t IntervalTimerDelta = 0;
uint32_t IntervalTimerCnts = 0;
extern uint16_t Charge_Value;
extern uint8_t CheckClusterValid;
uint16_t Time_Charge_2s_twoUpEnge;
uint16_t Time_Charge_2s_twoTimer;
uint16_t Time_Charge_2s_two;
uint16_t Time_Charge_1s_four;
uint16_t Time_Charge_1s_fourTimer;
uint16_t Time_Charge_2s_Four;
uint16_t Time_Charge_2s_FourTimer;
uint16_t Time_Charge_2s_FourUpEnge;
uint16_t Time_Charge_3s_twoTimer;
uint16_t Time_Charge_3s_twoUpEnge;
uint16_t g_SEAT_BELT_Sound_time = 0;

extern uint8_t  main_board_flag;
volatile uint16_t  BackLight_Value;
uint16_t  Eol_Timer;
uint32_t TftTimer;
uint32_t Err_Timer = 0;
uint8_t Buzz_Play;
void TimeProcessing(void)
{
    if (Timer1msCnts > IntervalTimerCnts) 
    {
        IntervalTimerDelta = (Timer1msCnts - IntervalTimerCnts);
        IntervalTimerCnts = Timer1msCnts;
        //StaticCurrent Time Out State
        
        
        //if(LampState_L.Lamps.RELAY_IGN3 == 1){
        //    if(StaticCurrent.Time < 30000){
        //        StaticCurrent.Time += IntervalTimerDelta;
        //    }
        //}else{
        //    StaticCurrent.Time = 0;
        //}
        
        if (Eol_Timer < 1000 &&   g_Stage == STAGE_SetEOL) {
            Eol_Timer ++;
        }
        if (GetInfoDelayTime > 0)
        {
            GetInfoDelayTime--;     
        }
        if (GetHighBeamDelayTime > 0)
        {
            GetHighBeamDelayTime--;     
        }
        if(time1>0)
        {
            time1--;
        }
        //�ȶ�����5��xxhh close
        if(laohuatime > 0) {
            laohuatime --;
        }
        
        if(Iol_TempCurrent.enable == 1){
            Iol_TempCurrent.Time += IntervalTimerDelta;
        }else{
            Iol_TempCurrent.Time = 0;
        }
        if(OthercountTime > 0) {
            OthercountTime --;
        }
        if(LedCurrent.enable == 1){
            LedCurrent.Time += IntervalTimerDelta;
        }else{
            LedCurrent.Time = 0;
        }
        
        if(ButtomCurrent.enable == 1){
            ButtomCurrent.Time += IntervalTimerDelta;
        }else{
            ButtomCurrent.Time = 0;
        }
        if((TFTCurrent.enable == 1)||(TFTCurrent.count == 30)){
            TFTCurrent.Time += IntervalTimerDelta;
        }else{
            TFTCurrent.Time = 0;
        }
        if(TftCurrent.enable == 1){
            TftCurrent.Time += IntervalTimerDelta;
        }else{
            TftCurrent.Time = 0;
        }
        
        if(ElseCurrent.enable != 0){
            ElseCurrent.Time += IntervalTimerDelta;
            Err_Timer += IntervalTimerDelta;
        }else{
            ElseCurrent.Time = 0;
            Err_Timer = 0;
        }
        
        if(Back_lightCurrent.enable != 0){
            Back_lightCurrent.Time += IntervalTimerDelta;
        }else{ 
            Back_lightCurrent.Time = 0;
            
        } 
        
        if(EndCurrent.enable == 1){
            EndCurrent.Time += IntervalTimerDelta;
        }else{
            EndCurrent.Time = 0;
        }

        if(LCDCurrent.enable == 1){
            LCDCurrent.Time += IntervalTimerDelta;
        }else{
            LCDCurrent.Time = 0;
        }
        
         if(SpeedCurrent.enable == 1){
            SpeedCurrent.Time += IntervalTimerDelta;
        }else{
            SpeedCurrent.Time = 0;
        }

        
        if(BuzzerAlarm.enable == 1){
            BuzzerAlarm.Time += IntervalTimerDelta;
        }else{
            BuzzerAlarm.Time = 0;
        }
        if(CheckCurrent.enable == 1){
            CheckCurrent.Time += IntervalTimerDelta;
            if(CheckCurrent.Time > 10000)
              CheckCurrent.Time = 10000;
        }else{
            CheckCurrent.Time = 0;
        }
        if(HJ_SWitchDownTime > 0) {
            HJ_SWitchDownTime --;
        }
         if(HJ_SWitchUpTime > 0) {
            HJ_SWitchUpTime --;
        } 
        
        // } else {
        //     HJ_SWitchDownSetTimeFalg = 0;
        // }

        
        //StaticCurrent Time Out Stop
        if (main_board_flag)
            Button_Statu_Manage();
        //else
        //    Button_Statu_Manage_Slave();
        
    }
}
uint8_t BlinkDspTimer = 0;
uint8_t PowerCheckTimer = 0;
uint8_t g_CostTimeSecond = 0;
uint32_t g_uiQrQueryTimer = 0;
uint16_t g_uiCommTimer = 0;
uint16_t g_uiDL3CDelayTimer = 0;
uint8_t g_PressTimeSecond = 0;
uint8_t g_uiSeatBeltSoundTimer = 0;
extern uint16_t g_uiFastFlushTimer;
uint8_t ClearOdoFlagTimer = 0; 
#if (SEMI_AUTOMATIC_STAGE)
uint8_t g_PerFuncExecSecond = 0;
#endif
static void TIMER_1MS_ISR(void)
{
#if JLINK_DEBUG_MODE 
    JLINKDCC_Process();
#endif
    Timer1msCnts += 1;
#if (PRO_CONFIG_CHECK_APPLY)
   
    if ((Timer1msCnts - SendCanMessage250msTimer) >= 500) {
        SendCanMessage250msTimer = Timer1msCnts; 
        if (g_uiSeatBeltSoundTimer > 0) {
            
            if (g_uiSeatBeltSoundTimer % 2 == 0){
#if (CAN_3RD)
                BCM_03_200ms.SBR_StBltWrngBzrSta = 0x2;
#endif
#if (CAN_2ND)
                CGW7.msg.bits.CF_Gway_SeatBeltWngBuz = 0x2;
#endif
                g_SEAT_BELT_Count++;
            } else {
#if (CAN_3RD)
                BCM_03_200ms.SBR_StBltWrngBzrSta = 0x0;
#endif
#if (CAN_2ND)
                CGW7.msg.bits.CF_Gway_SeatBeltWngBuz = 0x0;
#endif
            }
            g_uiSeatBeltSoundTimer--;
        }
    }

    if((Timer1msCnts % 500 == 0))
    {
        BlinkDspTimer++;
        if(BlinkDspTimer > 3)
            BlinkDspTimer = 1;
        LampState_M.Lamps.LED1 = 0;
        LampState_M.Lamps.LED2 = 0;
        LampState_M.Lamps.LED3 = 0;
        //LampState_M.Lamps.LED4 = 0;

        if(g_uiUpdateStep == 1) {
            switch(BlinkDspTimer) {
                case 1:
                    LampState_M.Lamps.LED1 = 1;
                    break;
                case 2:
                    LampState_M.Lamps.LED2 = 1;
                    break;
                case 3:
                    LampState_M.Lamps.LED3 = 1;
                    break;
//                case 4:
//                    LampState_M.Lamps.LED4 = 1;
//                    break;
            }
        }
        g_uiFunctionListDspFlag = 0;
    }
#endif
    if(ClearOdoFlagTimer > 0)
    {
        ClearOdoFlagTimer--;
    }

    if (g_uiCommTimer > 0) {
        g_uiCommTimer--;
    }
    if (g_uiQrQueryTimer > 0) {
        g_uiQrQueryTimer -- ;
    }
    if (g_uiFastFlushTimer > 0) {
        g_uiFastFlushTimer--;
    }
    if (g_uiDL3CDelayTimer > 0) {
        g_uiDL3CDelayTimer--;
    }
    if(Timer1msCnts % 1000 == 0)
    {
        Buzz_Play = !Buzz_Play;
        if(PowerCheckTimer > 0)
            PowerCheckTimer--;
        if(EndCurrent.enable == 1 || StaticCurrent.enable == 1) {
          if(g_CostTimeSecond < 1000)
            g_CostTimeSecond++;
        }
        if (g_PressTimeSecond > 0)
            g_PressTimeSecond--;
#if (SEMI_AUTOMATIC_STAGE)
        if (g_PerFuncExecSecond > 0) {
            g_PerFuncExecSecond--;
        }
#endif
    }
    if(Timer1msCnts % 2500 == 0)
    {
        if(InteriorLampTimer > 2)
            InteriorLampTimer = 0;
        InteriorLampTimer++;
    }
    CanRecvLibTimerCall(Timer1msCnts); 
    //button State
    if (ClusterValidTimerCnts) {
        if(g_Stage != STAGE_ClearODO && g_Stage != STAGE_AutoCheck) {
            ClusterValidTimerCnts--;
        }       
        else {
            ClusterValidTimerCnts = CLUSTER_CHECK_TIME;
        }
        if (/*LampState_L.Lamps.RELAY_IGN1 == 0*/0) {
            ClusterValidTimerCnts = CLUSTER_CHECK_TIME;
        }
    } else {
		if (/*LampState_L.Lamps.RELAY_IGN1 == 1*/0) {
			//CheckClusterValid = 0;
            g_uiUpdateStep = 0;
			BarcodeErr = 0u;
			g_Stage = 0;

			Flag_DisplayErr = 0;
			memset((void *)&EOL, 0, sizeof(EOL));
			memset((void *)&StaticCurrent, 0, sizeof(StaticCurrent)); 
			memset((void *)&ButtomCurrent, 0, sizeof(ButtomCurrent)); 
			memset((void *)&LedCurrent, 0, sizeof(LedCurrent));
			memset((void *)&SpeedCurrent, 0, sizeof(SpeedCurrent));
			memset((void *)&Iol_TempCurrent, 0, sizeof(Iol_TempCurrent));
			memset((void *)&TFTCurrent, 0, sizeof(TFTCurrent));
			memset((void *)&Back_lightCurrent, 0, sizeof(Back_lightCurrent));
			memset((void *)&LuminosityCurrent, 0, sizeof(LuminosityCurrent));
			memset((void *)&ElseCurrent, 0, sizeof(ElseCurrent));
			memset((void *)&EndCurrent, 0, sizeof(EndCurrent));
			memset((void *)&BuzzerAlarm, 0, sizeof(BuzzerAlarm));
			memset((void *)&CheckCurrent, 0, sizeof(CheckCurrent));
//#if (CAN_2ND)			
//			WHL_SPD11.msg.bits.WHL_SPD_FL = 0x500;//����40
//			WHL_SPD11.msg.bits.WHL_SPD_RL = 0x500;//����40
//			CGW_PC4.msg.bits.N=0x1F40;//2000  ת��
//			//EMS_01_10ms.ENG_EngSpdVal = 0;
//#endif		
		}
        else {
            ClusterValidTimerCnts = CLUSTER_CHECK_TIME;
        }
    }
    if (TftTimer > 0) {
        TftTimer --;
    }
    if (g_uiB_PlusResetWaitTimer > 0)
    {
        g_uiB_PlusResetWaitTimer--;
    }
    if (g_uiLedWaitTimer > 0){
        g_uiLedWaitTimer--;
    }
    if (g_uiSmartComfortWaitTimer > 0)
        g_uiSmartComfortWaitTimer--;
    
    if(KeyStruct.enable == 1){
        if(KeyStruct.Time > 0){
            KeyStruct.Time --;
        }else{
            KeyStruct.Time = 0;
        }
    }else{
        KeyStruct.Time = 0;
    }

    if(PressKeyStruct.enable == 1)
    {
        PressKeyStruct.Time++;
    }
    else
    {
        PressKeyStruct.Time = 0;
    }
    if(g_uiStepTimerEnable == 1) {
        g_uiStepTimer++;
    }

    
    if(Timer1msCnts % 1000 == 0){
      Time_1s_Flag = 1;
      Time_Charge_500ms++;

      if(Time_Charge_500ms == 4)
        Time_Charge_500ms = 0;
    }else{
      Time_1s_Flag = 0;
    }
    if(Timer1msCnts % 500 == 0)
    {
      Time_500ms_Flag = 1;
      if(StaticCurrent.Value > 5) {
        Charge_Value = StaticCurrent.Value - 5;
      } 
      else {
        Charge_Value = StaticCurrent.Value;
      }
      
    }
    else
    {
      Time_500ms_Flag =0 ;
    }

    if(Timer1msCnts % 300 == 0)
    {
      Time_Charge_1s ++;
      if(Time_Charge_1s == 3)
        Time_Charge_1s = 0;
    }

    if (CheckClusterValid == 1) {
        Get_Button_Value();
    }  
    else
	{
		GET_BUTTON_S30_LEVEL;
		if(BUTTON_S30_IN == 0)
			Botton.S30.Flag = 1;
		else
			Botton.S30.Flag = 0;
		
		GET_BUTTON_S15_LEVEL;
		if(BUTTON_S15_IN == 0)
			Botton.S15.Flag = 1;
		else
			Botton.S15.Flag = 0;
		
		GET_BUTTON_ELSE_LEVEL;
		if(BUTTON_ELSE_IN == 0){
			Botton.Other.Flag = 1;
		}
		else
			Botton.Other.Flag = 0;   
		
		GET_BUTTON_SPEED_UP_LEVEL;
		if(BUTTON_SPEED_UP_IN == 0)
			Botton.SpeedUp.Flag = 1;
		else
			Botton.SpeedUp.Flag = 0;
		
		GET_BUTTON_SPEED_DOWN_LEVEL;
		if(BUTTON_SPEED_DOWN_IN == 0)
			Botton.SpeedDown.Flag = 1;
		else
			Botton.SpeedDown.Flag = 0; 
        
        GET_BUTTON_EOL_LEVEL;
        if(BUTTON_EOL_IN == 0)
            Botton.EOL.Flag = 1;
        else
            Botton.EOL.Flag = 0;

        GET_BUTTON_END_LEVEL;
        if(BUTTON_END_IN == 0)
            Botton.End.Flag = 1;
        else
            Botton.End.Flag = 0;
	}



    //button Stop


    //UDS Time Out Stop
    if(Timer1msCnts % 500 == 0)
    {
        Time_500ms_Flag = 1;
        BackLight_Value = BackLight.Value;   
    }
    else
    {
        Time_500ms_Flag =0 ;
    }
    Time_Charge_1s_fourTimer++;
    if(Time_Charge_1s_fourTimer > 1000)
    {
        Time_Charge_1s_fourTimer = 0;     
        Time_Charge_1s_four++;
      if(Time_Charge_1s_four > 3)
        Time_Charge_1s_four = 0;
    }
    
    Time_Charge_2s_twoTimer++;
    if(Time_Charge_2s_twoTimer > 2000)
    {
        Time_Charge_2s_twoUpEnge = 1;
        Time_Charge_2s_twoTimer = 0;
        Time_Charge_2s_two++;
        if(Time_Charge_2s_two > 1)
            Time_Charge_2s_two = 0;
    }
    Time_Charge_3s_twoTimer++;
    if(Time_Charge_3s_twoTimer > 3000)
    {
        Time_Charge_3s_twoUpEnge = 1;
        Time_Charge_3s_twoTimer = 0;
    }

    Time_Charge_2s_FourTimer++;
    if(Time_Charge_2s_FourTimer > 2000)
    {
       Time_Charge_2s_Four = 1;
       if(Time_Charge_2s_FourTimer > 4000)
       {
         Time_Charge_2s_Four = 2;
         if(Time_Charge_2s_FourTimer > 6000)
         {
           Time_Charge_2s_Four = 3;
           if(Time_Charge_2s_FourTimer > 8000)
           {
             Time_Charge_2s_Four = 0;
             Time_Charge_2s_FourTimer = 0;
           }
         }
       }
    }
}


extern uint32_t Time_100us;
extern uint32_t Time_100us_Uart9;


static void TIMER4_50US_ISR(void)
{    

     if(Time_100us < 0xffffffff)
        Time_100us++;
     if(Time_100us_Uart9 < 0xffffffff)
        Time_100us_Uart9++;

    //TFT �����õ�
    if(UP_VSYNC)
    {
        UpScreenTime ++;
        if(LCDPanelUpdtCtrl.Request == 0)
        {
            if(UpScreenStep == 1)
            {
                if(UpScreenTime >= 66)
                {
                    UpScreenStep = 2;
                }
            }
            else if(UpScreenStep == 2)
            {
                LCD_Panel_Update_Req(64,96);
                UpScreenStep = 3;
            }
            else if(UpScreenStep == 3)
            {
                if(UpScreenTime >= 132)
                {
                    UpScreenStep = 4;
                }
            }
            else if(UpScreenStep == 4)
            {
                LCD_Panel_Update_Req(32,64);
                UpScreenStep = 5;
            }
            else if(UpScreenStep == 5)
            {
                if(UpScreenTime >= 198)
                {
                    UpScreenStep = 6;
                }
            }
            else if(UpScreenStep == 6)
            {
                LCD_Panel_Update_Req(0,32);
                UpScreenStep = 7;
            }
            else if(UpScreenStep == 7)
            {
                if(UpScreenTime >= 264)
                {
                    UpScreenStep = 8;
                }
            }
            else if(UpScreenStep == 8)
            {
                LCD_Panel_Update_Req(128,160);
                UpScreenStep = 9;
            }
        }
    }
    if (BackLight.Flag == 1)
    {
        if (BackLight.Time <= 10000) 
        {
            BackLight.Time++;
        }else
        {
            BackLight.Time = 0;
            BackLight.Value = 0;
            BackLight.Flag = 0;
        }
    } 
    
    if (BackLight.Flag == 0)
    {
        if (BackLight.TimeL <= 10000) 
        {
            BackLight.TimeL++;
        }else
        {
            BackLight.TimeL = 0;
            BackLight.Value = 0;
            BackLight.Flag = 0;
        }
    }
}
static void TIMER5_100US_ISR(void)
{
    /*
    if(Timer100usCnts <0xFFFFFFFF)
    {
        Timer100usCnts++;
    }
    */
 
    //ͨ��һ����
    if (Frequeice.Flag == 1) {
        if (Frequeice.Time <= 10000) {
            Frequeice.Time++;
        }else{
            Frequeice.Time = 0;
            Frequeice.Value = 0;
            Frequeice.Flag = 0;
        }
    } else {
        Frequeice.Time = 0;
        Frequeice.Value = 0;
        Frequeice.Flag = 0;
    }
}


extern uint8_t start_uart_timer;

extern uint8_t g_butto_msg[8];
extern uint8_t uart_send_end_flag;
extern uint8_t uart_send_flag;
extern uint8_t uart_send_count;
extern uint8_t  stop_uart_timer;

uint8_t uart_timer_count;
extern uint8_t Button_Press;
#if (PRO_SG2)
uint32_t MODEtimer = 500;
#elif ((PRO_SK3) || (PRO_KY) || (PRO_KS) || (PRO_US4))
uint32_t MODEtimer = DMS_MODE_INIT_VALUE;
#else
uint32_t MODEtimer = 0;
#endif
uint8_t SetTimeBlinkCount = 0;
uint32_t CANSendCnts = 0;
uint32_t Test_AD;
extern en_port_gpio_level_t BUTTON_S30__IN;
static void TIMER13_10MS_ISR(void)
{
    uint8_t i=0;
    Timer10msCnts += 10; 
    
    	if(Flag_DisplayErr == 1)
	{
		DisplayErrTimer++;
		if(DisplayErrTimer > 100)
		{
			Flag_DisplayErr = 0;
		}
	}
	else
	{
		DisplayErrTimer = 0;
	}

    if (g_Stage == STAGE_AutoCheck) {
        if(StaticCurrent.count < 50){
            StaticCurrent.buf[StaticCurrent.count] = AdcValList[14];//18
            StaticCurrent.count ++;
            if(StaticCurrent.count == 50) {
                StaticCurrent.count = 0;
                for(i=0;i<50;i++){
                    StaticCurrent.sum += StaticCurrent.buf[i];
                }
                StaticCurrent.Value = StaticCurrent.sum/50;
                StaticCurrent.sum = 0;
            }
        } else {
            StaticCurrent.count = 0; 
            StaticCurrent.sum = 0;
            //StaticCurrent.Value = 0;
        }
    }
#if ((PRO_SK3) || (PRO_KY) || (PRO_KS) || (PRO_US4)) 
    if(MODEtimer > 0)
    {
        MODEtimer--;
    }
#else
    if(MODEtimer < 0xffff)
    {
        MODEtimer++;
    }
#endif

    
    
    
     if(Flag_SetTime == 1)
	{
		SetTimeBlinkCount++;
		if(SetTimeBlinkCount == 100)
		{
			SetTimeBlinkCount = 0;
		}
	}
    
    
    
    if (main_board_flag)
    {
        if (1==start_uart_timer)
        {
            uart_timer_count++;
            if (uart_timer_count>30)
            {
                uart_send_flag =1;
                uart_timer_count=0;
                
                uart_send_count++;
                
                if (uart_send_count >10)
                {
                    uart_send_count=0;
                    start_uart_timer=0;
                    uart_send_flag=0;
                    Button_Press=0;
                }
            }

        }
     }
}



void TIMER1_1ms_Init(void)
{
    // RLT - configuration
    stc_rlt_config_t stcRltConfig1 = { 
        .enPrescaler            = RltDiv16,                   // Clock further divided by 16
        .enOperationMode        = RltSoftwareTriggerOnly,     // Trigger with Software
        .b32bitTimerModeEnable  = FALSE,                      // 16bit mode
        .bOutputPolarityInverse = FALSE,                      // normal polarity
        .bOneshotEnable         = FALSE,                      // run cyclic
        .bGateInputEnable       = FALSE,                      // trigger input
        .pfnTriggerCallback     = NULL,         // use callback for interrupt
        .pfnUnderflowCallback   = TIMER_1MS_ISR};
    
    // Init Timer with above configuration
    Bt_Rlt_Init ((stc_btn_rt_t*)&BT01_RT, &stcRltConfig1);
    
    // Start RLT by software trigger, and loads RLT_RELOAD_VALUE
    Bt_Rlt_Start ((stc_btn_rt_t*)&BT01_RT, NULL, (uint32_t) (RLT_RELOAD_1MS_VALUE - 1), TRUE);
}


void TIMER_50us_Init(void)  
{
    stc_rlt_config_t stcRltConfig4 = {
        .enPrescaler            = RltDiv16,                   // Clock further divided by 16
        .enOperationMode        = RltSoftwareTriggerOnly,     // Trigger with Software
        .b32bitTimerModeEnable  = FALSE,                      // 16bit mode
        .bOutputPolarityInverse = FALSE,                      // normal polarity
        .bOneshotEnable         = FALSE,                      // run cyclic
        .bGateInputEnable       = FALSE,                      // trigger input
        .pfnTriggerCallback     = NULL,    // use callback for interrupt
    .pfnUnderflowCallback   = TIMER4_50US_ISR};
    
    // Init Timer with above configuration
    Bt_Rlt_Init ((stc_btn_rt_t*)&BT04_RT, &stcRltConfig4);
    
    // Start RLT by software trigger, and loads RLT_RELOAD_VALUE
    Bt_Rlt_Start ((stc_btn_rt_t*)&BT04_RT, NULL, (uint32_t) RLT_RELOAD_50US_VALUE, TRUE);
}

void TIMER_100us_Init(void)  
{
    stc_rlt_config_t stcRltConfig5 = {
        .enPrescaler            = RltDiv16,                   // Clock further divided by 16
        .enOperationMode        = RltSoftwareTriggerOnly,     // Trigger with Software
        .b32bitTimerModeEnable  = FALSE,                      // 16bit mode
        .bOutputPolarityInverse = FALSE,                      // normal polarity
        .bOneshotEnable         = FALSE,                      // run cyclic
        .bGateInputEnable       = FALSE,                      // trigger input
        .pfnTriggerCallback     = NULL,    // use callback for interrupt
    .pfnUnderflowCallback   = TIMER5_100US_ISR};
    
    // Init Timer with above configuration
    Bt_Rlt_Init ((stc_btn_rt_t*)&BT05_RT, &stcRltConfig5);
    
    // Start RLT by software trigger, and loads RLT_RELOAD_VALUE
    Bt_Rlt_Start ((stc_btn_rt_t*)&BT05_RT, NULL, (uint32_t) RLT_RELOAD_100US_VALUE, TRUE);
}

void TIMER_10ms_Init(void)
{
    stc_rlt_config_t stcRltConfig13 = { .enPrescaler            = RltDiv16,                   // Clock further divided by 16
        .enOperationMode        = RltSoftwareTriggerOnly,     // Trigger with Software
        .b32bitTimerModeEnable  = FALSE,                      // 16bit mode
        .bOutputPolarityInverse = FALSE,                      // normal polarity
        .bOneshotEnable         = FALSE,                      // run cyclic
        .bGateInputEnable       = FALSE,                      // trigger input
        .pfnTriggerCallback     = NULL,         // use callback for interrupt
    .pfnUnderflowCallback   = TIMER13_10MS_ISR};
    
    // Init Timer with above configuration
    Bt_Rlt_Init ((stc_btn_rt_t*)&BT13_RT, &stcRltConfig13);
    
    // Start RLT by software trigger, and loads RLT_RELOAD_VALUE
    Bt_Rlt_Start ((stc_btn_rt_t*)&BT13_RT, NULL, (uint32_t) RLT_RELOAD_10MS_VALUE, TRUE);
}
