|
|
|
|
|
|
|
|
|
|
|
|
|
|
class USBHub : public USBDriver { |
|
|
class USBHub : public USBDriver { |
|
|
public: |
|
|
public: |
|
|
USBHub(); |
|
|
|
|
|
|
|
|
USBHub(USBHost &host) : debouncetimer(this), resettimer(this) { init(); } |
|
|
|
|
|
USBHub(USBHost *host) : debouncetimer(this), resettimer(this) { init(); } |
|
|
// Hubs with more more than 7 ports are built from two tiers of hubs |
|
|
// Hubs with more more than 7 ports are built from two tiers of hubs |
|
|
// using 4 or 7 port hub chips. While the USB spec seems to allow |
|
|
// using 4 or 7 port hub chips. While the USB spec seems to allow |
|
|
// hubs to have up to 255 ports, in practice all hub chips on the |
|
|
// hubs to have up to 255 ports, in practice all hub chips on the |
|
|
|
|
|
|
|
|
virtual void control(const Transfer_t *transfer); |
|
|
virtual void control(const Transfer_t *transfer); |
|
|
virtual void timer_event(USBDriverTimer *whichTimer); |
|
|
virtual void timer_event(USBDriverTimer *whichTimer); |
|
|
virtual void disconnect(); |
|
|
virtual void disconnect(); |
|
|
|
|
|
void init(); |
|
|
bool can_send_control_now(); |
|
|
bool can_send_control_now(); |
|
|
void send_poweron(uint32_t port); |
|
|
void send_poweron(uint32_t port); |
|
|
void send_getstatus(uint32_t port); |
|
|
void send_getstatus(uint32_t port); |
|
|
|
|
|
|
|
|
void new_port_status(uint32_t port, uint32_t status); |
|
|
void new_port_status(uint32_t port, uint32_t status); |
|
|
void start_debounce_timer(uint32_t port); |
|
|
void start_debounce_timer(uint32_t port); |
|
|
void stop_debounce_timer(uint32_t port); |
|
|
void stop_debounce_timer(uint32_t port); |
|
|
static volatile bool reset_busy; |
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
Device_t mydevices[MAXPORTS]; |
|
|
|
|
|
Pipe_t mypipes[2] __attribute__ ((aligned(32))); |
|
|
|
|
|
Transfer_t mytransfers[4] __attribute__ ((aligned(32))); |
|
|
USBDriverTimer debouncetimer; |
|
|
USBDriverTimer debouncetimer; |
|
|
USBDriverTimer resettimer; |
|
|
USBDriverTimer resettimer; |
|
|
setup_t setup; |
|
|
setup_t setup; |
|
|
|
|
|
|
|
|
portbitmask_t send_pending_clearstatus_reset; |
|
|
portbitmask_t send_pending_clearstatus_reset; |
|
|
portbitmask_t send_pending_setreset; |
|
|
portbitmask_t send_pending_setreset; |
|
|
portbitmask_t debounce_in_use; |
|
|
portbitmask_t debounce_in_use; |
|
|
Device_t mydevices[MAXPORTS]; |
|
|
|
|
|
Pipe_t mypipes[2] __attribute__ ((aligned(32))); |
|
|
|
|
|
Transfer_t mytransfers[4] __attribute__ ((aligned(32))); |
|
|
|
|
|
|
|
|
static volatile bool reset_busy; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
class KeyboardController : public USBDriver { |
|
|
class KeyboardController : public USBDriver { |
|
|
public: |
|
|
public: |
|
|
KeyboardController(); |
|
|
|
|
|
|
|
|
KeyboardController(USBHost &host) { init(); } |
|
|
|
|
|
KeyboardController(USBHost *host) { init(); } |
|
|
int available(); |
|
|
int available(); |
|
|
int read(); |
|
|
int read(); |
|
|
uint8_t getKey(); |
|
|
uint8_t getKey(); |
|
|
|
|
|
|
|
|
virtual void disconnect(); |
|
|
virtual void disconnect(); |
|
|
static void callback(const Transfer_t *transfer); |
|
|
static void callback(const Transfer_t *transfer); |
|
|
void new_data(const Transfer_t *transfer); |
|
|
void new_data(const Transfer_t *transfer); |
|
|
|
|
|
void init(); |
|
|
private: |
|
|
private: |
|
|
void (*keyPressedFunction)(); |
|
|
void (*keyPressedFunction)(); |
|
|
void (*keyReleasedFunction)(); |
|
|
void (*keyReleasedFunction)(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MIDIDevice : public USBDriver { |
|
|
class MIDIDevice : public USBDriver { |
|
|
public: |
|
|
public: |
|
|
MIDIDevice(); |
|
|
|
|
|
|
|
|
MIDIDevice(USBHost &host) { init(); } |
|
|
|
|
|
MIDIDevice(USBHost *host) { init(); } |
|
|
protected: |
|
|
protected: |
|
|
virtual bool claim(Device_t *device, int type, const uint8_t *descriptors, uint32_t len); |
|
|
virtual bool claim(Device_t *device, int type, const uint8_t *descriptors, uint32_t len); |
|
|
virtual void disconnect(); |
|
|
virtual void disconnect(); |
|
|
|
|
|
|
|
|
static void tx_callback(const Transfer_t *transfer); |
|
|
static void tx_callback(const Transfer_t *transfer); |
|
|
void rx_data(const Transfer_t *transfer); |
|
|
void rx_data(const Transfer_t *transfer); |
|
|
void tx_data(const Transfer_t *transfer); |
|
|
void tx_data(const Transfer_t *transfer); |
|
|
|
|
|
void init(); |
|
|
private: |
|
|
private: |
|
|
Pipe_t *rxpipe; |
|
|
Pipe_t *rxpipe; |
|
|
Pipe_t *txpipe; |
|
|
Pipe_t *txpipe; |