Skip to content

Commit 131185a

Browse files
committed
stmhal: Add MICROPY_HW_USB_OTG_ID_PIN config, set for relevant boards.
This config option is for the USB OTG pin, pin A10. This is used on some boards but not others. Eg PYBv3 uses PA10 for LED(2), so it shouldn't be used for OTG ID (actually PA10 is multiplexed on this board, but defaults to LED(2)). Partially addresses issue adafruit#1059.
1 parent 7630d9c commit 131185a

6 files changed

Lines changed: 11 additions & 9 deletions

File tree

stmhal/boards/HYDRABUS/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@
3737
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8)
3838
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
3939
#define MICROPY_HW_SDCARD_DETECT_PRESENT (1)
40+
41+
// USB config
42+
#define MICROPY_HW_USB_OTG_ID_PIN (pin_A10)

stmhal/boards/NETDUINO_PLUS_2/stm32f4xx_hal_conf.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848

4949
#define STM32F405xx
5050
#define USE_USB_FS
51-
#define USE_USB_OTG_ID 0
5251

5352
/* ########################## Module Selection ############################## */
5453
/**

stmhal/boards/PYBV10/mpconfigboard.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@
3939
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
4040
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
4141

42-
// USB VBUS detect pin
42+
// USB config
4343
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)
44+
#define MICROPY_HW_USB_OTG_ID_PIN (pin_A10)

stmhal/boards/PYBV4/mpconfigboard.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@
3838
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
3939
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
4040

41-
// USB VBUS detect pin
41+
// USB config
4242
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)
43+
#define MICROPY_HW_USB_OTG_ID_PIN (pin_A10)

stmhal/boards/STM32F4DISC/mpconfigboard.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@
3333
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
3434
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
3535

36-
// USB VBUS detect pin
36+
// USB config
3737
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)
38+
#define MICROPY_HW_USB_OTG_ID_PIN (pin_A10)

stmhal/usbd_conf.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@
3333
#include "stm32f4xx_hal.h"
3434
#include "usbd_core.h"
3535

36-
#if !defined(USE_USB_OTG_ID)
37-
#define USE_USB_OTG_ID 1
38-
#endif
39-
4036
/* Private typedef -----------------------------------------------------------*/
4137
/* Private define ------------------------------------------------------------*/
4238
/* Private macro -------------------------------------------------------------*/
@@ -79,7 +75,8 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
7975
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
8076
#endif
8177

82-
#if USE_USB_OTG_ID
78+
#if defined(MICROPY_HW_USB_OTG_ID_PIN)
79+
// USB ID pin is always A10
8380
GPIO_InitStruct.Pin = GPIO_PIN_10;
8481
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
8582
GPIO_InitStruct.Pull = GPIO_PULLUP;

0 commit comments

Comments
 (0)