/* Task to read in data received from the attached CDC device and print it to the serial port.  */
void CDCHost_Task(void)
/* Task to read in data received from the attached CDC device and print it to the serial port.  */
void CDCHost_Task(void)
{
	if (USB_HostState != HOST_STATE_Configured)
	  return;
	Pipe_SelectPipe(CDC_DATA_IN_PIPE);
	Pipe_Unfreeze();
	if (Pipe_IsINReceived())
	{
		Pipe_Freeze();
		if (Pipe_IsReadWriteAllowed())
		{
			uint16_t BufferLength = Pipe_BytesInPipe();
			uint8_t  Buffer[BufferLength];
			Pipe_Read_Stream_LE(Buffer, BufferLength, NULL);
			for (uint16_t BufferByte = 0; BufferByte < BufferLength; BufferByte++)
			  putchar(Buffer[BufferByte]);
		}
		Pipe_ClearIN();
	}
	Pipe_Freeze();
	Pipe_SelectPipe(CDC_NOTIFICATION_PIPE);
	Pipe_Unfreeze();
	if (Pipe_IsINReceived())
	{
		Pipe_ClearIN();
	}
	Pipe_Freeze();
}