forked from espressif/arduino-esp32
Add option USB CDC to be used for Serial (starting USB early)
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
menu.UploadSpeed=Upload Speed
|
||||
menu.UploadMode=Upload Mode
|
||||
menu.SerialMode=Serial Connected To
|
||||
menu.CPUFreq=CPU Frequency
|
||||
menu.FlashFreq=Flash Frequency
|
||||
menu.FlashMode=Flash Mode
|
||||
@ -30,6 +31,7 @@ esp32s2.build.core=esp32
|
||||
esp32s2.build.variant=esp32s2
|
||||
esp32s2.build.board=ESP32S2_DEV
|
||||
|
||||
esp32s2.build.serial=0
|
||||
esp32s2.build.f_cpu=240000000L
|
||||
esp32s2.build.flash_size=4MB
|
||||
esp32s2.build.flash_freq=80m
|
||||
@ -38,6 +40,11 @@ esp32s2.build.boot=qio
|
||||
esp32s2.build.partitions=default
|
||||
esp32s2.build.defines=
|
||||
|
||||
esp32s2.menu.SerialMode.default=UART0
|
||||
esp32s2.menu.SerialMode.default.build.serial=0
|
||||
esp32s2.menu.SerialMode.cdc=USB CDC
|
||||
esp32s2.menu.SerialMode.cdc.build.serial=1
|
||||
|
||||
esp32s2.menu.UploadMode.default=Default Uart
|
||||
esp32s2.menu.UploadMode.default.upload.flags=
|
||||
esp32s2.menu.UploadMode.default.upload.tool=esptool_py
|
||||
|
@ -37,7 +37,11 @@
|
||||
#endif
|
||||
|
||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
|
||||
#if ARDUINO_SERIAL_PORT //Serial used for USB CDC
|
||||
HardwareSerial Serial0(0);
|
||||
#else
|
||||
HardwareSerial Serial(0);
|
||||
#endif
|
||||
HardwareSerial Serial1(1);
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
HardwareSerial Serial2(2);
|
||||
|
@ -113,8 +113,13 @@ protected:
|
||||
extern void serialEventRun(void) __attribute__((weak));
|
||||
|
||||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
|
||||
#if ARDUINO_SERIAL_PORT //Serial used for USB CDC
|
||||
#include "USB.h"
|
||||
#include "USBCDC.h"
|
||||
extern HardwareSerial Serial0;
|
||||
#else
|
||||
extern HardwareSerial Serial;
|
||||
extern HardwareSerial Serial1;
|
||||
#endif
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
extern HardwareSerial Serial2;
|
||||
#endif
|
||||
|
@ -329,6 +329,10 @@ USBCDC::operator bool() const
|
||||
return connected;
|
||||
}
|
||||
|
||||
#if ARDUINO_SERIAL_PORT //Serial used for USB CDC
|
||||
USBCDC Serial(0);
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_USB_CDC_ENABLED */
|
||||
|
||||
#endif /* CONFIG_USB_ENABLED */
|
@ -126,6 +126,8 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
extern void serialEventRun(void) __attribute__((weak));
|
||||
#if ARDUINO_SERIAL_PORT //Serial used for USB CDC
|
||||
extern USBCDC Serial;
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_USB_CDC_ENABLED */
|
@ -2,6 +2,9 @@
|
||||
#include "freertos/task.h"
|
||||
#include "esp_task_wdt.h"
|
||||
#include "Arduino.h"
|
||||
#if ARDUINO_SERIAL_PORT //Serial used for USB CDC
|
||||
#include "USB.h"
|
||||
#endif
|
||||
|
||||
TaskHandle_t loopTaskHandle = NULL;
|
||||
|
||||
@ -36,6 +39,9 @@ void loopTask(void *pvParameters)
|
||||
|
||||
extern "C" void app_main()
|
||||
{
|
||||
#if ARDUINO_SERIAL_PORT //Serial used for USB CDC
|
||||
USB.begin();
|
||||
#endif
|
||||
loopTaskWDTEnabled = false;
|
||||
initArduino();
|
||||
xTaskCreateUniversal(loopTask, "loopTask", 8192, NULL, 1, &loopTaskHandle, CONFIG_ARDUINO_RUNNING_CORE);
|
||||
|
@ -29,6 +29,7 @@ compiler.cpp.flags.esp32=-mlongcalls -Wno-frame-address -ffunction-sections -fda
|
||||
compiler.S.flags.esp32=-ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-strategy=memw -Og -fstack-protector -x assembler-with-cpp -MMD -c
|
||||
compiler.c.elf.flags.esp32=-mlongcalls -T esp32.rom.ld -T esp32.rom.libgcc.ld -T esp32.rom.newlib-data.ld -T esp32.rom.syscalls.ld -T esp32_out.ld -T esp32.project.ld -T esp32.peripherals.ld -Wl,--cref -fno-rtti -fno-lto -u esp_app_desc -u vfs_include_syscalls_impl -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u app_main -u call_user_start_cpu0 -u ld_include_panic_highint_hdl -mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-strategy=memw -Wl,--gc-sections -Wl,--undefined=uxTopUsedPriority -u newlib_include_locks_impl -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u __cxa_guard_dummy
|
||||
compiler.ar.flags.esp32=cru
|
||||
build.extra_flags.esp32=-DARDUINO_SERIAL_PORT=0
|
||||
#
|
||||
# ESP32 Support End
|
||||
#
|
||||
@ -43,6 +44,7 @@ compiler.cpp.flags.esp32s2=-mlongcalls -ffunction-sections -fdata-sections -fstr
|
||||
compiler.S.flags.esp32s2=-ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -fstack-protector -x assembler-with-cpp -MMD -c
|
||||
compiler.c.elf.flags.esp32s2=-mlongcalls -T esp32s2.rom.ld -T esp32s2.rom.libgcc.ld -T esp32s2.rom.newlib-data.ld -T esp32s2.rom.newlib-funcs.ld -T esp32s2.rom.spiflash.ld -T esp32s2_out.ld -T esp32s2.project.ld -T esp32s2.peripherals.ld -Wl,--cref -fno-rtti -fno-lto -u esp_app_desc -u vfs_include_syscalls_impl -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u app_main -u call_user_start_cpu0 -u ld_include_panic_highint_hdl -Wl,--gc-sections -Wl,--undefined=uxTopUsedPriority -u newlib_include_locks_impl -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u __cxa_guard_dummy
|
||||
compiler.ar.flags.esp32s2=cru
|
||||
build.extra_flags.esp32s2=-DARDUINO_SERIAL_PORT={build.serial}
|
||||
#
|
||||
# ESP32S2 Support End
|
||||
#
|
||||
@ -88,7 +90,7 @@ build.flash_mode=dio
|
||||
build.boot=bootloader
|
||||
build.code_debug=0
|
||||
build.defines=
|
||||
build.extra_flags=-DESP32 -DCORE_DEBUG_LEVEL={build.code_debug} {build.defines}
|
||||
build.extra_flags=-DESP32 -DCORE_DEBUG_LEVEL={build.code_debug} {build.defines} {build.extra_flags.{build.mcu}}
|
||||
|
||||
# Check if custom partitions exist
|
||||
recipe.hooks.prebuild.1.pattern=bash -c "[ ! -f {build.source.path}/partitions.csv ] || cp -f {build.source.path}/partitions.csv {build.path}/partitions.csv"
|
||||
|
Reference in New Issue
Block a user