summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/esp32/main.c2
-rw-r--r--ports/esp32/mpconfigport.h11
-rw-r--r--ports/esp32/mphalport.c2
-rw-r--r--ports/esp32/uart.h2
-rw-r--r--ports/esp32/usb.c4
5 files changed, 15 insertions, 6 deletions
diff --git a/ports/esp32/main.c b/ports/esp32/main.c
index dedc5421e..ca5a0e3c2 100644
--- a/ports/esp32/main.c
+++ b/ports/esp32/main.c
@@ -101,7 +101,7 @@ void mp_task(void *pvParameter) {
#endif
#if MICROPY_HW_ESP_USB_SERIAL_JTAG
usb_serial_jtag_init();
- #elif CONFIG_USB_OTG_SUPPORTED
+ #elif MICROPY_HW_USB_CDC
usb_init();
#endif
#if MICROPY_HW_ENABLE_UART_REPL
diff --git a/ports/esp32/mpconfigport.h b/ports/esp32/mpconfigport.h
index 25fa47062..747c55e92 100644
--- a/ports/esp32/mpconfigport.h
+++ b/ports/esp32/mpconfigport.h
@@ -260,9 +260,18 @@ typedef long mp_off_t;
// board specifics
#define MICROPY_PY_SYS_PLATFORM "esp32"
+// Enable stdio over native USB peripheral CDC via TinyUSB
+#ifndef MICROPY_HW_USB_CDC
+#define MICROPY_HW_USB_CDC (SOC_USB_OTG_SUPPORTED)
+#endif
+
// Enable stdio over USB Serial/JTAG peripheral
#ifndef MICROPY_HW_ESP_USB_SERIAL_JTAG
-#define MICROPY_HW_ESP_USB_SERIAL_JTAG (SOC_USB_SERIAL_JTAG_SUPPORTED)
+#define MICROPY_HW_ESP_USB_SERIAL_JTAG (SOC_USB_SERIAL_JTAG_SUPPORTED && !MICROPY_HW_USB_CDC)
+#endif
+
+#if MICROPY_HW_USB_CDC && MICROPY_HW_ESP_USB_SERIAL_JTAG
+#error "Invalid build config: Can't enable both native USB and USB Serial/JTAG peripheral"
#endif
// ESP32-S3 extended IO for 47 & 48
diff --git a/ports/esp32/mphalport.c b/ports/esp32/mphalport.c
index e85aa6260..7d0154cc0 100644
--- a/ports/esp32/mphalport.c
+++ b/ports/esp32/mphalport.c
@@ -146,7 +146,7 @@ mp_uint_t mp_hal_stdout_tx_strn(const char *str, size_t len) {
#if MICROPY_HW_ESP_USB_SERIAL_JTAG
usb_serial_jtag_tx_strn(str, len);
did_write = true;
- #elif CONFIG_USB_OTG_SUPPORTED
+ #elif MICROPY_HW_USB_CDC
usb_tx_strn(str, len);
did_write = true;
#endif
diff --git a/ports/esp32/uart.h b/ports/esp32/uart.h
index 0a0985d1b..fe08e2689 100644
--- a/ports/esp32/uart.h
+++ b/ports/esp32/uart.h
@@ -30,7 +30,7 @@
// Whether to enable the REPL on a UART.
#ifndef MICROPY_HW_ENABLE_UART_REPL
-#define MICROPY_HW_ENABLE_UART_REPL (!CONFIG_USB_OTG_SUPPORTED && !CONFIG_ESP_CONSOLE_USB_CDC && !MICROPY_HW_ESP_USB_SERIAL_JTAG)
+#define MICROPY_HW_ENABLE_UART_REPL (!MICROPY_HW_USB_CDC && !MICROPY_HW_ESP_USB_SERIAL_JTAG)
#endif
#if MICROPY_HW_ENABLE_UART_REPL
diff --git a/ports/esp32/usb.c b/ports/esp32/usb.c
index 471f2c2e0..4207e77df 100644
--- a/ports/esp32/usb.c
+++ b/ports/esp32/usb.c
@@ -28,7 +28,7 @@
#include "py/mphal.h"
#include "usb.h"
-#if CONFIG_USB_OTG_SUPPORTED && !CONFIG_ESP_CONSOLE_USB_CDC && !MICROPY_HW_ESP_USB_SERIAL_JTAG
+#if MICROPY_HW_USB_CDC
#include "esp_timer.h"
#ifndef NO_QSTR
@@ -100,4 +100,4 @@ void usb_tx_strn(const char *str, size_t len) {
}
}
-#endif // CONFIG_USB_OTG_SUPPORTED && !CONFIG_ESP_CONSOLE_USB_CDC && !MICROPY_HW_ESP_USB_SERIAL_JTAG
+#endif // MICROPY_HW_USB_CDC