#define  GLOBALS_APP_CAN
#include "../app_Headers/g_includes.h"


//1000  //2000  //3000  //4000 //5000   //6000  //7000 //7600 //8000
INT16U    EngSpd[10] ={0X0000,0x1F40, 0x3E80, 0x5DC0, 0x7D00, 0x9D40, 0xBB80, 0xDAC0,0XFA00 };
INT16U    EngSpeed[11] = {0x0163, 0x02C7, 0x042A, 0x058E, 0x06F1, 0x0855, 0x09B8,0X0B1C,0X0C7E,0X0DE2,0X0F45 };

/*-------------------------------------------------------------------------
* Function Name  : app_Can_handle
* Description    :
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void app_Can_handle(void)
{
    app_Can_handle_PA5();
    
  //  G_Button.LED_STEP = 1;
    
    //================================================
    //
    if(api_TimerOver1((_Clock*)&g_Clock)) //50ms
    {
        api_SetTimer1(TT_50ms,(_Clock*)&g_Clock); 
       
        TxDelayTime = 10;
        
        if(G_Button.LED_STEP == 1)
        {
          WheelSpeedN = WheelSpeedN + glztest;//20kmh
          if(WheelSpeedN >= 64255)
          {
              WheelSpeedN = WheelSpeedN - 64255;
          }
          g_Msg08FFF00B.data[4].bbyte = WheelSpeedN % 256;
          g_Msg08FFF00B.data[5].bbyte = WheelSpeedN / 256;
          
        }
          CS_OUT_N =CS_FRset[G_Button.LED_STEP]; 
          ZS_OUT_N=ZS_FRset[G_Button.LED_STEP];	
        
        if(G_Button.LED_STEP == 2)
        {
          WheelSpeedN = WheelSpeedN + 32;//40kmh
          if(WheelSpeedN >= 64255)
          {
              WheelSpeedN = WheelSpeedN - 64255;
          }
          g_Msg08FFF00B.data[4].bbyte = WheelSpeedN % 256;
          g_Msg08FFF00B.data[5].bbyte = WheelSpeedN / 256;
        }
        
        if(G_Button.LED_STEP == 3)
        {
          WheelSpeedN = WheelSpeedN + 48;//60kmh
          if(WheelSpeedN >= 64255)
          {
              WheelSpeedN = WheelSpeedN - 64255;
          }
          g_Msg08FFF00B.data[4].bbyte = WheelSpeedN % 256;
          g_Msg08FFF00B.data[5].bbyte = WheelSpeedN / 256;
        }                
        if(G_Button.LED_STEP == 4)
        {
          WheelSpeedN = WheelSpeedN + 64;//80kmh
          if(WheelSpeedN >= 64255)
          {
              WheelSpeedN = WheelSpeedN - 64255;
          }
          g_Msg08FFF00B.data[4].bbyte = WheelSpeedN % 256;
          g_Msg08FFF00B.data[5].bbyte = WheelSpeedN / 256;
        }
        if(G_Button.LED_STEP == 5)
        {
          WheelSpeedN = WheelSpeedN + 80;//100kmh
          if(WheelSpeedN >= 64255)
          {
              WheelSpeedN = WheelSpeedN - 64255;
          }
          g_Msg08FFF00B.data[4].bbyte = WheelSpeedN % 256;
          g_Msg08FFF00B.data[5].bbyte = WheelSpeedN / 256;
        }        
        if(G_Button.LED_STEP == 6)
        {
          WheelSpeedN = WheelSpeedN + 96;//120kmh
          if(WheelSpeedN >= 64255)
          {
              WheelSpeedN = WheelSpeedN - 64255;
          }
          g_Msg08FFF00B.data[4].bbyte = WheelSpeedN % 256;
          g_Msg08FFF00B.data[5].bbyte = WheelSpeedN / 256;
        }        
        if(G_Button.LED_STEP == 7)
        {
          WheelSpeedN = WheelSpeedN + 112;//140kmh
          if(WheelSpeedN >= 64255)
          {
              WheelSpeedN = WheelSpeedN - 64255;
          }
          g_Msg08FFF00B.data[4].bbyte = WheelSpeedN % 256;
          g_Msg08FFF00B.data[5].bbyte = WheelSpeedN / 256;
        }
        if(G_Button.LED_STEP == 8)
        {
          WheelSpeedN = WheelSpeedN + 128;//160kmh
          if(WheelSpeedN >= 64255)
          {
              WheelSpeedN = WheelSpeedN - 64255;
          }
          g_Msg08FFF00B.data[4].bbyte = WheelSpeedN % 256;
          g_Msg08FFF00B.data[5].bbyte = WheelSpeedN / 256;
        }        
        if(G_Button.LED_STEP >= 9)
        {
          WheelSpeedN = WheelSpeedN + 480;//180kmh
          if(WheelSpeedN >= 64255)
          {
              WheelSpeedN = WheelSpeedN - 64255;
          }
          g_Msg08FFF00B.data[4].bbyte = WheelSpeedN % 256;
          g_Msg08FFF00B.data[5].bbyte = WheelSpeedN / 256;
        }                   
                
     //   g_bReturn = bsp_CANSendExtFrame(g_Msg08FFF00B.id,g_Msg08FFF00B.prio,g_Msg08FFF00B.dlc,g_Msg08FFF00B.data); 
    } 
    
    
    //if(TxDelayTime==0)
    {
      if(api_TimerOver0((_Clock*)&g_Clock))
      {
          api_SetTimer0(23,(_Clock*)&g_Clock); //1s
          
       //   g_bReturn = bsp_CANSendExtFrame(g_Msg18FE4F17.id,g_Msg18FE4F17.prio,g_Msg18FE4F17.dlc,g_Msg18FE4F17.data); //100
       //   g_bReturn = bsp_CANSendExtFrame(g_Msg18FF0113.id,g_Msg18FF0113.prio,g_Msg18FF0113.dlc,g_Msg18FF0113.data); //100 
          g_bReturn = bsp_CANSendFrame(g_Msg240.id,g_Msg240.prio,g_Msg240.dlc,g_Msg240.data);//1000
          g_bReturn = bsp_CANSendFrame(g_Msg101.id,g_Msg101.prio,g_Msg101.dlc,g_Msg101.data);
          g_bReturn = bsp_CANSendFrame(g_Msg402.id,g_Msg402.prio,g_Msg402.dlc,g_Msg402.data);  
          g_bReturn = bsp_CANSendFrame(g_Msg12B.id,g_Msg12B.prio,g_Msg12B.dlc,g_Msg12B.data);       
          g_bReturn = bsp_CANSendFrame(g_Msg125.id,g_Msg125.prio,g_Msg125.dlc,g_Msg125.data); 
          g_bReturn = bsp_CANSendFrame(g_Msg084.id,g_Msg084.prio,g_Msg084.dlc,g_Msg084.data); 
          g_bReturn = bsp_CANSendFrame(g_Msg230.id,g_Msg230.prio,g_Msg230.dlc,g_Msg230.data); 
          g_bReturn = bsp_CANSendFrame(g_Msg055.id,g_Msg055.prio,g_Msg055.dlc,g_Msg055.data); 
          g_bReturn = bsp_CANSendFrame(g_Msg2A0.id,g_Msg2A0.prio,g_Msg2A0.dlc,g_Msg2A0.data);
          g_bReturn = bsp_CANSendFrame(g_Msg250.id,g_Msg250.prio,g_Msg250.dlc,g_Msg250.data);
          g_bReturn = bsp_CANSendFrame(g_Msg200.id,g_Msg200.prio,g_Msg200.dlc,g_Msg200.data);

      }
     if(api_TimerOver3((_Clock*)&g_Clock)) //70ms
      {
          api_SetTimer3(63,(_Clock*)&g_Clock); 
          
       //   g_bReturn = bsp_CANSendExtFrame(g_Msg18FD7C00.id,g_Msg18FD7C00.prio,g_Msg18FD7C00.dlc,g_Msg18FD7C00.data);  //1000
       //   g_bReturn = bsp_CANSendExtFrame(g_Msg18FEF100.id,g_Msg18FEF100.prio,g_Msg18FEF100.dlc,g_Msg18FEF100.data); //1000       
      }
     if(api_TimerOver6((_Clock*)&g_Clock))
      {
          api_SetTimer6(77,(_Clock*)&g_Clock); //1000ms
      //    g_bReturn = bsp_CANSendExtFrame(g_Msg18FD0700.id,g_Msg18FD0700.prio,g_Msg18FD0700.dlc,g_Msg18FD0700.data);  //1000 
      //    g_bReturn = bsp_CANSendExtFrame(g_Msg18FEC600.id,g_Msg18FEC600.prio,g_Msg18FEC600.dlc,g_Msg18FEC600.data);  //1000 
       //   g_bReturn = bsp_CANSendExtFrame(g_Msg18850000.id,g_Msg18850000.prio,g_Msg18850000.dlc,g_Msg18850000.data);  //1000        
      } 
      
      if(api_TimerOver5((_Clock*)&g_Clock)) //
      {
          api_SetTimer5(22,(_Clock*)&g_Clock); //
          
      //    g_bReturn = bsp_CANSendExtFrame(g_Msg18F0010B.id,g_Msg18F0010B.prio,g_Msg18F0010B.dlc,g_Msg18F0010B.data); //1000
       //   g_bReturn = bsp_CANSendExtFrame(g_Msg0CFED926.id,g_Msg0CFED926.prio,g_Msg0CFED926.dlc,g_Msg0CFED926.data); //1000
       //   g_bReturn = bsp_CANSendExtFrame(g_Msg18FED800.id,g_Msg18FED800.prio,g_Msg18FED800.dlc,g_Msg18FED800.data); //1000 
      }
    } 
    
}
/*-------------------------------------------------------------------------
* Function Name  : app_Can_handle
* Description    :
* Input          : None
* Output         : None
* Return         : None
* onther         :
--------------------------------------------------------------------------*/
void app_Can_IdInit(void)
{
  api_SetTimer0(1,(_Clock*)&g_Clock);
  api_SetTimer1(1,(_Clock*)&g_Clock);
  api_SetTimer2(1,(_Clock*)&g_Clock);
  api_SetTimer3(1,(_Clock*)&g_Clock);
  api_SetTimer4(1,(_Clock*)&g_Clock);
  api_SetTimer5(1,(_Clock*)&g_Clock);
  api_SetTimer6(1,(_Clock*)&g_Clock);
  api_SetTimer7(1,(_Clock*)&g_Clock);
  
    g_Msg18FD0700.id = 0X18FD0700;
    g_Msg18FD0700.prio = 0;
    g_Msg18FD0700.dlc = 8;
    
    g_Msg18FD7C00.id = 0X18FD7C00;
    g_Msg18FD7C00.prio = 0;
    g_Msg18FD7C00.dlc = 8;
    
    
    //
    g_Msg18FE4F17.id = 0X18FE4F17;
    g_Msg18FE4F17.prio = 0;
    g_Msg18FE4F17.dlc = 8;
    
    //ת��
    g_Msg18FF0113.id = 0X0CF00400 ;
    g_Msg18FF0113.prio = 0;
    g_Msg18FF0113.dlc = 8;
    
    g_Msg0CFED926.id = 0X0CFED926;
    g_Msg0CFED926.prio = 0;
    g_Msg0CFED926.dlc = 8;
    
    g_Msg240.id = 0X240 ;
    g_Msg240.prio = 0;
    g_Msg240.dlc = 8;

    g_Msg101.id = 0X101 ;
    g_Msg101.prio = 0;
    g_Msg101.dlc = 8;

    g_Msg230.id = 0X230 ;
    g_Msg230.prio = 0;
    g_Msg230.dlc = 8;

    g_Msg2A0.id = 0X2A0 ;
    g_Msg2A0.prio = 0;
    g_Msg2A0.dlc = 8;

    g_Msg250.id = 0X250 ;
    g_Msg250.prio = 0;
    g_Msg250.dlc = 8;

    g_Msg200.id = 0X200 ;
    g_Msg200.prio = 0;
    g_Msg200.dlc = 8;

 
    g_Msg055.id = 0X055 ;
    g_Msg055.prio = 0;
    g_Msg055.dlc = 8;

    g_Msg084.id = 0X084 ;
    g_Msg084.prio = 0;
    g_Msg084.dlc = 8;

    g_Msg402.id = 0X402 ;
    g_Msg402.prio = 0;
    g_Msg402.dlc = 8;
    
    g_Msg18F0010B.id = 0X18F0010B;
    g_Msg18F0010B.prio = 0;
    g_Msg18F0010B.dlc = 8;
    
    
    //����ѹ��
    g_Msg08FFF00B.id = 0X08FFF00B;
    g_Msg08FFF00B.prio = 0;
    g_Msg08FFF00B.dlc = 8;
    
    
    g_Msg18FED800.id = 0X18FED800;
    g_Msg18FED800.prio = 0;
    g_Msg18FED800.dlc = 8;
    
    g_Msg18FEF100.id = 0X18FEF100;
    g_Msg18FEF100.prio = 0;
    g_Msg18FEF100.dlc = 8;
    
    g_Msg18DA17F9.id = 0X18DA17F9;
    g_Msg18DA17F9.prio = 0;
    g_Msg18DA17F9.dlc = 8; 
    g_Msg18DA17F9.data[0].bbyte=0x02;
    g_Msg18DA17F9.data[1].bbyte=0x3E;
    
    g_Msg18FEC600.id = 0X18FEC600;
    g_Msg18FEC600.prio = 0;
    g_Msg18FEC600.dlc = 8;    
    
    g_Msg18850000.id = 0X18850000;
    g_Msg18850000.prio = 0;
    g_Msg18850000.dlc = 8;    
       
}




void app_Can_handle_PA5(void) {
    
    
#if PA5_EN
        
 /*   if(G_Button.LED_STEP == 1)
    {      
        g_Msg240.data[7].bbyte=0xE3;  // ˮ�� 40�� --1ge
        g_Msg18FD0700.data[0].bbyte=0x04; //SVS 
        g_Msg18FEC600.data[2].bbyte=0xA0; //��ѹ4000kpa--1ge
        g_Msg18FEC600.data[3].bbyte=0x0F;
        g_Msg18FEF100.data[6].bbyte=0x0A;
    }
    if(G_Button.LED_STEP == 2)
    {
        g_Msg240.data[7].bbyte=0xE3;  // ˮ�� 50��--2ge
        g_Msg18FD0700.data[0].bbyte=0x40;  //OBD
        g_Msg18FEC600.data[2].bbyte=0x40; //��ѹ8000kpa--2ge
        g_Msg18FEC600.data[3].bbyte=0x1F;        
    }
    if(G_Button.LED_STEP == 3)
    {
        g_Msg240.data[7].bbyte=0xE3;  // ˮ�� 70��--4ge
        g_Msg18FD0700.data[0].bbyte=0x00;
        g_Msg18FD0700.data[1].bbyte=0x00;
        g_Msg18FD7C00.data[0].bbyte=0x01; //DPF-GPF
        g_Msg18FEC600.data[2].bbyte=0xE0; //��ѹ12000kpa--3ge
        g_Msg18FEC600.data[3].bbyte=0x2E;        
    }
    if(G_Button.LED_STEP == 4)
    {
        g_Msg240.data[7].bbyte=0xE3;  // ˮ�� 105��--7ge
        g_Msg18FD0700.data[0].bbyte=0x00;
        g_Msg18FD0700.data[1].bbyte=0x00;
        g_Msg18FD7C00.data[0].bbyte=0x04; //DPF-GPF  FLASH
        g_Msg18FEC600.data[2].bbyte=0x80; //��ѹ16000kpa--4ge
        g_Msg18FEC600.data[3].bbyte=0x3E;        
    }
    if(G_Button.LED_STEP == 5)
    {
        g_Msg240.data[7].bbyte=0xE3;  // ˮ�� 110��--8ge
        g_Msg18FD0700.data[0].bbyte=0x00;
        g_Msg18FD0700.data[1].bbyte=0x00;
        g_Msg18FD7C00.data[0].bbyte=0x00;
        g_Msg18FED800.data[0].bbyte=0x01; //G
    }
    if(G_Button.LED_STEP == 6)
    {
        g_Msg240.data[7].bbyte=0xC8;  // ˮ�� 120��--9ge
        g_Msg18FD0700.data[0].bbyte=0x00;
        g_Msg18FD0700.data[1].bbyte=0x00;
        g_Msg18FD7C00.data[0].bbyte=0x00;
        g_Msg18FED800.data[0].bbyte=0x02; //G flash
    }
    if(G_Button.LED_STEP == 13)
    {
        g_Msg240.data[7].bbyte=0xC8; 
        g_Msg18FD0700.data[0].bbyte=0x00;
        g_Msg18FD0700.data[1].bbyte=0x00;
        g_Msg18FD7C00.data[0].bbyte=0x00;
        g_Msg18FED800.data[0].bbyte=0x00;
        g_Msg18FEF100.data[3].bbyte=0x01;  //����Ѳ��
    }
    if(G_Button.LED_STEP == 12)
    {
        g_Msg240.data[7].bbyte=0xC8; 
        g_Msg18FD0700.data[0].bbyte=0x00;
        g_Msg18FD0700.data[1].bbyte=0x00;
        g_Msg18FD7C00.data[0].bbyte=0x00;
        g_Msg18FED800.data[0].bbyte=0x00;
        g_Msg18FEF100.data[3].bbyte=0x00;
        g_Msg18FE4F17.data[0].bbyte=0x01; //ESC--ESP
    }
    if(G_Button.LED_STEP == 14)
    {
    //    g_Msg240.data[7].bbyte=0xC8; 
        g_Msg18FD0700.data[0].bbyte=0x00;
        g_Msg18FD0700.data[1].bbyte=0x00;
        g_Msg18FD7C00.data[0].bbyte=0x00;
        g_Msg18FED800.data[0].bbyte=0x00;
        g_Msg18FEF100.data[3].bbyte=0x00; 
        g_Msg18850000.data[1].bbyte=0x82;//sport
    }
    if(G_Button.LED_STEP == 9)
    {
    //    g_Msg240.data[7].bbyte=0xC8; 
        g_Msg18FD0700.data[0].bbyte=0x00;
        g_Msg18FD0700.data[1].bbyte=0x00;
        g_Msg18FD7C00.data[0].bbyte=0x00;
        g_Msg18FED800.data[0].bbyte=0x00;
        g_Msg18FEF100.data[3].bbyte=0x00;
        g_Msg18FE4F17.data[0].bbyte=0x00;
        g_Msg0CFED926.data[0].bbyte=0x01;//Eps
    }
    if(G_Button.LED_STEP == 10)
    {
    //    g_Msg240.data[7].bbyte=0xC8; 
        g_Msg18FD0700.data[0].bbyte=0x00;
        g_Msg18FD0700.data[1].bbyte=0x00;
        g_Msg18FD7C00.data[0].bbyte=0x00;
        g_Msg18FED800.data[0].bbyte=0x00;
        g_Msg18FEF100.data[3].bbyte=0x00;
        g_Msg18FE4F17.data[0].bbyte=0x00;
        g_Msg0CFED926.data[0].bbyte=0x02;//Eps flash
    }
    if(G_Button.LED_STEP == 7)
    {
        Req_1001FlagY = 0;
        Req_1003FlagY = 0;
        Req_2701FlagY = 0; 
        Req_2702FlagY = 0;
        Req_1001Flag = 0;
        Req_1003Flag = 0;
        Req_2701Flag = 0; 
        Req_2702Flag = 0;                  
        g_Msg240.data[7].bbyte=0xC8; 
        g_Msg18FD0700.data[0].bbyte=0x00;
        g_Msg18FD0700.data[1].bbyte=0x00;
        g_Msg18FD7C00.data[0].bbyte=0x00;
        g_Msg18FED800.data[0].bbyte=0x00;
        g_Msg18FEF100.data[3].bbyte=0x00;
        g_Msg18FE4F17.data[0].bbyte=0x00;
        g_Msg0CFED926.data[0].bbyte=0x00;
        g_Msg18F0010B.data[5].bbyte=0x10;  //ABS 
    }
    
    if(G_Button.LED_STEP != 8) 
    {
        Req_1001FlagY1 = 0;
        Req_1003FlagY1 = 0;
        Req_2701FlagY1 = 0; 
        Req_2702FlagY1 = 0;
        Req_1001Flag1 = 0;
        Req_1003Flag1 = 0;
        Req_2701Flag1 = 0; 
        Req_2702Flag1 = 0;  
    }
    
    if(G_Button.LED_STEP == 8)   //ALL  //����: �г���
    {                
    //    g_Msg240.data[7].bbyte=0xC8; 
        g_Msg18FD0700.data[0].bbyte=0x00;
        g_Msg18FD0700.data[1].bbyte=0x00;
        g_Msg18FD7C00.data[0].bbyte=0x00;
        g_Msg18FED800.data[0].bbyte=0x00;
        g_Msg18FEF100.data[3].bbyte=0x00;
        g_Msg18FE4F17.data[0].bbyte=0x00;
        g_Msg0CFED926.data[0].bbyte=0x00;
        g_Msg18F0010B.data[5].bbyte=0x10;  //ABS   
        g_Msg0CFED926.data[0].bbyte=0x01;//Eps  
        g_Msg18FE4F17.data[0].bbyte=0x01; //ESC--ESP
        g_Msg18FEF100.data[3].bbyte=0x01;  //����Ѳ�� 
        g_Msg18FED800.data[0].bbyte=0x01; //G
        g_Msg18FD7C00.data[0].bbyte=0x01; //DPF-GPF 
        g_Msg18FD0700.data[0].bbyte=0x40;  //OBD  
        g_Msg18FD0700.data[0].bbyte=0x04; //SVS     
        
       Req_1001Flag1 = 0;
       Req_1003Flag1 = 0;
       Req_2701Flag1 = 0; 
       Req_2702Flag1 = 0;        
       if(!Req_1001FlagY1)
       {
          Req_1001FlagY1 = 1;
          g_Msg18DA17F9.data[0].bbyte=0x02; //
          g_Msg18DA17F9.data[1].bbyte=0x10;
          g_Msg18DA17F9.data[2].bbyte=0x01; 
        //  g_bReturn = bsp_CANSendExtFrame(g_Msg18DA17F9.id,g_Msg18DA17F9.prio,g_Msg18DA17F9.dlc,g_Msg18DA17F9.data);
          bsp_IIC_delay(); 
       }        
       if(!Req_1003FlagY1)
       {
          Req_1003FlagY1 = 1;
          g_Msg18DA17F9.data[0].bbyte=0x02; //
          g_Msg18DA17F9.data[1].bbyte=0x10;
          g_Msg18DA17F9.data[2].bbyte=0x03; 
       //   g_bReturn = bsp_CANSendExtFrame(g_Msg18DA17F9.id,g_Msg18DA17F9.prio,g_Msg18DA17F9.dlc,g_Msg18DA17F9.data);
          bsp_IIC_delay(); 
       }        
       if(!Req_2701FlagY1)
       {
          Req_2701FlagY1 = 1;
          g_Msg18DA17F9.data[0].bbyte=0x02; 
          g_Msg18DA17F9.data[1].bbyte=0x27;
          g_Msg18DA17F9.data[2].bbyte=0x01; 
       //   g_bReturn = bsp_CANSendExtFrame(g_Msg18DA17F9.id,g_Msg18DA17F9.prio,g_Msg18DA17F9.dlc,g_Msg18DA17F9.data);
          bsp_IIC_delay(); 
       }
       if((!Req_2702FlagY1) && (LockY == 1)) 
       {
          Req_2702FlagY1 = 1;
          UnlockProY(); 
          g_Msg18DA17F9.data[0].bbyte=0x06; //27 02 ....
          g_Msg18DA17F9.data[1].bbyte=0x27;
          g_Msg18DA17F9.data[2].bbyte=0x02; 
          g_Msg18DA17F9.data[3].bbyte=(INT8U)(CalcKey>>24); 
          g_Msg18DA17F9.data[4].bbyte=(INT8U)(CalcKey>>16); 
          g_Msg18DA17F9.data[5].bbyte=(INT8U)(CalcKey>>8); 
          g_Msg18DA17F9.data[6].bbyte=(INT8U)CalcKey; 
      //    g_bReturn = bsp_CANSendExtFrame(g_Msg18DA17F9.id,g_Msg18DA17F9.prio,g_Msg18DA17F9.dlc,g_Msg18DA17F9.data);
          bsp_IIC_delay(); 
          g_Msg18DA17F9.data[0].bbyte=0x04; //2E 02 10  _01
          g_Msg18DA17F9.data[1].bbyte=0x2E;
          g_Msg18DA17F9.data[2].bbyte=0x02; 
          g_Msg18DA17F9.data[3].bbyte=0x1F; 
          g_Msg18DA17F9.data[4].bbyte=0x01; 
          g_Msg18DA17F9.data[5].bbyte=0x00; 
          g_Msg18DA17F9.data[6].bbyte=0x00; 
          g_Msg18DA17F9.data[6].bbyte=0x00;
      //    g_bReturn = bsp_CANSendExtFrame(g_Msg18DA17F9.id,g_Msg18DA17F9.prio,g_Msg18DA17F9.dlc,g_Msg18DA17F9.data);                     
       }   
                          
    }    
    
    if(G_Button.LED_STEP != 11) 
    {
        Req_1001FlagY = 0;
        Req_1003FlagY = 0;
        Req_2701FlagY = 0; 
        Req_2702FlagY = 0;
        Req_1001Flag = 0;
        Req_1003Flag = 0;
        Req_2701Flag = 0; 
        Req_2702Flag = 0;  
    }
 
    if(G_Button.LED_STEP == 11) //����: ����ѹ,�޳���
    {       
       if(!Req_1001FlagY)
       {
          Req_1001FlagY = 1;
          g_Msg18DA17F9.data[0].bbyte=0x02; //
          g_Msg18DA17F9.data[1].bbyte=0x10;
          g_Msg18DA17F9.data[2].bbyte=0x01; 
      //    g_bReturn = bsp_CANSendExtFrame(g_Msg18DA17F9.id,g_Msg18DA17F9.prio,g_Msg18DA17F9.dlc,g_Msg18DA17F9.data);
          bsp_IIC_delay(); 
       }        
       if(!Req_1003FlagY)
       {
          Req_1003FlagY = 1;
          g_Msg18DA17F9.data[0].bbyte=0x02; //
          g_Msg18DA17F9.data[1].bbyte=0x10;
          g_Msg18DA17F9.data[2].bbyte=0x03; 
       //   g_bReturn = bsp_CANSendExtFrame(g_Msg18DA17F9.id,g_Msg18DA17F9.prio,g_Msg18DA17F9.dlc,g_Msg18DA17F9.data);
          bsp_IIC_delay(); 
       }        
       if(!Req_2701FlagY)
       {
          Req_2701FlagY = 1;
          g_Msg18DA17F9.data[0].bbyte=0x02; 
          g_Msg18DA17F9.data[1].bbyte=0x27;
          g_Msg18DA17F9.data[2].bbyte=0x01; 
      //    g_bReturn = bsp_CANSendExtFrame(g_Msg18DA17F9.id,g_Msg18DA17F9.prio,g_Msg18DA17F9.dlc,g_Msg18DA17F9.data);
          bsp_IIC_delay(); 
       }
       if((!Req_2702FlagY) && (LockY == 1)) 
       {
          Req_2702FlagY = 1;
          UnlockProY(); 
          g_Msg18DA17F9.data[0].bbyte=0x06; //27 02 ....
          g_Msg18DA17F9.data[1].bbyte=0x27;
          g_Msg18DA17F9.data[2].bbyte=0x02; 
          g_Msg18DA17F9.data[3].bbyte=(INT8U)(CalcKey>>24); 
          g_Msg18DA17F9.data[4].bbyte=(INT8U)(CalcKey>>16); 
          g_Msg18DA17F9.data[5].bbyte=(INT8U)(CalcKey>>8); 
          g_Msg18DA17F9.data[6].bbyte=(INT8U)CalcKey; 
     //    g_bReturn = bsp_CANSendExtFrame(g_Msg18DA17F9.id,g_Msg18DA17F9.prio,g_Msg18DA17F9.dlc,g_Msg18DA17F9.data);
          bsp_IIC_delay(); 
          g_Msg18DA17F9.data[0].bbyte=0x04; //2E 02 10  _14
          g_Msg18DA17F9.data[1].bbyte=0x2E;
          g_Msg18DA17F9.data[2].bbyte=0x02; 
          g_Msg18DA17F9.data[3].bbyte=0x10; 
          g_Msg18DA17F9.data[4].bbyte=0x14; 
          g_Msg18DA17F9.data[5].bbyte=0x00; 
          g_Msg18DA17F9.data[6].bbyte=0x00; 
          g_Msg18DA17F9.data[6].bbyte=0x00;
     //     g_bReturn = bsp_CANSendExtFrame(g_Msg18DA17F9.id,g_Msg18DA17F9.prio,g_Msg18DA17F9.dlc,g_Msg18DA17F9.data);     
          
          bsp_IIC_delay(); 
          g_Msg18DA17F9.data[0].bbyte=0x04; //2E 02 1F  _00
          g_Msg18DA17F9.data[1].bbyte=0x2E;
          g_Msg18DA17F9.data[2].bbyte=0x02; 
          g_Msg18DA17F9.data[3].bbyte=0x1F; 
          g_Msg18DA17F9.data[4].bbyte=0x00; 
          g_Msg18DA17F9.data[5].bbyte=0x00; 
          g_Msg18DA17F9.data[6].bbyte=0x00; 
          g_Msg18DA17F9.data[6].bbyte=0x00;
       //   g_bReturn = bsp_CANSendExtFrame(g_Msg18DA17F9.id,g_Msg18DA17F9.prio,g_Msg18DA17F9.dlc,g_Msg18DA17F9.data);                 
       }               
    } 
    

    if(G_Button.LED_STEP == 0)
    {
    //    g_Msg240.data[7].bbyte=0xC8; 
        g_Msg18FD0700.data[0].bbyte=0x00;
        g_Msg18FD0700.data[1].bbyte=0x00;
        g_Msg18FD7C00.data[0].bbyte=0x00;
        g_Msg18FED800.data[0].bbyte=0x00;
        g_Msg18FEF100.data[3].bbyte=0x00;
        g_Msg18FE4F17.data[0].bbyte=0x00;
        g_Msg0CFED926.data[0].bbyte=0x00;
        g_Msg18F0010B.data[5].bbyte=0x00;
        Req_1001FlagY = 0;
        Req_1003FlagY = 0;
        Req_2701FlagY = 0; 
        Req_2702FlagY = 0;
        Req_1001Flag = 0;
        Req_1003Flag = 0;
        Req_2701Flag = 0; 
        Req_2702Flag = 0;  
        g_Msg18FEC600.data[2].bbyte=0x00; 
        g_Msg18FEC600.data[3].bbyte=0x00;                      
    }
      */
    if(G_Button.LED_STEP == 0)
    {
        g_Msg230.data[3].bbyte=0x0;
        g_Msg200.data[0].bbyte=0x0;
        g_Msg250.data[0].bbyte=0x0;
        g_Msg2A0.data[0].bbyte=0x0;
        
        g_Msg2A0.data[3].bbyte=0x0;
       
        g_Msg230.data[2].bbyte=0x0;
        
        g_Msg055.data[0].bbyte=0x0;

        g_Msg230.data[0].bbyte=0x0;
        g_Msg230.data[1].bbyte=0x0;
        g_Msg240.data[7].bbyte=0x0;
        g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0;
        g_Msg101.data[0].bbyte=0x0;
        g_Msg101.data[1].bbyte=0x0;
        g_Msg101.data[2].bbyte=0x0;
        g_Msg101.data[4].bbyte=0x0;
        g_Msg101.data[5].bbyte=0x0;
        
        g_Msg12B.data[0].bbyte=0; 
        g_Msg12B.data[1].bbyte=0x00;
        g_Msg125.data[3].bbyte=0x00;
        g_Msg125.data[2].bbyte=0x00;
        g_Msg125.data[4].bbyte=0x00;


       
        g_Msg084.data[3].bbyte=0x00;
          // g_Msg402.data[7].bbyte=0;
        
        
    }
    if(G_Button.LED_STEP == 1)
    {
        g_Msg402.data[4].bbyte=0x04;
        g_Msg230.data[0].bbyte=0;
        g_Msg230.data[1].bbyte=0x60;
        g_Msg240.data[7].bbyte=0x90;
        g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0x80;
        g_Msg101.data[0].bbyte=0x0E;                                                                                      
        g_Msg101.data[1].bbyte=0x00;
        g_Msg101.data[2].bbyte=0x0B;
        g_Msg101.data[4].bbyte=0x0C;
        g_Msg101.data[5].bbyte=0xCD;
        
        
        g_Msg12B.data[0].bbyte=0; 
        g_Msg12B.data[1].bbyte=0x12; 
    }
    if(G_Button.LED_STEP == 2)
    {
        g_Msg402.data[4].bbyte=0x0;
        g_Msg230.data[0].bbyte=0;
g_Msg230.data[1].bbyte=0xC0;
       // g_Msg240.data[7].bbyte=0xA3;
       // g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0;
        g_Msg101.data[0].bbyte=0x1E;
        g_Msg101.data[1].bbyte=0x00;
        g_Msg101.data[2].bbyte=0x16;
        g_Msg101.data[4].bbyte=0x0D;
        g_Msg101.data[5].bbyte=0x95;
        g_Msg084.data[3].bbyte=0x01;
        
       // g_Msg12B.data[0].bbyte=0; 
       // g_Msg12B.data[1].bbyte=0x24; 
    }
    if(G_Button.LED_STEP == 3)
    {
        g_Msg230.data[0].bbyte=0x01;
g_Msg230.data[1].bbyte=0x25;
        g_Msg240.data[7].bbyte=0xB9;
        g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0;
       g_Msg101.data[0].bbyte=0x2E;
g_Msg101.data[1].bbyte=0x00;
g_Msg101.data[2].bbyte=0x20;
g_Msg101.data[4].bbyte=0x0E;
g_Msg101.data[5].bbyte=0x5D;
g_Msg084.data[3].bbyte=0x02;
       
        g_Msg12B.data[0].bbyte=0; 
        g_Msg12B.data[1].bbyte=0x35; 
    }
    if(G_Button.LED_STEP == 4)
    {
     g_Msg230.data[0].bbyte=0x01;
     g_Msg230.data[1].bbyte=0x80;
        g_Msg240.data[7].bbyte=0xC9;
        g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0;
        g_Msg101.data[0].bbyte=0x3E;
g_Msg101.data[1].bbyte=0x00;
g_Msg101.data[2].bbyte=0x2B;
g_Msg101.data[4].bbyte=0x0E;
g_Msg101.data[5].bbyte=0xC1;
g_Msg084.data[3].bbyte=0x03;
        
           }
    if(G_Button.LED_STEP == 5)
    {
                g_Msg230.data[0].bbyte=0x01;
g_Msg230.data[1].bbyte=0xE0;
        g_Msg240.data[7].bbyte=0xD8;
        g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0;
        g_Msg101.data[0].bbyte=0x4E;
g_Msg101.data[1].bbyte=0x00;
g_Msg101.data[2].bbyte=0x35;
g_Msg101.data[4].bbyte=0x0E;
g_Msg101.data[5].bbyte=0xF6;
        
        
        g_Msg12B.data[0].bbyte=0; 
        g_Msg12B.data[1].bbyte=0x50;
    }
    if(G_Button.LED_STEP == 6)
    {
        g_Msg230.data[0].bbyte=0x02;
        g_Msg230.data[1].bbyte=0x40;
        g_Msg240.data[7].bbyte=0xE4;
        g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0;
       g_Msg101.data[0].bbyte=0x5B;
g_Msg101.data[1].bbyte=0x00;
g_Msg101.data[2].bbyte=0x40;
g_Msg101.data[4].bbyte=0x0F;
g_Msg101.data[5].bbyte=0xBE;
       
       
        g_Msg12B.data[0].bbyte=0; 
        g_Msg12B.data[1].bbyte=0x60;
    }
    if(G_Button.LED_STEP == 7)
    {
        g_Msg230.data[0].bbyte=0x02;
       g_Msg230.data[1].bbyte=0xA0;
        g_Msg240.data[7].bbyte=0xE4;
        g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0;
        g_Msg101.data[0].bbyte=0x6B;
g_Msg101.data[1].bbyte=0x00;
g_Msg101.data[2].bbyte=0x4B;
g_Msg101.data[4].bbyte=0x0F;
g_Msg101.data[5].bbyte=0xBE;
        
                g_Msg12B.data[0].bbyte=0; 
        g_Msg12B.data[1].bbyte=0x70;
    }
    if(G_Button.LED_STEP >= 8)
    {
        g_Msg230.data[0].bbyte=0x02;
g_Msg230.data[1].bbyte=0xF8;
        g_Msg240.data[7].bbyte=0xE4;
        g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0;
        g_Msg101.data[0].bbyte=0x7B;
g_Msg101.data[1].bbyte=0;
g_Msg101.data[2].bbyte=0x55;
g_Msg101.data[4].bbyte=0x0F;
g_Msg101.data[5].bbyte=0xBE;
        
        
        g_Msg12B.data[0].bbyte=0; 
        g_Msg12B.data[1].bbyte=0x80;
    }
    if(G_Button.LED_STEP >= 9)
    {
//         g_Msg230.data[0].bbyte=0x03;
//         g_Msg230.data[1].bbyte=0x60;
//         g_Msg240.data[7].bbyte=0xE4;
//         g_Msg240.data[4].bbyte=0;
//         g_Msg402.data[7].bbyte=0;
//         g_Msg101.data[0].bbyte=0x8C;
// g_Msg101.data[1].bbyte=0xA0;
// g_Msg101.data[2].bbyte=0x8C;
// g_Msg101.data[4].bbyte=0x0F;
// g_Msg101.data[5].bbyte=0xBE;
        
//                g_Msg12B.data[0].bbyte=0; 
//         g_Msg12B.data[1].bbyte=0x90;
//         g_Msg125.data[3].bbyte=0x02;
//         g_Msg125.data[2].bbyte=0x00;
//         g_Msg125.data[4].bbyte=0x00;
        g_Msg230.data[3].bbyte=0x0;
        g_Msg200.data[0].bbyte=0x0;
        g_Msg250.data[0].bbyte=0x0;
        g_Msg2A0.data[0].bbyte=0x0;
        
        g_Msg2A0.data[3].bbyte=0x0;
       
        g_Msg230.data[2].bbyte=0x0;
        
        g_Msg055.data[0].bbyte=0x0;

        g_Msg230.data[0].bbyte=0x0;
        g_Msg230.data[1].bbyte=0x0;
        g_Msg240.data[7].bbyte=0x0;
        g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0;
        g_Msg101.data[0].bbyte=0x9B;
        g_Msg101.data[1].bbyte=0x0;
        g_Msg101.data[2].bbyte=0x60;
        g_Msg101.data[4].bbyte=0x0;
        g_Msg101.data[5].bbyte=0x0;
        
        g_Msg12B.data[0].bbyte=0; 
        g_Msg12B.data[1].bbyte=0x00;
        g_Msg125.data[3].bbyte=0x00;
        g_Msg125.data[2].bbyte=0x00;
        g_Msg125.data[4].bbyte=0x00;
           g_Msg402.data[4].bbyte=0x0;

       
        g_Msg084.data[3].bbyte=0x00;

    }
    if(G_Button.LED_STEP >= 10)
    {
        g_Msg230.data[3].bbyte|=0x20;
        g_Msg200.data[0].bbyte|=0x40;
        g_Msg250.data[0].bbyte|=0x40;
        g_Msg2A0.data[0].bbyte|=0x03;
        g_Msg2A0.data[0].bbyte|=0x30;
        g_Msg2A0.data[3].bbyte|=0x40;
        g_Msg230.data[3].bbyte|=0x40;
        g_Msg230.data[2].bbyte=0x60;
        g_Msg230.data[3].bbyte|=0x80;
        g_Msg055.data[0].bbyte=0x01;

        g_Msg230.data[0].bbyte=0x03;
        g_Msg230.data[1].bbyte=0xFF;
        g_Msg240.data[7].bbyte=0xE4;
        g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0;
        g_Msg101.data[0].bbyte=0xBF;
g_Msg101.data[1].bbyte=0x0;
g_Msg101.data[2].bbyte=0xFF;
g_Msg101.data[4].bbyte=0x0F;
g_Msg101.data[5].bbyte=0xBE;
         g_Msg402.data[4].bbyte=0x04;
               g_Msg12B.data[0].bbyte=0; 
        g_Msg12B.data[1].bbyte=0xA0;
        g_Msg125.data[3].bbyte=0x01;
        g_Msg125.data[2].bbyte=0x00;
        g_Msg125.data[4].bbyte=0x01;

    }
    if(G_Button.LED_STEP >= 11)
    {
        g_Msg240.data[7].bbyte=0xE4;
        g_Msg240.data[4].bbyte=0;
       // g_Msg402.data[7].bbyte=0;
        g_Msg101.data[0].bbyte=0x9C;
g_Msg101.data[1].bbyte=0x40;
g_Msg101.data[2].bbyte=0xC7;
g_Msg101.data[4].bbyte=0x0F;
g_Msg101.data[5].bbyte=0xBE;
g_Msg402.data[7].bbyte=0x80;
    g_Msg084.data[3].bbyte=0x01;    
        
        g_Msg12B.data[0].bbyte=0; 
        g_Msg12B.data[1].bbyte=0xC0;
        g_Msg125.data[3].bbyte=0x01;
        g_Msg125.data[2].bbyte=0x00;
        g_Msg125.data[4].bbyte=0x01;
    }
    if(G_Button.LED_STEP >= 12)
    {
        g_Msg240.data[7].bbyte=0xE4;
        g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0;
        g_Msg101.data[0].bbyte=0;
g_Msg101.data[1].bbyte=0;
g_Msg101.data[2].bbyte=0;
g_Msg101.data[4].bbyte=0;
g_Msg101.data[5].bbyte=0;
        
        
        g_Msg12B.data[0].bbyte=0; 
        g_Msg12B.data[1].bbyte=0xC4;
        g_Msg125.data[3].bbyte=0x02;
        g_Msg125.data[2].bbyte=0x00;
        g_Msg125.data[4].bbyte=0x00;
    }
    if(G_Button.LED_STEP >= 13)
    {
        g_Msg240.data[7].bbyte=0xE4;
        g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0;
        g_Msg101.data[2].bbyte=0x82;//����
        g_Msg101.data[4].bbyte=0x0F;//ˮ��
        g_Msg101.data[5].bbyte=0x5A; 
        g_Msg12B.data[0].bbyte=0; 
        g_Msg12B.data[1].bbyte=0xD0;
    }
    if(G_Button.LED_STEP >= 14)
    {
        g_Msg240.data[7].bbyte=0xE4;
        g_Msg240.data[4].bbyte=0x08;
        g_Msg402.data[7].bbyte=0;
        g_Msg101.data[2].bbyte=0x94;//����
        g_Msg101.data[4].bbyte=0x0F;//ˮ��
        g_Msg101.data[5].bbyte=0x5A; 
        g_Msg12B.data[0].bbyte=0; 
        g_Msg12B.data[1].bbyte=0xD5;
        
    }
    if(G_Button.LED_STEP >= 15)
    {
        g_Msg240.data[7].bbyte=0xE4;
        g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0;
        g_Msg101.data[2].bbyte=0xA7;//����
        g_Msg101.data[4].bbyte=0x0F;//ˮ��
        g_Msg101.data[5].bbyte=0x5A; 
        g_Msg12B.data[0].bbyte=0x01; 
        g_Msg12B.data[1].bbyte=0x1C;
        
    }
    if(G_Button.LED_STEP >= 16)
    {
        g_Msg240.data[7].bbyte=0xE4;
        g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0;
        g_Msg101.data[2].bbyte=0xBE;//����
        g_Msg101.data[4].bbyte=0x0F;//ˮ��
        g_Msg101.data[5].bbyte=0x5A; 
        g_Msg12B.data[0].bbyte=0x01; 
        g_Msg12B.data[1].bbyte=0x40;
    }
    if(G_Button.LED_STEP >= 17)
    {
        g_Msg240.data[7].bbyte=0xE4;
        g_Msg240.data[4].bbyte=0;
        g_Msg402.data[7].bbyte=0;
        g_Msg101.data[2].bbyte=0xBE;//����
        g_Msg101.data[4].bbyte=0x0F;//ˮ��
        g_Msg101.data[5].bbyte=0x5A; 
        g_Msg12B.data[0].bbyte=0x01; 
        g_Msg12B.data[1].bbyte=0x66;
    }
    if(G_Button.LED_STEP >= 18)
    {
        g_Msg240.data[7].bbyte=0xE4;
        g_Msg240.data[4].bbyte=0x08;
        g_Msg402.data[7].bbyte=0x80;
        g_Msg101.data[2].bbyte=0xBE;//����
        g_Msg101.data[4].bbyte=0x0F;//ˮ��
        g_Msg101.data[5].bbyte=0x5A; 
        g_Msg12B.data[0].bbyte=0x01; 
        g_Msg12B.data[1].bbyte=0x66;
        
    }
#endif
}

