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