From 74b9ce8a8f8093f5d94f697ede30875666eeed18 Mon Sep 17 00:00:00 2001 From: Andrey G Date: Sun, 9 Jan 2022 00:33:48 +0300 Subject: [PATCH] USB: use OTG1/OTG2 for serial over USB depending on which enabled (#3757) --- firmware/hw_layer/mass_storage/mass_storage_init.cpp | 6 ++++-- firmware/hw_layer/ports/stm32/serial_over_usb/usbcfg.c | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/firmware/hw_layer/mass_storage/mass_storage_init.cpp b/firmware/hw_layer/mass_storage/mass_storage_init.cpp index a26aceae80..4e637672fd 100644 --- a/firmware/hw_layer/mass_storage/mass_storage_init.cpp +++ b/firmware/hw_layer/mass_storage/mass_storage_init.cpp @@ -26,10 +26,12 @@ #endif #endif -#if STM32_USB_USE_OTG2 +#if STM32_USB_USE_OTG1 + USBDriver *usb_driver = &USBD1; +#elif STM32_USB_USE_OTG2 USBDriver *usb_driver = &USBD2; #else - USBDriver *usb_driver = &USBD1; + #error MSD needs OTG1 or OTG2 to be enabled #endif // One block buffer per LUN diff --git a/firmware/hw_layer/ports/stm32/serial_over_usb/usbcfg.c b/firmware/hw_layer/ports/stm32/serial_over_usb/usbcfg.c index 31fb2faea1..c3d10693b6 100644 --- a/firmware/hw_layer/ports/stm32/serial_over_usb/usbcfg.c +++ b/firmware/hw_layer/ports/stm32/serial_over_usb/usbcfg.c @@ -451,7 +451,13 @@ const USBConfig usbcfg = { * Serial over USB driver configuration. */ const SerialUSBConfig serusbcfg = { +#if STM32_USB_USE_OTG1 .usbp = &USBD1, +#elif STM32_USB_USE_OTG2 + .usbp = &USBD2, +#else + #error Serial over USB needs OTG1 or OTG2 to be enabled +#endif .bulk_in = USBD1_DATA_REQUEST_EP, .bulk_out = USBD1_DATA_AVAILABLE_EP, .int_in = USBD1_INTERRUPT_REQUEST_EP