aboutsummaryrefslogtreecommitdiffstats
path: root/Demos
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-07-27 10:48:55 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-07-27 10:48:55 +0000
commit84c3c4a3d90e7f890c61d4640c2d65a469b42b79 (patch)
treee498b8aea50aab1aa6931b775c0d68154c7db348 /Demos
parent5251bc6e4e312ec5c4f57c43a92ba49c19684c51 (diff)
downloadlufa-84c3c4a3d90e7f890c61d4640c2d65a469b42b79.tar.gz
lufa-84c3c4a3d90e7f890c61d4640c2d65a469b42b79.tar.bz2
lufa-84c3c4a3d90e7f890c61d4640c2d65a469b42b79.zip
Change Host mode class driver Pipe configuration routines -- better to let the application fetch the configuration descriptors once, and then pass them to each class driver in turn.
Diffstat (limited to 'Demos')
-rw-r--r--Demos/Host/ClassDriver/CDCHost/CDCHost.c28
-rw-r--r--Demos/Host/ClassDriver/MouseHost/MouseHost.c28
2 files changed, 48 insertions, 8 deletions
diff --git a/Demos/Host/ClassDriver/CDCHost/CDCHost.c b/Demos/Host/ClassDriver/CDCHost/CDCHost.c
index 4479e4fb8..b74c39418 100644
--- a/Demos/Host/ClassDriver/CDCHost/CDCHost.c
+++ b/Demos/Host/ClassDriver/CDCHost/CDCHost.c
@@ -74,10 +74,31 @@ int main(void)
case HOST_STATE_Addressed:
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
- if (CDC_Host_ConfigurePipes(&VirtualSerial_CDC_Interface, 512) != CDC_ENUMERROR_NoError)
+ uint16_t ConfigDescriptorSize;
+ uint8_t ConfigDescriptorData[512];
+
+ if (USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful)
{
- printf("Attached device is not a valid CDC device.\r\n");
+ printf("Error Retrieving Device Descriptor.\r\n");
+ LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
+ break;
+ }
+ if (ConfigDescriptorSize > 512)
+ {
+ printf("Device Descriptor Too Large To Process.\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;
@@ -86,12 +107,11 @@ 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;
diff --git a/Demos/Host/ClassDriver/MouseHost/MouseHost.c b/Demos/Host/ClassDriver/MouseHost/MouseHost.c
index 88518a845..c2850cfec 100644
--- a/Demos/Host/ClassDriver/MouseHost/MouseHost.c
+++ b/Demos/Host/ClassDriver/MouseHost/MouseHost.c
@@ -76,10 +76,31 @@ int main(void)
case HOST_STATE_Addressed:
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
- if (HID_Host_ConfigurePipes(&Mouse_HID_Interface, 512) != HID_ENUMERROR_NoError)
+ uint16_t ConfigDescriptorSize;
+ uint8_t ConfigDescriptorData[512];
+
+ if (USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful)
+ {
+ printf("Error Retrieving Device Descriptor.\r\n");
+ LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
+ break;
+ }
+
+ if (ConfigDescriptorSize > 512)
{
- printf("Attached device is not a valid Mouse.\r\n");
-
+ printf("Device Descriptor Too Large To Process.\r\n");
+ LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
+ break;
+ }
+
+ USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData);
+
+ if (HID_Host_ConfigurePipes(&Mouse_HID_Interface,
+ ConfigDescriptorSize, ConfigDescriptorData) != HID_ENUMERROR_NoError)
+ {
+ printf("Attached Device Not a Valid Mouse.\r\n");
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
@@ -88,7 +109,6 @@ 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;