Create a new function pointer type in StreamCallbacks.h for endpoint/pipe stream...
[pub/USBasp.git] / Demos / Host / KeyboardHostWithParser / ConfigDescriptor.c
index 73f0ce2..9cdf6f8 100644 (file)
@@ -49,7 +49,6 @@ uint8_t ProcessConfigurationDescriptor(void)
 {\r
        uint8_t* ConfigDescriptorData;\r
        uint16_t ConfigDescriptorSize;\r
-       uint8_t  ErrorCode;\r
        \r
        /* Get Configuration Descriptor size from the device */\r
        if (USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful)\r
@@ -70,14 +69,16 @@ uint8_t ProcessConfigurationDescriptor(void)
          return InvalidConfigDataReturned;\r
        \r
        /* Get the keyboard interface from the configuration descriptor */\r
-       if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextKeyboardInterface)))\r
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                     NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoHIDInterfaceFound;\r
        }\r
        \r
        /* Get the keyboard interface's HID descriptor */\r
-       if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextHID)))\r
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                     NextHID) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoHIDDescriptorFound;\r
@@ -87,8 +88,8 @@ uint8_t ProcessConfigurationDescriptor(void)
        HIDReportSize = DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_HID_t).HIDReportLength;\r
 \r
        /* Get the keyboard interface's data endpoint descriptor */\r
-       if ((ErrorCode = USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
-                                                       NextInterfaceKeyboardDataEndpoint)))\r
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+                                     NextInterfaceKeyboardDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
        {\r
                /* Descriptor not found, error out */\r
                return NoEndpointFound;\r
@@ -123,11 +124,11 @@ DESCRIPTOR_COMPARATOR(NextKeyboardInterface)
                if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class    == KEYBOARD_CLASS) &&\r
                    (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == KEYBOARD_PROTOCOL))\r
                {\r
-                       return Descriptor_Search_Found;\r
+                       return DESCRIPTOR_SEARCH_Found;\r
                }\r
        }\r
        \r
-       return Descriptor_Search_NotFound;\r
+       return DESCRIPTOR_SEARCH_NotFound;\r
 }\r
 \r
 /** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's\r
@@ -144,14 +145,14 @@ DESCRIPTOR_COMPARATOR(NextInterfaceKeyboardDataEndpoint)
        if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)\r
        {\r
                if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)\r
-                 return Descriptor_Search_Found;\r
+                 return DESCRIPTOR_SEARCH_Found;\r
        }\r
        else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)\r
        {\r
-               return Descriptor_Search_Fail;\r
+               return DESCRIPTOR_SEARCH_Fail;\r
        }\r
 \r
-       return Descriptor_Search_NotFound;\r
+       return DESCRIPTOR_SEARCH_NotFound;\r
 }\r
 \r
 /** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's\r
@@ -165,7 +166,7 @@ DESCRIPTOR_COMPARATOR(NextInterfaceKeyboardDataEndpoint)
 DESCRIPTOR_COMPARATOR(NextHID)\r
 {\r
        if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_HID)\r
-         return Descriptor_Search_Found;\r
+         return DESCRIPTOR_SEARCH_Found;\r
        else\r
-         return Descriptor_Search_NotFound;      \r
+         return DESCRIPTOR_SEARCH_NotFound;      \r
 }\r