- Main Page
- Classes
- Files
- Related Pages

- File List
- File Members

# usbstruct.h

    00001 /*
    00002         LPCUSB, an USB device driver for LPC microcontrollers
    00003         Copyright (C) 2006 Bertrik Sikken (bertrik@sikken.nl)
    00004
    00005         Redistribution and use in source and binary forms, with or without
    00006         modification, are permitted provided that the following conditions are met:
    00007
    00008         1. Redistributions of source code must retain the above copyright
    00009            notice, this list of conditions and the following disclaimer.
    00010         2. Redistributions in binary form must reproduce the above copyright
    00011            notice, this list of conditions and the following disclaimer in the
    00012            documentation and/or other materials provided with the distribution.
    00013         3. The name of the author may not be used to endorse or promote products
    00014            derived from this software without specific prior written permission.
    00015
    00016         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    00017         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    00018         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    00019         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    00020         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    00021         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    00022         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    00023         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    00024         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    00025         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00026 */
    00027
    00028
    00033 #ifndef _USBSTRUCT_H_
    00034 #define _USBSTRUCT_H_
    00035
    00036
    00037 #include "type.h"
    00038
    00039
    00041 typedef struct {
    00042         U8      bmRequestType;
    00043         U8      bRequest;
    00044         U16     wValue;
    00045         U16     wIndex;
    00046         U16     wLength;
    00047 } TSetupPacket;
    00048
    00049
    00050 #define REQTYPE_GET_DIR(x)              (((x)>>7)&0x01)
    00051 #define REQTYPE_GET_TYPE(x)             (((x)>>5)&0x03)
    00052 #define REQTYPE_GET_RECIP(x)    ((x)&0x1F)
    00053
    00054 #define REQTYPE_DIR_TO_DEVICE   0
    00055 #define REQTYPE_DIR_TO_HOST             1
    00056
    00057 #define REQTYPE_TYPE_STANDARD   0
    00058 #define REQTYPE_TYPE_CLASS              1
    00059 #define REQTYPE_TYPE_VENDOR             2
    00060 #define REQTYPE_TYPE_RESERVED   3
    00061
    00062 #define REQTYPE_RECIP_DEVICE    0
    00063 #define REQTYPE_RECIP_INTERFACE 1
    00064 #define REQTYPE_RECIP_ENDPOINT  2
    00065 #define REQTYPE_RECIP_OTHER             3
    00066
    00067 /* standard requests */
    00068 #define REQ_GET_STATUS                  0x00
    00069 #define REQ_CLEAR_FEATURE               0x01
    00070 #define REQ_SET_FEATURE                 0x03
    00071 #define REQ_SET_ADDRESS                 0x05
    00072 #define REQ_GET_DESCRIPTOR              0x06
    00073 #define REQ_SET_DESCRIPTOR              0x07
    00074 #define REQ_GET_CONFIGURATION   0x08
    00075 #define REQ_SET_CONFIGURATION   0x09
    00076 #define REQ_GET_INTERFACE               0x0A
    00077 #define REQ_SET_INTERFACE               0x0B
    00078 #define REQ_SYNCH_FRAME                 0x0C
    00079
    00080 /* class requests HID */
    00081 #define HID_GET_REPORT                  0x01
    00082 #define HID_GET_IDLE                    0x02
    00083 #define HID_GET_PROTOCOL                0x03
    00084 #define HID_SET_REPORT                  0x09
    00085 #define HID_SET_IDLE                    0x0A
    00086 #define HID_SET_PROTOCOL                0x0B
    00087
    00088 /* feature selectors */
    00089 #define FEA_ENDPOINT_HALT               0x00
    00090 #define FEA_REMOTE_WAKEUP               0x01
    00091 #define FEA_TEST_MODE                   0x02
    00092
    00093 /*
    00094         USB descriptors
    00095 */
    00096
    00098 typedef struct {
    00099         U8      bLength;
    00100         U8      bDescriptorType;
    00101 } TUSBDescHeader;
    00102
    00103 #define DESC_DEVICE                             1
    00104 #define DESC_CONFIGURATION              2
    00105 #define DESC_STRING                             3
    00106 #define DESC_INTERFACE                  4
    00107 #define DESC_ENDPOINT                   5
    00108 #define DESC_DEVICE_QUALIFIER   6
    00109 #define DESC_OTHER_SPEED                7
    00110 #define DESC_INTERFACE_POWER    8
    00111
    00112 #define DESC_HID_HID                    0x21
    00113 #define DESC_HID_REPORT                 0x22
    00114 #define DESC_HID_PHYSICAL               0x23
    00115
    00116 #define GET_DESC_TYPE(x)                (((x)>>8)&0xFF)
    00117 #define GET_DESC_INDEX(x)               ((x)&0xFF)
    00118
    00119 #endif /* _USBSTRUCT_H_ */
    00120