The Raspberry Pi RP2040 specifications only list one USB 1.1 Host/Device hardware interface, but developer’s Sekigon Gonnoc decided to leverage the microcontroller’s programmable I/Os (PIO) to add an extra USB port that also works in host or device mode.
While the C library is still supposed to be a work in progress Sekigon implemented full-speed (12 Mbps) and slow-speed (1.5Mbps) host, full-speed device, USB hub, and multi-port support. There’s even a demo with three “Pico Pico USB” keyboards acting as USB hubs and HID plus a wireless mouse to show the results.
The implementation uses one PIO for the USB transmitter using 22 instructions and one state machine and another PIO for the USB receiver using 31 instructions and two state machines, as well as one 1ms loop timer for the host, and one PIO interrupt for the receiver.
You’ll find the code to implement the extra USB port on RP2040 MCU through PIO on the Pico-PIO-USB Github repository including two samples:
- capture_hid_report.c USB host sample program that prints HID reports received from a device.
- usb_device.c HID USB FS device sample which moves mouse cursor every 0.5s.
Another more advanced sample is the QMK firmware for the Pico Pico USB board. The hardware keyboard also appears to be designed by Sekigon Gonnoc, but I could not find any information about it. Having said that, he previously designed the Pico Micro RP2040 board and sold it through Booth.pm, a “creator market” for the Japanese market that looks somewhat similar to Tindie to me, except it also works for artists.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.