From 842bb64195f958b050867c50db66fc0aa413dafb Mon Sep 17 00:00:00 2001
From: QuakeGod <quakegod@sina.com>
Date: 星期六, 27 七月 2024 10:42:56 +0800
Subject: [PATCH] KBus upgrade

---
 Radio_LLCC68/Radio/KWireLess.h |  129 ++++++++++++++++++++++++++++++++----------
 1 files changed, 97 insertions(+), 32 deletions(-)

diff --git a/Radio_LLCC68/Radio/KWireLess.h b/Radio_LLCC68/Radio/KWireLess.h
index 81af49f..ea94fac 100644
--- a/Radio_LLCC68/Radio/KWireLess.h
+++ b/Radio_LLCC68/Radio/KWireLess.h
@@ -38,17 +38,94 @@
 	KW_ERROR3,
 }KWStates;
 
+#define STORE_KWCONFIG_BASE (FLASH_BASE + 0x0000F000)		//50k K //and 
+//#define STORE_RUNSTAT_PAGESIZE (0x00000400)							//Page Size = 1K
+#define STORE_KWCONFIG_PAGES 1														//use 1 pages
+
+enum enWLWorkMode
+{
+	WLWorkModeNone,			//
+	WLWorkModeUni,			// 涓�瀵逛竴
+	WLWorkModeMul,			// 涓�瀵瑰
+	WLWorkModeThr,			// 閫忎紶
+	
+};
+
+typedef struct tagWLConfig
+{
+	uint32_t RF_T_Freq;					//Hz
+	uint32_t RF_R_Freq;					//Hz
+	uint16_t nChnSpacing;		//kHz
+	uchar workMode;			//0: FSK,    1: LoRa	
+	uchar Tx_Power;			// dBm		5 - 22 dBm
+	uchar LoraBandWidth;		//		[0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved ] 
+	uchar LoRaFactor;				//		[SF5 .. SF 12]
+	uchar LoRaCodingRate;		//		[1 : 4/5,  2: 4/6,  3:  4/7,	4:  4/8 ]
+	uint8_t NetWorkAddr;
+	uint16_t DeviceAddr;
+	uchar bEnableAddr;
+	uchar bEnableEncrypt;
+	uchar bEnableRelay;	
+	uchar LoRaPreambleLen;			// 2 - 12
+	uchar bAutoReSend;		//鑷姩閲嶅彂
+	
+	
+//	uchar ;		//
+//	uchar 
+	
+}stWLConfig, *pstWLConfig;
+
+typedef struct tagStoredWLConfig
+{
+	unsigned short BlockSign;
+	unsigned char BlockType;
+	unsigned char nSeq;
+	unsigned short nSize;
+	unsigned short nCRC16;
+	stWLConfig WLConfig;
+}stStoredWLConfig, *pstStoredWLConfig;
+
+
 typedef enum tag_runstep{
 	RS_IDEL,
 	RS_SENDING,
 	RS_RECVING,
 }enRunStep;
 
