while (1) { // Loop forever //VCOM_Serial2Usb(); // Read serial and write to USB VCOM_CheckSerialState(); // Update serial states //VCOM_Usb2Serial(); // Read USB and write serial VCOM_Usb2Usb(); // Read USB and write to USB } // end while |
/*---------------------------------------------------------------------------- Reads character from USB buffer and writes back to USB buffer *---------------------------------------------------------------------------*/ void VCOM_Usb2Usb(void){ static char serBuf [32]; int numBytesToRead, numBytesRead, numAvailByte; /* Get USB VCOM received bytes */ CDC_OutBufAvailChar (&numAvailByte); if (numAvailByte > 0) { numBytesToRead = numAvailByte > 32 ? 32 : numAvailByte; numBytesRead = CDC_RdOutBuf (&serBuf[0], &numBytesToRead); /* Write bytes to USB VCOM */ USB_WriteEP (CDC_DEP_IN, (unsigned char *)&serBuf[0], numBytesRead); } } |