cancel
Showing results for 
Search instead for 
Did you mean: 

Switching between Host and Device roles on stm32g0b1 for usb 2.0 port?

SHuds.2
Associate II

Hello,

I am working on a project for the stm32g0b1 mcu that does not interface with type C ports. It will only be connecting to usb 2.0 devices. Since I don't need the power delivery negotiations for the type c ports, I have been combining the examples for USB Host only and USB Device only as found in the cubeMX g0 repo under the stm32g0C1E-EV example folders.

I combined those projects into one now where the Host/Device drivers are initialized and deinitialized depending on the USB ID Pin. This works to some degree but I am running into issues with the Host role. Currently switching to and from Device mode works and the VCP always opens, but the MSC is only successfully opened the first time it is plugged in.

Has anybody tries this before? I am trying to avoid using the more complicated Power Delivery drivers for type C because they use FreeRTOS and my project does not.

1 REPLY 1
SHuds.2
Associate II

I solved my problem, in case anyone tries the same setup the problem was in the usbd_conf and usbh_conf files. There is a msp_deinit function in each that stops the usb clock and disables the irq usb lines which was causing me to miss interupts. I commented out the msp_deinit functions so the usb clock is always running and now it seems to be switching between roles just fine.