diff --git a/features/unsupported/USBHost/targets/TARGET_STM/USBHALHost_STM.h b/features/unsupported/USBHost/targets/TARGET_STM/USBHALHost_STM.h index dd741ecd03..59d3e61f56 100644 --- a/features/unsupported/USBHost/targets/TARGET_STM/USBHALHost_STM.h +++ b/features/unsupported/USBHost/targets/TARGET_STM/USBHALHost_STM.h @@ -122,10 +122,17 @@ static gpio_t gpio_powerpin; void usb_vbus(uint8_t state) { - if (state == 0) { - gpio_write(&gpio_powerpin, USB_POWER_OFF); - } else { - gpio_write(&gpio_powerpin, USB_POWER_ON); + if (gpio_powerpin.reg_set && gpio_powerpin.reg_clr) + { + if (state == 0) { + gpio_write(&gpio_powerpin, USB_POWER_OFF); + } else { + gpio_write(&gpio_powerpin, USB_POWER_ON); + } + } + else + { + /* The board does not have GPIO pin to control usb supply */ } wait(0.2); }