diff options
Diffstat (limited to 'src/stm32/usbotg.c')
-rw-r--r-- | src/stm32/usbotg.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/src/stm32/usbotg.c b/src/stm32/usbotg.c index d6551106..b61c99ca 100644 --- a/src/stm32/usbotg.c +++ b/src/stm32/usbotg.c @@ -15,21 +15,31 @@ #include "sched.h" // DECL_INIT #if CONFIG_STM32_USB_PB14_PB15 -#define USB_PERIPH_BASE USB_OTG_HS_PERIPH_BASE -#define OTG_IRQn OTG_HS_IRQn -#define USBOTGEN RCC_AHB1ENR_USB1OTGHSEN -#define GPIO_D_NEG GPIO('B', 14) -#define GPIO_D_POS GPIO('B', 15) -#define GPIO_FUNC GPIO_FUNCTION(12) -DECL_CONSTANT_STR("RESERVE_PINS_USB1", "PB14,PB15"); + #define IS_OTG_HS 1 + #define GPIO_D_NEG GPIO('B', 14) + #define GPIO_D_POS GPIO('B', 15) + #define GPIO_FUNC GPIO_FUNCTION(12) + DECL_CONSTANT_STR("RESERVE_PINS_USB1", "PB14,PB15"); #else -#define USB_PERIPH_BASE USB_OTG_FS_PERIPH_BASE -#define OTG_IRQn OTG_FS_IRQn -#define USBOTGEN RCC_AHB1ENR_USB2OTGHSEN -#define GPIO_D_NEG GPIO('A', 11) -#define GPIO_D_POS GPIO('A', 12) -#define GPIO_FUNC GPIO_FUNCTION(10) -DECL_CONSTANT_STR("RESERVE_PINS_USB", "PA11,PA12"); + #if CONFIG_MACH_STM32H723 + #define IS_OTG_HS 1 + #else + #define IS_OTG_HS 0 + #endif + #define GPIO_D_NEG GPIO('A', 11) + #define GPIO_D_POS GPIO('A', 12) + #define GPIO_FUNC GPIO_FUNCTION(10) + DECL_CONSTANT_STR("RESERVE_PINS_USB", "PA11,PA12"); +#endif + +#if IS_OTG_HS + #define USB_PERIPH_BASE USB_OTG_HS_PERIPH_BASE + #define OTG_IRQn OTG_HS_IRQn + #define USBOTGEN RCC_AHB1ENR_USB1OTGHSEN +#else + #define USB_PERIPH_BASE USB_OTG_FS_PERIPH_BASE + #define OTG_IRQn OTG_FS_IRQn + #define USBOTGEN RCC_AHB1ENR_USB2OTGHSEN #endif static void |