4 * \brief USB Human Interface Device (HID) protocol definitions.
6 * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright notice,
19 * this list of conditions and the following disclaimer in the documentation
20 * and/or other materials provided with the distribution.
22 * 3. The name of Atmel may not be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * 4. This software may only be redistributed and used in connection with an
26 * Atmel microcontroller product.
28 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
31 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
32 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
44 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
47 #ifndef _USB_PROTOCOL_HID_H_
48 #define _USB_PROTOCOL_HID_H_
51 * \ingroup usb_protocol_group
52 * \defgroup usb_hid_protocol USB Human Interface Device (HID)
53 * protocol definitions
54 * \brief USB Human Interface Device (HID) protocol definitions
59 //! \name Possible Class value
61 #define HID_CLASS 0x03
64 //! \name Possible SubClass value
66 //! Interface subclass NO support BOOT protocol
67 #define HID_SUB_CLASS_NOBOOT 0x00
68 //! Interface subclass support BOOT protocol
69 #define HID_SUB_CLASS_BOOT 0x01
72 //! \name Possible protocol value
74 //! Protocol generic standard
75 #define HID_PROTOCOL_GENERIC 0x00
76 //! Protocol keyboard standard
77 #define HID_PROTOCOL_KEYBOARD 0x01
78 //! Protocol mouse standard
79 #define HID_PROTOCOL_MOUSE 0x02
83 //! \brief Hid USB requests (bRequest)
85 USB_REQ_HID_GET_REPORT = 0x01,
86 USB_REQ_HID_GET_IDLE = 0x02,
87 USB_REQ_HID_GET_PROTOCOL = 0x03,
88 USB_REQ_HID_SET_REPORT = 0x09,
89 USB_REQ_HID_SET_IDLE = 0x0A,
90 USB_REQ_HID_SET_PROTOCOL = 0x0B,
93 //! \brief HID USB descriptor types
94 enum usb_descriptor_type_hid {
96 USB_DT_HID_REPORT = 0x22,
97 USB_DT_HID_PHYSICAL = 0x23,
100 //! \brief HID Type for report descriptor
101 enum usb_hid_item_report_type {
102 USB_HID_ITEM_REPORT_TYPE_MAIN = 0,
103 USB_HID_ITEM_REPORT_TYPE_GLOBAL = 1,
104 USB_HID_ITEM_REPORT_TYPE_LOCAL = 2,
105 USB_HID_ITEM_REPORT_TYPE_LONG = 3,
108 //! \brief HID report type
109 enum usb_hid_report_type {
110 USB_HID_REPORT_TYPE_INPUT = 1,
111 USB_HID_REPORT_TYPE_OUTPUT = 2,
112 USB_HID_REPORT_TYPE_FEATURE = 3,
116 //! \brief HID protocol
117 enum usb_hid_protocol {
118 USB_HID_PROCOTOL_BOOT = 0,
119 USB_HID_PROCOTOL_REPORT = 1,
124 //! \brief HID Descriptor
126 uint8_t bLength; //!< Size of this descriptor in bytes
127 uint8_t bDescriptorType; //!< HID descriptor type
128 le16_t bcdHID; //!< Binary Coded Decimal Spec. release
129 uint8_t bCountryCode; //!< Hardware target country
130 uint8_t bNumDescriptors; //!< Number of HID class descriptors to follow
131 uint8_t bRDescriptorType; //!< Report descriptor type
132 le16_t wDescriptorLength; //!< Total length of Report descriptor
133 } usb_hid_descriptor_t;
135 COMPILER_PACK_RESET()
137 //! \name HID Report type
138 //! Used by SETUP_HID_GET_REPORT & SETUP_HID_SET_REPORT
140 #define REPORT_TYPE_INPUT 0x01
141 #define REPORT_TYPE_OUTPUT 0x02
142 #define REPORT_TYPE_FEATURE 0x03
145 //! \name Constants of field DESCRIPTOR_HID
147 //! Numeric expression identifying the HID Class
148 //! Specification release (here V1.11)
149 #define USB_HID_BDC_V1_11 0x0111
150 //! Numeric expression specifying the number of class descriptors
151 //! Note: Always at least one i.e. Report descriptor.
152 #define USB_HID_NUM_DESC 0x01
154 //! \name Country code
156 #define USB_HID_NO_COUNTRY_CODE 0 // Not Supported
157 #define USB_HID_COUNTRY_ARABIC 1 // Arabic
158 #define USB_HID_COUNTRY_BELGIAN 2 // Belgian
159 #define USB_HID_COUNTRY_CANADIAN_BILINGUAL 3 // Canadian-Bilingual
160 #define USB_HID_COUNTRY_CANADIAN_FRENCH 4 // Canadian-French
161 #define USB_HID_COUNTRY_CZECH_REPUBLIC 5 // Czech Republic
162 #define USB_HID_COUNTRY_DANISH 6 // Danish
163 #define USB_HID_COUNTRY_FINNISH 7 // Finnish
164 #define USB_HID_COUNTRY_FRENCH 8 // French
165 #define USB_HID_COUNTRY_GERMAN 9 // German
166 #define USB_HID_COUNTRY_GREEK 10 // Greek
167 #define USB_HID_COUNTRY_HEBREW 11 // Hebrew
168 #define USB_HID_COUNTRY_HUNGARY 12 // Hungary
169 #define USB_HID_COUNTRY_INTERNATIONAL_ISO 13 // International (ISO)
170 #define USB_HID_COUNTRY_ITALIAN 14 // Italian
171 #define USB_HID_COUNTRY_JAPAN_KATAKANA 15 // Japan (Katakana)
172 #define USB_HID_COUNTRY_KOREAN 16 // Korean
173 #define USB_HID_COUNTRY_LATIN_AMERICAN 17 // Latin American
174 #define USB_HID_COUNTRY_NETHERLANDS_DUTCH 18 // Netherlands/Dutch
175 #define USB_HID_COUNTRY_NORWEGIAN 19 // Norwegian
176 #define USB_HID_COUNTRY_PERSIAN_FARSI 20 // Persian (Farsi)
177 #define USB_HID_COUNTRY_POLAND 21 // Poland
178 #define USB_HID_COUNTRY_PORTUGUESE 22 // Portuguese
179 #define USB_HID_COUNTRY_RUSSIA 23 // Russia
180 #define USB_HID_COUNTRY_SLOVAKIA 24 // Slovakia
181 #define USB_HID_COUNTRY_SPANISH 25 // Spanish
182 #define USB_HID_COUNTRY_SWEDISH 26 // Swedish
183 #define USB_HID_COUNTRY_SWISS_FRENCH 27 // Swiss/French
184 #define USB_HID_COUNTRY_SWISS_GERMAN 28 // Swiss/German
185 #define USB_HID_COUNTRY_SWITZERLAND 29 // Switzerland
186 #define USB_HID_COUNTRY_TAIWAN 30 // Taiwan
187 #define USB_HID_COUNTRY_TURKISH_Q 31 // Turkish-Q
188 #define USB_HID_COUNTRY_UK 32 // UK
189 #define USB_HID_COUNTRY_US 33 // US
190 #define USB_HID_COUNTRY_YUGOSLAVIA 34 // Yugoslavia
191 #define USB_HID_COUNTRY_TURKISH_F 35 // Turkish-F
197 //! \name HID KEYS values
236 #define HID_ESCAPE 41
237 #define HID_BACKSPACE 42
239 #define HID_SPACEBAR 44
240 #define HID_UNDERSCORE 45
242 #define HID_OPEN_BRACKET 47 // {
243 #define HID_CLOSE_BRACKET 48 // }
244 #define HID_BACKSLASH 49
245 #define HID_ASH 50 // # ~
246 #define HID_COLON 51 // ; :
247 #define HID_QUOTE 52 // ' "
252 #define HID_CAPS_LOCK 57
265 #define HID_PRINTSCREEN 70
266 #define HID_SCROLL_LOCK 71
268 #define HID_INSERT 73
270 #define HID_PAGEUP 75
271 #define HID_DELETE 76
273 #define HID_PAGEDOWN 78
278 #define HID_KEYPAD_NUM_LOCK 83
279 #define HID_KEYPAD_DIVIDE 84
280 #define HID_KEYPAD_AT 85
281 #define HID_KEYPAD_MULTIPLY 85
282 #define HID_KEYPAD_MINUS 86
283 #define HID_KEYPAD_PLUS 87
284 #define HID_KEYPAD_ENTER 88
285 #define HID_KEYPAD_1 89
286 #define HID_KEYPAD_2 90
287 #define HID_KEYPAD_3 91
288 #define HID_KEYPAD_4 92
289 #define HID_KEYPAD_5 93
290 #define HID_KEYPAD_6 94
291 #define HID_KEYPAD_7 95
292 #define HID_KEYPAD_8 96
293 #define HID_KEYPAD_9 97
294 #define HID_KEYPAD_0 98
296 //! \name HID modifier values
298 #define HID_MODIFIER_NONE 0x00
299 #define HID_MODIFIER_LEFT_CTRL 0x01
300 #define HID_MODIFIER_LEFT_SHIFT 0x02
301 #define HID_MODIFIER_LEFT_ALT 0x04
302 #define HID_MODIFIER_LEFT_UI 0x08
303 #define HID_MODIFIER_RIGHT_CTRL 0x10
304 #define HID_MODIFIER_RIGHT_SHIFT 0x20
305 #define HID_MODIFIER_RIGHT_ALT 0x40
306 #define HID_MODIFIER_RIGHT_UI 0x80
310 //! \name HID KEYS values
312 #define HID_LED_NUM_LOCK (1<<0)
313 #define HID_LED_CAPS_LOCK (1<<1)
314 #define HID_LED_SCROLL_LOCK (1<<2)
315 #define HID_LED_COMPOSE (1<<3)
316 #define HID_LED_KANA (1<<4)
319 #endif // _USB_PROTOCOL_HID_H_