X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/44179abcf85acb14fb3aff72ce50ae84281c0f2e..c5eeedd522c12c8b4996594f3c4167393d0af7ff:/Demos/Host/ClassDriver/CDCHost/CDCHost.c diff --git a/Demos/Host/ClassDriver/CDCHost/CDCHost.c b/Demos/Host/ClassDriver/CDCHost/CDCHost.c index 65f490f28..0cbb77122 100644 --- a/Demos/Host/ClassDriver/CDCHost/CDCHost.c +++ b/Demos/Host/ClassDriver/CDCHost/CDCHost.c @@ -48,12 +48,8 @@ USB_ClassInfo_CDC_Host_t VirtualSerial_CDC_Interface = .DataOUTPipeNumber = 2, .NotificationPipeNumber = 3, }, - - .State = - { - // Leave all state values to their defaults - } }; + /** Main program entry point. This routine configures the hardware required by the application, then * starts the scheduler to run the application tasks. @@ -71,8 +67,26 @@ int main(void) switch (USB_HostState) { case HOST_STATE_Addressed: - if (!(CDC_Host_ConfigurePipes(&VirtualSerial_CDC_Interface))) + LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); + + uint16_t ConfigDescriptorSize; + uint8_t ConfigDescriptorData[512]; + + if ((USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful) || + (ConfigDescriptorSize > sizeof(ConfigDescriptorData))) + { + printf("Error Retrieving Configuration Descriptor.\r\n"); + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + USB_HostState = HOST_STATE_WaitForDeviceRemoval; + break; + } + + USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData); + + if (CDC_Host_ConfigurePipes(&VirtualSerial_CDC_Interface, + ConfigDescriptorSize, ConfigDescriptorData) != CDC_ENUMERROR_NoError) { + printf("Attached Device Not a Valid CDC Class Device.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; @@ -80,17 +94,16 @@ int main(void) if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { + printf("Error Setting Device Configuration.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + + printf("CDC Device Enumerated.\r\n"); USB_HostState = HOST_STATE_Configured; break; case HOST_STATE_Configured: - USB_HostState = HOST_STATE_Ready; - break; - case HOST_STATE_Ready: break; }