aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George2019-04-08 14:30:16 +1000
committerDamien George2019-04-08 14:30:16 +1000
commitae1e18a346b9a3f4bdd75dcb9faa9287b4f5e7cf (patch)
treea012ce7995d9f7108cc5a3a35df72b96f3f18ce0
parent2c3fa4ad820c26b485da803a2de679744317ff90 (diff)
stm32/usbd_conf: Add support for USB HS peripheral on H7 MCUs.
-rw-r--r--ports/stm32/usbd_conf.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/ports/stm32/usbd_conf.c b/ports/stm32/usbd_conf.c
index 48af633cb..b7c1665f0 100644
--- a/ports/stm32/usbd_conf.c
+++ b/ports/stm32/usbd_conf.c
@@ -104,10 +104,16 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) {
else if (hpcd->Instance == USB_OTG_HS) {
#if MICROPY_HW_USB_HS_IN_FS
+ #if defined(STM32H7)
+ const uint32_t otg_alt = GPIO_AF12_OTG2_FS;
+ #else
+ const uint32_t otg_alt = GPIO_AF12_OTG_HS_FS;
+ #endif
+
// Configure USB FS GPIOs
- mp_hal_pin_config(pin_B14, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, GPIO_AF12_OTG_HS_FS);
+ mp_hal_pin_config(pin_B14, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, otg_alt);
mp_hal_pin_config_speed(pin_B14, GPIO_SPEED_FREQ_VERY_HIGH);
- mp_hal_pin_config(pin_B15, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, GPIO_AF12_OTG_HS_FS);
+ mp_hal_pin_config(pin_B15, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, otg_alt);
mp_hal_pin_config_speed(pin_B15, GPIO_SPEED_FREQ_VERY_HIGH);
#if defined(MICROPY_HW_USB_VBUS_DETECT_PIN)
@@ -117,7 +123,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) {
#if defined(MICROPY_HW_USB_OTG_ID_PIN)
// Configure ID pin
- mp_hal_pin_config(MICROPY_HW_USB_OTG_ID_PIN, MP_HAL_PIN_MODE_ALT_OPEN_DRAIN, MP_HAL_PIN_PULL_UP, GPIO_AF12_OTG_HS_FS);
+ mp_hal_pin_config(MICROPY_HW_USB_OTG_ID_PIN, MP_HAL_PIN_MODE_ALT_OPEN_DRAIN, MP_HAL_PIN_PULL_UP, otg_alt);
#endif
// Enable calling WFI and correct function of the embedded USB_FS_IN_HS phy