#include "common_include.h"

uint32_t TFT_step =10;
uint32_t LIG_step=0;
uint32_t B_step=0;
uint32_t IG_step;
uint32_t SPEED_step;
uint32_t run_step=0;
uint32_t xunhuan=0;
extern uint8_t  R_Speed;
extern uint32_t Speed_down_long;
extern uint16_t Diaplay_test;
extern DATA_SAVE_PACK NewData;
extern uint32_t timeCount;
en_port_gpio_level_t Can1Rx_IN;

en_port_gpio_level_t BUTTON_S30_IN;
en_port_gpio_level_t BUTTON_S15_IN;
en_port_gpio_level_t BUTTON_AUTO_IN;
en_port_gpio_level_t BUTTON_EOL_IN;
en_port_gpio_level_t BUTTON_SPEED_UP_IN;
en_port_gpio_level_t BUTTON_SPEED_DOWN_IN;
en_port_gpio_level_t BUTTON_LED_IN;
en_port_gpio_level_t BUTTON_IOL_UP_IN;
en_port_gpio_level_t BUTTON_IOL_DOWN_IN;
en_port_gpio_level_t BUTTON_TFT_UP_IN;
en_port_gpio_level_t BUTTON_TFT_DOWN_IN;
en_port_gpio_level_t BUTTON_ELSE_IN;
en_port_gpio_level_t BUTTON_END_IN;

en_port_gpio_level_t BUTTON_S_IN;
en_port_gpio_level_t BUTTON_D_IN;
en_port_gpio_level_t BUTTON_N_IN;
en_port_gpio_level_t BUTTON_R_IN;
en_port_gpio_level_t BUTTON_P_IN;
en_port_gpio_level_t BUTTON_1_IN;
en_port_gpio_level_t BUTTON_2_IN;
en_port_gpio_level_t BUTTON_3_IN;
en_port_gpio_level_t BUTTON_4_IN;
en_port_gpio_level_t BUTTON_5_IN;
en_port_gpio_level_t BUTTON_6_IN;


