Collapse configuration descriptor size retrieval and size testing into a single if statement within the new host mode class driver demos for clarity.
This commit is contained in:
parent
84c3c4a3d9
commit
b9dd51cd63
3 changed files with 13 additions and 22 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue