This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

USB dual-role OTG on STM32F4

Can't figure out is it possible to configure Keil's Middleware for dual-role OTG host/device?
I would like to be able to read from USB stick, if inserted, but also to present itself as a MSC device if attached to a PC or Android phone. It does not have to be fully automatic, btw.

  • Hi Dejan,

    you can use ID pin for detecting a type of device in which case you need to have specific cables for each Host or Device functionality, details about ID pin can be found here: www.edn.com/.../Understanding-USB-On-The-Go

    You can also read the VBUS pin, if there is power it means your device is probably connected to a Host so you initialize it as Device, otherwise you initialize it as host.

    Or you can try it as Host for some time and then switch to Device.

    BTW, switching between roles for example from Device to Host could look like this:

      .
      .
      USBD_Initialize   (0);
      USBD_Connect      (0);
      // Do USB Device functionality
      USBD_Uninitialize (0);
      USBH_Initialize   (0);
      // Do USB Host functionality
      USBH_Uninitialize (0);
      .
      .