usbhhub.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // usbhhub.h - This hold the host driver for hid class.
4 //
5 // Copyright (c) 2011-2017 Texas Instruments Incorporated. All rights reserved.
6 // Software License Agreement
7 //
8 // Texas Instruments (TI) is supplying this software for use solely and
9 // exclusively on TI's microcontroller products. The software is owned by
10 // TI and/or its suppliers, and is protected under applicable copyright
11 // laws. You may not combine this software with "viral" open-source
12 // software in order to form a larger program.
13 //
14 // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
15 // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
16 // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
18 // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
19 // DAMAGES, FOR ANY REASON WHATSOEVER.
20 //
21 //*****************************************************************************
22 
23 #ifndef __USBHHUB_H__
24 #define __USBHHUB_H__
25 
26 //*****************************************************************************
27 //
28 // If building with a C++ compiler, make all of the definitions in this header
29 // have a C binding.
30 //
31 //*****************************************************************************
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif
36 
37 typedef struct tHubInstance tHubInstance;
38 
40 
41 //*****************************************************************************
42 //
43 // The USB standard allows for up to 127 downstream ports on a single hub.
44 // This would require rather more memory than we would like to set aside so the
45 // default configuration of the hub driver supports hubs with up to 7
46 // downstream-facing ports. In practice, this should be more than enough
47 // since this covers the vast majority of consumer hubs. Note that, by
48 // default, we will only support 4 devices so you can't fully populate a 7 port
49 // hub and have everything work.
50 //
51 // Feel free to change this but bad things will happen if you increase it above
52 // 31 since we assume the reports will always fit inside a 4 byte buffer.
53 //
54 //*****************************************************************************
55 #define ROOT_HUB_MAX_PORTS 7
56 
57 //*****************************************************************************
58 //
59 // Values used as the ui16Feature parameter to USBHHubClearHubFeature().
60 //
61 //*****************************************************************************
62 #define HUB_FEATURE_C_HUB_LOCAL_POWER \
63  0
64 #define HUB_FEATURE_C_HUB_OVER_CURRENT \
65  1
66 
67 //*****************************************************************************
68 //
69 // Values used as the ui16Feature parameter to USBHHubSetPortFeature() and
70 // USBHHubClearPortFeature().
71 //
72 //*****************************************************************************
73 #define HUB_FEATURE_PORT_CONNECTION \
74  0
75 #define HUB_FEATURE_PORT_ENABLE 1
76 #define HUB_FEATURE_PORT_SUSPEND \
77  2
78 #define HUB_FEATURE_PORT_OVER_CURRENT \
79  3
80 #define HUB_FEATURE_PORT_RESET 4
81 #define HUB_FEATURE_PORT_POWER 8
82 #define HUB_FEATURE_PORT_LOW_SPEED \
83  9
84 #define HUB_FEATURE_C_PORT_CONNECTION \
85  16
86 #define HUB_FEATURE_C_PORT_ENABLE \
87  17
88 #define HUB_FEATURE_C_PORT_SUSPEND \
89  18
90 #define HUB_FEATURE_C_PORT_OVER_CURRENT \
91  19
92 #define HUB_FEATURE_C_PORT_RESET \
93  20
94 #define HUB_FEATURE_PORT_TEST 21
95 #define HUB_FEATURE_PORT_INDICATOR \
96  22
97 
98 //*****************************************************************************
99 //
100 // Values returned via the *pui16HubStatus and *pui16HubChange parameters
101 // passed to USBHHubGetHubStatus(). These may be ORed together into the
102 // returned status value.
103 //
104 //*****************************************************************************
105 #define HUB_STATUS_PWR_LOST 1
106 #define HUB_STATUS_OVER_CURRENT 2
107 
108 //*****************************************************************************
109 //
110 // Values returned via the *pui16PortStatus parameter passed to
111 // USBHHubGetPortStatus(). These may be ORed together into the returned status
112 // value.
113 //
114 //*****************************************************************************
115 #define HUB_PORT_STATUS_DEVICE_PRESENT \
116  0x0001
117 #define HUB_PORT_STATUS_ENABLED 0x0002
118 #define HUB_PORT_STATUS_SUSPENDED \
119  0x0004
120 #define HUB_PORT_STATUS_OVER_CURRENT \
121  0x0008
122 #define HUB_PORT_STATUS_RESET 0x0010
123 #define HUB_PORT_STATUS_POWERED 0x0100
124 #define HUB_PORT_STATUS_LOW_SPEED \
125  0x0200
126 #define HUB_PORT_STATUS_HIGH_SPEED \
127  0x0400
128 #define HUB_PORT_STATUS_TEST_MODE \
129  0x0800
130 #define HUB_PORT_STATUS_INDICATOR_CONTROL \
131  0x1000
132 
133 //*****************************************************************************
134 //
135 // Values returned via the *pui16PortChange parameter passed to
136 // USBHHubGetPortStatus(). These may be ORed together into the returned status
137 // value.
138 //
139 //*****************************************************************************
140 #define HUB_PORT_CHANGE_DEVICE_PRESENT \
141  0x0001
142 #define HUB_PORT_CHANGE_ENABLED 0x0002
143 #define HUB_PORT_CHANGE_SUSPENDED \
144  0x0004
145 #define HUB_PORT_CHANGE_OVER_CURRENT \
146  0x0008
147 #define HUB_PORT_CHANGE_RESET 0x0010
148 
149 //*****************************************************************************
150 //
151 // The prototype for the USB Hub host driver callback function.
152 //
153 //*****************************************************************************
154 typedef void (*tUSBHHubCallback)(tHubInstance *psHubInstance,
155  uint32_t ui32Event, uint32_t ui32MsgParam,
156  void *pvMsgData);
157 
158 //*****************************************************************************
159 //
160 // Public function prototypes for the HUB class driver.
161 //
162 //*****************************************************************************
163 extern tHubInstance * USBHHubOpen(tUSBHHubCallback pfnCallback);
164 extern void USBHHubClose(tHubInstance *psHubInstance);
165 extern uint32_t USBHHubLPMSleep(tHubInstance *psHubInstance);
166 extern uint32_t USBHHubLPMStatus(tHubInstance *psHubInstance);
167 
168 #ifdef __cplusplus
169 }
170 #endif
171 
172 #endif // __USBHHUB_H__
void(* tUSBHHubCallback)(tHubInstance *psHubInstance, uint32_t ui32Event, uint32_t ui32MsgParam, void *pvMsgData)
Definition: usbhhub.h:154
uint32_t USBHHubLPMSleep(tHubInstance *psHubInstance)
Definition: usbhhub.c:1467
uint32_t USBHHubLPMStatus(tHubInstance *psHubInstance)
Definition: usbhhub.c:1495
tHubInstance * USBHHubOpen(tUSBHHubCallback pfnCallback)
Definition: usbhhub.c:1368
Definition: usbhost.h:156
void USBHHubClose(tHubInstance *psHubInstance)
Definition: usbhhub.c:1409
struct tHubInstance tHubInstance
Definition: usbhhub.h:37
const tUSBHostClassDriver g_sUSBHubClassDriver
Definition: usbhhub.c:250
Copyright 2018, Texas Instruments Incorporated