void VCOM_Serial2Usb(void) { static char serBuf [USB_CDC_BUFSIZE]; int numBytesRead, numAvailByte; //ser_AvailChar (&numAvailByte); numAvailByte = USART_available(&usart); if (numAvailByte > 0) { if (CDC_DepInEmpty) { for ( numBytesRead = 0; numBytesRead < numAvailByte && numBytesRead < USB_CDC_BUFSIZE; numBytesRead++) serBuf[numBytesRead] = USART_read(&usart); //ser_Read (&serBuf[0], &numAvailByte); CDC_DepInEmpty = 0; USB_WriteEP (CDC_DEP_IN, (unsigned char *)&serBuf[0], numBytesRead); } } }
unsigned char USART_receive() { while (!USART_available()); return UDR0; }