usbcdc_defs.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #ifndef USB_DEFS_H
  2. #define USB_DEFS_H
  3. #define PTR16(x) ((unsigned int)(((unsigned long)x) & 0xFFFF))
  4. // Size of the buffer for endpoint 0
  5. #define E0SZ 16
  6. //
  7. //////////////CDC/////////
  8. /* CDC */
  9. #define CDC_COMM_INTF_ID 0x00
  10. #define CDC_COMM_UEP UEP2
  11. #define CDC_INT_BD_IN ep2Bi
  12. #define CDC_INT_EP_SIZE 8
  13. #define CDC_DATA_INTF_ID 0x01
  14. #define CDC_DATA_UEP UEP3
  15. #define CDC_BULK_BD_OUT ep3Bo
  16. #define CDC_BULK_OUT_EP_SIZE 8
  17. #define CDC_BULK_BD_IN ep3Bi
  18. #define CDC_BULK_IN_EP_SIZE 8
  19. /** D E F I N I T I O N S ****************************************************/
  20. /* Class-Specific Requests */
  21. #define SEND_ENCAPSULATED_COMMAND 0x00
  22. #define GET_ENCAPSULATED_RESPONSE 0x01
  23. #define SET_COMM_FEATURE 0x02
  24. #define GET_COMM_FEATURE 0x03
  25. #define CLEAR_COMM_FEATURE 0x04
  26. #define SET_LINE_CODING 0x20
  27. #define GET_LINE_CODING 0x21
  28. #define SET_CONTROL_LINE_STATE 0x22
  29. #define SEND_BREAK 0x23
  30. /* Notifications *
  31. * Note: Notifications are polled over
  32. * Communication Interface (Interrupt Endpoint)
  33. */
  34. #define NETWORK_CONNECTION 0x00
  35. #define RESPONSE_AVAILABLE 0x01
  36. #define SERIAL_STATE 0x20
  37. /* Device Class Code */
  38. #define CDC_DEVICE 0x02
  39. /* Communication Interface Class Code */
  40. #define COMM_INTF 0x02
  41. /* Communication Interface Class SubClass Codes */
  42. #define ABSTRACT_CONTROL_MODEL 0x02
  43. /* Communication Interface Class Control Protocol Codes */
  44. #define V25TER 0x01 // Common AT commands ("Hayes(TM)")
  45. /* Data Interface Class Codes */
  46. #define DATA_INTF 0x0A
  47. /* Data Interface Class Protocol Codes */
  48. #define NO_PROTOCOL 0x00 // No class specific protocol required
  49. /* Communication Feature Selector Codes */
  50. #define ABSTRACT_STATE 0x01
  51. #define COUNTRY_SETTING 0x02
  52. /* Functional Descriptors */
  53. /* Type Values for the bDscType Field */
  54. #define CS_INTERFACE 0x24
  55. #define CS_ENDPOINT 0x25
  56. /* bDscSubType in Functional Descriptors */
  57. #define DSC_FN_HEADER 0x00
  58. #define DSC_FN_CALL_MGT 0x01
  59. #define DSC_FN_ACM 0x02 // ACM - Abstract Control Management
  60. #define DSC_FN_DLM 0x03 // DLM - Direct Line Managment
  61. #define DSC_FN_TELEPHONE_RINGER 0x04
  62. #define DSC_FN_RPT_CAPABILITIES 0x05
  63. #define DSC_FN_UNION 0x06
  64. #define DSC_FN_COUNTRY_SELECTION 0x07
  65. #define DSC_FN_TEL_OP_MODES 0x08
  66. #define DSC_FN_USB_TERMINAL 0x09
  67. /* more.... see Table 25 in USB CDC Specification 1.1 */
  68. /* CDC Bulk IN transfer states */
  69. #define CDC_TX_READY 0
  70. #define CDC_TX_BUSY 1
  71. #define CDC_TX_BUSY_ZLP 2 // ZLP: Zero Length Packet
  72. #define CDC_TX_COMPLETING 3
  73. /** S T R U C T U R E S ******************************************************/
  74. /* Line Coding Structure */
  75. #define LINE_CODING_LENGTH 0x07
  76. /* Functional Descriptor Structure - See CDC Specification 1.1 for details */
  77. /* Header Functional Descriptor */
  78. typedef struct _USB_CDC_HEADER_FN_DSC
  79. {
  80. unsigned char bFNLength;
  81. unsigned char bDscType;
  82. unsigned char bDscSubType;
  83. unsigned short bcdCDC;
  84. } USB_CDC_HEADER_FN_DSC;
  85. /* Abstract Control Management Functional Descriptor */
  86. typedef struct _USB_CDC_ACM_FN_DSC
  87. {
  88. unsigned char bFNLength;
  89. unsigned char bDscType;
  90. unsigned char bDscSubType;
  91. unsigned char bmCapabilities;
  92. } USB_CDC_ACM_FN_DSC;
  93. /* Union Functional Descriptor */
  94. typedef struct _USB_CDC_UNION_FN_DSC
  95. {
  96. unsigned char bFNLength;
  97. unsigned char bDscType;
  98. unsigned char bDscSubType;
  99. unsigned char bMasterIntf;
  100. unsigned char bSaveIntf0;
  101. } USB_CDC_UNION_FN_DSC;
  102. /* Call Management Functional Descriptor */
  103. typedef struct _USB_CDC_CALL_MGT_FN_DSC
  104. {
  105. unsigned char bFNLength;
  106. unsigned char bDscType;
  107. unsigned char bDscSubType;
  108. unsigned char bmCapabilities;
  109. unsigned char bDataInterface;
  110. } USB_CDC_CALL_MGT_FN_DSC;
  111. #endif