Add new HID_DESCRIPTOR_VENDOR() macro, change over all projects and Device ClassDriver demos to use it.

Fix reversed byte ordering of multi-byte HID data.

Added support to the HID parser for extended USAGE items that contain the usage page as well as the usage index.

Removed the HID_IOF_NON_VOLATILE and HID_IOF_VOLATILE flags from HID INPUT items where the flag is invalid. Changed over HID OUTPUT items to use HID_IOF_NON_VOLATILE.

Change over MagStripe project to use HID_DESCRIPTOR_KEYBOARD() for its HID report. Change over MouseHostDevice demo to use HID_DESCRIPTOR_MOUSE() for its HID report.
pull/1469/head
Dean Camera 14 years ago
parent a852ea8e43
commit e6dc951630

@ -45,22 +45,14 @@
*/
USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] =
{
HID_RI_USAGE_PAGE(16, 0x00FF), /* Vendor Page 1 */
HID_RI_USAGE(8, 0x01), /* Vendor Usage 1 */
HID_RI_COLLECTION(8, 0x01), /* Vendor Usage 1 */
HID_RI_USAGE(8, 0x02), /* Vendor Usage 2 */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_REPORT_COUNT(8, GENERIC_REPORT_SIZE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
HID_RI_USAGE(8, 0x03), /* Vendor Usage 3 */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_REPORT_COUNT(8, GENERIC_REPORT_SIZE),
HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
HID_RI_END_COLLECTION(0),
/* Use the HID class driver's standard Joystick report.
* Vendor Usage Page: 1
* Vendor Collection Usage: 1
* Vendor Report IN Usage: 2
* Vendor Report OUT Usage: 3
* Vendor Report Size: GENERIC_REPORT_SIZE
*/
HID_DESCRIPTOR_VENDOR(0x00, 0x01, 0x02, 0x03, GENERIC_REPORT_SIZE)
};
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -44,14 +44,14 @@
* more details on HID report descriptors.
*/
USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] =
{
{
/* Use the HID class driver's standard Joystick report.
* Min X/Y Axis values: -100
* Max X/Y Axis values: 100
* Buttons: 2
*/
HID_DESCRIPTOR_JOYSTICK(-100, 100, 2)
};
};
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
* device characteristics, including the supported USB version, control endpoint size and the

@ -61,7 +61,7 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM HIDReport[] =
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
HID_RI_REPORT_COUNT(8, 0x03),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x05),
HID_RI_INPUT(8, HID_IOF_CONSTANT),
@ -74,7 +74,7 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM HIDReport[] =
HID_RI_PHYSICAL_MAXIMUM(8, 1),
HID_RI_REPORT_COUNT(8, 0x02),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE | HID_IOF_NON_VOLATILE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0),
@ -90,7 +90,7 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM HIDReport[] =
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_REPORT_COUNT(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_CONSTANT),
@ -110,7 +110,7 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM HIDReport[] =
HID_RI_USAGE_MAXIMUM(8, 0x65), /* Keyboard Application */
HID_RI_REPORT_COUNT(8, 0x06),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
HID_RI_END_COLLECTION(0),
};

@ -45,7 +45,7 @@
*/
USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] =
{
HID_RI_USAGE_PAGE(16, 0x00FF), /* Vendor Page 1 */
HID_RI_USAGE_PAGE(16, 0xFF00), /* Vendor Page 1 */
HID_RI_USAGE(8, 0x01), /* Vendor Usage 1 */
HID_RI_COLLECTION(8, 0x01), /* Vendor Usage 1 */
HID_RI_USAGE(8, 0x02), /* Vendor Usage 2 */
@ -53,13 +53,13 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] =
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_REPORT_COUNT(8, GENERIC_REPORT_SIZE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_USAGE(8, 0x03), /* Vendor Usage 3 */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_REPORT_COUNT(8, GENERIC_REPORT_SIZE),
HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_END_COLLECTION(0),
};

@ -56,7 +56,7 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] =
HID_RI_LOGICAL_MAXIMUM(8, 100),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_REPORT_COUNT(8, 0x02),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_END_COLLECTION(0),
HID_RI_USAGE_PAGE(8, 0x09), /* Button */
HID_RI_USAGE_MINIMUM(8, 0x01),
@ -65,7 +65,7 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] =
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_REPORT_COUNT(8, 0x02),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_REPORT_SIZE(8, 0x06),
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_INPUT(8, HID_IOF_CONSTANT),

