1 #ifndef USB_CDC_H 2 #define USB_CDC_H 3 4 // (Partial) USB Class Definitions for Communication Devices (CDC), version 1.1 5 // Reference: http://www.usb.org/developers/devclass_docs/usbcdc11.pdf 6 7 #define USB_COMMUNICATION_DEVICE_CLASS 0x02 8 9 #define USB_CDC_COMMUNICATION_INTERFACE_CLASS 0x02 10 #define USB_CDC_CLASS_VERSION 0x0101 11 12 enum { // Communication Interface Subclasses 13 USB_CDC_COMMUNICATION_INTERFACE_DLCM_SUBCLASS = 0x01, // Direct Line Control Model 14 USB_CDC_COMMUNICATION_INTERFACE_ACM_SUBCLASS, // Abstract Control Model 15 USB_CDC_COMMUNICATION_INTERFACE_TCM_SUBCLASS, // Telephone Control Model 16 USB_CDC_COMMUNICATION_INTERFACE_MCCM_SUBCLASS, // Multi-Channel Control Model 17 USB_CDC_COMMUNICATION_INTERFACE_CAPICM_SUBCLASS, // CAPI Control Model 18 USB_CDC_COMMUNICATION_INTERFACE_ENCM_SUBCLASS, // Ethernet Networking Control Model 19 USB_CDC_COMMUNICATION_INTERFACE_ATMNCM_SUBCLASS // ATM Networking Control Model 20 }; 21 22 enum { // Communication Interface Class Control Protocols 23 USB_CDC_COMMUNICATION_INTERFACE_NONE_PROTOCOL = 0x00, // No class specific protocol required 24 USB_CDC_COMMUNICATION_INTERFACE_V25TER_PROTOCOL = 0x01, // Common AT commands (also knowns as "Hayes compatible") 25 USB_CDC_COMMUNICATION_INTERFACE_SPECIFIC_PROTOCOL = 0xff // Vendor-specific protocol 26 }; 27 28 29 #define USB_CDC_DATA_INTERFACE_CLASS 0x0a 30 31 // Functional Descriptors (p32) 32 33 enum { // Functional Descriptors Subtypes 34 USB_CDC_HEADER_FUNCTIONAL_DESCRIPTOR = 0x00, 35 USB_CDC_CM_FUNCTIONAL_DESCRIPTOR, 36 USB_CDC_ACM_FUNCTIONAL_DESCRIPTOR, 37 USB_CDC_UNION_FUNCTIONAL_DESCRIPTOR = 0x06 38 }; 39 40 typedef struct usb_cdc_header_function_descriptor { 41 uint8 length; 42 uint8 descriptor_type; 43 uint8 descriptor_subtype; // USB_CDC_HEADER_FUNCTIONAL_DESCRIPTOR 44 uint16 cdc_version; 45 } _PACKED usb_cdc_header_function_descriptor; 46 47 typedef struct usb_cdc_cm_functional_descriptor { 48 uint8 length; 49 uint8 descriptor_type; 50 uint8 descriptor_subtype; // USB_CDC_CM_FUNCTIONAL_DESCRIPTOR 51 uint8 capabilities; 52 uint8 data_interface; 53 } _PACKED usb_cdc_cm_functional_descriptor; 54 55 enum { // Call Management Functional Descriptor capabilities bitmap 56 USB_CDC_CM_DOES_CALL_MANAGEMENT = 0x01, 57 USB_CDC_CM_OVER_DATA_INTERFACE = 0x02 58 }; 59 60 typedef struct usb_cdc_acm_functional_descriptor { 61 uint8 length; 62 uint8 descriptor_type; 63 uint8 descriptor_subtype; // USB_CDC_ACM_FUNCTIONAL_DESCRIPTOR 64 uint8 capabilities; 65 } _PACKED usb_cdc_acm_functional_descriptor; 66 67 enum { // Abstract Control Model Functional Descriptor capabilities bitmap (p36) 68 USB_CDC_ACM_HAS_COMM_FEATURES = 0x01, 69 USB_CDC_ACM_HAS_LINE_CONTROL = 0x02, 70 USB_CDC_ACM_HAS_SEND_BREAK = 0x04, 71 USB_CDC_ACM_HAS_NETWORK_CONNECTION = 0x08 72 }; 73 74 typedef struct usb_cdc_union_functional_descriptor { 75 uint8 length; 76 uint8 descriptor_type; 77 uint8 descriptor_subtype; // USB_CDC_UNION_FUNCTIONAL_DESCRIPTOR 78 uint8 master_interface; 79 uint8 slave_interfaces[1]; 80 } _PACKED usb_cdc_union_functional_descriptor; 81 82 83 enum { // Management Element Requests (p62) 84 USB_CDC_SEND_ENCAPSULATED_COMMAND = 0x00, 85 USB_CDC_GET_ENCAPSULATED_RESPONSE, 86 USB_CDC_SET_COMM_FEATURE, 87 USB_CDC_GET_COMM_FEATURE, 88 USB_CDC_CLEAR_COMM_FEATURE, 89 // 0x05 -> 0x0F: reserved for future use 90 USB_CDC_SET_AUX_LINE_STATE = 0x10, 91 USB_CDC_SET_HOOK_STATE, 92 USB_CDC_PULSE_SETUP, 93 USB_CDC_SEND_PULSE, 94 USB_CDC_SET_PULSE_TIME, 95 USB_CDC_RING_AUX_JACK, 96 // 0x16 -> 0x1F: reserved for future use 97 USB_CDC_SET_LINE_CODING = 0x20, 98 USB_CDC_GET_LINE_CODING, 99 USB_CDC_SET_CONTROL_LINE_STATE, 100 USB_CDC_SEND_BREAK, 101 // 0x24 -> 0x2F: reserved for future use 102 USB_CDC_SET_RINGER_PARMS = 0x30, 103 USB_CDC_GET_RINGER_PARMS, 104 USB_CDC_SET_OPERATION_PARMS, 105 USB_CDC_GET_OPERATION_PARMS, 106 USB_CDC_SET_LINE_PARMS, 107 USB_CDC_GET_LINE_PARMS, 108 USB_CDC_DIAL_DIGITS, 109 USB_CDC_SET_UNIT_PARAMETER, 110 USB_CDC_GET_UNIT_PARAMETER, 111 USB_CDC_CLEAR_UNIT_PARAMETER, 112 USB_CDC_GET_PROFILE, 113 // 0x3B -> 0x3F: reserved for future use 114 USB_CDC_SET_ETHERNET_MULTICAST_FILTERS = 0x40, 115 USB_CDC_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER, 116 USB_CDC_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER, 117 USB_CDC_SET_ETHERNET_PACKET_FILTER, 118 USB_CDC_GET_ETHERNET_STATISTIC, 119 // 0x45 -> 0x4F: reserved for future use 120 USB_CDC_SET_ATM_DATA_FORMAT = 0x50, 121 USB_CDC_GET_ATM_DEVICE_STATISTICS, 122 USB_CDC_SET_ATM_DEFAULT_VC, 123 USB_CDC_GET_ATM_VC_STATISTICS 124 // 0x54 -> 0xFF: reserved for future use 125 }; 126 127 enum { // Feature Selector (for USB_CDC_SET/GET/CLEAR_COMM_FEATURE (p65-66)) 128 USB_CDC_ABSTRACT_STATE = 0x01, 129 USB_CDC_COUNTRY_SETTING = 0x02 130 }; 131 132 enum { // ABSTRACT_STATE bitmap (for USB_CDC_ABSTRAT_STATE Feature Selector (p66)) 133 USB_CDC_ABSTRACT_STATE_IDLE = 0x01, 134 USB_CDC_ABSTRACT_STATE_DATA_MULTIPLEXED = 0x02 135 }; 136 137 typedef struct { // Line Coding Structure (for USB_CDC_SET/GET_LINE_CODING (p69)) 138 uint32 speed; 139 uint8 stopbits; 140 uint8 parity; 141 uint8 databits; 142 } _PACKED usb_cdc_line_coding; 143 144 enum { // CDC stopbits values (for Line Coding Structure stopbits field) 145 USB_CDC_LINE_CODING_1_STOPBIT = 0, 146 USB_CDC_LINE_CODING_1_5_STOPBITS, 147 USB_CDC_LINE_CODING_2_STOPBITS 148 }; 149 150 enum { // CDC parity values (for Line Coding Structure parity field) 151 USB_CDC_LINE_CODING_NO_PARITY = 0, 152 USB_CDC_LINE_CODING_ODD_PARITY, 153 USB_CDC_LINE_CODING_EVEN_PARITY, 154 USB_CDC_LINE_CODING_MARK_PARITY, 155 USB_CDC_LINE_CODING_SPACE_PARITY 156 }; 157 158 enum { // CDC Control Signal bitmap (for CDC_SET_CONTROL_LINE_STATE request) 159 USB_CDC_CONTROL_SIGNAL_STATE_DTR = 0x01, 160 USB_CDC_CONTROL_SIGNAL_STATE_RTS = 0x02 161 }; 162 163 enum { // Notification Elements notifications (p84) 164 USB_CDC_NETWORK_CONNECTION = 0x00, 165 USB_CDC_RESPONSE_AVAILABLE, 166 // 0x02 -> 0x07: reserved for future use 167 USB_CDC_AUX_JACK_HOOK_STATE = 0x08, 168 USB_CDC_RING_DETECT, 169 // 0x0a -> 0x1f: reserved for future use 170 USB_CDC_SERIAL_STATE = 0x20, 171 // 0x21 -> 0x27: reserved for future use 172 USB_CDC_CALL_STATE_CHANGE = 0x28, 173 USB_CDC_LINE_STATE_CHANGE, 174 USB_CDC_CONNECTION_SPEED_CHANGE 175 // 0x2b -> 0xff: reserved for future use 176 }; 177 178 enum { // CDC UART State bitmap (for USB_CDC_SERIAL_STATE notification) 179 USB_CDC_UART_STATE_DCD = 0x01, 180 USB_CDC_UART_STATE_DSR = 0x02, 181 USB_CDC_UART_STATE_BREAK = 0x04, 182 USB_CDC_UART_STATE_RING = 0x08, 183 USB_CDC_UART_STATE_FRAMING_ERROR = 0x10, 184 USB_CDC_UART_STATE_PARITY_ERROR = 0x20, 185 USB_CDC_UART_STATE_OVERRUN_ERROR = 0x40 186 }; 187 188 #endif // USB_CDC_H 189 190