AnsweredAssumed Answered

Questions about SDK 2.3.1 USB CDC VCOM Example

Question asked by Keith Smith on Apr 24, 2018
Latest reply on May 9, 2018 by Daniel Chen

I have questions about the USB CDC VCOM FreeRTOS example as well as the USB Middleware stack.



The example is basically a poll loop in the main application waiting for USB data, one character at a time. I would like to have the application wait for a fully formed message. My questions below are to clarify my understanding of the USB stack to remove the polling in favor of a 'wait for message'.



1 - It appears that the CDC class receives one character at time.

Is this correct?


There is a configuration file, usb_device_config.h, which is provided for each USB example.

All the defines are #define USB_DEVICE_CONFIG_xxx.


2 - The #define USB_DEVICE_CONFIG_USE_TASK (1) is used to configure the USB stack to run in its own task.

The design of the cdc callback, USB_DeviceCdcVcomCallback(), in virtual_com.<c,h> is such that regardless of the value of USB_DEVICE_CONFIG_USE_TASK,  USB_DeviceCdcVcomCallback() is called to handle the CDC class events.

In the non-task case, USB_DeviceCdcVcomCallback() is called from within the USB IRQ context.

In the task case, USB_DeviceCdcVcomCallback() is called within the USB task context. [The USB IRQ issues a FreeRTOS xQueueSendToBackFromISR() message from USB_OsaMsgqSend() to the USB task to handle the cdc class events.]

Is this correct?


3- In USB_DeviceCdcVcomCallback(), there are two events, kUSB_DeviceCdcEventSendResponse, and kUSB_DeviceCdcEventRecvResponse.

It would appear that any data handling or additional messages to another task to handle the USB data stream would be placed in these case statements.

Is this correct?

There is a comment in the kUSB_DeviceCdcEventSendResponse case

/* User: add your own code for send complete event */ but not such a comment for the kUSB_DeviceCdcEventRecvResponse case.


4 - If a FreeRTOS message is sent from these two cases, then the #define USB_DEVICE_CONFIG_USE_TASK would have to select between SendFromISR or Send, as the context of USB_DeviceCdcVcomCallback() changes.

Is this correct?



[BTW, there are many typos in the comments in just about every USB middleware file. Using Eclipse, the typos are automatically highlighted. Some typos are difficult to understand, did the author mean 'reserved' or 'reversed'?]