cancel
Showing results for 
Search instead for 
Did you mean: 

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

s_
Associate III

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.

1 REPLY 1

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