/* * CommDef.h * * Created on: 2016-2-15 * Author: guoxs */ #ifndef _UART_COMMDEF_H_ #define _UART_COMMDEF_H_ #include #ifndef BYTE typedef unsigned char BYTE; #endif #ifndef UINT typedef unsigned int UINT; #endif #ifndef UINT16 typedef unsigned short UINT16; #endif #ifndef MAKEWORD #define MAKEWORD(low, high) (((BYTE)(low)) | (((BYTE)(high)) << 8)) #endif #ifndef LOBYTE #define LOBYTE(l) ((BYTE)(l)) #endif #ifndef HIBYTE #define HIBYTE(l) ((BYTE)(l >> 8)) #endif #ifndef TABLESIZE #define TABLESIZE(table) (sizeof(table)/sizeof(table[0])) #endif #define UART_TTYS0 0 #define UART_TTYS1 1 #define UART_TTYS2 2 #define UART_TTYS3 3 // 需要打印协议数据时,打开以下宏 //When you need to print the protocol data, open the following macro //#define DEBUG_PRO_DATA // 支持checksum校验,打开以下宏 //Support checksum verification, open the following macro //#define PRO_SUPPORT_CHECK_SUM // SynchFrame CmdID DataLen Data CheckSum (可选) // SynchFrame CmdID DataLen Data CheckSum (optional) /* 2Byte 2Byte 1Byte N Byte 1Byte */ // Minimum length with CheckSum: 2 + 2 + 1 + 1 = 6 // 有CheckSum情况下最小长度: 2 + 2 + 1 + 1 = 6 // Minimum length without CheckSum: 2 + 2 + 1 = 5 // 无CheckSum情况下最小长度: 2 + 2 + 1 = 5 #ifdef PRO_SUPPORT_CHECK_SUM #define DATA_PACKAGE_MIN_LEN 6 #else #define DATA_PACKAGE_MIN_LEN 9 //最少9位 #endif // 同步帧头 // Sync frame header #define CMD_HEAD 0x24 #define CMD_END1 0X23 #define CMD_END2 0x00 #endif /* _UART_COMMDEF_H_ */