| | |
| | | typedef unsigned short WORD;
|
| | | typedef unsigned char BYTE;
|
| | |
|
| | | #define LoBofW(x) ((x)&0xff)
|
| | | #define HiBofW(x) (((x)>>8)&0xff)
|
| | |
|
| | | #define LoHofB(x) ((x)&0xf)
|
| | | #define HiHofB(x) (((x)>>4)&0xf)
|
| | |
|
| | | enum enStoreCfg
|
| | | {
|
| | | START_SIGN = 0x55aa,
|
| | |
| | | PortType_KNet = 4, // KNetͨѶ
|
| | | PortType_ModbusRTU = 5, //Modbus RTU ͨѶ
|
| | | };
|
| | |
|
| | | //每个模块有 0/1/2/3/4/5/6/7/8个 通讯port
|
| | | //不限于 UART, 网口,无线,单总线等,都是port
|
| | | //甚至可以有虚拟的port
|
| | |
|
| | | typedef struct tagPortStat
|
| | | {
|
| | | UCHAR nWorking; //工作中
|
| | | UCHAR nStation; //自己站号
|
| | | UCHAR bBus; //总线?,,全双工?
|
| | | UCHAR bMaster; //主机
|
| | | UCHAR PortType; //端口工作模式
|
| | | UCHAR nDevices; //连接的设备数量//不包括自己 //device list;
|
| | | |
| | | }stPortStat,*pPortStat;
|
| | |
|
| | | enum enKeventType
|
| | | {
|
| | |
| | | unsigned char CurVAL;
|
| | | stTimer Timers[TOTALTIMERS];
|
| | |
|
| | | union {
|
| | | unsigned short WX[KLDataWXCount]; //本机的X和Y
|
| | | unsigned char WXB[KLDataWXCount*2]; |
| | | };
|
| | | union {
|
| | | unsigned short WY[KLDataWYCount]; //本机的X和Y
|
| | | unsigned char WYB[KLDataWYCount*2]; //本机的X和Y
|
| | | }; |
| | | unsigned short WR[KLDataWRCount];
|
| | |
|
| | | unsigned short WT[16];
|
| | |
| | | unsigned short WLR[16];
|
| | | unsigned short WSR[16];
|
| | |
|
| | | union {
|
| | | unsigned int DTD[KLDataDTCount];
|
| | | unsigned short DT[KLDataDTCount];
|
| | | |
| | | unsigned char DTB[KLDataDTCount*2];
|
| | | }; |
| | | // 配置寄存器
|
| | | // 系统状态寄存器
|
| | | // 特殊寄存器
|
| | |
| | | extern stKMem KMem;
|
| | | extern const stKMInfoBlock KMInfoBlock;
|
| | |
|
| | | extern volatile int PowerDownEvent;
|
| | | extern volatile int OldPowerDownEvent;
|
| | | extern volatile int OldPowerDownEventTime;
|
| | |
|
| | | int KMachineInit(void);
|
| | | int ReadFlashMem(void * pBuf, void * pAddrFlash, int nByteSize);
|
| | | int WriteToFlashMemNoErase(void * pBuf, void * pAddrFlash, unsigned int nByteSize);
|