mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-09-12 01:24:04 +00:00
[USBCDC] Remove 2nd USB CDC port + use USB CDC on ESP32-S3
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
"memory_type": "qio_opi"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": "-DBOARD_HAS_PSRAM -DARDUINO_USB_MODE=1 -DUSE_USB_CDC_CONSOLE -DESP32_4M -DESP32S3",
|
||||
"extra_flags": "-DBOARD_HAS_PSRAM -DARDUINO_USB_MODE=0 -DUSE_USB_CDC_CONSOLE -DESP32_4M -DESP32S3 -DARDUINO_USB_CDC_ON_BOOT=1",
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "qio",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"memory_type": "qio_qspi"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": "-DBOARD_HAS_PSRAM -DARDUINO_USB_MODE=1 -DUSE_USB_CDC_CONSOLE -DESP32_4M -DESP32S3",
|
||||
"extra_flags": "-DBOARD_HAS_PSRAM -DARDUINO_USB_MODE=0 -DUSE_USB_CDC_CONSOLE -DESP32_4M -DESP32S3 -DARDUINO_USB_CDC_ON_BOOT=1",
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "qio",
|
||||
|
||||
@@ -38,7 +38,7 @@ Port_ESPEasySerial_base * ESPeasySerial::ESPEasySerial_Port_factory(const ESPEas
|
||||
#endif // if USES_HWCDC
|
||||
#if USES_USBCDC
|
||||
case ESPEasySerialPort::usb_cdc_0:
|
||||
case ESPEasySerialPort::usb_cdc_1:
|
||||
// case ESPEasySerialPort::usb_cdc_1:
|
||||
{
|
||||
return new (std::nothrow) Port_ESPEasySerial_USBCDC_t(config);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ const __FlashStringHelper* ESPEasySerialPort_toString(ESPEasySerialPort port)
|
||||
case ESPEasySerialPort::usb_hw_cdc: return F("USB HWCDC");
|
||||
#endif // if USES_HWCDC
|
||||
#if USES_USBCDC
|
||||
case ESPEasySerialPort::usb_cdc_0: return F("USB CDC0");
|
||||
case ESPEasySerialPort::usb_cdc_1: return F("USB CDC1");
|
||||
case ESPEasySerialPort::usb_cdc_0: return F("USB CDC");
|
||||
// case ESPEasySerialPort::usb_cdc_1: return F("USB CDC1");
|
||||
#endif // if USES_USBCDC
|
||||
case ESPEasySerialPort::MAX_SERIAL_TYPE: break;
|
||||
|
||||
@@ -103,7 +103,7 @@ bool validSerialPort(ESPEasySerialPort port)
|
||||
#endif // if USES_HWCDC
|
||||
#if USES_USBCDC
|
||||
case ESPEasySerialPort::usb_cdc_0:
|
||||
case ESPEasySerialPort::usb_cdc_1:
|
||||
// case ESPEasySerialPort::usb_cdc_1:
|
||||
#endif // if USES_USBCDC
|
||||
return true;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ enum class ESPEasySerialPort : uint8_t {
|
||||
#endif // if USES_HWCDC
|
||||
#if USES_USBCDC
|
||||
usb_cdc_0 = 8,
|
||||
usb_cdc_1 = 9,
|
||||
// usb_cdc_1 = 9, // TD-er: Disable 2nd USB CDC port as it doesn't seem to work well
|
||||
#endif // if USES_USBCDC
|
||||
|
||||
MAX_SERIAL_TYPE
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#if !ARDUINO_USB_CDC_ON_BOOT
|
||||
USBCDC ESPEasySerial_USBCDC_port0(0);
|
||||
USBCDC ESPEasySerial_USBCDC_port1(1);
|
||||
//USBCDC ESPEasySerial_USBCDC_port1(1);
|
||||
#endif
|
||||
|
||||
volatile bool usbActive = false;
|
||||
@@ -93,9 +93,11 @@ Port_ESPEasySerial_USBCDC_t::Port_ESPEasySerial_USBCDC_t(const ESPEasySerialConf
|
||||
if (config.port == ESPEasySerialPort::usb_cdc_0) {
|
||||
_serial = &ESPEasySerial_USBCDC_port0;
|
||||
}
|
||||
/*
|
||||
else if (config.port == ESPEasySerialPort::usb_cdc_1) {
|
||||
_serial = &ESPEasySerial_USBCDC_port1;
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
if (_serial != nullptr) {
|
||||
|
||||
@@ -55,7 +55,7 @@ private:
|
||||
#if ARDUINO_USB_CDC_ON_BOOT
|
||||
#else
|
||||
extern USBCDC ESPEasySerial_USBCDC_port0;
|
||||
extern USBCDC ESPEasySerial_USBCDC_port1;
|
||||
//extern USBCDC ESPEasySerial_USBCDC_port1;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -60,9 +60,7 @@ Port_ESPEasySerial_USB_HWCDC_t::Port_ESPEasySerial_USB_HWCDC_t(const ESPEasySeri
|
||||
_config.rxBuffSize = _hwcdc_serial->setRxBufferSize(_config.rxBuffSize);
|
||||
_config.txBuffSize = _hwcdc_serial->setRxBufferSize(_config.txBuffSize);
|
||||
_hwcdc_serial->begin();
|
||||
// delay(10);
|
||||
_hwcdc_serial->onEvent(hwcdcEventCallback);
|
||||
// delay(1);
|
||||
// _hwcdc_serial->onEvent(hwcdcEventCallback);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -164,7 +162,9 @@ size_t Port_ESPEasySerial_USB_HWCDC_t::write(const uint8_t *buffer,
|
||||
Port_ESPEasySerial_USB_HWCDC_t::operator bool() const
|
||||
{
|
||||
if (_hwcdc_serial != nullptr) {
|
||||
return usbActive; // _hwcdc_serial->operator bool();
|
||||
//return usbActive;
|
||||
const bool connected = (*_hwcdc_serial);
|
||||
return connected;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -34,18 +34,27 @@
|
||||
//extern HardwareSerial Serial;
|
||||
ESPeasySerial *swSerial = nullptr;
|
||||
|
||||
#define DEBUG
|
||||
#define PZEM_DEBUG 0
|
||||
|
||||
#ifndef PZEM_DEBUG_SERIAL_0
|
||||
#if defined(ESP32) && !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) && ARDUINO_USB_CDC_ON_BOOT // Serial used for USB CDC
|
||||
#define PZEM_DEBUG_SERIAL_0 Serial0
|
||||
#else
|
||||
#define PZEM_DEBUG_SERIAL_0 Serial
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// Debugging function;
|
||||
void printBuf(uint8_t* buffer, uint16_t len){
|
||||
#ifdef DEBUG
|
||||
#if PZEM_DEBUG
|
||||
for(uint16_t i = 0; i < len; i++){
|
||||
char temp[6];
|
||||
sprintf(temp, "%.2x ", buffer[i]);
|
||||
Serial.print(temp);
|
||||
PZEM_DEBUG_SERIAL_0.print(temp);
|
||||
|
||||
}
|
||||
Serial.println();
|
||||
PZEM_DEBUG_SERIAL_0.println();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -2975,8 +2975,12 @@ To create/register a plugin, you have to :
|
||||
#endif
|
||||
|
||||
#ifndef ESPEASY_SERIAL_0
|
||||
#if defined(ESP32) && !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) && ARDUINO_USB_CDC_ON_BOOT // Serial used for USB CDC
|
||||
#define ESPEASY_SERIAL_0 Serial0
|
||||
#else
|
||||
#define ESPEASY_SERIAL_0 Serial
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if FEATURE_MDNS
|
||||
|
||||
@@ -50,8 +50,8 @@ String serialHelper_getGpioDescription(ESPEasySerialPort typeHint, int config_pi
|
||||
#if USES_HWCDC
|
||||
if (porttype == ESPEasySerialPort::usb_hw_cdc)
|
||||
#else
|
||||
if (porttype == ESPEasySerialPort::usb_cdc_0 ||
|
||||
porttype == ESPEasySerialPort::usb_cdc_1)
|
||||
if (porttype == ESPEasySerialPort::usb_cdc_0 /*||
|
||||
porttype == ESPEasySerialPort::usb_cdc_1*/)
|
||||
#endif
|
||||
{
|
||||
result += getConflictingUse(PIN_USB_D_MIN);
|
||||
@@ -249,7 +249,7 @@ void serialHelper_webformLoad(ESPEasySerialPort port, int rxPinDef, int txPinDef
|
||||
#endif // if USES_HWCDC
|
||||
#if USES_USBCDC
|
||||
,static_cast<int>(ESPEasySerialPort::usb_cdc_0)
|
||||
,static_cast<int>(ESPEasySerialPort::usb_cdc_1)
|
||||
// ,static_cast<int>(ESPEasySerialPort::usb_cdc_1)
|
||||
#endif // if USES_USBCDC
|
||||
#if USES_I2C_SC16IS752
|
||||
,static_cast<int>(ESPEasySerialPort::sc16is752)
|
||||
|
||||
Reference in New Issue
Block a user