AnsweredAssumed Answered

Issue with STM32Cube generated code for USB Host with middleware "platform settings"

Question asked by Jon Carrier on Apr 13, 2018

I am not sure if this is the best way to report issues with STM32Cube, if not please let me know and I can go the suggested path.


Before describing the actual issue here are the primary configuration settings using STM32F767ZI Nucleo that are related to the problem:

- Pinout: USB_OTG_FS: set to "Host_Only"

- Pinout: Middleware: USB_HOST: "Host supporting ALL classes"

- Configuration: Middleware: USB_HOST: Platform Settings: Set "Supported IPs" to "GPIO:Output" using PG6


This generates code for USBH_Start() containing the following:


/* Activate VBUS on the port */
USBH_LL_DriverVBUS (phost, TRUE);


The issue is that USBH_LL_DriverVBUS() is defined such that the second parameter is inverted logic.


Here is the function comment for USBH_LL_DriverVBUS():


  * @brief  Drive VBUS.
  * @param  phost: Host handle
  * @param  state : VBUS state
  *          This parameter can be one of the these values:
  *           0 : VBUS Active
  *           1 : VBUS Inactive
  * @retval Status


So when calling USBH_Start() with TRUE, it is actually turning the port's VBUS OFF instead of ON. The same issue exists for USBH_Stop().


Simply changing the call above to use FALSE (and similarly for USBH_Stop, setting to TRUE), the issue of the USB host not working will be resolved.