SAMV71 Xplained Ultra Software Package 1.5

hid.h

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------- */
00002 /*                  Atmel Microcontroller Software Support                      */
00003 /*                       SAM Software Package License                           */
00004 /* ---------------------------------------------------------------------------- */
00005 /* Copyright (c) 2015, Atmel Corporation                                        */
00006 /*                                                                              */
00007 /* All rights reserved.                                                         */
00008 /*                                                                              */
00009 /* Redistribution and use in source and binary forms, with or without           */
00010 /* modification, are permitted provided that the following condition is met:    */
00011 /*                                                                              */
00012 /* - Redistributions of source code must retain the above copyright notice,     */
00013 /* this list of conditions and the disclaimer below.                            */
00014 /*                                                                              */
00015 /* Atmel's name may not be used to endorse or promote products derived from     */
00016 /* this software without specific prior written permission.                     */
00017 /*                                                                              */
00018 /* DISCLAIMER:  THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR   */
00019 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
00020 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE   */
00021 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,      */
00022 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
00023 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,  */
00024 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
00025 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING         */
00026 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
00027 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                           */
00028 /* ---------------------------------------------------------------------------- */
00029 
00030 /*This file is prepared for Doxygen automatic documentation generation.*/
00031 /*! \file *********************************************************************
00032  *
00033  * \brief Management of the generic HID features.
00034  *
00035  ******************************************************************************/
00036 
00037 #ifndef _HID_H_
00038 #define _HID_H_
00039 
00040 
00041 //_____ I N C L U D E S ________________________________________________________
00042 
00043 
00044 //_____ M A C R O S ____________________________________________________________
00045 
00046 /*! \name HID Descriptor Types
00047  */
00048 //! @{
00049 #define HID_DESCRIPTOR                          0x21
00050 #define HID_REPORT_DESCRIPTOR                   0x22
00051 #define HID_PHYSICAL_DESCRIPTOR                 0x23
00052 //! @}
00053 
00054 /*! \name Constants of field DESCRIPTOR_HID
00055  */
00056 //! @{
00057 #define  HID_BDC                              0x0111  //!< Numeric expression identifying the HID Class Specification release (here V1.11)
00058 #define  HID_CLASS_DESC_NB_DEFAULT            0x01    //!< Numeric expression specifying the number of class descriptors (always at least one i.e. Report descriptor.)
00059 //! @}
00060 
00061 /*! \name HID Country Codes
00062  */
00063 //! @{
00064 #define HID_COUNTRY_CODE_NOT_SUPPORTED          0
00065 #define HID_COUNTRY_CODE_ARABIC                 1
00066 #define HID_COUNTRY_CODE_BELGIAN                2
00067 #define HID_COUNTRY_CODE_CANADIAN_BILINGUAL     3
00068 #define HID_COUNTRY_CODE_CANADIAN_FRENCH        4
00069 #define HID_COUNTRY_CODE_CZECH_REPUBLIC         5
00070 #define HID_COUNTRY_CODE_DANISH                 6
00071 #define HID_COUNTRY_CODE_FINNISH                7
00072 #define HID_COUNTRY_CODE_FRENCH                 8
00073 #define HID_COUNTRY_CODE_GERMAN                 9
00074 #define HID_COUNTRY_CODE_GREEK                  10
00075 #define HID_COUNTRY_CODE_HEBREW                 11
00076 #define HID_COUNTRY_CODE_HUNGARY                12
00077 #define HID_COUNTRY_CODE_INTERNATIONAL_ISO      13
00078 #define HID_COUNTRY_CODE_ITALIAN                14
00079 #define HID_COUNTRY_CODE_JAPAN_KATAKANA         15
00080 #define HID_COUNTRY_CODE_KOREAN                 16
00081 #define HID_COUNTRY_CODE_LATIN_AMERICAN         17
00082 #define HID_COUNTRY_CODE_NETHERLANDS_DUTCH      18
00083 #define HID_COUNTRY_CODE_NORWEGIAN              19
00084 #define HID_COUNTRY_CODE_PERSIAN_FARSI          20
00085 #define HID_COUNTRY_CODE_POLAND                 21
00086 #define HID_COUNTRY_CODE_PORTUGUESE             22
00087 #define HID_COUNTRY_CODE_RUSSIA                 23
00088 #define HID_COUNTRY_CODE_SLOVAKIA               24
00089 #define HID_COUNTRY_CODE_SPANISH                25
00090 #define HID_COUNTRY_CODE_SWEDISH                26
00091 #define HID_COUNTRY_CODE_SWISS_FRENCH           27
00092 #define HID_COUNTRY_CODE_SWISS_GERMAN           28
00093 #define HID_COUNTRY_CODE_SWITZERLAND            29
00094 #define HID_COUNTRY_CODE_TAIWAN                 30
00095 #define HID_COUNTRY_CODE_TURKISH_Q              31
00096 #define HID_COUNTRY_CODE_UK                     32
00097 #define HID_COUNTRY_CODE_US                     33
00098 #define HID_COUNTRY_CODE_YUGOSLAVIA             34
00099 #define HID_COUNTRY_CODE_TURKISH_F              35
00100 //! @}
00101 
00102 //! \name HID KEYS values
00103 //! @{
00104 #define  HID_A                4
00105 #define  HID_B                5
00106 #define  HID_C                6
00107 #define  HID_D                7
00108 #define  HID_E                8
00109 #define  HID_F                9
00110 #define  HID_G                10
00111 #define  HID_H                11
00112 #define  HID_I                12
00113 #define  HID_J                13
00114 #define  HID_K                14
00115 #define  HID_L                15
00116 #define  HID_M                16
00117 #define  HID_N                17
00118 #define  HID_O                18
00119 #define  HID_P                19
00120 #define  HID_Q                20
00121 #define  HID_R                21
00122 #define  HID_S                22
00123 #define  HID_T                23
00124 #define  HID_U                24
00125 #define  HID_V                25
00126 #define  HID_W                26
00127 #define  HID_X                27
00128 #define  HID_Y                28
00129 #define  HID_Z                29
00130 #define  HID_1                30
00131 #define  HID_2                31
00132 #define  HID_3                32
00133 #define  HID_4                33
00134 #define  HID_5                34
00135 #define  HID_6                35
00136 #define  HID_7                36
00137 #define  HID_8                37
00138 #define  HID_9                38
00139 #define  HID_0                39
00140 #define  HID_ENTER            40
00141 #define  HID_ESCAPE           41
00142 #define  HID_BACKSPACE        42
00143 #define  HID_TAB              43
00144 #define  HID_SPACEBAR         44
00145 #define  HID_UNDERSCORE       45
00146 #define  HID_PLUS             46
00147 /*
00148 #define  HID_[ {              47
00149 #define  HID_] }              48
00150 */
00151 #define  HID_BACKSLASH        49
00152 /*
00153 #define  HID_# ~              50
00154 #define  HID_; :              51
00155 #define  HID_?"              52
00156 */
00157 #define  HID_TILDE            53
00158 #define  HID_COMMA            54
00159 #define  HID_DOT              55
00160 #define  HID_SLASH            56
00161 #define  HID_CAPS LOCK        57
00162 #define  HID_F1               58
00163 #define  HID_F2               59
00164 #define  HID_F3               60
00165 #define  HID_F4               61
00166 #define  HID_F5               62
00167 #define  HID_F6               63
00168 #define  HID_F7               64
00169 #define  HID_F8               65
00170 #define  HID_F9               66
00171 #define  HID_F10              67
00172 #define  HID_F11              68
00173 #define  HID_F12              69
00174 #define  HID_PRINTSCREEN      70
00175 #define  HID_SCROLL LOCK      71
00176 #define  HID_PAUSE            72
00177 #define  HID_INSERT           73
00178 #define  HID_HOME             74
00179 #define  HID_PAGEUP           75
00180 #define  HID_DELETE           76
00181 #define  HID_END              77
00182 #define  HID_PAGEDOWN         78
00183 #define  HID_RIGHT            79
00184 #define  HID_LEFT             80
00185 #define  HID_DOWN             81
00186 #define  HID_UP               82
00187 #define  HID_KEYPAD_NUM_LOCK  83
00188 #define  HID_KEYPAD_DIVIDE    84
00189 #define  HID_KEYPAD_AT        85
00190 #define  HID_KEYPAD_MULTIPLY  85
00191 #define  HID_KEYPAD_MINUS     86
00192 #define  HID_KEYPAD_PLUS      87
00193 #define  HID_KEYPAD_ENTER     88
00194 #define  HID_KEYPAD_1         89
00195 #define  HID_KEYPAD_2         90
00196 #define  HID_KEYPAD_3         91
00197 #define  HID_KEYPAD_4         92
00198 #define  HID_KEYPAD_5         93
00199 #define  HID_KEYPAD_6         94
00200 #define  HID_KEYPAD_7         95
00201 #define  HID_KEYPAD_8         96
00202 #define  HID_KEYPAD_9         97
00203 #define  HID_KEYPAD_0         98
00204 
00205 //! \name HID modifier values
00206 //! @{
00207 #define  HID_MODIFIER_NONE          0x00
00208 #define  HID_MODIFIER_LEFT_CTRL     0x01
00209 #define  HID_MODIFIER_LEFT_SHIFT    0x02
00210 #define  HID_MODIFIER_LEFT_ALT      0x04
00211 #define  HID_MODIFIER_LEFT_GUI      0x08
00212 #define  HID_MODIFIER_RIGHT_CTRL    0x10
00213 #define  HID_MODIFIER_RIGHT_SHIFT   0x20
00214 #define  HID_MODIFIER_RIGHT_ALT     0x40
00215 #define  HID_MODIFIER_RIGHT_GUI     0x80
00216 //! @}
00217 //! @}
00218 
00219 /*! \name HID Requests
00220  */
00221 //! @{
00222 #define HID_GET_REPORT                          0x01
00223 #define HID_GET_IDLE                            0x02
00224 #define HID_GET_PROTOCOL                        0x03
00225 #define HID_SET_REPORT                          0x09
00226 #define HID_SET_IDLE                            0x0A
00227 #define HID_SET_PROTOCOL                        0x0B
00228 //! @}
00229 
00230 /*! \name HID Report Types
00231  */
00232 //! @{
00233 #define HID_REPORT_INPUT                        0x01
00234 #define HID_REPORT_OUTPUT                       0x02
00235 #define HID_REPORT_FEATURE                      0x03
00236 //! @}
00237 
00238 /*! \name Special HID Report IDs
00239  */
00240 //! @{
00241 #define HID_REPORT_ID_ALL                       0x00
00242 //! @}
00243 
00244 /*! \name Special HID Idle Durations
00245  */
00246 //! @{
00247 #define HID_IDLE_DURATION_INDEFINITE            0x00
00248 //! @}
00249 
00250 /*! \name HID Protocols
00251  */
00252 //! @{
00253 #define HID_BOOT_PROTOCOL                       0x00
00254 #define HID_REPORT_PROTOCOL                     0x01
00255 //! @}
00256 
00257 /*! \name HID Report Descriptor Item Types
00258  */
00259 //! @{
00260 #define HID_ITEM_TYPE_MAIN                      0x00
00261 #define HID_ITEM_TYPE_GLOBAL                    0x01
00262 #define HID_ITEM_TYPE_LOCAL                     0x02
00263 #define HID_ITEM_TYPE_RESERVED                  0x03
00264 //! @}
00265 
00266 /*! \name Special HID Report Descriptor Item Tags
00267  */
00268 //! @{
00269 #define HID_ITEM_TAG_LONG_ITEM                  0x0F
00270 //! @}
00271 
00272 /*! \name HID Report Descriptor Main Item Tags
00273  */
00274 //! @{
00275 #define HID_MAIN_ITEM_TAG_INPUT                 0x08
00276 #define HID_MAIN_ITEM_TAG_OUTPUT                0x09
00277 #define HID_MAIN_ITEM_TAG_FEATURE               0x0B
00278 #define HID_MAIN_ITEM_TAG_COLLECTION            0x0A
00279 #define HID_MAIN_ITEM_TAG_END_COLLECTION        0x0C
00280 //! @}
00281 
00282 /*! \name HID Report Descriptor Global Item Tags
00283  */
00284 //! @{
00285 #define HID_GLOBAL_ITEM_TAG_USAGE_PAGE          0x00
00286 #define HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM     0x01
00287 #define HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM     0x02
00288 #define HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM    0x03
00289 #define HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM    0x04
00290 #define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT       0x05
00291 #define HID_GLOBAL_ITEM_TAG_UNIT                0x06
00292 #define HID_GLOBAL_ITEM_TAG_REPORT_SIZE         0x07
00293 #define HID_GLOBAL_ITEM_TAG_REPORT_ID           0x08
00294 #define HID_GLOBAL_ITEM_TAG_REPORT_COUNT        0x09
00295 #define HID_GLOBAL_ITEM_TAG_PUSH                0x0A
00296 #define HID_GLOBAL_ITEM_TAG_POP                 0x0B
00297 //! @}
00298 
00299 /*! \name HID Report Descriptor Local Item Tags
00300  */
00301 //! @{
00302 #define HID_LOCAL_ITEM_TAG_USAGE                0x00
00303 #define HID_LOCAL_ITEM_TAG_USAGE_MINIMUM        0x01
00304 #define HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM        0x02
00305 #define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX     0x03
00306 #define HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM   0x04
00307 #define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM   0x05
00308 #define HID_LOCAL_ITEM_TAG_STRING_INDEX         0x07
00309 #define HID_LOCAL_ITEM_TAG_STRING_MINIMUM       0x08
00310 #define HID_LOCAL_ITEM_TAG_STRING_MAXIMUM       0x09
00311 #define HID_LOCAL_ITEM_TAG_DELIMITER            0x0A
00312 //! @}
00313 
00314 
00315 //_____ D E F I N I T I O N S __________________________________________________
00316 
00317 //! HID descriptor.
00318 typedef
00319 #if (defined __ICCAVR32__)
00320     #pragma pack(1)
00321 #endif
00322 struct
00323 #if (defined __GNUC__)
00324     __attribute__((__packed__))
00325 #endif
00326 {
00327     unsigned char bLength;
00328     unsigned char bDescriptorType;
00329     unsigned short bcdHID;
00330     unsigned char bCountryCode;
00331     unsigned char bNumDescriptors;
00332     struct
00333 #if (defined __GNUC__)
00334     __attribute__((__packed__))
00335 #endif
00336     {
00337         unsigned char bType;
00338         unsigned short wLength;
00339     } Descriptor[];
00340 }
00341 #if (defined __ICCAVR32__)
00342     #pragma pack()
00343 #endif
00344 hid_descriptor_t;
00345 
00346 //! HID report ID.
00347 typedef unsigned char hid_report_id_t;
00348 
00349 //! HID report descriptor item.
00350 typedef
00351 #if (defined __ICCAVR32__)
00352     #pragma pack(1)
00353 #endif
00354 union
00355 #if (defined __GNUC__)
00356     __attribute__((__packed__))
00357 #endif
00358 {
00359     struct
00360 #if (defined __GNUC__)
00361     __attribute__((__packed__))
00362 #endif
00363     {
00364         unsigned char bTag                          : 4;
00365         unsigned char bType                         : 2;
00366         unsigned char bSize                         : 2;
00367     } header;
00368     struct
00369 #if (defined __GNUC__)
00370     __attribute__((__packed__))
00371 #endif
00372     {
00373         unsigned char bTag                          : 4;
00374         unsigned char bType                         : 2;
00375         unsigned char bSize                         : 2;
00376         unsigned char data[];
00377     } short_format;
00378     struct
00379 #if (defined __GNUC__)
00380     __attribute__((__packed__))
00381 #endif
00382     {
00383         unsigned char bTag                          : 4;
00384         unsigned char bType                         : 2;
00385         unsigned char bSize                         : 2;
00386         unsigned char bDataSize;
00387         unsigned char bLongItemTag;
00388         unsigned char data[];
00389     } long_format;
00390 }
00391 #if (defined __ICCAVR32__)
00392     #pragma pack()
00393 #endif
00394 hid_item_t;
00395 
00396 //! HID report descriptor short item data.
00397 typedef union {
00398     unsigned long value;
00399     union {
00400         struct {
00401             unsigned int                              : 23;
00402             unsigned int buffered_bytes               : 1;
00403             unsigned int                              : 1;
00404             unsigned int null_state                   : 1;
00405             unsigned int no_preferred                 : 1;
00406             unsigned int non_linear                   : 1;
00407             unsigned int wrap                         : 1;
00408             unsigned int relative                     : 1;
00409             unsigned int variable                     : 1;
00410             unsigned int constant                     : 1;
00411         } input;
00412         struct {
00413             unsigned int                              : 23;
00414             unsigned int buffered_bytes               : 1;
00415             unsigned int volatile_                    : 1;
00416             unsigned int null_state                   : 1;
00417             unsigned int no_preferred                 : 1;
00418             unsigned int non_linear                   : 1;
00419             unsigned int wrap                         : 1;
00420             unsigned int relative                     : 1;
00421             unsigned int variable                     : 1;
00422             unsigned int constant                     : 1;
00423         } output;
00424         struct {
00425             unsigned int                              : 23;
00426             unsigned int buffered_bytes               : 1;
00427             unsigned int volatile_                    : 1;
00428             unsigned int null_state                   : 1;
00429             unsigned int no_preferred                 : 1;
00430             unsigned int non_linear                   : 1;
00431             unsigned int wrap                         : 1;
00432             unsigned int relative                     : 1;
00433             unsigned int variable                     : 1;
00434             unsigned int constant                     : 1;
00435         } feature;
00436         enum {
00437             HID_COLLECTION_PHYSICAL                   = 0x00,
00438             HID_COLLECTION_APPLICATION                = 0x01,
00439             HID_COLLECTION_LOGICAL                    = 0x02,
00440             HID_COLLECTION_REPORT                     = 0x03,
00441             HID_COLLECTION_NAMED_ARRAY                = 0x04,
00442             HID_COLLECTION_USAGE_SWITCH               = 0x05,
00443             HID_COLLECTION_USAGE_MODIFIER             = 0x06
00444         } collection;
00445     } main;
00446     union {
00447         unsigned int usage_page;
00448         int logical_minimum;
00449         int logical_maximum;
00450         int physical_minimum;
00451         int physical_maximum;
00452         struct {
00453             unsigned int                              : 28;
00454             int unit_exponent                         : 4;
00455         };
00456         struct {
00457             unsigned int                              : 4;
00458             enum {
00459                 HID_UNIT_LUMINOUS_INTENSITY_NONE        = 0x0,
00460                 HID_UNIT_LUMINOUS_INTENSITY_CANDELA     = 0x1
00461             } luminous_intensity                      : 4;
00462             enum {
00463                 HID_UNIT_CURRENT_NONE                   = 0x0,
00464                 HID_UNIT_CURRENT_AMPERE                 = 0x1
00465             } current                                 : 4;
00466             enum {
00467                 HID_UNIT_TEMPERATURE_NONE               = 0x0,
00468                 HID_UNIT_TEMPERATURE_KELVIN             = 0x1,
00469                 HID_UNIT_TEMPERATURE_FAHRENHEIT         = 0x3
00470             } temperature                             : 4;
00471             enum {
00472                 HID_UNIT_TIME_NONE                      = 0x0,
00473                 HID_UNIT_TIME_SECONDS                   = 0x1
00474             } time                                    : 4;
00475             enum {
00476                 HID_UNIT_MASS_NONE                      = 0x0,
00477                 HID_UNIT_MASS_GRAM                      = 0x1,
00478                 HID_UNIT_MASS_SLUG                      = 0x3
00479             } mass                                    : 4;
00480             enum {
00481                 HID_UNIT_LENGTH_NONE                    = 0x0,
00482                 HID_UNIT_LENGTH_CENTIMETER              = 0x1,
00483                 HID_UNIT_LENGTH_RADIANS                 = 0x2,
00484                 HID_UNIT_LENGTH_INCH                    = 0x3,
00485                 HID_UNIT_LENGTH_DEGREES                 = 0x4
00486             } length                                  : 4;
00487             enum {
00488                 HID_UNIT_SYSTEM_NONE                    = 0x0,
00489                 HID_UNIT_SYSTEM_SI_LINEAR               = 0x1,
00490                 HID_UNIT_SYSTEM_SI_ROTATION             = 0x2,
00491                 HID_UNIT_SYSTEM_ENGLISH_LINEAR          = 0x3,
00492                 HID_UNIT_SYSTEM_ENGLISH_ROTATION        = 0x4
00493             } system                                  : 4;
00494         } unit;
00495         unsigned int report_size;
00496         unsigned int report_id;
00497         unsigned int report_count;
00498     } global;
00499     union {
00500         unsigned int usage;
00501         unsigned int usage_minimum;
00502         unsigned int usage_maximum;
00503         unsigned int designator_index;
00504         unsigned int designator_minimum;
00505         unsigned int designator_maximum;
00506         unsigned int string_index;
00507         unsigned int string_minimum;
00508         unsigned int string_maximum;
00509         enum {
00510             HID_DELIMITER_OPEN_SET                    = 0x01,
00511             HID_DELIMITER_CLOSE_SET                   = 0x00
00512         } delimiter;
00513     } local;
00514 } hid_short_item_data_t;
00515 
00516 
00517 //_____ D E C L A R A T I O N S ________________________________________________
00518 
00519 
00520 #endif  // _HID_H_
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines