#ifndef __COMMUTION_H__
#define __COMMUTION_H__


#if (Uart_COMMUNICATION==0)
    #define RX_LEN                        20
    #define TX_LEN                        20
#elif (Uart_COMMUNICATION==1)
    #define RX_LEN                        23
    #define TX_LEN                        23
#endif

#define RX_ZHENTOU                    0x00
#define TX_ZHENTOU                    0x95

#define RX_LEN1                        8
#define TX_LEN1                        11

#define RX_ZHENTOU1                   0x81
#define TX_ZHENTOU1                   0x28

#define T_mreset                    5000      //5000ms
#define T_mrxerr                    180       //180s
#define T_mchgerr                   120       //120s
#define T_mtxcyc                    230       //230ms
#define T_mcomcyc                   500       //500ms
#define T_mfrmwt                    25        //25ms
#define T_mwtchg                    50        //50ms

#define evnodd                      0    //0:  ????1:???



typedef union
{
    uint8 DATA00;
    struct
    {
        uint8  DATA0 :  1;  //DATA1.0
        uint8  DATA1 :  1;  //DATA1.1
        uint8  DATA2 :  1;  //DATA1.2
        uint8  DATA3 :  1;  //DATA1.3
        uint8  DATA4 :  1;  //DATA1.4
        uint8  DATA5 :  1;  //DATA1.5
        uint8  DATA6 :  1;  //DATA1.6
        uint8  DATA7 :  1;  //DATA1.7
    } bf;
} ddatet00;



//????typedef struct

typedef union
{
    uint8 DATAT00;
    struct
    {
        uint8  DATA0 :  1;  //DATA1.0
        uint8  DATA1 :  1;  //DATA1.1
        uint8  DATA2 :  1;  //DATA1.2
        uint8  DATA3 :  1;  //DATA1.3
        uint8  DATA4 :  1;  //DATA1.4
        uint8  DATA5 :  1;  //DATA1.5
        uint8  DATA6 :  1;  //DATA1.6
        uint8  DATA7 :  1;  //DATA1.7
    } bf;
} MCUART_Rec00;




typedef struct
{
    uint8 R_DATA[42];
    uint8 T_DATA[42];
    int16 uarttimejishu;
    uint8 recive_lenth;
    uint16 Uart_Tmreset;
    uint16 Uart_Tmcomcyc;
    uint8  Uart_Recivetime;
    uint8 Oder;
    uint8 Recive_Flag;
    
    
    uint8 recive_sussf_falg;
    uint8 send_start_falg;
    uint8     sussf_falg;
    
    uint8     sendflag;
    uint8     ResponseFlag;
    
    uint16      time_cnt;
    uint16    time_shuju;
    
    uint8     UartReadTemp;
    uint8     UartReadCnt;
    uint8     TxCnt;
    uint8     send_delay_time;
    
    uint16    YaJI_Speed;
    uint16    FengSpeed;
    int16     PengZhangFa;
    int16     PengZhangFa_ACT;
    uint8     u1IduRevDataCnt;
} MCUART;




extern MCUART xdata Uart;
extern uint8 BBC(uint8 * puchMsg, uint8 usDataLen);

extern unsigned char        u1_cnt_idu_comm_task;

extern MCUART_Rec00 xdata Uart_Rec_DATA00;
extern MCUART_Rec00 xdata Uart_Rec_DATA01;
extern MCUART_Rec00 xdata Uart_Rec_DATA02;
extern MCUART_Rec00 xdata Uart_Rec_DATA03;
extern MCUART_Rec00 xdata Uart_Rec_DATA04;
extern MCUART_Rec00 xdata Uart_Rec_DATA05;
extern MCUART_Rec00 xdata Uart_Rec_DATA06;
extern MCUART_Rec00 xdata Uart_Rec_DATA09;
extern MCUART_Rec00 xdata Uart_Rec_DATA10;
extern MCUART_Rec00 xdata Uart_Rec_DATA12;
extern MCUART_Rec00 xdata Uart_Rec_DATA13;
extern MCUART_Rec00 xdata Uart_Rec_DATA14;
extern MCUART_Rec00 xdata Uart_Rec_DATA15;

extern void UartRecive1(void);
extern void UartSend1(void);
extern void UartDealResponse1(void);
extern void UartDealResponse2(void);
extern void Uart_Int01(void);
extern void Uart_Int02(void);
extern void Uart_Int_Finsh(void);
extern void Uart_Run01(void);
extern void Uart_Run02(void);
extern void Uart_Run03(void);



#endif