en_port_gpio_level_t BUTTON_DEFOG_IN;
en_port_gpio_level_t BUTTON_HOODOPEN_IN;
en_port_gpio_level_t BUTTON_SEATBELT_IN;
en_port_gpio_level_t BUTTON_ALTL_IN;
en_port_gpio_level_t BUTTON_BREAKOIL_IN;
en_port_gpio_level_t BUTTON_BackLigth_IN;
void Api_GPIO_Init(void)
{
    //-----------------------IN---------------------------//
    stc_port_pin_config_t stc_IN_pin_config =
    {
        .enOutputFunction      = PortOutputResourceGPIO,
        .enOutputDrive         = PortOutputDriveD,
        .enPullResistor        = PortPullResistorNone,
        .bInputEnable          = TRUE,
        .bNoiseFilterEnable    = TRUE,
        .enGpioDirection       = PortGpioInput,
        .enGpioInitOutputLevel = PortGpioLow,
    };
    //��������
    Port_SetPinConfig(0, 24, &stc_IN_pin_config); // 30 1
    Port_SetPinConfig(1, 26, &stc_IN_pin_config); // 15 2
    Port_SetPinConfig(1, 27, &stc_IN_pin_config); // AUTO 3
    Port_SetPinConfig(0, 5, &stc_IN_pin_config); //  EOL 4
    Port_SetPinConfig(1, 29, &stc_IN_pin_config); // SPEED UP 5
    Port_SetPinConfig(1, 30, &stc_IN_pin_config); // SPEED DOWN 6
    Port_SetPinConfig(1, 28,  &stc_IN_pin_config); // LED 7
    Port_SetPinConfig(1, 31,  &stc_IN_pin_config); // IOL UP 8
    Port_SetPinConfig(0, 9,  &stc_IN_pin_config); // IOL DOWN 9
    Port_SetPinConfig(0, 1,  &stc_IN_pin_config); // TFT UP 10
    Port_SetPinConfig(0, 2,  &stc_IN_pin_config); // TFT DOWN 11
    Port_SetPinConfig(0, 3,  &stc_IN_pin_config); // ELSE 12
    Port_SetPinConfig(0, 4,  &stc_IN_pin_config); // END 13
    //��������
    
    //��λ��
//    Port_SetPinConfig(1, 19, &stc_IN_pin_config); // S
//    Port_SetPinConfig(1, 20, &stc_IN_pin_config); // D
//    Port_SetPinConfig(1, 21, &stc_IN_pin_config); // N
//    Port_SetPinConfig(1, 22, &stc_IN_pin_config); // R
//    Port_SetPinConfig(1, 23, &stc_IN_pin_config); // P
   
    //��λ����
    Port_SetPinConfig(2, 13, &stc_IN_pin_config); // N
    Port_SetPinConfig(2, 14, &stc_IN_pin_config); // 1
    Port_SetPinConfig(2, 3, &stc_IN_pin_config);  // 2
    Port_SetPinConfig(2, 20, &stc_IN_pin_config); // 3
    Port_SetPinConfig(2, 29, &stc_IN_pin_config); // 4
    Port_SetPinConfig(2, 27, &stc_IN_pin_config); // 5
    Port_SetPinConfig(2, 12, &stc_IN_pin_config); // 6
    
    //��
    //Port_SetPinConfig(1, 25, &stc_IN_pin_config);
    
   
    
   // Port_SetPinConfig(1, 13, &stc_IN_pin_config);  //����ʻ��ȫ����Ϣ
    Port_SetPinConfig(1, 11, &stc_IN_pin_config);  //ALTL ����
    
    //AD�ɼ���
    Port_SetPinConfig(1, 3, &stc_IN_pin_config); //
    Port_SetPinConfig(1, 7, &stc_IN_pin_config); //
    Port_SetPinConfig(1, 2, &stc_IN_pin_config); //
    Port_SetPinConfig(1, 1, &stc_IN_pin_config); //
    //AD�ɼ���
    //Port_SetPinConfig(1, 18, &stc_IN_pin_config); 
//    Port_SetPinConfig(1, 16, &stc_IN_pin_config);  //����Ƶ��
//    Port_SetPinConfig(1, 15, &stc_IN_pin_config);  //ILLƵ��
    
    Port_EnableInput();
    //-----------------------OUT---------------------------//
    
    stc_port_pin_config_t stc_OUT_pin_config =
    {
        .enOutputFunction      = PortOutputResourceGPIO,
        .enOutputDrive         = PortOutputDriveA,
        .enPullResistor        = PortPullResistorNone,
        .enInputLevel          = PortInputLevelCmosA,
        .bInputEnable          = FALSE,
        .bNoiseFilterEnable    = TRUE,
        .enGpioDirection       = PortGpioOutput,
        .enGpioInitOutputLevel = PortGpioLow,
    };
    
    
    //BD8379����
    // Port_SetPinConfig(2, 4, &stc_OUT_pin_config);  //L_ONEBitCLU_OUT 
    // Port_SetPinConfig(2, 5, &stc_OUT_pin_config);  //L_CLKBitCLU_OUT 
    // Port_SetPinConfig(2, 6, &stc_OUT_pin_config);  //L_SerinBitCLU_OUT 
    // Port_SetPinConfig(2, 7, &stc_OUT_pin_config);  //BD8379_RESB_PIN 
    // Port_SetPinConfig(2, 8, &stc_OUT_pin_config);  //L_LATCHBitCLU_OUT 
    //BD8379���� 
    
    //�µ�Դ
    Port_SetPinConfig(1, 20, &stc_OUT_pin_config);//B+
    Port_SetPinConfig(1, 15, &stc_OUT_pin_config); // B+~
    Port_SetPinConfig(1, 19, &stc_OUT_pin_config);//15
    //�µ�λ��
    Port_SetPinConfig(2, 13, &stc_OUT_pin_config);//N��
    Port_SetPinConfig(2, 14, &stc_OUT_pin_config);//1��
    Port_SetPinConfig(2,  3, &stc_OUT_pin_config); //2��
    Port_SetPinConfig(2, 20, &stc_OUT_pin_config);//3��
    Port_SetPinConfig(2, 29, &stc_OUT_pin_config);//4��
    Port_SetPinConfig(2, 27, &stc_OUT_pin_config);//5��
    Port_SetPinConfig(2, 12, &stc_OUT_pin_config);//6��
    
    // ������λ
    Port_SetPinConfig(2, 9, &stc_OUT_pin_config);//N��
    Port_SetPinConfig(2, 10, &stc_OUT_pin_config);//1��
    Port_SetPinConfig(2, 8, &stc_OUT_pin_config); //2��
    Port_SetPinConfig(2, 7, &stc_OUT_pin_config);//3��
    Port_SetPinConfig(2, 6, &stc_OUT_pin_config);//4��
    Port_SetPinConfig(2, 5, &stc_OUT_pin_config);//5��
    Port_SetPinConfig(2, 4, &stc_OUT_pin_config);//6��
    
    //��
    Port_SetPinConfig(2, 0, &stc_OUT_pin_config);//��ת
    Port_SetPinConfig(1, 24, &stc_OUT_pin_config);//��ת
    Port_SetPinConfig(2, 1, &stc_OUT_pin_config);//Զ��
    //Port_SetPinConfig(2, 21, &stc_OUT_pin_config);//ABS
    Port_SetPinConfig(0, 0, &stc_OUT_pin_config);//����ѹ��
    
   
   //ȼ��
   Port_SetPinConfig(1, 25, &stc_OUT_pin_config);//1��
   Port_SetPinConfig(1, 23, &stc_OUT_pin_config);//2��
   Port_SetPinConfig(1, 22, &stc_OUT_pin_config);//3��
   Port_SetPinConfig(1, 21, &stc_OUT_pin_config);//4��
   Port_SetPinConfig(1, 13, &stc_OUT_pin_config);//5��
   Port_SetPinConfig(1, 11, &stc_OUT_pin_config);//6��
   Port_SetPinConfig(1, 10, &stc_OUT_pin_config);//7��
   Port_SetPinConfig(0, 27, &stc_OUT_pin_config);//8��
    
    
    Port_SetPinConfig(2, 0, &stc_OUT_pin_config);  //AIRBAG
    //Port_SetPinConfig(2, 3, &stc_OUT_pin_config);  //SEATSAFE��
    Port_SetPinConfig(2, 20, &stc_OUT_pin_config); //����ѹ��
    Port_SetPinConfig(2, 26, &stc_OUT_pin_config); //DEFOG
    Port_SetPinConfig(2, 27, &stc_OUT_pin_config); //DEFOG
    Port_SetPinConfig(2, 19, &stc_OUT_pin_config); //HOODOPEN
    Port_SetPinConfig(2, 29, &stc_OUT_pin_config); //SEATBELT
    Port_SetPinConfig(2, 28, &stc_OUT_pin_config); //SEATMAT
    //Port_SetPinConfig(0, 0, &stc_OUT_pin_config);  //ALTL   
    //Port_SetPinConfig(2, 21, &stc_OUT_pin_config); //BREAK OIL
    Port_SetPinConfig(1, 24, &stc_OUT_pin_config); //R_MT
    //Port_SetPinConfig(2, 14, &stc_OUT_pin_config); //����
    Port_SetPinConfig(1, 18, &stc_OUT_pin_config); //������
    
    //IIC����
    Port_SetPinConfig(1, 8, &stc_OUT_pin_config);  //I2C_SCL_OUT 
    Port_SetPinConfig(1, 9, &stc_OUT_pin_config);  //I2C_SDA_OUT
    //IIC����
    
    Port_SetPinConfig(2, 0, &stc_OUT_pin_config);  //CSB0LCD_OUT 
    Port_SetPinConfig(2, 1, &stc_OUT_pin_config);  //SEG0LCD_OUT 
    //TFT���� 
    
    //CANSTB��
    Port_SetPinConfig(1, 2, &stc_OUT_pin_config); // 
    Port_SetPinConfig(0, 29, &stc_OUT_pin_config); // 
    //CANSTB��
    
    //��̬������
    Port_SetPinConfig(1, 4, &stc_OUT_pin_config); //GS1
    Port_SetPinConfig(1, 5, &stc_OUT_pin_config); //GS0
    //��̬������
    Port_SetPortPinLevel(1, 4, PortGpioLow);
    Port_SetPortPinLevel(1, 5, PortGpioHigh);

//    Port_SetPinConfig(1, 6, &stc_OUT_pin_config); // 
//    Port_SetPinConfig(1, 7, &stc_OUT_pin_config); // 
//    Port_SetPortPinLevel(1, 6, PortGpioLow);
//    Port_SetPortPinLevel(1, 7, PortGpioHigh);
    
    stc_port_pin_config_t stc_OUT_pin_high_config =
    {
        .enOutputFunction      = PortOutputResourceGPIO,
        .enOutputDrive         = PortOutputDriveA,
        .enPullResistor        = PortPullResistorNone,
        .enInputLevel          = PortInputLevelCmosA,
        .bInputEnable          = FALSE,
        .bNoiseFilterEnable    = TRUE,
        .enGpioDirection       = PortGpioOutput,
        .enGpioInitOutputLevel = PortGpioHigh,
    };
    Port_SetPinConfig(2, 28, &stc_OUT_pin_high_config); //AIRBAG_OFF_OUT 
    //Port_SetPinConfig(0, 24, &stc_OUT_pin_high_config);
     
    //��λ����
    //Port_SetPinConfig(2, 13, &stc_OUT_pin_high_config);
    //Port_SetPinConfig(0, 0, &stc_OUT_pin_high_config);//����ѹ��
    Port_SetPinConfig(2, 21, &stc_OUT_pin_high_config);
//    Port_SetPinConfig(0, 24, &stc_OUT_pin_high_config);//B+
//    Port_SetPinConfig(1, 26, &stc_OUT_pin_high_config);//15

    stc_port_pin_config_t stc_OUT_pin_config2 =
    {
        .enOutputFunction      = PortOutputResourceG,
        .enOutputDrive         = PortOutputDriveA,
        .enPullResistor        = PortPullResistorNone,
        .enInputLevel          = PortInputLevelCmosA,
        .bInputEnable          = FALSE,
        .bNoiseFilterEnable    = TRUE,
        .enGpioDirection       = PortGpioOutput,
        .enGpioInitOutputLevel = PortGpioLow,
    };
    //����ת��
    
   Port_SetPinConfig(1, 17, &stc_OUT_pin_config2);//����
   Port_SetPinConfig(1, 16, &stc_OUT_pin_config2);//ת��
}


