void PcSerialSendPrg(UINT16 Cmd,UINT8 Len,UINT8 *Buf) { UINT8 i; //在上次发送未完成前等待发送结束 ComTransFrame.SOF=SLAVE_ANSWER_HEAD; ComTransFrame.AddrH=MachineType; ComTransFrame.AddrL=MachineSelfNum; ComTransFrame.CmdH=Cmd>>8; ComTransFrame.CmdL=Cmd; //ComTransFrame.LenthH=Len>>8; //ComTransFrame.LenthL=(UINT8)Len; ComTransFrame.LenthH=0; ComTransFrame.LenthL=Len; for (i=0;i<Len;i++) { ComTransFrame.DBuf=Buf; } ComTransFrame.CRC=0; #if QuerySerialSend ES=0;RI=0;TI=0; for (i=0;i<Len+7;i++) { SBUF=*((UINT8 *)&ComTransFrame+i); ComTransFrame.CRC += *((UINT8 *)&ComTransFrame+i); while(!TI);TI=0; } SBUF=ComTransFrame.CRC; while(!TI);TI=0; #endif UartSendDataNum=0; ES=1; EA=1; } |