cancel
Showing results for 
Search instead for 
Did you mean: 

USB otg dynamic role switching between hid device and msc host

SSure
Associate II

Hello,

I'm working with the STM32f412g discovery board and I want to develop an application which supports both HID Device and MSC Host. I have tested and got both the functionalities working independently, but I'm not understanding how to integrate them together. I cannot find any example for this OTG functionality. Please help me here by providing an example or explaining how to go about it.

Thanks in advance

1 REPLY 1

According to the standard, switching is based on the ID contact in the USB microAB socket; then the use of microA or microB plug (which differ not only in shape but also in whether the ID pin is grounded or not) determines the role, see https://en.wikipedia.org/wiki/USB_On-The-Go#Plug (and the OTG annex in standard, of course).

In STM32 the OTG module has an ID input (connected to OTG_FS_ID/OTG_HS_ID pin if set to the appropriate AF in GPIO), and its behaviour is described in the ID line detection subchapter of the OTG chapter in RM. See OTG_GOTGCTL.CIDSTS and OTG_GINTSTS.CIDSCHG .

JW