void ApiPowerSupply(void)
{
    //�ϵ�ʱ�� 
    //DelayMs(6);//6ms
    
    //P_VCC4V2_EN_NEW(PortGpioLow);// P1_25 Pin97
    
   // DelayMs(1000);//125ms
    
    P_3V3MCU_EN(PortGpioHigh);//64pin     104
    
   // P_APOWER_OUT(PortGpioHigh);//91pin     119
    
//    P_RELAY_B_MCU(PortGpioHigh);//85pin
    P_RELAY_IG_MCU(PortGpioHigh);
    //P_30MCU_EN(PortGpioHigh);//91pin    
    
    //DelayMs(1500);//1500ms
    
    //P_VCC3V3_EN(PortGpioHigh);//106pin    200
    
    
    
    //DelayMs(2);//1ms 
    
    //F_LCD_RESET(PortGpioHigh);//103pin      129
    
    F_LCD_STBYB(PortGpioHigh);//6pin      004
    
    //DelayMs(1);
    
    P_1531_EN(PortGpioHigh);
    
    //DelayMs(115);//115ms
    
    //P_61194_EN(PortGpioHigh);//125pin    213
    
    //P_APOWER_OUT(PortGpioHigh);//91pin     119
    
    //NEW_F_Sound_EN(PortGpioHigh);//����ʹ��
    
    P_BD12_EN(PortGpioHigh);
    //LIG_HighBeam_OUT(PortGpioHigh);
    
    //P_TPA6211_EN(PortGpioHigh);
    //P_61194_EN(PortGpioLow);
    //LIG_Oil_OUT(PortGpioLow);
}  



void Gear_Step()
{
  if(TFT_step==10)
  {
   GEAR_N_OUT(PortGpioHigh);
  }
  else
  {
    GEAR_N_OUT(PortGpioLow);
  }
  if(TFT_step==11)
  {
    GEAR_1_OUT(PortGpioHigh);
  }
  else
  {
    GEAR_1_OUT(PortGpioLow);
  }
  if(TFT_step==12)
  {
    GEAR_2_OUT(PortGpioHigh);
  }
  else
  {
    GEAR_2_OUT(PortGpioLow);
  }
  if(TFT_step==13)
  {
    GEAR_3_OUT(PortGpioHigh);
  }
  else
  {
    GEAR_3_OUT(PortGpioLow);
  }
  if(TFT_step==14)
  {
    GEAR_4_OUT(PortGpioHigh);
  }
  else
  {
    GEAR_4_OUT(PortGpioLow);
  }
   if(TFT_step==15)
  {
    GEAR_5_OUT(PortGpioHigh);
  }
  else
  {
    GEAR_5_OUT(PortGpioLow);
  }
   if(TFT_step==16)
  {
    GEAR_6_OUT(PortGpioHigh);
  }
  else
  {
    GEAR_6_OUT(PortGpioLow);
  }
}  
void light()
{
  if(LIG_step==1)
  {
    //LIG_left_OUT(PortGpioHigh);
  }
  if(LIG_step==2)
  {
    //LIG_left_OUT(PortGpioLow);
    //LIG_right_OUT(PortGpioHigh);
  }
  if(LIG_step==3)
  {
    //LIG_right_OUT(PortGpioLow);
    LIG_HighBeam_OUT(PortGpioHigh);
  }
  if(LIG_step==4)
  {
    LIG_HighBeam_OUT(PortGpioLow);
    LIG_ABS_OUT(PortGpioLow);
  }
  if(LIG_step==5)
  {
    LIG_ABS_OUT(PortGpioHigh);
    LIG_Oil_OUT(PortGpioHigh);
  }
  if(LIG_step==6)
  {
    //LIG_left_OUT(PortGpioHigh);
    //LIG_right_OUT(PortGpioHigh);
    LIG_HighBeam_OUT(PortGpioHigh);
    LIG_ABS_OUT(PortGpioLow);
    LIG_Oil_OUT(PortGpioHigh);
  }
   if(LIG_step>=7)
  {
    LIG_step=0;
    //LIG_left_OUT(PortGpioLow);
    //LIG_right_OUT(PortGpioLow);
    LIG_HighBeam_OUT(PortGpioLow);
    LIG_ABS_OUT(PortGpioHigh);
    LIG_Oil_OUT(PortGpioLow);
  }
}

//void _B()
//{
//  if(B_step % 2==0)//�ж�b+ �ϵ�
//  {
//    P_RELAY_B_MCU(PortGpioLow);
////    if(IG_step %2==0)
////    {
////      P_RELAY_IG_MCU(PortGpioLow);
////    }
//  }
//  if(B_step %2 != 0)//�ж�B+ �ϵ�
//  {
//    P_RELAY_B_MCU(PortGpioHigh);
//    if(IG_step %2 !=0)//�ж�ig �ϵ�
//    {
//      P_RELAY_IG_MCU(PortGpioHigh);
//    }
//  } 
//  if(IG_step %2==0)//������ig ��
//    {
//      P_RELAY_IG_MCU(PortGpioLow);
//    }
//  
//}

