From 7d8ba5df7d883c86c24aa38449c4a6dd126e920f Mon Sep 17 00:00:00 2001 From: QuakeGod <quakegod@sina.com> Date: 星期二, 06 八月 2024 14:41:31 +0800 Subject: [PATCH] Radio_LLCC68 1.15, Stable version --- Radio_LLCC68/Radio/KWireLess.h | 149 ++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 114 insertions(+), 35 deletions(-) diff --git a/Radio_LLCC68/Radio/KWireLess.h b/Radio_LLCC68/Radio/KWireLess.h index 81af49f..f7ebad2 100644 --- a/Radio_LLCC68/Radio/KWireLess.h +++ b/Radio_LLCC68/Radio/KWireLess.h @@ -38,17 +38,103 @@ 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 + uint16_t nCycleTime; // + uchar workMode; //0: FSK, 1: LoRa + uchar nChannel; + uchar bMaster; + uchar nRadioAddr; + uchar bEnableMulti; + + 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 bAutoPower; //鑷姩鍔熺巼 + 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_IDLE, + RS_MASTER_CAD, RS_SENDING, + RS_SENT, RS_RECVING, + RS_RECVED, }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 +146,25 @@ 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 PktErr; //鍖呴敊璇� ; + uint16_t ChnErr; //棰戦亾閿欒; + uint16_t nErrChn; //閿欒鐨勯閬撳彿; + uint16_t CADDoneCount; //CAD 瀹屾垚娆℃暟 + uint16_t CADOkCount; //CAD 鏄鏁� + uint16_t CADNgCount; //CAD 鍚︽鏁� + uint16_t CADTimeOut; //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 +182,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 +192,8 @@ }stKLPacket, *pstKLPacket; +int LoadKwConfig(void); +int SaveKwConfig(void); int KWireLessInit(bool bRadioEnableMaster, uint32_t nChn); int KWireLessStart(void); @@ -153,9 +231,10 @@ int KWSendPkg(void* pPkg, int len); int KWProcPkg(void); -extern uchar nRadioChannel; -extern uchar nRadioAddr; +//extern uchar nRadioChannel; +//extern uchar nRadioAddr; +extern stWLConfig WLCfg ; extern stWLRunStat KwRunStat; -- Gitblit v1.9.1