+#pragma anon_unions
 typedef struct tagWLStat
 {
-	uint32_t Stat;							//鐘舵��
-	uint32_t curStat;						//褰撳墠鐘舵��
-	uint32_t runStep;						//宸ヤ綔姝ラ
+	union {
+		uint32_t Status;							//鐘舵��
+		struct {
+			uint32_t bMasterSent:1;
+			uint32_t bMasterRecved:1; 
+		};  
+	}; 
+	uint16_t curStat;						//褰撳墠鐘舵��
+	uint16_t runStep;						//宸ヤ綔姝ラ
+	
+	uint16_t RunStat;						//杩愯鐘舵��
+	uint16_t ErrStat;						//閿欒鐘舵��
+	
+	uint32_t RF_Freq;						//杩愯棰戠巼
+	uint16_t nTimeOnAir;
+	uint16_t DeviceAddr;	
+
+	uint8_t NetWorkAddr;
+	
+	uchar Tx_Power;			// dBm		5 - 22 dBm
+	uchar LoraBandWidth;		//		[0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved ] 
+	uchar LoRaFactor;				//		[SF5 .. SF 12]
+	uchar LoRaCodingRate;		//		[1 : 4/5,  2: 4/6,  3:  4/7,	4:  4/8 ]
+
+	uchar LoRaPreambleLen;			// 2 - 12
+
+	uchar bEnableAddr;
+	uchar bEnableEncrypt;
+	uchar bEnableRelay;	
+	uchar bAutoReSend;		//鑷姩閲嶅彂
+	
 	uint32_t sentCount;					//鍙戦�佽鏁�
 	uint32_t recvCount;					//鎺ユ敹璁℃暟
 	uint32_t lastSendtime;			//涓婃鍙戦�佹椂闂�
@@ -60,18 +137,20 @@
 	uint32_t lastErrTime;				//涓婃閿欒鏃堕棿
 	uint32_t latancy;						//寤惰繜
 	uint32_t cycleTime;					//寰幆鏃堕棿
-	uint32_t LostPackets;				//涓㈠寘璁℃暟
-	uint32_t CtnLstPkts;				//杩炵画涓㈠寘璁℃暟
-	uint32_t MaxCtnLstPkts;			//鏈�澶ц繛缁涪鍖呰鏁�
-	uint32_t TXErr;							//鍙戦�侀敊璇鏁�
-	uint32_t RXErr;							//鎺ユ敹閿欒璁℃暟
-	uint32_t CRCErr; 						//CRC閿欒璁℃暟
-	uint32_t CADDoneCount;			//CAD 瀹屾垚娆℃暟
-	uint32_t StepErr1;					//姝ラ閿欒1
-	uint32_t StepErr2;					//姝ラ閿欒2
-	uint32_t Err1Count;					//寰棯鎶ヨ娆℃暟
-	uint32_t Err2Count;					//澶ч棯鎶ヨ娆℃暟
-	uint32_t Err3Count;					//涓ラ噸涓㈠け淇″彿娆℃暟
+	uint16_t LostPackets;				//涓㈠寘璁℃暟
+	uint16_t CtnLstPkts;				//杩炵画涓㈠寘璁℃暟
+	uint16_t MaxCtnLstPkts;			//鏈�澶ц繛缁涪鍖呰鏁�
+	uint16_t TXErr;							//鍙戦�侀敊璇鏁�
+	uint16_t RXErr;							//鎺ユ敹閿欒璁℃暟
+	uint16_t CRCErr; 						//CRC閿欒璁℃暟
+	uint16_t ChnErr;						//棰戦亾閿欒
+	uint16_t PktErr;						//鍖呴敊璇�
+	uint16_t CADDoneCount;			//CAD 瀹屾垚娆℃暟
+	uint16_t StepErr1;					//姝ラ閿欒1
+	uint16_t StepErr2;					//姝ラ閿欒2
+	uint16_t Err1Count;					//寰棯鎶ヨ娆℃暟
+	uint16_t Err2Count;					//澶ч棯鎶ヨ娆℃暟
+	uint16_t Err3Count;					//涓ラ噸涓㈠け淇″彿娆℃暟
 	
 	int8_t RSSI;								//淇″彿寮哄害
 	int8_t SNR;								//淇″櫔姣�
@@ -89,23 +168,6 @@
 	
 };
 
-typedef struct tagWLConfig
-{
-	uint32_t RF_Freq;
-	uint32_t ChannelSpacing;
-	uchar Tx_Power;
-	
-	uchar workMode;			//0: FSK,    1: LoRa
-	uchar LoraBandWidth;		//		[0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved ] 
-	uchar LoRaFactor;				//		[SF5 .. SF 12]
-	uchar LoRaCodingRate;		//		[1 : 4/5,  2: 4/6,  3:  4/7  
-	uchar LoRaPreamble_Len;			// 2 - 12
-//	uchar ;		//
-//	uchar 
-	
-}stWLConfig;
-
-
 typedef struct tagKLPacket
 {
 	uchar STSign;
@@ -116,6 +178,8 @@
 	
 }stKLPacket, *pstKLPacket;
 
+int LoadKwConfig(void);
+int SaveKwConfig(void);
 
 int KWireLessInit(bool bRadioEnableMaster, uint32_t nChn);
 int KWireLessStart(void);
@@ -156,6 +220,7 @@
 extern uchar nRadioChannel;
 extern uchar nRadioAddr;
 
+extern stWLConfig WLCfg ;
 extern stWLRunStat KwRunStat;
 
 

--
Gitblit v1.9.1