Support Isochronous transfer additionally

Dependents:   USBHostC270_example_GR-PEACH USBHostDac_example USBHostDac_Audio_in_out

Fork of USBHost_custom by Renesas

Committer:
HinoNaka
Date:
Fri Apr 21 07:23:33 2017 +0000
Revision:
41:5c3ebf7372ee
Parent:
24:868cbfe611a7
Support Isochronous transfer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 8:93da8ea2708b 1 /* mbed USBHost Library
samux 8:93da8ea2708b 2 * Copyright (c) 2006-2013 ARM Limited
samux 8:93da8ea2708b 3 *
samux 8:93da8ea2708b 4 * Licensed under the Apache License, Version 2.0 (the "License");
samux 8:93da8ea2708b 5 * you may not use this file except in compliance with the License.
samux 8:93da8ea2708b 6 * You may obtain a copy of the License at
samux 8:93da8ea2708b 7 *
samux 8:93da8ea2708b 8 * http://www.apache.org/licenses/LICENSE-2.0
samux 8:93da8ea2708b 9 *
samux 8:93da8ea2708b 10 * Unless required by applicable law or agreed to in writing, software
samux 8:93da8ea2708b 11 * distributed under the License is distributed on an "AS IS" BASIS,
samux 8:93da8ea2708b 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
samux 8:93da8ea2708b 13 * See the License for the specific language governing permissions and
samux 8:93da8ea2708b 14 * limitations under the License.
samux 8:93da8ea2708b 15 */
mbed_official 0:a554658735bf 16
mbed_official 0:a554658735bf 17 #ifndef USBHOST_H
mbed_official 0:a554658735bf 18 #define USBHOST_H
mbed_official 0:a554658735bf 19
mbed_official 0:a554658735bf 20 #include "USBHALHost.h"
mbed_official 0:a554658735bf 21 #include "USBDeviceConnected.h"
mbed_official 0:a554658735bf 22 #include "IUSBEnumerator.h"
mbed_official 0:a554658735bf 23 #include "USBHostConf.h"
mbed_official 0:a554658735bf 24 #include "rtos.h"
mbed_official 0:a554658735bf 25 #include "dbg.h"
mbed_official 0:a554658735bf 26 #include "USBHostHub.h"
mbed_official 0:a554658735bf 27
samux 8:93da8ea2708b 28 /**
samux 8:93da8ea2708b 29 * USBHost class
samux 8:93da8ea2708b 30 * This class is a singleton. All drivers have a reference on the static USBHost instance
samux 8:93da8ea2708b 31 */
mbed_official 0:a554658735bf 32 class USBHost : public USBHALHost {
mbed_official 0:a554658735bf 33 public:
mbed_official 0:a554658735bf 34 /**
mbed_official 0:a554658735bf 35 * Static method to create or retrieve the single USBHost instance
mbed_official 0:a554658735bf 36 */
mbed_official 0:a554658735bf 37 static USBHost * getHostInst();
mbed_official 24:868cbfe611a7 38
mbed_official 0:a554658735bf 39 /**
mbed_official 0:a554658735bf 40 * Control read: setup stage, data stage and status stage
mbed_official 0:a554658735bf 41 *
mbed_official 0:a554658735bf 42 * @param dev the control read will be done for this device
mbed_official 0:a554658735bf 43 * @param requestType request type
mbed_official 0:a554658735bf 44 * @param request request
mbed_official 0:a554658735bf 45 * @param value value
mbed_official 0:a554658735bf 46 * @param index index
mbed_official 0:a554658735bf 47 * @param buf pointer on a buffer where will be store the data received
mbed_official 0:a554658735bf 48 * @param len length of the transfer
mbed_official 0:a554658735bf 49 *
mbed_official 0:a554658735bf 50 * @returns status of the control read
mbed_official 0:a554658735bf 51 */
mbed_official 0:a554658735bf 52 USB_TYPE controlRead(USBDeviceConnected * dev, uint8_t requestType, uint8_t request, uint32_t value, uint32_t index, uint8_t * buf, uint32_t len);
mbed_official 0:a554658735bf 53
mbed_official 0:a554658735bf 54 /**
mbed_official 0:a554658735bf 55 * Control write: setup stage, data stage and status stage
mbed_official 0:a554658735bf 56 *
mbed_official 0:a554658735bf 57 * @param dev the control write will be done for this device
mbed_official 0:a554658735bf 58 * @param requestType request type
mbed_official 0:a554658735bf 59 * @param request request
mbed_official 0:a554658735bf 60 * @param value value
mbed_official 0:a554658735bf 61 * @param index index
mbed_official 0:a554658735bf 62 * @param buf pointer on a buffer which will be written
mbed_official 0:a554658735bf 63 * @param len length of the transfer
mbed_official 0:a554658735bf 64 *
mbed_official 0:a554658735bf 65 * @returns status of the control write
mbed_official 0:a554658735bf 66 */
mbed_official 0:a554658735bf 67 USB_TYPE controlWrite(USBDeviceConnected * dev, uint8_t requestType, uint8_t request, uint32_t value, uint32_t index, uint8_t * buf, uint32_t len);
mbed_official 0:a554658735bf 68
mbed_official 0:a554658735bf 69 /**
mbed_official 0:a554658735bf 70 * Bulk read
mbed_official 0:a554658735bf 71 *
mbed_official 0:a554658735bf 72 * @param dev the bulk transfer will be done for this device
mbed_official 0:a554658735bf 73 * @param ep USBEndpoint which will be used to read a packet
mbed_official 0:a554658735bf 74 * @param buf pointer on a buffer where will be store the data received
mbed_official 0:a554658735bf 75 * @param len length of the transfer
mbed_official 0:a554658735bf 76 * @param blocking if true, the read is blocking (wait for completion)
mbed_official 0:a554658735bf 77 *
mbed_official 0:a554658735bf 78 * @returns status of the bulk read
mbed_official 0:a554658735bf 79 */
mbed_official 0:a554658735bf 80 USB_TYPE bulkRead(USBDeviceConnected * dev, USBEndpoint * ep, uint8_t * buf, uint32_t len, bool blocking = true);
mbed_official 0:a554658735bf 81
mbed_official 0:a554658735bf 82 /**
mbed_official 0:a554658735bf 83 * Bulk write
mbed_official 0:a554658735bf 84 *
mbed_official 0:a554658735bf 85 * @param dev the bulk transfer will be done for this device
mbed_official 0:a554658735bf 86 * @param ep USBEndpoint which will be used to write a packet
mbed_official 0:a554658735bf 87 * @param buf pointer on a buffer which will be written
mbed_official 0:a554658735bf 88 * @param len length of the transfer
mbed_official 0:a554658735bf 89 * @param blocking if true, the write is blocking (wait for completion)
mbed_official 0:a554658735bf 90 *
mbed_official 0:a554658735bf 91 * @returns status of the bulk write
mbed_official 0:a554658735bf 92 */
mbed_official 0:a554658735bf 93 USB_TYPE bulkWrite(USBDeviceConnected * dev, USBEndpoint * ep, uint8_t * buf, uint32_t len, bool blocking = true);
mbed_official 0:a554658735bf 94
mbed_official 0:a554658735bf 95 /**
mbed_official 0:a554658735bf 96 * Interrupt read
mbed_official 0:a554658735bf 97 *
mbed_official 0:a554658735bf 98 * @param dev the bulk transfer will be done for this device
mbed_official 0:a554658735bf 99 * @param ep USBEndpoint which will be used to write a packet
mbed_official 0:a554658735bf 100 * @param buf pointer on a buffer which will be written
mbed_official 0:a554658735bf 101 * @param len length of the transfer
mbed_official 0:a554658735bf 102 * @param blocking if true, the read is blocking (wait for completion)
mbed_official 0:a554658735bf 103 *
mbed_official 0:a554658735bf 104 * @returns status of the interrupt read
mbed_official 0:a554658735bf 105 */
mbed_official 0:a554658735bf 106 USB_TYPE interruptRead(USBDeviceConnected * dev, USBEndpoint * ep, uint8_t * buf, uint32_t len, bool blocking = true);
mbed_official 0:a554658735bf 107
mbed_official 0:a554658735bf 108 /**
mbed_official 0:a554658735bf 109 * Interrupt write
mbed_official 0:a554658735bf 110 *
mbed_official 0:a554658735bf 111 * @param dev the bulk transfer will be done for this device
mbed_official 0:a554658735bf 112 * @param ep USBEndpoint which will be used to write a packet
mbed_official 0:a554658735bf 113 * @param buf pointer on a buffer which will be written
mbed_official 0:a554658735bf 114 * @param len length of the transfer
mbed_official 0:a554658735bf 115 * @param blocking if true, the write is blocking (wait for completion)
mbed_official 0:a554658735bf 116 *
mbed_official 0:a554658735bf 117 * @returns status of the interrupt write
mbed_official 0:a554658735bf 118 */
mbed_official 0:a554658735bf 119 USB_TYPE interruptWrite(USBDeviceConnected * dev, USBEndpoint * ep, uint8_t * buf, uint32_t len, bool blocking = true);
mbed_official 0:a554658735bf 120
mbed_official 0:a554658735bf 121 /**
mbed_official 0:a554658735bf 122 * Enumerate a device.
mbed_official 0:a554658735bf 123 *
mbed_official 0:a554658735bf 124 * @param dev device which will be enumerated
mbed_official 0:a554658735bf 125 *
mbed_official 0:a554658735bf 126 * @returns status of the enumeration
mbed_official 0:a554658735bf 127 */
mbed_official 0:a554658735bf 128 USB_TYPE enumerate(USBDeviceConnected * dev, IUSBEnumerator* pEnumerator);
mbed_official 0:a554658735bf 129
HinoNaka 41:5c3ebf7372ee 130 #if(1) /* Isochronous */
HinoNaka 41:5c3ebf7372ee 131 inline uint8_t * getConfDescrCurPtr() {
HinoNaka 41:5c3ebf7372ee 132 return &data[indexCnfdDescr];
HinoNaka 41:5c3ebf7372ee 133 };
HinoNaka 41:5c3ebf7372ee 134
HinoNaka 41:5c3ebf7372ee 135 inline uint16_t getConfDescrRestLen() {
HinoNaka 41:5c3ebf7372ee 136 return lenCnfdDescr - indexCnfdDescr;
HinoNaka 41:5c3ebf7372ee 137 };
HinoNaka 41:5c3ebf7372ee 138 #endif
HinoNaka 41:5c3ebf7372ee 139
mbed_official 0:a554658735bf 140 /**
samux 8:93da8ea2708b 141 * reset a specific device
samux 8:93da8ea2708b 142 *
samux 8:93da8ea2708b 143 * @param dev device which will be resetted
samux 8:93da8ea2708b 144 */
samux 8:93da8ea2708b 145 USB_TYPE resetDevice(USBDeviceConnected * dev);
samux 9:7671b6a8c363 146
samux 8:93da8ea2708b 147 /**
mbed_official 0:a554658735bf 148 * Get a device
mbed_official 0:a554658735bf 149 *
mbed_official 0:a554658735bf 150 * @param index index of the device which will be returned
mbed_official 0:a554658735bf 151 *
mbed_official 0:a554658735bf 152 * @returns pointer on the "index" device
mbed_official 0:a554658735bf 153 */
mbed_official 0:a554658735bf 154 USBDeviceConnected * getDevice(uint8_t index);
mbed_official 0:a554658735bf 155
mbed_official 0:a554658735bf 156 /*
mbed_official 0:a554658735bf 157 * If there is a HID device connected, the host stores the length of the report descriptor.
mbed_official 0:a554658735bf 158 * This avoid to the driver to re-ask the configuration descriptor to request the report descriptor
mbed_official 0:a554658735bf 159 *
mbed_official 0:a554658735bf 160 * @returns length of the report descriptor
mbed_official 0:a554658735bf 161 */
mbed_official 0:a554658735bf 162 inline uint16_t getLengthReportDescr() {
mbed_official 0:a554658735bf 163 return lenReportDescr;
mbed_official 0:a554658735bf 164 };
mbed_official 0:a554658735bf 165
mbed_official 0:a554658735bf 166 /**
mbed_official 0:a554658735bf 167 * register a driver into the host associated with a callback function called when the device is disconnected
mbed_official 0:a554658735bf 168 *
mbed_official 0:a554658735bf 169 * @param dev device
samux 4:b320d68e98e7 170 * @param intf interface number
mbed_official 0:a554658735bf 171 * @param tptr pointer to the object to call the member function on
mbed_official 0:a554658735bf 172 * @param mptr pointer to the member function to be called
mbed_official 0:a554658735bf 173 */
mbed_official 0:a554658735bf 174 template<typename T>
mbed_official 0:a554658735bf 175 inline void registerDriver(USBDeviceConnected * dev, uint8_t intf, T* tptr, void (T::*mptr)(void)) {
mbed_official 0:a554658735bf 176 int index = findDevice(dev);
mbed_official 0:a554658735bf 177 if ((index != -1) && (mptr != NULL) && (tptr != NULL)) {
samux 4:b320d68e98e7 178 USB_DBG("register driver for dev: %p on intf: %d", dev, intf);
samux 4:b320d68e98e7 179 deviceAttachedDriver[index][intf] = true;
mbed_official 0:a554658735bf 180 dev->onDisconnect(intf, tptr, mptr);
mbed_official 0:a554658735bf 181 }
mbed_official 0:a554658735bf 182 }
mbed_official 0:a554658735bf 183
mbed_official 0:a554658735bf 184 /**
mbed_official 0:a554658735bf 185 * register a driver into the host associated with a callback function called when the device is disconnected
mbed_official 0:a554658735bf 186 *
mbed_official 0:a554658735bf 187 * @param dev device
samux 4:b320d68e98e7 188 * @param intf interface number
mbed_official 0:a554658735bf 189 * @param fn callback called when the specified device has been disconnected
mbed_official 0:a554658735bf 190 */
mbed_official 0:a554658735bf 191 inline void registerDriver(USBDeviceConnected * dev, uint8_t intf, void (*fn)(void)) {
mbed_official 0:a554658735bf 192 int index = findDevice(dev);
mbed_official 0:a554658735bf 193 if ((index != -1) && (fn != NULL)) {
samux 4:b320d68e98e7 194 USB_DBG("register driver for dev: %p on intf: %d", dev, intf);
samux 4:b320d68e98e7 195 deviceAttachedDriver[index][intf] = true;
mbed_official 0:a554658735bf 196 dev->onDisconnect(intf, fn);
mbed_official 0:a554658735bf 197 }
mbed_official 0:a554658735bf 198 }
mbed_official 24:868cbfe611a7 199
mbed_official 23:759ec18ee1a7 200 /**
mbed_official 23:759ec18ee1a7 201 * Instantiate to protect USB thread from accessing shared objects (USBConnectedDevices and Interfaces)
mbed_official 23:759ec18ee1a7 202 */
mbed_official 23:759ec18ee1a7 203 class Lock
mbed_official 23:759ec18ee1a7 204 {
mbed_official 23:759ec18ee1a7 205 public:
mbed_official 24:868cbfe611a7 206 Lock(USBHost* pHost);
mbed_official 24:868cbfe611a7 207 ~Lock();
mbed_official 23:759ec18ee1a7 208 private:
mbed_official 23:759ec18ee1a7 209 USBHost* m_pHost;
mbed_official 23:759ec18ee1a7 210 };
mbed_official 24:868cbfe611a7 211
samux 8:93da8ea2708b 212 friend class USBHostHub;
samux 8:93da8ea2708b 213
samux 8:93da8ea2708b 214 protected:
samux 8:93da8ea2708b 215
samux 8:93da8ea2708b 216 /**
samux 8:93da8ea2708b 217 * Virtual method called when a transfer has been completed
samux 8:93da8ea2708b 218 *
samux 8:93da8ea2708b 219 * @param addr list of the TDs which have been completed
samux 8:93da8ea2708b 220 */
samux 8:93da8ea2708b 221 virtual void transferCompleted(volatile uint32_t addr);
samux 9:7671b6a8c363 222
mbed_official 0:a554658735bf 223 /**
mbed_official 0:a554658735bf 224 * Virtual method called when a device has been connected
mbed_official 0:a554658735bf 225 *
mbed_official 0:a554658735bf 226 * @param hub hub number of the device
mbed_official 0:a554658735bf 227 * @param port port number of the device
mbed_official 0:a554658735bf 228 * @param lowSpeed 1 if low speed, 0 otherwise
mbed_official 0:a554658735bf 229 * @param hub_parent reference on the parent hub
mbed_official 0:a554658735bf 230 */
mbed_official 0:a554658735bf 231 virtual void deviceConnected(int hub, int port, bool lowSpeed, USBHostHub * hub_parent = NULL);
mbed_official 0:a554658735bf 232
mbed_official 0:a554658735bf 233 /**
mbed_official 0:a554658735bf 234 * Virtuel method called when a device has been disconnected
mbed_official 0:a554658735bf 235 *
mbed_official 0:a554658735bf 236 * @param hub hub number of the device
mbed_official 0:a554658735bf 237 * @param port port number of the device
mbed_official 0:a554658735bf 238 * @param addr list of the TDs which have been completed to dequeue freed TDs
mbed_official 0:a554658735bf 239 */
mbed_official 0:a554658735bf 240 virtual void deviceDisconnected(int hub, int port, USBHostHub * hub_parent, volatile uint32_t addr);
mbed_official 0:a554658735bf 241
mbed_official 0:a554658735bf 242
mbed_official 0:a554658735bf 243 private:
mbed_official 0:a554658735bf 244 // singleton class -> constructor is private
mbed_official 0:a554658735bf 245 USBHost();
mbed_official 0:a554658735bf 246 static USBHost * instHost;
mbed_official 0:a554658735bf 247 uint16_t lenReportDescr;
HinoNaka 41:5c3ebf7372ee 248 #if(1) /* Isochronous */
HinoNaka 41:5c3ebf7372ee 249 uint16_t lenCnfdDescr;
HinoNaka 41:5c3ebf7372ee 250 uint16_t indexCnfdDescr;
HinoNaka 41:5c3ebf7372ee 251 #endif
mbed_official 0:a554658735bf 252
mbed_official 0:a554658735bf 253 // endpoints
mbed_official 0:a554658735bf 254 void unqueueEndpoint(USBEndpoint * ep) ;
mbed_official 0:a554658735bf 255 USBEndpoint endpoints[MAX_ENDPOINT];
mbed_official 0:a554658735bf 256 USBEndpoint* volatile control;
mbed_official 0:a554658735bf 257
mbed_official 0:a554658735bf 258 USBEndpoint* volatile headControlEndpoint;
mbed_official 0:a554658735bf 259 USBEndpoint* volatile headBulkEndpoint;
mbed_official 0:a554658735bf 260 USBEndpoint* volatile headInterruptEndpoint;
mbed_official 0:a554658735bf 261
mbed_official 0:a554658735bf 262 USBEndpoint* volatile tailControlEndpoint;
mbed_official 0:a554658735bf 263 USBEndpoint* volatile tailBulkEndpoint;
mbed_official 0:a554658735bf 264 USBEndpoint* volatile tailInterruptEndpoint;
mbed_official 0:a554658735bf 265
mbed_official 0:a554658735bf 266 bool controlEndpointAllocated;
mbed_official 0:a554658735bf 267
mbed_official 0:a554658735bf 268 // devices connected
mbed_official 0:a554658735bf 269 USBDeviceConnected devices[MAX_DEVICE_CONNECTED];
samux 6:1571e517a91b 270 bool deviceInUse[MAX_DEVICE_CONNECTED];
samux 6:1571e517a91b 271 bool deviceAttachedDriver[MAX_DEVICE_CONNECTED][MAX_INTF];
samux 6:1571e517a91b 272 bool deviceReset[MAX_DEVICE_CONNECTED];
samux 6:1571e517a91b 273 bool deviceInited[MAX_DEVICE_CONNECTED];
mbed_official 24:868cbfe611a7 274
mbed_official 0:a554658735bf 275 #if MAX_HUB_NB
mbed_official 0:a554658735bf 276 USBHostHub hubs[MAX_HUB_NB];
mbed_official 0:a554658735bf 277 bool hub_in_use[MAX_HUB_NB];
mbed_official 0:a554658735bf 278 #endif
mbed_official 0:a554658735bf 279
mbed_official 0:a554658735bf 280 // to store a setup packet
mbed_official 0:a554658735bf 281 uint8_t setupPacket[8];
mbed_official 24:868cbfe611a7 282
mbed_official 0:a554658735bf 283 typedef struct {
mbed_official 0:a554658735bf 284 uint8_t event_id;
mbed_official 0:a554658735bf 285 void * td_addr;
mbed_official 0:a554658735bf 286 uint8_t hub;
mbed_official 0:a554658735bf 287 uint8_t port;
mbed_official 0:a554658735bf 288 uint8_t lowSpeed;
mbed_official 0:a554658735bf 289 uint8_t td_state;
mbed_official 0:a554658735bf 290 void * hub_parent;
mbed_official 0:a554658735bf 291 } message_t;
mbed_official 24:868cbfe611a7 292
mbed_official 0:a554658735bf 293 Thread usbThread;
mbed_official 0:a554658735bf 294 void usb_process();
mbed_official 0:a554658735bf 295 static void usb_process_static(void const * arg);
samux 9:7671b6a8c363 296 Mail<message_t, 10> mail_usb_event;
mbed_official 0:a554658735bf 297 Mutex usb_mutex;
samux 9:7671b6a8c363 298 Mutex td_mutex;
mbed_official 24:868cbfe611a7 299
mbed_official 0:a554658735bf 300 // buffer for conf descriptor
HinoNaka 41:5c3ebf7372ee 301 #if(1) /* Isochronous */
HinoNaka 41:5c3ebf7372ee 302 uint8_t data[1024];
HinoNaka 41:5c3ebf7372ee 303 #else
mbed_official 16:ab8c9118524e 304 uint8_t data[415];
HinoNaka 41:5c3ebf7372ee 305 #endif
mbed_official 24:868cbfe611a7 306
mbed_official 0:a554658735bf 307 /**
mbed_official 0:a554658735bf 308 * Add a transfer on the TD linked list associated to an ED
mbed_official 0:a554658735bf 309 *
mbed_official 0:a554658735bf 310 * @param ed the transfer is associated to this ed
mbed_official 0:a554658735bf 311 * @param buf pointer on a buffer where will be read/write data to send or receive
mbed_official 0:a554658735bf 312 * @param len transfer length
mbed_official 0:a554658735bf 313 *
mbed_official 0:a554658735bf 314 * @return status of the transfer
mbed_official 0:a554658735bf 315 */
mbed_official 0:a554658735bf 316 USB_TYPE addTransfer(USBEndpoint * ed, uint8_t * buf, uint32_t len) ;
mbed_official 24:868cbfe611a7 317
mbed_official 0:a554658735bf 318 /**
mbed_official 0:a554658735bf 319 * Link the USBEndpoint to the linked list and attach an USBEndpoint this USBEndpoint to a device
mbed_official 0:a554658735bf 320 *
mbed_official 0:a554658735bf 321 * @param dev pointer on a USBDeviceConnected object
mbed_official 0:a554658735bf 322 * @param ep pointer on the USBEndpoint which will be added
mbed_official 0:a554658735bf 323 *
mbed_official 0:a554658735bf 324 * return true if successful
mbed_official 0:a554658735bf 325 */
mbed_official 0:a554658735bf 326 bool addEndpoint(USBDeviceConnected * dev, uint8_t intf_nb, USBEndpoint * ep) ;
mbed_official 0:a554658735bf 327
mbed_official 0:a554658735bf 328 /**
mbed_official 0:a554658735bf 329 * Create an USBEndpoint descriptor. Warning: the USBEndpoint is not linked.
mbed_official 0:a554658735bf 330 *
mbed_official 0:a554658735bf 331 * @param type USBEndpoint type (CONTROL_ENDPOINT, BULK_ENDPOINT, INTERRUPT_ENDPOINT)
mbed_official 0:a554658735bf 332 * @param dir USBEndpoint direction (no meaning for CONTROL_ENDPOINT)
mbed_official 0:a554658735bf 333 * @param size USBEndpoint max packet size
mbed_official 0:a554658735bf 334 * @param addr USBEndpoint address
mbed_official 0:a554658735bf 335 *
mbed_official 0:a554658735bf 336 * @returns pointer on the USBEndpoint created
mbed_official 0:a554658735bf 337 */
mbed_official 0:a554658735bf 338 USBEndpoint * newEndpoint(ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir, uint32_t size, uint8_t addr) ;
mbed_official 24:868cbfe611a7 339
mbed_official 0:a554658735bf 340 /**
mbed_official 0:a554658735bf 341 * Request the device descriptor
mbed_official 0:a554658735bf 342 *
mbed_official 0:a554658735bf 343 * @param dev request the device descriptor on this device
mbed_official 0:a554658735bf 344 * @param buf buffer to store the device descriptor
mbed_official 0:a554658735bf 345 * @param max_len_buf maximum size of buf
mbed_official 0:a554658735bf 346 * @param len_dev_descr pointer to store the length of the packet transferred
mbed_official 0:a554658735bf 347 */
mbed_official 0:a554658735bf 348 USB_TYPE getDeviceDescriptor(USBDeviceConnected * dev, uint8_t * buf, uint16_t max_len_buf, uint16_t * len_dev_descr = NULL);
mbed_official 0:a554658735bf 349
mbed_official 0:a554658735bf 350 /**
mbed_official 0:a554658735bf 351 * Request the configuration descriptor
mbed_official 0:a554658735bf 352 *
mbed_official 0:a554658735bf 353 * @param dev request the configuration descriptor on this device
mbed_official 0:a554658735bf 354 * @param buf buffer to store the configuration descriptor
mbed_official 0:a554658735bf 355 * @param max_len_buf maximum size of buf
mbed_official 0:a554658735bf 356 * @param len_conf_descr pointer to store the length of the packet transferred
mbed_official 0:a554658735bf 357 */
mbed_official 0:a554658735bf 358 USB_TYPE getConfigurationDescriptor(USBDeviceConnected * dev, uint8_t * buf, uint16_t max_len_buf, uint16_t * len_conf_descr = NULL);
mbed_official 24:868cbfe611a7 359
mbed_official 0:a554658735bf 360 /**
mbed_official 0:a554658735bf 361 * Set the address of a specific device
mbed_official 0:a554658735bf 362 *
mbed_official 0:a554658735bf 363 * @param dev device to set the address
mbed_official 0:a554658735bf 364 * @param address address
mbed_official 0:a554658735bf 365 */
mbed_official 0:a554658735bf 366 USB_TYPE setAddress(USBDeviceConnected * dev, uint8_t address);
mbed_official 0:a554658735bf 367
mbed_official 0:a554658735bf 368 /**
mbed_official 0:a554658735bf 369 * Set the configuration of a device
mbed_official 0:a554658735bf 370 *
mbed_official 0:a554658735bf 371 * @param dev device on which the specified configuration will be activated
mbed_official 0:a554658735bf 372 * @param conf configuration number to activate (usually 1)
mbed_official 0:a554658735bf 373 */
mbed_official 0:a554658735bf 374 USB_TYPE setConfiguration(USBDeviceConnected * dev, uint8_t conf);
mbed_official 24:868cbfe611a7 375
samux 8:93da8ea2708b 376 /**
samux 8:93da8ea2708b 377 * Free a specific device
samux 8:93da8ea2708b 378 *
samux 8:93da8ea2708b 379 * @param dev device to be freed
samux 8:93da8ea2708b 380 */
samux 8:93da8ea2708b 381 void freeDevice(USBDeviceConnected * dev);
samux 9:7671b6a8c363 382
mbed_official 0:a554658735bf 383 USB_TYPE controlTransfer( USBDeviceConnected * dev,
mbed_official 0:a554658735bf 384 uint8_t requestType,
mbed_official 0:a554658735bf 385 uint8_t request,
mbed_official 0:a554658735bf 386 uint32_t value,
mbed_official 0:a554658735bf 387 uint32_t index,
mbed_official 0:a554658735bf 388 uint8_t * buf,
mbed_official 0:a554658735bf 389 uint32_t len,
mbed_official 0:a554658735bf 390 bool write);
mbed_official 0:a554658735bf 391
mbed_official 0:a554658735bf 392 USB_TYPE generalTransfer( USBDeviceConnected * dev,
mbed_official 0:a554658735bf 393 USBEndpoint * ep,
mbed_official 0:a554658735bf 394 uint8_t * buf,
mbed_official 0:a554658735bf 395 uint32_t len,
mbed_official 0:a554658735bf 396 bool blocking,
mbed_official 0:a554658735bf 397 ENDPOINT_TYPE type,
mbed_official 0:a554658735bf 398 bool write) ;
mbed_official 24:868cbfe611a7 399
mbed_official 0:a554658735bf 400 void fillControlBuf(uint8_t requestType, uint8_t request, uint16_t value, uint16_t index, int len) ;
mbed_official 0:a554658735bf 401 void parseConfDescr(USBDeviceConnected * dev, uint8_t * conf_descr, uint32_t len, IUSBEnumerator* pEnumerator) ;
mbed_official 0:a554658735bf 402 int findDevice(USBDeviceConnected * dev) ;
mbed_official 0:a554658735bf 403 int findDevice(uint8_t hub, uint8_t port, USBHostHub * hub_parent = NULL) ;
samux 4:b320d68e98e7 404 uint8_t numberDriverAttached(USBDeviceConnected * dev);
mbed_official 0:a554658735bf 405
mbed_official 0:a554658735bf 406 /////////////////////////
mbed_official 0:a554658735bf 407 /// FOR DEBUG
mbed_official 0:a554658735bf 408 /////////////////////////
mbed_official 0:a554658735bf 409 void printList(ENDPOINT_TYPE type);
mbed_official 0:a554658735bf 410
mbed_official 0:a554658735bf 411 };
mbed_official 0:a554658735bf 412
mbed_official 0:a554658735bf 413 #endif