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