Created
August 29, 2015 22:51
-
-
Save blondie7575/a90f51fd413b6767cbf4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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