Using the WriteEP function from the USB ROM drivers in LPCOpen

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by psatyshur on Thu Nov 07 18:41:49 MST 2013

I am building a project that will combine the freeRTOS example with the USB CDC example from LPCOpen V2. I have most of the basic stuff done, but I am having problems with the function WriteEP. Specifically, I am using the provided VCOM write function:

/* Virtual com port write routine*/
uint32_t vcom_write(uint8_t *pBuf, uint32_t len)
VCOM_DATA_T *pVcom = &g_vCOM;
uint32_t ret = 0;

if ( (pVcom->tx_flags & VCOM_TX_CONNECTED) && ((pVcom->tx_flags & VCOM_TX_BUSY) == 0) ) {
pVcom->tx_flags |= VCOM_TX_BUSY;

/* enter critical section */
ret = USBD_API->hw->WriteEP(pVcom->hUsb, USB_CDC_IN_EP, pBuf, len);
/* exit critical section */

return ret;

If I call this function slowly (as in, but a delay after each call to this function), everything works fine, but when I call it quickly, there are problems. It appears that the WriteEP function will only let me write to the endpoint once. All other writes are ignored until the computer requests the data from the endpoint. Is this correct?

If so, is there anything stopping me from putting the WriteEP function inside the VCOM_bulk_in_hdlr function, which (I assume) is called inside the USB interrupt? I would then need some sort of buffer that I can fill up with data, and then write it all to the endpoint when computer requests it.