| | |
| | | uint8_t bSentLen;
|
| | |
|
| | | uint8_t bConfiged=0;
|
| | | uint8_t nConfigAddr=0;
|
| | | uint8_t nConfigStationId=0;
|
| | | uint8_t nInputBytes=8;
|
| | | uint8_t nOutputBytes=8;
|
| | | uint8_t nIndex=0;
|
| | |
| | | bSPI1Sending=0;
|
| | | bSPI1Recving=0;
|
| | | if (nChilds==0) {
|
| | | nInputBytes=1; //根据子机数量,报告扩展容量
|
| | | nInputBytes=1; //根据子机数量,报告扩展容量
|
| | | nOutputBytes=1;
|
| | | } else
|
| | | {
|
| | | nInputBytes=nChilds; //根据子机数量,报告扩展容量
|
| | | nInputBytes=nChilds; //根据子机数量,报告扩展容量
|
| | | nOutputBytes=nChilds;
|
| | | }
|
| | | SetACKPin_0();
|
| | |
| | | }
|
| | | }
|
| | | if (CurSYN ==0 && oldSYN != 0) {
|
| | | KMem.SDT[121] = KMem.SDT[122];
|
| | | KMem.SDT[122]=0;
|
| | | KMem.WDT[121] = KMem.WDT[122];
|
| | | KMem.WDT[122]=0;
|
| | | }
|
| | | if (CurSEL && CurSYN !=0 && oldSYN == 0){
|
| | | bSPI1Recving=1;
|
| | |
| | | uint8_t res=0;
|
| | | uint8_t nST=pBuf[0];
|
| | | uint8_t nCMD=nST&0x7;
|
| | | uint8_t nAddr=nST&0xf8;
|
| | | KMem.SDB[128+KMem.SDT[123]] = 0xFF;
|
| | | KMem.SDT[123]++; if (KMem.SDT[123]>=100) {KMem.SDT[123]=81;}
|
| | | uint8_t nStationID=nST&0xf8;
|
| | |
|
| | | if (nAddr<0x80) return 0;
|
| | | logData(0xff);
|
| | | |
| | | if (nStationID<0x80) return 0;
|
| | | switch (nCMD)
|
| | | {
|
| | | case CMD_0_QUERY:
|
| | | if (!bConfiged || (bConfiged && nAddr == nConfigAddr))
|
| | | if (!bConfiged || (bConfiged && nStationID == nConfigStationId))
|
| | | {
|
| | | KMem.DT[8]++;
|
| | | pFP0QuRplyPkg p1 = (pFP0QuRplyPkg)PkgBuf2;
|
| | |
| | | p1->nBCC= 0x30|CalFP0BCC(PkgBuf2,4);
|
| | | p1->End1=0x0d;
|
| | |
|
| | | KMem.SDB[128+KMem.SDT[123]] = 0x11;
|
| | | KMem.SDT[123]++; if (KMem.SDT[123]>=100) {KMem.SDT[123]=81;} |
| | | logData(0x11);
|
| | |
|
| | | SendFP0Pkg(PkgBuf2,sizeof(stFP0QuRplyPkg));
|
| | | nConfigAddr=nAddr;
|
| | | nConfigStationId=nStationID;
|
| | | bConfiged=1;
|
| | | }
|
| | | bSPI1Recving=1;
|
| | |
| | | // bSPI1Recving=1;
|
| | | break;
|
| | | case CMD_3_EXCHG:
|
| | | if (!bConfiged || nConfigAddr != nAddr)
|
| | | if (!bConfiged || nConfigStationId != nStationID)
|
| | | {
|
| | | bSPI1Recving=1;
|
| | | break;
|
| | |
| | | break;
|
| | | case CMD_7_END:
|
| | | KMem.DT[15]++;
|
| | | if (bConfiged && nConfigAddr == nAddr)
|
| | | if (bConfiged && nConfigStationId == nStationID)
|
| | | {
|
| | | //SetFP0DEPin_0();
|
| | | SetACKPin_1();
|
| | |
| | | value = SPI1SendBuf[nSPI1SentLen];
|
| | | LL_SPI_TransmitData8(SPI1,value);
|
| | | bSPI1Sending=1;
|
| | | KMem.SDB[128+KMem.SDT[123]] = value;
|
| | | KMem.SDT[123]++; if (KMem.SDT[123]>=100) {KMem.SDT[123]=81;} |
| | | |
| | | logData(value); |
| | |
|
| | | // passive mode
|
| | | SetFP0DEPin_1();
|
| | | SetACKPin_0();
|