From 2b7acd554a00f196394fdb91cd11a18e7981949f Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 12 Jul 2019 19:38:04 +0700 Subject: updating webusb with cdc --- examples/device/webusb/src/main.c | 48 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'examples/device/webusb/src/main.c') diff --git a/examples/device/webusb/src/main.c b/examples/device/webusb/src/main.c index 6d96eba0b..59e934930 100644 --- a/examples/device/webusb/src/main.c +++ b/examples/device/webusb/src/main.c @@ -54,7 +54,7 @@ enum { static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED; void led_blinking_task(void); -void midi_task(void); +void cdc_task(void); /*------------- MAIN -------------*/ int main(void) @@ -66,6 +66,7 @@ int main(void) while (1) { tud_task(); // tinyusb device task + cdc_task(); led_blinking_task(); } @@ -108,6 +109,51 @@ void tud_resume_cb(void) //--------------------------------------------------------------------+ +//--------------------------------------------------------------------+ +// USB CDC +//--------------------------------------------------------------------+ +void cdc_task(void) +{ + if ( tud_cdc_connected() ) + { + // 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)); + + for(uint32_t i=0; i