Fix XPLAINBridge code broken during the changes to the Rescue Clock generation in...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 2 Nov 2010 11:16:36 +0000 (11:16 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 2 Nov 2010 11:16:36 +0000 (11:16 +0000)
Change over all low level host mode project's descriptor comparator routines to perform the descriptor casting in a temp variable to make the code clearer and easier to modify (despite being more verbose).

25 files changed:
Demos/Device/LowLevel/Mouse/Mouse.c
Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.c
Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c
Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c
Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c
Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c
Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c
Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c
Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c
Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c
Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c
Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.c
Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c
Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.c
LUFA/Drivers/USB/Class/Host/CDC.c
LUFA/Drivers/USB/Class/Host/HID.c
LUFA/Drivers/USB/Class/Host/MIDI.c
LUFA/Drivers/USB/Class/Host/MassStorage.c
LUFA/Drivers/USB/Class/Host/Printer.c
LUFA/Drivers/USB/Class/Host/RNDIS.c
LUFA/Drivers/USB/Class/Host/StillImage.c
LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h
Projects/AVRISP-MKII/Lib/V2Protocol.c
Projects/MissileLauncher/ConfigDescriptor.c
Projects/XPLAINBridge/Lib/SoftUART.c

index 03d5bbb..3ccd0f0 100644 (file)
@@ -119,7 +119,7 @@ void EVENT_USB_Device_ConfigurationChanged(void)
        ConfigSuccess &= Endpoint_ConfigureEndpoint(MOUSE_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
                                                    MOUSE_EPSIZE, ENDPOINT_BANK_SINGLE);
 
        ConfigSuccess &= Endpoint_ConfigureEndpoint(MOUSE_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
                                                    MOUSE_EPSIZE, ENDPOINT_BANK_SINGLE);
 
-       /* Turn on Start-of-Frame events for tracking HID report period exiry */
+       /* Turn on Start-of-Frame events for tracking HID report period expiry */
        USB_Device_EnableSOFEvents();
 
        /* Indicate endpoint configuration success or failure */
        USB_Device_EnableSOFEvents();
 
        /* Indicate endpoint configuration success or failure */
index 29008ba..b09146c 100644 (file)
@@ -132,10 +132,12 @@ uint8_t ProcessConfigurationDescriptor(void)
  */
 uint8_t DComp_NextInterfaceBluetoothDataEndpoint(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextInterfaceBluetoothDataEndpoint(void* CurrentDescriptor)
 {
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
        /* Determine the type of the current descriptor */
        /* Determine the type of the current descriptor */
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       if (Header->Type == DTYPE_Endpoint)
          return DESCRIPTOR_SEARCH_Found;
          return DESCRIPTOR_SEARCH_Found;
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
          return DESCRIPTOR_SEARCH_Fail;
        else
          return DESCRIPTOR_SEARCH_NotFound;
          return DESCRIPTOR_SEARCH_Fail;
        else
          return DESCRIPTOR_SEARCH_NotFound;
index c2a1f36..7361d73 100644 (file)
@@ -135,11 +135,15 @@ uint8_t ProcessConfigurationDescriptor(void)
  */
 uint8_t DComp_NextHIDInterface(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextHIDInterface(void* CurrentDescriptor)
 {
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
        /* Determine if the current descriptor is an interface descriptor */
        /* Determine if the current descriptor is an interface descriptor */
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       if (Header->Type == DTYPE_Interface)
        {
        {
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
+
                /* Check the HID descriptor class, break out if correct class/protocol interface found */
                /* Check the HID descriptor class, break out if correct class/protocol interface found */
-               if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == HID_CSCP_HIDClass)
+               if (Interface->Class == HID_CSCP_HIDClass)
                {
                        /* Indicate that the descriptor being searched for has been found */
                        return DESCRIPTOR_SEARCH_Found;
                {
                        /* Indicate that the descriptor being searched for has been found */
                        return DESCRIPTOR_SEARCH_Found;
@@ -161,13 +165,15 @@ uint8_t DComp_NextHIDInterface(void* CurrentDescriptor)
  */
 uint8_t DComp_NextHIDInterfaceDataEndpoint(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextHIDInterfaceDataEndpoint(void* CurrentDescriptor)
 {
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
        /* Determine the type of the current descriptor */
        /* Determine the type of the current descriptor */
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       if (Header->Type == DTYPE_Endpoint)
        {
                /* Indicate that the descriptor being searched for has been found */
                return DESCRIPTOR_SEARCH_Found;
        }
        {
                /* Indicate that the descriptor being searched for has been found */
                return DESCRIPTOR_SEARCH_Found;
        }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
        {
                /* Indicate that the search has failed prematurely and should be aborted */
                return DESCRIPTOR_SEARCH_Fail;
        {
                /* Indicate that the search has failed prematurely and should be aborted */
                return DESCRIPTOR_SEARCH_Fail;
index 8e83700..9fc1498 100644 (file)
@@ -131,10 +131,14 @@ uint8_t ProcessConfigurationDescriptor(void)
  */
 uint8_t DComp_NextJoystickInterface(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextJoystickInterface(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
+
                /* Check the HID descriptor class, break out if correct class interface found */
                /* Check the HID descriptor class, break out if correct class interface found */
-               if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == HID_CSCP_HIDClass))
+               if ((Interface->Class == HID_CSCP_HIDClass))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -147,24 +151,21 @@ uint8_t DComp_NextJoystickInterface(void* CurrentDescriptor)
  *  configuration descriptor, to search for a specific sub descriptor. It can also be used to abort the configuration
  *  descriptor processing if an incompatible descriptor configuration is found.
  *
  *  configuration descriptor, to search for a specific sub descriptor. It can also be used to abort the configuration
  *  descriptor processing if an incompatible descriptor configuration is found.
  *
- *  This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor,
- *  aborting the search if another interface descriptor is found before the required endpoint.
+ *  This comparator searches for the next Endpoint descriptor inside the current interface descriptor, aborting the
+ *  search if another interface descriptor is found before the required endpoint.
  *
  *  \return A value from the DSEARCH_Return_ErrorCodes_t enum
  */
 uint8_t DComp_NextJoystickInterfaceDataEndpoint(void* CurrentDescriptor)
 {
  *
  *  \return A value from the DSEARCH_Return_ErrorCodes_t enum
  */
 uint8_t DComp_NextJoystickInterfaceDataEndpoint(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
-       {
-               if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
-                 return DESCRIPTOR_SEARCH_Found;
-       }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
-       {
-               return DESCRIPTOR_SEARCH_Fail;
-       }
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
 
 
-       return DESCRIPTOR_SEARCH_NotFound;
+       if (Header->Type == DTYPE_Endpoint)
+         return DESCRIPTOR_SEARCH_Found;
+       else if (Header->Type == DTYPE_Interface)
+         return DESCRIPTOR_SEARCH_Fail;
+       else
+         return DESCRIPTOR_SEARCH_NotFound;
 }
 
 /** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
 }
 
 /** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
@@ -177,7 +178,9 @@ uint8_t DComp_NextJoystickInterfaceDataEndpoint(void* CurrentDescriptor)
  */
 uint8_t DComp_NextHID(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextHID(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == HID_DTYPE_HID)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == HID_DTYPE_HID)
          return DESCRIPTOR_SEARCH_Found;
        else
          return DESCRIPTOR_SEARCH_NotFound;
          return DESCRIPTOR_SEARCH_Found;
        else
          return DESCRIPTOR_SEARCH_NotFound;
index 7e614b0..01c252c 100644 (file)
@@ -116,11 +116,15 @@ uint8_t ProcessConfigurationDescriptor(void)
  */
 uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
+
                /* Check the HID descriptor class and protocol, break out if correct class/protocol interface found */
                /* Check the HID descriptor class and protocol, break out if correct class/protocol interface found */
-               if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class    == HID_CSCP_HIDClass) &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == HID_CSCP_KeyboardBootProtocol))
+               if ((Interface->Class    == HID_CSCP_HIDClass) &&
+                   (Interface->Protocol == HID_CSCP_KeyboardBootProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -133,23 +137,20 @@ uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor)
  *  configuration descriptor, to search for a specific sub descriptor. It can also be used to abort the configuration
  *  descriptor processing if an incompatible descriptor configuration is found.
  *
  *  configuration descriptor, to search for a specific sub descriptor. It can also be used to abort the configuration
  *  descriptor processing if an incompatible descriptor configuration is found.
  *
- *  This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor,
- *  aborting the search if another interface descriptor is found before the required endpoint.
+ *  This comparator searches for the next Endpoint descriptor inside the current interface descriptor, aborting the
+ *  search if another interface descriptor is found before the required endpoint.
  *
  *  \return A value from the DSEARCH_Return_ErrorCodes_t enum
  */
 uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor)
 {
  *
  *  \return A value from the DSEARCH_Return_ErrorCodes_t enum
  */
 uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
-       {
-               if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
-                 return DESCRIPTOR_SEARCH_Found;
-       }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
-       {
-               return DESCRIPTOR_SEARCH_Fail;
-       }
-
-       return DESCRIPTOR_SEARCH_NotFound;
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Endpoint)
+         return DESCRIPTOR_SEARCH_Found;
+       else if (Header->Type == DTYPE_Interface)
+         return DESCRIPTOR_SEARCH_Fail;
+       else
+         return DESCRIPTOR_SEARCH_NotFound;
 }
 
 }
 
index 1d389ef..998ba20 100644 (file)
@@ -131,10 +131,14 @@ uint8_t ProcessConfigurationDescriptor(void)
  */
 uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
+
                /* Check the HID descriptor class, break out if correct class interface found */
                /* Check the HID descriptor class, break out if correct class interface found */
-               if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class    == HID_CSCP_HIDClass)
+               if (Interface->Class == HID_CSCP_HIDClass)
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -147,24 +151,21 @@ uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor)
  *  configuration descriptor, to search for a specific sub descriptor. It can also be used to abort the configuration
  *  descriptor processing if an incompatible descriptor configuration is found.
  *
  *  configuration descriptor, to search for a specific sub descriptor. It can also be used to abort the configuration
  *  descriptor processing if an incompatible descriptor configuration is found.
  *
- *  This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor,
- *  aborting the search if another interface descriptor is found before the required endpoint.
+ *  This comparator searches for the next Endpoint descriptor inside the current interface descriptor, aborting the
+ *  search if another interface descriptor is found before the required endpoint.
  *
  *  \return A value from the DSEARCH_Return_ErrorCodes_t enum
  */
 uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor)
 {
  *
  *  \return A value from the DSEARCH_Return_ErrorCodes_t enum
  */
 uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
-       {
-               if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
-                 return DESCRIPTOR_SEARCH_Found;
-       }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
-       {
-               return DESCRIPTOR_SEARCH_Fail;
-       }
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
 
 
-       return DESCRIPTOR_SEARCH_NotFound;
+       if (Header->Type == DTYPE_Endpoint)
+         return DESCRIPTOR_SEARCH_Found;
+       else if (Header->Type == DTYPE_Interface)
+         return DESCRIPTOR_SEARCH_Fail;
+       else
+         return DESCRIPTOR_SEARCH_NotFound;
 }
 
 /** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
 }
 
 /** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
@@ -177,9 +178,11 @@ uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor)
  */
 uint8_t DComp_NextHID(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextHID(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == HID_DTYPE_HID)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == HID_DTYPE_HID)
          return DESCRIPTOR_SEARCH_Found;
          return DESCRIPTOR_SEARCH_Found;
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
          return DESCRIPTOR_SEARCH_Fail;
        else
          return DESCRIPTOR_SEARCH_NotFound;
          return DESCRIPTOR_SEARCH_Fail;
        else
          return DESCRIPTOR_SEARCH_NotFound;
index cf1d4e6..544e31a 100644 (file)
@@ -126,12 +126,16 @@ uint8_t ProcessConfigurationDescriptor(void)
  */
 uint8_t DComp_NextMIDIStreamingInterface(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextMIDIStreamingInterface(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
+
                /* Check the MIDI descriptor class, subclass and protocol, break out if correct data interface found */
                /* Check the MIDI descriptor class, subclass and protocol, break out if correct data interface found */
-               if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class    == AUDIO_CSCP_AudioClass)            &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == AUDIO_CSCP_MIDIStreamingSubclass) &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == AUDIO_CSCP_StreamingProtocol))
+               if ((Interface->Class    == AUDIO_CSCP_AudioClass)            &&
+                   (Interface->SubClass == AUDIO_CSCP_MIDIStreamingSubclass) &&
+                   (Interface->Protocol == AUDIO_CSCP_StreamingProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -151,16 +155,17 @@ uint8_t DComp_NextMIDIStreamingInterface(void* CurrentDescriptor)
  */
 uint8_t DComp_NextMIDIStreamingDataEndpoint(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextMIDIStreamingDataEndpoint(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Endpoint)
        {
        {
-               uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor,
-                                                       USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK);
+               USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
 
                /* Check the endpoint type, break out if correct BULK type endpoint found */
 
                /* Check the endpoint type, break out if correct BULK type endpoint found */
-               if (EndpointType == EP_TYPE_BULK)
+               if ((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_BULK)
                  return DESCRIPTOR_SEARCH_Found;
        }
                  return DESCRIPTOR_SEARCH_Found;
        }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
index 2629f20..91c9682 100644 (file)
@@ -126,12 +126,16 @@ uint8_t ProcessConfigurationDescriptor(void)
  */
 uint8_t DComp_NextMSInterface(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextMSInterface(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
+
                /* Check the descriptor class and protocol, break out if correct class/protocol interface found */
                /* Check the descriptor class and protocol, break out if correct class/protocol interface found */
-               if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class    == MASS_STORE_CLASS)    &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == MASS_STORE_SUBCLASS) &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == MASS_STORE_PROTOCOL))
+               if ((Interface->Class    == MASS_STORE_CLASS)    &&
+                   (Interface->SubClass == MASS_STORE_SUBCLASS) &&
+                   (Interface->Protocol == MASS_STORE_PROTOCOL))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -151,16 +155,17 @@ uint8_t DComp_NextMSInterface(void* CurrentDescriptor)
  */
 uint8_t DComp_NextMSInterfaceBulkDataEndpoint(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextMSInterfaceBulkDataEndpoint(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Endpoint)
        {
        {
-               uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor,
-                                                       USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK);
+               USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
 
                /* Check the endpoint type, break out if correct BULK type endpoint found */
 
                /* Check the endpoint type, break out if correct BULK type endpoint found */
-               if (EndpointType == EP_TYPE_BULK)
+               if ((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_BULK)
                  return DESCRIPTOR_SEARCH_Found;
        }
                  return DESCRIPTOR_SEARCH_Found;
        }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
index f74ecf2..5a8ffa7 100644 (file)
@@ -116,12 +116,16 @@ uint8_t ProcessConfigurationDescriptor(void)
  */
 uint8_t DComp_NextMouseInterface(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextMouseInterface(void* CurrentDescriptor)
 {
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
        /* Determine if the current descriptor is an interface descriptor */
        /* Determine if the current descriptor is an interface descriptor */
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       if (Header->Type == DTYPE_Interface)
        {
        {
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
+
                /* Check the HID descriptor class and protocol, break out if correct class/protocol interface found */
                /* Check the HID descriptor class and protocol, break out if correct class/protocol interface found */
-               if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class    == HID_CSCP_HIDClass) &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == HID_CSCP_MouseBootProtocol))
+               if ((Interface->Class    == HID_CSCP_HIDClass) &&
+                   (Interface->Protocol == HID_CSCP_MouseBootProtocol))
                {
                        /* Indicate that the descriptor being searched for has been found */
                        return DESCRIPTOR_SEARCH_Found;
                {
                        /* Indicate that the descriptor being searched for has been found */
                        return DESCRIPTOR_SEARCH_Found;
@@ -136,30 +140,21 @@ uint8_t DComp_NextMouseInterface(void* CurrentDescriptor)
  *  configuration descriptor, to search for a specific sub descriptor. It can also be used to abort the configuration
  *  descriptor processing if an incompatible descriptor configuration is found.
  *
  *  configuration descriptor, to search for a specific sub descriptor. It can also be used to abort the configuration
  *  descriptor processing if an incompatible descriptor configuration is found.
  *
- *  This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor,
- *  aborting the search if another interface descriptor is found before the required endpoint.
+ *  This comparator searches for the next Endpoint descriptor inside the current interface descriptor, aborting the
+ *  search if another interface descriptor is found before the required endpoint.
  *
  *  \return A value from the DSEARCH_Return_ErrorCodes_t enum
  */
 uint8_t DComp_NextMouseInterfaceDataEndpoint(void* CurrentDescriptor)
 {
  *
  *  \return A value from the DSEARCH_Return_ErrorCodes_t enum
  */
 uint8_t DComp_NextMouseInterfaceDataEndpoint(void* CurrentDescriptor)
 {
-       /* Determine the type of the current descriptor */
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
-       {
-               /* Check if the current Endpoint descriptor is of type IN */
-               if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
-               {
-                       /* Indicate that the descriptor being searched for has been found */
-                       return DESCRIPTOR_SEARCH_Found;
-               }
-       }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
-       {
-               /* Indicate that the search has failed prematurely and should be aborted */
-               return DESCRIPTOR_SEARCH_Fail;
-       }
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
 
 
-       /* Current descriptor does not match what this comparator is looking for */
-       return DESCRIPTOR_SEARCH_NotFound;
+       /* Determine the type of the current descriptor */
+       if (Header->Type == DTYPE_Endpoint)
+         return DESCRIPTOR_SEARCH_Found;
+       else if (Header->Type == DTYPE_Interface)
+         return DESCRIPTOR_SEARCH_Fail;
+       else
+         return DESCRIPTOR_SEARCH_NotFound;
 }
 
 }
 
index 5684248..7702511 100644 (file)
@@ -131,10 +131,14 @@ uint8_t ProcessConfigurationDescriptor(void)
  */
 uint8_t DComp_NextMouseInterface(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextMouseInterface(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
+
                /* Check the HID descriptor class, break out if correct class interface found */
                /* Check the HID descriptor class, break out if correct class interface found */
-               if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == HID_CSCP_HIDClass)
+               if (Interface->Class == HID_CSCP_HIDClass)
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -147,24 +151,21 @@ uint8_t DComp_NextMouseInterface(void* CurrentDescriptor)
  *  configuration descriptor, to search for a specific sub descriptor. It can also be used to abort the configuration
  *  descriptor processing if an incompatible descriptor configuration is found.
  *
  *  configuration descriptor, to search for a specific sub descriptor. It can also be used to abort the configuration
  *  descriptor processing if an incompatible descriptor configuration is found.
  *
- *  This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor,
- *  aborting the search if another interface descriptor is found before the required endpoint.
+ *  This comparator searches for the next Endpoint descriptor inside the current interface descriptor, aborting the
+ *  search if another interface descriptor is found before the required endpoint.
  *
  *  \return A value from the DSEARCH_Return_ErrorCodes_t enum
  */
 uint8_t DComp_NextMouseInterfaceDataEndpoint(void* CurrentDescriptor)
 {
  *
  *  \return A value from the DSEARCH_Return_ErrorCodes_t enum
  */
 uint8_t DComp_NextMouseInterfaceDataEndpoint(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
-       {
-               if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
-                 return DESCRIPTOR_SEARCH_Found;
-       }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
-       {
-               return DESCRIPTOR_SEARCH_Fail;
-       }
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
 
 
-       return DESCRIPTOR_SEARCH_NotFound;
+       if (Header->Type == DTYPE_Endpoint)
+         return DESCRIPTOR_SEARCH_Found;
+       else if (Header->Type == DTYPE_Interface)
+         return DESCRIPTOR_SEARCH_Fail;
+       else
+         return DESCRIPTOR_SEARCH_NotFound;
 }
 
 /** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
 }
 
 /** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
@@ -177,7 +178,9 @@ uint8_t DComp_NextMouseInterfaceDataEndpoint(void* CurrentDescriptor)
  */
 uint8_t DComp_NextHID(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextHID(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == HID_DTYPE_HID)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == HID_DTYPE_HID)
          return DESCRIPTOR_SEARCH_Found;
        else
          return DESCRIPTOR_SEARCH_NotFound;
          return DESCRIPTOR_SEARCH_Found;
        else
          return DESCRIPTOR_SEARCH_NotFound;
index 2b1f690..162afab 100644 (file)
@@ -130,12 +130,16 @@ uint8_t ProcessConfigurationDescriptor(void)
  */
 uint8_t DComp_NextBidirectionalPrinterInterface(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextBidirectionalPrinterInterface(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
+
                /* Check the descriptor class, subclass and protocol, break out if correct value interface found */
                /* Check the descriptor class, subclass and protocol, break out if correct value interface found */
-               if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class    == PRNT_CSCP_PrinterClass)    &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == PRNT_CSCP_PrinterSubclass) &&
-                       (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == PRNT_CSCP_BidirectionalProtocol))
+               if ((Interface->Class    == PRNT_CSCP_PrinterClass)    &&
+                   (Interface->SubClass == PRNT_CSCP_PrinterSubclass) &&
+                       (Interface->Protocol == PRNT_CSCP_BidirectionalProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -155,16 +159,17 @@ uint8_t DComp_NextBidirectionalPrinterInterface(void* CurrentDescriptor)
  */
 uint8_t DComp_NextPrinterInterfaceBulkDataEndpoint(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextPrinterInterfaceBulkDataEndpoint(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Endpoint)
        {
        {
-               uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor,
-                                                       USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK);
+               USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
 
                /* Check the endpoint type, break out if correct BULK type endpoint found */
 
                /* Check the endpoint type, break out if correct BULK type endpoint found */
-               if (EndpointType == EP_TYPE_BULK)
+               if ((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_BULK)
                  return DESCRIPTOR_SEARCH_Found;
        }
                  return DESCRIPTOR_SEARCH_Found;
        }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
index 8bd12bc..eef8673 100644 (file)
@@ -157,12 +157,16 @@ uint8_t ProcessConfigurationDescriptor(void)
  */
 uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
+
                /* Check the CDC descriptor class, subclass and protocol, break out if correct control interface found */
                /* Check the CDC descriptor class, subclass and protocol, break out if correct control interface found */
-               if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class    == CDC_CSCP_CDCClass)    &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == CDC_CSCP_ACMSubclass) &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == CDC_CSCP_VendorSpecificProtocol))
+               if ((Interface->Class    == CDC_CSCP_CDCClass)    &&
+                   (Interface->SubClass == CDC_CSCP_ACMSubclass) &&
+                   (Interface->Protocol == CDC_CSCP_VendorSpecificProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -181,12 +185,16 @@ uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor)
  */
 uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
+
                /* Check the CDC descriptor class, subclass and protocol, break out if correct data interface found */
                /* Check the CDC descriptor class, subclass and protocol, break out if correct data interface found */
-               if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class    == CDC_CSCP_CDCDataClass)   &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == CDC_CSCP_NoDataSubclass) &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == CDC_CSCP_NoDataProtocol))
+               if ((Interface->Class    == CDC_CSCP_CDCDataClass)   &&
+                   (Interface->SubClass == CDC_CSCP_NoDataSubclass) &&
+                   (Interface->Protocol == CDC_CSCP_NoDataProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -207,15 +215,20 @@ uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor)
  */
 uint8_t DComp_NextCDCDataInterfaceEndpoint(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextCDCDataInterfaceEndpoint(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Endpoint)
        {
        {
-               uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor,
-                                                       USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK);
+               USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
 
 
-               if ((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT))
-                 return DESCRIPTOR_SEARCH_Found;
+               /* Check the endpoint type, break out if correct BULK or INTERRUPT type endpoint found */
+               if (((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_BULK) || 
+                   ((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT))
+               {
+                       return DESCRIPTOR_SEARCH_Found;
+               }
        }
        }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
index 6a34586..e11fc17 100644 (file)
@@ -141,12 +141,16 @@ uint8_t ProcessConfigurationDescriptor(void)
  */
 uint8_t DComp_NextStillImageInterface(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextStillImageInterface(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
+
                /* Check the descriptor class, subclass and protocol, break out if correct interface found */
                /* Check the descriptor class, subclass and protocol, break out if correct interface found */
-               if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class    == SI_CSCP_StillImageClass)    &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == SI_CSCP_StillImageSubclass) &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == SI_CSCP_BulkOnlyProtocol))
+               if ((Interface->Class    == SI_CSCP_StillImageClass)    &&
+                   (Interface->SubClass == SI_CSCP_StillImageSubclass) &&
+                   (Interface->Protocol == SI_CSCP_BulkOnlyProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -166,15 +170,20 @@ uint8_t DComp_NextStillImageInterface(void* CurrentDescriptor)
  */
 uint8_t DComp_NextStillImageInterfaceDataEndpoint(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextStillImageInterfaceDataEndpoint(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Endpoint)
        {
        {
-               uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor,
-                                                       USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK);
+               USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
 
 
-               if ((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT))
-                 return DESCRIPTOR_SEARCH_Found;
+               /* Check the endpoint type, break out if correct BULK or INTERRUPT type endpoint found */
+               if (((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_BULK) || 
+                   ((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT))
+               {
+                       return DESCRIPTOR_SEARCH_Found;
+               }
        }
        }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
index d702771..7a8f972 100644 (file)
@@ -157,12 +157,16 @@ uint8_t ProcessConfigurationDescriptor(void)
  */
 uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
+
                /* Check the CDC descriptor class, subclass and protocol, break out if correct control interface found */
                /* Check the CDC descriptor class, subclass and protocol, break out if correct control interface found */
-               if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class    == CDC_CSCP_CDCClass)    &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == CDC_CSCP_ACMSubclass) &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == CDC_CSCP_ATCommandProtocol))
+               if ((Interface->Class    == CDC_CSCP_CDCClass)    &&
+                   (Interface->SubClass == CDC_CSCP_ACMSubclass) &&
+                   (Interface->Protocol == CDC_CSCP_ATCommandProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -181,12 +185,16 @@ uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor)
  */
 uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
+
                /* Check the CDC descriptor class, subclass and protocol, break out if correct data interface found */
                /* Check the CDC descriptor class, subclass and protocol, break out if correct data interface found */
-               if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class    == CDC_CSCP_CDCDataClass)   &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == CDC_CSCP_NoDataSubclass) &&
-                   (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == CDC_CSCP_NoDataProtocol))
+               if ((Interface->Class    == CDC_CSCP_CDCDataClass)   &&
+                   (Interface->SubClass == CDC_CSCP_NoDataSubclass) &&
+                   (Interface->Protocol == CDC_CSCP_NoDataProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -207,15 +215,19 @@ uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor)
  */
 uint8_t DComp_NextCDCDataInterfaceEndpoint(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextCDCDataInterfaceEndpoint(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Endpoint)
        {
        {
-               uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor,
-                                                       USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK);
+               USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
 
 
-               if ((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT))
-                 return DESCRIPTOR_SEARCH_Found;
+               if (((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_BULK) || 
+                   ((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT))
+               {
+                       return DESCRIPTOR_SEARCH_Found;
+               }
        }
        }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
index 9304161..e48d487 100644 (file)
@@ -137,14 +137,15 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
 
 static uint8_t DCOMP_CDC_Host_NextCDCControlInterface(void* const CurrentDescriptor)
 {
 
 static uint8_t DCOMP_CDC_Host_NextCDCControlInterface(void* const CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
-               USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
-                                                                               USB_Descriptor_Interface_t);
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
 
 
-               if ((CurrentInterface->Class    == CDC_CSCP_CDCClass)    &&
-                   (CurrentInterface->SubClass == CDC_CSCP_ACMSubclass) &&
-                   (CurrentInterface->Protocol == CDC_CSCP_ATCommandProtocol))
+               if ((Interface->Class    == CDC_CSCP_CDCClass)    &&
+                   (Interface->SubClass == CDC_CSCP_ACMSubclass) &&
+                   (Interface->Protocol == CDC_CSCP_ATCommandProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -155,14 +156,15 @@ static uint8_t DCOMP_CDC_Host_NextCDCControlInterface(void* const CurrentDescrip
 
 static uint8_t DCOMP_CDC_Host_NextCDCDataInterface(void* const CurrentDescriptor)
 {
 
 static uint8_t DCOMP_CDC_Host_NextCDCDataInterface(void* const CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
-               USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
-                                                                               USB_Descriptor_Interface_t);
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
 
 
-               if ((CurrentInterface->Class    == CDC_CSCP_CDCDataClass)   &&
-                   (CurrentInterface->SubClass == CDC_CSCP_NoDataSubclass) &&
-                   (CurrentInterface->Protocol == CDC_CSCP_NoDataProtocol))
+               if ((Interface->Class    == CDC_CSCP_CDCDataClass)   &&
+                   (Interface->SubClass == CDC_CSCP_NoDataSubclass) &&
+                   (Interface->Protocol == CDC_CSCP_NoDataProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -173,20 +175,21 @@ static uint8_t DCOMP_CDC_Host_NextCDCDataInterface(void* const CurrentDescriptor
 
 static uint8_t DCOMP_CDC_Host_NextCDCInterfaceEndpoint(void* const CurrentDescriptor)
 {
 
 static uint8_t DCOMP_CDC_Host_NextCDCInterfaceEndpoint(void* const CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Endpoint)
        {
        {
-               USB_Descriptor_Endpoint_t* CurrentEndpoint = DESCRIPTOR_PCAST(CurrentDescriptor,
-                                                                             USB_Descriptor_Endpoint_t);
+               USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
 
 
-               uint8_t EndpointType = (CurrentEndpoint->Attributes & EP_TYPE_MASK);
+               uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK);
 
                if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) &&
 
                if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) &&
-                   !(Pipe_IsEndpointBound(CurrentEndpoint->EndpointAddress)))
+                   !(Pipe_IsEndpointBound(Endpoint->EndpointAddress)))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
        }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
        }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
index 4ba7558..bb10ee2 100644 (file)
@@ -116,8 +116,8 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
                }
        }
 
                }
        }
 
-       HIDInterfaceInfo->State.InterfaceNumber = HIDInterface->InterfaceNumber;
-       HIDInterfaceInfo->State.HIDReportSize   = HIDDescriptor->HIDReportLength;
+       HIDInterfaceInfo->State.InterfaceNumber      = HIDInterface->InterfaceNumber;
+       HIDInterfaceInfo->State.HIDReportSize        = HIDDescriptor->HIDReportLength;
        HIDInterfaceInfo->State.SupportsBootProtocol = (HIDInterface->SubClass != HID_CSCP_NonBootProtocol);
        HIDInterfaceInfo->State.LargestReportSize    = 8;
        HIDInterfaceInfo->State.IsActive = true;
        HIDInterfaceInfo->State.SupportsBootProtocol = (HIDInterface->SubClass != HID_CSCP_NonBootProtocol);
        HIDInterfaceInfo->State.LargestReportSize    = 8;
        HIDInterfaceInfo->State.IsActive = true;
@@ -127,12 +127,13 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
 
 static uint8_t DCOMP_HID_Host_NextHIDInterface(void* const CurrentDescriptor)
 {
 
 static uint8_t DCOMP_HID_Host_NextHIDInterface(void* const CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
-               USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
-                                                                               USB_Descriptor_Interface_t);
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
 
 
-               if (CurrentInterface->Class == HID_CSCP_HIDClass)
+               if (Interface->Class == HID_CSCP_HIDClass)
                  return DESCRIPTOR_SEARCH_Found;
        }
 
                  return DESCRIPTOR_SEARCH_Found;
        }
 
@@ -141,9 +142,11 @@ static uint8_t DCOMP_HID_Host_NextHIDInterface(void* const CurrentDescriptor)
 
 static uint8_t DCOMP_HID_Host_NextHID(void* const CurrentDescriptor)
 {
 
 static uint8_t DCOMP_HID_Host_NextHID(void* const CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == HID_DTYPE_HID)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == HID_DTYPE_HID)
          return DESCRIPTOR_SEARCH_Found;
          return DESCRIPTOR_SEARCH_Found;
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
          return DESCRIPTOR_SEARCH_Fail;
        else
          return DESCRIPTOR_SEARCH_NotFound;
          return DESCRIPTOR_SEARCH_Fail;
        else
          return DESCRIPTOR_SEARCH_NotFound;
@@ -151,15 +154,16 @@ static uint8_t DCOMP_HID_Host_NextHID(void* const CurrentDescriptor)
 
 static uint8_t DCOMP_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescriptor)
 {
 
 static uint8_t DCOMP_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Endpoint)
        {
        {
-               USB_Descriptor_Endpoint_t* CurrentEndpoint = DESCRIPTOR_PCAST(CurrentDescriptor,
-                                                                             USB_Descriptor_Endpoint_t);
+               USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
 
 
-               if (!(Pipe_IsEndpointBound(CurrentEndpoint->EndpointAddress)))
+               if (!(Pipe_IsEndpointBound(Endpoint->EndpointAddress)))
                  return DESCRIPTOR_SEARCH_Found;
        }
                  return DESCRIPTOR_SEARCH_Found;
        }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
index 6aed766..ad6c5cf 100644 (file)
@@ -105,14 +105,15 @@ uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceI
 
 static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingInterface(void* const CurrentDescriptor)
 {
 
 static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingInterface(void* const CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
-               USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
-                                                                               USB_Descriptor_Interface_t);
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
 
 
-               if ((CurrentInterface->Class    == AUDIO_CSCP_AudioClass)            &&
-                   (CurrentInterface->SubClass == AUDIO_CSCP_MIDIStreamingSubclass) &&
-                   (CurrentInterface->Protocol == AUDIO_CSCP_StreamingProtocol))
+               if ((Interface->Class    == AUDIO_CSCP_AudioClass)            &&
+                   (Interface->SubClass == AUDIO_CSCP_MIDIStreamingSubclass) &&
+                   (Interface->Protocol == AUDIO_CSCP_StreamingProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -123,17 +124,18 @@ static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingInterface(void* const CurrentDes
 
 static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingDataEndpoint(void* const CurrentDescriptor)
 {
 
 static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingDataEndpoint(void* const CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Endpoint)
        {
        {
-               USB_Descriptor_Endpoint_t* CurrentEndpoint = DESCRIPTOR_PCAST(CurrentDescriptor,
-                                                                             USB_Descriptor_Endpoint_t);
+               USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
 
 
-               uint8_t EndpointType = (CurrentEndpoint->Attributes & EP_TYPE_MASK);
+               uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK);
 
 
-               if ((EndpointType == EP_TYPE_BULK) && !(Pipe_IsEndpointBound(CurrentEndpoint->EndpointAddress)))
+               if ((EndpointType == EP_TYPE_BULK) && !(Pipe_IsEndpointBound(Endpoint->EndpointAddress)))
                  return DESCRIPTOR_SEARCH_Found;
        }
                  return DESCRIPTOR_SEARCH_Found;
        }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
index d07a7b7..ef8053b 100644 (file)
@@ -105,14 +105,15 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
 
 static uint8_t DCOMP_MS_Host_NextMSInterface(void* const CurrentDescriptor)
 {
 
 static uint8_t DCOMP_MS_Host_NextMSInterface(void* const CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
-               USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
-                                                                               USB_Descriptor_Interface_t);
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
 
 
-               if ((CurrentInterface->Class    == MS_CSCP_MassStorageClass)        &&
-                   (CurrentInterface->SubClass == MS_CSCP_SCSITransparentSubclass) &&
-                   (CurrentInterface->Protocol == MS_CSCP_BulkOnlyTransportProtocol))
+               if ((Interface->Class    == MS_CSCP_MassStorageClass)        &&
+                   (Interface->SubClass == MS_CSCP_SCSITransparentSubclass) &&
+                   (Interface->Protocol == MS_CSCP_BulkOnlyTransportProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -123,20 +124,20 @@ static uint8_t DCOMP_MS_Host_NextMSInterface(void* const CurrentDescriptor)
 
 static uint8_t DCOMP_MS_Host_NextMSInterfaceEndpoint(void* const CurrentDescriptor)
 {
 
 static uint8_t DCOMP_MS_Host_NextMSInterfaceEndpoint(void* const CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Endpoint)
        {
        {
-               USB_Descriptor_Endpoint_t* CurrentEndpoint = DESCRIPTOR_PCAST(CurrentDescriptor,
-                                                                             USB_Descriptor_Endpoint_t);
+               USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
 
 
-               uint8_t EndpointType = (CurrentEndpoint->Attributes & EP_TYPE_MASK);
+               uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK);
 
 
-               if ((EndpointType == EP_TYPE_BULK) &&
-                   (!(Pipe_IsEndpointBound(CurrentEndpoint->EndpointAddress))))
+               if ((EndpointType == EP_TYPE_BULK) && (!(Pipe_IsEndpointBound(Endpoint->EndpointAddress))))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
        }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
        }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
index 42fa7ec..f08ee5b 100644 (file)
@@ -38,7 +38,7 @@
 
 uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,
                                  uint16_t ConfigDescriptorSize,
 
 uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,
                                  uint16_t ConfigDescriptorSize,
-                                                            void* DeviceConfigDescriptor)
+                                                            void* ConfigDescriptorData)
 {
        USB_Descriptor_Endpoint_t*  DataINEndpoint   = NULL;
        USB_Descriptor_Endpoint_t*  DataOUTEndpoint  = NULL;
 {
        USB_Descriptor_Endpoint_t*  DataINEndpoint   = NULL;
        USB_Descriptor_Endpoint_t*  DataOUTEndpoint  = NULL;
@@ -46,22 +46,22 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
 
        memset(&PRNTInterfaceInfo->State, 0x00, sizeof(PRNTInterfaceInfo->State));
 
 
        memset(&PRNTInterfaceInfo->State, 0x00, sizeof(PRNTInterfaceInfo->State));
 
-       if (DESCRIPTOR_TYPE(DeviceConfigDescriptor) != DTYPE_Configuration)
+       if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)
          return PRNT_ENUMERROR_InvalidConfigDescriptor;
 
        while (!(DataINEndpoint) || !(DataOUTEndpoint))
        {
                if (!(PrinterInterface) ||
          return PRNT_ENUMERROR_InvalidConfigDescriptor;
 
        while (!(DataINEndpoint) || !(DataOUTEndpoint))
        {
                if (!(PrinterInterface) ||
-                   USB_GetNextDescriptorComp(&ConfigDescriptorSize, &DeviceConfigDescriptor,
+                   USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
                                              DCOMP_PRNT_Host_NextPRNTInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
                {
                                              DCOMP_PRNT_Host_NextPRNTInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
                {
-                       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &DeviceConfigDescriptor,
+                       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
                                                      DCOMP_PRNT_Host_NextPRNTInterface) != DESCRIPTOR_SEARCH_COMP_Found)
                        {
                                return PRNT_ENUMERROR_NoCompatibleInterfaceFound;
                        }
 
                                                      DCOMP_PRNT_Host_NextPRNTInterface) != DESCRIPTOR_SEARCH_COMP_Found)
                        {
                                return PRNT_ENUMERROR_NoCompatibleInterfaceFound;
                        }
 
-                       PrinterInterface = DESCRIPTOR_PCAST(DeviceConfigDescriptor, USB_Descriptor_Interface_t);
+                       PrinterInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);
 
                        DataINEndpoint  = NULL;
                        DataOUTEndpoint = NULL;
 
                        DataINEndpoint  = NULL;
                        DataOUTEndpoint = NULL;
@@ -69,7 +69,7 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
                        continue;
                }
 
                        continue;
                }
 
-               USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(DeviceConfigDescriptor, USB_Descriptor_Endpoint_t);
+               USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);
 
                if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
                  DataINEndpoint  = EndpointData;
 
                if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
                  DataINEndpoint  = EndpointData;
@@ -106,14 +106,15 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
 
 static uint8_t DCOMP_PRNT_Host_NextPRNTInterface(void* CurrentDescriptor)
 {
 
 static uint8_t DCOMP_PRNT_Host_NextPRNTInterface(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
-               USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
-                                                                               USB_Descriptor_Interface_t);
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
 
 
-               if ((CurrentInterface->Class    == PRNT_CSCP_PrinterClass)    &&
-                   (CurrentInterface->SubClass == PRNT_CSCP_PrinterSubclass) &&
-                   (CurrentInterface->Protocol == PRNT_CSCP_BidirectionalProtocol))
+               if ((Interface->Class    == PRNT_CSCP_PrinterClass)    &&
+                   (Interface->SubClass == PRNT_CSCP_PrinterSubclass) &&
+                   (Interface->Protocol == PRNT_CSCP_BidirectionalProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -124,15 +125,18 @@ static uint8_t DCOMP_PRNT_Host_NextPRNTInterface(void* CurrentDescriptor)
 
 static uint8_t DCOMP_PRNT_Host_NextPRNTInterfaceEndpoint(void* CurrentDescriptor)
 {
 
 static uint8_t DCOMP_PRNT_Host_NextPRNTInterfaceEndpoint(void* CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Endpoint)
        {
        {
-               uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor,
-                                                       USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK);
+               USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
+
+               uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK);
 
                if (EndpointType == EP_TYPE_BULK)
                  return DESCRIPTOR_SEARCH_Found;
        }
 
                if (EndpointType == EP_TYPE_BULK)
                  return DESCRIPTOR_SEARCH_Found;
        }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
index d312f82..e3948ec 100644 (file)
@@ -137,14 +137,15 @@ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfa
 
 static uint8_t DCOMP_RNDIS_Host_NextRNDISControlInterface(void* const CurrentDescriptor)
 {
 
 static uint8_t DCOMP_RNDIS_Host_NextRNDISControlInterface(void* const CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
-               USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
-                                                                               USB_Descriptor_Interface_t);
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
 
 
-               if ((CurrentInterface->Class    == CDC_CSCP_CDCClass)    &&
-                   (CurrentInterface->SubClass == CDC_CSCP_ACMSubclass) &&
-                   (CurrentInterface->Protocol == CDC_CSCP_VendorSpecificProtocol))
+               if ((Interface->Class    == CDC_CSCP_CDCClass)    &&
+                   (Interface->SubClass == CDC_CSCP_ACMSubclass) &&
+                   (Interface->Protocol == CDC_CSCP_VendorSpecificProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -155,14 +156,16 @@ static uint8_t DCOMP_RNDIS_Host_NextRNDISControlInterface(void* const CurrentDes
 
 static uint8_t DCOMP_RNDIS_Host_NextRNDISDataInterface(void* const CurrentDescriptor)
 {
 
 static uint8_t DCOMP_RNDIS_Host_NextRNDISDataInterface(void* const CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
-               USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
-                                                                               USB_Descriptor_Interface_t);
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor,
+                                                                        USB_Descriptor_Interface_t);
 
 
-               if ((CurrentInterface->Class    == CDC_CSCP_CDCDataClass)   &&
-                   (CurrentInterface->SubClass == CDC_CSCP_NoDataSubclass) &&
-                   (CurrentInterface->Protocol == CDC_CSCP_NoDataProtocol))
+               if ((Interface->Class    == CDC_CSCP_CDCDataClass)   &&
+                   (Interface->SubClass == CDC_CSCP_NoDataSubclass) &&
+                   (Interface->Protocol == CDC_CSCP_NoDataProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -173,20 +176,21 @@ static uint8_t DCOMP_RNDIS_Host_NextRNDISDataInterface(void* const CurrentDescri
 
 static uint8_t DCOMP_RNDIS_Host_NextRNDISInterfaceEndpoint(void* const CurrentDescriptor)
 {
 
 static uint8_t DCOMP_RNDIS_Host_NextRNDISInterfaceEndpoint(void* const CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Endpoint)
        {
        {
-               USB_Descriptor_Endpoint_t* CurrentEndpoint = DESCRIPTOR_PCAST(CurrentDescriptor,
-                                                                             USB_Descriptor_Endpoint_t);
+               USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
 
 
-               uint8_t EndpointType = (CurrentEndpoint->Attributes & EP_TYPE_MASK);
+               uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK);
 
                if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) &&
 
                if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) &&
-                   !(Pipe_IsEndpointBound(CurrentEndpoint->EndpointAddress)))
+                   !(Pipe_IsEndpointBound(Endpoint->EndpointAddress)))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
        }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
        }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
index 63f61d5..d3dda8f 100644 (file)
@@ -123,14 +123,15 @@ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
 
 uint8_t DCOMP_SI_Host_NextSIInterface(void* const CurrentDescriptor)
 {
 
 uint8_t DCOMP_SI_Host_NextSIInterface(void* const CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Interface)
        {
        {
-               USB_Descriptor_Interface_t* CurrentInterface = DESCRIPTOR_PCAST(CurrentDescriptor,
-                                                                               USB_Descriptor_Interface_t);
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
 
 
-               if ((CurrentInterface->Class    == SI_CSCP_StillImageClass)    &&
-                   (CurrentInterface->SubClass == SI_CSCP_StillImageSubclass) &&
-                   (CurrentInterface->Protocol == SI_CSCP_BulkOnlyProtocol))
+               if ((Interface->Class    == SI_CSCP_StillImageClass)    &&
+                   (Interface->SubClass == SI_CSCP_StillImageSubclass) &&
+                   (Interface->Protocol == SI_CSCP_BulkOnlyProtocol))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
@@ -141,20 +142,21 @@ uint8_t DCOMP_SI_Host_NextSIInterface(void* const CurrentDescriptor)
 
 uint8_t DCOMP_SI_Host_NextSIInterfaceEndpoint(void* const CurrentDescriptor)
 {
 
 uint8_t DCOMP_SI_Host_NextSIInterfaceEndpoint(void* const CurrentDescriptor)
 {
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
+       if (Header->Type == DTYPE_Endpoint)
        {
        {
-               USB_Descriptor_Endpoint_t* CurrentEndpoint = DESCRIPTOR_PCAST(CurrentDescriptor,
-                                                                             USB_Descriptor_Endpoint_t);
+               USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
 
 
-               uint8_t EndpointType = (CurrentEndpoint->Attributes & EP_TYPE_MASK);
+               uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK);
 
                if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) &&
 
                if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) &&
-                   (!(Pipe_IsEndpointBound(CurrentEndpoint->EndpointAddress))))
+                   (!(Pipe_IsEndpointBound(Endpoint->EndpointAddress))))
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
        }
                {
                        return DESCRIPTOR_SEARCH_Found;
                }
        }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
        {
                return DESCRIPTOR_SEARCH_Fail;
        }
index ee1e2b6..a406498 100644 (file)
                         *  This value's meaning depends on the descriptor's placement in the descriptor, but standard type
                         *  values can be accessed in the \ref USB_DescriptorTypes_t enum.
                         */
                         *  This value's meaning depends on the descriptor's placement in the descriptor, but standard type
                         *  values can be accessed in the \ref USB_DescriptorTypes_t enum.
                         */
-                       #define DESCRIPTOR_TYPE(DescriptorPtr)    DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).Type
+                       #define DESCRIPTOR_TYPE(DescriptorPtr)    DESCRIPTOR_PCAST(DescriptorPtr, USB_Descriptor_Header_t)->Type
 
                        /** Returns the descriptor's size, expressed as the 8-bit value indicating the number of bytes. */
 
                        /** Returns the descriptor's size, expressed as the 8-bit value indicating the number of bytes. */
-                       #define DESCRIPTOR_SIZE(DescriptorPtr)    DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).Size
+                       #define DESCRIPTOR_SIZE(DescriptorPtr)    DESCRIPTOR_PCAST(DescriptorPtr, USB_Descriptor_Header_t)->Size
 
                /* Type Defines: */
                        /** Type define for a Configuration Descriptor comparator function (function taking a pointer to an array
 
                /* Type Defines: */
                        /** Type define for a Configuration Descriptor comparator function (function taking a pointer to an array
index 208d7b7..e2c6586 100644 (file)
@@ -66,7 +66,10 @@ void V2Protocol_Init(void)
        TIMSK0 = (1 << OCIE0A);
 
        V2Params_LoadNonVolatileParamValues();
        TIMSK0 = (1 << OCIE0A);
 
        V2Params_LoadNonVolatileParamValues();
+       
+       #if defined(ENABLE_ISP_PROTOCOL)
        ISPTarget_ConfigureRescueClock();
        ISPTarget_ConfigureRescueClock();
+       #endif
 }
 
 /** Master V2 Protocol packet handler, for received V2 Protocol packets from a connected host.
 }
 
 /** Master V2 Protocol packet handler, for received V2 Protocol packets from a connected host.
index 378fa9a..b26fa75 100644 (file)
@@ -135,11 +135,15 @@ uint8_t ProcessConfigurationDescriptor(void)
  */
 uint8_t DComp_NextHIDInterface(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextHIDInterface(void* CurrentDescriptor)
 {
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
        /* Determine if the current descriptor is an interface descriptor */
        /* Determine if the current descriptor is an interface descriptor */
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       if (Header->Type == DTYPE_Interface)
        {
        {
+               USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
+
                /* Check the HID descriptor class and protocol, break out if correct class/protocol interface found */
                /* Check the HID descriptor class and protocol, break out if correct class/protocol interface found */
-               if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == HID_CLASS)
+               if (Interface->Class == HID_CLASS)
                {
                        /* Indicate that the descriptor being searched for has been found */
                        return DESCRIPTOR_SEARCH_Found;
                {
                        /* Indicate that the descriptor being searched for has been found */
                        return DESCRIPTOR_SEARCH_Found;
@@ -161,19 +165,23 @@ uint8_t DComp_NextHIDInterface(void* CurrentDescriptor)
  */
 uint8_t DComp_NextHIDInterfaceDataEndpoint(void* CurrentDescriptor)
 {
  */
 uint8_t DComp_NextHIDInterfaceDataEndpoint(void* CurrentDescriptor)
 {
+       USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
+
        /* Determine the type of the current descriptor */
        /* Determine the type of the current descriptor */
-       if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+       if (Header->Type == DTYPE_Endpoint)
        {
                /* Indicate that the descriptor being searched for has been found */
                return DESCRIPTOR_SEARCH_Found;
        }
        {
                /* Indicate that the descriptor being searched for has been found */
                return DESCRIPTOR_SEARCH_Found;
        }
-       else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
+       else if (Header->Type == DTYPE_Interface)
        {
                /* Indicate that the search has failed prematurely and should be aborted */
                return DESCRIPTOR_SEARCH_Fail;
        }
        {
                /* Indicate that the search has failed prematurely and should be aborted */
                return DESCRIPTOR_SEARCH_Fail;
        }
-
-       /* Current descriptor does not match what this comparator is looking for */
-       return DESCRIPTOR_SEARCH_NotFound;
+       else
+       {
+               /* Current descriptor does not match what this comparator is looking for */
+               return DESCRIPTOR_SEARCH_NotFound;
+       }
 }
 
 }
 
index 5de3659..4b38a0b 100644 (file)
@@ -67,7 +67,7 @@ void SoftUART_Init(void)
        SoftUART_SetBaud(9600);
 
        /* Setup reception timer compare ISR */
        SoftUART_SetBaud(9600);
 
        /* Setup reception timer compare ISR */
-       TIMSK2 = (1 << ICIE2);
+       TIMSK1 = (1 << ICIE1);
 
        /* Setup transmission timer compare ISR and start the timer */
        TIMSK3 = (1 << ICIE3);
 
        /* Setup transmission timer compare ISR and start the timer */
        TIMSK3 = (1 << ICIE3);
@@ -81,7 +81,7 @@ ISR(INT0_vect, ISR_BLOCK)
        RX_BitsRemaining = 8;
 
        /* Reset the bit reception timer */
        RX_BitsRemaining = 8;
 
        /* Reset the bit reception timer */
-       TCNT2 = 0;
+       TCNT1 = 0;
 
        /* Check to see that the pin is still low (prevents glitches from starting a frame reception) */
        if (!(SRXPIN & (1 << SRX)))
 
        /* Check to see that the pin is still low (prevents glitches from starting a frame reception) */
        if (!(SRXPIN & (1 << SRX)))
@@ -90,12 +90,12 @@ ISR(INT0_vect, ISR_BLOCK)
                EIMSK = 0;
 
                /* Start the reception timer */
                EIMSK = 0;
 
                /* Start the reception timer */
-               TCCR2B = ((1 << CS20) | (1 << WGM23) | (1 << WGM22));
+               TCCR1B = ((1 << CS10) | (1 << WGM13) | (1 << WGM12));
        }
 }
 
 /** ISR to manage the reception of bits to the software UART. */
        }
 }
 
 /** ISR to manage the reception of bits to the software UART. */
-ISR(TIMER2_CAPT_vect, ISR_BLOCK)
+ISR(TIMER1_CAPT_vect, ISR_BLOCK)
 {
        /* Cache the current RX pin value for later checking */
        uint8_t SRX_Cached = (SRXPIN & (1 << SRX));
 {
        /* Cache the current RX pin value for later checking */
        uint8_t SRX_Cached = (SRXPIN & (1 << SRX));
@@ -114,7 +114,7 @@ ISR(TIMER2_CAPT_vect, ISR_BLOCK)
        else
        {
                /* Disable the reception timer as all data has now been received, re-enable start bit detection ISR */
        else
        {
                /* Disable the reception timer as all data has now been received, re-enable start bit detection ISR */
-               TCCR2B = 0;
+               TCCR1B = 0;
                EIFR   = (1 << INTF0);
                EIMSK  = (1 << INT0);
 
                EIFR   = (1 << INTF0);
                EIMSK  = (1 << INT0);