]> git.sur5r.net Git - freertos/blob - Demo/CORTEX_LPC1768_IAR/LPCUSB/usbstruct.h
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / CORTEX_LPC1768_IAR / LPCUSB / usbstruct.h
1 /*\r
2         LPCUSB, an USB device driver for LPC microcontrollers   \r
3         Copyright (C) 2006 Bertrik Sikken (bertrik@sikken.nl)\r
4 \r
5         Redistribution and use in source and binary forms, with or without\r
6         modification, are permitted provided that the following conditions are met:\r
7 \r
8         1. Redistributions of source code must retain the above copyright\r
9            notice, this list of conditions and the following disclaimer.\r
10         2. Redistributions in binary form must reproduce the above copyright\r
11            notice, this list of conditions and the following disclaimer in the\r
12            documentation and/or other materials provided with the distribution.\r
13         3. The name of the author may not be used to endorse or promote products\r
14            derived from this software without specific prior written permission.\r
15 \r
16         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\r
17         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r
18         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
19         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\r
20         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
21         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
22         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
23         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
24         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
25         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
26 */\r
27 \r
28 \r
29 /**\r
30         Definitions of structures of standard USB packets\r
31 */\r
32 \r
33 #ifndef _USBSTRUCT_H_\r
34 #define _USBSTRUCT_H_\r
35 \r
36 // CodeRed - include the LPCUSB type.h file rather than NXP one directly\r
37 #include "type.h"\r
38 \r
39 /** setup packet definitions */\r
40 typedef struct {\r
41         unsigned char   bmRequestType;                  /**< characteristics of the specific request */\r
42         unsigned char   bRequest;                               /**< specific request */\r
43         unsigned short  wValue;                                 /**< request specific parameter */\r
44         unsigned short  wIndex;                                 /**< request specific parameter */\r
45         unsigned short  wLength;                                /**< length of data transfered in data phase */\r
46 } TSetupPacket;\r
47 \r
48 \r
49 #define REQTYPE_GET_DIR(x)              (((x)>>7)&0x01)\r
50 #define REQTYPE_GET_TYPE(x)             (((x)>>5)&0x03)\r
51 #define REQTYPE_GET_RECIP(x)    ((x)&0x1F)\r
52 \r
53 #define REQTYPE_DIR_TO_DEVICE   0\r
54 #define REQTYPE_DIR_TO_HOST             1\r
55 \r
56 #define REQTYPE_TYPE_STANDARD   0\r
57 #define REQTYPE_TYPE_CLASS              1\r
58 #define REQTYPE_TYPE_VENDOR             2\r
59 #define REQTYPE_TYPE_RESERVED   3\r
60 \r
61 #define REQTYPE_RECIP_DEVICE    0\r
62 #define REQTYPE_RECIP_INTERFACE 1\r
63 #define REQTYPE_RECIP_ENDPOINT  2\r
64 #define REQTYPE_RECIP_OTHER             3\r
65 \r
66 /* standard requests */\r
67 #define REQ_GET_STATUS                  0x00\r
68 #define REQ_CLEAR_FEATURE               0x01\r
69 #define REQ_SET_FEATURE                 0x03\r
70 #define REQ_SET_ADDRESS                 0x05\r
71 #define REQ_GET_DESCRIPTOR              0x06\r
72 #define REQ_SET_DESCRIPTOR              0x07\r
73 #define REQ_GET_CONFIGURATION   0x08\r
74 #define REQ_SET_CONFIGURATION   0x09\r
75 #define REQ_GET_INTERFACE               0x0A\r
76 #define REQ_SET_INTERFACE               0x0B\r
77 #define REQ_SYNCH_FRAME                 0x0C\r
78 \r
79 /* class requests HID */\r
80 #define HID_GET_REPORT                  0x01\r
81 #define HID_GET_IDLE                    0x02\r
82 #define HID_GET_PROTOCOL                0x03\r
83 #define HID_SET_REPORT                  0x09\r
84 #define HID_SET_IDLE                    0x0A\r
85 #define HID_SET_PROTOCOL                0x0B\r
86 \r
87 /* feature selectors */\r
88 #define FEA_ENDPOINT_HALT               0x00\r
89 #define FEA_REMOTE_WAKEUP               0x01\r
90 #define FEA_TEST_MODE                   0x02\r
91 \r
92 /*\r
93         USB descriptors\r
94 */\r
95 \r
96 /** USB descriptor header */\r
97 typedef struct {\r
98         unsigned char   bLength;                        /**< descriptor length */\r
99         unsigned char   bDescriptorType;        /**< descriptor type */\r
100 } TUSBDescHeader;\r
101 \r
102 #define DESC_DEVICE                             1\r
103 #define DESC_CONFIGURATION              2\r
104 #define DESC_STRING                             3\r
105 #define DESC_INTERFACE                  4\r
106 #define DESC_ENDPOINT                   5\r
107 #define DESC_DEVICE_QUALIFIER   6\r
108 #define DESC_OTHER_SPEED                7\r
109 #define DESC_INTERFACE_POWER    8\r
110 \r
111 #define DESC_HID_HID                    0x21\r
112 #define DESC_HID_REPORT                 0x22\r
113 #define DESC_HID_PHYSICAL               0x23\r
114 \r
115 #define GET_DESC_TYPE(x)                (((x)>>8)&0xFF)\r
116 #define GET_DESC_INDEX(x)               ((x)&0xFF)\r
117 \r
118 #endif /* _USBSTRUCT_H_ */\r
119 \r