1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
//*****************************************************************************
//
// usbhhub.h - This hold the host driver for hid class.
//
// Copyright (c) 2011-2012 Texas Instruments Incorporated. All rights reserved.
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 9453 of the Stellaris USB Library.
//
//*****************************************************************************
#ifndef __USBHHUB_H__
#define __USBHHUB_H__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
extern const tUSBHostClassDriver g_USBHubClassDriver;
//*****************************************************************************
//
//! The USB standard hub descriptor structure. Full documentation for the
//! contents of this structure can be found in chapter 11.23.2.1 of the USB
//! 2.0 specification.
//
//*****************************************************************************
#ifdef ewarm
#pragma pack(1)
#endif
//*****************************************************************************
//
// The USB standard allows for up to 127 downstream ports on a single hub. This
// would require rather more memory than we would like to set aside so the
// default configuration of the hub driver supports hubs with up to 7
// downstream-facing ports. In practice, this should be more than enough
// since this covers the vast majority of consumer hubs. Note that, by default,
// we will only support 4 devices so you can't fully populate a 7 port hub and
// have everything work.
//
// Feel free to change this but bad things will happen if you increase it above
// 31 since we assume the reports will always fit inside a 4 byte buffer.
//
//*****************************************************************************
#define ROOT_HUB_MAX_PORTS 7
typedef struct
{
//
//! The total number of bytes in the descriptor (including this field).
//
unsigned char bLength;
//
//! The descriptor type. For a hub descriptor, this will be USB_DTYPE_HUB
//! (0x29 or 41 decimal).
//
unsigned char bDescType;
//
//! The number of downstream-facing ports that the hub supports.
//
unsigned char bNbrPorts;
//
//! Characteristics of the hub device including its power switching
//! capabilities and overcurrent protection mode.
//
unsigned short wHubCharacteristics;
//
//! The time between the start of the power-on sequence for a port and
//! the power to the port becoming stable. This is expressed in 2mS units.
//
unsigned char bPwrOn2PwrGood;
//
//! The maximum current requirement for the hub circuitry in mA.
//
unsigned char bHubContrCurrent;
//
//! The last two fields in the structure are bit masks indicating which
//! downstream ports support removable devices and, following this, another
//! obsolete field from USB1.0 related to port power control. Each field
//! is byte aligned and contains a bit for each hub port. This structure
//! definition is set up with enough storage to handle ROOT_HUB_MAX_PORTS
//! ports but beware that the actual size of each field is dependent upon
//! the bNbrPorts field above.
//
unsigned char PortInfo[((ROOT_HUB_MAX_PORTS + 7) / 8) * 2];
}
PACKED tUsbHubDescriptor;
#ifdef ewarm
#pragma pack()
#endif
//*****************************************************************************
//
// Values used as the usFeature parameter to USBHHubClearHubFeature.
//
//*****************************************************************************
#define HUB_FEATURE_C_HUB_LOCAL_POWER 0
#define HUB_FEATURE_C_HUB_OVER_CURRENT 1
//*****************************************************************************
//
// Values used as the usFeature parameter to USBHHubSetPortFeature and
// USBHHubClearPortFeature.
//
//*****************************************************************************
#define HUB_FEATURE_PORT_CONNECTION 0
#define HUB_FEATURE_PORT_ENABLE 1
#define HUB_FEATURE_PORT_SUSPEND 2
#define HUB_FEATURE_PORT_OVER_CURRENT 3
#define HUB_FEATURE_PORT_RESET 4
#define HUB_FEATURE_PORT_POWER 8
#define HUB_FEATURE_PORT_LOW_SPEED 9
#define HUB_FEATURE_C_PORT_CONNECTION 16
#define HUB_FEATURE_C_PORT_ENABLE 17
#define HUB_FEATURE_C_PORT_SUSPEND 18
#define HUB_FEATURE_C_PORT_OVER_CURRENT 19
#define HUB_FEATURE_C_PORT_RESET 20
#define HUB_FEATURE_PORT_TEST 21
#define HUB_FEATURE_PORT_INDICATOR 22
//*****************************************************************************
//
// Values returned via the *pusHubStatus and *pusHubChange parameters passed to
// USBHHubGetHubStatus. These may be ORed together into the returned status
// value.
//
//*****************************************************************************
#define HUB_STATUS_PWR_LOST 1
#define HUB_STATUS_OVER_CURRENT 2
//*****************************************************************************
//
// Values returned via the *pusPortStatus parameter passed to
// USBHHubGetPortStatus. These may be ORed together into the returned status
// value.
//
//*****************************************************************************
#define HUB_PORT_STATUS_DEVICE_PRESENT 0x0001
#define HUB_PORT_STATUS_ENABLED 0x0002
#define HUB_PORT_STATUS_SUSPENDED 0x0004
#define HUB_PORT_STATUS_OVER_CURRENT 0x0008
#define HUB_PORT_STATUS_RESET 0x0010
#define HUB_PORT_STATUS_POWERED 0x0100
#define HUB_PORT_STATUS_LOW_SPEED 0x0200
#define HUB_PORT_STATUS_HIGH_SPEED 0x0400
#define HUB_PORT_STATUS_TEST_MODE 0x0800
#define HUB_PORT_STATUS_INDICATOR_CONTROL 0x1000
//*****************************************************************************
//
// Values returned via the *pusPortChange parameter passed to
// USBHHubGetPortStatus. These may be ORed together into the returned status
// value.
//
//*****************************************************************************
#define HUB_PORT_CHANGE_DEVICE_PRESENT 0x0001
#define HUB_PORT_CHANGE_ENABLED 0x0002
#define HUB_PORT_CHANGE_SUSPENDED 0x0004
#define HUB_PORT_CHANGE_OVER_CURRENT 0x0008
#define HUB_PORT_CHANGE_RESET 0x0010
//*****************************************************************************
//
// Public function prototypes for the HUB class driver.
//
//*****************************************************************************
extern unsigned long USBHHubOpen(tUSBCallback pfnCallback,
unsigned char *pucHubPool,
unsigned long ulPoolSize,
tHubInstance *psHubInstance,
unsigned long ulNumHubs);
extern void USBHHubClose(unsigned long ulInstance);
#ifdef __cplusplus
}
#endif
#endif // __USBHHUB_H__
|