summaryrefslogtreecommitdiff
path: root/usblib/host/usbhhub.h
blob: 17a3c089cb617a394e0cea95d86833c9a0c3d0ca (plain)
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
//*****************************************************************************
//
// usbhhub.h - This hold the host driver for hid class.
//
// Copyright (c) 2011-2014 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 2.1.0.12573 of the Tiva 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

typedef struct tHubInstance tHubInstance;

extern const tUSBHostClassDriver g_sUSBHubClassDriver;

//*****************************************************************************
//
// 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

//*****************************************************************************
//
// Values used as the ui16Feature parameter to USBHHubClearHubFeature().
//
//*****************************************************************************
#define HUB_FEATURE_C_HUB_LOCAL_POWER                                         \
                                0
#define HUB_FEATURE_C_HUB_OVER_CURRENT                                        \
                                1

//*****************************************************************************
//
// Values used as the ui16Feature 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 *pui16HubStatus and *pui16HubChange 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 *pui16PortStatus 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 *pui16PortChange 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

//*****************************************************************************
//
// The prototype for the USB Hub host driver callback function.
//
//*****************************************************************************
typedef void (*tUSBHHubCallback)(tHubInstance *psHubInstance,
                                 uint32_t ui32Event, uint32_t ui32MsgParam,
                                 void *pvMsgData);

//*****************************************************************************
//
// Public function prototypes for the HUB class driver.
//
//*****************************************************************************
extern tHubInstance * USBHHubOpen(tUSBHHubCallback pfnCallback);
extern void USBHHubClose(tHubInstance *psHubInstance);
extern uint32_t USBHHubLPMSleep(tHubInstance *psHubInstance);
extern uint32_t USBHHubLPMStatus(tHubInstance *psHubInstance);

#ifdef __cplusplus
}
#endif

#endif // __USBHHUB_H__