void Auto_Power_change()
{
  if(timeCount<240)
  {
      P_RELAY_IG_MCU(PortGpioHigh);
      P_RELAY_B_MCU(PortGpioHigh);
}
  if(timeCount>240 && timeCount<540)
  {
     P_RELAY_B_MCU(PortGpioLow);
     P_RELAY_IG_MCU(PortGpioLow);
  }
  if(timeCount>540)
  {
     timeCount=0;
  }
}
uint8_t a = 0;
void SPEED_Step()
{
  //uint32_t speed = 0;
  //_OIL1_out(PortGpioLow);
  //_OIL2_out(PortGpioLow);
  //_OIL3_out(PortGpioLow);
  //_OIL4_out(PortGpioLow);
  //_OIL5_out(PortGpioLow);
  //_OIL6_out(PortGpioLow);
  //_OIL7_out(PortGpioLow);
  //_OIL8_out(PortGpioLow);
  //LIG_left_OUT(PortGpioLow);
  //LIG_right_OUT(PortGpioLow);
  ////GEAR_N_OUT(PortGpioHigh);//λ�õ�(��λN����)
  //
  //GEAR_1_OUT(PortGpioLow);//����
  //GEAR_2_OUT(PortGpioLow);//������
  //GEAR_3_OUT(PortGpioHigh);//ABSָʾ��
  //GEAR_4_OUT(PortGpioLow);//TCS
  // LIG_HighBeam_OUT(PortGpioLow);
  switch (SPEED_step)
  {
    
    case 0:
      LIG_right_OUT(PortGpioLow);//大灯
      LIG_left_OUT(PortGpioLow);//草满指示灯
      SOC1.msg.bits.MBMS_Soc = 0;
      SOC2.msg.bits.MBMS_Soc = 0;
      CAN125.msg.bits.MMCU_TravelSpeedGear = 0;//挡位
      CAN125.msg.bits.MMCU_ParkingGearState = 0;//P档
      CAN157.msg.bits.BMCU_BladeSpeedGear = 0;//刀盘挡位

     CAN38E.msg.bits.BMCU_Moto1_Locked_RotorFault = 0;//刀盘过载指示灯 1 || 2亮
     CAN38E.msg.bits.BMCU_Moto2_Locked_RotorFault = 0;

     CAN125.msg.bits.MMCU_SeatDetectState = 0;//座椅检测
     CAN18202922.msg.bits.MBMS_TOTALSigAcc = 0;//钥匙接入
     CAN157.msg.bits.BMCU_PTOSwicthState = 0;//刀盘开关
      CAN125.msg.bits.MMCU_PowerMode = 0x2;//READY灯 电源
    CAN18202922.msg.bits.MBMS_TOTALSigAcc = 0;
    CAN18202922.msg.bits.MBMS_TOTALSigCharg = 0;//充电指示灯

    CAN18203220.msg.bits.MBMS_StatBattChargeState = 0x05;
    CAN18203220.msg.bits.MBMS_StatBattWorkState = 0xE;

    CAN18203020.msg.bits.MBMS_StatSoc = 0;
    
    break;
    case 1:
    LIG_left_OUT(PortGpioHigh);//草满指示灯
    SOC1.msg.bits.MBMS_Soc = 10;
    SOC2.msg.bits.MBMS_Soc = 10;
    CAN125.msg.bits.MMCU_TravelSpeedGear = 1;
    CAN157.msg.bits.BMCU_BladeSpeedGear = 0;

    CAN18203020.msg.bits.MBMS_StatSoc = 10;
  
    break;
    case 2:
    LIG_left_OUT(PortGpioLow);//草满指示灯

    CAN38E.msg.bits.BMCU_Moto1_Locked_RotorFault = 1;//刀盘
    SOC1.msg.bits.MBMS_Soc = 30;
    SOC2.msg.bits.MBMS_Soc = 30;
    CAN125.msg.bits.MMCU_TravelSpeedGear = 2;
    CAN157.msg.bits.BMCU_BladeSpeedGear = 1;

    
    CAN18203020.msg.bits.MBMS_StatSoc = 20;
    break;
    case 3:
    CAN38E.msg.bits.BMCU_Moto1_Locked_RotorFault = 0;//刀盘

    CAN125.msg.bits.MMCU_SeatDetectState = 1;//座椅检测
    SOC1.msg.bits.MBMS_Soc = 50;
    SOC2.msg.bits.MBMS_Soc = 50;
    CAN125.msg.bits.MMCU_TravelSpeedGear = 0;
    CAN125.msg.bits.MMCU_ParkingGearState = 1;//P档
    CAN157.msg.bits.BMCU_BladeSpeedGear = 2;

    
    CAN18203020.msg.bits.MBMS_StatSoc = 30;
  
    break;
    case 4:
    CAN125.msg.bits.MMCU_SeatDetectState = 0;//座椅检测

    CAN18202922.msg.bits.MBMS_TOTALSigAcc = 1;//钥匙接入
    SOC1.msg.bits.MBMS_Soc = 70;
    SOC2.msg.bits.MBMS_Soc = 70;

    CAN125.msg.bits.MMCU_TravelSpeedGear = 0;
    CAN125.msg.bits.MMCU_ParkingGearState = 1;//P档

    CAN157.msg.bits.BMCU_BladeSpeedGear = 3;

    
    CAN18203020.msg.bits.MBMS_StatSoc = 40;
  
    break;
    case 5:
    CAN18202922.msg.bits.MBMS_TOTALSigAcc = 0;//钥匙接入

    CAN125.msg.bits.MMCU_PowerMode = 3;//READY灯
    SOC1.msg.bits.MBMS_Soc = 100;
    SOC2.msg.bits.MBMS_Soc = 90;

    CAN125.msg.bits.MMCU_TravelSpeedGear = 0;
    CAN125.msg.bits.MMCU_ParkingGearState = 1;//P档

    CAN157.msg.bits.BMCU_BladeSpeedGear = 3;

    
    CAN18203020.msg.bits.MBMS_StatSoc = 50;
    break;
    case 6:
    CAN125.msg.bits.MMCU_PowerMode = 2;//READY灯

    CAN125.msg.bits.MMCU_PowerMode = 5;
    CAN18202922.msg.bits.MBMS_TOTALSigAcc = 1;
    CAN18202922.msg.bits.MBMS_TOTALSigCharg = 1;//充电指示灯

    SOC1.msg.bits.MBMS_Soc = 100;
    SOC2.msg.bits.MBMS_Soc = 100;

    CAN125.msg.bits.MMCU_TravelSpeedGear = 0;
    CAN125.msg.bits.MMCU_ParkingGearState = 1;//P档

    CAN157.msg.bits.BMCU_BladeSpeedGear = 3;

    
    CAN18203020.msg.bits.MBMS_StatSoc = 60;
  
    break;
    
    case 7:
    CAN125.msg.bits.MMCU_PowerMode = 2;
    CAN18202922.msg.bits.MBMS_TOTALSigAcc = 0;
    CAN18202922.msg.bits.MBMS_TOTALSigCharg = 0;//充电指示灯


    CAN157.msg.bits.BMCU_PTOSwicthState = 1;//刀盘开关
    SOC1.msg.bits.MBMS_Soc = 100;
    SOC2.msg.bits.MBMS_Soc = 100;

    CAN125.msg.bits.MMCU_TravelSpeedGear = 0;
    CAN125.msg.bits.MMCU_ParkingGearState = 1;//P档

    CAN157.msg.bits.BMCU_BladeSpeedGear = 3;

    
    CAN18203020.msg.bits.MBMS_StatSoc = 70;
    break;
    case 8:
    CAN157.msg.bits.BMCU_PTOSwicthState = 0;//刀盘开关


    LIG_right_OUT(PortGpioHigh);
    SOC1.msg.bits.MBMS_Soc = 100;
    SOC2.msg.bits.MBMS_Soc = 100;

    CAN125.msg.bits.MMCU_TravelSpeedGear = 0;
    CAN125.msg.bits.MMCU_ParkingGearState = 1;//P档

    CAN157.msg.bits.BMCU_BladeSpeedGear = 3;

    
    CAN18203020.msg.bits.MBMS_StatSoc = 80;
     break;
    case 9:
   LIG_right_OUT(PortGpioLow);
  LIG_left_OUT(PortGpioLow);//草满指示灯

   SOC1.msg.bits.MBMS_Soc = 100;
    SOC2.msg.bits.MBMS_Soc = 100;

   CAN125.msg.bits.MMCU_TravelSpeedGear = 0;
    CAN125.msg.bits.MMCU_ParkingGearState = 1;//P档

    CAN157.msg.bits.BMCU_BladeSpeedGear = 3;

    CAN18203020.msg.bits.MBMS_StatSoc = 90;
      break;
    case 10:
    LIG_right_OUT(PortGpioHigh);//大灯
      LIG_left_OUT(PortGpioHigh);//草满指示灯

    CAN38E.msg.bits.BMCU_Moto1_Locked_RotorFault = 1;//刀盘过载指示灯 1 || 2亮
     CAN38E.msg.bits.BMCU_Moto2_Locked_RotorFault = 0;

     CAN125.msg.bits.MMCU_SeatDetectState = 1;//座椅检测
     CAN18202922.msg.bits.MBMS_TOTALSigAcc = 1;//钥匙接入
     CAN157.msg.bits.BMCU_PTOSwicthState = 1;//刀盘开关
      CAN125.msg.bits.MMCU_PowerMode = 0x3;//READY灯 电源
    CAN18202922.msg.bits.MBMS_TOTALSigAcc = 1;
    CAN18202922.msg.bits.MBMS_TOTALSigCharg = 1;//充电指示灯

    CAN18203220.msg.bits.MBMS_StatBattChargeState = 0x07;
    CAN18203220.msg.bits.MBMS_StatBattWorkState = 0xF;
    CAN157.msg.bits.BMCU_BladeSpeedGear = 3;
    //CAN125.msg.bits.MMCU_TravelSpeedGear = 0x3;
    CAN339.msg.bits.MMCU_AccumulatedWorkHour_L = (6006)&0xFF;
    CAN339.msg.bits.MMCU_AccumulatedWorkHour_H = (6006>>8)&0xFF;

    CAN125.msg.bits.MMCU_TravelSpeedGear = 0;
    CAN125.msg.bits.MMCU_ParkingGearState = 1;//P档

    
    CAN18203020.msg.bits.MBMS_StatSoc = 100;
      break;
    //case 11:
    //   TCS_125.msg.bits.TCS_WorkMode = 0x1; //TCSָʾ�ƿ���
    // TCS_125.msg.bits.TCS_WarningLamp = 0x0; //TCSָʾ�ƿ���
    //  TCS_125.msg.bits.TCS_SysState = 0x1; //TCSָʾ�ƿ���
    //  LIG_left_OUT(PortGpioHigh);//left light open
    //  TCU11.msg.bits.ISG_Power_Enable = 0x0; //����ʹ�ܹر�
    // //ECU_101.msg.bits.ECU_Vehicle_Speed =200;  //����200
    // TCU13.msg.bits.Tbatt = 120;//����¶�
    // ECU_401.msg.bits.ECU_Battery_Voltage = 150;//��ѹ
    // VEH_Output_Update(PWMCH_VEH_OUT, 1666.6, 50); //�������2000Hz
    //  REV_Output_Update(PWMCH_REV_OUT, 200, 50); //ת�����200Hz
    // ECU_114.msg.bits.ISG_DTC_START_H = 0;
    // ECU_114.msg.bits.ISG_DTC_ISTOP_H = 1;
    // ECU_101.msg.bits.ECU_Engine_Temperature_H = 0x0F;
    // ECU_101.msg.bits.ECU_Engine_Temperature_L = 0x5A;
    //  _OIL4_out(PortGpioHigh);//����
    //  TBOX.msg.bits.TBOX_WorkMode=0;//TBOXָʾ��
    //  ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water =0xF0;//ˮ��
    // _GEAR1_out(PortGpioLow);
    // _GEAR2_out(PortGpioLow);
    // _GEAR3_out(PortGpioLow);
    // _GEAR4_out(PortGpioLow);
    // _GEAR5_out(PortGpioLow);
    // _GEAR6_out(PortGpioHigh);
    // _GEARN_out(PortGpioLow);
    //  break; 
    //case 12:
    //  TCS_125.msg.bits.TCS_WorkMode = 0x1; //TCSָʾ�ƿ���
    // TCS_125.msg.bits.TCS_WarningLamp = 0x0; //TCSָʾ�ƿ���
    //  TCS_125.msg.bits.TCS_SysState = 0x1; //TCSָʾ�ƿ���
    //  LIG_left_OUT(PortGpioLow);//left light open
    //  LIG_Oil_OUT(PortGpioHigh);   //Oil light open
    //  TCU11.msg.bits.ISG_Power_Enable = 0x1; //����ʹ��
    //  TCU11.msg.bits.ISG_Ready = 0x0; //�綯����״̬�ر�
    // ECU_101.msg.bits.ECU_Vehicle_Speed =240;  //����240
    // TCU13.msg.bits.Tbatt = 130;//����¶�
    // ECU_401.msg.bits.ECU_Battery_Voltage = 160;//��ѹ
    // VEH_Output_Update(PWMCH_VEH_OUT, 1794, 50); //�������2000Hz
    // REV_Output_Update(PWMCH_REV_OUT, 200, 50); //ת�����200Hz
    // ECU_114.msg.bits.ISG_DTC_ISTOP_H = 2;
    // ECU_101.msg.bits.ECU_Engine_Temperature_H = 0x0F;
    // ECU_101.msg.bits.ECU_Engine_Temperature_L = 0x5A;
    // ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water =0xF0;//ˮ��
    //  _OIL4_out(PortGpioHigh);//����
    // _GEAR1_out(PortGpioLow);
    // _GEAR2_out(PortGpioLow);
    // _GEAR3_out(PortGpioLow);
    // _GEAR4_out(PortGpioLow);
    // _GEAR5_out(PortGpioLow);
    // _GEAR6_out(PortGpioHigh);
    // _GEARN_out(PortGpioLow);
    //  break; 
    //case 13:
    //  TCU11.msg.bits.ISG_Ready = 0x1; //�綯����״̬����
    //  TCS_125.msg.bits.TCS_WorkMode = 0x1; //TCSָʾ�ƿ���
    // TCS_125.msg.bits.TCS_WarningLamp = 0x0; //TCSָʾ�ƿ���
    //  TCS_125.msg.bits.TCS_SysState = 0x1; //TCSָʾ�ƿ���
    //  LIG_left_OUT(PortGpioLow);//left light open
    //  LIG_Oil_OUT(PortGpioLow);   //Oil light open
    //  TCU11.msg.bits.ISG_Power_Enable = 0x0; //����ʹ�ܹر�
    //  TCU11.msg.bits.ISG_Power = 0x0; //�綯ִ��״̬�ر�
    // ECU_101.msg.bits.ECU_Vehicle_Speed =100;  //����100
    // TCU13.msg.bits.Tbatt = 140;//����¶�
    // ECU_401.msg.bits.ECU_Battery_Voltage = 170;//��ѹ
    // VEH_Output_Update(PWMCH_VEH_OUT, 1923, 50); //�������2000Hz
    //  REV_Output_Update(PWMCH_REV_OUT, 200, 50); //ת�����200Hz
    // ECU_114.msg.bits.ISG_DTC_ISTOP_H = 3;
    // ECU_101.msg.bits.ECU_Engine_Temperature_H = 0x0F;
    // ECU_101.msg.bits.ECU_Engine_Temperature_L = 0x5A;
    //  _OIL4_out(PortGpioHigh);//����
    //  ECU_Engine_Data_M2.msg.bits.ECU_MILLampSts =1;//�綯������
    //  ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water =0xF0;//ˮ��
    // _GEAR1_out(PortGpioLow);
    // _GEAR2_out(PortGpioLow);
    // _GEAR3_out(PortGpioLow);
    // _GEAR4_out(PortGpioLow);
    // _GEAR5_out(PortGpioLow);
    // _GEAR6_out(PortGpioHigh);
    // _GEARN_out(PortGpioLow);
    //  break; 
    //case 14:
    //  TCU11.msg.bits.ISG_Ready = 0x0; //�綯����״̬�ر�
    //  TCS_125.msg.bits.TCS_WorkMode = 0x1; //TCSָʾ�ƿ���
    // TCS_125.msg.bits.TCS_WarningLamp = 0x0; //TCSָʾ�ƿ���
    //  TCS_125.msg.bits.TCS_SysState = 0x1; //TCSָʾ�ƿ���
    //  LIG_left_OUT(PortGpioLow);//left light open
    //  LIG_HighBeam_OUT(PortGpioHigh); //HighBeam light open
    //  TCU11.msg.bits.ISG_Power = 0x1; //�綯ִ��״̬����
    //  TCU11.msg.bits.ISG_Batt = 0x0; //����״̬�ر�
    // ECU_101.msg.bits.ECU_Vehicle_Speed =40;  //����40
    // VEH_Output_Update(PWMCH_VEH_OUT, 2051, 50); //�������2000Hz
    //  REV_Output_Update(PWMCH_REV_OUT, 200, 50); //ת�����200Hz
    // TCU13.msg.bits.Tbatt = 150;//����¶�
    // ECU_401.msg.bits.ECU_Battery_Voltage = 180;//��ѹ
    // ECU_114.msg.bits.ISG_DTC_ISTOP_H = 4;
    // ECU_101.msg.bits.ECU_Engine_Temperature_H = 0x0F;
    // ECU_101.msg.bits.ECU_Engine_Temperature_L = 0x5A;
    //  _OIL4_out(PortGpioHigh);//����
    //  ECU_Engine_Data_M2.msg.bits.ECU_MILLampSts =0;//�綯������
    //  ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water =0xF0;//ˮ��
    // _GEAR1_out(PortGpioLow);
    // _GEAR2_out(PortGpioLow);
    // _GEAR3_out(PortGpioLow);
    // _GEAR4_out(PortGpioLow);
    // _GEAR5_out(PortGpioLow);
    // _GEAR6_out(PortGpioHigh);
    // _GEARN_out(PortGpioLow);
    //  break; 
    //case 15:
    // LIG_HighBeam_OUT(PortGpioLow); //HighBeam light open
    //  LIG_ABS_OUT(PortGpioLow);//ABS light open
    //  TCS_125.msg.bits.TCS_WorkMode = 0x1; //TCSָʾ�ƿ���
    // TCS_125.msg.bits.TCS_WarningLamp = 0x0; //TCSָʾ�ƿ���
    //  TCS_125.msg.bits.TCS_SysState = 0x1; //TCSָʾ�ƿ���
    //  TCU11.msg.bits.ISG_Batt = 0x1; //����״̬����
    //  TCU11.msg.bits.ISG_Power = 0x0; //�綯ִ��״̬�ر�
    // ECU_101.msg.bits.ECU_Vehicle_Speed =25;  //����25
    // TCU13.msg.bits.Tbatt = 160;//����¶�
    // ECU_401.msg.bits.ECU_Battery_Voltage = 190;//��ѹ
    // VEH_Output_Update(PWMCH_VEH_OUT, 1923, 50); //�������2000Hz
    //  REV_Output_Update(PWMCH_REV_OUT, 200, 50); //ת�����200Hz
    // ECU_114.msg.bits.ISG_DTC_ISTOP_H = 8;
    // ECU_101.msg.bits.ECU_Engine_Temperature_H = 0x0F;
    // ECU_101.msg.bits.ECU_Engine_Temperature_L = 0x5A;
    // ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water =0xF0;//ˮ��
    //  _OIL4_out(PortGpioHigh);//����
    // _GEAR1_out(PortGpioLow);
    // _GEAR2_out(PortGpioLow);
    // _GEAR3_out(PortGpioLow);
    // _GEAR4_out(PortGpioLow);
    // _GEAR5_out(PortGpioLow);
    // _GEAR6_out(PortGpioHigh);
    // _GEARN_out(PortGpioLow);
    //  break; 
    //case 16:
    //  //LIG_left_OUT(PortGpioHigh);//left light open
    //  TCU13.msg.bits.ISTOP_display = 0x1;  //ASC light open
    //  //LIG_HighBeam_OUT(PortGpioHigh); //HighBeam light open
    //  ECU_402.msg.bits.ECU_Warning_Lamp = 0x1; //Engine malfunction light open
    //  LIG_Oil_OUT(PortGpioLow);   //Oil light open
    //  LIG_ABS_OUT(PortGpioHigh);//ABS light open
    //  LIG_right_OUT(PortGpioHigh);//right light open
    //  TCU13.msg.bits.LIGHT_0N = 0x1; //autolight light open
    //   TCS_125.msg.bits.TCS_WorkMode = 0x1; //TCSָʾ�ƿ���
    // TCS_125.msg.bits.TCS_WarningLamp = 0x0; //TCSָʾ�ƿ���
    //  TCS_125.msg.bits.TCS_SysState = 0x1; //TCSָʾ�ƿ���
    //  TCU11.msg.bits.ISG_Batt = 0x1; //����״̬����
    //  TCU11.msg.bits.ISG_Power = 0x1; //�綯ִ��״̬����
    //  TCU11.msg.bits.ISG_Power_Enable = 0x1; //����ʹ��  
    //  TCU11.msg.bits.ISG_Ready = 0x1; //�綯����״̬����
    //  TCU11.msg.bits.ISG_SideStand = 0x1; //����
    // ECU_101.msg.bits.ECU_Vehicle_Speed =255;  //����255
    // VEH_Output_Update(PWMCH_VEH_OUT, 2179, 50); //�������2000Hz
    //  REV_Output_Update(PWMCH_REV_OUT, 200, 50); //ת�����200Hz
    // TCU13.msg.bits.Tbatt = 185;//����¶�
    // ECU_401.msg.bits.ECU_Battery_Voltage = 200;//��ѹ
    // ECU_114.msg.bits.ISG_DTC_ISTOP_H = 8;
    // ECU_101.msg.bits.ECU_Engine_Temperature_H = 0x0F;
    // ECU_101.msg.bits.ECU_Engine_Temperature_L = 0x5A;
    // //ECU_Engine_Data_M2.msg.bits.ECU_MILLampSts =1;//�綯������
    // ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water =0xF0;//ˮ��
   //
    //  _OIL4_out(PortGpioHigh);//����
    // _GEAR1_out(PortGpioLow);
    // _GEAR2_out(PortGpioLow);
    // _GEAR3_out(PortGpioLow);
    // _GEAR4_out(PortGpioLow);
    // _GEAR5_out(PortGpioLow);
    // _GEAR6_out(PortGpioHigh);
    // _GEARN_out(PortGpioLow);
    //  break;  
    //case 17:
    //  LIG_left_OUT(PortGpioHigh);//left light open
    //  TCU13.msg.bits.ISTOP_display = 0x1;  //ASC light open
    //  LIG_HighBeam_OUT(PortGpioHigh); //HighBeam light open
    //  ECU_402.msg.bits.ECU_Warning_Lamp = 0x1; //Engine malfunction light open
    //  LIG_Oil_OUT(PortGpioHigh);   //Oil light open
    //  LIG_ABS_OUT(PortGpioLow);//ABS light open
    //  LIG_right_OUT(PortGpioHigh);//right light open
    //  TCU13.msg.bits.LIGHT_0N = 0x1; //autolight light open
    //  TCS_125.msg.bits.TCS_WorkMode = 0x1; //TCSָʾ�ƿ���
    //  TCS_125.msg.bits.TCS_WarningLamp = 0x0; //TCSָʾ�ƿ���
    //  TCS_125.msg.bits.TCS_SysState = 0x1; //TCSָʾ�ƿ���
    //  TCU11.msg.bits.ISG_Batt = 0x1; //����״̬����
    //  TCU11.msg.bits.ISG_Power = 0x1; //�綯ִ��״̬����
    //  TCU11.msg.bits.ISG_Power_Enable = 0x1; //����ʹ��  
    //  TCU11.msg.bits.ISG_Ready = 0x1; //�綯����״̬����
    //  TCU11.msg.bits.ISG_SideStand = 0x1; //����
    //  ECU_101.msg.bits.ECU_Vehicle_Speed =255;  //����255
    //  VEH_Output_Update(PWMCH_VEH_OUT, 2800, 50); //�������2000Hz
    //  REV_Output_Update(PWMCH_REV_OUT, 250, 50); //ת�����200Hz
    //  TCU13.msg.bits.Tbatt = 185;//����¶�
    //  ECU_401.msg.bits.ECU_Battery_Voltage = 200;//��ѹ
    //  ECU_114.msg.bits.ISG_DTC_ISTOP_H = 8;
    //  ECU_101.msg.bits.ECU_Engine_Temperature_H = 0x0F;
    //  ECU_101.msg.bits.ECU_Engine_Temperature_L = 0x5A;
    //  ECU_Engine_Data_M2.msg.bits.ECU_MILLampSts =1;//�綯������
    //  ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water =0xF0;//ˮ��
    // //ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water =0x9F; //ˮ��
    //  _OIL1_out(PortGpioHigh);//
    //  QS_341.msg.bits.QS_status= 1;//QSָʾ��
    //  QS_341.msg.bits.Launch_ControlSwitch=1;//���俪�أ�CLS��
    //  QS_341.msg.bits.Launch_ControlStatus=1;//���书��
    //  TBOX.msg.bits.TBOX_WorkMode=1;//TBOXָʾ��
    // _GEAR1_out(PortGpioLow);
    // _GEAR2_out(PortGpioLow);
    // _GEAR3_out(PortGpioLow);
    // _GEAR4_out(PortGpioLow);
    // _GEAR5_out(PortGpioLow);
    // _GEAR6_out(PortGpioHigh); 
    // _GEARN_out(PortGpioLow);
    //  break;
    default:
     break;
  }
  if(SPEED_step >10)
  {
    SPEED_step = 0;
  }
}  