@ -56,7 +56,7 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_REPORT_COUNT(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_CONSTANT),
@ -76,7 +76,7 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
HID_RI_USAGE_MAXIMUM(8, 0x65), /* Keyboard Application */
HID_RI_REPORT_COUNT(8, 0x06),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
HID_RI_END_COLLECTION(0),
};

@ -60,7 +60,7 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
HID_RI_REPORT_COUNT(8, 0x03),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x05),
HID_RI_INPUT(8, HID_IOF_CONSTANT),
@ -73,7 +73,7 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
HID_RI_PHYSICAL_MAXIMUM(8, 1),
HID_RI_REPORT_COUNT(8, 0x02),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE | HID_IOF_NON_VOLATILE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0),
};
@ -91,7 +91,7 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_REPORT_COUNT(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_CONSTANT),
@ -111,7 +111,7 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
HID_RI_USAGE_MAXIMUM(8, 0x65), /* Keyboard Application */
HID_RI_REPORT_COUNT(8, 0x06),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
HID_RI_END_COLLECTION(0),
};

@ -57,7 +57,7 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
HID_RI_REPORT_COUNT(8, 0x03),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x05),
HID_RI_INPUT(8, HID_IOF_CONSTANT),
@ -70,7 +70,7 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
HID_RI_PHYSICAL_MAXIMUM(8, 1),
HID_RI_REPORT_COUNT(8, 0x02),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE | HID_IOF_NON_VOLATILE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0),
};

