Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef _ch9_h_
00032 #define _ch9_h_
00033
00034
00035 #define DEV_DESCR_LEN 18 //device descriptor length
00036 #define CONF_DESCR_LEN 9 //configuration descriptor length
00037 #define INTR_DESCR_LEN 9 //interface descriptor length
00038 #define EP_DESCR_LEN 7 //endpoint descriptor length
00039
00040
00041
00042 #define USB_REQUEST_GET_STATUS 0 // Standard Device Request - GET STATUS
00043 #define USB_REQUEST_CLEAR_FEATURE 1 // Standard Device Request - CLEAR FEATURE
00044 #define USB_REQUEST_SET_FEATURE 3 // Standard Device Request - SET FEATURE
00045 #define USB_REQUEST_SET_ADDRESS 5 // Standard Device Request - SET ADDRESS
00046 #define USB_REQUEST_GET_DESCRIPTOR 6 // Standard Device Request - GET DESCRIPTOR
00047 #define USB_REQUEST_SET_DESCRIPTOR 7 // Standard Device Request - SET DESCRIPTOR
00048 #define USB_REQUEST_GET_CONFIGURATION 8 // Standard Device Request - GET CONFIGURATION
00049 #define USB_REQUEST_SET_CONFIGURATION 9 // Standard Device Request - SET CONFIGURATION
00050 #define USB_REQUEST_GET_INTERFACE 10 // Standard Device Request - GET INTERFACE
00051 #define USB_REQUEST_SET_INTERFACE 11 // Standard Device Request - SET INTERFACE
00052 #define USB_REQUEST_SYNCH_FRAME 12 // Standard Device Request - SYNCH FRAME
00053
00054 #define USB_FEATURE_ENDPOINT_HALT 0 // CLEAR/SET FEATURE - Endpoint Halt
00055 #define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // CLEAR/SET FEATURE - Device remote wake-up
00056 #define USB_FEATURE_TEST_MODE 2 // CLEAR/SET FEATURE - Test mode
00057
00058
00059
00060 #define USB_SETUP_HOST_TO_DEVICE 0x00 // Device Request bmRequestType transfer direction - host to device transfer
00061 #define USB_SETUP_DEVICE_TO_HOST 0x80 // Device Request bmRequestType transfer direction - device to host transfer
00062 #define USB_SETUP_TYPE_STANDARD 0x00 // Device Request bmRequestType type - standard
00063 #define USB_SETUP_TYPE_CLASS 0x20 // Device Request bmRequestType type - class
00064 #define USB_SETUP_TYPE_VENDOR 0x40 // Device Request bmRequestType type - vendor
00065 #define USB_SETUP_RECIPIENT_DEVICE 0x00 // Device Request bmRequestType recipient - device
00066 #define USB_SETUP_RECIPIENT_INTERFACE 0x01 // Device Request bmRequestType recipient - interface
00067 #define USB_SETUP_RECIPIENT_ENDPOINT 0x02 // Device Request bmRequestType recipient - endpoint
00068 #define USB_SETUP_RECIPIENT_OTHER 0x03 // Device Request bmRequestType recipient - other
00069
00070
00071
00072 #define USB_DESCRIPTOR_DEVICE 0x01 // bDescriptorType for a Device Descriptor.
00073 #define USB_DESCRIPTOR_CONFIGURATION 0x02 // bDescriptorType for a Configuration Descriptor.
00074 #define USB_DESCRIPTOR_STRING 0x03 // bDescriptorType for a String Descriptor.
00075 #define USB_DESCRIPTOR_INTERFACE 0x04 // bDescriptorType for an Interface Descriptor.
00076 #define USB_DESCRIPTOR_ENDPOINT 0x05 // bDescriptorType for an Endpoint Descriptor.
00077 #define USB_DESCRIPTOR_DEVICE_QUALIFIER 0x06 // bDescriptorType for a Device Qualifier.
00078 #define USB_DESCRIPTOR_OTHER_SPEED 0x07 // bDescriptorType for a Other Speed Configuration.
00079 #define USB_DESCRIPTOR_INTERFACE_POWER 0x08 // bDescriptorType for Interface Power.
00080 #define USB_DESCRIPTOR_OTG 0x09 // bDescriptorType for an OTG Descriptor.
00081
00082
00083 #define OTG_FEATURE_B_HNP_ENABLE 3 // SET FEATURE OTG - Enable B device to perform HNP
00084 #define OTG_FEATURE_A_HNP_SUPPORT 4 // SET FEATURE OTG - A device supports HNP
00085 #define OTG_FEATURE_A_ALT_HNP_SUPPORT 5 // SET FEATURE OTG - Another port on the A device supports HNP
00086
00087
00088 #define USB_TRANSFER_TYPE_CONTROL 0x00 // Endpoint is a control endpoint.
00089 #define USB_TRANSFER_TYPE_ISOCHRONOUS 0x01 // Endpoint is an isochronous endpoint.
00090 #define USB_TRANSFER_TYPE_BULK 0x02 // Endpoint is a bulk endpoint.
00091 #define USB_TRANSFER_TYPE_INTERRUPT 0x03 // Endpoint is an interrupt endpoint.
00092 #define bmUSB_TRANSFER_TYPE 0x03 // bit mask to separate transfer type from ISO attributes
00093
00094
00095
00096 #define USB_FEATURE_ENDPOINT_STALL 0 // Endpoint recipient
00097 #define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // Device recipient
00098 #define USB_FEATURE_TEST_MODE 2 // Device recipient
00099
00100
00101
00102 #define HID_REQUEST_GET_REPORT 0x01
00103 #define HID_REQUEST_GET_IDLE 0x02
00104 #define HID_REQUEST_GET_PROTOCOL 0x03
00105 #define HID_REQUEST_SET_REPORT 0x09
00106 #define HID_REQUEST_SET_IDLE 0x0A
00107 #define HID_REQUEST_SET_PROTOCOL 0x0B
00108
00109
00110 #define HID_DESCRIPTOR_HID 0x21
00111 #define HID_DESCRIPTOR_REPORT 0x22
00112 #define HID_DESRIPTOR_PHY 0x23
00113
00114
00115 #define BOOT_PROTOCOL 0x00
00116 #define RPT_PROTOCOL 0x01
00117
00118 #define HID_INTF 0x03
00119
00120 #define BOOT_INTF_SUBCLASS 0x01
00121
00122 #define HID_PROTOCOL_NONE 0x00
00123 #define HID_PROTOCOL_KEYBOARD 0x01
00124 #define HID_PROTOCOL_MOUSE 0x02
00125
00126
00127
00128
00129
00130 typedef struct {
00131 byte bLength;
00132 byte bDescriptorType;
00133 unsigned int bcdUSB;
00134 byte bDeviceClass;
00135 byte bDeviceSubClass;
00136 byte bDeviceProtocol;
00137 byte bMaxPacketSize0;
00138 unsigned int idVendor;
00139 unsigned int idProduct;
00140 unsigned int bcdDevice;
00141 byte iManufacturer;
00142 byte iProduct;
00143 byte iSerialNumber;
00144 byte bNumConfigurations;
00145 } USB_DEVICE_DESCRIPTOR;
00146
00147
00148 typedef struct
00149 {
00150 byte bLength;
00151 byte bDescriptorType;
00152 unsigned int wTotalLength;
00153 byte bNumInterfaces;
00154 byte bConfigurationValue;
00155 byte iConfiguration;
00156 byte bmAttributes;
00157 byte bMaxPower;
00158 } USB_CONFIGURATION_DESCRIPTOR;
00159
00160
00161 typedef struct
00162 {
00163 byte bLength;
00164 byte bDescriptorType;
00165 byte bInterfaceNumber;
00166 byte bAlternateSetting;
00167 byte bNumEndpoints;
00168 byte bInterfaceClass;
00169 byte bInterfaceSubClass;
00170 byte bInterfaceProtocol;
00171 byte iInterface;
00172 } USB_INTERFACE_DESCRIPTOR;
00173
00174
00175 typedef struct
00176 {
00177 byte bLength;
00178 byte bDescriptorType;
00179 byte bEndpointAddress;
00180 byte bmAttributes;
00181 unsigned int wMaxPacketSize;
00182 byte bInterval;
00183 } USB_ENDPOINT_DESCRIPTOR;
00184
00185
00186 typedef struct {
00187 byte bLength;
00188 byte bDescriptorType;
00189 unsigned int bcdHID;
00190 byte bCountryCode;
00191 byte bNumDescriptors;
00192 byte bDescrType;
00193 unsigned int wDescriptorLength;
00194 } USB_HID_DESCRIPTOR;
00195
00196 #endif // _ch9_h_