mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
Reset CDC examples to original state
This commit is contained in:
parent
54e29e9ff4
commit
e7069da7eb
@ -83,15 +83,18 @@ static void cdc_task(void)
|
||||
|
||||
for (itf = 0; itf < CFG_TUD_CDC; itf++)
|
||||
{
|
||||
if ( tud_cdc_n_available(itf) )
|
||||
if ( tud_cdc_n_connected(itf) )
|
||||
{
|
||||
uint8_t buf[64];
|
||||
if ( tud_cdc_n_available(itf) )
|
||||
{
|
||||
uint8_t buf[64];
|
||||
|
||||
uint32_t count = tud_cdc_n_read(itf, buf, sizeof(buf));
|
||||
uint32_t count = tud_cdc_n_read(itf, buf, sizeof(buf));
|
||||
|
||||
// echo back to both serial ports
|
||||
echo_serial_port(0, buf, count);
|
||||
echo_serial_port(1, buf, count);
|
||||
// echo back to both serial ports
|
||||
echo_serial_port(0, buf, count);
|
||||
echo_serial_port(1, buf, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,31 +105,34 @@ void tud_resume_cb(void)
|
||||
//--------------------------------------------------------------------+
|
||||
void cdc_task(void)
|
||||
{
|
||||
// is data available to read from rx fifo
|
||||
if ( tud_cdc_available() )
|
||||
if ( tud_cdc_connected() )
|
||||
{
|
||||
uint8_t buf[64];
|
||||
|
||||
// read and echo back
|
||||
uint32_t count = tud_cdc_read(buf, sizeof(buf));
|
||||
|
||||
for(uint32_t i=0; i<count; i++)
|
||||
// connected and there are data available
|
||||
if ( tud_cdc_available() )
|
||||
{
|
||||
tud_cdc_write_char(buf[i]);
|
||||
uint8_t buf[64];
|
||||
|
||||
if ( buf[i] == '\r' ) tud_cdc_write_char('\n');
|
||||
// read and echo back
|
||||
uint32_t count = tud_cdc_read(buf, sizeof(buf));
|
||||
|
||||
for(uint32_t i=0; i<count; i++)
|
||||
{
|
||||
tud_cdc_write_char(buf[i]);
|
||||
|
||||
if ( buf[i] == '\r' ) tud_cdc_write_char('\n');
|
||||
}
|
||||
|
||||
tud_cdc_write_flush();
|
||||
}
|
||||
|
||||
tud_cdc_write_flush();
|
||||
}
|
||||
}
|
||||
|
||||
// Invoked when cdc line state changed e.g connected/disconnected
|
||||
// Invoked when cdc when line state changed e.g connected/disconnected
|
||||
void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
|
||||
{
|
||||
(void) itf;
|
||||
|
||||
// usually terminal software sets DTR and RTS when connected
|
||||
// connected
|
||||
if ( dtr && rts )
|
||||
{
|
||||
// print initial message when connected
|
||||
|
@ -168,22 +168,25 @@ void cdc_task(void* params)
|
||||
// RTOS forever loop
|
||||
while ( 1 )
|
||||
{
|
||||
// is data available to read from rx fifo
|
||||
if ( tud_cdc_available() )
|
||||
if ( tud_cdc_connected() )
|
||||
{
|
||||
uint8_t buf[64];
|
||||
|
||||
// read and echo back
|
||||
uint32_t count = tud_cdc_read(buf, sizeof(buf));
|
||||
|
||||
for(uint32_t i=0; i<count; i++)
|
||||
// connected and there are data available
|
||||
if ( tud_cdc_available() )
|
||||
{
|
||||
tud_cdc_write_char(buf[i]);
|
||||
uint8_t buf[64];
|
||||
|
||||
if ( buf[i] == '\r' ) tud_cdc_write_char('\n');
|
||||
// read and echo back
|
||||
uint32_t count = tud_cdc_read(buf, sizeof(buf));
|
||||
|
||||
for(uint32_t i=0; i<count; i++)
|
||||
{
|
||||
tud_cdc_write_char(buf[i]);
|
||||
|
||||
if ( buf[i] == '\r' ) tud_cdc_write_char('\n');
|
||||
}
|
||||
|
||||
tud_cdc_write_flush();
|
||||
}
|
||||
|
||||
tud_cdc_write_flush();
|
||||
}
|
||||
|
||||
// For ESP32-S2 this delay is essential to allow idle how to run and reset wdt
|
||||
@ -191,12 +194,12 @@ void cdc_task(void* params)
|
||||
}
|
||||
}
|
||||
|
||||
// Invoked when cdc line state changed e.g connected/disconnected
|
||||
// Invoked when cdc when line state changed e.g connected/disconnected
|
||||
void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
|
||||
{
|
||||
(void) itf;
|
||||
|
||||
// usually terminal software sets DTR and RTS when connected
|
||||
// connected
|
||||
if ( dtr && rts )
|
||||
{
|
||||
// print initial message when connected
|
||||
|
Loading…
x
Reference in New Issue
Block a user