| | |
| | | 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; //上次发送时间 |
| | | uint32_t lastSenttime; //上次发送出时间 |
| | | uint32_t lastSenttime; //上次发完时间 |
| | | uint32_t lastRecvtime; //上次启动接收时间 |
| | | uint32_t lastRecvdtime; //上次接收时间 |
| | | uint32_t lastRecvdtime; //上次收到时间 |
| | | uint32_t lastActTime; //上次动作时间 |
| | | uint32_t lastAckTime; //上次应答时间 |
| | | 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错误计数 |
| | | |
| | | 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; //信噪比 |
| | | int8_t tRSSI; //对方信号强度 |
| | | int8_t tSNR; //对方信噪比 |
| | | |
| | | }stWLRunStat; |
| | | uint32_t targetSentCount; //对方发送数量 |
| | | uint32_t targetRecvdCount; //对方接受数量 |
| | | |
| | | }stWLRunStat,*pstWLRunStat; |
| | | |
| | | enum { |
| | | enReqSign = 0x55, |
| | | enRplySign = 0xAA, |
| | | |
| | | }; |
| | | |
| | | extern uint32_t nRadioChannel; |
| | | extern stWLRunStat KwRunStat; |
| | | typedef struct tagKLPacket |
| | | { |
| | | uchar STSign; |
| | | uchar DstAddr; |
| | | uchar Func; |
| | | uchar Stat; |
| | | uchar Data[1]; |
| | | |
| | | }stKLPacket, *pstKLPacket; |
| | | |
| | | int LoadKwConfig(void); |
| | | int SaveKwConfig(void); |
| | | |
| | | int KWireLessInit(bool bRadioEnableMaster, uint32_t nChn); |
| | | int KWireLessStart(void); |
| | | |
| | |
| | | int KWLMasterProc(int nChn); |
| | | int KWLSlaveProc(int nChn); |
| | | |
| | | int KWLMasterParsePkt(int nChn); |
| | | int KWLSlaveParsePkt(int nChn); |
| | | int KWLMasterParsePkt(int nChn, int nSize); |
| | | int KWLSlaveParsePkt(int nChn, int nSize); |
| | | |
| | | int KWLMasterSendReqPkt(int nChn); |
| | | int KWLSlaveSendRplyPkt(int nChn); |
| | |
| | | |
| | | int KWSendPkg(void* pPkg, int len); |
| | | int KWProcPkg(void); |
| | | |
| | | //extern uchar nRadioChannel; |
| | | //extern uchar nRadioAddr; |
| | | |
| | | extern stWLConfig WLCfg ; |
| | | extern stWLRunStat KwRunStat; |
| | | |
| | | |
| | | #endif ///* __KBUS_H__ */ |
| | | |