]> git.sur5r.net Git - armstart-ibdap/blobdiff - inc/usbd/usbd_hid.h
initial commit
[armstart-ibdap] / inc / usbd / usbd_hid.h
diff --git a/inc/usbd/usbd_hid.h b/inc/usbd/usbd_hid.h
new file mode 100644 (file)
index 0000000..5d801ac
--- /dev/null
@@ -0,0 +1,430 @@
+/***********************************************************************\r
+* $Id: mw_usbd_hid.h.rca 1.2 Tue Nov  1 11:45:07 2011 nlv09221 Experimental $\r
+*\r
+* Project: USB device ROM Stack\r
+*\r
+* Description:\r
+*     HID Definitions.\r
+*\r
+***********************************************************************\r
+*   Copyright(C) 2011, NXP Semiconductor\r
+*   All rights reserved.\r
+*\r
+* Software that is described herein is for illustrative purposes only\r
+* which provides customers with programming information regarding the\r
+* products. This software is supplied "AS IS" without any warranties.\r
+* NXP Semiconductors assumes no responsibility or liability for the\r
+* use of the software, conveys no license or title under any patent,\r
+* copyright, or mask work right to the product. NXP Semiconductors\r
+* reserves the right to make changes in the software without\r
+* notification. NXP Semiconductors also make no representation or\r
+* warranty that such application will be suitable for the specified\r
+* use without further testing or modification.\r
+**********************************************************************/\r
+#ifndef __HID_H__\r
+#define __HID_H__\r
+\r
+#include "usbd.h"\r
+\r
+/** \file\r
+ *  \brief Common definitions and declarations for the library USB HID Class driver.\r
+ *\r
+ *  Common definitions and declarations for the library USB HID Class driver.\r
+ *  \addtogroup USBD_HID \r
+ *  @{\r
+ */\r
+\r
+\r
+/** HID Subclass Codes  \r
+ * @{ \r
+ */\r
+/** Descriptor Subclass value indicating that the device or interface does not implement a HID boot protocol. */\r
+#define HID_SUBCLASS_NONE               0x00\r
+/** Descriptor Subclass value indicating that the device or interface implements a HID boot protocol. */\r
+#define HID_SUBCLASS_BOOT               0x01\r
+/** @} */\r
+\r
+/** HID Protocol Codes \r
+ * @{ \r
+ */\r
+/** Descriptor Protocol value indicating that the device or interface does not belong to a HID boot protocol. */\r
+#define HID_PROTOCOL_NONE               0x00\r
+/** Descriptor Protocol value indicating that the device or interface belongs to the Keyboard HID boot protocol. */\r
+#define HID_PROTOCOL_KEYBOARD           0x01\r
+/** Descriptor Protocol value indicating that the device or interface belongs to the Mouse HID boot protocol. */\r
+#define HID_PROTOCOL_MOUSE              0x02\r
+/** @} */\r
+\r
+\r
+\r
+/** Descriptor Types  \r
+ * @{ \r
+ */\r
+/** Descriptor header type value, to indicate a HID class HID descriptor. */\r
+#define HID_HID_DESCRIPTOR_TYPE         0x21\r
+/** Descriptor header type value, to indicate a HID class HID report descriptor. */\r
+#define HID_REPORT_DESCRIPTOR_TYPE      0x22\r
+/** Descriptor header type value, to indicate a HID class HID Physical descriptor. */\r
+#define HID_PHYSICAL_DESCRIPTOR_TYPE    0x23\r
+/** @} */\r
+\r
+\r
+/** \brief HID class-specific HID Descriptor.\r
+ *\r
+ *  Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID\r
+ *  specification for details on the structure elements.\r
+ *\r
+ */\r
+PRE_PACK struct POST_PACK _HID_DESCRIPTOR {\r
+  uint8_t  bLength;    /**< Size of the descriptor, in bytes. */\r
+  uint8_t  bDescriptorType;    /**< Type of HID descriptor. */\r
+  uint16_t bcdHID; /**< BCD encoded version that the HID descriptor and device complies to. */\r
+  uint8_t  bCountryCode; /**< Country code of the localized device, or zero if universal. */\r
+  uint8_t  bNumDescriptors; /**< Total number of HID report descriptors for the interface. */\r
+  \r
+  PRE_PACK struct POST_PACK _HID_DESCRIPTOR_LIST {\r
+    uint8_t  bDescriptorType; /**< Type of HID report. */\r
+    uint16_t wDescriptorLength; /**< Length of the associated HID report descriptor, in bytes. */\r
+  } DescriptorList[1]; /**< Array of one or more descriptors */\r
+} ;\r
+/** HID class-specific HID Descriptor. */\r
+typedef struct _HID_DESCRIPTOR HID_DESCRIPTOR;\r
+\r
+#define HID_DESC_SIZE   sizeof(HID_DESCRIPTOR)\r
+\r
+/** HID Request Codes  \r
+ * @{ \r
+ */\r
+#define HID_REQUEST_GET_REPORT          0x01\r
+#define HID_REQUEST_GET_IDLE            0x02\r
+#define HID_REQUEST_GET_PROTOCOL        0x03\r
+#define HID_REQUEST_SET_REPORT          0x09\r
+#define HID_REQUEST_SET_IDLE            0x0A\r
+#define HID_REQUEST_SET_PROTOCOL        0x0B\r
+/** @} */\r
+\r
+/** HID Report Types  \r
+ * @{ \r
+ */\r
+#define HID_REPORT_INPUT                0x01\r
+#define HID_REPORT_OUTPUT               0x02\r
+#define HID_REPORT_FEATURE              0x03\r
+/** @} */\r
+\r
+\r
+/** Usage Pages  \r
+ * @{ \r
+ */\r
+#define HID_USAGE_PAGE_UNDEFINED        0x00\r
+#define HID_USAGE_PAGE_GENERIC          0x01\r
+#define HID_USAGE_PAGE_SIMULATION       0x02\r
+#define HID_USAGE_PAGE_VR               0x03\r
+#define HID_USAGE_PAGE_SPORT            0x04\r
+#define HID_USAGE_PAGE_GAME             0x05\r
+#define HID_USAGE_PAGE_DEV_CONTROLS     0x06\r
+#define HID_USAGE_PAGE_KEYBOARD         0x07\r
+#define HID_USAGE_PAGE_LED              0x08\r
+#define HID_USAGE_PAGE_BUTTON           0x09\r
+#define HID_USAGE_PAGE_ORDINAL          0x0A\r
+#define HID_USAGE_PAGE_TELEPHONY        0x0B\r
+#define HID_USAGE_PAGE_CONSUMER         0x0C\r
+#define HID_USAGE_PAGE_DIGITIZER        0x0D\r
+#define HID_USAGE_PAGE_UNICODE          0x10\r
+#define HID_USAGE_PAGE_ALPHANUMERIC     0x14\r
+/** @} */\r
+\r
+\r
+/** Generic Desktop Page (0x01)  \r
+ * @{ \r
+ */\r
+#define HID_USAGE_GENERIC_POINTER               0x01\r
+#define HID_USAGE_GENERIC_MOUSE                 0x02\r
+#define HID_USAGE_GENERIC_JOYSTICK              0x04\r
+#define HID_USAGE_GENERIC_GAMEPAD               0x05\r
+#define HID_USAGE_GENERIC_KEYBOARD              0x06\r
+#define HID_USAGE_GENERIC_KEYPAD                0x07\r
+#define HID_USAGE_GENERIC_X                     0x30\r
+#define HID_USAGE_GENERIC_Y                     0x31\r
+#define HID_USAGE_GENERIC_Z                     0x32\r
+#define HID_USAGE_GENERIC_RX                    0x33\r
+#define HID_USAGE_GENERIC_RY                    0x34\r
+#define HID_USAGE_GENERIC_RZ                    0x35\r
+#define HID_USAGE_GENERIC_SLIDER                0x36\r
+#define HID_USAGE_GENERIC_DIAL                  0x37\r
+#define HID_USAGE_GENERIC_WHEEL                 0x38\r
+#define HID_USAGE_GENERIC_HATSWITCH             0x39\r
+#define HID_USAGE_GENERIC_COUNTED_BUFFER        0x3A\r
+#define HID_USAGE_GENERIC_BYTE_COUNT            0x3B\r
+#define HID_USAGE_GENERIC_MOTION_WAKEUP         0x3C\r
+#define HID_USAGE_GENERIC_VX                    0x40\r
+#define HID_USAGE_GENERIC_VY                    0x41\r
+#define HID_USAGE_GENERIC_VZ                    0x42\r
+#define HID_USAGE_GENERIC_VBRX                  0x43\r
+#define HID_USAGE_GENERIC_VBRY                  0x44\r
+#define HID_USAGE_GENERIC_VBRZ                  0x45\r
+#define HID_USAGE_GENERIC_VNO                   0x46\r
+#define HID_USAGE_GENERIC_SYSTEM_CTL            0x80\r
+#define HID_USAGE_GENERIC_SYSCTL_POWER          0x81\r
+#define HID_USAGE_GENERIC_SYSCTL_SLEEP          0x82\r
+#define HID_USAGE_GENERIC_SYSCTL_WAKE           0x83\r
+#define HID_USAGE_GENERIC_SYSCTL_CONTEXT_MENU   0x84\r
+#define HID_USAGE_GENERIC_SYSCTL_MAIN_MENU      0x85\r
+#define HID_USAGE_GENERIC_SYSCTL_APP_MENU       0x86\r
+#define HID_USAGE_GENERIC_SYSCTL_HELP_MENU      0x87\r
+#define HID_USAGE_GENERIC_SYSCTL_MENU_EXIT      0x88\r
+#define HID_USAGE_GENERIC_SYSCTL_MENU_SELECT    0x89\r
+#define HID_USAGE_GENERIC_SYSCTL_MENU_RIGHT     0x8A\r
+#define HID_USAGE_GENERIC_SYSCTL_MENU_LEFT      0x8B\r
+#define HID_USAGE_GENERIC_SYSCTL_MENU_UP        0x8C\r
+#define HID_USAGE_GENERIC_SYSCTL_MENU_DOWN      0x8D\r
+/** @} */\r
+\r
+/** Simulation Controls Page (0x02)  \r
+ * @{ \r
+ */\r
+#define HID_USAGE_SIMULATION_RUDDER             0xBA\r
+#define HID_USAGE_SIMULATION_THROTTLE           0xBB\r
+/** @} */\r
+\r
+/* Virtual Reality Controls Page (0x03) */\r
+/* ... */\r
+\r
+/* Sport Controls Page (0x04) */\r
+/* ... */\r
+\r
+/* Game Controls Page (0x05) */\r
+/* ... */\r
+\r
+/* Generic Device Controls Page (0x06) */\r
+/* ... */\r
+\r
+/** Keyboard/Keypad Page (0x07)  \r
+ * @{ \r
+ */\r
+/** Error "keys" */\r
+#define HID_USAGE_KEYBOARD_NOEVENT              0x00\r
+#define HID_USAGE_KEYBOARD_ROLLOVER             0x01\r
+#define HID_USAGE_KEYBOARD_POSTFAIL             0x02\r
+#define HID_USAGE_KEYBOARD_UNDEFINED            0x03\r
+\r
+/** Letters */\r
+#define HID_USAGE_KEYBOARD_aA                   0x04\r
+#define HID_USAGE_KEYBOARD_zZ                   0x1D\r
+\r
+/** Numbers */\r
+#define HID_USAGE_KEYBOARD_ONE                  0x1E\r
+#define HID_USAGE_KEYBOARD_ZERO                 0x27\r
+\r
+#define HID_USAGE_KEYBOARD_RETURN               0x28\r
+#define HID_USAGE_KEYBOARD_ESCAPE               0x29\r
+#define HID_USAGE_KEYBOARD_DELETE               0x2A\r
+\r
+/** Funtion keys */\r
+#define HID_USAGE_KEYBOARD_F1                   0x3A\r
+#define HID_USAGE_KEYBOARD_F12                  0x45\r
+\r
+#define HID_USAGE_KEYBOARD_PRINT_SCREEN         0x46\r
+\r
+/** Modifier Keys */\r
+#define HID_USAGE_KEYBOARD_LCTRL                0xE0\r
+#define HID_USAGE_KEYBOARD_LSHFT                0xE1\r
+#define HID_USAGE_KEYBOARD_LALT                 0xE2\r
+#define HID_USAGE_KEYBOARD_LGUI                 0xE3\r
+#define HID_USAGE_KEYBOARD_RCTRL                0xE4\r
+#define HID_USAGE_KEYBOARD_RSHFT                0xE5\r
+#define HID_USAGE_KEYBOARD_RALT                 0xE6\r
+#define HID_USAGE_KEYBOARD_RGUI                 0xE7\r
+#define HID_USAGE_KEYBOARD_SCROLL_LOCK          0x47\r
+#define HID_USAGE_KEYBOARD_NUM_LOCK             0x53\r
+#define HID_USAGE_KEYBOARD_CAPS_LOCK            0x39\r
+/** @} */\r
+\r
+/* ... */\r
+\r
+/** LED Page (0x08)  \r
+ * @{ \r
+ */\r
+#define HID_USAGE_LED_NUM_LOCK                  0x01\r
+#define HID_USAGE_LED_CAPS_LOCK                 0x02\r
+#define HID_USAGE_LED_SCROLL_LOCK               0x03\r
+#define HID_USAGE_LED_COMPOSE                   0x04\r
+#define HID_USAGE_LED_KANA                      0x05\r
+#define HID_USAGE_LED_POWER                     0x06\r
+#define HID_USAGE_LED_SHIFT                     0x07\r
+#define HID_USAGE_LED_DO_NOT_DISTURB            0x08\r
+#define HID_USAGE_LED_MUTE                      0x09\r
+#define HID_USAGE_LED_TONE_ENABLE               0x0A\r
+#define HID_USAGE_LED_HIGH_CUT_FILTER           0x0B\r
+#define HID_USAGE_LED_LOW_CUT_FILTER            0x0C\r
+#define HID_USAGE_LED_EQUALIZER_ENABLE          0x0D\r
+#define HID_USAGE_LED_SOUND_FIELD_ON            0x0E\r
+#define HID_USAGE_LED_SURROUND_FIELD_ON         0x0F\r
+#define HID_USAGE_LED_REPEAT                    0x10\r
+#define HID_USAGE_LED_STEREO                    0x11\r
+#define HID_USAGE_LED_SAMPLING_RATE_DETECT      0x12\r
+#define HID_USAGE_LED_SPINNING                  0x13\r
+#define HID_USAGE_LED_CAV                       0x14\r
+#define HID_USAGE_LED_CLV                       0x15\r
+#define HID_USAGE_LED_RECORDING_FORMAT_DET      0x16\r
+#define HID_USAGE_LED_OFF_HOOK                  0x17\r
+#define HID_USAGE_LED_RING                      0x18\r
+#define HID_USAGE_LED_MESSAGE_WAITING           0x19\r
+#define HID_USAGE_LED_DATA_MODE                 0x1A\r
+#define HID_USAGE_LED_BATTERY_OPERATION         0x1B\r
+#define HID_USAGE_LED_BATTERY_OK                0x1C\r
+#define HID_USAGE_LED_BATTERY_LOW               0x1D\r
+#define HID_USAGE_LED_SPEAKER                   0x1E\r
+#define HID_USAGE_LED_HEAD_SET                  0x1F\r
+#define HID_USAGE_LED_HOLD                      0x20\r
+#define HID_USAGE_LED_MICROPHONE                0x21\r
+#define HID_USAGE_LED_COVERAGE                  0x22\r
+#define HID_USAGE_LED_NIGHT_MODE                0x23\r
+#define HID_USAGE_LED_SEND_CALLS                0x24\r
+#define HID_USAGE_LED_CALL_PICKUP               0x25\r
+#define HID_USAGE_LED_CONFERENCE                0x26\r
+#define HID_USAGE_LED_STAND_BY                  0x27\r
+#define HID_USAGE_LED_CAMERA_ON                 0x28\r
+#define HID_USAGE_LED_CAMERA_OFF                0x29\r
+#define HID_USAGE_LED_ON_LINE                   0x2A\r
+#define HID_USAGE_LED_OFF_LINE                  0x2B\r
+#define HID_USAGE_LED_BUSY                      0x2C\r
+#define HID_USAGE_LED_READY                     0x2D\r
+#define HID_USAGE_LED_PAPER_OUT                 0x2E\r
+#define HID_USAGE_LED_PAPER_JAM                 0x2F\r
+#define HID_USAGE_LED_REMOTE                    0x30\r
+#define HID_USAGE_LED_FORWARD                   0x31\r
+#define HID_USAGE_LED_REVERSE                   0x32\r
+#define HID_USAGE_LED_STOP                      0x33\r
+#define HID_USAGE_LED_REWIND                    0x34\r
+#define HID_USAGE_LED_FAST_FORWARD              0x35\r
+#define HID_USAGE_LED_PLAY                      0x36\r
+#define HID_USAGE_LED_PAUSE                     0x37\r
+#define HID_USAGE_LED_RECORD                    0x38\r
+#define HID_USAGE_LED_ERROR                     0x39\r
+#define HID_USAGE_LED_SELECTED_INDICATOR        0x3A\r
+#define HID_USAGE_LED_IN_USE_INDICATOR          0x3B\r
+#define HID_USAGE_LED_MULTI_MODE_INDICATOR      0x3C\r
+#define HID_USAGE_LED_INDICATOR_ON              0x3D\r
+#define HID_USAGE_LED_INDICATOR_FLASH           0x3E\r
+#define HID_USAGE_LED_INDICATOR_SLOW_BLINK      0x3F\r
+#define HID_USAGE_LED_INDICATOR_FAST_BLINK      0x40\r
+#define HID_USAGE_LED_INDICATOR_OFF             0x41\r
+#define HID_USAGE_LED_FLASH_ON_TIME             0x42\r
+#define HID_USAGE_LED_SLOW_BLINK_ON_TIME        0x43\r
+#define HID_USAGE_LED_SLOW_BLINK_OFF_TIME       0x44\r
+#define HID_USAGE_LED_FAST_BLINK_ON_TIME        0x45\r
+#define HID_USAGE_LED_FAST_BLINK_OFF_TIME       0x46\r
+#define HID_USAGE_LED_INDICATOR_COLOR           0x47\r
+#define HID_USAGE_LED_RED                       0x48\r
+#define HID_USAGE_LED_GREEN                     0x49\r
+#define HID_USAGE_LED_AMBER                     0x4A\r
+#define HID_USAGE_LED_GENERIC_INDICATOR         0x4B\r
+/** @} */\r
+\r
+/*  Button Page (0x09)  \r
+ */\r
+/*   There is no need to label these usages. */\r
+\r
+/*  Ordinal Page (0x0A)  \r
+ */\r
+/*   There is no need to label these usages. */\r
+\r
+/** Telephony Device Page (0x0B)  \r
+ * @{ \r
+ */\r
+#define HID_USAGE_TELEPHONY_PHONE               0x01\r
+#define HID_USAGE_TELEPHONY_ANSWERING_MACHINE   0x02\r
+#define HID_USAGE_TELEPHONY_MESSAGE_CONTROLS    0x03\r
+#define HID_USAGE_TELEPHONY_HANDSET             0x04\r
+#define HID_USAGE_TELEPHONY_HEADSET             0x05\r
+#define HID_USAGE_TELEPHONY_KEYPAD              0x06\r
+#define HID_USAGE_TELEPHONY_PROGRAMMABLE_BUTTON 0x07\r
+/** @} */\r
+/* ... */\r
+\r
+/** Consumer Page (0x0C)  \r
+ * @{ \r
+ */\r
+#define HID_USAGE_CONSUMER_CONTROL              0x01\r
+#define HID_USAGE_CONSUMER_FAST_FORWARD       0xB3\r
+#define HID_USAGE_CONSUMER_REWIND             0xB4\r
+#define HID_USAGE_CONSUMER_PLAY_PAUSE                      0xCD\r
+#define HID_USAGE_CONSUMER_VOLUME_INCREMENT            0xE9\r
+#define HID_USAGE_CONSUMER_VOLUME_DECREMENT            0xEA\r
+/** @} */\r
+/* ... */\r
+\r
+/* and others ... */\r
+\r
+\r
+/** HID Report Item Macros  \r
+ * @{ \r
+ */\r
+/** Main Items */\r
+#define HID_Input(x)           0x81,x\r
+#define HID_Output(x)          0x91,x\r
+#define HID_Feature(x)         0xB1,x\r
+#define HID_Collection(x)      0xA1,x\r
+#define HID_EndCollection      0xC0\r
+\r
+/** Data (Input, Output, Feature) */\r
+#define HID_Data               0<<0\r
+#define HID_Constant           1<<0\r
+#define HID_Array              0<<1\r
+#define HID_Variable           1<<1\r
+#define HID_Absolute           0<<2\r
+#define HID_Relative           1<<2\r
+#define HID_NoWrap             0<<3\r
+#define HID_Wrap               1<<3\r
+#define HID_Linear             0<<4\r
+#define HID_NonLinear          1<<4\r
+#define HID_PreferredState     0<<5\r
+#define HID_NoPreferred        1<<5\r
+#define HID_NoNullPosition     0<<6\r
+#define HID_NullState          1<<6\r
+#define HID_NonVolatile        0<<7\r
+#define HID_Volatile           1<<7\r
+\r
+/** Collection Data */\r
+#define HID_Physical           0x00\r
+#define HID_Application        0x01\r
+#define HID_Logical            0x02\r
+#define HID_Report             0x03\r
+#define HID_NamedArray         0x04\r
+#define HID_UsageSwitch        0x05\r
+#define HID_UsageModifier      0x06\r
+\r
+/** Global Items */\r
+#define HID_UsagePage(x)       0x05,x\r
+#define HID_UsagePageVendor(x) 0x06,x,0xFF\r
+#define HID_LogicalMin(x)      0x15,x\r
+#define HID_LogicalMinS(x)     0x16,(x&0xFF),((x>>8)&0xFF)\r
+#define HID_LogicalMinL(x)     0x17,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)\r
+#define HID_LogicalMax(x)      0x25,x\r
+#define HID_LogicalMaxS(x)     0x26,(x&0xFF),((x>>8)&0xFF)\r
+#define HID_LogicalMaxL(x)     0x27,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)\r
+#define HID_PhysicalMin(x)     0x35,x\r
+#define HID_PhysicalMinS(x)    0x36,(x&0xFF),((x>>8)&0xFF)\r
+#define HID_PhysicalMinL(x)    0x37,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)\r
+#define HID_PhysicalMax(x)     0x45,x\r
+#define HID_PhysicalMaxS(x)    0x46,(x&0xFF),((x>>8)&0xFF)\r
+#define HID_PhysicalMaxL(x)    0x47,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)\r
+#define HID_UnitExponent(x)    0x55,x\r
+#define HID_Unit(x)            0x65,x\r
+#define HID_UnitS(x)           0x66,(x&0xFF),((x>>8)&0xFF)\r
+#define HID_UnitL(x)           0x67,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)\r
+#define HID_ReportSize(x)      0x75,x\r
+#define HID_ReportID(x)        0x85,x\r
+#define HID_ReportCount(x)     0x95,x\r
+#define HID_Push               0xA0\r
+#define HID_Pop                0xB0\r
+\r
+/** Local Items */\r
+#define HID_Usage(x)           0x09,x\r
+#define HID_UsageMin(x)        0x19,x\r
+#define HID_UsageMax(x)        0x29,x\r
+/** @} */\r
+\r
+/** @} */\r
+\r
+#endif  /* __HID_H__ */\r