Fix XPLAINBridge code broken during the changes to the Rescue Clock generation in the AVRISP-MKII clone project.
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).
This commit is contained in:
parent
3bf760ad7d
commit
5ce8380a7d
25 changed files with 380 additions and 287 deletions
|
|
@ -135,11 +135,15 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
*/
|
||||
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 */
|
||||
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 */
|
||||
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;
|
||||
|
|
@ -161,13 +165,15 @@ uint8_t DComp_NextHIDInterface(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 */
|
||||
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;
|
||||
}
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -131,10 +131,14 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
*/
|
||||
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 */
|
||||
if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == HID_CSCP_HIDClass))
|
||||
if ((Interface->Class == HID_CSCP_HIDClass))
|
||||
{
|
||||
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.
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
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
|
||||
|
|
@ -177,7 +178,9 @@ uint8_t DComp_NextJoystickInterfaceDataEndpoint(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;
|
||||
|
|
|
|||
|
|
@ -116,11 +116,15 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
*/
|
||||
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 */
|
||||
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;
|
||||
}
|
||||
|
|
@ -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.
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,10 +131,14 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
*/
|
||||
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 */
|
||||
if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == HID_CSCP_HIDClass)
|
||||
if (Interface->Class == HID_CSCP_HIDClass)
|
||||
{
|
||||
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.
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
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
|
||||
|
|
@ -177,9 +178,11 @@ uint8_t DComp_NextKeyboardInterfaceDataEndpoint(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 if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
|
||||
else if (Header->Type == DTYPE_Interface)
|
||||
return DESCRIPTOR_SEARCH_Fail;
|
||||
else
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
|
|
|
|||
|
|
@ -126,12 +126,16 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
*/
|
||||
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 */
|
||||
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;
|
||||
}
|
||||
|
|
@ -151,16 +155,17 @@ uint8_t DComp_NextMIDIStreamingInterface(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 */
|
||||
if (EndpointType == EP_TYPE_BULK)
|
||||
if ((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_BULK)
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
|
||||
else if (Header->Type == DTYPE_Interface)
|
||||
{
|
||||
return DESCRIPTOR_SEARCH_Fail;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,12 +126,16 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
*/
|
||||
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 */
|
||||
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;
|
||||
}
|
||||
|
|
@ -151,16 +155,17 @@ uint8_t DComp_NextMSInterface(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 */
|
||||
if (EndpointType == EP_TYPE_BULK)
|
||||
if ((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_BULK)
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
|
||||
else if (Header->Type == DTYPE_Interface)
|
||||
{
|
||||
return DESCRIPTOR_SEARCH_Fail;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,12 +116,16 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
*/
|
||||
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 */
|
||||
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 */
|
||||
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;
|
||||
|
|
@ -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.
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,10 +131,14 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
*/
|
||||
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 */
|
||||
if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == HID_CSCP_HIDClass)
|
||||
if (Interface->Class == HID_CSCP_HIDClass)
|
||||
{
|
||||
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.
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
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
|
||||
|
|
@ -177,7 +178,9 @@ uint8_t DComp_NextMouseInterfaceDataEndpoint(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;
|
||||
|
|
|
|||
|
|
@ -130,12 +130,16 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
*/
|
||||
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 */
|
||||
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;
|
||||
}
|
||||
|
|
@ -155,16 +159,17 @@ uint8_t DComp_NextBidirectionalPrinterInterface(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 */
|
||||
if (EndpointType == EP_TYPE_BULK)
|
||||
if ((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_BULK)
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
|
||||
else if (Header->Type == DTYPE_Interface)
|
||||
{
|
||||
return DESCRIPTOR_SEARCH_Fail;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,12 +157,16 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
*/
|
||||
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 */
|
||||
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;
|
||||
}
|
||||
|
|
@ -181,12 +185,16 @@ uint8_t DComp_NextCDCControlInterface(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 */
|
||||
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;
|
||||
}
|
||||
|
|
@ -207,15 +215,20 @@ uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor)
|
|||
*/
|
||||
uint8_t DComp_NextCDCDataInterfaceEndpoint(void* CurrentDescriptor)
|
||||
{
|
||||
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
|
||||
{
|
||||
uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor,
|
||||
USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK);
|
||||
USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
|
||||
|
||||
if ((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT))
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
if (Header->Type == DTYPE_Endpoint)
|
||||
{
|
||||
USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,12 +141,16 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
*/
|
||||
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 */
|
||||
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;
|
||||
}
|
||||
|
|
@ -166,15 +170,20 @@ uint8_t DComp_NextStillImageInterface(void* CurrentDescriptor)
|
|||
*/
|
||||
uint8_t DComp_NextStillImageInterfaceDataEndpoint(void* CurrentDescriptor)
|
||||
{
|
||||
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
|
||||
{
|
||||
uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor,
|
||||
USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK);
|
||||
USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
|
||||
|
||||
if ((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT))
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
if (Header->Type == DTYPE_Endpoint)
|
||||
{
|
||||
USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,12 +157,16 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
*/
|
||||
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 */
|
||||
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;
|
||||
}
|
||||
|
|
@ -181,12 +185,16 @@ uint8_t DComp_NextCDCControlInterface(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 */
|
||||
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;
|
||||
}
|
||||
|
|
@ -207,15 +215,19 @@ uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor)
|
|||
*/
|
||||
uint8_t DComp_NextCDCDataInterfaceEndpoint(void* CurrentDescriptor)
|
||||
{
|
||||
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
|
||||
{
|
||||
uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor,
|
||||
USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK);
|
||||
USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
|
||||
|
||||
if ((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT))
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
if (Header->Type == DTYPE_Endpoint)
|
||||
{
|
||||
USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue