USB CDC example has flaws

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by rjm on Thu Oct 15 07:25:26 MST 2015
today, I tested "usbd_rom_cdc" Example for LPC1549.

The code works well, demonstrating echoing characters that are typed in a terminal emulator that connects to the target via a CDC-ACM virtual COM-port.

However, when I send a file from the terminal emulator, data loss occurs.
It has been found out that the design of the buffer structure, where data is buffered into an interrupt routine and unbuffered into a function loop at the main loop level is not OK. It would have been better when the buffer structure was designed à la fifo, in order to ensure no data loss. Under such circumstances, the code could be reused in own applications without pain.

In the situation "as is", the appropriate code segments aren't readable well, and the small portions of interrupt disable aren't necessary, too, when the buffer structure would have been implemented well.