Skip to content

Instantly share code, notes, and snippets.

@blondie7575
Created August 29, 2015 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blondie7575/a90f51fd413b6767cbf4 to your computer and use it in GitHub Desktop.
Save blondie7575/a90f51fd413b6767cbf4 to your computer and use it in GitHub Desktop.
// 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