Selecting Dual-Role USB on Embedded Devices Supporting Serial Connections[Copy link]
I am new to USB and developing a USB enabled embedded device for a client who designs hardware. The target is the STM32F4. The use case is that this device A) when connected to a computer, should appear as a COM port. B) when connected to a peripheral, can communicate with it through the COM port as a host. For example, the initial peripheral will provide a DB9 connection, so there may be a USB to RS232 dongle between my embedded device and the peripheral. So in this case, I think our peripheral will be a dongle. C) The long term goal is to support other peripherals such as flash drives and user input devices. Project A) above has been implemented using ST's CDC class driver. I have a lot of questions about how to handle this. My understanding of the On The Go Supplement is that there are basically two ways to go about this - either as an embedded host or using OTG. 1) The spec seems to indicate that if you use the embedded host model, you must support at least two USB connections, and may need to support multiple ports on the micro, one configured as a host connection and one as a peripheral connection. Is this correct? 2) The customer plans to use OTG and hardwire the ID signal to the micro ground (host), and switch roles as needed (perhaps via HNP, if both support OTG?). I don't believe this will work, since the PC will think it's the host when connected to it, correct? 3) I'm a little confused about the relationship between CDC (ACP) and VCP. It seems like VCP is a specific type of CDC, but it's not clear to me how it extends it. Given that the customer has already implemented A) above using the ST CDC driver, it seems odd to me that there is no VCP? 4) If I wanted to implement B) above (assuming OTG is used) what would be required on my side, since the device is already acting as a peripheral CDC? i.e. when acting as a peripheral, what would be required in addition to the CDC connection already in the driver to act as the host for the CDC connection?