//void clean_Mil()
//{
//  if(Botton.EOL.Statu==1)
//  {
//   bsp_Save_Check_Service(3);// �������
//   Diaplay_test = NewData.Data1;
//  }
//}
//void text_step()
//{
//  if(SPEED_step==0)
//  {
//    GEAR_6_OUT(PortGpioLow);
//    GEAR_N_OUT(PortGpioHigh);
//    LIG_left_OUT(PortGpioLow);
//    LIG_right_OUT(PortGpioLow);
//    LIG_HighBeam_OUT(PortGpioLow);
//    LIG_ABS_OUT(PortGpioHigh);
//    LIG_Oil_OUT(PortGpioLow);
//     VEH_Output_Update(PWMCH_VEH_OUT, 0, 50); //�������2000Hz
//     REV_Output_Update(PWMCH_REV_OUT, 0, 50); //ת�����200Hz
//    ECU_Engine_Data_M2.msg.bits.ECU_MILLampSts = 0x1;
//    
//  }
//  else
//  {
//    GEAR_N_OUT(PortGpioLow);
//    ECU_Engine_Data_M2.msg.bits.ECU_MILLampSts = 0x0;
//    
//  }
//     if(SPEED_step==1)
//  {
//    GEAR_N_OUT(PortGpioLow);
//    GEAR_1_OUT(PortGpioHigh);
//    LIG_left_OUT(PortGpioHigh);
//    LIG_right_OUT(PortGpioLow);
//    LIG_HighBeam_OUT(PortGpioLow);
//    LIG_ABS_OUT(PortGpioHigh);
//    LIG_Oil_OUT(PortGpioLow);
////     ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water = 0x90;   //69        SEG1 ??? 
//     VEH_Output_Update(PWMCH_VEH_OUT, 274, 50); //�������2000Hz
//     REV_Output_Update(PWMCH_REV_OUT, 33, 50); //ת�����200Hz
//  }
//    else
//  {
//    GEAR_1_OUT(PortGpioLow);
//  }
//   if(SPEED_step==2)
//  {
//    GEAR_1_OUT(PortGpioLow);
//    GEAR_2_OUT(PortGpioHigh);
//    LIG_left_OUT(PortGpioLow);
//    //LIG_right_OUT(PortGpioHigh);
//    LIG_HighBeam_OUT(PortGpioLow);
//    LIG_ABS_OUT(PortGpioHigh);
//    LIG_Oil_OUT(PortGpioLow);
//     //LIG_right_OUT(PortGpioHigh);
////     ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water = 0xb7 ;   //87           SEG2  ???
//     VEH_Output_Update(PWMCH_VEH_OUT, 687, 50); //�������2000Hz
//     REV_Output_Update(PWMCH_REV_OUT, 66, 50); //ת�����200Hz
//  }
//    else
//  {
//
//    GEAR_2_OUT(PortGpioLow);
//
//  }
//    if(SPEED_step==3)
//  {
//    GEAR_2_OUT(PortGpioLow);
//    GEAR_3_OUT(PortGpioHigh);
//    LIG_left_OUT(PortGpioLow);
//    LIG_right_OUT(PortGpioLow);
//    LIG_HighBeam_OUT(PortGpioHigh);
//    LIG_ABS_OUT(PortGpioHigh);
//    LIG_Oil_OUT(PortGpioLow);
////    ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water = 0xc7 ;
//     VEH_Output_Update(PWMCH_VEH_OUT, 950, 50); //�������2000Hz
//     REV_Output_Update(PWMCH_REV_OUT, 99, 50); //ת�����200Hz
//  }
//    else
//  {
//
//    GEAR_3_OUT(PortGpioLow);
//
//  }
//   if(SPEED_step==4)
//  {
//    GEAR_3_OUT(PortGpioLow);
//    GEAR_4_OUT(PortGpioHigh);
//    LIG_left_OUT(PortGpioLow);
//    LIG_right_OUT(PortGpioLow);
//    LIG_HighBeam_OUT(PortGpioLow);
//    LIG_ABS_OUT(PortGpioLow);
//    LIG_Oil_OUT(PortGpioLow); 
////    ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water = 0xd4 ;    
//     VEH_Output_Update(PWMCH_VEH_OUT, 1507, 50); //�������2000Hz
//     REV_Output_Update(PWMCH_REV_OUT, 132, 50); //ת�����200Hz
//  }
//    else
//  {
//    GEAR_4_OUT(PortGpioLow);
//
//  }
//  if(SPEED_step==5)
//  {
//    GEAR_4_OUT(PortGpioLow);
//    GEAR_5_OUT(PortGpioHigh);
//    LIG_left_OUT(PortGpioLow);
//    LIG_right_OUT(PortGpioLow);
//    LIG_HighBeam_OUT(PortGpioLow);
//    LIG_ABS_OUT(PortGpioHigh);
//    LIG_Oil_OUT(PortGpioHigh);
////    ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water = 0xd8 ;   //114       SEG5  ????
//     VEH_Output_Update(PWMCH_VEH_OUT, 2055, 50); //�������2000Hz
//     REV_Output_Update(PWMCH_REV_OUT, 166, 50); //ת�����200Hz
//  }
//    else
//  {
//    GEAR_5_OUT(PortGpioLow);
//  }
//   if(SPEED_step==6)
//  {
//    GEAR_5_OUT(PortGpioLow);
//    GEAR_6_OUT(PortGpioHigh);
//    LIG_left_OUT(PortGpioHigh);
//    LIG_right_OUT(PortGpioHigh);
//    LIG_HighBeam_OUT(PortGpioHigh);
//    LIG_ABS_OUT(PortGpioLow);
//    LIG_Oil_OUT(PortGpioHigh);
////    ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water = 0xe4 ;   //123       SEG6  ????
//     VEH_Output_Update(PWMCH_VEH_OUT, 2466, 50); //�������2000Hz
//     REV_Output_Update(PWMCH_REV_OUT, 201, 50); //ת�����200Hz
//  }
//    else
//  {
//    GEAR_6_OUT(PortGpioLow);
//  }
//  if(SPEED_step==7)
//  {
//    LIG_left_OUT(PortGpioLow);
//    LIG_right_OUT(PortGpioLow);
//    LIG_HighBeam_OUT(PortGpioLow);
//    LIG_ABS_OUT(PortGpioHigh);
//    LIG_Oil_OUT(PortGpioLow);
//    GEAR_N_OUT(PortGpioHigh);
//  }
//  if( SPEED_step>=8)
//  {
//    SPEED_step=0;
//  }
//  
//    if(SPEED_step==4294967295)
//  {
//    SPEED_step=6;
//  }
//  
//}


