Skip to main content
s__it
Associate III
November 6, 2019
Question

USB OTG device / host switching using USB 'ID' pin - example ?

  • November 6, 2019
  • 1 reply
  • 1542 views

I'm looking for an example showing how switching is done between 'host' and 'device' mode using the USB 'ID' pin.

The only 'dual role' example I have found requires the user to switch manually between these 2 roles (using joystick on eval board).

The USB peripheral in the MCU (STM32F407) seems to support automatic switching, but I cannot find any example of how to implement this.

This topic has been closed for replies.

1 reply

waclawek.jan
Super User
November 6, 2019

AFAIK the SPL based USB library (described in UM1021) contained an example of true OTG functionality, but I never used it and I also never dug deep enough into it.

At the end of the day, the switchover is much the same as if it is done upon "manual" observation of the pin - you need to shut down the software portions of one role's stack and initialize the other role's stack - except that it's done in the USB interrupt. There's not that much automatism in the hardware, IMO.

JW