Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Pseudo-code. May not compile or work
for (;;)
{
// Check for host data
uint16_t byteCount = CDC_Device_BytesReceived(&EETool_CDC_Interface);
byteCount = MIN(byteCount,BUFF_SIZE-1);
if (byteCount>BUFF_SIZE)
{
FatalError();
}
if (byteCount>0)
{
// Read all data from host
int i;
for (i=0; i<byteCount; i++)
{
int16_t value = CDC_Device_ReceiveByte(&EETool_CDC_Interface);
if (value>=0)
{
gCommBuffer[i] = (uint8_t)value;
}
}
// Echo it back
CDC_Device_SendData(&EETool_CDC_Interface, gCommBuffer, byteCount);
}
CDC_Device_USBTask(&EETool_CDC_Interface);
USB_USBTask();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.