Opencv 3.1 project on GR-PEACH board

Fork of gr-peach-opencv-project by the do

Committer:
thedo
Date:
Thu Jun 29 11:00:41 2017 +0000
Revision:
166:3a9487d57a5c
This is Opencv 3.1 project on GR-PEACH board

Who changed what in which revision?

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