From 9aed5d7e7b3c7bf09da712e9c272ece401a7acc9 Mon Sep 17 00:00:00 2001 From: QuakeGod <QuakeGod@sina.com> Date: 星期一, 25 十一月 2024 14:51:23 +0800 Subject: [PATCH] add UltraSonic and MultiWireLess --- KSingleLineBus/user/main.c | 28 +++++++++++++++++++--------- 1 files changed, 19 insertions(+), 9 deletions(-) diff --git a/KSingleLineBus/user/main.c b/KSingleLineBus/user/main.c index 4ca5711..768e02e 100644 --- a/KSingleLineBus/user/main.c +++ b/KSingleLineBus/user/main.c @@ -74,6 +74,10 @@ int nCount=0; +stSLPDef SLP1; + +unsigned char bSLPMaster; +unsigned char nSLPStation; void PutOutput(uchar a); @@ -94,6 +98,8 @@ }Coils; Coils inputdata; + +/* void Delay1ms() //@22.1184MHz { uchar data i, j; @@ -108,7 +114,6 @@ } while (--i); } - void Delay_ms(uint n) { while(n--) @@ -117,7 +122,7 @@ } } - +*/ void Delay_us(uint n) { uchar data j; @@ -298,11 +303,12 @@ uart3busy=1; } } +/* void SLPSendPacket(char * str, uchar len) { Uart3SendPacket(str,len); } - +*/ void Uart3RecvPacket() { if (uart3recvtimeout <2){ @@ -310,7 +316,7 @@ }else { /// recieved packet; RUN=~RUN; //闪灯 - SLPparsePacket(uart3recvbuf,uart3recvlen); + SLPparsePacket(&SLP1,uart3recvbuf,uart3recvlen); uart3recvlen =0; } } @@ -378,7 +384,11 @@ 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) @@ -389,15 +399,15 @@ // 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; @@ -405,7 +415,7 @@ } // Set Ouput Port - PutOutput(SLPoutputB); + PutOutput(SLP1.SLPoutputB); // receive packet -- Gitblit v1.9.1