Skip to content

Commit b12da3e

Browse files
committed
fix building serial host with esp32, it runs but does not echo, probably due to inherit of HardwareSerial (fix/test later)
1 parent 554cb09 commit b12da3e

File tree

10 files changed

+23
-9
lines changed

10 files changed

+23
-9
lines changed

examples/DualRole/CDC/serial_host_bridge/serial_host_bridge.ino

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,19 @@ void forward_serial(void) {
7171
//--------------------------------------------------------------------+
7272

7373
#ifdef USE_FREERTOS
74+
75+
#ifdef ARDUINO_ARCH_ESP32
76+
#define USBH_STACK_SZ 2048
77+
#else
78+
#define USBH_STACK_SZ 200
79+
#endif
80+
7481
void usbhost_rtos_task(void *param) {
7582
(void) param;
7683
while (1) {
7784
USBHost.task();
7885
}
7986
}
80-
81-
void create_usbhost_rtos_task(void) {
82-
const uint32_t usbh_stack_size = 200;
83-
xTaskCreate(usbhost_rtos_task, "usbh", usbh_stack_size, NULL, TASK_PRIO_HIGH, NULL);
84-
}
8587
#endif
8688

8789
void setup() {
@@ -94,7 +96,8 @@ void setup() {
9496
SerialHost.begin(115200);
9597

9698
#ifdef USE_FREERTOS
97-
create_usbhost_rtos_task();
99+
// Create a task to run USBHost.task() in background
100+
xTaskCreate(usbhost_rtos_task, "usbh", USBH_STACK_SZ, NULL, 3, NULL);
98101
#endif
99102

100103
// while ( !Serial ) delay(10); // wait for native usb

examples/DualRole/Simple/device_info/.feather_esp32s2.only

Whitespace-only changes.

examples/DualRole/Simple/device_info/.feather_esp32s3.only

Whitespace-only changes.

examples/DualRole/Simple/device_info/.feather_rp2040_tinyusb.test.only

Whitespace-only changes.

examples/DualRole/Simple/device_info/.metro_m0_tinyusb.only

Whitespace-only changes.

examples/DualRole/Simple/device_info/.metro_m4_tinyusb.only

Whitespace-only changes.

examples/DualRole/Simple/device_info/.nrf52840.only

Whitespace-only changes.

examples/DualRole/Simple/device_info/device_info.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
typedef struct {
5858
tusb_desc_device_t desc_device;
5959
uint16_t manufacturer[32];
60-
uint16_t product[32];
60+
uint16_t product[48];
6161
uint16_t serial[16];
6262
bool mounted;
6363
} dev_info_t;

src/arduino/Adafruit_USBH_Host.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ bool Adafruit_USBH_Host::begin(uint8_t rhport) {
114114
#ifdef ARDUINO_ARCH_ESP32
115115
// Create an task for executing interrupt handler in thread mode
116116
max3421_intr_sem = xSemaphoreCreateBinary();
117-
xTaskCreateUniversal(max3421_intr_task, "max3421 intr", 2048, NULL, 2, NULL,
117+
xTaskCreateUniversal(max3421_intr_task, "max3421 intr", 2048, NULL, 5, NULL,
118118
ARDUINO_RUNNING_CORE);
119119
#endif
120120

src/arduino/cdc/Adafruit_USBH_CDC.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
* THE SOFTWARE.
2323
*/
2424

25+
// ESP32 out-of-sync
26+
#ifdef ARDUINO_ARCH_ESP32
27+
#include "arduino/ports/esp32/tusb_config_esp32.h"
28+
#endif
29+
2530
#include "tusb_option.h"
2631

2732
#if CFG_TUH_ENABLED && CFG_TUH_MSC
@@ -30,7 +35,13 @@
3035

3136
#include "Adafruit_USBH_CDC.h"
3237

33-
Adafruit_USBH_CDC::Adafruit_USBH_CDC(void) { _idx = TUSB_INDEX_INVALID_8; }
38+
Adafruit_USBH_CDC::Adafruit_USBH_CDC(void)
39+
#ifdef ARDUINO_ARCH_ESP32
40+
: HardwareSerial(0)
41+
#endif
42+
{
43+
_idx = TUSB_INDEX_INVALID_8;
44+
}
3445

3546
void Adafruit_USBH_CDC::begin(unsigned long baudrate) {
3647
// default to index 0 when begin

0 commit comments

Comments
 (0)