MG32F10x Standard Peripherals Firmware Library

USB_HID_KeyBoard/usb_hid_def.h
1 /* Define to prevent recursive inclusion -------------------------------------*/
2 #ifndef __USB_HID_DEF_H
3 #define __USB_HID_DEF_H
4
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8
9 /* Includes ------------------------------------------------------------------*/
10 /* Exported types ------------------------------------------------------------*/
11
12 /* Exported constants --------------------------------------------------------*/
13
14 /* HID Subclass Codes */
15 #define HID_SUBCLASS_NONE 0x00
16 #define HID_SUBCLASS_BOOT 0x01
17
18 /* HID Protocol Codes */
19 #define HID_PROTOCOL_NONE 0x00
20 #define HID_PROTOCOL_KEYBOARD 0x01
21 #define HID_PROTOCOL_MOUSE 0x02
22
23
24 /* HID Descriptor Types */
25 #define HID_HID_DESCRIPTOR_TYPE 0x21
26 #define HID_REPORT_DESCRIPTOR_TYPE 0x22
27 #define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23
28
29
30
31
32 /* HID Request Codes */
33 #define HID_REQUEST_GET_REPORT 0x01
34 #define HID_REQUEST_GET_IDLE 0x02
35 #define HID_REQUEST_GET_PROTOCOL 0x03
36 #define HID_REQUEST_SET_REPORT 0x09
37 #define HID_REQUEST_SET_IDLE 0x0A
38 #define HID_REQUEST_SET_PROTOCOL 0x0B
39
40 /* HID Report Types */
41 #define HID_REPORT_INPUT 0x01
42 #define HID_REPORT_OUTPUT 0x02
43 #define HID_REPORT_FEATURE 0x03
44
45
46 /* Usage Pages */
47 #define HID_USAGE_PAGE_UNDEFINED 0x00
48 #define HID_USAGE_PAGE_GENERIC 0x01
49 #define HID_USAGE_PAGE_SIMULATION 0x02
50 #define HID_USAGE_PAGE_VR 0x03
51 #define HID_USAGE_PAGE_SPORT 0x04
52 #define HID_USAGE_PAGE_GAME 0x05
53 #define HID_USAGE_PAGE_DEV_CONTROLS 0x06
54 #define HID_USAGE_PAGE_KEYBOARD 0x07
55 #define HID_USAGE_PAGE_LED 0x08
56 #define HID_USAGE_PAGE_BUTTON 0x09
57 #define HID_USAGE_PAGE_ORDINAL 0x0A
58 #define HID_USAGE_PAGE_TELEPHONY 0x0B
59 #define HID_USAGE_PAGE_CONSUMER 0x0C
60 #define HID_USAGE_PAGE_DIGITIZER 0x0D
61 #define HID_USAGE_PAGE_UNICODE 0x10
62 #define HID_USAGE_PAGE_ALPHANUMERIC 0x14
63 /* ... */
64
65
66 /* Generic Desktop Page (0x01) */
67 #define HID_USAGE_GENERIC_POINTER 0x01
68 #define HID_USAGE_GENERIC_MOUSE 0x02
69 #define HID_USAGE_GENERIC_JOYSTICK 0x04
70 #define HID_USAGE_GENERIC_GAMEPAD 0x05
71 #define HID_USAGE_GENERIC_KEYBOARD 0x06
72 #define HID_USAGE_GENERIC_KEYPAD 0x07
73 #define HID_USAGE_GENERIC_X 0x30
74 #define HID_USAGE_GENERIC_Y 0x31
75 #define HID_USAGE_GENERIC_Z 0x32
76 #define HID_USAGE_GENERIC_RX 0x33
77 #define HID_USAGE_GENERIC_RY 0x34
78 #define HID_USAGE_GENERIC_RZ 0x35
79 #define HID_USAGE_GENERIC_SLIDER 0x36
80 #define HID_USAGE_GENERIC_DIAL 0x37
81 #define HID_USAGE_GENERIC_WHEEL 0x38
82 #define HID_USAGE_GENERIC_HATSWITCH 0x39
83 #define HID_USAGE_GENERIC_COUNTED_BUFFER 0x3A
84 #define HID_USAGE_GENERIC_BYTE_COUNT 0x3B
85 #define HID_USAGE_GENERIC_MOTION_WAKEUP 0x3C
86 #define HID_USAGE_GENERIC_VX 0x40
87 #define HID_USAGE_GENERIC_VY 0x41
88 #define HID_USAGE_GENERIC_VZ 0x42
89 #define HID_USAGE_GENERIC_VBRX 0x43
90 #define HID_USAGE_GENERIC_VBRY 0x44
91 #define HID_USAGE_GENERIC_VBRZ 0x45
92 #define HID_USAGE_GENERIC_VNO 0x46
93 #define HID_USAGE_GENERIC_SYSTEM_CTL 0x80
94 #define HID_USAGE_GENERIC_SYSCTL_POWER 0x81
95 #define HID_USAGE_GENERIC_SYSCTL_SLEEP 0x82
96 #define HID_USAGE_GENERIC_SYSCTL_WAKE 0x83
97 #define HID_USAGE_GENERIC_SYSCTL_CONTEXT_MENU 0x84
98 #define HID_USAGE_GENERIC_SYSCTL_MAIN_MENU 0x85
99 #define HID_USAGE_GENERIC_SYSCTL_APP_MENU 0x86
100 #define HID_USAGE_GENERIC_SYSCTL_HELP_MENU 0x87
101 #define HID_USAGE_GENERIC_SYSCTL_MENU_EXIT 0x88
102 #define HID_USAGE_GENERIC_SYSCTL_MENU_SELECT 0x89
103 #define HID_USAGE_GENERIC_SYSCTL_MENU_RIGHT 0x8A
104 #define HID_USAGE_GENERIC_SYSCTL_MENU_LEFT 0x8B
105 #define HID_USAGE_GENERIC_SYSCTL_MENU_UP 0x8C
106 #define HID_USAGE_GENERIC_SYSCTL_MENU_DOWN 0x8D
107 /* ... */
108
109 /* Simulation Controls Page (0x02) */
110 /* ... */
111 #define HID_USAGE_SIMULATION_RUDDER 0xBA
112 #define HID_USAGE_SIMULATION_THROTTLE 0xBB
113 /* ... */
114
115 /* Virtual Reality Controls Page (0x03) */
116 /* ... */
117
118 /* Sport Controls Page (0x04) */
119 /* ... */
120
121 /* Game Controls Page (0x05) */
122 /* ... */
123
124 /* Generic Device Controls Page (0x06) */
125 /* ... */
126
127 /* Keyboard/Keypad Page (0x07) */
128 /* Error "Keys" */
129 #define HID_USAGE_KEYBOARD_NOEVENT 0x00
130 #define HID_USAGE_KEYBOARD_ROLLOVER 0x01
131 #define HID_USAGE_KEYBOARD_POSTFAIL 0x02
132 #define HID_USAGE_KEYBOARD_UNDEFINED 0x03
133
134 /* Letters */
135 #define HID_USAGE_KEYBOARD_aA 0x04
136 #define HID_USAGE_KEYBOARD_zZ 0x1D
137
138 /* Numbers */
139 #define HID_USAGE_KEYBOARD_ONE 0x1E
140 #define HID_USAGE_KEYBOARD_ZERO 0x27
141
142 #define HID_USAGE_KEYBOARD_RETURN 0x28
143 #define HID_USAGE_KEYBOARD_ESCAPE 0x29
144 #define HID_USAGE_KEYBOARD_DELETE 0x2A
145
146 /* Funtion Keys */
147 #define HID_USAGE_KEYBOARD_F1 0x3A
148 #define HID_USAGE_KEYBOARD_F12 0x45
149
150 #define HID_USAGE_KEYBOARD_PRINT_SCREEN 0x46
151
152 /* Modifier Keys */
153 #define HID_USAGE_KEYBOARD_LCTRL 0xE0
154 #define HID_USAGE_KEYBOARD_LSHFT 0xE1
155 #define HID_USAGE_KEYBOARD_LALT 0xE2
156 #define HID_USAGE_KEYBOARD_LGUI 0xE3
157 #define HID_USAGE_KEYBOARD_RCTRL 0xE4
158 #define HID_USAGE_KEYBOARD_RSHFT 0xE5
159 #define HID_USAGE_KEYBOARD_RALT 0xE6
160 #define HID_USAGE_KEYBOARD_RGUI 0xE7
161 #define HID_USAGE_KEYBOARD_SCROLL_LOCK 0x47
162 #define HID_USAGE_KEYBOARD_NUM_LOCK 0x53
163 #define HID_USAGE_KEYBOARD_CAPS_LOCK 0x39
164 /* ... */
165
166 /* LED Page (0x08) */
167 #define HID_USAGE_LED_NUM_LOCK 0x01
168 #define HID_USAGE_LED_CAPS_LOCK 0x02
169 #define HID_USAGE_LED_SCROLL_LOCK 0x03
170 #define HID_USAGE_LED_COMPOSE 0x04
171 #define HID_USAGE_LED_KANA 0x05
172 #define HID_USAGE_LED_POWER 0x06
173 #define HID_USAGE_LED_SHIFT 0x07
174 #define HID_USAGE_LED_DO_NOT_DISTURB 0x08
175 #define HID_USAGE_LED_MUTE 0x09
176 #define HID_USAGE_LED_TONE_ENABLE 0x0A
177 #define HID_USAGE_LED_HIGH_CUT_FILTER 0x0B
178 #define HID_USAGE_LED_LOW_CUT_FILTER 0x0C
179 #define HID_USAGE_LED_EQUALIZER_ENABLE 0x0D
180 #define HID_USAGE_LED_SOUND_FIELD_ON 0x0E
181 #define HID_USAGE_LED_SURROUND_FIELD_ON 0x0F
182 #define HID_USAGE_LED_REPEAT 0x10
183 #define HID_USAGE_LED_STEREO 0x11
184 #define HID_USAGE_LED_SAMPLING_RATE_DETECT 0x12
185 #define HID_USAGE_LED_SPINNING 0x13
186 #define HID_USAGE_LED_CAV 0x14
187 #define HID_USAGE_LED_CLV 0x15
188 #define HID_USAGE_LED_RECORDING_FORMAT_DET 0x16
189 #define HID_USAGE_LED_OFF_HOOK 0x17
190 #define HID_USAGE_LED_RING 0x18
191 #define HID_USAGE_LED_MESSAGE_WAITING 0x19
192 #define HID_USAGE_LED_DATA_MODE 0x1A
193 #define HID_USAGE_LED_BATTERY_OPERATION 0x1B
194 #define HID_USAGE_LED_BATTERY_OK 0x1C
195 #define HID_USAGE_LED_BATTERY_LOW 0x1D
196 #define HID_USAGE_LED_SPEAKER 0x1E
197 #define HID_USAGE_LED_HEAD_SET 0x1F
198 #define HID_USAGE_LED_HOLD 0x20
199 #define HID_USAGE_LED_MICROPHONE 0x21
200 #define HID_USAGE_LED_COVERAGE 0x22
201 #define HID_USAGE_LED_NIGHT_MODE 0x23
202 #define HID_USAGE_LED_SEND_CALLS 0x24
203 #define HID_USAGE_LED_CALL_PICKUP 0x25
204 #define HID_USAGE_LED_CONFERENCE 0x26
205 #define HID_USAGE_LED_STAND_BY 0x27
206 #define HID_USAGE_LED_CAMERA_ON 0x28
207 #define HID_USAGE_LED_CAMERA_OFF 0x29
208 #define HID_USAGE_LED_ON_LINE 0x2A
209 #define HID_USAGE_LED_OFF_LINE 0x2B
210 #define HID_USAGE_LED_BUSY 0x2C
211 #define HID_USAGE_LED_READY 0x2D
212 #define HID_USAGE_LED_PAPER_OUT 0x2E
213 #define HID_USAGE_LED_PAPER_JAM 0x2F
214 #define HID_USAGE_LED_REMOTE 0x30
215 #define HID_USAGE_LED_FORWARD 0x31
216 #define HID_USAGE_LED_REVERSE 0x32
217 #define HID_USAGE_LED_STOP 0x33
218 #define HID_USAGE_LED_REWIND 0x34
219 #define HID_USAGE_LED_FAST_FORWARD 0x35
220 #define HID_USAGE_LED_PLAY 0x36
221 #define HID_USAGE_LED_PAUSE 0x37
222 #define HID_USAGE_LED_RECORD 0x38
223 #define HID_USAGE_LED_ERROR 0x39
224 #define HID_USAGE_LED_SELECTED_INDICATOR 0x3A
225 #define HID_USAGE_LED_IN_USE_INDICATOR 0x3B
226 #define HID_USAGE_LED_MULTI_MODE_INDICATOR 0x3C
227 #define HID_USAGE_LED_INDICATOR_ON 0x3D
228 #define HID_USAGE_LED_INDICATOR_FLASH 0x3E
229 #define HID_USAGE_LED_INDICATOR_SLOW_BLINK 0x3F
230 #define HID_USAGE_LED_INDICATOR_FAST_BLINK 0x40
231 #define HID_USAGE_LED_INDICATOR_OFF 0x41
232 #define HID_USAGE_LED_FLASH_ON_TIME 0x42
233 #define HID_USAGE_LED_SLOW_BLINK_ON_TIME 0x43
234 #define HID_USAGE_LED_SLOW_BLINK_OFF_TIME 0x44
235 #define HID_USAGE_LED_FAST_BLINK_ON_TIME 0x45
236 #define HID_USAGE_LED_FAST_BLINK_OFF_TIME 0x46
237 #define HID_USAGE_LED_INDICATOR_COLOR 0x47
238 #define HID_USAGE_LED_RED 0x48
239 #define HID_USAGE_LED_GREEN 0x49
240 #define HID_USAGE_LED_AMBER 0x4A
241 #define HID_USAGE_LED_GENERIC_INDICATOR 0x4B
242
243 /* Button Page (0x09) */
244 /* There is no need to label these usages. */
245
246 /* Ordinal Page (0x0A) */
247 /* There is no need to label these usages. */
248
249 /* Telephony Device Page (0x0B) */
250 #define HID_USAGE_TELEPHONY_PHONE 0x01
251 #define HID_USAGE_TELEPHONY_ANSWERING_MACHINE 0x02
252 #define HID_USAGE_TELEPHONY_MESSAGE_CONTROLS 0x03
253 #define HID_USAGE_TELEPHONY_HANDSET 0x04
254 #define HID_USAGE_TELEPHONY_HEADSET 0x05
255 #define HID_USAGE_TELEPHONY_KEYPAD 0x06
256 #define HID_USAGE_TELEPHONY_PROGRAMMABLE_BUTTON 0x07
257 /* ... */
258
259 /* Consumer Page (0x0C) */
260 #define HID_USAGE_CONSUMER_CONTROL 0x01
261 /* ... */
262
263 /* and others ... */
264
265
266 /* HID Report Item Macros */
267
268 /* Main Items */
269 #define HID_Input(x) 0x81,x
270 #define HID_Output(x) 0x91,x
271 #define HID_Feature(x) 0xB1,x
272 #define HID_Collection(x) 0xA1,x
273 #define HID_EndCollection 0xC0
274
275 /* Data (Input, Output, Feature) */
276 #define HID_Data 0<<0
277 #define HID_Constant 1<<0
278 #define HID_Array 0<<1
279 #define HID_Variable 1<<1
280 #define HID_Absolute 0<<2
281 #define HID_Relative 1<<2
282 #define HID_NoWrap 0<<3
283 #define HID_Wrap 1<<3
284 #define HID_Linear 0<<4
285 #define HID_NonLinear 1<<4
286 #define HID_PreferredState 0<<5
287 #define HID_NoPreferred 1<<5
288 #define HID_NoNullPosition 0<<6
289 #define HID_NullState 1<<6
290 #define HID_NonVolatile 0<<7
291 #define HID_Volatile 1<<7
292
293 /* Collection Data */
294 #define HID_Physical 0x00
295 #define HID_Application 0x01
296 #define HID_Logical 0x02
297 #define HID_Report 0x03
298 #define HID_NamedArray 0x04
299 #define HID_UsageSwitch 0x05
300 #define HID_UsageModifier 0x06
301
302 /* Global Items */
303 #define HID_UsagePage(x) 0x05,x
304 #define HID_UsagePageVendor(x) 0x06,x,0xFF
305 #define HID_LogicalMin(x) 0x15,x
306 #define HID_LogicalMinS(x) 0x16,(x&0xFF),((x>>8)&0xFF)
307 #define HID_LogicalMinL(x) 0x17,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
308 #define HID_LogicalMax(x) 0x25,x
309 #define HID_LogicalMaxS(x) 0x26,(x&0xFF),((x>>8)&0xFF)
310 #define HID_LogicalMaxL(x) 0x27,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
311 #define HID_PhysicalMin(x) 0x35,x
312 #define HID_PhysicalMinS(x) 0x36,(x&0xFF),((x>>8)&0xFF)
313 #define HID_PhysicalMinL(x) 0x37,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
314 #define HID_PhysicalMax(x) 0x45,x
315 #define HID_PhysicalMaxS(x) 0x46,(x&0xFF),((x>>8)&0xFF)
316 #define HID_PhysicalMaxL(x) 0x47,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
317 #define HID_UnitExponent(x) 0x55,x
318 #define HID_Unit(x) 0x65,x
319 #define HID_UnitS(x) 0x66,(x&0xFF),((x>>8)&0xFF)
320 #define HID_UnitL(x) 0x67,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
321 #define HID_ReportSize(x) 0x75,x
322 #define HID_ReportSizeS(x) 0x76,(x&0xFF),((x>>8)&0xFF)
323 #define HID_ReportSizeL(x) 0x77,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
324 #define HID_ReportID(x) 0x85,x
325 #define HID_ReportCount(x) 0x95,x
326 #define HID_ReportCountS(x) 0x96,(x&0xFF),((x>>8)&0xFF)
327 #define HID_ReportCountL(x) 0x97,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
328 #define HID_Push 0xA4
329 #define HID_Pop 0xB4
330
331 /* Local Items */
332 #define HID_Usage(x) 0x09,x
333 #define HID_UsageMin(x) 0x19,x
334 #define HID_UsageMax(x) 0x29,x
335
336 /* Exported macro ------------------------------------------------------------*/
337 /* Exported functions --------------------------------------------------------*/
338
339 #ifdef __cplusplus
340 }
341 #endif
342
343 #endif /* __USB_HID_DEF_H */