Fixing issues with library dependencies

Dependencies:   FATFileSystem mbed-rtos

Fork of USBHost by mbed official

Committer:
mbed_official
Date:
Wed Mar 06 16:27:14 2013 +0000
Revision:
0:a554658735bf
Child:
4:b320d68e98e7
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:a554658735bf 1 /* Copyright (c) 2010-2012 mbed.org, MIT License
mbed_official 0:a554658735bf 2 *
mbed_official 0:a554658735bf 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
mbed_official 0:a554658735bf 4 * and associated documentation files (the "Software"), to deal in the Software without
mbed_official 0:a554658735bf 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
mbed_official 0:a554658735bf 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
mbed_official 0:a554658735bf 7 * Software is furnished to do so, subject to the following conditions:
mbed_official 0:a554658735bf 8 *
mbed_official 0:a554658735bf 9 * The above copyright notice and this permission notice shall be included in all copies or
mbed_official 0:a554658735bf 10 * substantial portions of the Software.
mbed_official 0:a554658735bf 11 *
mbed_official 0:a554658735bf 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
mbed_official 0:a554658735bf 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
mbed_official 0:a554658735bf 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
mbed_official 0:a554658735bf 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mbed_official 0:a554658735bf 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
mbed_official 0:a554658735bf 17 */
mbed_official 0:a554658735bf 18
mbed_official 0:a554658735bf 19 #ifndef USBHOST_H
mbed_official 0:a554658735bf 20 #define USBHOST_H
mbed_official 0:a554658735bf 21
mbed_official 0:a554658735bf 22 #include "USBHALHost.h"
mbed_official 0:a554658735bf 23 #include "USBDeviceConnected.h"
mbed_official 0:a554658735bf 24 #include "IUSBEnumerator.h"
mbed_official 0:a554658735bf 25 #include "USBHostConf.h"
mbed_official 0:a554658735bf 26 #include "rtos.h"
mbed_official 0:a554658735bf 27 #include "dbg.h"
mbed_official 0:a554658735bf 28 #include "USBHostHub.h"
mbed_official 0:a554658735bf 29
mbed_official 0:a554658735bf 30 // singleton class
mbed_official 0:a554658735bf 31 class USBHost : public USBHALHost {
mbed_official 0:a554658735bf 32 public:
mbed_official 0:a554658735bf 33 /**
mbed_official 0:a554658735bf 34 * Static method to create or retrieve the single USBHost instance
mbed_official 0:a554658735bf 35 */
mbed_official 0:a554658735bf 36 static USBHost * getHostInst();
mbed_official 0:a554658735bf 37
mbed_official 0:a554658735bf 38 /**
mbed_official 0:a554658735bf 39 * Control read: setup stage, data stage and status stage
mbed_official 0:a554658735bf 40 *
mbed_official 0:a554658735bf 41 * @param dev the control read will be done for this device
mbed_official 0:a554658735bf 42 * @param requestType request type
mbed_official 0:a554658735bf 43 * @param request request
mbed_official 0:a554658735bf 44 * @param value value
mbed_official 0:a554658735bf 45 * @param index index
mbed_official 0:a554658735bf 46 * @param buf pointer on a buffer where will be store the data received
mbed_official 0:a554658735bf 47 * @param len length of the transfer
mbed_official 0:a554658735bf 48 *
mbed_official 0:a554658735bf 49 * @returns status of the control read
mbed_official 0:a554658735bf 50 */
mbed_official 0:a554658735bf 51 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 52
mbed_official 0:a554658735bf 53 /**
mbed_official 0:a554658735bf 54 * Control write: setup stage, data stage and status stage
mbed_official 0:a554658735bf 55 *
mbed_official 0:a554658735bf 56 * @param dev the control write will be done for this device
mbed_official 0:a554658735bf 57 * @param requestType request type
mbed_official 0:a554658735bf 58 * @param request request
mbed_official 0:a554658735bf 59 * @param value value
mbed_official 0:a554658735bf 60 * @param index index
mbed_official 0:a554658735bf 61 * @param buf pointer on a buffer which will be written
mbed_official 0:a554658735bf 62 * @param len length of the transfer
mbed_official 0:a554658735bf 63 *
mbed_official 0:a554658735bf 64 * @returns status of the control write
mbed_official 0:a554658735bf 65 */
mbed_official 0:a554658735bf 66 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 67
mbed_official 0:a554658735bf 68 /**
mbed_official 0:a554658735bf 69 * Bulk read
mbed_official 0:a554658735bf 70 *
mbed_official 0:a554658735bf 71 * @param dev the bulk transfer will be done for this device
mbed_official 0:a554658735bf 72 * @param ep USBEndpoint which will be used to read a packet
mbed_official 0:a554658735bf 73 * @param buf pointer on a buffer where will be store the data received
mbed_official 0:a554658735bf 74 * @param len length of the transfer
mbed_official 0:a554658735bf 75 * @param blocking if true, the read is blocking (wait for completion)
mbed_official 0:a554658735bf 76 *
mbed_official 0:a554658735bf 77 * @returns status of the bulk read
mbed_official 0:a554658735bf 78 */
mbed_official 0:a554658735bf 79 USB_TYPE bulkRead(USBDeviceConnected * dev, USBEndpoint * ep, uint8_t * buf, uint32_t len, bool blocking = true);
mbed_official 0:a554658735bf 80
mbed_official 0:a554658735bf 81 /**
mbed_official 0:a554658735bf 82 * Bulk write
mbed_official 0:a554658735bf 83 *
mbed_official 0:a554658735bf 84 * @param dev the bulk transfer will be done for this device
mbed_official 0:a554658735bf 85 * @param ep USBEndpoint which will be used to write a packet
mbed_official 0:a554658735bf 86 * @param buf pointer on a buffer which will be written
mbed_official 0:a554658735bf 87 * @param len length of the transfer
mbed_official 0:a554658735bf 88 * @param blocking if true, the write is blocking (wait for completion)
mbed_official 0:a554658735bf 89 *
mbed_official 0:a554658735bf 90 * @returns status of the bulk write
mbed_official 0:a554658735bf 91 */
mbed_official 0:a554658735bf 92 USB_TYPE bulkWrite(USBDeviceConnected * dev, USBEndpoint * ep, uint8_t * buf, uint32_t len, bool blocking = true);
mbed_official 0:a554658735bf 93
mbed_official 0:a554658735bf 94 /**
mbed_official 0:a554658735bf 95 * Interrupt read
mbed_official 0:a554658735bf 96 *
mbed_official 0:a554658735bf 97 * @param dev the bulk transfer will be done for this device
mbed_official 0:a554658735bf 98 * @param ep USBEndpoint which will be used to write a packet
mbed_official 0:a554658735bf 99 * @param buf pointer on a buffer which will be written
mbed_official 0:a554658735bf 100 * @param len length of the transfer
mbed_official 0:a554658735bf 101 * @param blocking if true, the read is blocking (wait for completion)
mbed_official 0:a554658735bf 102 *
mbed_official 0:a554658735bf 103 * @returns status of the interrupt read
mbed_official 0:a554658735bf 104 */
mbed_official 0:a554658735bf 105 USB_TYPE interruptRead(USBDeviceConnected * dev, USBEndpoint * ep, uint8_t * buf, uint32_t len, bool blocking = true);
mbed_official 0:a554658735bf 106
mbed_official 0:a554658735bf 107 /**
mbed_official 0:a554658735bf 108 * Interrupt write
mbed_official 0:a554658735bf 109 *
mbed_official 0:a554658735bf 110 * @param dev the bulk transfer will be done for this device
mbed_official 0:a554658735bf 111 * @param ep USBEndpoint which will be used to write a packet
mbed_official 0:a554658735bf 112 * @param buf pointer on a buffer which will be written
mbed_official 0:a554658735bf 113 * @param len length of the transfer
mbed_official 0:a554658735bf 114 * @param blocking if true, the write is blocking (wait for completion)
mbed_official 0:a554658735bf 115 *
mbed_official 0:a554658735bf 116 * @returns status of the interrupt write
mbed_official 0:a554658735bf 117 */
mbed_official 0:a554658735bf 118 USB_TYPE interruptWrite(USBDeviceConnected * dev, USBEndpoint * ep, uint8_t * buf, uint32_t len, bool blocking = true);
mbed_official 0:a554658735bf 119
mbed_official 0:a554658735bf 120 /**
mbed_official 0:a554658735bf 121 * Enumerate a device.
mbed_official 0:a554658735bf 122 *
mbed_official 0:a554658735bf 123 * @param dev device which will be enumerated
mbed_official 0:a554658735bf 124 *
mbed_official 0:a554658735bf 125 * @returns status of the enumeration
mbed_official 0:a554658735bf 126 */
mbed_official 0:a554658735bf 127 USB_TYPE enumerate(USBDeviceConnected * dev, IUSBEnumerator* pEnumerator);
mbed_official 0:a554658735bf 128
mbed_official 0:a554658735bf 129 /**
mbed_official 0:a554658735bf 130 * Get a device
mbed_official 0:a554658735bf 131 *
mbed_official 0:a554658735bf 132 * @param index index of the device which will be returned
mbed_official 0:a554658735bf 133 *
mbed_official 0:a554658735bf 134 * @returns pointer on the "index" device
mbed_official 0:a554658735bf 135 */
mbed_official 0:a554658735bf 136 USBDeviceConnected * getDevice(uint8_t index);
mbed_official 0:a554658735bf 137
mbed_official 0:a554658735bf 138 /*
mbed_official 0:a554658735bf 139 * reset a specific device
mbed_official 0:a554658735bf 140 *
mbed_official 0:a554658735bf 141 * @param dev device which will be resetted
mbed_official 0:a554658735bf 142 */
mbed_official 0:a554658735bf 143 USB_TYPE resetDevice(USBDeviceConnected * dev);
mbed_official 0:a554658735bf 144
mbed_official 0:a554658735bf 145 /**
mbed_official 0:a554658735bf 146 * If there is a HID device connected, the host stores the length of the report descriptor.
mbed_official 0:a554658735bf 147 * This avoid to the driver to re-ask the configuration descriptor to request the report descriptor
mbed_official 0:a554658735bf 148 *
mbed_official 0:a554658735bf 149 * @returns length of the report descriptor
mbed_official 0:a554658735bf 150 */
mbed_official 0:a554658735bf 151 inline uint16_t getLengthReportDescr() {
mbed_official 0:a554658735bf 152 return lenReportDescr;
mbed_official 0:a554658735bf 153 };
mbed_official 0:a554658735bf 154
mbed_official 0:a554658735bf 155 /**
mbed_official 0:a554658735bf 156 * register a driver into the host associated with a callback function called when the device is disconnected
mbed_official 0:a554658735bf 157 *
mbed_official 0:a554658735bf 158 * @param dev device
mbed_official 0:a554658735bf 159 * @param tptr pointer to the object to call the member function on
mbed_official 0:a554658735bf 160 * @param mptr pointer to the member function to be called
mbed_official 0:a554658735bf 161 */
mbed_official 0:a554658735bf 162 template<typename T>
mbed_official 0:a554658735bf 163 inline void registerDriver(USBDeviceConnected * dev, uint8_t intf, T* tptr, void (T::*mptr)(void)) {
mbed_official 0:a554658735bf 164 int index = findDevice(dev);
mbed_official 0:a554658735bf 165 if ((index != -1) && (mptr != NULL) && (tptr != NULL)) {
mbed_official 0:a554658735bf 166 USB_DBG("register driver for dev: %p", dev);
mbed_official 0:a554658735bf 167 deviceAttachedDriver[index] = true;
mbed_official 0:a554658735bf 168 dev->onDisconnect(intf, tptr, mptr);
mbed_official 0:a554658735bf 169 }
mbed_official 0:a554658735bf 170 }
mbed_official 0:a554658735bf 171
mbed_official 0:a554658735bf 172 /**
mbed_official 0:a554658735bf 173 * register a driver into the host associated with a callback function called when the device is disconnected
mbed_official 0:a554658735bf 174 *
mbed_official 0:a554658735bf 175 * @param dev device
mbed_official 0:a554658735bf 176 * @param fn callback called when the specified device has been disconnected
mbed_official 0:a554658735bf 177 */
mbed_official 0:a554658735bf 178 inline void registerDriver(USBDeviceConnected * dev, uint8_t intf, void (*fn)(void)) {
mbed_official 0:a554658735bf 179 int index = findDevice(dev);
mbed_official 0:a554658735bf 180 if ((index != -1) && (fn != NULL)) {
mbed_official 0:a554658735bf 181 USB_DBG("register driver for dev: %p", dev);
mbed_official 0:a554658735bf 182 deviceAttachedDriver[index] = true;
mbed_official 0:a554658735bf 183 dev->onDisconnect(intf, fn);
mbed_official 0:a554658735bf 184 }
mbed_official 0:a554658735bf 185 }
mbed_official 0:a554658735bf 186
mbed_official 0:a554658735bf 187 /**
mbed_official 0:a554658735bf 188 * Virtual method called when a device has been connected
mbed_official 0:a554658735bf 189 *
mbed_official 0:a554658735bf 190 * @param hub hub number of the device
mbed_official 0:a554658735bf 191 * @param port port number of the device
mbed_official 0:a554658735bf 192 * @param lowSpeed 1 if low speed, 0 otherwise
mbed_official 0:a554658735bf 193 * @param hub_parent reference on the parent hub
mbed_official 0:a554658735bf 194 */
mbed_official 0:a554658735bf 195 virtual void deviceConnected(int hub, int port, bool lowSpeed, USBHostHub * hub_parent = NULL);
mbed_official 0:a554658735bf 196
mbed_official 0:a554658735bf 197 /**
mbed_official 0:a554658735bf 198 * Virtuel method called when a device has been disconnected
mbed_official 0:a554658735bf 199 *
mbed_official 0:a554658735bf 200 * @param hub hub number of the device
mbed_official 0:a554658735bf 201 * @param port port number of the device
mbed_official 0:a554658735bf 202 * @param addr list of the TDs which have been completed to dequeue freed TDs
mbed_official 0:a554658735bf 203 */
mbed_official 0:a554658735bf 204 virtual void deviceDisconnected(int hub, int port, USBHostHub * hub_parent, volatile uint32_t addr);
mbed_official 0:a554658735bf 205
mbed_official 0:a554658735bf 206 /**
mbed_official 0:a554658735bf 207 * Free a specific device
mbed_official 0:a554658735bf 208 *
mbed_official 0:a554658735bf 209 * @param dev device to be freed
mbed_official 0:a554658735bf 210 */
mbed_official 0:a554658735bf 211 void freeDevice(USBDeviceConnected * dev);
mbed_official 0:a554658735bf 212
mbed_official 0:a554658735bf 213 protected:
mbed_official 0:a554658735bf 214
mbed_official 0:a554658735bf 215 /**
mbed_official 0:a554658735bf 216 * Virtual method called when a transfer has been completed
mbed_official 0:a554658735bf 217 *
mbed_official 0:a554658735bf 218 * @param addr list of the TDs which have been completed
mbed_official 0:a554658735bf 219 */
mbed_official 0:a554658735bf 220 virtual void transferCompleted(volatile uint32_t addr) ;
mbed_official 0:a554658735bf 221
mbed_official 0:a554658735bf 222
mbed_official 0:a554658735bf 223 private:
mbed_official 0:a554658735bf 224 // singleton class -> constructor is private
mbed_official 0:a554658735bf 225 USBHost();
mbed_official 0:a554658735bf 226 static USBHost * instHost;
mbed_official 0:a554658735bf 227 uint16_t lenReportDescr;
mbed_official 0:a554658735bf 228
mbed_official 0:a554658735bf 229 // endpoints
mbed_official 0:a554658735bf 230 void unqueueEndpoint(USBEndpoint * ep) ;
mbed_official 0:a554658735bf 231 USBEndpoint endpoints[MAX_ENDPOINT];
mbed_official 0:a554658735bf 232 USBEndpoint* volatile control;
mbed_official 0:a554658735bf 233
mbed_official 0:a554658735bf 234 USBEndpoint* volatile headControlEndpoint;
mbed_official 0:a554658735bf 235 USBEndpoint* volatile headBulkEndpoint;
mbed_official 0:a554658735bf 236 USBEndpoint* volatile headInterruptEndpoint;
mbed_official 0:a554658735bf 237
mbed_official 0:a554658735bf 238 USBEndpoint* volatile tailControlEndpoint;
mbed_official 0:a554658735bf 239 USBEndpoint* volatile tailBulkEndpoint;
mbed_official 0:a554658735bf 240 USBEndpoint* volatile tailInterruptEndpoint;
mbed_official 0:a554658735bf 241
mbed_official 0:a554658735bf 242 bool controlEndpointAllocated;
mbed_official 0:a554658735bf 243
mbed_official 0:a554658735bf 244 // devices connected
mbed_official 0:a554658735bf 245 USBDeviceConnected devices[MAX_DEVICE_CONNECTED];
mbed_official 0:a554658735bf 246 volatile bool deviceInUse[MAX_DEVICE_CONNECTED];
mbed_official 0:a554658735bf 247 volatile bool deviceAttachedDriver[MAX_DEVICE_CONNECTED];
mbed_official 0:a554658735bf 248 volatile bool deviceReset[MAX_DEVICE_CONNECTED];
mbed_official 0:a554658735bf 249
mbed_official 0:a554658735bf 250 #if MAX_HUB_NB
mbed_official 0:a554658735bf 251 USBHostHub hubs[MAX_HUB_NB];
mbed_official 0:a554658735bf 252 bool hub_in_use[MAX_HUB_NB];
mbed_official 0:a554658735bf 253 #endif
mbed_official 0:a554658735bf 254
mbed_official 0:a554658735bf 255 // to store a setup packet
mbed_official 0:a554658735bf 256 uint8_t setupPacket[8];
mbed_official 0:a554658735bf 257
mbed_official 0:a554658735bf 258 typedef struct {
mbed_official 0:a554658735bf 259 uint8_t event_id;
mbed_official 0:a554658735bf 260 void * td_addr;
mbed_official 0:a554658735bf 261 uint8_t hub;
mbed_official 0:a554658735bf 262 uint8_t port;
mbed_official 0:a554658735bf 263 uint8_t lowSpeed;
mbed_official 0:a554658735bf 264 uint8_t td_state;
mbed_official 0:a554658735bf 265 void * hub_parent;
mbed_official 0:a554658735bf 266 } message_t;
mbed_official 0:a554658735bf 267
mbed_official 0:a554658735bf 268 Thread usbThread;
mbed_official 0:a554658735bf 269 void usb_process();
mbed_official 0:a554658735bf 270 static void usb_process_static(void const * arg);
mbed_official 0:a554658735bf 271 MemoryPool<message_t, 10> mpool_usb_event;
mbed_official 0:a554658735bf 272 Queue<message_t, 10> queue_usb_event;
mbed_official 0:a554658735bf 273 Mutex usb_mutex;
mbed_official 0:a554658735bf 274
mbed_official 0:a554658735bf 275 // buffer for conf descriptor
mbed_official 0:a554658735bf 276 uint8_t data[400];
mbed_official 0:a554658735bf 277
mbed_official 0:a554658735bf 278 /**
mbed_official 0:a554658735bf 279 * Add a transfer on the TD linked list associated to an ED
mbed_official 0:a554658735bf 280 *
mbed_official 0:a554658735bf 281 * @param ed the transfer is associated to this ed
mbed_official 0:a554658735bf 282 * @param buf pointer on a buffer where will be read/write data to send or receive
mbed_official 0:a554658735bf 283 * @param len transfer length
mbed_official 0:a554658735bf 284 *
mbed_official 0:a554658735bf 285 * @return status of the transfer
mbed_official 0:a554658735bf 286 */
mbed_official 0:a554658735bf 287 USB_TYPE addTransfer(USBEndpoint * ed, uint8_t * buf, uint32_t len) ;
mbed_official 0:a554658735bf 288
mbed_official 0:a554658735bf 289 /**
mbed_official 0:a554658735bf 290 * Link the USBEndpoint to the linked list and attach an USBEndpoint this USBEndpoint to a device
mbed_official 0:a554658735bf 291 *
mbed_official 0:a554658735bf 292 * @param dev pointer on a USBDeviceConnected object
mbed_official 0:a554658735bf 293 * @param ep pointer on the USBEndpoint which will be added
mbed_official 0:a554658735bf 294 *
mbed_official 0:a554658735bf 295 * return true if successful
mbed_official 0:a554658735bf 296 */
mbed_official 0:a554658735bf 297 bool addEndpoint(USBDeviceConnected * dev, uint8_t intf_nb, USBEndpoint * ep) ;
mbed_official 0:a554658735bf 298
mbed_official 0:a554658735bf 299 /**
mbed_official 0:a554658735bf 300 * Create an USBEndpoint descriptor. Warning: the USBEndpoint is not linked.
mbed_official 0:a554658735bf 301 *
mbed_official 0:a554658735bf 302 * @param type USBEndpoint type (CONTROL_ENDPOINT, BULK_ENDPOINT, INTERRUPT_ENDPOINT)
mbed_official 0:a554658735bf 303 * @param dir USBEndpoint direction (no meaning for CONTROL_ENDPOINT)
mbed_official 0:a554658735bf 304 * @param size USBEndpoint max packet size
mbed_official 0:a554658735bf 305 * @param addr USBEndpoint address
mbed_official 0:a554658735bf 306 *
mbed_official 0:a554658735bf 307 * @returns pointer on the USBEndpoint created
mbed_official 0:a554658735bf 308 */
mbed_official 0:a554658735bf 309 USBEndpoint * newEndpoint(ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir, uint32_t size, uint8_t addr) ;
mbed_official 0:a554658735bf 310
mbed_official 0:a554658735bf 311 /**
mbed_official 0:a554658735bf 312 * Request the device descriptor
mbed_official 0:a554658735bf 313 *
mbed_official 0:a554658735bf 314 * @param dev request the device descriptor on this device
mbed_official 0:a554658735bf 315 * @param buf buffer to store the device descriptor
mbed_official 0:a554658735bf 316 * @param max_len_buf maximum size of buf
mbed_official 0:a554658735bf 317 * @param len_dev_descr pointer to store the length of the packet transferred
mbed_official 0:a554658735bf 318 */
mbed_official 0:a554658735bf 319 USB_TYPE getDeviceDescriptor(USBDeviceConnected * dev, uint8_t * buf, uint16_t max_len_buf, uint16_t * len_dev_descr = NULL);
mbed_official 0:a554658735bf 320
mbed_official 0:a554658735bf 321 /**
mbed_official 0:a554658735bf 322 * Request the configuration descriptor
mbed_official 0:a554658735bf 323 *
mbed_official 0:a554658735bf 324 * @param dev request the configuration descriptor on this device
mbed_official 0:a554658735bf 325 * @param buf buffer to store the configuration descriptor
mbed_official 0:a554658735bf 326 * @param max_len_buf maximum size of buf
mbed_official 0:a554658735bf 327 * @param len_conf_descr pointer to store the length of the packet transferred
mbed_official 0:a554658735bf 328 */
mbed_official 0:a554658735bf 329 USB_TYPE getConfigurationDescriptor(USBDeviceConnected * dev, uint8_t * buf, uint16_t max_len_buf, uint16_t * len_conf_descr = NULL);
mbed_official 0:a554658735bf 330
mbed_official 0:a554658735bf 331 /**
mbed_official 0:a554658735bf 332 * Set the address of a specific device
mbed_official 0:a554658735bf 333 *
mbed_official 0:a554658735bf 334 * @param dev device to set the address
mbed_official 0:a554658735bf 335 * @param address address
mbed_official 0:a554658735bf 336 */
mbed_official 0:a554658735bf 337 USB_TYPE setAddress(USBDeviceConnected * dev, uint8_t address);
mbed_official 0:a554658735bf 338
mbed_official 0:a554658735bf 339 /**
mbed_official 0:a554658735bf 340 * Set the configuration of a device
mbed_official 0:a554658735bf 341 *
mbed_official 0:a554658735bf 342 * @param dev device on which the specified configuration will be activated
mbed_official 0:a554658735bf 343 * @param conf configuration number to activate (usually 1)
mbed_official 0:a554658735bf 344 */
mbed_official 0:a554658735bf 345 USB_TYPE setConfiguration(USBDeviceConnected * dev, uint8_t conf);
mbed_official 0:a554658735bf 346
mbed_official 0:a554658735bf 347 USB_TYPE controlTransfer( USBDeviceConnected * dev,
mbed_official 0:a554658735bf 348 uint8_t requestType,
mbed_official 0:a554658735bf 349 uint8_t request,
mbed_official 0:a554658735bf 350 uint32_t value,
mbed_official 0:a554658735bf 351 uint32_t index,
mbed_official 0:a554658735bf 352 uint8_t * buf,
mbed_official 0:a554658735bf 353 uint32_t len,
mbed_official 0:a554658735bf 354 bool write);
mbed_official 0:a554658735bf 355
mbed_official 0:a554658735bf 356 USB_TYPE generalTransfer( USBDeviceConnected * dev,
mbed_official 0:a554658735bf 357 USBEndpoint * ep,
mbed_official 0:a554658735bf 358 uint8_t * buf,
mbed_official 0:a554658735bf 359 uint32_t len,
mbed_official 0:a554658735bf 360 bool blocking,
mbed_official 0:a554658735bf 361 ENDPOINT_TYPE type,
mbed_official 0:a554658735bf 362 bool write) ;
mbed_official 0:a554658735bf 363
mbed_official 0:a554658735bf 364 void fillControlBuf(uint8_t requestType, uint8_t request, uint16_t value, uint16_t index, int len) ;
mbed_official 0:a554658735bf 365 void parseConfDescr(USBDeviceConnected * dev, uint8_t * conf_descr, uint32_t len, IUSBEnumerator* pEnumerator) ;
mbed_official 0:a554658735bf 366 int findDevice(USBDeviceConnected * dev) ;
mbed_official 0:a554658735bf 367 int findDevice(uint8_t hub, uint8_t port, USBHostHub * hub_parent = NULL) ;
mbed_official 0:a554658735bf 368
mbed_official 0:a554658735bf 369 /////////////////////////
mbed_official 0:a554658735bf 370 /// FOR DEBUG
mbed_official 0:a554658735bf 371 /////////////////////////
mbed_official 0:a554658735bf 372 void printList(ENDPOINT_TYPE type);
mbed_official 0:a554658735bf 373
mbed_official 0:a554658735bf 374 };
mbed_official 0:a554658735bf 375
mbed_official 0:a554658735bf 376 #endif
mbed_official 0:a554658735bf 377