| | |
| | | #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; |
| | |
| | | |
| | | }stFactoryData,* pFactoryData; |
| | | |
| | | typedef struct tagNewAppInfoBlock |
| | | { |
| | | unsigned short Sign; |
| | | unsigned short Version; |
| | | unsigned int Length; |
| | | unsigned int nCRC; |
| | | |
| | | }stNewAppInfoBlock,*pNewAppInfoBlock; |
| | | |
| | | enum enStoreCfg |
| | | { |
| | |
| | | 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, |
| | | }; |
| | | |
| | |
| | | }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; |
| | |
| | | |
| | | 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); |
| | |
| | | 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__ */ |