summaryrefslogtreecommitdiff
path: root/examples/device/cdc_msc
diff options
context:
space:
mode:
authorJan Dümpelmann <[email protected]>2020-11-18 09:47:39 +0100
committerJan Dümpelmann <[email protected]>2020-11-18 09:47:39 +0100
commite7069da7eb41c8af6801b1404acd81d745eb8b83 (patch)
tree01ddd5bd8811f9a4d8843bd01c78dc6f90d548b0 /examples/device/cdc_msc
parent54e29e9ff451d5e30eb59d0411adbe5d4993c59b (diff)
Reset CDC examples to original state
Diffstat (limited to 'examples/device/cdc_msc')
-rw-r--r--examples/device/cdc_msc/src/main.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/examples/device/cdc_msc/src/main.c b/examples/device/cdc_msc/src/main.c
index bcf05eaac..a407e2ddd 100644
--- a/examples/device/cdc_msc/src/main.c
+++ b/examples/device/cdc_msc/src/main.c
@@ -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];
+ // connected and there are data available
+ if ( tud_cdc_available() )
+ {
+ uint8_t buf[64];
- // read and echo back
- uint32_t count = tud_cdc_read(buf, sizeof(buf));
+ // 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]);
+ for(uint32_t i=0; i<count; i++)
+ {
+ tud_cdc_write_char(buf[i]);
- if ( buf[i] == '\r' ) tud_cdc_write_char('\n');
- }
+ 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