| | |
| | | |
| | | int nCount=0; |
| | | |
| | | stSLPDef SLP1; |
| | | |
| | | unsigned char bSLPMaster; |
| | | unsigned char nSLPStation; |
| | | |
| | | |
| | | void PutOutput(uchar a); |
| | |
| | | }Coils; |
| | | |
| | | Coils inputdata; |
| | | |
| | | /* |
| | | void Delay1ms() //@22.1184MHz |
| | | { |
| | | uchar data i, j; |
| | |
| | | } while (--i); |
| | | } |
| | | |
| | | |
| | | void Delay_ms(uint n) |
| | | { |
| | | while(n--) |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | */ |
| | | void Delay_us(uint n) |
| | | { |
| | | uchar data j; |
| | |
| | | uart3busy=1; |
| | | } |
| | | } |
| | | /* |
| | | void SLPSendPacket(char * str, uchar len) |
| | | { |
| | | Uart3SendPacket(str,len); |
| | | } |
| | | |
| | | */ |
| | | void Uart3RecvPacket() |
| | | { |
| | | if (uart3recvtimeout <2){ |
| | |
| | | }else |
| | | { /// recieved packet; |
| | | RUN=~RUN; //闪灯 |
| | | SLPparsePacket(uart3recvbuf,uart3recvlen); |
| | | SLPparsePacket(&SLP1,uart3recvbuf,uart3recvlen); |
| | | uart3recvlen =0; |
| | | } |
| | | } |
| | |
| | | |
| | | inputdata.Byte = GetJumper(); |
| | | bSLPMaster = inputdata.bits.b5 ; //master? |
| | | nStation = inputdata.Byte & 0x0f; |
| | | nSLPStation = inputdata.Byte & 0x0f; |
| | | SLPInit(&SLP1,Uart3SendPacket); |
| | | SLP1.bSLPMaster = bSLPMaster; |
| | | SLP1.nStation = nSLPStation; |
| | | |
| | | // bSLPMaster=1; |
| | | |
| | | while(1) |
| | |
| | | |
| | | // Get Input Port; |
| | | inputdata.Byte = GetInput(); |
| | | SLPinputB = inputdata.Byte; |
| | | SLP1.SLPinputB = inputdata.Byte; |
| | | RUN =~ RUN; |
| | | // Delay_ms(1); |
| | | // receive packet |
| | | Uart3RecvPacket(); |
| | | // Process Packet |
| | | SLPProcess(); |
| | | SLPProcess(&SLP1); |
| | | |
| | | if (SLPErrSign) { |
| | | if (SLP1.SLPErrSign) { |
| | | ERR = 0; |
| | | }else { |
| | | ERR =1; |
| | |
| | | } |
| | | |
| | | // Set Ouput Port |
| | | PutOutput(SLPoutputB); |
| | | PutOutput(SLP1.SLPoutputB); |
| | | |
| | | |
| | | // receive packet |