hathach / tinyusb

An open source cross-platform USB stack for embedded system
https://www.tinyusb.org
MIT License
5.1k stars 1.07k forks source link

RP2040: Allow switching between Host and Device on runtime #1719

Open DatanoiseTV opened 2 years ago

DatanoiseTV commented 2 years ago

Related area

host + device stack

Hardware specification

rp2040

Is your feature request related to a problem?

I am currently working on porting https://github.com/rppicomidi/midi2usbhost to support USB host and device mode without providing different firmware and noticed that TinyUSB currently doesn't support compiling with USB host and device support at the same time.

Describe the solution you'd like

I would like to be able to deal with USB host and device switching in software. It would be great if the tuh* and tud functions would be available and could be either controlled in software or a GPIO. This would significantly reduce the workflow when dealing with my USB Type-C Host + Device.

image

Diagram) ser-images.githubusercontent.com/6614616/199957627-fc01223d-1d22-4788-84da-074136017c9b.png)

It is either powered by the Type-C connector to be used as a MIDI Device or for providing VUSB for the Type-A connector (I am using a USB Mux to switch the data lines from Type-C to Type-A via a GPIO and a MOSFET to control VUSB supply to Type-A via software.

I have checked existing issues, dicussion and documentation

DatanoiseTV commented 6 months ago

Is there any progress on host/device switching (or dual-role support)?