Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
HID.h
00001 00002 #ifndef HID_H 00003 #define HID_H 00004 00005 #include "USBHost.h" 00006 00007 #ifndef u8 00008 typedef unsigned char u8; 00009 typedef unsigned short u16; 00010 typedef unsigned long u32; 00011 00012 typedef char s8; 00013 typedef short s16; 00014 typedef char s32; 00015 #endif 00016 00017 00018 00019 00020 enum mode{ INPUT=0x81, OUTPUT=0x91, FEATURE=0xB1}; 00021 00022 typedef struct 00023 { 00024 u8 Usage; 00025 u8 LocalMinimun; 00026 u16 LocalMaximun; 00027 u8 ReportCount; 00028 u8 ReportSize; 00029 mode coll_mode; //INPUT/OUTPUT//FEATURE. 00030 u8 mode_value; 00031 }Report; 00032 00033 typedef struct 00034 { 00035 u8 numberofreports; 00036 Report* pFirstReport; 00037 //All the reports must be allocated in an array 00038 //so they can be accessed easily. 00039 }Collection; 00040 00041 /////////////////////////////////////////////////////////////////////// 00042 00043 00044 00045 /* 00046 * Constants 00047 */ 00048 #define PATH_SIZE 10 00049 #define USAGE_TAB_SIZE 50 00050 #define MAX_REPORT 300 00051 #define REPORT_DSC_SIZE 6144 00052 00053 #define SIZE_0 0x00 00054 #define SIZE_1 0x01 00055 #define SIZE_2 0x02 00056 #define SIZE_4 0x03 00057 #define SIZE_MASK 0x03 00058 00059 00060 #define TYPE_MAIN 0x00 00061 #define TYPE_GLOBAL 0x04 00062 #define TYPE_LOCAL 0x08 00063 #define TYPE_MASK 0x0C 00064 00065 /* Main items */ 00066 #define ITEM_COLLECTION 0xA0 00067 #define ITEM_END_COLLECTION 0xC0 00068 #define ITEM_FEATURE 0xB0 00069 #define ITEM_INPUT 0x80 00070 #define ITEM_OUTPUT 0x90 00071 00072 00073 /* Global items */ 00074 #define ITEM_UPAGE 0x04 00075 #define ITEM_LOG_MIN 0x14 00076 #define ITEM_LOG_MAX 0x24 00077 #define ITEM_PHY_MIN 0x34 00078 #define ITEM_PHY_MAX 0x44 00079 #define ITEM_UNIT_EXP 0x54 00080 #define ITEM_UNIT 0x64 00081 #define ITEM_REP_SIZE 0x74 00082 #define ITEM_REP_ID 0x84 00083 #define ITEM_REP_COUNT 0x94 00084 00085 /* Local items */ 00086 #define ITEM_USAGE 0x08 00087 #define ITEM_STRING 0x78 00088 00089 /* Long item */ 00090 #define ITEM_LONG 0xFC 00091 00092 #define ITEM_MASK 0xFC 00093 00094 /* Attribute Flags */ 00095 #define ATTR_DATA_CST 0x01 00096 #define ATTR_NVOL_VOL 0x80 00097 00098 00099 00100 typedef struct 00101 { 00102 u8 UPage; 00103 u8 Usage; 00104 }HIDNode; 00105 00106 typedef struct 00107 { 00108 u8 Size; 00109 HIDNode Node[PATH_SIZE]; 00110 }HIDPath; 00111 00112 00113 typedef struct 00114 { 00115 u32 Value; 00116 HIDPath Path; 00117 u8 ReportID; 00118 u8 Offset; 00119 u8 Size; 00120 u8 Type; 00121 u8 Attribute; 00122 u32 Unit; 00123 u8 UnitExp; 00124 u32 LogMin; 00125 u32 LogMax; 00126 u32 PhyMin; 00127 u32 PhyMax; 00128 } HIDData; 00129 00130 typedef struct 00131 { 00132 u8 ReportDesc[REPORT_DSC_SIZE]; 00133 u8 ReportDescSize; 00134 u8 Pos; 00135 u8 Item; 00136 u32 Value; 00137 HIDData Data; 00138 u8 OffsetTab[MAX_REPORT][3]; 00139 u8 ReportCount; 00140 u8 Count; 00141 u8 UPage; 00142 HIDNode UsageTab[USAGE_TAB_SIZE]; 00143 u8 UsageSize; 00144 u8 nObject; 00145 u8 nReport; 00146 } HIDParser; 00147 00148 00149 00150 int HIDParse(HIDParser* pParser,HIDData* pData); 00151 void ResetParser(HIDParser* pParser); 00152 int FindObject(HIDParser* pParser, HIDData* pData); 00153 void GetValue(const u8* Buff, HIDData* pData); 00154 void SetValue(const HIDData* pData, u8* Buf); 00155 u8* GetReportOffset(HIDParser* pParser, const u8 ReportID, const u8 ReportType); 00156 00157 00158 00159 00160 00161 00162 00163 00164 #endif
Generated on Thu Jul 14 2022 02:50:59 by
1.7.2