Rewritten event system to remove all macros, to make user code clearer.
[pub/USBasp.git] / LUFA / Drivers / USB / Class / ConfigDescriptor.h
index 74d6d27..5c2b6e2 100644 (file)
                        #else\r
                                #define DESCRIPTOR_SIZE(DescriptorPtr)    DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).bLength\r
                        #endif\r
-                       \r
-                       /** Creates a prototype for or begins a descriptor comparator routine. Descriptor comparator routines are \r
-                        *  small search routines which are passed a pointer to the current sub descriptor in the configuration\r
-                        *  descriptor, and which analyse the sub descriptor to determine whether or not it matches the routine's\r
-                        *  search parameters. Comparator routines provide a powerful way to scan through the config descriptor\r
-                        *  for certain descriptors matching unique criteria.\r
+\r
+               /* Type Defines: */\r
+                       /** Type define for a Configuration Descriptor comparator function (function taking a pointer to an array\r
+                        *  of type void, returning a uint8_t value).\r
                         *\r
-                        *  Comparator routines are passed in a single pointer named CurrentDescriptor, and should return a value\r
-                        *  of a member of the \ref DSearch_Return_ErrorCodes_t enum.\r
+                        *  \see \ref USB_GetNextDescriptorComp function for more details\r
                         */\r
-                       #define DESCRIPTOR_COMPARATOR(name)           uint8_t DCOMP_##name (void* const CurrentDescriptor)\r
+                       typedef uint8_t (* const ConfigComparatorPtr_t)(void* const);\r
 \r
-               /* Pseudo-Function Macros: */\r
-                       #if defined(__DOXYGEN__)\r
-                               /** Searches for the next descriptor in the given configuration descriptor using a premade comparator\r
-                                *  function. The routine updates the position and remaining configuration descriptor bytes values\r
-                                *  automatically. If a comparator routine fails a search, the descriptor pointer is retreated back\r
-                                *  so that the next descriptor search invocation will start from the descriptor which first caused the\r
-                                *  original search to fail. This behaviour allows for one comparator to be used immediately after another\r
-                                *  has failed, starting the second search from the descriptor which failed the first.\r
-                                *\r
-                                *  \note This function is available in USB Host mode only.\r
-                                *\r
-                                *  \param BytesRem  Pointer to an int storing the remaining bytes in the configuration descriptor\r
-                                *  \param CurrConfigLoc  Pointer to the current position in the configuration descriptor\r
-                                *  \param ComparatorRoutine  Name of the comparator search function to use on the configuration descriptor\r
-                                *\r
-                                *  \return Value of one of the members of the \ref DSearch_Comp_Return_ErrorCodes_t enum\r
-                                *\r
-                                *  Usage Example:\r
-                                *  \code\r
-                                *  DESCRIPTOR_COMPARATOR(EndpointSearcher); // Comparator Prototype\r
-                                *\r
-                                *  DESCRIPTOR_COMPARATOR(EndpointSearcher)\r
-                                *  {\r
-                                *     if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)\r
-                                *         return DESCRIPTOR_SEARCH_Found;\r
-                                *     else\r
-                                *         return DESCRIPTOR_SEARCH_NotFound;\r
-                                *  }\r
-                                *\r
-                                *  //...\r
-                                *  // After retrieving configuration descriptor:\r
-                                *  if (USB_Host_GetNextDescriptorComp(&BytesRemaining, &ConfigDescriptorData, EndpointSearcher) ==\r
-                                *      Descriptor_Search_Comp_Found)\r
-                                *  {\r
-                                *      // Do something with the endpoint descriptor\r
-                                *  }\r
-                                *  \endcode\r
-                                */\r
-                               uint8_t USB_GetNextDescriptorComp(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ComparatorPtr_t ComparatorRoutine);\r
-                       #else\r
-                               #define USB_GetNextDescriptorComp(DSize, DPos, DSearch) USB_GetNextDescriptorComp_Prv(DSize, DPos, DCOMP_##DSearch)\r
-                       #endif\r
+               /* Function Prototypes: */\r
+                       /** Searches for the next descriptor in the given configuration descriptor using a premade comparator\r
+                        *  function. The routine updates the position and remaining configuration descriptor bytes values\r
+                        *  automatically. If a comparator routine fails a search, the descriptor pointer is retreated back\r
+                        *  so that the next descriptor search invocation will start from the descriptor which first caused the\r
+                        *  original search to fail. This behaviour allows for one comparator to be used immediately after another\r
+                        *  has failed, starting the second search from the descriptor which failed the first.\r
+                        *\r
+                        *  Comparator functions should be standard functions which accept a pointer to the header of the current\r
+                        *  descriptor inside the configuration descriptor which is being compared, and should return a value from\r
+                        *  the \ref DSearch_Return_ErrorCodes_t enum as a uint8_t value.\r
+                        *\r
+                        *  \note This function is available in USB Host mode only.\r
+                        *\r
+                        *  \param BytesRem  Pointer to an int storing the remaining bytes in the configuration descriptor\r
+                        *  \param CurrConfigLoc  Pointer to the current position in the configuration descriptor\r
+                        *  \param ComparatorRoutine  Name of the comparator search function to use on the configuration descriptor\r
+                        *\r
+                        *  \return Value of one of the members of the \ref DSearch_Comp_Return_ErrorCodes_t enum\r
+                        *\r
+                        *  Usage Example:\r
+                        *  \code\r
+                        *  uint8_t EndpointSearcher(void* CurrentDescriptor); // Comparator Prototype\r
+                        *\r
+                        *  uint8_t EndpointSearcher(void* CurrentDescriptor)\r
+                        *  {\r
+                        *     if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)\r
+                        *         return DESCRIPTOR_SEARCH_Found;\r
+                        *     else\r
+                        *         return DESCRIPTOR_SEARCH_NotFound;\r
+                        *  }\r
+                        *\r
+                        *  //...\r
+                        *  // After retrieving configuration descriptor:\r
+                        *  if (USB_Host_GetNextDescriptorComp(&BytesRemaining, &ConfigDescriptorData, EndpointSearcher) ==\r
+                        *      Descriptor_Search_Comp_Found)\r
+                        *  {\r
+                        *      // Do something with the endpoint descriptor\r
+                        *  }\r
+                        *  \endcode\r
+                        */\r
+                       uint8_t USB_GetNextDescriptorComp(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine);\r
                        \r
                /* Enums: */\r
-                       /** Enum for return values of a descriptor comparator made with \ref DESCRIPTOR_COMPARATOR. */\r
+                       /** Enum for return values of a descriptor comparator function. */\r
                        enum DSearch_Return_ErrorCodes_t\r
                        {\r
                                DESCRIPTOR_SEARCH_Found                = 0, /**< Current descriptor matches comparator criteria. */\r
                                *BytesRem      -= CurrDescriptorSize;\r
                        }\r
                        \r
-               /* Type Defines: */\r
-                       /** Type define for a Configuration Descriptor comparator function (function taking a pointer to an array\r
-                        *  of type void, returning a uint8_t value).\r
-                        *\r
-                        *  \see \ref USB_GetNextDescriptorComp function for more details\r
-                        */\r
-                       typedef uint8_t (* const ConfigComparatorPtr_t)(void* const);\r
-\r
-       /* Private Interface - For use in library only: */\r
-       #if !defined(__DOXYGEN__)\r
-               /* Function Prototypes: */\r
-                       uint8_t USB_GetNextDescriptorComp_Prv(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine);\r
-       #endif\r
-                       \r
        /* Disable C linkage for C++ Compilers: */\r
                #if defined(__cplusplus)\r
                        }\r