Bmag incl gps rettelse
Dependencies: mbed WDT MODSERIAL BME280
USBHost/USBHostHub/USBHostHub.cpp@61:52a6d0ffd8e5, 2019-07-05 (annotated)
- Committer:
- gert_lauritsen
- Date:
- Fri Jul 05 12:55:53 2019 +0000
- Branch:
- MbedBMAGThrRev
- Revision:
- 61:52a6d0ffd8e5
dato rettel og ID i file lagt ind i version 5
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gert_lauritsen | 61:52a6d0ffd8e5 | 1 | /* mbed USBHost Library |
gert_lauritsen | 61:52a6d0ffd8e5 | 2 | * Copyright (c) 2006-2013 ARM Limited |
gert_lauritsen | 61:52a6d0ffd8e5 | 3 | * |
gert_lauritsen | 61:52a6d0ffd8e5 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
gert_lauritsen | 61:52a6d0ffd8e5 | 5 | * you may not use this file except in compliance with the License. |
gert_lauritsen | 61:52a6d0ffd8e5 | 6 | * You may obtain a copy of the License at |
gert_lauritsen | 61:52a6d0ffd8e5 | 7 | * |
gert_lauritsen | 61:52a6d0ffd8e5 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
gert_lauritsen | 61:52a6d0ffd8e5 | 9 | * |
gert_lauritsen | 61:52a6d0ffd8e5 | 10 | * Unless required by applicable law or agreed to in writing, software |
gert_lauritsen | 61:52a6d0ffd8e5 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
gert_lauritsen | 61:52a6d0ffd8e5 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
gert_lauritsen | 61:52a6d0ffd8e5 | 13 | * See the License for the specific language governing permissions and |
gert_lauritsen | 61:52a6d0ffd8e5 | 14 | * limitations under the License. |
gert_lauritsen | 61:52a6d0ffd8e5 | 15 | */ |
gert_lauritsen | 61:52a6d0ffd8e5 | 16 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 17 | #include "USBHostHub.h" |
gert_lauritsen | 61:52a6d0ffd8e5 | 18 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 19 | #if MAX_HUB_NB |
gert_lauritsen | 61:52a6d0ffd8e5 | 20 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 21 | #include "USBHost.h" |
gert_lauritsen | 61:52a6d0ffd8e5 | 22 | #include "dbg.h" |
gert_lauritsen | 61:52a6d0ffd8e5 | 23 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 24 | #define GET_STATUS 0x00 |
gert_lauritsen | 61:52a6d0ffd8e5 | 25 | #define CLEAR_FEATURE 0x01 |
gert_lauritsen | 61:52a6d0ffd8e5 | 26 | #define GET_STATE 0x02 |
gert_lauritsen | 61:52a6d0ffd8e5 | 27 | #define SET_FEATURE 0x03 |
gert_lauritsen | 61:52a6d0ffd8e5 | 28 | #define GET_DESCRIPTOR 0x06 |
gert_lauritsen | 61:52a6d0ffd8e5 | 29 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 30 | #define PORT_CONNECTION_FEATURE (0x00) |
gert_lauritsen | 61:52a6d0ffd8e5 | 31 | #define PORT_ENABLE_FEATURE (0x01) |
gert_lauritsen | 61:52a6d0ffd8e5 | 32 | #define PORT_RESET_FEATURE (0x04) |
gert_lauritsen | 61:52a6d0ffd8e5 | 33 | #define PORT_POWER_FEATURE (0x08) |
gert_lauritsen | 61:52a6d0ffd8e5 | 34 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 35 | #define C_PORT_CONNECTION_FEATURE (16) |
gert_lauritsen | 61:52a6d0ffd8e5 | 36 | #define C_PORT_ENABLE_FEATURE (17) |
gert_lauritsen | 61:52a6d0ffd8e5 | 37 | #define C_PORT_RESET_FEATURE (20) |
gert_lauritsen | 61:52a6d0ffd8e5 | 38 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 39 | #define PORT_CONNECTION (1 << 0) |
gert_lauritsen | 61:52a6d0ffd8e5 | 40 | #define PORT_ENABLE (1 << 1) |
gert_lauritsen | 61:52a6d0ffd8e5 | 41 | #define PORT_SUSPEND (1 << 2) |
gert_lauritsen | 61:52a6d0ffd8e5 | 42 | #define PORT_OVER_CURRENT (1 << 3) |
gert_lauritsen | 61:52a6d0ffd8e5 | 43 | #define PORT_RESET (1 << 4) |
gert_lauritsen | 61:52a6d0ffd8e5 | 44 | #define PORT_POWER (1 << 8) |
gert_lauritsen | 61:52a6d0ffd8e5 | 45 | #define PORT_LOW_SPEED (1 << 9) |
gert_lauritsen | 61:52a6d0ffd8e5 | 46 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 47 | #define C_PORT_CONNECTION (1 << 16) |
gert_lauritsen | 61:52a6d0ffd8e5 | 48 | #define C_PORT_ENABLE (1 << 17) |
gert_lauritsen | 61:52a6d0ffd8e5 | 49 | #define C_PORT_SUSPEND (1 << 18) |
gert_lauritsen | 61:52a6d0ffd8e5 | 50 | #define C_PORT_OVER_CURRENT (1 << 19) |
gert_lauritsen | 61:52a6d0ffd8e5 | 51 | #define C_PORT_RESET (1 << 20) |
gert_lauritsen | 61:52a6d0ffd8e5 | 52 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 53 | USBHostHub::USBHostHub() { |
gert_lauritsen | 61:52a6d0ffd8e5 | 54 | host = NULL; |
gert_lauritsen | 61:52a6d0ffd8e5 | 55 | init(); |
gert_lauritsen | 61:52a6d0ffd8e5 | 56 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 57 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 58 | void USBHostHub::init() { |
gert_lauritsen | 61:52a6d0ffd8e5 | 59 | dev_connected = false; |
gert_lauritsen | 61:52a6d0ffd8e5 | 60 | dev = NULL; |
gert_lauritsen | 61:52a6d0ffd8e5 | 61 | int_in = NULL; |
gert_lauritsen | 61:52a6d0ffd8e5 | 62 | dev_connected = false; |
gert_lauritsen | 61:52a6d0ffd8e5 | 63 | hub_intf = -1; |
gert_lauritsen | 61:52a6d0ffd8e5 | 64 | hub_device_found = false; |
gert_lauritsen | 61:52a6d0ffd8e5 | 65 | nb_port = 0; |
gert_lauritsen | 61:52a6d0ffd8e5 | 66 | hub_characteristics = 0; |
gert_lauritsen | 61:52a6d0ffd8e5 | 67 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 68 | for (int i = 0; i < MAX_HUB_PORT; i++) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 69 | device_children[i] = NULL; |
gert_lauritsen | 61:52a6d0ffd8e5 | 70 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 71 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 72 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 73 | void USBHostHub::setHost(USBHost * host_) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 74 | host = host_; |
gert_lauritsen | 61:52a6d0ffd8e5 | 75 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 76 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 77 | bool USBHostHub::connected() |
gert_lauritsen | 61:52a6d0ffd8e5 | 78 | { |
gert_lauritsen | 61:52a6d0ffd8e5 | 79 | return dev_connected; |
gert_lauritsen | 61:52a6d0ffd8e5 | 80 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 81 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 82 | bool USBHostHub::connect(USBDeviceConnected * dev) |
gert_lauritsen | 61:52a6d0ffd8e5 | 83 | { |
gert_lauritsen | 61:52a6d0ffd8e5 | 84 | if (dev_connected) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 85 | return true; |
gert_lauritsen | 61:52a6d0ffd8e5 | 86 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 87 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 88 | if(host->enumerate(dev, this)) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 89 | init(); |
gert_lauritsen | 61:52a6d0ffd8e5 | 90 | return false; |
gert_lauritsen | 61:52a6d0ffd8e5 | 91 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 92 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 93 | if (hub_device_found) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 94 | this->dev = dev; |
gert_lauritsen | 61:52a6d0ffd8e5 | 95 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 96 | int_in = dev->getEndpoint(hub_intf, INTERRUPT_ENDPOINT, IN); |
gert_lauritsen | 61:52a6d0ffd8e5 | 97 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 98 | if (!int_in) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 99 | init(); |
gert_lauritsen | 61:52a6d0ffd8e5 | 100 | return false; |
gert_lauritsen | 61:52a6d0ffd8e5 | 101 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 102 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 103 | USB_INFO("New HUB: VID:%04x PID:%04x [dev: %p - intf: %d]", dev->getVid(), dev->getPid(), dev, hub_intf); |
gert_lauritsen | 61:52a6d0ffd8e5 | 104 | dev->setName("Hub", hub_intf); |
gert_lauritsen | 61:52a6d0ffd8e5 | 105 | host->registerDriver(dev, hub_intf, this, &USBHostHub::disconnect); |
gert_lauritsen | 61:52a6d0ffd8e5 | 106 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 107 | int_in->attach(this, &USBHostHub::rxHandler); |
gert_lauritsen | 61:52a6d0ffd8e5 | 108 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 109 | // get HUB descriptor |
gert_lauritsen | 61:52a6d0ffd8e5 | 110 | host->controlRead( dev, |
gert_lauritsen | 61:52a6d0ffd8e5 | 111 | USB_DEVICE_TO_HOST | USB_REQUEST_TYPE_CLASS, |
gert_lauritsen | 61:52a6d0ffd8e5 | 112 | GET_DESCRIPTOR, |
gert_lauritsen | 61:52a6d0ffd8e5 | 113 | 0x29 << 8, 0, buf, sizeof(HubDescriptor)); |
gert_lauritsen | 61:52a6d0ffd8e5 | 114 | nb_port = buf[2]; |
gert_lauritsen | 61:52a6d0ffd8e5 | 115 | hub_characteristics = buf[3]; |
gert_lauritsen | 61:52a6d0ffd8e5 | 116 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 117 | USB_DBG("Hub has %d port", nb_port); |
gert_lauritsen | 61:52a6d0ffd8e5 | 118 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 119 | for (uint8_t j = 1; j <= nb_port; j++) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 120 | setPortFeature(PORT_POWER_FEATURE, j); |
gert_lauritsen | 61:52a6d0ffd8e5 | 121 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 122 | wait_ms(buf[5]*2); |
gert_lauritsen | 61:52a6d0ffd8e5 | 123 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 124 | host->interruptRead(dev, int_in, buf, 1, false); |
gert_lauritsen | 61:52a6d0ffd8e5 | 125 | dev_connected = true; |
gert_lauritsen | 61:52a6d0ffd8e5 | 126 | return true; |
gert_lauritsen | 61:52a6d0ffd8e5 | 127 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 128 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 129 | return false; |
gert_lauritsen | 61:52a6d0ffd8e5 | 130 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 131 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 132 | void USBHostHub::disconnect() { |
gert_lauritsen | 61:52a6d0ffd8e5 | 133 | init(); |
gert_lauritsen | 61:52a6d0ffd8e5 | 134 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 135 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 136 | /*virtual*/ void USBHostHub::setVidPid(uint16_t vid, uint16_t pid) |
gert_lauritsen | 61:52a6d0ffd8e5 | 137 | { |
gert_lauritsen | 61:52a6d0ffd8e5 | 138 | // we don't check VID/PID for MSD driver |
gert_lauritsen | 61:52a6d0ffd8e5 | 139 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 140 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 141 | /*virtual*/ bool USBHostHub::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 |
gert_lauritsen | 61:52a6d0ffd8e5 | 142 | { |
gert_lauritsen | 61:52a6d0ffd8e5 | 143 | if ((hub_intf == -1) && |
gert_lauritsen | 61:52a6d0ffd8e5 | 144 | (intf_class == HUB_CLASS) && |
gert_lauritsen | 61:52a6d0ffd8e5 | 145 | (intf_subclass == 0) && |
gert_lauritsen | 61:52a6d0ffd8e5 | 146 | (intf_protocol == 0)) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 147 | hub_intf = intf_nb; |
gert_lauritsen | 61:52a6d0ffd8e5 | 148 | return true; |
gert_lauritsen | 61:52a6d0ffd8e5 | 149 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 150 | return false; |
gert_lauritsen | 61:52a6d0ffd8e5 | 151 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 152 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 153 | /*virtual*/ bool USBHostHub::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used |
gert_lauritsen | 61:52a6d0ffd8e5 | 154 | { |
gert_lauritsen | 61:52a6d0ffd8e5 | 155 | if (intf_nb == hub_intf) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 156 | if ((type == INTERRUPT_ENDPOINT) && (dir == IN)) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 157 | hub_device_found = true; |
gert_lauritsen | 61:52a6d0ffd8e5 | 158 | return true; |
gert_lauritsen | 61:52a6d0ffd8e5 | 159 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 160 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 161 | return false; |
gert_lauritsen | 61:52a6d0ffd8e5 | 162 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 163 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 164 | void USBHostHub::deviceConnected(USBDeviceConnected * dev) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 165 | device_children[dev->getPort() - 1] = dev; |
gert_lauritsen | 61:52a6d0ffd8e5 | 166 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 167 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 168 | void USBHostHub::deviceDisconnected(USBDeviceConnected * dev) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 169 | device_children[dev->getPort() - 1] = NULL; |
gert_lauritsen | 61:52a6d0ffd8e5 | 170 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 171 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 172 | void USBHostHub::hubDisconnected() { |
gert_lauritsen | 61:52a6d0ffd8e5 | 173 | for (uint8_t i = 0; i < MAX_HUB_PORT; i++) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 174 | if (device_children[i] != NULL) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 175 | host->freeDevice(device_children[i]); |
gert_lauritsen | 61:52a6d0ffd8e5 | 176 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 177 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 178 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 179 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 180 | void USBHostHub::rxHandler() { |
gert_lauritsen | 61:52a6d0ffd8e5 | 181 | uint32_t status; |
gert_lauritsen | 61:52a6d0ffd8e5 | 182 | if (int_in) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 183 | if (int_in->getState() == USB_TYPE_IDLE) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 184 | for (int port = 1; port <= nb_port; port++) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 185 | status = getPortStatus(port); |
gert_lauritsen | 61:52a6d0ffd8e5 | 186 | USB_DBG("[hub handler hub: %d] status port %d [hub: %p]: 0x%X", dev->getHub(), port, dev, status); |
gert_lauritsen | 61:52a6d0ffd8e5 | 187 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 188 | // if connection status has changed |
gert_lauritsen | 61:52a6d0ffd8e5 | 189 | if (status & C_PORT_CONNECTION) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 190 | if (status & PORT_CONNECTION) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 191 | USB_DBG("[hub handler hub: %d - port: %d] new device connected", dev->getHub(), port); |
gert_lauritsen | 61:52a6d0ffd8e5 | 192 | host->deviceConnected(dev->getHub() + 1, port, status & PORT_LOW_SPEED, this); |
gert_lauritsen | 61:52a6d0ffd8e5 | 193 | } else { |
gert_lauritsen | 61:52a6d0ffd8e5 | 194 | USB_DBG("[hub handler hub: %d - port: %d] device disconnected", dev->getHub(), port); |
gert_lauritsen | 61:52a6d0ffd8e5 | 195 | host->deviceDisconnected(dev->getHub() + 1, port, this, 0); |
gert_lauritsen | 61:52a6d0ffd8e5 | 196 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 197 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 198 | clearPortFeature(C_PORT_CONNECTION_FEATURE, port); |
gert_lauritsen | 61:52a6d0ffd8e5 | 199 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 200 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 201 | if (status & C_PORT_RESET) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 202 | clearPortFeature(C_PORT_RESET_FEATURE, port); |
gert_lauritsen | 61:52a6d0ffd8e5 | 203 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 204 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 205 | if (status & C_PORT_ENABLE) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 206 | clearPortFeature(C_PORT_ENABLE_FEATURE, port); |
gert_lauritsen | 61:52a6d0ffd8e5 | 207 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 208 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 209 | if ((status & PORT_OVER_CURRENT)) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 210 | USB_ERR("OVER CURRENT DETECTED\r\n"); |
gert_lauritsen | 61:52a6d0ffd8e5 | 211 | clearPortFeature(PORT_OVER_CURRENT, port); |
gert_lauritsen | 61:52a6d0ffd8e5 | 212 | host->deviceDisconnected(dev->getHub() + 1, port, this, 0); |
gert_lauritsen | 61:52a6d0ffd8e5 | 213 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 214 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 215 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 216 | host->interruptRead(dev, int_in, buf, 1, false); |
gert_lauritsen | 61:52a6d0ffd8e5 | 217 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 218 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 219 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 220 | void USBHostHub::portReset(uint8_t port) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 221 | // reset port |
gert_lauritsen | 61:52a6d0ffd8e5 | 222 | uint32_t status; |
gert_lauritsen | 61:52a6d0ffd8e5 | 223 | USB_DBG("reset port %d on hub: %p [this: %p]", port, dev, this) |
gert_lauritsen | 61:52a6d0ffd8e5 | 224 | setPortFeature(PORT_RESET_FEATURE, port); |
gert_lauritsen | 61:52a6d0ffd8e5 | 225 | #if defined(TARGET_RZ_A1H) |
gert_lauritsen | 61:52a6d0ffd8e5 | 226 | Thread::wait(50); // Reset release waiting for Hi-Speed check. |
gert_lauritsen | 61:52a6d0ffd8e5 | 227 | #endif |
gert_lauritsen | 61:52a6d0ffd8e5 | 228 | while(1) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 229 | status = getPortStatus(port); |
gert_lauritsen | 61:52a6d0ffd8e5 | 230 | if (status & (PORT_ENABLE | PORT_RESET)) |
gert_lauritsen | 61:52a6d0ffd8e5 | 231 | break; |
gert_lauritsen | 61:52a6d0ffd8e5 | 232 | if (status & PORT_OVER_CURRENT) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 233 | USB_ERR("OVER CURRENT DETECTED\r\n"); |
gert_lauritsen | 61:52a6d0ffd8e5 | 234 | clearPortFeature(PORT_OVER_CURRENT, port); |
gert_lauritsen | 61:52a6d0ffd8e5 | 235 | host->deviceDisconnected(dev->getHub() + 1, port, this, 0); |
gert_lauritsen | 61:52a6d0ffd8e5 | 236 | break; |
gert_lauritsen | 61:52a6d0ffd8e5 | 237 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 238 | Thread::wait(10); |
gert_lauritsen | 61:52a6d0ffd8e5 | 239 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 240 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 241 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 242 | void USBHostHub::setPortFeature(uint32_t feature, uint8_t port) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 243 | host->controlWrite( dev, |
gert_lauritsen | 61:52a6d0ffd8e5 | 244 | USB_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS | USB_RECIPIENT_INTERFACE | USB_RECIPIENT_ENDPOINT, |
gert_lauritsen | 61:52a6d0ffd8e5 | 245 | SET_FEATURE, |
gert_lauritsen | 61:52a6d0ffd8e5 | 246 | feature, |
gert_lauritsen | 61:52a6d0ffd8e5 | 247 | port, |
gert_lauritsen | 61:52a6d0ffd8e5 | 248 | NULL, |
gert_lauritsen | 61:52a6d0ffd8e5 | 249 | 0); |
gert_lauritsen | 61:52a6d0ffd8e5 | 250 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 251 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 252 | void USBHostHub::clearPortFeature(uint32_t feature, uint8_t port) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 253 | host->controlWrite( dev, |
gert_lauritsen | 61:52a6d0ffd8e5 | 254 | USB_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS | USB_RECIPIENT_INTERFACE | USB_RECIPIENT_ENDPOINT, |
gert_lauritsen | 61:52a6d0ffd8e5 | 255 | CLEAR_FEATURE, |
gert_lauritsen | 61:52a6d0ffd8e5 | 256 | feature, |
gert_lauritsen | 61:52a6d0ffd8e5 | 257 | port, |
gert_lauritsen | 61:52a6d0ffd8e5 | 258 | NULL, |
gert_lauritsen | 61:52a6d0ffd8e5 | 259 | 0); |
gert_lauritsen | 61:52a6d0ffd8e5 | 260 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 261 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 262 | uint32_t USBHostHub::getPortStatus(uint8_t port) { |
gert_lauritsen | 61:52a6d0ffd8e5 | 263 | uint32_t st; |
gert_lauritsen | 61:52a6d0ffd8e5 | 264 | host->controlRead( dev, |
gert_lauritsen | 61:52a6d0ffd8e5 | 265 | USB_DEVICE_TO_HOST | USB_REQUEST_TYPE_CLASS | USB_RECIPIENT_INTERFACE | USB_RECIPIENT_ENDPOINT, |
gert_lauritsen | 61:52a6d0ffd8e5 | 266 | GET_STATUS, |
gert_lauritsen | 61:52a6d0ffd8e5 | 267 | 0, |
gert_lauritsen | 61:52a6d0ffd8e5 | 268 | port, |
gert_lauritsen | 61:52a6d0ffd8e5 | 269 | (uint8_t *)&st, |
gert_lauritsen | 61:52a6d0ffd8e5 | 270 | 4); |
gert_lauritsen | 61:52a6d0ffd8e5 | 271 | return st; |
gert_lauritsen | 61:52a6d0ffd8e5 | 272 | } |
gert_lauritsen | 61:52a6d0ffd8e5 | 273 | |
gert_lauritsen | 61:52a6d0ffd8e5 | 274 | #endif |