diff --git a/cores/esp32/USBCDC.cpp b/cores/esp32/USBCDC.cpp index 14da7bd05448f9a55e1d1e52dee08b852fd872cd..9dcd6bfbf5f180edab64bb68c2552d0df1d000aa 100644 --- a/cores/esp32/USBCDC.cpp +++ b/cores/esp32/USBCDC.cpp @@ -227,7 +227,8 @@ void USBCDC::_onLineState(bool _dtr, bool _rts){ void USBCDC::_onLineCoding(uint32_t _bit_rate, uint8_t _stop_bits, uint8_t _parity, uint8_t _data_bits){ if(bit_rate != _bit_rate || data_bits != _data_bits || stop_bits != _stop_bits || parity != _parity){ - if(bit_rate == 9600 && _bit_rate == 1200){ + // ArduinoIDE sends LineCoding with 1200bps baud to reset the device + if(_bit_rate == 1200){ usb_persist_restart(RESTART_BOOTLOADER); } else { bit_rate = _bit_rate; diff --git a/cores/esp32/esp32-hal-tinyusb.c b/cores/esp32/esp32-hal-tinyusb.c index f19fa4bf3166099935c02f43a08f6e25aa8e9862..75ed1f9bdd0103275c6a910ac8d4664f77fce611 100644 --- a/cores/esp32/esp32-hal-tinyusb.c +++ b/cores/esp32/esp32-hal-tinyusb.c @@ -502,6 +502,15 @@ static void tinyusb_apply_device_config(tinyusb_device_config_t *config){ snprintf(WEBUSB_URL, 126, "%s", config->webusb_url); } + // Windows 10 will not recognize the CDC device if WebUSB is enabled and USB Class is not 2 (CDC) + if( + (tinyusb_loaded_interfaces_mask & BIT(USB_INTERFACE_CDC)) + && config->webusb_enabled + && (config->usb_class != TUSB_CLASS_CDC) + ){ + config->usb_class = TUSB_CLASS_CDC; + } + WEBUSB_ENABLED = config->webusb_enabled; USB_DEVICE_ATTRIBUTES = config->usb_attributes; USB_DEVICE_POWER = config->usb_power_ma;