Raspberry Pi RP2040 gains an extra USB port through PIO’s (programmable I/Os)

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.

Raspberry Pi RP2040 usb pio demo

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.

Via Hackster.io.

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX Rockchip RK3588 mini-ITX motherboard
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
5 Comments
oldest
newest
Willy
Willy
2 years ago

I didn’t notice the capabilities of PIO, that’s super interesting. I’m currently thinking about making a USB-audio input device that directly converts SPDIF input data to digital audio. It sounds easy to do once you have the suitable device, but there are considerations such as USB speed, signal rate and buffering that limit the choices. From what I’m seeing here, there could be some real possibilities with this chip.

Shree Kumar
2 years ago

There’s some discussion on SPDIF conversion in the forum’s !

Willy
Willy
2 years ago

Ah cool, thanks for letting me know! I was amazed to see how complicated it is to find such solutions nowadays compared to how simple it ought to be at the protocol level!

Hugh
Hugh
2 years ago

I’d really like an SBC with multiple USB-device ports. I want to play at building a KVM. I guess that this lets the Pico have two device ports but perhaps only one can be device (not sure). One problem is that most SBCs put a USB hub chip between their USB ports and the SoC. A USB hub port cannot be a device, only a host. Some or all models of the Raspberry Pi 0 provide one bare USB port that can be host or device. The Raspberry Pi 4 has one USB 2 port that can act as a… Read more »

Rogan Dawes
Rogan Dawes
2 years ago

There are many SBC’s that have a USB Device Controller (UDC), including the Pi 4 and Pi Zero, but also Allwinner and RockChip-based devices too. There are a few microcontrollers with more than one device port, but the most I have seen is two, I think, and even then, you probably still want one port to manage the physical keyboard and mouse. The alternative is to use an SBC with a USB host port(s) for the keyboard/mouse, and connect multiple microcontrollers via e.g. SPI to act as devices to the various computers. An example here is the Maxim MAX3420 and… Read more »

Boardcon Rockchip RK3588S SBC with 8K, WiFI 6, 4G LTE, NVME SSD, HDMI 2.1...