SAMV71 Xplained Ultra Software Package 1.3

HIDDescriptors.h

Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  *         SAM Software Package License 
00003  * ----------------------------------------------------------------------------
00004  * Copyright (c) 2014, Atmel Corporation
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *
00011  * - Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the disclaimer below.
00013  *
00014  * Atmel's name may not be used to endorse or promote products derived from
00015  * this software without specific prior written permission.
00016  *
00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  * ----------------------------------------------------------------------------
00028  */
00029 
00030 /**\file
00031  *
00032  * \section Purpose
00033  *
00034  * Definitions used for declaring the descriptors of a HID device.
00035  *
00036  */
00037 
00038 #ifndef _HIDDESCRIPTORS_H_
00039 #define _HIDDESCRIPTORS_H_
00040 /** \addtogroup usb_hid
00041  *@{
00042  */
00043 
00044 /*----------------------------------------------------------------------------
00045  *         Includes
00046  *----------------------------------------------------------------------------*/
00047 
00048 #include <stdint.h>
00049 
00050 #include "HIDReports.h"
00051 #include "HIDUsages.h"
00052 
00053 /*----------------------------------------------------------------------------
00054  *         Definitions
00055  *----------------------------------------------------------------------------*/
00056 
00057 /** \addtogroup usb_hid_device_descriptor_codes HID Device Descriptor Codes
00058  *      @{
00059  * This page lists HID device class, subclass and protocol codes.
00060  *
00061  * \section Codes
00062  * - HIDDeviceDescriptor_CLASS
00063  * - HIDDeviceDescriptor_SUBCLASS
00064  * - HIDDeviceDescriptor_PROTOCOL
00065  */
00066 
00067 /** Class code for a HID device. */
00068 #define HIDDeviceDescriptor_CLASS               0
00069 /** Subclass code for a HID device. */
00070 #define HIDDeviceDescriptor_SUBCLASS            0
00071 /** Protocol code for a HID device. */
00072 #define HIDDeviceDescriptor_PROTOCOL            0
00073 /**      @}*/
00074 
00075 /** \addtogroup usb_hid_interface_descriptor_codes HID Interface Descriptor Codes
00076  *      @{
00077  * This page lists HID Interface class, subclass and protocol codes.
00078  *
00079  * \section Codes
00080  * - HIDInterfaceDescriptor_CLASS
00081  * - HIDInterfaceDescriptor_SUBCLASS_NONE
00082  * - HIDInterfaceDescriptor_SUBCLASS_BOOT
00083  * - HIDInterfaceDescriptor_PROTOCOL_NONE
00084  * - HIDInterfaceDescriptor_PROTOCOL_KEYBOARD
00085  * - HIDInterfaceDescriptor_PROTOCOL_MOUSE
00086  */
00087 
00088 /** HID interface class code. */
00089 #define HIDInterfaceDescriptor_CLASS                0x03
00090 /** Indicates the interface does not implement a particular subclass. */
00091 #define HIDInterfaceDescriptor_SUBCLASS_NONE        0x00
00092 /** Indicates the interface is compliant with the boot specification. */
00093 #define HIDInterfaceDescriptor_SUBCLASS_BOOT        0x01
00094 /** Indicates the interface does not implement a particular protocol. */
00095 #define HIDInterfaceDescriptor_PROTOCOL_NONE        0x00
00096 /** Indicates the interface supports the boot specification as a keyboard. */
00097 #define HIDInterfaceDescriptor_PROTOCOL_KEYBOARD    0x01
00098 /** Indicates the interface supports the boot specification as a mouse. */
00099 #define HIDInterfaceDescriptor_PROTOCOL_MOUSE       0x02
00100 /**      @}*/
00101 
00102 /** \addtogroup usb_hid_ver HID Release Numbers
00103  *      @{
00104  * - \ref HIDDescriptor_HID1_11
00105  */
00106 
00107 /** Identifies version 1.11 of the HID specification. */
00108 #define HIDDescriptor_HID1_11           0x0111
00109 /**     @}*/
00110 
00111 /** \addtogroup usb_descriptors_types HID Descriptors Types
00112  *      @{
00113  *
00114  * \section Types
00115  * - HIDGenericDescriptor_HID
00116  * - HIDGenericDescriptor_REPORT
00117  * - HIDGenericDescriptor_PHYSICAL
00118  */
00119 
00120 /** HID descriptor type. */
00121 #define HIDGenericDescriptor_HID            0x21
00122 /** Report descriptor type. */
00123 #define HIDGenericDescriptor_REPORT         0x22
00124 /** Physical descriptor type. */
00125 #define HIDGenericDescriptor_PHYSICAL       0x23
00126 /**      @}*/
00127 
00128 /*----------------------------------------------------------------------------
00129  *         Types
00130  *----------------------------------------------------------------------------*/
00131 #pragma pack(1)
00132 #if defined   ( __CC_ARM   ) /* Keil ¦̀Vision 4 */
00133 #elif defined ( __ICCARM__ ) /* IAR Ewarm */
00134 #define __attribute__(...)
00135 #define __packed__  packed
00136 #elif defined (  __GNUC__  ) /* GCC CS3 */
00137 #define __packed__  aligned(1)
00138 #endif
00139 
00140 /**
00141  * \typedef HIDDescriptor
00142  * \brief Identifies the length of type of subordinate descriptors of a HID
00143  *        device. This particular type has no subordinate descriptor.
00144  */
00145 typedef struct _HIDDescriptor {
00146 
00147     /** Size of descriptor in bytes. */
00148     uint8_t  bLength;
00149     /** Descriptor type (\ref HIDGenericDescriptor_HID). */
00150     uint8_t  bDescriptorType;
00151     /** HID class specification release number in BCD format. */
00152     uint16_t bcdHID;
00153     /** Country code of the device if it is localized. */
00154     uint8_t  bCountryCode;
00155     /** Number of subordinate descriptors. */
00156     uint8_t  bNumDescriptors;
00157 
00158 } __attribute__ ((__packed__)) HIDDescriptor; /* GCC */
00159 
00160 /**
00161  * \typedef HIDDescriptor
00162  * \brief Identifies the length of type of subordinate descriptors of a HID
00163  *        device. This particular type only supports one subordinate descriptor.
00164  */
00165 typedef struct _HIDDescriptor1 {
00166 
00167     /** Size of descriptor in bytes. */
00168     uint8_t  bLength;
00169     /** Descriptor type (\ref HIDGenericDescriptor_HID). */
00170     uint8_t  bDescriptorType;
00171     /** HID class specification release number in BCD format. */
00172     uint16_t bcdHID;
00173     /** Country code of the device if it is localized. */
00174     uint8_t  bCountryCode;
00175     /** Number of subordinate descriptors. */
00176     uint8_t  bNumDescriptors;
00177     /** Type of the first subordinate descriptor. */
00178     uint8_t  bDescriptorType0;
00179     /** Size in bytes of the first subordinate descriptor. */
00180     uint8_t  bDescriptorLength0[2];
00181 
00182 } __attribute__ ((__packed__)) HIDDescriptor1; /* GCC */
00183 
00184 /**
00185  * HID Physical Descriptor set 0: specifies the number of additional
00186  * descriptor sets.
00187  */
00188 typedef struct _HIDPhysicalDescriptor0 {
00189     /** Numeric expression specifying the number of Physical Descriptor sets
00190         Physical Descriptor 0 itself not included */
00191     uint8_t   bNumber;
00192     /** Numeric expression identifying the length of each Physical descriptor */
00193     uint8_t   bLength[2];
00194 } __attribute__ ((__packed__)) HIDPhysicalDescriptor0; /* GCC */
00195 
00196 /**
00197  * HID Physical information
00198  */
00199 typedef union _HIDPhysicalInfo {
00200     /** Bits specifying physical information: 7..5 Bias, 4..0 Preference */
00201     uint8_t bData;
00202     struct {
00203         uint8_t Preference:5,   /**< 0=Most preferred */
00204                 Bias:3;         /**< indicates which hand the descriptor
00205                                      set is characterizing */
00206     } sPhysicalInfo;
00207 } HIDPhysicalInfo;
00208 
00209 /**
00210  * HID Physical Descriptor
00211  */
00212 typedef struct _HIDPhysicalDescriptor {
00213     /** Designator: indicates which part of the body affects the item */
00214     uint8_t bDesignator;
00215     /** Bits specifying flags:
00216         7..5 Qualifier;
00217         4..0 Effort */
00218     uint8_t bFlags;
00219 } __attribute__ ((__packed__)) HIDPhysicalDescriptor; /* GCC */
00220 
00221 #pragma pack()
00222 
00223 /*----------------------------------------------------------------------------
00224  *         Functions
00225  *----------------------------------------------------------------------------*/
00226 
00227 /**@}*/
00228 #endif /* #ifndef _HIDDESCRIPTORS_H_ */
00229 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines