aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Host
diff options
context:
space:
mode:
Diffstat (limited to 'Demos/Host')
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.c6
-rw-r--r--Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c14
-rw-r--r--Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c33
-rw-r--r--Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c33
-rw-r--r--Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c35
-rw-r--r--Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c23
-rw-r--r--Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c23
-rw-r--r--Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c39
-rw-r--r--Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c33
-rw-r--r--Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c23
-rw-r--r--Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.c41
-rw-r--r--Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c29
-rw-r--r--Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.c40
13 files changed, 217 insertions, 155 deletions
diff --git a/Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.c b/Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.c
index 29008bad1..b09146c0e 100644
--- a/Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.c
+++ b/Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.c
@@ -132,10 +132,12 @@ uint8_t ProcessConfigurationDescriptor(void)
*/
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 */
- if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
+ if (Header->Type == DTYPE_Endpoint)
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;
diff --git a/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c b/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c
index c2a1f36be..7361d73a5 100644
--- a/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c
+++ b/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c
@@ -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;
diff --git a/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c b/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c
index 8e837005f..9fc1498c2 100644
--- a/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c
+++ b/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c
@@ -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;
diff --git a/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c b/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c
index 7e614b097..01c252c02 100644
--- a/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c
+++ b/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c
@@ -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;
- }
-
- 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;
}
diff --git a/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c b/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c
index 1d389ef32..998ba20e1 100644
--- a/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c
+++ b/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c
@@ -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;
diff --git a/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c b/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c
index cf1d4e69a..544e31ac8 100644
--- a/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c
+++ b/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c
@@ -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;
}
diff --git a/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c b/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c
index 2629f2071..91c96828e 100644
--- a/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c
+++ b/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c
@@ -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;
}
diff --git a/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c b/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c
index f74ecf29f..5a8ffa7fb 100644
--- a/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c
+++ b/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c
@@ -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;
}
diff --git a/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c b/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c
index 56842486d..7702511c7 100644
--- a/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c
+++ b/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c
@@ -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;
diff --git a/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c b/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c
index 2b1f6906f..162afabcf 100644
--- a/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c
+++ b/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c
@@ -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;
}
diff --git a/Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.c b/Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.c
index 8bd12bc20..eef8673c1 100644
--- a/Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.c
+++ b/Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.c
@@ -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)
+ 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;
}
diff --git a/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c b/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c
index 6a345864d..e11fc1708 100644
--- a/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c
+++ b/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c
@@ -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)
+ 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;
}
diff --git a/Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.c b/Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.c
index d702771eb..7a8f97235 100644
--- a/Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.c
+++ b/Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.c
@@ -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)
+ 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;
}