summaryrefslogtreecommitdiff
path: root/examples/device/cdc_msc/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/device/cdc_msc/src/main.c')
-rw-r--r--examples/device/cdc_msc/src/main.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/examples/device/cdc_msc/src/main.c b/examples/device/cdc_msc/src/main.c
index a407e2ddd..131ae6549 100644
--- a/examples/device/cdc_msc/src/main.c
+++ b/examples/device/cdc_msc/src/main.c
@@ -48,7 +48,6 @@ enum {
static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED;
void led_blinking_task(void);
-
void cdc_task(void);
/*------------- MAIN -------------*/
@@ -105,23 +104,23 @@ void tud_resume_cb(void)
//--------------------------------------------------------------------+
void cdc_task(void)
{
- if ( tud_cdc_connected() )
+ // connected() check for DTR bit
+ // Most but not all terminal client set this when making connection
+ // if ( tud_cdc_connected() )
{
// connected and there are data available
if ( tud_cdc_available() )
{
- uint8_t buf[64];
-
- // read and echo back
+ // read datas
+ char buf[64];
uint32_t count = tud_cdc_read(buf, sizeof(buf));
+ (void) count;
- for(uint32_t i=0; i<count; i++)
- {
- tud_cdc_write_char(buf[i]);
-
- if ( buf[i] == '\r' ) tud_cdc_write_char('\n');
- }
-
+ // Echo back
+ // Note: Skip echo by commenting out write() and write_flush()
+ // for throughput test e.g
+ // $ dd if=/dev/zero of=/dev/ttyACM0 count=10000
+ tud_cdc_write(buf, count);
tud_cdc_write_flush();
}
}
@@ -131,12 +130,15 @@ void cdc_task(void)
void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
{
(void) itf;
+ (void) rts;
- // connected
- if ( dtr && rts )
+ // TODO set some indicator
+ if ( dtr )
+ {
+ // Terminal connected
+ }else
{
- // print initial message when connected
- tud_cdc_write_str("\r\nTinyUSB CDC MSC device example\r\n");
+ // Terminal disconnected
}
}