From b6290b94cac76a5634cd90b495b65d91ee92d85e Mon Sep 17 00:00:00 2001
From: QuakeGod <QuakeGod@sina.com>
Date: 星期三, 22 二月 2023 08:57:38 +0800
Subject: [PATCH] fix conflict

---
 Src/main.c |   95 ++++++++++++++++++++++++++++-------------------
 1 files changed, 56 insertions(+), 39 deletions(-)

diff --git a/Src/main.c b/Src/main.c
index b6da46e..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,7 +313,6 @@
 	KWireLessInit(KMem.EffJumperSW&0x20);
 	KWireLessStart();
 #endif
-
   while (1)
   {
 		//int MyKeyStat1,MyKeyStat2;
@@ -440,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);
@@ -485,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