I have a very unstable, very alpha (so alpha it underflows to omega) USB Host library.
GitHub repository
Right now the code is only able to enumerate the device: get its descriptors, change the address and configure it.
The tests are done using a Teensy as Host and a 2nd Teesny as device, un-commenting a lot of debug code in usb_dev.c.
Upload the USBtoSerial sketch to the Device Teensy, it will output serial comments. You can press 's' to make sure the Serial connection is alive.
Upload the usb_host_example sketch to the Host Teensy. Press 's' for some information, 'h' to go to host mode (press 's' to see the change).
You need to change line 46 in usb_dev.c from
Code:
static bdt_t table[(NUM_ENDPOINTS+1)*4];
to
Code:
bdt_t table[(NUM_ENDPOINTS+1)*4];
Connect both Teensys (I split and joined two USB micro cables). You should see over the serial of both teensys a bunch of debug information.
The host gets the device, configuration and string descriptors, change the address and configure the device. This ends the enumeration process.
For some reason as soon as this ends the host believes it just attached and repeats the process, that's why I've disabled the attach interrupts at the end of the enumeration.
The next steps are:
- Design an API to do the enumeration in a more "professional" way.
- Design an API to obtain the HID reports
- The code only works for full speed devices, most mice are low speed, the changes are minimal and easy.
- Solve the attach problem... No idea how.