@ -45,34 +45,15 @@
*/
USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
{
HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
HID_RI_USAGE(8, 0x02), /* Mouse */
HID_RI_COLLECTION(8, 0x01), /* Application */
HID_RI_USAGE(8, 0x01), /* Pointer */
HID_RI_COLLECTION(8, 0x00), /* Physical */
HID_RI_USAGE_PAGE(8, 0x09), /* Button */
HID_RI_USAGE_MINIMUM(8, 0x01),
HID_RI_USAGE_MAXIMUM(8, 0x03),
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
HID_RI_REPORT_COUNT(8, 0x03),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x05),
HID_RI_INPUT(8, HID_IOF_CONSTANT),
HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
HID_RI_USAGE(8, 0x30), /* Usage X */
HID_RI_USAGE(8, 0x31), /* Usage Y */
HID_RI_LOGICAL_MINIMUM(8, -1),
HID_RI_LOGICAL_MAXIMUM(8, 1),
HID_RI_PHYSICAL_MINIMUM(8, -1),
HID_RI_PHYSICAL_MAXIMUM(8, 1),
HID_RI_REPORT_COUNT(8, 0x02),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE | HID_IOF_NON_VOLATILE),
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0),
/* Use the HID class driver's standard Mouse report.
* Min X/Y Axis values: -1
* Max X/Y Axis values: 1
* Min physical X/Y Axis values (used to determine resolution): -1
* Max physical X/Y Axis values (used to determine resolution): 1
* Buttons: 3
* Absolute screen coordinates: false
*/
HID_DESCRIPTOR_MOUSE(-1, 1, -1, 1, 3, false)
};
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -357,7 +357,7 @@
HID_RI_USAGE(8, 0x31), \
HID_RI_REPORT_SIZE(8, (((((uint16_t)MinAxisVal > 0xFF) && ((uint16_t)MaxAxisVal < 0xFF)) ? 8 : 16))), \
HID_RI_REPORT_COUNT(8, 0x02), \
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), \
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
HID_RI_END_COLLECTION(0), \
HID_RI_USAGE_PAGE(8, 0x09), \
HID_RI_USAGE_MINIMUM(8, 0x01), \
@ -366,7 +366,7 @@
HID_RI_LOGICAL_MAXIMUM(8, 0x01), \
HID_RI_REPORT_SIZE(8, 0x01), \
HID_RI_REPORT_COUNT(8, Buttons), \
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), \
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
HID_RI_REPORT_SIZE(8, (8 - (Buttons % 8))), \
HID_RI_REPORT_COUNT(8, 0x01), \
HID_RI_INPUT(8, HID_IOF_CONSTANT), \
@ -400,7 +400,7 @@
HID_RI_LOGICAL_MAXIMUM(8, 0x01), \
HID_RI_REPORT_SIZE(8, 0x01), \
HID_RI_REPORT_COUNT(8, 0x08), \
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), \
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
HID_RI_REPORT_COUNT(8, 0x01), \
HID_RI_REPORT_SIZE(8, 0x08), \
HID_RI_INPUT(8, HID_IOF_CONSTANT), \
@ -420,7 +420,7 @@
HID_RI_USAGE_MAXIMUM(8, 0x65), \
HID_RI_REPORT_COUNT(8, MaxKeys), \
HID_RI_REPORT_SIZE(8, 0x08), \
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), \
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), \
HID_RI_END_COLLECTION(0)
/** \hideinitializer
@ -460,7 +460,7 @@
HID_RI_LOGICAL_MAXIMUM(8, 0x01), \
HID_RI_REPORT_COUNT(8, Buttons), \
HID_RI_REPORT_SIZE(8, 0x01), \
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE), \
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
HID_RI_REPORT_COUNT(8, 0x01), \
HID_RI_REPORT_SIZE(8, (8 - (Buttons % 8))), \
HID_RI_INPUT(8, HID_IOF_CONSTANT), \
@ -473,9 +473,38 @@
HID_RI_PHYSICAL_MAXIMUM(16, MaxPhysicalVal), \
HID_RI_REPORT_COUNT(8, 0x02), \
HID_RI_REPORT_SIZE(8, (((((uint16_t)MinAxisVal > 0xFF) && ((uint16_t)MaxAxisVal < 0xFF)) ? 8 : 16))), \
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | (AbsoluteCoords ? HID_IOF_ABSOLUTE : HID_IOF_RELATIVE) | HID_IOF_NON_VOLATILE), \
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | (AbsoluteCoords ? HID_IOF_ABSOLUTE : HID_IOF_RELATIVE)), \
HID_RI_END_COLLECTION(0), \
HID_RI_END_COLLECTION(0)
/** \hideinitializer
* A list of HID report item array elements that describe a typical Vendor Defined byte array HID report descriptor,
* used for transporting abitrary data between the USB host and device via HID reports. The resulting report should be
* a uint8_t byte array of the specified length in both Device to Host (IN) and Host to Device (OUT) directions.
*
* \param[in] VendorPageNum Vendor Defined HID Usage Page index, ranging from 0x00 to 0xFF
* \param[in] CollectionUsage Vendor Usage for the encompasing report IN and OUT collection, ranging from 0x00 to 0xFF
* \param[in] DataINUsage Vendor Usage for the IN report data, ranging from 0x00 to 0xFF
* \param[in] DataOUTUsage Vendor Usage for the OUT report data, ranging from 0x00 to 0xFF
* \param[in] NumBytes Length of the data IN and OUT reports
*/
#define HID_DESCRIPTOR_VENDOR(VendorPageNum, CollectionUsage, DataINUsage, DataOUTUsage, NumBytes) \
HID_RI_USAGE_PAGE(16, (0xFF00 | VendorPageNum)), \
HID_RI_USAGE(8, CollectionUsage), \
HID_RI_COLLECTION(8, 0x01), \
HID_RI_USAGE(8, DataINUsage), \
HID_RI_LOGICAL_MINIMUM(8, 0x00), \
HID_RI_LOGICAL_MAXIMUM(8, 0xFF), \
HID_RI_REPORT_SIZE(8, 0x08), \
HID_RI_REPORT_COUNT(8, NumBytes), \
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
HID_RI_USAGE(8, DataOUTUsage), \
HID_RI_LOGICAL_MINIMUM(8, 0x00), \
HID_RI_LOGICAL_MAXIMUM(8, 0xFF), \
HID_RI_REPORT_SIZE(8, 0x08), \
HID_RI_REPORT_COUNT(8, NumBytes), \
HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), \
HID_RI_END_COLLECTION(0)
//@}
/* Type Defines: */

@ -96,6 +96,9 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
CurrStateTable--;
break;
case HID_RI_USAGE_PAGE(0):
if ((HIDReportItem & HID_RI_DATA_SIZE_MASK) == HID_RI_DATA_BITS_32)
CurrStateTable->Attributes.Usage.Page = (ReportItemData >> 16);
CurrStateTable->Attributes.Usage.Page = ReportItemData;
break;
case HID_RI_LOGICAL_MINIMUM(0):

