Arrow / Mbed OS DAPLink Reset
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers usb_cdc.h Source File

usb_cdc.h

Go to the documentation of this file.
00001 /**
00002  * @file    usb_cdc.h
00003  * @brief   USB CDC driver header
00004  *
00005  * DAPLink Interface Firmware
00006  * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
00007  * SPDX-License-Identifier: Apache-2.0
00008  *
00009  * Licensed under the Apache License, Version 2.0 (the "License"); you may
00010  * not use this file except in compliance with the License.
00011  * You may obtain a copy of the License at
00012  *
00013  * http://www.apache.org/licenses/LICENSE-2.0
00014  *
00015  * Unless required by applicable law or agreed to in writing, software
00016  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00017  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00018  * See the License for the specific language governing permissions and
00019  * limitations under the License.
00020  */
00021 
00022 #ifndef __USB_CDC_H
00023 #define __USB_CDC_H
00024 
00025 /*------------------------------------------------------------------------------
00026  *      Definitions  based on usbcdc11.pdf (www.usb.org)
00027  *----------------------------------------------------------------------------*/
00028 /* Communication device class specification version 1.10 */
00029 #define CDC_V1_10                               0x0110
00030 
00031 /* Communication interface class code */
00032 /* (usbcdc11.pdf, 4.2, Table 15) */
00033 #define CDC_COMMUNICATION_INTERFACE_CLASS       0x02
00034 
00035 /* Communication interface class subclass codes */
00036 /* (usbcdc11.pdf, 4.3, Table 16) */
00037 #define CDC_DIRECT_LINE_CONTROL_MODEL           0x01
00038 #define CDC_ABSTRACT_CONTROL_MODEL              0x02
00039 #define CDC_TELEPHONE_CONTROL_MODEL             0x03
00040 #define CDC_MULTI_CHANNEL_CONTROL_MODEL         0x04
00041 #define CDC_CAPI_CONTROL_MODEL                  0x05
00042 #define CDC_ETHERNET_NETWORKING_CONTROL_MODEL   0x06
00043 #define CDC_ATM_NETWORKING_CONTROL_MODEL        0x07
00044 
00045 /* Communication interface class control protocol codes */
00046 /* (usbcdc11.pdf, 4.4, Table 17) */
00047 #define CDC_PROTOCOL_COMMON_AT_COMMANDS         0x01
00048 
00049 /* Data interface class code */
00050 /* (usbcdc11.pdf, 4.5, Table 18) */
00051 #define CDC_DATA_INTERFACE_CLASS                0x0A
00052 
00053 /* Data interface class protocol codes */
00054 /* (usbcdc11.pdf, 4.7, Table 19) */
00055 #define CDC_PROTOCOL_ISDN_BRI                   0x30
00056 #define CDC_PROTOCOL_HDLC                       0x31
00057 #define CDC_PROTOCOL_TRANSPARENT                0x32
00058 #define CDC_PROTOCOL_Q921_MANAGEMENT            0x50
00059 #define CDC_PROTOCOL_Q921_DATA_LINK             0x51
00060 #define CDC_PROTOCOL_Q921_MULTIPLEXOR           0x52
00061 #define CDC_PROTOCOL_V42                        0x90
00062 #define CDC_PROTOCOL_EURO_ISDN                  0x91
00063 #define CDC_PROTOCOL_V24_RATE_ADAPTATION        0x92
00064 #define CDC_PROTOCOL_CAPI                       0x93
00065 #define CDC_PROTOCOL_HOST_BASED_DRIVER          0xFD
00066 #define CDC_PROTOCOL_DESCRIBED_IN_PUFD          0xFE
00067 
00068 /* Type values for bDescriptorType field of functional descriptors */
00069 /* (usbcdc11.pdf, 5.2.3, Table 24) */
00070 #define CDC_CS_INTERFACE                        0x24
00071 #define CDC_CS_ENDPOINT                         0x25
00072 
00073 /* Type values for bDescriptorSubtype field of functional descriptors */
00074 /* (usbcdc11.pdf, 5.2.3, Table 25) */
00075 #define CDC_HEADER                              0x00
00076 #define CDC_CALL_MANAGEMENT                     0x01
00077 #define CDC_ABSTRACT_CONTROL_MANAGEMENT         0x02
00078 #define CDC_DIRECT_LINE_MANAGEMENT              0x03
00079 #define CDC_TELEPHONE_RINGER                    0x04
00080 #define CDC_REPORTING_CAPABILITIES              0x05
00081 #define CDC_UNION                               0x06
00082 #define CDC_COUNTRY_SELECTION                   0x07
00083 #define CDC_TELEPHONE_OPERATIONAL_MODES         0x08
00084 #define CDC_USB_TERMINAL                        0x09
00085 #define CDC_NETWORK_CHANNEL                     0x0A
00086 #define CDC_PROTOCOL_UNIT                       0x0B
00087 #define CDC_EXTENSION_UNIT                      0x0C
00088 #define CDC_MULTI_CHANNEL_MANAGEMENT            0x0D
00089 #define CDC_CAPI_CONTROL_MANAGEMENT             0x0E
00090 #define CDC_ETHERNET_NETWORKING                 0x0F
00091 #define CDC_ATM_NETWORKING                      0x10
00092 
00093 /* CDC class-specific request codes */
00094 /* (usbcdc11.pdf, 6.2, Table 46) */
00095 /* see Table 45 for info about the specific requests. */
00096 #define CDC_SEND_ENCAPSULATED_COMMAND           0x00
00097 #define CDC_GET_ENCAPSULATED_RESPONSE           0x01
00098 #define CDC_SET_COMM_FEATURE                    0x02
00099 #define CDC_GET_COMM_FEATURE                    0x03
00100 #define CDC_CLEAR_COMM_FEATURE                  0x04
00101 #define CDC_SET_AUX_LINE_STATE                  0x10
00102 #define CDC_SET_HOOK_STATE                      0x11
00103 #define CDC_PULSE_SETUP                         0x12
00104 #define CDC_SEND_PULSE                          0x13
00105 #define CDC_SET_PULSE_TIME                      0x14
00106 #define CDC_RING_AUX_JACK                       0x15
00107 #define CDC_SET_LINE_CODING                     0x20
00108 #define CDC_GET_LINE_CODING                     0x21
00109 #define CDC_SET_CONTROL_LINE_STATE              0x22
00110 #define CDC_SEND_BREAK                          0x23
00111 #define CDC_SET_RINGER_PARMS                    0x30
00112 #define CDC_GET_RINGER_PARMS                    0x31
00113 #define CDC_SET_OPERATION_PARMS                 0x32
00114 #define CDC_GET_OPERATION_PARMS                 0x33
00115 #define CDC_SET_LINE_PARMS                      0x34
00116 #define CDC_GET_LINE_PARMS                      0x35
00117 #define CDC_DIAL_DIGITS                         0x36
00118 #define CDC_SET_UNIT_PARAMETER                  0x37
00119 #define CDC_GET_UNIT_PARAMETER                  0x38
00120 #define CDC_CLEAR_UNIT_PARAMETER                0x39
00121 #define CDC_GET_PROFILE                         0x3A
00122 #define CDC_SET_ETHERNET_MULTICAST_FILTERS      0x40
00123 #define CDC_SET_ETHERNET_PMP_FILTER             0x41
00124 #define CDC_GET_ETHERNET_PMP_FILTER             0x42
00125 #define CDC_SET_ETHERNET_PACKET_FILTER          0x43
00126 #define CDC_GET_ETHERNET_STATISTIC              0x44
00127 #define CDC_SET_ATM_DATA_FORMAT                 0x50
00128 #define CDC_GET_ATM_DEVICE_STATISTICS           0x51
00129 #define CDC_SET_ATM_DEFAULT_VC                  0x52
00130 #define CDC_GET_ATM_VC_STATISTICS               0x53
00131 
00132 /* Communication feature selector codes */
00133 /* (usbcdc11.pdf, 6.2.2..6.2.4, Table 47) */
00134 #define CDC_ABSTRACT_STATE                      0x01
00135 #define CDC_COUNTRY_SETTING                     0x02
00136 
00137 /* Feature Status returned for ABSTRACT_STATE Selector */
00138 /* (usbcdc11.pdf, 6.2.3, Table 48) */
00139 #define CDC_IDLE_SETTING                        (1 << 0)
00140 #define CDC_DATA_MULTPLEXED_STATE               (1 << 1)
00141 
00142 
00143 /* Control signal bitmap values for the SetControlLineState request */
00144 /* (usbcdc11.pdf, 6.2.14, Table 51) */
00145 #define CDC_DTE_PRESENT                         (1 << 0)
00146 #define CDC_ACTIVATE_CARRIER                    (1 << 1)
00147 
00148 /* CDC class-specific notification codes */
00149 /* (usbcdc11.pdf, 6.3, Table 68) */
00150 /* see Table 67 for Info about class-specific notifications */
00151 #define CDC_NOTIFICATION_NETWORK_CONNECTION     0x00
00152 #define CDC_RESPONSE_AVAILABLE                  0x01
00153 #define CDC_AUX_JACK_HOOK_STATE                 0x08
00154 #define CDC_RING_DETECT                         0x09
00155 #define CDC_NOTIFICATION_SERIAL_STATE           0x20
00156 #define CDC_CALL_STATE_CHANGE                   0x28
00157 #define CDC_LINE_STATE_CHANGE                   0x29
00158 #define CDC_CONNECTION_SPEED_CHANGE             0x2A
00159 
00160 /* UART state bitmap values (Serial state notification). */
00161 /* (usbcdc11.pdf, 6.3.5, Table 69) */
00162 #define CDC_SERIAL_STATE_OVERRUN                (1 << 6)  /* receive data overrun error has occurred */
00163 #define CDC_SERIAL_STATE_OVERRUN_Pos            (     6)
00164 #define CDC_SERIAL_STATE_OVERRUN_Msk            (1 << CDC_SERIAL_STATE_OVERRUN_Pos)
00165 #define CDC_SERIAL_STATE_PARITY                 (1 << 5)  /* parity error has occurred */
00166 #define CDC_SERIAL_STATE_PARITY_Pos             (     5)
00167 #define CDC_SERIAL_STATE_PARITY_Msk             (1 << CDC_SERIAL_STATE_PARITY_Pos)
00168 #define CDC_SERIAL_STATE_FRAMING                (1 << 4)  /* framing error has occurred */
00169 #define CDC_SERIAL_STATE_FRAMING_Pos            (     4)
00170 #define CDC_SERIAL_STATE_FRAMING_Msk            (1 << CDC_SERIAL_STATE_FRAMING_Pos)
00171 #define CDC_SERIAL_STATE_RING                   (1 << 3)  /* state of ring signal detection */
00172 #define CDC_SERIAL_STATE_RING_Pos               (     3)
00173 #define CDC_SERIAL_STATE_RING_Msk               (1 << CDC_SERIAL_STATE_RING_Pos)
00174 #define CDC_SERIAL_STATE_BREAK                  (1 << 2)  /* state of break detection */
00175 #define CDC_SERIAL_STATE_BREAK_Pos              (     2)
00176 #define CDC_SERIAL_STATE_BREAK_Msk              (1 << CDC_SERIAL_STATE_BREAK_Pos)
00177 #define CDC_SERIAL_STATE_TX_CARRIER             (1 << 1)  /* state of transmission carrier */
00178 #define CDC_SERIAL_STATE_TX_CARRIER_Pos         (     1)
00179 #define CDC_SERIAL_STATE_TX_CARRIER_Msk         (1 << CDC_SERIAL_STATE_TX_CARRIER_Pos)
00180 #define CDC_SERIAL_STATE_RX_CARRIER             (1 << 0)  /* state of receiver carrier */
00181 #define CDC_SERIAL_STATE_RX_CARRIER_Pos         (     0)
00182 #define CDC_SERIAL_STATE_RX_CARRIER_Msk         (1 << CDC_SERIAL_STATE_RX_CARRIER_Pos)
00183 
00184 
00185 /*------------------------------------------------------------------------------
00186  *      Structures  based on usbcdc11.pdf (www.usb.org)
00187  *----------------------------------------------------------------------------*/
00188 
00189 /* Header functional descriptor */
00190 /* (usbcdc11.pdf, 5.2.3.1) */
00191 /* This header must precede any list of class-specific descriptors. */
00192 typedef __packed struct _CDC_HEADER_DESCRIPTOR {
00193     U8  bFunctionLength;                      /* size of this descriptor in bytes */
00194     U8  bDescriptorType;                      /* CS_INTERFACE descriptor type */
00195     U8  bDescriptorSubtype;                   /* Header functional descriptor subtype */
00196     U16 bcdCDC;                               /* USB CDC specification release version */
00197 } CDC_HEADER_DESCRIPTOR;
00198 
00199 /* Call management functional descriptor */
00200 /* (usbcdc11.pdf, 5.2.3.2) */
00201 /* Describes the processing of calls for the communication class interface. */
00202 typedef __packed struct _CDC_CALL_MANAGEMENT_DESCRIPTOR {
00203     U8  bFunctionLength;                      /* size of this descriptor in bytes */
00204     U8  bDescriptorType;                      /* CS_INTERFACE descriptor type */
00205     U8  bDescriptorSubtype;                   /* call management functional descriptor subtype */
00206     U8  bmCapabilities;                       /* capabilities that this configuration supports */
00207     U8  bDataInterface;                       /* interface number of the data class interface used for call management (optional) */
00208 } CDC_CALL_MANAGEMENT_DESCRIPTOR;
00209 
00210 /* Abstract control management functional descriptor */
00211 /* (usbcdc11.pdf, 5.2.3.3) */
00212 /* Describes the command supported by the communication interface class with the Abstract Control Model subclass code. */
00213 typedef __packed struct _CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR {
00214     U8  bFunctionLength;                      /* size of this descriptor in bytes */
00215     U8  bDescriptorType;                      /* CS_INTERFACE descriptor type */
00216     U8  bDescriptorSubtype;                   /* abstract control management functional descriptor subtype */
00217     U8  bmCapabilities;                       /* capabilities supported by this configuration */
00218 } CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR;
00219 
00220 /* Union functional descriptors */
00221 /* (usbcdc11.pdf, 5.2.3.8) */
00222 /* Describes the relationship between a group of interfaces that can be considered to form a functional unit. */
00223 typedef __packed struct _CDC_UNION_DESCRIPTOR {
00224     U8  bFunctionLength;                      /* size of this descriptor in bytes */
00225     U8  bDescriptorType;                      /* CS_INTERFACE descriptor type */
00226     U8  bDescriptorSubtype;                   /* union functional descriptor subtype */
00227     U8  bMasterInterface;                     /* interface number designated as master */
00228 } CDC_UNION_DESCRIPTOR;
00229 
00230 /* Union functional descriptors with one slave interface */
00231 /* (usbcdc11.pdf, 5.2.3.8) */
00232 typedef __packed struct _CDC_UNION_1SLAVE_DESCRIPTOR {
00233     CDC_UNION_DESCRIPTOR sUnion;              /* Union functional descriptor */
00234     U8                   bSlaveInterfaces[1]; /* Slave interface 0 */
00235 } CDC_UNION_1SLAVE_DESCRIPTOR;
00236 
00237 /* Line coding structure */
00238 /* Format of the data returned when a GetLineCoding request is received */
00239 /* (usbcdc11.pdf, 6.2.13) */
00240 typedef __packed struct _CDC_LINE_CODING {
00241     U32 dwDTERate;                            /* Data terminal rate in bits per second */
00242     U8  bCharFormat;                          /* Number of stop bits */
00243     U8  bParityType;                          /* Parity bit type */
00244     U8  bDataBits;                            /* Number of data bits */
00245 } CDC_LINE_CODING;
00246 
00247 /* Notification header */
00248 /* Data sent on the notification endpoint must follow this header. */
00249 /* see  USB_SETUP_PACKET in file usb.h */
00250 typedef USB_SETUP_PACKET CDC_NOTIFICATION_HEADER;
00251 
00252 #endif /* __USB_CDC_H */
00253