Skip to content

Commit 4640859

Browse files
committed
Allow swapping LSFS USB on ESP32-P4 to USB OTG
This allows full USB device on the M5Stack Tab5. Improves micropython#10666
1 parent 108860a commit 4640859

File tree

21 files changed

+123
-41
lines changed

21 files changed

+123
-41
lines changed

lib/tinyusb

Submodule tinyusb updated 692 files

ports/analog/boards/apard32690/mpconfigboard.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ USB_VID=0x0456
1919
USB_PID=0x003C
2020
USB_MANUFACTURER="Analog Devices, Inc."
2121
USB_PRODUCT="MAX32690 APARD"
22-
USB_HIGHSPEED=1
2322

2423
# NOTE: MAX32 devices do not support IN/OUT pairs on the same EP
2524
USB_NUM_ENDPOINT_PAIRS=12

ports/analog/boards/max32690evkit/mpconfigboard.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ USB_VID=0x0456
1919
USB_PID=0x003D
2020
USB_MANUFACTURER="Analog Devices, Inc."
2121
USB_PRODUCT="MAX32690 EvKit"
22-
USB_HIGHSPEED=1
2322

2423
# NOTE: MAX32 devices do not support IN/OUT pairs on the same EP
2524
USB_NUM_ENDPOINT_PAIRS=12

ports/analog/mpconfigport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// 24KiB stack
1313
#define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000
1414

15+
#define CIRCUITPY_USB_DEVICE_HIGH_SPEED (1)
16+
1517
// Also includes mpconfigboard.h
1618
#include "py/circuitpy_mpconfig.h"
1719

ports/broadcom/mpconfigport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#define MICROPY_FATFS_EXFAT (1)
2727
#define MICROPY_FATFS_MKFS_FAT32 (1)
2828

29+
#define CIRCUITPY_USB_DEVICE_HIGH_SPEED (1)
30+
2931
////////////////////////////////////////////////////////////////////////////////////////////////////
3032

3133
// This also includes mpconfigboard.h.

ports/broadcom/mpconfigport.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ CIRCUITPY_VIDEOCORE = 1
2222
INTERNAL_FLASH_FILESYSTEM = 1
2323

2424
USB_NUM_ENDPOINT_PAIRS = 8
25-
USB_HIGHSPEED = 1
2625

2726
CIRCUITPY_BUILD_EXTENSIONS ?= disk.img.zip,kernel8.img
2827

ports/cxd56/mpconfigport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#define USB_MSC_EP_NUM_OUT (5)
2424
#define USB_MSC_EP_NUM_IN (4)
2525

26+
#define CIRCUITPY_USB_DEVICE_HIGH_SPEED (1)
27+
2628
#include "py/circuitpy_mpconfig.h"
2729

2830
#define MICROPY_BYTES_PER_GC_BLOCK (32)

ports/cxd56/mpconfigport.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
USB_HIGHSPEED = 1
2-
31
# Number of USB endpoint pairs.
42
USB_NUM_ENDPOINT_PAIRS = 6
53

ports/espressif/boards/m5stack_tab5/mpconfigboard.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@
2525
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO19)
2626

2727
// Use the second USB device (numbered 0 and 1)
28-
#define CIRCUITPY_USB_DEVICE_INSTANCE 1
28+
#define CIRCUITPY_USB_DEVICE_INSTANCE 0
29+
#define CIRCUITPY_ESP32P4_SWAP_LSFS (1)

ports/espressif/common-hal/microcontroller/Pin.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,26 @@ static const uint64_t pin_mask_reset_forbidden =
211211
GPIO_SEL_32 |
212212
GPIO_SEL_33 |
213213
GPIO_SEL_34 |
214+
// USB is on the FS OTG
215+
#if CIRCUITPY_USB_DEVICE_INSTANCE == 0
216+
#if CIRCUITPY_ESP32P4_SWAP_LSFS == 1
217+
// We leave 24 and 25 alone in addition to 26 and 27 when swapped. It doesn't work otherwise. (Not sure why.)
218+
GPIO_SEL_24 | // USB D-
219+
GPIO_SEL_25 | // USB D+
220+
#endif
221+
GPIO_SEL_26 | // USB D-
222+
GPIO_SEL_27 | // USB D+
223+
#endif
214224
#if CIRCUITPY_ESP_USB_SERIAL_JTAG || (defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG) && CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG)
215225
// Never ever reset serial/JTAG communication pins.
226+
#if CIRCUITPY_ESP32P4_SWAP_LSFS == 1
227+
GPIO_SEL_26 | // USB D-
228+
GPIO_SEL_27 | // USB D+
229+
#else
216230
GPIO_SEL_24 | // USB D-
217231
GPIO_SEL_25 | // USB D+
218232
#endif
233+
#endif
219234
#if defined(CONFIG_ESP_CONSOLE_UART_DEFAULT) && CONFIG_ESP_CONSOLE_UART_DEFAULT && CONFIG_ESP_CONSOLE_UART_NUM == 0
220235
// Never reset debug UART/console pins.
221236
GPIO_SEL_37 |

0 commit comments

Comments
 (0)