@ -217,7 +217,7 @@
{
uint16_t BitOffset; /**< Bit offset in the IN, OUT or FEATURE report of the item. */
uint8_t ItemType; /**< Report item type, a value in \ref HID_ReportItemTypes_t. */
uint16_t ItemFlags; /**< Item data flags, such as constant/variable, etc. */
uint16_t ItemFlags; /**< Item data flags, a mask of HID_IOF_* constants. */
uint8_t ReportID; /**< Report ID this item belongs to, or 0x00 if device has only one report */
HID_CollectionPath_t* CollectionPath; /**< Collection path of the item. */

@ -63,10 +63,10 @@
#define HID_RI_DATA_BITS_32 0x03
#define HID_RI_DATA_BITS(DataBits) HID_RI_DATA_BITS_ ## DataBits
#define _HID_RI_ENCODE_0(Data) /* No Data */
#define _HID_RI_ENCODE_0(Data)
#define _HID_RI_ENCODE_8(Data) , (Data & 0xFF)
#define _HID_RI_ENCODE_16(Data) _HID_RI_ENCODE_8(Data >> 8) _HID_RI_ENCODE_8(Data)
#define _HID_RI_ENCODE_32(Data) _HID_RI_ENCODE_16(Data >> 16) _HID_RI_ENCODE_16(Data)
#define _HID_RI_ENCODE_16(Data) _HID_RI_ENCODE_8(Data) _HID_RI_ENCODE_8(Data >> 8)
#define _HID_RI_ENCODE_32(Data) _HID_RI_ENCODE_16(Data) _HID_RI_ENCODE_16(Data >> 16)
#define _HID_RI_ENCODE(DataBits, ...) _HID_RI_ENCODE_ ## DataBits(__VA_ARGS__)
#define _HID_RI_ENTRY(Type, Tag, DataBits, ...) \

@ -320,7 +320,7 @@
* This event is time-critical; it is run once per millisecond and thus long handlers will significantly
* degrade device performance. This event should only be enabled when needed to reduce device wake-ups.
*
* \note This event is not normally active - it must be manually enabled and disabled via the
* \pre This event is not normally active - it must be manually enabled and disabled via the
* \ref USB_Device_EnableSOFEvents() and \ref USB_Device_DisableSOFEvents() commands after enumeration.
* \n\n
*

@ -60,9 +60,9 @@
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
#define USB_INT_Enable(int) do { USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); } while(0)
#define USB_INT_Disable(int) do { USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); } while(0)
#define USB_INT_Clear(int) do { USB_INT_GET_INT_REG(int) &= ~(USB_INT_GET_INT_MASK(int)); } while(0)
#define USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE
#define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE
#define USB_INT_Clear(int) MACROS{ USB_INT_GET_INT_REG(int) &= ~(USB_INT_GET_INT_MASK(int)); }MACROE
#define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false)
#define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false)

@ -18,8 +18,8 @@
* - Added new Endpoint_Null_Stream() and Pipe_Null_stream() functions
* - Added new ADC_GET_CHANNEL_MASK() convenience macro
* - Added new HID report item macros (with HID_RI_ prefix) to allow for easy creation and editing of HID report descriptors
* - Added new HID_DESCRIPTOR_MOUSE, HID_DESCRIPTOR_KEYBOARD and HID_DESCRIPTOR_JOYSTICK macros for easy automatic creation of
* basic USB HID device reports
* - Added new HID_DESCRIPTOR_MOUSE, HID_DESCRIPTOR_KEYBOARD, HID_DESCRIPTOR_JOYSTICK and HID_DESCRIPTOR_VENDOR macros
* for easy automatic creation of basic USB HID device reports
* - Added new MAX() and MIN() convenience macros
* - Library Applications:
* - Added ability to write protect Mass Storage disk write operations from the host OS
@ -39,6 +39,7 @@
* - The NO_STREAM_CALLBACKS compile time option has now been removed due to the new partial stream transfer feature
* - Changed over all project and demo HID report descriptors to use the new HID report item macros
* - Moved the HIDParser.c source file to the LUFA/Drivers/USB/Class/Common/ directory from the LUFA/Drivers/USB/Class/Host/
* - Added support to the HID parser for extended USAGE items that contain the usage page as well as the usage index
* - Library Applications:
* - Changed the XPLAINBridge software UART to use the regular timer CTC mode instead of the alternative CTC mode
* via the Input Capture register, to reduce user confusion

@ -106,6 +106,9 @@ int main(void)
/* Check if the millisecond timer has elapsed */
if (TIFR0 & (1 << OCF0A))
{
/* Clear flush timer expiry flag */
TIFR0 |= (1 << TOV0);
/* Check if the reset pulse period has elapsed, if so tristate the target reset line */
if (PulseMSRemaining.ResetPulse && !(--PulseMSRemaining.ResetPulse))
{
@ -132,9 +135,16 @@ int main(void)
uint16_t BufferCount = RingBuffer_GetCount(&USARTtoUSB_Buffer);
if (!(--FlushPeriodRemaining) || (BufferCount > 200))
{
/* Echo bytes from the target to the host via the virtual serial port */
FlushPeriodRemaining = RECEIVE_BUFFER_FLUSH_MS;
/* Start RX LED indicator pulse */
if (BufferCount)
{
LEDs_TurnOnLEDs(LEDMASK_RX);
PulseMSRemaining.RxLEDPulse = TX_RX_LED_PULSE_MS;
}
/* Echo bytes from the target to the host via the virtual serial port */
while (BufferCount--)
{
/* Try to send the next byte of data to the host, abort if there is an error without dequeuing */
@ -147,16 +157,7 @@ int main(void)
/* Dequeue the already sent byte from the buffer now we have confirmed that no transmission error occurred */
RingBuffer_Remove(&USARTtoUSB_Buffer);
}
LEDs_TurnOnLEDs(LEDMASK_RX);
PulseMSRemaining.RxLEDPulse = TX_RX_LED_PULSE_MS;
}
FlushPeriodRemaining = RECEIVE_BUFFER_FLUSH_MS;
}
/* Clear the millisecond timer CTC flag (cleared by writing logic one to the register) */
TIFR0 |= (1 << OCF0A);
}
CDC_Device_USBTask(&VirtualSerial_CDC_Interface);

@ -131,7 +131,7 @@ LUFA_OPTS += -D AVR_RESET_LINE_MASK="(1 << 4)"
LUFA_OPTS += -D AVR_RESET_PULSE_MS=10
LUFA_OPTS += -D TX_RX_LED_PULSE_MS=30
LUFA_OPTS += -D PING_PONG_LED_PULSE_MS=100
LUFA_OPTS += -D RECEIVE_BUFFER_FLUSH_MS=20
LUFA_OPTS += -D RECEIVE_BUFFER_FLUSH_MS=10
# Create the LUFA source path variables by including the LUFA root makefile

@ -46,38 +46,10 @@
*/
USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
{
HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
HID_RI_USAGE(8, 0x06), /* Keyboard */
HID_RI_COLLECTION(8, 0x01), /* Application */
HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */
HID_RI_USAGE_MINIMUM(8, 0xE0), /* Keyboard Left Control */
HID_RI_USAGE_MAXIMUM(8, 0xE7), /* Keyboard Right GUI */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_REPORT_COUNT(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_CONSTANT),
HID_RI_USAGE_PAGE(8, 0x08), /* LEDs */
HID_RI_USAGE_MINIMUM(8, 0x01), /* Num Lock */
HID_RI_USAGE_MAXIMUM(8, 0x05), /* Kana */
HID_RI_REPORT_COUNT(8, 0x05),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x03),
HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0x65),
HID_RI_USAGE_PAGE(8, 0x07), /* Keyboard */
HID_RI_USAGE_MINIMUM(8, 0x00), /* Reserved (no event indicated) */
HID_RI_USAGE_MAXIMUM(8, 0x65), /* Keyboard Application */
HID_RI_REPORT_COUNT(8, 0x06),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_END_COLLECTION(0),
/* Use the HID class driver's standard Keyboard report.
* Max simultaneous keys: 6
*/
HID_DESCRIPTOR_KEYBOARD(6)
};
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

