This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UART application using USB CDC Device Class?



Hello,

I am using an LX4FS1A. I have an application that uses UARTstdio.c that I am trying to convert to work through the USB port using the CDC driver. I am able to get my hardware to show up as a virtual COM port and I can send strings back and forth using USBBufferWrite(). 

Is there a way to still use the UARTstdio.c functions when the device is configured as a CDC device? I want to use UARTgets() for command line processing and I want to use UARTprintf() and have it sent out the USB port.

Thanks,

Casey

  • Casey,

    To do this properly you can use the UARTstdio.c as a base but you will have to write a specific "USBstdio.c" or you could edit the UARTstdio.c code to look for the USB connection and then communicate over USB opposed to the UART. In summary we do not have any examples that do this already and no you can't use it UARTstdio.c as is to do what you are asking(at least that I know), sorry.

    -Sheldon  

  • Casey,

    In case you're interested, I've taken the existing ek-lm4f120xl project usb_dev_serial and modified it along with the StellarisWare utility uartstdio.c files to make an example command line project using the Stellaris LaunchPad board's USB Device port as a virtual COM port without the UART on the LM4F120 side. I called the modified UART stdio USB Stdio and it includes similar functionality only with the USB port instead of a UART. It works basically the same and includes a buffered and non-buffered version controlled by a similar #define called USB_BUFFERED. The buffered version includes a transmit and receive buffer between the USB Stdio printf() and gets() functions and the USB library functions while the non-buffered version connects the USB Stdio printf() and gets() functions directly to the USB library functions with no additional buffering. Below is a screenshot of part of the Doxygen output showing the supported public API functions.

    As with the UART Stdio API, the top 5 functions are supported in both the buffered and non-buffered mode while the bottom 6 functions are supported in buffered mode only.

    The example command line application from the virtual serial port does not do much except display and process a short menu of commands using these USB Stdio API functions. A representative example partial screenshot is as follows:

    As you can see, in addition to responding to some commands, the example also displays which buttons have been pressed on the Stellaris LaunchPad board.

    If you find this useful as a starting point for what you need, you're welcome to use my example. I've attached a zip file with all of the source files and other related files, including the Makefile and HTML doxygen output files. An executable version (.bin) is also included that can be loaded and run on the stock Stellaris LaunchPad board. The board's DEBUG USB port shows debug output on it's virtual serial port and the board's DEVICE USB port is another virtual serial port that provides the command line application as described above.

    8463.USB_Stdio.zip

    I don't use the any of the official T.I. development environments for my Stellaris development, but use the Yagarto GCC tools instead. The zip file contains the directory structure used and the Makefile has references to the StellarisWare library and utilities directories, which you will need to build this example.

    Dan

  • Hi Dan,

    Thanks for the quick response. This seems to be exactly what I was looking for.

    Thanks for sharing your code. I will try to get it incorporated into my project. I may come back to this post for help I run into any issues.

    Casey