usb11spec.h

00001 /* usb11spec.h
00002 * Copyright (C) 2005  Benedikt Sauter
00003 *
00004 * This program is free software; you can redistribute it and/or modify
00005 * it under the terms of the GNU General Public License as published by
00006 * the Free Software Foundation; either version 2 of the License, or
00007 * (at your option) any later version.
00008 *
00009 * This program is distributed in the hope that it will be useful,
00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 * GNU General Public License for more details.
00013 *
00014 * You should have received a copy of the GNU General Public License
00015 * along with this program; if not, write to the Free Software
00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 */
00018 #ifndef _USB11PSEC_H
00019 #define _USB11SPEC_H
00020 
00021 /*-------------------------------------------
00022  * device descriptor 
00023  * ------------------------------------------*/
00024 struct usb_device_descriptor 
00025 {
00026         unsigned char   bLength;
00027         unsigned char   bDescriptorType;
00028         unsigned short  bcdUSB;
00029         unsigned char   bDeviceClass;
00030         unsigned char   bDeviceSubClass;
00031         unsigned char   bDeviceProtocol;
00032         unsigned char   bMaxPacketSize0;
00033         unsigned short  idVendor;
00034         unsigned short  idProduct;
00035         unsigned short  bcdDevice;
00036         unsigned char   iManufacturer;
00037         unsigned char   iProduct;
00038         unsigned char   iSerialNumber;
00039         unsigned char   bNumConfigurations;
00040 };
00041 
00042 /*-------------------------------------------
00043  * configuration descriptor 
00044  * ------------------------------------------*/
00045 
00046 struct usb_configuration_descriptor 
00047 {
00048         unsigned char   bLength;
00049         unsigned char   bDescriptorType;
00050         unsigned short  wTotalLength;
00051         unsigned char   bNumInterfaces;
00052         unsigned char   bConfigurationValue;
00053         unsigned char   iConfiguration;
00054         unsigned char   bmAttributes;
00055         unsigned char   MaxPower;
00056 };
00057 
00058 /*-------------------------------------------
00059  * interface descriptor 
00060  * ------------------------------------------*/
00061 
00062 struct usb_interface_descriptor 
00063 {
00064         unsigned char   bLength;
00065         unsigned char   bDescriptorType;
00066         unsigned char   bInterfaceNumber;
00067         unsigned char   bAlternateSetting;
00068         unsigned char   bNumEndpoints;
00069         unsigned char   bInterfaceClass;
00070         unsigned char   bInterfaceSubClass;
00071         unsigned char   bInterfaceProtocol;
00072         unsigned char   iInterface;
00073 };
00074 
00075 
00076 /*-------------------------------------------
00077  * endpoint descriptor 
00078  * ------------------------------------------*/
00079 struct usb_endpoint_descriptor 
00080 {
00081         unsigned char   bLength;
00082         unsigned char   bDescriptorType;
00083         unsigned char   bEndpointAddress;
00084         unsigned char   bmAttributes;
00085         unsigned short  wMaxPacketSize;
00086         unsigned char   bIntervall;
00087 };
00088 
00089 
00090 
00091 /*-------------------------------------------
00092  * string descriptor 
00093  * ------------------------------------------*/
00094 struct usb_string_descriptor 
00095 {
00096         unsigned char   bLength;
00097         unsigned char   bDescriptorType;
00098         unsigned char*  String;
00099 };
00100 
00101 
00102 
00103 
00104 /*-------------------------------------------
00105  * USB Device Request
00106  * ------------------------------------------*/
00107 typedef struct usb_device_request_t usb_device_request;
00108 struct usb_device_request_t
00109 {
00110         unsigned char bmRequestType;
00111         unsigned char bRequest;
00112         unsigned short wValue;
00113         unsigned short wIndex;  
00114         unsigned short wLength;
00115 };
00116 
00117 /*-------------------------------------------
00118  * Get Device Descriptor Request
00119  * ------------------------------------------*/
00120 //char GetDeviceDescriptor[] {0x80,GET_DESCRIPTOR, DEVICE,0x00, 0x00,0x00,0x00,0x40};
00121 //char GetDeviceDescriptor[] {0x80,GET_DESCRIPTOR, DEVICE,0x00, 0x00,0x00,0x00,0x40};
00122 //char SetAddress[] {0x00,SET_ADDRESS, 0x00, address, 0x00,0x00,0x00,0x40};
00123 //char SetAddress[] {0x00,SET_ADDRESS, 0x00, 0x00, 0x00,0x00,0x00,0x00};
00124 
00125 
00126 /*------------------------------------------
00127  * transfer types 
00128  * ------------------------------------------*/
00129 
00130 #define USB_CTRL                0x00
00131 #define USB_ISOC                0x01
00132 #define USB_BULK                0x02
00133 #define USB_INTR                0x03
00134 
00135 /*-------------------------------------------
00136  * device descriptor types 
00137  * ------------------------------------------*/
00138 #define DO_STANDARD   0x00
00139 #define DO_CLASS      0x20
00140 #define DO_VENDOR     0x40
00141 
00142 /*-------------------------------------------
00143  * standard requests for ep0 
00144  * ------------------------------------------*/
00145 
00146 #define GET_STATUS              0x00 
00147 #define CLR_FEATURE             0x01
00148 #define SET_FEATURE             0x03
00149 #define SET_ADDRESS             0x05
00150 #define GET_DESCRIPTOR          0x06
00151 #define SET_DESCRIPTOR          0x07
00152 #define GET_CONFIGURATION       0x08
00153 #define SET_CONFIGURATION       0x09
00154 #define GET_INTERFACE           0x0A
00155 #define SET_INTERFACE           0x0B
00156 
00157 /*-------------------------------------------
00158  * descriptor types 
00159  * ------------------------------------------*/
00160 
00161 #define DEVICE                  0x01
00162 #define CONFIGURATION           0x02
00163 #define STRING                  0x03
00164 #define INTERFACE               0x04
00165 #define ENDPOINT                0x05
00166 #define DEVICEQUALIFIER         0x06 // only usb2.0
00167 #define OTHERSPEEDCONFIGURATION 0x07 // only usb2.0
00168 
00169 
00170 /*-------------------------------------------
00171  * pid fields 
00172  * ------------------------------------------*/
00173 
00174 #define USB_PID_SOF     0x05
00175 #define USB_PID_SETUP   0x0D
00176 #define USB_PID_IN      0x09
00177 #define USB_PID_OUT     0x01
00178 #define USB_PID_DATA0   0x03
00179 #define USB_PID_DATA1   0x0B
00180 #define USB_PID_ACK     0x02
00181 #define USB_PID_NACK    0x0A
00182 #define USB_PID_STALL   0x0E
00183 #define USB_PID_PRE     0x0C
00184 
00185 
00186 #define HID_CLASSCODE   0x03
00187 #define MASS_STORAGE_CLASSCODE  0x08
00188 #define HUB_CLASSCODE           0x09
00189 
00190 
00191 
00192 #endif /* __USB11SPEC_H__ */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated by  doxygen 1.6.3