X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/be9d0a5aa97c84cc8723f69f2b88576965e386aa..f69f03cb0d02937dee018264f0ac4e9be76fc1f4:/Demos/Host/ClassDriver/CDCHost/CDCHost.c diff --git a/Demos/Host/ClassDriver/CDCHost/CDCHost.c b/Demos/Host/ClassDriver/CDCHost/CDCHost.c index 99c0c8172..4b08f7d57 100644 --- a/Demos/Host/ClassDriver/CDCHost/CDCHost.c +++ b/Demos/Host/ClassDriver/CDCHost/CDCHost.c @@ -44,33 +44,16 @@ USB_ClassInfo_CDC_Host_t VirtualSerial_CDC_Interface = { .Config = { - .DataINPipeNumber = 1, - .DataOUTPipeNumber = 2, - .NotificationPipeNumber = 3, - }, - }; - -#if 0 -/* NOTE: Here you can set up a standard stream using the created virtual serial port, so that the standard stream functions in - * can be used on the virtual serial port (e.g. fprintf(&USBSerial, "Test"); to print a string). - */ - -static int CDC_putchar(char c, FILE *stream) -{ - CDC_Host_SendByte(&VirtualSerial_CDC_Interface, c); - return 0; -} - -static int CDC_getchar(FILE *stream) -{ - if (!(CDC_Host_BytesReceived(&VirtualSerial_CDC_Interface))) - return -1; + .DataINPipeNumber = 1, + .DataINPipeDoubleBank = false, - return CDC_Host_ReceiveByte(&VirtualSerial_CDC_Interface); -} + .DataOUTPipeNumber = 2, + .DataOUTPipeDoubleBank = false, -static FILE USBSerial = FDEV_SETUP_STREAM(CDC_putchar, CDC_getchar, _FDEV_SETUP_RW); -#endif + .NotificationPipeNumber = 3, + .NotificationPipeDoubleBank = false, + }, + }; /** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. @@ -93,8 +76,8 @@ int main(void) uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; - if (USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, - sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) + if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, + sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) { printf("Error Retrieving Configuration Descriptor.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -128,6 +111,8 @@ int main(void) /* Echo received bytes from the attached device through the USART */ while (CDC_Host_BytesReceived(&VirtualSerial_CDC_Interface)) putchar(CDC_Host_ReceiveByte(&VirtualSerial_CDC_Interface)); + + CDC_Host_Flush(&VirtualSerial_CDC_Interface); } break;