aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-07-27 10:55:21 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-07-27 10:55:21 +0000
commitb9dd51cd632c1a8cff18f77b4f09c33bdf804768 (patch)
treefdd996d102f100e63b10cb90dc19a48aa6888f8e
parent84c3c4a3d90e7f890c61d4640c2d65a469b42b79 (diff)
downloadlufa-b9dd51cd632c1a8cff18f77b4f09c33bdf804768.tar.gz
lufa-b9dd51cd632c1a8cff18f77b4f09c33bdf804768.tar.bz2
lufa-b9dd51cd632c1a8cff18f77b4f09c33bdf804768.zip
Collapse configuration descriptor size retrieval and size testing into a single if statement within the new host mode class driver demos for clarity.
-rw-r--r--Demos/Host/ClassDriver/CDCHost/CDCHost.c13
-rw-r--r--Demos/Host/ClassDriver/MouseHost/MouseHost.c13
-rw-r--r--LUFA/Drivers/USB/Class/Host/HID.h9
3 files changed, 13 insertions, 22 deletions
diff --git a/Demos/Host/ClassDriver/CDCHost/CDCHost.c b/Demos/Host/ClassDriver/CDCHost/CDCHost.c
index b74c39418..291e8359e 100644
--- a/Demos/Host/ClassDriver/CDCHost/CDCHost.c
+++ b/Demos/Host/ClassDriver/CDCHost/CDCHost.c
@@ -77,17 +77,10 @@ int main(void)
uint16_t ConfigDescriptorSize;
uint8_t ConfigDescriptorData[512];
- if (USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful)
+ if ((USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful) ||
+ (ConfigDescriptorSize > sizeof(ConfigDescriptorData)))
{
- 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");
+ printf("Error Retrieving Configuration Descriptor.\r\n");
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
diff --git a/Demos/Host/ClassDriver/MouseHost/MouseHost.c b/Demos/Host/ClassDriver/MouseHost/MouseHost.c
index c2850cfec..6913ec3cb 100644
--- a/Demos/Host/ClassDriver/MouseHost/MouseHost.c
+++ b/Demos/Host/ClassDriver/MouseHost/MouseHost.c
@@ -79,22 +79,15 @@ int main(void)
uint16_t ConfigDescriptorSize;
uint8_t ConfigDescriptorData[512];
- if (USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful)
+ if ((USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful) ||
+ (ConfigDescriptorSize > sizeof(ConfigDescriptorData)))
{
- printf("Error Retrieving Device Descriptor.\r\n");
+ printf("Error Retrieving Configuration 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 (HID_Host_ConfigurePipes(&Mouse_HID_Interface,
diff --git a/LUFA/Drivers/USB/Class/Host/HID.h b/LUFA/Drivers/USB/Class/Host/HID.h
index 1959fd265..344c06f06 100644
--- a/LUFA/Drivers/USB/Class/Host/HID.h
+++ b/LUFA/Drivers/USB/Class/Host/HID.h
@@ -66,8 +66,13 @@
uint8_t DataINPipeNumber; /**< Pipe number of the HID interface's IN data pipe */
uint8_t DataOUTPipeNumber; /**< Pipe number of the HID interface's OUT data pipe */
- bool MatchInterfaceProtocol;
- uint8_t HIDInterfaceProtocol;
+ bool MatchInterfaceProtocol; /**< Indicates whether the driver should match the device's
+ * HID interface protocol's value to the \ref HIDInterfaceProtocol
+ * suppled (otherwise just accept all HID class devices)
+ */
+ uint8_t HIDInterfaceProtocol; /**< HID interface protocol value to match against if the
+ * \ref MatchInterfaceProtocol is set to true (ignored otherwise)
+ */
} Config; /**< Config data for the USB class interface within the device. All elements in this section
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
*/