00001
00002
00003
00004
00005 #ifndef USB_DESCRIPTORS_H
00006 #define USB_DESCRIPTORS_H
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 typedef struct {
00019 BYTE bLength;
00020 BYTE bDescriptorType;
00021 UINT bcdUSB;
00022 BYTE bDeviceClass;
00023 BYTE bDeviceSubClass;
00024 BYTE bDeviceProtocol;
00025 BYTE bMaxPacketSize0;
00026 UINT idVendor;
00027 UINT idProduct;
00028 UINT bcdDevice;
00029 BYTE iManufacturer;
00030 BYTE iProduct;
00031 BYTE iSerialNumber;
00032 BYTE bNumConfigurations;
00033 } Tdevice_descriptor;
00034
00035
00036
00037
00038 typedef struct {
00039 BYTE bLength;
00040 BYTE bDescriptorType;
00041 UINT wTotalLength;
00042 BYTE bNumInterfaces;
00043 BYTE bConfigurationValue;
00044 BYTE iConfiguration;
00045 BYTE bmAttributes;
00046 BYTE bMaxPower;
00047 } Tconfiguration_descriptor;
00048
00049
00050
00051
00052 typedef struct {
00053 BYTE bLength;
00054 BYTE bDescriptorType;
00055 BYTE bInterfaceNumber;
00056 BYTE bAlternateSetting;
00057 BYTE bNumEndpoints;
00058 BYTE bInterfaceClass;
00059 BYTE bInterfaceSubClass;
00060 BYTE bInterfaceProtocol;
00061 BYTE iInterface;
00062 } Tinterface_descriptor;
00063
00064
00065
00066
00067 typedef struct {
00068 BYTE bLength;
00069 BYTE bDescriptorType;
00070 BYTE bEndpointAddress;
00071 BYTE bmAttributes;
00072 UINT wMaxPacketSize;
00073 BYTE bInterval;
00074 } Tendpoint_descriptor;
00075
00076
00077
00078
00079 typedef struct {
00080 BYTE bLength;
00081 BYTE bDescriptorType;
00082 BYTE bFirstInterface;
00083 BYTE bInterfaceCount;
00084 BYTE bFunctionClass;
00085 BYTE bFunctionSubClass;
00086 BYTE bFunctionProcotol;
00087 BYTE iInterface;
00088 } Tinterface_association_descriptor;
00089
00090
00091
00092
00093
00094
00095
00096 typedef struct {
00097 BYTE bLength;
00098 BYTE bDescriptorType;
00099 BYTE bDescriptorSubtype;
00100 UINT bcdCDC;
00101 } Theader_func_descriptor;
00102
00103
00104
00105
00106 typedef struct {
00107 BYTE bLength;
00108 BYTE bDescriptorType;
00109 BYTE bDescriptorSubtype;
00110 BYTE bmCapabilities;
00111 BYTE bDataInterface;
00112 } Tcall_man_func_descriptor;
00113
00114
00115
00116
00117 typedef struct {
00118 BYTE bLength;
00119 BYTE bDescriptorType;
00120 BYTE bDescriptorSubtype;
00121 BYTE bmCapabilities;
00122 } Tabst_control_mana_descriptor;
00123
00124
00125
00126
00127 typedef struct {
00128 BYTE bLength;
00129 BYTE bDescriptorType;
00130 BYTE bDescriptorSubtype;
00131 BYTE bMasterInterface;
00132 BYTE bSlaveInterface0;
00133 } Tunion_func_descriptor;
00134
00135
00136
00137
00138
00139
00140
00141
00142 typedef struct {
00143 BYTE bLength;
00144 BYTE bDescriptorType;
00145 UINT bcdHID;
00146 BYTE bCountryCode;
00147 BYTE bNumDescriptors;
00148 BYTE bReportDescriptorType;
00149 UINT wReportDescriptorLength;
00150 } THID_class_descriptor;
00151
00152
00153
00154
00155
00156 typedef struct {
00157 Tconfiguration_descriptor m_config_desc;
00158 Tinterface_descriptor m_interface_desc_CDC_comm;
00159 Theader_func_descriptor m_header_func_desc;
00160 Tcall_man_func_descriptor m_call_man_desc;
00161 Tabst_control_mana_descriptor m_abst_control_desc;
00162 Tunion_func_descriptor m_union_func_desc;
00163 Tendpoint_descriptor m_endpoint_desc_CDC_INT_IN;
00164 Tinterface_descriptor m_interface_desc_CDC_data;
00165 Tendpoint_descriptor m_endpoint_desc_CDC_BULK_IN;
00166 Tendpoint_descriptor m_endpoint_desc_CDC_BULK_OUT;
00167 } Tconfiguration_desc_set;
00168
00169
00170
00171
00172
00173
00174 #define DSC_TYPE_DEVICE 0x01
00175 #define DSC_TYPE_CONFIG 0x02
00176 #define DSC_TYPE_STRING 0x03
00177 #define DSC_TYPE_INTERFACE 0x04
00178 #define DSC_TYPE_ENDPOINT 0x05
00179 #define DSC_TYPE_IAD 0x0B
00180
00181
00182 #define DSC_CNFG_ATR_BASE 0x80 // D7: base attribute, always 1
00183 #define DSC_CNFG_ATR_SELF_POWERED 0x40 // D6: bus-powered: 0, self-powered: 1, both: 1
00184 #define DSC_CNFG_ATR_BUS_POWERED 0x00
00185 #define DSC_CNFG_ATR_REMOTEWAKEUP 0x20 // D5: remote-wakeup disabled: 0, enabled: 1
00186
00187
00188 #define DSC_CNFG_MAXPOWER( x ) (((x) + 1) / 2) // 1 unit = 2mA
00189
00190
00191 #define DSC_EP_CONTROL 0x00
00192 #define DSC_EP_ISOC 0x01
00193 #define DSC_EP_BULK 0x02
00194 #define DSC_EP_INTERRUPT 0x03
00195
00196
00197 #define EP1_OUT 0x01
00198 #define EP2_OUT 0x02
00199 #define EP3_OUT 0x03
00200 #define EP1_IN 0x81
00201 #define EP2_IN 0x82
00202 #define EP3_IN 0x83
00203
00204
00205 #define DSC_TYPE_CS_INTERFACE 0x24
00206
00207
00208 #define DSC_SUBTYPE_CS_CDC_HEADER_FUNC 0x00
00209 #define DSC_SUBTYPE_CS_CDC_CALL_MAN 0x01
00210 #define DSC_SUBTYPE_CS_CDC_ABST_CNTRL 0x02
00211 #define DSC_SUBTYPE_CS_CDC_UNION_FUNC 0x06
00212
00213
00214 #define DSC_SUBTYPE_CS_HID_CLASS 0x21
00215 #define DSC_SUBTYPE_CS_HID_REPORT 0x22
00216 #define DSC_SUBTYPE_CS_HID_PHYSICAL 0x23
00217
00218
00219
00220
00221
00222 extern Tdevice_descriptor code DeviceDesc;
00223 extern Tconfiguration_desc_set code ConfigDescSet;
00224 extern BYTE code * code StringDescTable[];
00225 extern BYTE code StringDescNum;
00226
00227
00228 #define HID_IN_REPORT_SIZE EP3_IN_PACKET_SIZE
00229 #define HID_OUT_REPORT_SIZE EP3_OUT_PACKET_SIZE
00230
00231 extern BYTE code HID_report_desc0[];
00232 extern BYTE code HID_report_desc0_size;
00233
00234 #endif // USB_DESCRIPTORS_H
00235
00236
00237
00238