void _lianxu()
{

      if(run_step==0)
      {
         GEAR_N_OUT(PortGpioHigh);
        //LIG_left_OUT(PortGpioLow);
        //LIG_right_OUT(PortGpioLow);
        LIG_HighBeam_OUT(PortGpioLow);
        LIG_ABS_OUT(PortGpioHigh);
        LIG_Oil_OUT(PortGpioLow);
        // VEH_Output_Update(PWMCH_VEH_OUT, 0, 50); //�������2000Hz
        // REV_Output_Update(PWMCH_REV_OUT, 0, 50); //ת�����200Hz
        ECU_Engine_Data_M2.msg.bits.ECU_MILLampSts = 0x1;
      }
     else
      {
     GEAR_N_OUT(PortGpioLow);
     ECU_Engine_Data_M2.msg.bits.ECU_MILLampSts = 0x0;
       }
         if(run_step==1)
      {
          GEAR_N_OUT(PortGpioLow);
          GEAR_1_OUT(PortGpioHigh);
        //LIG_left_OUT(PortGpioHigh);
        //(PortGpioLow);
        LIG_HighBeam_OUT(PortGpioLow);
        LIG_ABS_OUT(PortGpioHigh);
        LIG_Oil_OUT(PortGpioLow);
    //     ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water = 0x90;   //69        SEG1 ??? 
        // VEH_Output_Update(PWMCH_VEH_OUT, 274, 50); //�������2000Hz
        // REV_Output_Update(PWMCH_REV_OUT, 33, 50); //ת�����200Hz
      }
  else
  {
     GEAR_1_OUT(PortGpioLow);
  }
       if(run_step==2)
      {
       GEAR_1_OUT(PortGpioLow);        
          GEAR_2_OUT(PortGpioHigh);
       // LIG_left_OUT(PortGpioLow);
        //(PortGpioHigh);
        LIG_HighBeam_OUT(PortGpioLow);
        LIG_ABS_OUT(PortGpioHigh);
        LIG_Oil_OUT(PortGpioLow);
        // LIG_right_OUT(PortGpioHigh);
    //     ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water = 0xb7 ;   //87           SEG2  ???
        // VEH_Output_Update(PWMCH_VEH_OUT, 687, 50); //�������2000Hz
        // REV_Output_Update(PWMCH_REV_OUT, 66, 50); //ת�����200Hz
      }
else
  {
     GEAR_2_OUT(PortGpioLow);
  }
         if(run_step==3)
      {
        GEAR_2_OUT(PortGpioLow);        
          GEAR_3_OUT(PortGpioHigh);
        LIG_left_OUT(PortGpioLow);
        //LIG_right_OUT(PortGpioLow);
        LIG_HighBeam_OUT(PortGpioHigh);
        LIG_ABS_OUT(PortGpioHigh);
        LIG_Oil_OUT(PortGpioLow);
    //    ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water = 0xc7 ;
        // VEH_Output_Update(PWMCH_VEH_OUT, 950, 50); //�������2000Hz
        // REV_Output_Update(PWMCH_REV_OUT, 99, 50); //ת�����200Hz
      }
else
  {
     GEAR_3_OUT(PortGpioLow);
  }
       if(run_step==4)
      {
         GEAR_3_OUT(PortGpioLow);
          GEAR_4_OUT(PortGpioHigh);
        //LIG_left_OUT(PortGpioLow);
        //LIG_right_OUT(PortGpioLow);
        LIG_HighBeam_OUT(PortGpioLow);
        LIG_ABS_OUT(PortGpioLow);
        LIG_Oil_OUT(PortGpioLow); 
    //    ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water = 0xd4 ;    
        // VEH_Output_Update(PWMCH_VEH_OUT, 1507, 50); //�������2000Hz
        // REV_Output_Update(PWMCH_REV_OUT, 132, 50); //ת�����200Hz
      }
else
  {
     GEAR_4_OUT(PortGpioLow);
  }
      if(run_step==5)
      {
        GEAR_4_OUT(PortGpioLow);
          GEAR_5_OUT(PortGpioHigh);
        //LIG_left_OUT(PortGpioLow);
        //LIG_right_OUT(PortGpioLow);
        LIG_HighBeam_OUT(PortGpioLow);
        LIG_ABS_OUT(PortGpioHigh);
        LIG_Oil_OUT(PortGpioHigh);
    //    ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water = 0xd8 ;   //114       SEG5  ????
        // VEH_Output_Update(PWMCH_VEH_OUT, 2055, 50); //�������2000Hz
        // REV_Output_Update(PWMCH_REV_OUT, 166, 50); //ת�����200Hz
      }
else
  {
     GEAR_5_OUT(PortGpioLow);
  }
       if(run_step==6)
      {
        GEAR_5_OUT(PortGpioLow);
          GEAR_6_OUT(PortGpioHigh);
        //LIG_left_OUT(PortGpioHigh);
        //LIG_right_OUT(PortGpioHigh);
        LIG_HighBeam_OUT(PortGpioHigh);
        LIG_ABS_OUT(PortGpioLow);
        LIG_Oil_OUT(PortGpioHigh);
    //    ECU_Engine_Data_M2.msg.bits.ECU_Temperature_Water = 0xe4 ;   //123       SEG6  ????
         VEH_Output_Update(PWMCH_VEH_OUT, 2466, 50); //�������2000Hz
         REV_Output_Update(PWMCH_REV_OUT, 201, 50); //ת�����200Hz
      }
else
  {
     GEAR_6_OUT(PortGpioLow);
  }
      if(run_step==7)
      {
        
        //LIG_left_OUT(PortGpioLow);
        //(PortGpioLow);
        LIG_HighBeam_OUT(PortGpioLow);
        LIG_ABS_OUT(PortGpioHigh);
        LIG_Oil_OUT(PortGpioLow);
        GEAR_N_OUT(PortGpioHigh);
        //SPEED_step=0;
      }
       if(run_step>=8)
      {
        run_step=0;
      }

}

  
    


  
    
    
    
    
    
    
    
    
    
    
    
    