diff options
| author | hathach <[email protected]> | 2018-03-08 15:00:38 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-03-08 15:03:03 +0700 |
| commit | b608f8895a30b01441a2c43feaf00148b6b6f1e3 (patch) | |
| tree | 914f9a1d46ac7944a31e458f3aff63d57a6242bf /examples/device/device_virtual_com/src/main.c | |
| parent | 23fa9eeebe1581e4cc877a2fe52336469974ddc9 (diff) | |
clean up virtual com example
Diffstat (limited to 'examples/device/device_virtual_com/src/main.c')
| -rw-r--r-- | examples/device/device_virtual_com/src/main.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/examples/device/device_virtual_com/src/main.c b/examples/device/device_virtual_com/src/main.c index baf946a56..25f78ebd2 100644 --- a/examples/device/device_virtual_com/src/main.c +++ b/examples/device/device_virtual_com/src/main.c @@ -46,8 +46,6 @@ #include "bsp/board.h" #include "tusb.h" -#include "cdc_device_app.h" - //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF //--------------------------------------------------------------------+ @@ -57,6 +55,7 @@ //--------------------------------------------------------------------+ void print_greeting(void); void led_blinking_task(void); +void virtual_com_task(void); /*------------- MAIN -------------*/ int main(void) @@ -66,31 +65,46 @@ int main(void) tusb_init(); - //------------- application task init -------------// - cdc_serial_app_init(); - while (1) { tusb_task(); led_blinking_task(); - cdc_serial_app_task(); + virtual_com_task(); } return 0; } +void virtual_com_task(void) +{ + // connected and there are data available + if ( tud_mounted(0) && tud_cdc_available(0) ) + { + uint8_t buf[64]; + + // read and echo back + uint32_t count = tud_cdc_read(0, buf, sizeof(buf)); + + tud_cdc_write(0, buf, count); + } +} + + //--------------------------------------------------------------------+ // tinyusb callbacks //--------------------------------------------------------------------+ void tud_mount_cb(uint8_t coreid) { - cdc_serial_app_mount(coreid); + } void tud_umount_cb(uint8_t coreid) { - cdc_serial_app_umount(coreid); +} + +void tud_cdc_rx_cb(uint8_t coreid) +{ } //--------------------------------------------------------------------+ |
