Skip to content

Commit 0cbd8b2

Browse files
committed
Add CIRCUITPY_USB_DEVICE config
This replaces CIRCUITPY_USB and makes room for CIRCUITPY_TINYUSB when it may only be included for host support.
1 parent fde6263 commit 0cbd8b2

File tree

32 files changed

+131
-266
lines changed

32 files changed

+131
-266
lines changed

lib/tinyusb

Submodule tinyusb updated 377 files

main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ STATIC void stop_mp(void) {
236236

237237
background_callback_reset();
238238

239-
#if CIRCUITPY_USB
239+
#if CIRCUITPY_TINYUSB
240240
usb_background();
241241
#endif
242242

@@ -466,7 +466,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool *simulate_reset) {
466466

467467
start_mp(safe_mode);
468468

469-
#if CIRCUITPY_USB
469+
#if CIRCUITPY_USB_DEVICE
470470
usb_setup_with_vm();
471471
#endif
472472

@@ -845,7 +845,7 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
845845

846846
start_mp(safe_mode);
847847

848-
#if CIRCUITPY_USB
848+
#if CIRCUITPY_USB_DEVICE
849849
// Set up default USB values after boot.py VM starts but before running boot.py.
850850
usb_set_defaults();
851851
#endif
@@ -930,7 +930,7 @@ STATIC int run_repl(safe_mode_t safe_mode) {
930930

931931
start_mp(safe_mode);
932932

933-
#if CIRCUITPY_USB
933+
#if CIRCUITPY_USB_DEVICE
934934
usb_setup_with_vm();
935935
#endif
936936

@@ -1078,7 +1078,7 @@ int __attribute__((used)) main(void) {
10781078
// By default our internal flash is readonly to local python code and
10791079
// writable over USB. Set it here so that safemode.py or boot.py can change it.
10801080
filesystem_set_internal_concurrent_write_protection(true);
1081-
filesystem_set_internal_writable_by_usb(CIRCUITPY_USB == 1);
1081+
filesystem_set_internal_writable_by_usb(CIRCUITPY_USB_DEVICE == 1);
10821082

10831083
#if CIRCUITPY_SAFEMODE_PY
10841084
// Run safemode.py if we ARE in safe mode.

ports/atmel-samd/common-hal/microcontroller/Pin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void reset_all_pins(void) {
5252
uint32_t pin_mask[PORT_COUNT] = PORT_OUT_IMPLEMENTED;
5353

5454
// Do not full reset USB lines.
55-
#if CIRCUITPY_USB
55+
#if CIRCUITPY_USB_DEVICE
5656
pin_mask[0] &= ~(PORT_PA24 | PORT_PA25);
5757
#endif
5858

ports/espressif/Makefile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,22 +260,34 @@ LIBS += -lm
260260
endif
261261

262262
# TinyUSB defines
263-
ifeq ($(CIRCUITPY_USB),1)
264-
ifeq ($(IDF_TARGET),esp32s2)
263+
# Always add these because we might be doing host.
264+
ifeq ($(IDF_TARGET),esp32)
265+
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_ESP32
266+
else ifeq ($(IDF_TARGET),esp32c3)
267+
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_ESP32C3
268+
else ifeq ($(IDF_TARGET),esp32c6)
269+
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_ESP32C6
270+
else ifeq ($(IDF_TARGET),esp32h2)
271+
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_ESP32H2
272+
else ifeq ($(IDF_TARGET),esp32s2)
265273
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_ESP32S2
266274
else ifeq ($(IDF_TARGET),esp32s3)
267275
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_ESP32S3
268276
endif
277+
ifeq ($(CIRCUITPY_TINYUSB),1)
269278
CFLAGS += \
270279
-DCFG_TUSB_OS=OPT_OS_FREERTOS \
280+
-DCFG_TUD_TASK_QUEUE_SZ=32
281+
endif
282+
ifeq ($(CIRCUITPY_USB_DEVICE),1)
283+
CFLAGS += \
271284
-DCFG_TUD_CDC_RX_BUFSIZE=1024 \
272285
-DCFG_TUD_CDC_TX_BUFSIZE=1024 \
273286
-DCFG_TUD_MSC_BUFSIZE=4096 \
274287
-DCFG_TUD_MIDI_RX_BUFSIZE=128 \
275288
-DCFG_TUD_MIDI_TX_BUFSIZE=128 \
276289
-DCFG_TUD_VENDOR_RX_BUFSIZE=128 \
277-
-DCFG_TUD_VENDOR_TX_BUFSIZE=128 \
278-
-DCFG_TUD_TASK_QUEUE_SZ=32
290+
-DCFG_TUD_VENDOR_TX_BUFSIZE=128
279291
endif
280292

281293
######################################
@@ -303,7 +315,7 @@ ifneq ($(CIRCUITPY_TOUCHIO_USE_NATIVE),0)
303315
SRC_C += peripherals/touch.c
304316
endif
305317

306-
ifneq ($(CIRCUITPY_USB),0)
318+
ifneq ($(CIRCUITPY_USB_DEVICE),0)
307319
SRC_C += lib/tinyusb/src/portable/espressif/esp32sx/dcd_esp32sx.c
308320
endif
309321

@@ -390,7 +402,7 @@ TARGET_SDKCONFIG = esp-idf-config/sdkconfig-$(IDF_TARGET).defaults
390402
ifeq ($(CIRCUITPY_ESP_FLASH_SIZE), 2MB)
391403
FLASH_SIZE_SDKCONFIG ?= esp-idf-config/sdkconfig-flash-$(CIRCUITPY_ESP_FLASH_SIZE)-no-ota-no-uf2.defaults
392404
else
393-
UF2_BOOTLOADER ?= $(CIRCUITPY_USB)
405+
UF2_BOOTLOADER ?= $(CIRCUITPY_USB_DEVICE)
394406
ifeq ($(UF2_BOOTLOADER), 1)
395407
FLASH_SIZE_SDKCONFIG ?= esp-idf-config/sdkconfig-flash-$(CIRCUITPY_ESP_FLASH_SIZE).defaults
396408
else
@@ -503,7 +515,7 @@ endif
503515
ifneq ($(CIRCUITPY_PARALLELDISPLAYBUS),0)
504516
ESP_IDF_COMPONENTS_LINK += esp_lcd
505517
endif
506-
ifneq ($(CIRCUITPY_USB),0)
518+
ifneq ($(CIRCUITPY_USB_DEVICE),0)
507519
ESP_IDF_COMPONENTS_LINK += usb
508520
endif
509521

ports/espressif/boards/heltec_esp32s3_wifi_lora_v3/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ IDF_TARGET = esp32s3
1313

1414
# This board doesn't have USB by default, it
1515
# instead uses a CP2102 USB-to-Serial chip
16-
CIRCUITPY_USB = 0
16+
CIRCUITPY_USB_DEVICE = 0
1717
CIRCUITPY_ESP_USB_SERIAL_JTAG = 0
1818

1919
CIRCUITPY_ESP_FLASH_MODE = qio

ports/espressif/boards/makerfabs_tft7/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ CIRCUITPY_DOTCLOCKFRAMEBUFFER = 1
1818
# To build with USB disabled allowing access to I2S pins
1919
#CIRCUITPY_CREATOR_ID = 0x1A000000
2020
#CIRCUITPY_CREATION_ID = 0x005381BF
21-
#CIRCUITPY_USB=0
21+
#CIRCUITPY_USB_DEVICE=0
2222
#CIRCUITPY_BUILD_EXTENSIONS = bin,uf2
2323
#UF2_BOOTLOADER = 1
2424
#CIRCUITPY_WIFI=1

ports/espressif/boards/makerfabs_tft7/pins.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
9999
{ MP_ROM_QSTR(MP_QSTR_GPIO19), MP_ROM_PTR(&pin_GPIO19) },
100100

101101
// I2S pins are shared with USB D+/D-, these are only useful if USB is disabled
102-
#if CIRCUITPY_USB == 0
102+
#if CIRCUITPY_USB_DEVICE == 0
103103
{ MP_ROM_QSTR(MP_QSTR_I2S_BIT_CLOCK), MP_ROM_PTR(&pin_GPIO20) },
104104
{ MP_ROM_QSTR(MP_QSTR_I2S_WORD_SELECT), MP_ROM_PTR(&pin_GPIO2) },
105105
{ MP_ROM_QSTR(MP_QSTR_I2S_DATA), MP_ROM_PTR(&pin_GPIO19) },

ports/espressif/boards/sunton_esp32_8048S070/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CIRCUITPY_CREATION_ID = 0x00AA0004
33

44
# This board doesn't have USB by default, it
55
# instead uses a CH340C USB-to-Serial chip
6-
CIRCUITPY_USB = 0
6+
CIRCUITPY_USB_DEVICE = 0
77
CIRCUITPY_ESP_USB_SERIAL_JTAG = 0
88

99
IDF_TARGET = esp32s3

ports/espressif/boards/waveshare_esp32_s3_lcd_1_28/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CIRCUITPY_CREATION_ID = 0x00AB0001
33

44
# This board doesn't have USB by default, it
55
# instead uses a CH340C USB-to-Serial chip
6-
CIRCUITPY_USB = 0
6+
CIRCUITPY_USB_DEVICE = 0
77
CIRCUITPY_ESP_USB_SERIAL_JTAG = 0
88

99
IDF_TARGET = esp32s3

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static const uint64_t pin_mask_reset_forbidden =
176176
#endif // ESP32H2
177177

178178
#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
179-
#if CIRCUITPY_USB
179+
#if CIRCUITPY_USB_DEVICE
180180
// Never ever reset USB pins.
181181
GPIO_SEL_19 | // USB D-
182182
GPIO_SEL_20 | // USB D+

0 commit comments

Comments
 (0)