Skip to main content
SSure
Associate II
January 11, 2019
Question

USB otg dynamic role switching between hid device and msc host

  • January 11, 2019
  • 1 reply
  • 810 views

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

This topic has been closed for replies.

1 reply

waclawek.jan
Super User
January 11, 2019

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