Commit 663f449c authored by Dean Camera's avatar Dean Camera
Browse files

Fixed incorrect HID interface class and subclass values in the Mouse and...

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.
parent 32e735b2
......@@ -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;
}
......@@ -52,6 +52,9 @@
* - Removed "Host_" section of the function names in ConfigDescriptor.h, as most of the routines can now be used in device mode on the
* device descriptor
* - Renamed functions in the HID parser to have a "USB_" prefix and the acronym "HID" in the name
* - 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
*
*
* \section Sec_ChangeLog090401 Version 090401
......
......@@ -66,7 +66,7 @@
#if !defined(__DOXYGEN__)
static inline void HWB_Init(void)
{
// TODO: Initialize the appropriate port pin as an input here, with pullup
// TODO: Initialize the appropriate port pin as an input here, with pull-up
}
static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
......
......@@ -75,7 +75,7 @@
#endif
/* Public Interface - May be used in end-application: */
/* Psuedo-Function Macros: */
/* Pseudo-Function Macros: */
#if defined(__DOXYGEN__)
/** Determines the currently selected dataflash chip.
*
......
......@@ -82,7 +82,7 @@
/** Maximum returnable temperature from the Temperature_GetTemperature() function. */
#define TEMP_MAX_TEMP ((TEMP_TABLE_SIZE - 1) + TEMP_TABLE_OFFSET)
/* Psuedo-Functions: */
/* Pseudo-Function Macros: */
#if defined(__DOXYGEN__)
/** Initializes the temperature sensor driver, including setting up the appropriate ADC channel.
* This must be called before any other temperature sensor routines.
......
......@@ -62,32 +62,7 @@
#endif
/* Public Interface - May be used in end-application: */
/* Macros: */
/** Initializes the ADC, ready for conversions. This must be called before any other ADC operations.
* The "mode" parameter should be a mask comprised of a conversion mode (free running or single) and
* prescaler masks.
*/
#define ADC_Init(mode) MACROS{ ADCSRA = ((1 << ADEN) | mode); }MACROE
/** Turns off the ADC. If this is called, any further ADC operations will require a call to the
* ADC_Init() macro before the ADC can be used again.
*/
#define ADC_Off() MACROS{ ADCSRA = 0; }MACROE
/** Indicates if the ADC is enabled. This macro will return boolean true if the ADC subsystem is
* currently enabled, or false otherwise.
*/
#define ADC_GetStatus() ((ADCSRA & (1 << ADEN)) ? true : false)
/** Indicates if the current ADC conversion is completed, or still in progress. This returns boolean
* false if the reading is still taking place, or true if the conversion is complete and ready to be
* read out with ADC_GetResult().
*/
#define ADC_IsReadingComplete() (!(ADCSRA & (1 << ADSC)))
/** Returns the result of the last conversion, as a 16-bit wide integer. */
#define ADC_GetResult() ADC
/* Macros: */
/** Reference mask, for using the voltage present at the AVR's AREF pin for the ADC reference. */
#define ADC_REFERENCE_AREF 0
......@@ -134,6 +109,51 @@
/** Sets the ADC input clock to prescale by a factor of 128 the AVR's system clock. */
#define ADC_PRESCALE_128 ((1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0))
/* Pseudo-Function Macros: */
#if defined(__DOXYGEN__)
/** Initializes the ADC, ready for conversions. This must be called before any other ADC operations.
* The "mode" parameter should be a mask comprised of a conversion mode (free running or single) and
* prescaler masks.
*
* \param Mode Mask of ADC settings, including adjustment, prescale, mode and reference
*/
static inline void ADC_Init(uint8_t Mode);
/** Turns off the ADC. If this is called, any further ADC operations will require a call to
* ADC_Init() before the ADC can be used again.
*/
static inline void ADC_Off(void);
/** Indicates if the ADC is currently enabled.
*
* \return Boolean true if the ADC subsystem is currently enabled, false otherwise.
*/
static inline bool ADC_GetStatus(void);
/** Indicates if the current ADC conversion is completed, or still in progress.
*
* \return Boolean false if the reading is still taking place, or true if the conversion is
* complete and ready to be read out with ADC_GetResult()
*/
static inline bool ADC_IsReadingComplete(void);
/** Retrieves the conversion value of the last completed ADC conversion.
*
* \return The result of the last ADC conversion
*/
static inline uint16_t ADC_GetResult(void);
#else
#define ADC_Init(mode) MACROS{ ADCSRA = ((1 << ADEN) | mode); }MACROE
#define ADC_Off() MACROS{ ADCSRA = 0; }MACROE
#define ADC_GetStatus() ((ADCSRA & (1 << ADEN)) ? true : false)
#define ADC_IsReadingComplete() (!(ADCSRA & (1 << ADSC)))
#define ADC_GetResult() ADC
#endif
/* Inline Functions: */
/** Configures the given ADC channel, ready for ADC conversions. This function sets the
* associated port pin as an input and disables the digital portion of the I/O to reduce
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment