From 5dd1b7fdcc52a43867f924e8d220de8467af372a Mon Sep 17 00:00:00 2001 From: QuakeGod <quakegod@sina.com> Date: 星期五, 12 四月 2024 14:27:26 +0800 Subject: [PATCH] Change KBus to OOP and Packge --- ComLib/Inc/KMachine.h | 100 ++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 89 insertions(+), 11 deletions(-) diff --git a/ComLib/Inc/KMachine.h b/ComLib/Inc/KMachine.h index 736e08a..f9ec465 100644 --- a/ComLib/Inc/KMachine.h +++ b/ComLib/Inc/KMachine.h @@ -8,36 +8,34 @@ #ifndef __KMACHINE_H__ #define __KMACHINE_H__ -#define FLASH_PAGESIZE (0x00000400) //Page Size = 1K - #define FACTORY_DATA_BASE (FLASH_BASE + 0x00007C00) //31k //and -#define FACTORY_DATA_PAGESIZE (0x00000400) //Page Size = 1K +//#define FACTORY_DATA_PAGESIZE (0x00000400) //Page Size = 1K #define FACOTRY_DATA_PAGES 1 // use 1 page(s) #define STORE_PRG_BASE (FLASH_BASE + 0x00008000) //32k //and FLASH_BANK1_END -#define STORE_PRG_PAGESIZE (0x00000400) //Page Size = 1K +//#define STORE_PRG_PAGESIZE (0x00000400) //Page Size = 1K #define STORE_PRG_PAGES 8 //use 4 pages #define ALT_PRG_BASE (FLASH_BASE + 0x0000A000) //40k //and FLASH_BANK1_END -#define ALT_PRG_PAGESIZE (0x00000400) //Page Size = 1K +//#define ALT_PRG_PAGESIZE (0x00000400) //Page Size = 1K #define ALT_PRG_PAGES 8 //use 4 pages #define STORE_SYSREG_BASE (FLASH_BASE + 0x0000C000) //48k //and -#define STORE_SYSREG_PAGESIZE (0x00000400) //Page Size = 1K +//#define STORE_SYSREG_PAGESIZE (0x00000400) //Page Size = 1K #define STORE_SYSREG_PAGES 1 //use 1 pages #define STORE_RUNSTAT_BASE (FLASH_BASE + 0x0000C800) //50k K //and -#define STORE_RUNSTAT_PAGESIZE (0x00000400) //Page Size = 1K +//#define STORE_RUNSTAT_PAGESIZE (0x00000400) //Page Size = 1K #define STORE_RUNSTAT_PAGES 1 //use 1 pages #define STORE_LOG_BASE (FLASH_BASE + 0x0000D000) //52k and FLASH_BANK1_END -#define STORE_LOG_PAGESIZE (0x00000400) //Page Size = 1K +//#define STORE_LOG_PAGESIZE (0x00000400) //Page Size = 1K #define STORE_LOG_PAGES 4 //use 4 pages - typedef unsigned char uchar; typedef unsigned char UCHAR; +typedef unsigned short ushort; typedef unsigned short USHORT; typedef unsigned int UINT; typedef unsigned int uint32_t; @@ -120,6 +118,14 @@ }stFactoryData,* pFactoryData; +typedef struct tagNewAppInfoBlock +{ + unsigned short Sign; + unsigned short Version; + unsigned int Length; + unsigned int nCRC; + +}stNewAppInfoBlock,*pNewAppInfoBlock; enum enStoreCfg { @@ -361,6 +367,8 @@ KLDataTypeWDT = 41 | TYPEDATA, //璋冭瘯鐩戞帶鏁版嵁 KLDataTypeKBD = 51 | TYPEDATA, //KBus 璋冭瘯鏁版嵁 KLDataTypeKWLD = 52 | TYPEDATA, //鏃犵嚎璋冭瘯鏁版嵁 + KLDataTypeNewApp = 61 | TYPEDATA, // New FirmWare + KLDataTypeNewAppInfo = 62 | TYPEDATA, // New Firmware Info Block; KLDataTypeTest = 254 | TYPEDATA, }; @@ -508,6 +516,71 @@ }stKMem; +// 閫氫俊绔彛锛� 娉ㄥ唽鍒� KMachine 閲岋紝 缁熶竴绠$悊 + +typedef struct tagPortAbility +{ + ushort ChildList:1; + ushort AccessChild:1; + ushort TranProg:1; + ushort TranCfg:1; + ushort Diag:1; + ushort TranOutBandData:1; + ushort Tunnel:1; + ushort TranFirmware:1; + ushort TranBlink:1; + + +}stPortAbility; + +enum enServiceReqs +{ + ReqNone, + ReqInit, + ReqReset, + ReqStop, + ReqRun, + ReqBlink, + ReqStartDiag, + ReqStopDiag, + ReqTransFirmware, + ReqTransCfg, + ReqTransProg, + ReqTransData, + ReqTransBlink, + ReqTransChild, + ReqTransInfo, + ReqTransOutBandData, + ReqRead1Bit, + ReqWrite1Bit, + ReqReadBits, + ReqWriteBits, + ReqReadData, + ReqWriteData, + ReqRemoteTran, + +}; + +// 鍚勭鍙� 浜掕仈 閫氫俊 +typedef int (*CommFunc)(int n , void *, int len1); +typedef struct tagPortReg +{ + ushort nType; + ushort nVer; + // func1 GetInfo; + // func2 CommReq; + ushort ability; //鑳藉姏, 鑾峰彇瀛愭満淇℃伅绛夈�� + +}stPortReg; + +typedef struct tagInterComm +{ + int nId; + + +}stInterComm; + + extern stKMem KMem; extern const stKMInfoBlock KMInfoBlock; extern const stStoredKMSysCfg KMDefaultSysCfg; @@ -518,8 +591,8 @@ int KMachineInit(void); int ReadFlashMem(void * pBuf, void * pAddrFlash, int nByteSize); -int WriteToFlashMemNoErase(void * pBuf, void * pAddrFlash, unsigned int nByteSize); int EraseAndWriteToFlashMem(void * pBuf, void * pAddrFlash, unsigned int nByteSize); +int WriteToFlashMemNoErase(void * pBuf, void * pAddrFlash, unsigned int nByteSize); int ReadFactoryData(void * pDatabuf, int nByteCount); int WriteFactoryData(void * pDataBuf, int nByteCount); @@ -537,10 +610,15 @@ int LoadRunStat(pRunStat theRunStat); int SaveRunStat(pRunStat theRunStat); +int WriteNewApp(int nProgByteAddr, void *pBuf, int nByteSize); +int WriteNewAppInfo(int nProgByteAddr, void *pBuf, int nByteSize); unsigned char GetCoilValue(unsigned char nCoilType, unsigned short nCoilAddr); int SetCoilValue(unsigned char nCoilType, unsigned short nCoilAddr, unsigned char nCoilValue); int GetVarData(int nDataType, int nDataAddr); int SetVarData(int nDataType, int nDataAddr, int nDataValue); -#endif /* __KLPROTOCOL_H__ */ +typedef int (*KMSvCBDef) (int nChn, int nSvType, int ,void *, int); //Service Req callback func ,param is int ,int, int, void *,int; return int; + + +#endif /* __KMACHINE_H__ */ -- Gitblit v1.9.1