diff --git a/examples/device/cdc_msc_hid/src/usb_descriptors.c b/examples/device/cdc_msc_hid/src/usb_descriptors.c index b06658c5..4220dc5f 100644 --- a/examples/device/cdc_msc_hid/src/usb_descriptors.c +++ b/examples/device/cdc_msc_hid/src/usb_descriptors.c @@ -124,10 +124,7 @@ enum ITF_NUM_TOTAL }; -enum -{ - CONFIG_TOTAL_LEN = TUD_CONFIG_DESC_LEN + CFG_TUD_CDC*TUD_CDC_DESC_LEN + CFG_TUD_MSC*TUD_MSC_DESC_LEN + CFG_TUD_HID*TUD_HID_DESC_LEN -}; +#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + CFG_TUD_CDC*TUD_CDC_DESC_LEN + CFG_TUD_MSC*TUD_MSC_DESC_LEN + CFG_TUD_HID*TUD_HID_DESC_LEN) #if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX // LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number diff --git a/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c b/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c index 65c8cd71..4e1df9fb 100644 --- a/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c +++ b/examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c @@ -124,10 +124,7 @@ enum ITF_NUM_TOTAL }; -enum -{ - CONFIG_TOTAL_LEN = TUD_CONFIG_DESC_LEN + CFG_TUD_CDC*TUD_CDC_DESC_LEN + CFG_TUD_MSC*TUD_MSC_DESC_LEN + CFG_TUD_HID*TUD_HID_DESC_LEN -}; +#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + CFG_TUD_CDC*TUD_CDC_DESC_LEN + CFG_TUD_MSC*TUD_MSC_DESC_LEN + CFG_TUD_HID*TUD_HID_DESC_LEN) #if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX // LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number diff --git a/examples/device/hid_generic_inout/src/usb_descriptors.c b/examples/device/hid_generic_inout/src/usb_descriptors.c index 516dab64..849c2be8 100644 --- a/examples/device/hid_generic_inout/src/usb_descriptors.c +++ b/examples/device/hid_generic_inout/src/usb_descriptors.c @@ -92,10 +92,8 @@ enum ITF_NUM_TOTAL }; -enum -{ - CONFIG_TOTAL_LEN = TUD_CONFIG_DESC_LEN + TUD_HID_INOUT_DESC_LEN -}; + +#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_HID_INOUT_DESC_LEN) // Use Endpoint 2 instead of 1 due to NXP MCU // LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number diff --git a/examples/device/midi_test/src/usb_descriptors.c b/examples/device/midi_test/src/usb_descriptors.c index cffef0fb..85cffffc 100644 --- a/examples/device/midi_test/src/usb_descriptors.c +++ b/examples/device/midi_test/src/usb_descriptors.c @@ -77,10 +77,7 @@ enum ITF_NUM_TOTAL }; -enum -{ - CONFIG_TOTAL_LEN = TUD_CONFIG_DESC_LEN + TUD_MIDI_DESC_LEN -}; +#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_MIDI_DESC_LEN) // Use Endpoint 2 instead of 1 due to NXP MCU // LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number diff --git a/examples/device/msc_dual_lun/src/usb_descriptors.c b/examples/device/msc_dual_lun/src/usb_descriptors.c index c4e171c0..585588a9 100644 --- a/examples/device/msc_dual_lun/src/usb_descriptors.c +++ b/examples/device/msc_dual_lun/src/usb_descriptors.c @@ -75,10 +75,7 @@ enum ITF_NUM_TOTAL }; -enum -{ - CONFIG_TOTAL_LEN = TUD_CONFIG_DESC_LEN + TUD_MSC_DESC_LEN -}; +#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_MSC_DESC_LEN) // Use Endpoint 2 instead of 1 due to NXP MCU // LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number diff --git a/examples/device/webusb/src/main.c b/examples/device/webusb/src/main.c index 6d96eba0..59e93493 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