summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJan Dümpelmann <[email protected]>2020-11-18 10:16:32 +0100
committerJan Dümpelmann <[email protected]>2020-11-18 10:16:32 +0100
commit6a72cc5d483142a6d7120fb569a6a1225d8a04b0 (patch)
tree37927f0cdfca57ed3b1e6dbc6ebe26623a3541c8 /examples
parente7069da7eb41c8af6801b1404acd81d745eb8b83 (diff)
Changes to CDC example code:
- auto flush welcome message at connection event - provide information to the user if the terminal did not set DTR
Diffstat (limited to 'examples')
-rw-r--r--examples/device/cdc_msc/src/main.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/examples/device/cdc_msc/src/main.c b/examples/device/cdc_msc/src/main.c
index a407e2ddd..e4477927f 100644
--- a/examples/device/cdc_msc/src/main.c
+++ b/examples/device/cdc_msc/src/main.c
@@ -137,6 +137,7 @@ void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
{
// print initial message when connected
tud_cdc_write_str("\r\nTinyUSB CDC MSC device example\r\n");
+ tud_cdc_write_flush();
}
}
@@ -144,6 +145,16 @@ void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
void tud_cdc_rx_cb(uint8_t itf)
{
(void) itf;
+ uint8_t const line_state = tud_cdc_get_line_state();
+
+ // Provide information that terminal did not set DTR bit
+ if( !(line_state & 0x01) )
+ {
+ tud_cdc_write_str("\r\nTinyUSB example: Your terminal did not set DTR bit\r\n");
+ tud_cdc_write_flush();
+ // Clear rx fifo since we do not read the data
+ tud_cdc_read_flush();
+ }
}
//--------------------------------------------------------------------+