diff --git a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.h b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.h index 4d7ae1593..e9f9c5756 100644 --- a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.h +++ b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.h @@ -178,19 +178,6 @@ #error "STM32_OTGx_NUMBER not defined in registry" #endif -/** - * @brief Maximum endpoint address. - */ -#if (STM32_HAS_OTG2 && STM32_USB_USE_OTG2) || defined(__DOXYGEN__) -#if (STM32_OTG1_ENDPOINTS < STM32_OTG2_ENDPOINTS) || defined(__DOXYGEN__) -#define USB_MAX_ENDPOINTS STM32_OTG2_ENDPOINTS -#else -#define USB_MAX_ENDPOINTS STM32_OTG1_ENDPOINTS -#endif -#else -#define USB_MAX_ENDPOINTS STM32_OTG1_ENDPOINTS -#endif - #if STM32_USB_USE_OTG1 && !STM32_HAS_OTG1 #error "OTG1 not present in the selected device" #endif @@ -203,6 +190,19 @@ #error "USB driver activated but no USB peripheral assigned" #endif +/* Maximum endpoint address.*/ +#if STM32_HAS_OTG1 && STM32_USB_USE_OTG1 && STM32_HAS_OTG2 && STM32_USB_USE_OTG2 + #if STM32_OTG1_ENDPOINTS < STM32_OTG2_ENDPOINTS + #define USB_MAX_ENDPOINTS STM32_OTG2_ENDPOINTS + #else + #define USB_MAX_ENDPOINTS STM32_OTG1_ENDPOINTS + #endif +#elif STM32_HAS_OTG1 && STM32_USB_USE_OTG1 + #define USB_MAX_ENDPOINTS STM32_OTG1_ENDPOINTS +#elif STM32_HAS_OTG2 && STM32_USB_USE_OTG2 + #define USB_MAX_ENDPOINTS STM32_OTG2_ENDPOINTS +#endif + #if STM32_USB_USE_OTG1 && \ !OSAL_IRQ_IS_VALID_PRIORITY(STM32_USB_OTG1_IRQ_PRIORITY) #error "Invalid IRQ priority assigned to OTG1" diff --git a/os/hal/ports/STM32/STM32H7xx/stm32_registry.h b/os/hal/ports/STM32/STM32H7xx/stm32_registry.h index 83e8d3a0f..b434ade6c 100644 --- a/os/hal/ports/STM32/STM32H7xx/stm32_registry.h +++ b/os/hal/ports/STM32/STM32H7xx/stm32_registry.h @@ -539,10 +539,11 @@ /* USB attributes.*/ #define STM32_OTG_STEPPING 2 -#define STM32_HAS_OTG1 TRUE -#define STM32_OTG1_ENDPOINTS 8 +#define STM32_HAS_OTG1 FALSE + +#define STM32_HAS_OTG2 TRUE +#define STM32_OTG2_ENDPOINTS 8 -#define STM32_HAS_OTG2 FALSE #define STM32_HAS_USB FALSE /* IWDG attributes.*/