blob: d6bd7256a3496a57c110cf0bf854c1031a5cfe19 [file] [log] [blame]
brians0ab60bb2013-01-31 02:21:51 +00001/*
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// CodeRed - include the LPCUSB type.h file rather than NXP one directly
37#include "type.h"
38
39/** setup packet definitions */
40typedef struct {
41 unsigned char bmRequestType; /**< characteristics of the specific request */
42 unsigned char bRequest; /**< specific request */
43 unsigned short wValue; /**< request specific parameter */
44 unsigned short wIndex; /**< request specific parameter */
45 unsigned short wLength; /**< length of data transfered in data phase */
46} TSetupPacket;
47
48
49#define REQTYPE_GET_DIR(x) (((x)>>7)&0x01)
50#define REQTYPE_GET_TYPE(x) (((x)>>5)&0x03)
51#define REQTYPE_GET_RECIP(x) ((x)&0x1F)
52
53#define REQTYPE_DIR_TO_DEVICE 0
54#define REQTYPE_DIR_TO_HOST 1
55
56#define REQTYPE_TYPE_STANDARD 0
57#define REQTYPE_TYPE_CLASS 1
58#define REQTYPE_TYPE_VENDOR 2
59#define REQTYPE_TYPE_RESERVED 3
60
61#define REQTYPE_RECIP_DEVICE 0
62#define REQTYPE_RECIP_INTERFACE 1
63#define REQTYPE_RECIP_ENDPOINT 2
64#define REQTYPE_RECIP_OTHER 3
65
66/* standard requests */
67#define REQ_GET_STATUS 0x00
68#define REQ_CLEAR_FEATURE 0x01
69#define REQ_SET_FEATURE 0x03
70#define REQ_SET_ADDRESS 0x05
71#define REQ_GET_DESCRIPTOR 0x06
72#define REQ_SET_DESCRIPTOR 0x07
73#define REQ_GET_CONFIGURATION 0x08
74#define REQ_SET_CONFIGURATION 0x09
75#define REQ_GET_INTERFACE 0x0A
76#define REQ_SET_INTERFACE 0x0B
77#define REQ_SYNCH_FRAME 0x0C
78
79/* class requests HID */
80#define HID_GET_REPORT 0x01
81#define HID_GET_IDLE 0x02
82#define HID_GET_PROTOCOL 0x03
83#define HID_SET_REPORT 0x09
84#define HID_SET_IDLE 0x0A
85#define HID_SET_PROTOCOL 0x0B
86
87/* feature selectors */
88#define FEA_ENDPOINT_HALT 0x00
89#define FEA_REMOTE_WAKEUP 0x01
90#define FEA_TEST_MODE 0x02
91
92/*
93 USB descriptors
94*/
95
96/** USB descriptor header */
97typedef struct {
98 unsigned char bLength; /**< descriptor length */
99 unsigned char bDescriptorType; /**< descriptor type */
100} TUSBDescHeader;
101
102#define DESC_DEVICE 1
103#define DESC_CONFIGURATION 2
104#define DESC_STRING 3
105#define DESC_INTERFACE 4
106#define DESC_ENDPOINT 5
107#define DESC_DEVICE_QUALIFIER 6
108#define DESC_OTHER_SPEED 7
109#define DESC_INTERFACE_POWER 8
110
111#define DESC_HID_HID 0x21
112#define DESC_HID_REPORT 0x22
113#define DESC_HID_PHYSICAL 0x23
114
115#define GET_DESC_TYPE(x) (((x)>>8)&0xFF)
116#define GET_DESC_INDEX(x) ((x)&0xFF)
117
118#endif /* _USBSTRUCT_H_ */
119