Questions about SDK 2.3.1 USB CDC VCOM Example

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Questions about SDK 2.3.1 USB CDC VCOM Example

1,118 Views
Keith4DSmith
Contributor V

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'?]

Tags (1)
0 Kudos
3 Replies

797 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Keith Smith

We are busy at testing SDK2.4.0 now, which will be released very soon. Could you please give more details about the typos in the USB middle ware files?

Regards

Daniel

0 Kudos

797 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Keith:

For question 1:

It appears that the CDC class receives one character at time.Is this correct?

[Daniel]:CDC class can send and receive a buffer at one time, not only a character.

For question 2:  #define USB_DEVICE_CONFIG_USE_TASK (1) is used to configure the USB stack to run in its own task, Is this correct?

[Daniel]:

If  USB_DEVICE_CONFIG_USE_TASK is 0    , it means when USB_DeviceCdcVcomCallback is serviced, cpu is in interrupted mode.

If  USB_DEVICE_CONFIG_USE_TASK is 1,CPU is in normal mode.

In other words, this macro is defined to check whether the callback is trigger by a task, or by an interrupt.

Regards

Daniel

0 Kudos

797 Views
geoffsokoll
Contributor I

Nice questions.  It's a shame no-one from NXP cares to answer them...

0 Kudos