From 0fe6b074f3f3994d87af195f37e349a83e27882c Mon Sep 17 00:00:00 2001 From: QuakeGod <QuakeGod@sina.com> Date: 星期六, 10 十二月 2022 16:55:40 +0800 Subject: [PATCH] FP0 fix utf8 char --- Src/main.c | 96 ++++++++++++++++++++++++++++------------------- 1 files changed, 57 insertions(+), 39 deletions(-) diff --git a/Src/main.c b/Src/main.c index bf13c65..c1a7ec3 100644 --- a/Src/main.c +++ b/Src/main.c @@ -70,11 +70,11 @@ /* USER CODE BEGIN PV */ /* Private variables ---------------------------------------------------------*/ -#define RX2BUFSIZE 128 -#define TX2BUFSIZE 128 +#define RX2BUFSIZE 64 +#define TX2BUFSIZE 64 -unsigned char Uart1RxBuf[256]; -unsigned char Uart1TxBuf[280]; +unsigned char Uart1RxBuf[128]; +unsigned char Uart1TxBuf[260]; unsigned char Uart2RxBuf[RX2BUFSIZE]; unsigned char Uart2TxBuf[TX2BUFSIZE]; @@ -124,6 +124,8 @@ Count=0; KMem.CurTimeSec++; KMem.ThisRunTime++; KMem.TotalRunTime++; + if (KMRunStat.bLEDFlick) KMRunStat.bLEDFlick--; + if (KMRunStat.bLEDFlick >120) KMRunStat.bLEDFlick=120; } return; @@ -139,9 +141,10 @@ int main(void) { /* USER CODE BEGIN 1 */ - - InitUartstat(&Uart1Stat,Uart1TxBuf,sizeof(Uart1RxBuf),Uart1TxBuf,sizeof(Uart1TxBuf)); - InitUartstat(&Uart2Stat,Uart2TxBuf,sizeof(Uart2RxBuf),Uart2TxBuf,sizeof(Uart2TxBuf)); + KMRunStat.bLEDFlick = 1; + + InitUartstat(&Uart1Stat,Uart1RxBuf,sizeof(Uart1RxBuf),Uart1TxBuf,sizeof(Uart1TxBuf)); + InitUartstat(&Uart2Stat,Uart2RxBuf,sizeof(Uart2RxBuf),Uart2TxBuf,sizeof(Uart2TxBuf)); /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ @@ -153,18 +156,18 @@ for (int i=0;i<9;i++) { -// memset(ChnStats[i],0,0); - ChnStats[i].SendPackets=0; - ChnStats[i].RecvPackets=0; - ChnStats[i].LostPackets=0; - ChnStats[i].CtnLstPkts=0; - ChnStats[i].MaxCtnLstPkts=0; - ChnStats[i].NotPkgErr=0; - ChnStats[i].PkgLenErr=0; - ChnStats[i].TimeOutErr=0; - ChnStats[i].BCCErr=0; - ChnStats[i].Delay=0; - ChnStats[i].MaxDelay=0; +// memset(KBusChnStats[i],0,0); + KBusChnStats[i].SendPackets=0; + KBusChnStats[i].RecvPackets=0; + KBusChnStats[i].LostPackets=0; + KBusChnStats[i].CtnLstPkts=0; + KBusChnStats[i].MaxCtnLstPkts=0; + KBusChnStats[i].NotPkgErr=0; + KBusChnStats[i].PkgLenErr=0; + KBusChnStats[i].TimeOutErr=0; + KBusChnStats[i].BCCErr=0; + KBusChnStats[i].Delay=0; + KBusChnStats[i].MaxDelay=0; } KMem.LastScanTime=0; @@ -188,9 +191,9 @@ SystemClock_Config(); /* USER CODE BEGIN SysInit */ - TickFreq=10000; //Tick频锟斤拷 + TickFreq=10000; //Tick棰戠巼 InituS(TickFreq); - // HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/TickFreq); //锟斤拷锟铰讹拷锟斤拷SysTick锟斤拷频锟斤拷锟� + // HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/TickFreq); //閲嶆柊瀹氫箟SysTick鐨勯鐜� /* USER CODE END SysInit */ @@ -201,26 +204,28 @@ KMachineInit(); ReadSysCfgFromFlash(&storedKMSysCfg); + KMRunStat.bLEDFlick = 1; + KMem.EffJumperSW=ReadJumperSW(); #if (BOARD_TYPE == 14) KMem.EffJumperSW|=0x10; - nAddr=KMem.EffJumperSW&0x0f; + nStationID=KMem.EffJumperSW&0x0f; if ((KMem.EffJumperSW&0x10)!=0) {bKBusMaster=1;bKBusSlave=0;} else{bKBusMaster=0;bKBusSlave=1;} - nChilds=nAddr; + nChilds=nStationID; FP0_Init(); #elif (BOARD_TYPE == 15) - nAddr=KMem.EffJumperSW&0x0f; + nStationID=KMem.EffJumperSW&0x0f; if (KMem.EffJumperSW == 0x1f) {bKBusRepeater=1;bKBusMaster=1;bKBusSlave=0;} else if ((KMem.EffJumperSW&0x10)!=0) {bKBusMaster=1;bKBusSlave=0;} else{bKBusMaster=0;bKBusSlave=1;} #else - nAddr=KMem.EffJumperSW&0x7; + nStationID=KMem.EffJumperSW&0x7; if (KMem.EffJumperSW == 0x0f) {bKBusRepeater=1;bKBusMaster=1;bKBusSlave=0;} else if ((KMem.EffJumperSW&0x08)!=0) {bKBusMaster=1;bKBusSlave=0;} else{bKBusMaster=0;bKBusSlave=1;} #endif - nChilds=nAddr; + nChilds=nStationID; nCurPollId=1; //if (KMem.EffJumperSW == 0x00) Uart1Baud = DefaultUart1Baud; @@ -308,11 +313,11 @@ KWireLessInit(KMem.EffJumperSW&0x20); KWireLessStart(); #endif - while (1) { //int MyKeyStat1,MyKeyStat2; //MyKeyStat1=GetInput(); + //*((unsigned int *)&(PLCMem.SDT[10]))=nRunCount; // KMem.nRunCount=nRunCount; SlowFlicker=0; @@ -439,20 +444,33 @@ // KMem.WY[0]=nCount2>>5; if (KMem.RunStat) {KMem.RunStat--;} if (KMem.ErrStat) {KMem.ErrStat--;} - - if (!KMem.RunStat) SetRunLed(SlowFlicker); - else SetRunLed(FastFlicker); - if (!KMem.ErrStat) + if (KMRunStat.bLEDFlick) { - SetErrLed(0); - SetOutStat(1); - } - else - { + SetRunLed(FastFlicker); SetErrLed(FastFlicker); - SetOutStat(0); + SetErr2Led(FastFlicker); + SetOutStat(!FastFlicker); + //KMRunStat.bLEDFlick-- ; + } + else + { + if (!KMem.RunStat) SetRunLed(SlowFlicker); + else SetRunLed(FastFlicker); + if (!KMem.ErrStat) + { + SetErrLed(0); + SetErr2Led(0); + SetOutStat(1); + } + else + { + SetErrLed(FastFlicker); + SetErr2Led(FastFlicker); + SetOutStat(0); + + } } // SetRunLed(RunStat); @@ -484,8 +502,8 @@ } KMem.nRunCount++; // int nSize=sizeof(stChnStat); -// memcpy(&KMem.SDT[64],&ChnStats[1],nSize); -// memcpy(&KMem.SDT[64+nSize/2],&ChnStats[2],nSize); +// memcpy(&KMem.SDT[64],&KBusChnStats[1],nSize); +// memcpy(&KMem.SDT[64+nSize/2],&KBusChnStats[2],nSize); // for (int i=0;i<128;i++) { SDT[i]=i; } // SDT[48]=55; if (Uart1RecvBuf1DataLen >0 && Uart1Stat.bPacketRecved) -- Gitblit v1.9.1