1 /* mbed USBHost Library
2 * Copyright (c) 2006-2013 ARM Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include "USBHostConf.h"
24 #include "USBHostTypes.h"
25 #include "IUSBEnumerator.h"
28 class USBDeviceConnected;
32 * A class to use a USB Hub
34 class USBHostHub : public IUSBEnumerator {
42 * Check if a USB Hub is connected
44 * @return true if a serial device is connected
49 * Try to connect device
51 * @param dev device to connect
52 * @return true if connection was successful
54 bool connect(USBDeviceConnected * dev);
57 * Automatically called by USBHost when a device
58 * has been enumerated by usb_thread
60 * @param dev device connected
62 void deviceConnected(USBDeviceConnected * dev);
65 * Automatically called by USBHost when a device
66 * has been disconnected from this hub
68 * @param dev device disconnected
70 void deviceDisconnected(USBDeviceConnected * dev);
73 * Rest a specific port
75 * @param port port number
77 void portReset(uint8_t port);
80 * Called by USBHost to set the instance of USBHost
82 * @param host host instance
84 void setHost(USBHost * host);
87 * Called by USBhost when a hub has been disconnected
89 void hubDisconnected();
93 virtual void setVidPid(uint16_t vid, uint16_t pid);
94 virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed
95 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
99 USBDeviceConnected * dev;
101 USBEndpoint * int_in;
103 uint8_t hub_characteristics;
107 uint8_t buf[sizeof(HubDescriptor)];
110 bool hub_device_found;
112 void setPortFeature(uint32_t feature, uint8_t port);
113 void clearPortFeature(uint32_t feature, uint8_t port);
114 uint32_t getPortStatus(uint8_t port);
116 USBDeviceConnected * device_children[MAX_HUB_PORT];