@ -219,6 +219,6 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
const void* ReportData,
const uint16_t ReportSize)
{
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
// Ignore keyboard LED reports from the host, but still need to declare the callback routine
}

@ -57,22 +57,14 @@
*/
USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] =
{
HID_RI_USAGE_PAGE(16, 0x00FF), /* Vendor Page 1 */
HID_RI_USAGE(8, 0x01), /* Vendor Usage 1 */
HID_RI_COLLECTION(8, 0x01), /* Vendor Usage 1 */
HID_RI_USAGE(8, 0x02), /* Vendor Usage 2 */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_REPORT_COUNT(8, GENERIC_REPORT_SIZE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
HID_RI_USAGE(8, 0x03), /* Vendor Usage 3 */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_REPORT_COUNT(8, GENERIC_REPORT_SIZE),
HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
HID_RI_END_COLLECTION(0),
/* Use the HID class driver's standard Joystick report.
* Vendor Usage Page: 1
* Vendor Collection Usage: 1
* Vendor Report IN Usage: 2
* Vendor Report OUT Usage: 3
* Vendor Report Size: GENERIC_REPORT_SIZE
*/
HID_DESCRIPTOR_VENDOR(0x00, 0x01, 0x02, 0x03, GENERIC_REPORT_SIZE)
};
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall

Loading…
Cancel
Save