Fixed incorrect HID interface class and subclass values in the Mouse and KeyboardMouse demos (thanks to Brian Dickman).
Capitolised the "Descriptor_Search" and "Descriptor_Search_Comp" prefixes of the values in the DSearch_Return_ErrorCodes_t and DSearch_Comp_Return_ErrorCodes_t enums. Minor documentation improvements.
This commit is contained in:
parent
32e735b2b2
commit
663f449c10
33 changed files with 142 additions and 119 deletions
|
|
@ -173,7 +173,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
|
||||
Class: 0x03,
|
||||
SubClass: 0x01,
|
||||
Protocol: 0x00,
|
||||
Protocol: 0x01,
|
||||
|
||||
InterfaceStrIndex: NO_DESCRIPTOR
|
||||
},
|
||||
|
|
@ -219,8 +219,8 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
TotalEndpoints: 1,
|
||||
|
||||
Class: 0x03,
|
||||
SubClass: 0x02,
|
||||
Protocol: 0x00,
|
||||
SubClass: 0x01,
|
||||
Protocol: 0x02,
|
||||
|
||||
InterfaceStrIndex: NO_DESCRIPTOR
|
||||
},
|
||||
|
|
|
|||
|
|
@ -132,8 +132,8 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
TotalEndpoints: 1,
|
||||
|
||||
Class: 0x03,
|
||||
SubClass: 0x02,
|
||||
Protocol: 0x01,
|
||||
SubClass: 0x01,
|
||||
Protocol: 0x02,
|
||||
|
||||
InterfaceStrIndex: NO_DESCRIPTOR
|
||||
},
|
||||
|
|
|
|||
|
|
@ -181,11 +181,11 @@ DESCRIPTOR_COMPARATOR(NextCDCControlInterface)
|
|||
(DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == CDC_CONTROL_SUBCLASS) &&
|
||||
(DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == CDC_CONTROL_PROTOCOL))
|
||||
{
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
}
|
||||
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
/** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
|
||||
|
|
@ -205,11 +205,11 @@ DESCRIPTOR_COMPARATOR(NextCDCDataInterface)
|
|||
(DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == CDC_DATA_SUBCLASS) &&
|
||||
(DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == CDC_DATA_PROTOCOL))
|
||||
{
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
}
|
||||
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
/** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
|
||||
|
|
@ -230,12 +230,12 @@ DESCRIPTOR_COMPARATOR(NextInterfaceCDCDataEndpoint)
|
|||
USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK);
|
||||
|
||||
if ((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT))
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
|
||||
{
|
||||
return Descriptor_Search_Fail;
|
||||
return DESCRIPTOR_SEARCH_Fail;
|
||||
}
|
||||
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,12 +143,12 @@ DESCRIPTOR_COMPARATOR(NextHIDInterface)
|
|||
if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == HID_CLASS)
|
||||
{
|
||||
/* Indicate that the descriptor being searched for has been found */
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
}
|
||||
|
||||
/* Current descriptor does not match what this comparator is looking for */
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
/** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
|
||||
|
|
@ -166,14 +166,14 @@ DESCRIPTOR_COMPARATOR(NextInterfaceHIDDataEndpoint)
|
|||
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
|
||||
{
|
||||
/* Indicate that the descriptor being searched for has been found */
|
||||
return Descriptor_Search_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;
|
||||
return DESCRIPTOR_SEARCH_Fail;
|
||||
}
|
||||
|
||||
/* Current descriptor does not match what this comparator is looking for */
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,9 +117,9 @@ DESCRIPTOR_COMPARATOR(NextKeyboardInterface)
|
|||
{
|
||||
/* Check the HID descriptor class and protocol, break out if correct class/protocol interface found */
|
||||
if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == KEYBOARD_CLASS) &&
|
||||
(DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == KEYBOARD_PROTOCOL))
|
||||
(DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Subclass == KEYBOARD_SUBCLASS))
|
||||
{
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -140,12 +140,12 @@ DESCRIPTOR_COMPARATOR(NextInterfaceKeyboardDataEndpoint)
|
|||
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
|
||||
{
|
||||
if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
|
||||
{
|
||||
return Descriptor_Search_Fail;
|
||||
return DESCRIPTOR_SEARCH_Fail;
|
||||
}
|
||||
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,11 +123,11 @@ DESCRIPTOR_COMPARATOR(NextKeyboardInterface)
|
|||
if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == KEYBOARD_CLASS) &&
|
||||
(DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == KEYBOARD_PROTOCOL))
|
||||
{
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
}
|
||||
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
/** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
|
||||
|
|
@ -144,14 +144,14 @@ DESCRIPTOR_COMPARATOR(NextInterfaceKeyboardDataEndpoint)
|
|||
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
|
||||
{
|
||||
if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
|
||||
{
|
||||
return Descriptor_Search_Fail;
|
||||
return DESCRIPTOR_SEARCH_Fail;
|
||||
}
|
||||
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
/** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
|
||||
|
|
@ -165,7 +165,7 @@ DESCRIPTOR_COMPARATOR(NextInterfaceKeyboardDataEndpoint)
|
|||
DESCRIPTOR_COMPARATOR(NextHID)
|
||||
{
|
||||
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_HID)
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
else
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ uint8_t GetHIDReportData(void)
|
|||
return ParseControlError;
|
||||
|
||||
/* Send the HID report to the parser for processing */
|
||||
if (ProcessHIDReport(HIDReportData, HIDReportSize, &HIDReportInfo) != HID_PARSE_Successful)
|
||||
if (USB_ProcessHIDReport(HIDReportData, HIDReportSize, &HIDReportInfo) != HID_PARSE_Successful)
|
||||
return ParseError;
|
||||
|
||||
return ParseSuccessful;
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ void ProcessKeyboardReport(uint8_t* KeyboardReport)
|
|||
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
|
||||
{
|
||||
/* Retrieve the keyboard scancode from the report data retrieved from the device */
|
||||
bool FoundData = GetReportItemInfo(KeyboardReport, ReportItem);
|
||||
bool FoundData = USB_GetHIDReportItemInfo(KeyboardReport, ReportItem);
|
||||
|
||||
/* For multi-report devices - if the requested data was not in the issued report, continue */
|
||||
if (!(FoundData))
|
||||
|
|
|
|||
|
|
@ -137,11 +137,11 @@ DESCRIPTOR_COMPARATOR(NextMassStorageInterface)
|
|||
(DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == MASS_STORE_SUBCLASS) &&
|
||||
(DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == MASS_STORE_PROTOCOL))
|
||||
{
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
}
|
||||
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
/** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
|
||||
|
|
@ -162,12 +162,12 @@ DESCRIPTOR_COMPARATOR(NextInterfaceBulkDataEndpoint)
|
|||
|
||||
/* Check the endpoint type, break out if correct BULK type endpoint found */
|
||||
if (EndpointType == EP_TYPE_BULK)
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
|
||||
{
|
||||
return Descriptor_Search_Fail;
|
||||
return DESCRIPTOR_SEARCH_Fail;
|
||||
}
|
||||
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,15 +69,15 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
return InvalidConfigDataReturned;
|
||||
|
||||
/* Get the mouse interface from the configuration descriptor */
|
||||
if (USB_Host_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextMouseInterface))
|
||||
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, NextMouseInterface))
|
||||
{
|
||||
/* Descriptor not found, error out */
|
||||
return NoHIDInterfaceFound;
|
||||
}
|
||||
|
||||
/* Get the mouse interface's data endpoint descriptor */
|
||||
if (USB_Host_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
|
||||
NextInterfaceMouseDataEndpoint))
|
||||
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
|
||||
NextInterfaceMouseDataEndpoint))
|
||||
{
|
||||
/* Descriptor not found, error out */
|
||||
return NoEndpointFound;
|
||||
|
|
@ -121,12 +121,12 @@ DESCRIPTOR_COMPARATOR(NextMouseInterface)
|
|||
(DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == MOUSE_PROTOCOL))
|
||||
{
|
||||
/* Indicate that the descriptor being searched for has been found */
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
}
|
||||
|
||||
/* Current descriptor does not match what this comparator is looking for */
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
/** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
|
||||
|
|
@ -147,15 +147,15 @@ DESCRIPTOR_COMPARATOR(NextInterfaceMouseDataEndpoint)
|
|||
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;
|
||||
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;
|
||||
return DESCRIPTOR_SEARCH_Fail;
|
||||
}
|
||||
|
||||
/* Current descriptor does not match what this comparator is looking for */
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,11 +123,11 @@ DESCRIPTOR_COMPARATOR(NextMouseInterface)
|
|||
if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == MOUSE_CLASS) &&
|
||||
(DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == MOUSE_PROTOCOL))
|
||||
{
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
}
|
||||
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
/** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
|
||||
|
|
@ -144,14 +144,14 @@ DESCRIPTOR_COMPARATOR(NextInterfaceMouseDataEndpoint)
|
|||
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
|
||||
{
|
||||
if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
|
||||
{
|
||||
return Descriptor_Search_Fail;
|
||||
return DESCRIPTOR_SEARCH_Fail;
|
||||
}
|
||||
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
/** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
|
||||
|
|
@ -165,7 +165,7 @@ DESCRIPTOR_COMPARATOR(NextInterfaceMouseDataEndpoint)
|
|||
DESCRIPTOR_COMPARATOR(NextHID)
|
||||
{
|
||||
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_HID)
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
else
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ uint8_t GetHIDReportData(void)
|
|||
return ParseControlError;
|
||||
|
||||
/* Send the HID report to the parser for processing */
|
||||
if (ProcessHIDReport(HIDReportData, HIDReportSize, &HIDReportInfo) != HID_PARSE_Successful)
|
||||
if (USB_ProcessHIDReport(HIDReportData, HIDReportSize, &HIDReportInfo) != HID_PARSE_Successful)
|
||||
return ParseError;
|
||||
|
||||
return ParseSuccessful;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
#define _HID_REPORT_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h> // HID Class Report Parser
|
||||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
|
||||
#include "MouseHostWithParser.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ void ProcessMouseReport(uint8_t* MouseReport)
|
|||
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
|
||||
{
|
||||
/* Get the mouse button value */
|
||||
FoundData = GetReportItemInfo(MouseReport, ReportItem);
|
||||
FoundData = USB_GetHIDReportItemInfo(MouseReport, ReportItem);
|
||||
|
||||
/* For multi-report devices - if the requested data was not in the issued report, continue */
|
||||
if (!(FoundData))
|
||||
|
|
@ -328,7 +328,7 @@ void ProcessMouseReport(uint8_t* MouseReport)
|
|||
(ReportItem->ItemType == REPORT_ITEM_TYPE_In))
|
||||
{
|
||||
/* Get the mouse relative position value */
|
||||
FoundData = GetReportItemInfo(MouseReport, ReportItem);
|
||||
FoundData = USB_GetHIDReportItemInfo(MouseReport, ReportItem);
|
||||
|
||||
/* For multi-report devices - if the requested data was not in the issued report, continue */
|
||||
if (!(FoundData))
|
||||
|
|
|
|||
|
|
@ -156,11 +156,11 @@ DESCRIPTOR_COMPARATOR(NextStillImageInterface)
|
|||
(DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == SIMAGE_SUBCLASS) &&
|
||||
(DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == SIMAGE_PROTOCOL))
|
||||
{
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
}
|
||||
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
/** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
|
||||
|
|
@ -180,12 +180,12 @@ DESCRIPTOR_COMPARATOR(NextSImageInterfaceDataEndpoint)
|
|||
USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK);
|
||||
|
||||
if ((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT))
|
||||
return Descriptor_Search_Found;
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
|
||||
{
|
||||
return Descriptor_Search_Fail;
|
||||
return DESCRIPTOR_SEARCH_Fail;
|
||||
}
|
||||
|
||||
return Descriptor_Search_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue