|
|
|
|
|
|
|
|
/************************************************/ |
|
|
/************************************************/ |
|
|
|
|
|
|
|
|
class USBHost; |
|
|
class USBHost; |
|
|
class USBHostDriver; |
|
|
|
|
|
|
|
|
class USBDriver; |
|
|
typedef struct Device_struct Device_t; |
|
|
typedef struct Device_struct Device_t; |
|
|
typedef struct Pipe_struct Pipe_t; |
|
|
typedef struct Pipe_struct Pipe_t; |
|
|
typedef struct Transfer_struct Transfer_t; |
|
|
typedef struct Transfer_struct Transfer_t; |
|
|
|
|
|
|
|
|
Pipe_t *control_pipe; |
|
|
Pipe_t *control_pipe; |
|
|
Device_t *next; |
|
|
Device_t *next; |
|
|
setup_t setup; // TODO: move this to static in enumeration.cpp |
|
|
setup_t setup; // TODO: move this to static in enumeration.cpp |
|
|
USBHostDriver *drivers; |
|
|
|
|
|
|
|
|
USBDriver *drivers; |
|
|
uint8_t speed; // 0=12, 1=1.5, 2=480 Mbit/sec |
|
|
uint8_t speed; // 0=12, 1=1.5, 2=480 Mbit/sec |
|
|
uint8_t address; |
|
|
uint8_t address; |
|
|
uint8_t hub_address; |
|
|
uint8_t hub_address; |
|
|
|
|
|
|
|
|
static bool new_Transfer(Pipe_t *pipe, void *buffer, uint32_t len); |
|
|
static bool new_Transfer(Pipe_t *pipe, void *buffer, uint32_t len); |
|
|
static Device_t * new_Device(uint32_t speed, uint32_t hub_addr, uint32_t hub_port); |
|
|
static Device_t * new_Device(uint32_t speed, uint32_t hub_addr, uint32_t hub_port); |
|
|
static void enumeration(const Transfer_t *transfer); |
|
|
static void enumeration(const Transfer_t *transfer); |
|
|
static void driver_ready_for_device(USBHostDriver *driver); |
|
|
|
|
|
|
|
|
static void driver_ready_for_device(USBDriver *driver); |
|
|
private: |
|
|
private: |
|
|
static void isr(); |
|
|
static void isr(); |
|
|
static void claim_drivers(Device_t *dev); |
|
|
static void claim_drivers(Device_t *dev); |
|
|
|
|
|
|
|
|
s.word1 = bmRequestType | (bRequest << 8) | (wValue << 16); |
|
|
s.word1 = bmRequestType | (bRequest << 8) | (wValue << 16); |
|
|
s.word2 = wIndex | (wLength << 16); |
|
|
s.word2 = wIndex | (wLength << 16); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************/ |
|
|
/************************************************/ |
|
|
/* USB Device Drivers */ |
|
|
|
|
|
|
|
|
/* USB Device Driver Common Base Class */ |
|
|
/************************************************/ |
|
|
/************************************************/ |
|
|
|
|
|
|
|
|
class USBHostDriver : public USBHost { |
|
|
|
|
|
|
|
|
// All USB device drivers inherit from this base class. |
|
|
|
|
|
class USBDriver : public USBHost { |
|
|
protected: |
|
|
protected: |
|
|
USBHostDriver() : next(NULL), device(NULL) {} |
|
|
|
|
|
|
|
|
USBDriver() : next(NULL), device(NULL) {} |
|
|
// Check if a driver wishes to claim a device or interface or group |
|
|
// Check if a driver wishes to claim a device or interface or group |
|
|
// of interfaces within a device. When this function returns true, |
|
|
// of interfaces within a device. When this function returns true, |
|
|
// the driver is considered bound or loaded for that device. When |
|
|
// the driver is considered bound or loaded for that device. When |
|
|
|
|
|
|
|
|
// (not bound to any device) drivers are linked from |
|
|
// (not bound to any device) drivers are linked from |
|
|
// available_drivers is enumeration.cpp. When bound to a device, |
|
|
// available_drivers is enumeration.cpp. When bound to a device, |
|
|
// drivers are linked from that Device_t drivers list. |
|
|
// drivers are linked from that Device_t drivers list. |
|
|
USBHostDriver *next; |
|
|
|
|
|
|
|
|
USBDriver *next; |
|
|
// When not bound to any device, this must be NULL. |
|
|
// When not bound to any device, this must be NULL. |
|
|
Device_t *device; |
|
|
Device_t *device; |
|
|
friend class USBHost; |
|
|
friend class USBHost; |
|
|
|
|
|
|
|
|
// query string: manufacturer, product, serial number |
|
|
// query string: manufacturer, product, serial number |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
class USBHub : public USBHostDriver { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************/ |
|
|
|
|
|
/* USB Device Drivers */ |
|
|
|
|
|
/************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
class USBHub : public USBDriver { |
|
|
public: |
|
|
public: |
|
|
USBHub(); |
|
|
USBHub(); |
|
|
protected: |
|
|
protected: |