CommDef.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * CommDef.h
  3. *
  4. * Created on: 2016-2-15
  5. * Author: guoxs
  6. */
  7. #ifndef _UART_COMMDEF_H_
  8. #define _UART_COMMDEF_H_
  9. #include <stdint.h>
  10. #ifndef BYTE
  11. typedef unsigned char BYTE;
  12. #endif
  13. #ifndef UINT
  14. typedef unsigned int UINT;
  15. #endif
  16. #ifndef UINT16
  17. typedef unsigned short UINT16;
  18. #endif
  19. #ifndef MAKEWORD
  20. #define MAKEWORD(low, high) (((BYTE)(low)) | (((BYTE)(high)) << 8))
  21. #endif
  22. #ifndef LOBYTE
  23. #define LOBYTE(l) ((BYTE)(l))
  24. #endif
  25. #ifndef HIBYTE
  26. #define HIBYTE(l) ((BYTE)(l >> 8))
  27. #endif
  28. #ifndef TABLESIZE
  29. #define TABLESIZE(table) (sizeof(table)/sizeof(table[0]))
  30. #endif
  31. #define UART_TTYS0 0
  32. #define UART_TTYS1 1
  33. #define UART_TTYS2 2
  34. #define UART_TTYS3 3
  35. // 需要打印协议数据时,打开以下宏
  36. //When you need to print the protocol data, open the following macro
  37. //#define DEBUG_PRO_DATA
  38. // 支持checksum校验,打开以下宏
  39. //Support checksum verification, open the following macro
  40. //#define PRO_SUPPORT_CHECK_SUM
  41. // SynchFrame CmdID DataLen Data CheckSum (可选)
  42. // SynchFrame CmdID DataLen Data CheckSum (optional)
  43. /* 2Byte 2Byte 1Byte N Byte 1Byte */
  44. // Minimum length with CheckSum: 2 + 2 + 1 + 1 = 6
  45. // 有CheckSum情况下最小长度: 2 + 2 + 1 + 1 = 6
  46. // Minimum length without CheckSum: 2 + 2 + 1 = 5
  47. // 无CheckSum情况下最小长度: 2 + 2 + 1 = 5
  48. #ifdef PRO_SUPPORT_CHECK_SUM
  49. #define DATA_PACKAGE_MIN_LEN 6
  50. #else
  51. #define DATA_PACKAGE_MIN_LEN 9 //最少9位
  52. #endif
  53. // 同步帧头
  54. // Sync frame header
  55. #define CMD_HEAD 0x24
  56. #define CMD_END1 0X23
  57. #define CMD_END2 0x00
  58. #endif /* _UART_COMMDEF_H_ */