Commit 76d5e99b authored by Dean Camera's avatar Dean Camera
Browse files

Fix to previous patch (make CDCHost demo deallocate pipes when an invalid CDC...

Fix to previous patch (make CDCHost demo deallocate pipes when an invalid CDC interface is skipped).

Remove the saving of the USB_GetNextDescriptorComp() return value in all host demos, since it went unused anyway; replaced with a simple check against the success error code for clarity.
parent fabfdd45
...@@ -70,7 +70,8 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -70,7 +70,8 @@ uint8_t ProcessConfigurationDescriptor(void)
return InvalidConfigDataReturned; return InvalidConfigDataReturned;
/* Get the CDC control interface from the configuration descriptor */ /* Get the CDC control interface from the configuration descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextCDCControlInterface)) if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoCDCInterfaceFound; return NoCDCInterfaceFound;
...@@ -81,13 +82,14 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -81,13 +82,14 @@ uint8_t ProcessConfigurationDescriptor(void)
{ {
/* Fetch the next bulk or interrupt endpoint from the current CDC interface */ /* Fetch the next bulk or interrupt endpoint from the current CDC interface */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceCDCDataEndpoint)) NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Check to see if the control interface's notification pipe has been found, if so search for the data interface */ /* Check to see if the control interface's notification pipe has been found, if so search for the data interface */
if (FoundEndpoints & (1 << CDC_NOTIFICATIONPIPE)) if (FoundEndpoints & (1 << CDC_NOTIFICATIONPIPE))
{ {
/* Get the next CDC data interface from the configuration descriptor (CDC class has two CDC interfaces) */ /* Get the next CDC data interface from the configuration descriptor (CDC class has two CDC interfaces) */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextCDCDataInterface)) if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextCDCDataInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoCDCInterfaceFound; return NoCDCInterfaceFound;
...@@ -98,13 +100,17 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -98,13 +100,17 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Clear the found endpoints mask, since any already processed endpoints aren't in the CDC interface we need */ /* Clear the found endpoints mask, since any already processed endpoints aren't in the CDC interface we need */
FoundEndpoints = 0; FoundEndpoints = 0;
/* Disable any already configured endpoints from the invalid CDC interfaces */ /* Disable any already configured pipes from the invalid CDC interfaces */
Endpoint_DisableEndpoint(CDC_NOTIFICATIONPIPE); Pipe_SelectPipe(CDC_NOTIFICATIONPIPE);
Endpoint_DisableEndpoint(CDC_DATAPIPE_IN); Pipe_DisablePipe();
Endpoint_DisableEndpoint(CDC_DATAPIPE_OUT); Pipe_SelectPipe(CDC_DATAPIPE_IN);
Pipe_DisablePipe();
Pipe_SelectPipe(CDC_DATAPIPE_OUT);
Pipe_DisablePipe();
/* Get the next CDC control interface from the configuration descriptor (CDC class has two CDC interfaces) */ /* Get the next CDC control interface from the configuration descriptor (CDC class has two CDC interfaces) */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextCDCControlInterface)) if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoCDCInterfaceFound; return NoCDCInterfaceFound;
...@@ -113,7 +119,7 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -113,7 +119,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Fetch the next bulk or interrupt endpoint from the current CDC interface */ /* Fetch the next bulk or interrupt endpoint from the current CDC interface */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceCDCDataEndpoint)) NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoEndpointFound; return NoEndpointFound;
......
...@@ -71,7 +71,8 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -71,7 +71,8 @@ uint8_t ProcessConfigurationDescriptor(void)
return InvalidConfigDataReturned; return InvalidConfigDataReturned;
/* Get the HID interface from the configuration descriptor */ /* Get the HID interface from the configuration descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextHIDInterface)) if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoHIDInterfaceFound; return NoHIDInterfaceFound;
...@@ -80,7 +81,8 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -80,7 +81,8 @@ uint8_t ProcessConfigurationDescriptor(void)
while (FoundEndpoints != ((1 << HID_DATA_IN_PIPE) | (1 << HID_DATA_OUT_PIPE))) while (FoundEndpoints != ((1 << HID_DATA_IN_PIPE) | (1 << HID_DATA_OUT_PIPE)))
{ {
/* Get the next HID interface's data endpoint descriptor */ /* Get the next HID interface's data endpoint descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextInterfaceHIDDataEndpoint)) if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceHIDDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Not all HID devices have an OUT endpoint - if we've reached the end of the HID descriptor /* Not all HID devices have an OUT endpoint - if we've reached the end of the HID descriptor
* but only found the mandatory IN endpoint, it's safe to continue with the device enumeration */ * but only found the mandatory IN endpoint, it's safe to continue with the device enumeration */
......
...@@ -69,7 +69,8 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -69,7 +69,8 @@ uint8_t ProcessConfigurationDescriptor(void)
return InvalidConfigDataReturned; return InvalidConfigDataReturned;
/* Get the keyboard interface from the configuration descriptor */ /* Get the keyboard interface from the configuration descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextKeyboardInterface)) if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoHIDInterfaceFound; return NoHIDInterfaceFound;
...@@ -77,7 +78,7 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -77,7 +78,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the keyboard interface's data endpoint descriptor */ /* Get the keyboard interface's data endpoint descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceKeyboardDataEndpoint)) NextInterfaceKeyboardDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoEndpointFound; return NoEndpointFound;
......
...@@ -49,7 +49,6 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -49,7 +49,6 @@ uint8_t ProcessConfigurationDescriptor(void)
{ {
uint8_t* ConfigDescriptorData; uint8_t* ConfigDescriptorData;
uint16_t ConfigDescriptorSize; uint16_t ConfigDescriptorSize;
uint8_t ErrorCode;
/* Get Configuration Descriptor size from the device */ /* Get Configuration Descriptor size from the device */
if (USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful) if (USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful)
...@@ -70,14 +69,16 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -70,14 +69,16 @@ uint8_t ProcessConfigurationDescriptor(void)
return InvalidConfigDataReturned; return InvalidConfigDataReturned;
/* Get the keyboard interface from the configuration descriptor */ /* Get the keyboard interface from the configuration descriptor */
if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextKeyboardInterface))) if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoHIDInterfaceFound; return NoHIDInterfaceFound;
} }
/* Get the keyboard interface's HID descriptor */ /* Get the keyboard interface's HID descriptor */
if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextHID))) if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextHID) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoHIDDescriptorFound; return NoHIDDescriptorFound;
...@@ -87,8 +88,8 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -87,8 +88,8 @@ uint8_t ProcessConfigurationDescriptor(void)
HIDReportSize = DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_HID_t).HIDReportLength; HIDReportSize = DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_HID_t).HIDReportLength;
/* Get the keyboard interface's data endpoint descriptor */ /* Get the keyboard interface's data endpoint descriptor */
if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceKeyboardDataEndpoint))) NextInterfaceKeyboardDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoEndpointFound; return NoEndpointFound;
......
...@@ -49,7 +49,6 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -49,7 +49,6 @@ uint8_t ProcessConfigurationDescriptor(void)
{ {
uint8_t* ConfigDescriptorData; uint8_t* ConfigDescriptorData;
uint16_t ConfigDescriptorSize; uint16_t ConfigDescriptorSize;
uint8_t ErrorCode;
uint8_t FoundEndpoints = 0; uint8_t FoundEndpoints = 0;
/* Get Configuration Descriptor size from the device */ /* Get Configuration Descriptor size from the device */
...@@ -71,8 +70,8 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -71,8 +70,8 @@ uint8_t ProcessConfigurationDescriptor(void)
return InvalidConfigDataReturned; return InvalidConfigDataReturned;
/* Get the mass storage interface from the configuration descriptor */ /* Get the mass storage interface from the configuration descriptor */
if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextMassStorageInterface))) NextMassStorageInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoInterfaceFound; return NoInterfaceFound;
...@@ -82,8 +81,8 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -82,8 +81,8 @@ uint8_t ProcessConfigurationDescriptor(void)
while (FoundEndpoints != ((1 << MASS_STORE_DATA_IN_PIPE) | (1 << MASS_STORE_DATA_OUT_PIPE))) while (FoundEndpoints != ((1 << MASS_STORE_DATA_IN_PIPE) | (1 << MASS_STORE_DATA_OUT_PIPE)))
{ {
/* Fetch the next bulk endpoint from the current mass storage interface */ /* Fetch the next bulk endpoint from the current mass storage interface */
if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceBulkDataEndpoint))) NextInterfaceBulkDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoEndpointFound; return NoEndpointFound;
......
...@@ -69,7 +69,8 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -69,7 +69,8 @@ uint8_t ProcessConfigurationDescriptor(void)
return InvalidConfigDataReturned; return InvalidConfigDataReturned;
/* Get the mouse interface from the configuration descriptor */ /* Get the mouse interface from the configuration descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextMouseInterface)) if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextMouseInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoHIDInterfaceFound; return NoHIDInterfaceFound;
...@@ -77,7 +78,7 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -77,7 +78,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the mouse interface's data endpoint descriptor */ /* Get the mouse interface's data endpoint descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceMouseDataEndpoint)) NextInterfaceMouseDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoEndpointFound; return NoEndpointFound;
......
...@@ -49,7 +49,6 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -49,7 +49,6 @@ uint8_t ProcessConfigurationDescriptor(void)
{ {
uint8_t* ConfigDescriptorData; uint8_t* ConfigDescriptorData;
uint16_t ConfigDescriptorSize; uint16_t ConfigDescriptorSize;
uint8_t ErrorCode;
/* Get Configuration Descriptor size from the device */ /* Get Configuration Descriptor size from the device */
if (USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful) if (USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful)
...@@ -70,14 +69,16 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -70,14 +69,16 @@ uint8_t ProcessConfigurationDescriptor(void)
return InvalidConfigDataReturned; return InvalidConfigDataReturned;
/* Get the mouse interface from the configuration descriptor */ /* Get the mouse interface from the configuration descriptor */
if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextMouseInterface))) if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextMouseInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoHIDInterfaceFound; return NoHIDInterfaceFound;
} }
/* Get the mouse interface's HID descriptor */ /* Get the mouse interface's HID descriptor */
if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextHID))) if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextHID) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoHIDDescriptorFound; return NoHIDDescriptorFound;
...@@ -87,8 +88,8 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -87,8 +88,8 @@ uint8_t ProcessConfigurationDescriptor(void)
HIDReportSize = DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_HID_t).HIDReportLength; HIDReportSize = DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_HID_t).HIDReportLength;
/* Get the mouse interface's data endpoint descriptor */ /* Get the mouse interface's data endpoint descriptor */
if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceMouseDataEndpoint))) NextInterfaceMouseDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoEndpointFound; return NoEndpointFound;
......
...@@ -70,7 +70,8 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -70,7 +70,8 @@ uint8_t ProcessConfigurationDescriptor(void)
return InvalidConfigDataReturned; return InvalidConfigDataReturned;
/* Get the Still Image interface from the configuration descriptor */ /* Get the Still Image interface from the configuration descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextStillImageInterface)) if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextStillImageInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoInterfaceFound; return NoInterfaceFound;
...@@ -81,7 +82,7 @@ uint8_t ProcessConfigurationDescriptor(void) ...@@ -81,7 +82,7 @@ uint8_t ProcessConfigurationDescriptor(void)
{ {
/* Fetch the next endpoint from the current Still Image interface */ /* Fetch the next endpoint from the current Still Image interface */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextSImageInterfaceDataEndpoint)) NextSImageInterfaceDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoEndpointFound; return NoEndpointFound;
......
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
* *
* - Fixed bug in RNDISEthernet and DualCDC demos not using the correct USB_ControlRequest structure for control request data * - Fixed bug in RNDISEthernet and DualCDC demos not using the correct USB_ControlRequest structure for control request data
* - Fixed documentation showing incorrect USB mode support on the supported AVRs list * - Fixed documentation showing incorrect USB mode support on the supported AVRs list
* - Fixed RNDISEthernet not working under Linux due to Linux requiring an "optional" request which was unhandled * - Fixed RNDISEthernet not working under Linux due to Linux requiring an "optional" RNDIS request which was unhandled
* - Fixed Mouse and Keyboard device demos not acting in accordance with the HID specification for idle periods (thanks to Brian Dickman) * - Fixed Mouse and Keyboard device demos not acting in accordance with the HID specification for idle periods (thanks to Brian Dickman)
* - Removed support for endpoint/pipe non-control interrupts; these did not act in the way users expected, and had many subtle issues * - Removed support for endpoint/pipe non-control interrupts; these did not act in the way users expected, and had many subtle issues
* - Fixed Device Mode not handling Set Feature and Clear Feature Chapter 9 requests that are addressed to the device (thanks to Brian Dickman) * - Fixed Device Mode not handling Set Feature and Clear Feature Chapter 9 requests that are addressed to the device (thanks to Brian Dickman)
* - Moved control endpoint interrupt handling into the library itself, enable via the new INTERRUPT_CONTROL_ENDPOINT token * - Moved control endpoint interrupt handling into the library itself, enable via the new INTERRUPT_CONTROL_ENDPOINT token
* - Fixed CDCHost not clearing configured endpoints and resetting configured endpoints mask when a partially enumerated invalid CDC * - Fixed CDCHost not clearing configured pipes and resetting configured pipes mask when a partially enumerated invalid CDC
* interface is skipped * interface is skipped
* *
* *
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment