Skip to content

Commit 8757287

Browse files
committed
update example for better cdc echo
1 parent 6a022c7 commit 8757287

File tree

1 file changed

+4
-2
lines changed
  • examples/device/cdc_msc_freertos/src

1 file changed

+4
-2
lines changed

examples/device/cdc_msc_freertos/src/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ void usb_device_task(void* param)
134134
tud_task();
135135

136136
// following code only run if tud_task() process at least 1 event
137+
tud_cdc_write_flush();
137138
}
138139
}
139140

@@ -183,7 +184,7 @@ void cdc_task(void* params)
183184
// if ( tud_cdc_connected() )
184185
{
185186
// There are data available
186-
if ( tud_cdc_available() )
187+
while ( tud_cdc_available() )
187188
{
188189
uint8_t buf[64];
189190

@@ -196,8 +197,9 @@ void cdc_task(void* params)
196197
// for throughput test e.g
197198
// $ dd if=/dev/zero of=/dev/ttyACM0 count=10000
198199
tud_cdc_write(buf, count);
199-
tud_cdc_write_flush();
200200
}
201+
202+
tud_cdc_write_flush();
201203
}
202204

203205
// For ESP32-Sx this delay is essential to allow idle how to run and reset watchdog

0 commit comments

Comments
 (0)