diff options
Diffstat (limited to 'lib/lufa/LUFA/Drivers/USB/Class/Common')
12 files changed, 4282 insertions, 0 deletions
diff --git a/lib/lufa/LUFA/Drivers/USB/Class/Common/AndroidAccessoryClassCommon.h b/lib/lufa/LUFA/Drivers/USB/Class/Common/AndroidAccessoryClassCommon.h new file mode 100644 index 000000000..fdf8671fc --- /dev/null +++ b/lib/lufa/LUFA/Drivers/USB/Class/Common/AndroidAccessoryClassCommon.h | |||
| @@ -0,0 +1,129 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 12 | Permission to use, copy, modify, distribute, and sell this | ||
| 13 | software and its documentation for any purpose is hereby granted | ||
| 14 | without fee, provided that the above copyright notice appear in | ||
| 15 | all copies and that both that the copyright notice and this | ||
| 16 | permission notice and warranty disclaimer appear in supporting | ||
| 17 | documentation, and that the name of the author not be used in | ||
| 18 | advertising or publicity pertaining to distribution of the | ||
| 19 | software without specific, written prior permission. | ||
| 20 | |||
| 21 | The author disclaims all warranties with regard to this | ||
| 22 | software, including all implied warranties of merchantability | ||
| 23 | and fitness. In no event shall the author be liable for any | ||
| 24 | special, indirect or consequential damages or any damages | ||
| 25 | whatsoever resulting from loss of use, data or profits, whether | ||
| 26 | in an action of contract, negligence or other tortious action, | ||
| 27 | arising out of or in connection with the use or performance of | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | /** \file | ||
| 32 | * \brief Common definitions and declarations for the library USB Android Open Accessory Class driver. | ||
| 33 | * | ||
| 34 | * Common definitions and declarations for the library USB Android Open Accessory Class driver. | ||
| 35 | * | ||
| 36 | * \note This file should not be included directly. It is automatically included as needed by the USB module driver | ||
| 37 | * dispatch header located in LUFA/Drivers/USB.h. | ||
| 38 | */ | ||
| 39 | |||
| 40 | /** \ingroup Group_USBClassAOA | ||
| 41 | * \defgroup Group_USBClassAOACommon Common Class Definitions | ||
| 42 | * | ||
| 43 | * \section Sec_USBClassAOACommon_ModDescription Module Description | ||
| 44 | * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB | ||
| 45 | * Android Open Accessory Class. | ||
| 46 | * | ||
| 47 | * @{ | ||
| 48 | */ | ||
| 49 | |||
| 50 | #ifndef _AOA_CLASS_COMMON_H_ | ||
| 51 | #define _AOA_CLASS_COMMON_H_ | ||
| 52 | |||
| 53 | /* Includes: */ | ||
| 54 | #include "../../Core/StdDescriptors.h" | ||
| 55 | |||
| 56 | /* Enable C linkage for C++ Compilers: */ | ||
| 57 | #if defined(__cplusplus) | ||
| 58 | extern "C" { | ||
| 59 | #endif | ||
| 60 | |||
| 61 | /* Preprocessor Checks: */ | ||
| 62 | #if !defined(__INCLUDE_FROM_AOA_DRIVER) | ||
| 63 | #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. | ||
| 64 | #endif | ||
| 65 | |||
| 66 | /* Macros: */ | ||
| 67 | /** Product ID value in a Device Descriptor to indicate an Android device in Open Accessory mode. */ | ||
| 68 | #define ANDROID_ACCESSORY_PRODUCT_ID 0x2D00 | ||
| 69 | |||
| 70 | /** Product ID value in a Device Descriptor to indicate an Android device in Open Accessory and Android Debug mode. */ | ||
| 71 | #define ANDROID_ACCESSORY_ADB_PRODUCT_ID 0x2D01 | ||
| 72 | |||
| 73 | /* Enums: */ | ||
| 74 | /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the | ||
| 75 | * Android Open Accessory class. | ||
| 76 | */ | ||
| 77 | enum AOA_Descriptor_ClassSubclassProtocol_t | ||
| 78 | { | ||
| 79 | AOA_CSCP_AOADataClass = 0xFF, /**< Descriptor Class value indicating that the device or interface | ||
| 80 | * belongs to the AOA data class. | ||
| 81 | */ | ||
| 82 | AOA_CSCP_AOADataSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device or interface | ||
| 83 | * belongs to AOA data subclass. | ||
| 84 | */ | ||
| 85 | AOA_CSCP_AOADataProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface | ||
| 86 | * belongs to the AOA data class protocol. | ||
| 87 | */ | ||
| 88 | }; | ||
| 89 | |||
| 90 | /** Enum for the Android Open Accessory class specific control requests that can be issued by the USB bus host. */ | ||
| 91 | enum AOA_ClassRequests_t | ||
| 92 | { | ||
| 93 | AOA_REQ_GetAccessoryProtocol = 0x33, /**< Android Open Accessory control request to retrieve the device's supported Accessory Protocol version. */ | ||
| 94 | AOA_REQ_SendString = 0x34, /**< Android Open Accessory control request to set an accessory property string in the device. */ | ||
| 95 | AOA_REQ_StartAccessoryMode = 0x35, /**< Android Open Accessory control request to switch the device into Accessory mode. */ | ||
| 96 | }; | ||
| 97 | |||
| 98 | /** Enum for the possible Android Open Accessory property string indexes. */ | ||
| 99 | enum AOA_Strings_t | ||
| 100 | { | ||
| 101 | AOA_STRING_Manufacturer = 0, /**< Index of the Manufacturer property string. */ | ||
| 102 | AOA_STRING_Model = 1, /**< Index of the Model Name property string. */ | ||
| 103 | AOA_STRING_Description = 2, /**< Index of the Description property string. */ | ||
| 104 | AOA_STRING_Version = 3, /**< Index of the Version Number property string. */ | ||
| 105 | AOA_STRING_URI = 4, /**< Index of the URI Information property string. */ | ||
| 106 | AOA_STRING_Serial = 5, /**< Index of the Serial Number property string. */ | ||
| 107 | |||
| 108 | #if !defined(__DOXYGEN__) | ||
| 109 | AOA_STRING_TOTAL_STRINGS | ||
| 110 | #endif | ||
| 111 | }; | ||
| 112 | |||
| 113 | /** Enum for the possible Android Open Accessory protocol versions. */ | ||
| 114 | enum AOA_Protocols_t | ||
| 115 | { | ||
| 116 | AOA_PROTOCOL_AccessoryV1 = 0x0001, /**< Android Open Accessory version 1. */ | ||
| 117 | AOA_PROTOCOL_AccessoryV2 = 0x0002, /**< Android Open Accessory version 2. */ | ||
| 118 | }; | ||
| 119 | |||
| 120 | /* Disable C linkage for C++ Compilers: */ | ||
| 121 | #if defined(__cplusplus) | ||
| 122 | } | ||
| 123 | #endif | ||
| 124 | |||
| 125 | #endif | ||
| 126 | |||
| 127 | /** @} */ | ||
| 128 | |||
| 129 | |||
diff --git a/lib/lufa/LUFA/Drivers/USB/Class/Common/AudioClassCommon.h b/lib/lufa/LUFA/Drivers/USB/Class/Common/AudioClassCommon.h new file mode 100644 index 000000000..46ecd0858 --- /dev/null +++ b/lib/lufa/LUFA/Drivers/USB/Class/Common/AudioClassCommon.h | |||
| @@ -0,0 +1,780 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 12 | Permission to use, copy, modify, distribute, and sell this | ||
| 13 | software and its documentation for any purpose is hereby granted | ||
| 14 | without fee, provided that the above copyright notice appear in | ||
| 15 | all copies and that both that the copyright notice and this | ||
| 16 | permission notice and warranty disclaimer appear in supporting | ||
| 17 | documentation, and that the name of the author not be used in | ||
| 18 | advertising or publicity pertaining to distribution of the | ||
| 19 | software without specific, written prior permission. | ||
| 20 | |||
| 21 | The author disclaims all warranties with regard to this | ||
| 22 | software, including all implied warranties of merchantability | ||
| 23 | and fitness. In no event shall the author be liable for any | ||
| 24 | special, indirect or consequential damages or any damages | ||
| 25 | whatsoever resulting from loss of use, data or profits, whether | ||
| 26 | in an action of contract, negligence or other tortious action, | ||
| 27 | arising out of or in connection with the use or performance of | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | /** \file | ||
| 32 | * \brief Common definitions and declarations for the library USB Audio 1.0 Class driver. | ||
| 33 | * | ||
| 34 | * Common definitions and declarations for the library USB Audio 1.0 Class driver. | ||
| 35 | * | ||
| 36 | * \note This file should not be included directly. It is automatically included as needed by the USB module driver | ||
| 37 | * dispatch header located in LUFA/Drivers/USB.h. | ||
| 38 | */ | ||
| 39 | |||
| 40 | /** \ingroup Group_USBClassAudio | ||
| 41 | * \defgroup Group_USBClassAudioCommon Common Class Definitions | ||
| 42 | * | ||
| 43 | * \section Sec_USBClassAudioCommon_ModDescription Module Description | ||
| 44 | * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB | ||
| 45 | * Audio 1.0 Class. | ||
| 46 | * | ||
| 47 | * @{ | ||
| 48 | */ | ||
| 49 | |||
| 50 | #ifndef _AUDIO_CLASS_COMMON_H_ | ||
| 51 | #define _AUDIO_CLASS_COMMON_H_ | ||
| 52 | |||
| 53 | /* Includes: */ | ||
| 54 | #include "../../Core/StdDescriptors.h" | ||
| 55 | |||
| 56 | /* Enable C linkage for C++ Compilers: */ | ||
| 57 | #if defined(__cplusplus) | ||
| 58 | extern "C" { | ||
| 59 | #endif | ||
| 60 | |||
| 61 | /* Preprocessor Checks: */ | ||
| 62 | #if !defined(__INCLUDE_FROM_AUDIO_DRIVER) | ||
| 63 | #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. | ||
| 64 | #endif | ||
| 65 | |||
| 66 | /* Macros: */ | ||
| 67 | /** \name Audio Channel Masks */ | ||
| 68 | //@{ | ||
| 69 | /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 70 | #define AUDIO_CHANNEL_LEFT_FRONT (1 << 0) | ||
| 71 | |||
| 72 | /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 73 | #define AUDIO_CHANNEL_RIGHT_FRONT (1 << 1) | ||
| 74 | |||
| 75 | /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 76 | #define AUDIO_CHANNEL_CENTER_FRONT (1 << 2) | ||
| 77 | |||
| 78 | /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 79 | #define AUDIO_CHANNEL_LOW_FREQ_ENHANCE (1 << 3) | ||
| 80 | |||
| 81 | /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 82 | #define AUDIO_CHANNEL_LEFT_SURROUND (1 << 4) | ||
| 83 | |||
| 84 | /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 85 | #define AUDIO_CHANNEL_RIGHT_SURROUND (1 << 5) | ||
| 86 | |||
| 87 | /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 88 | #define AUDIO_CHANNEL_LEFT_OF_CENTER (1 << 6) | ||
| 89 | |||
| 90 | /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 91 | #define AUDIO_CHANNEL_RIGHT_OF_CENTER (1 << 7) | ||
| 92 | |||
| 93 | /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 94 | #define AUDIO_CHANNEL_SURROUND (1 << 8) | ||
| 95 | |||
| 96 | /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 97 | #define AUDIO_CHANNEL_SIDE_LEFT (1 << 9) | ||
| 98 | |||
| 99 | /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 100 | #define AUDIO_CHANNEL_SIDE_RIGHT (1 << 10) | ||
| 101 | |||
| 102 | /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 103 | #define AUDIO_CHANNEL_TOP (1 << 11) | ||
| 104 | //@} | ||
| 105 | |||
| 106 | /** \name Audio Feature Masks */ | ||
| 107 | //@{ | ||
| 108 | /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ | ||
| 109 | #define AUDIO_FEATURE_MUTE (1 << 0) | ||
| 110 | |||
| 111 | /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ | ||
| 112 | #define AUDIO_FEATURE_VOLUME (1 << 1) | ||
| 113 | |||
| 114 | /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ | ||
| 115 | #define AUDIO_FEATURE_BASS (1 << 2) | ||
| 116 | |||
| 117 | /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ | ||
| 118 | #define AUDIO_FEATURE_MID (1 << 3) | ||
| 119 | |||
| 120 | /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ | ||
| 121 | #define AUDIO_FEATURE_TREBLE (1 << 4) | ||
| 122 | |||
| 123 | /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ | ||
| 124 | #define AUDIO_FEATURE_GRAPHIC_EQUALIZER (1 << 5) | ||
| 125 | |||
| 126 | /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ | ||
| 127 | #define AUDIO_FEATURE_AUTOMATIC_GAIN (1 << 6) | ||
| 128 | |||
| 129 | /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ | ||
| 130 | #define AUDIO_FEATURE_DELAY (1 << 7) | ||
| 131 | |||
| 132 | /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ | ||
| 133 | #define AUDIO_FEATURE_BASS_BOOST (1 << 8) | ||
| 134 | |||
| 135 | /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ | ||
| 136 | #define AUDIO_FEATURE_BASS_LOUDNESS (1 << 9) | ||
| 137 | //@} | ||
| 138 | |||
| 139 | /** \name Audio Terminal Types */ | ||
| 140 | //@{ | ||
| 141 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 142 | #define AUDIO_TERMINAL_UNDEFINED 0x0100 | ||
| 143 | |||
| 144 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 145 | #define AUDIO_TERMINAL_STREAMING 0x0101 | ||
| 146 | |||
| 147 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 148 | #define AUDIO_TERMINAL_VENDOR 0x01FF | ||
| 149 | |||
| 150 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 151 | #define AUDIO_TERMINAL_IN_UNDEFINED 0x0200 | ||
| 152 | |||
| 153 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 154 | #define AUDIO_TERMINAL_IN_MIC 0x0201 | ||
| 155 | |||
| 156 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 157 | #define AUDIO_TERMINAL_IN_DESKTOP_MIC 0x0202 | ||
| 158 | |||
| 159 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 160 | #define AUDIO_TERMINAL_IN_PERSONAL_MIC 0x0203 | ||
| 161 | |||
| 162 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 163 | #define AUDIO_TERMINAL_IN_OMNIDIR_MIC 0x0204 | ||
| 164 | |||
| 165 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 166 | #define AUDIO_TERMINAL_IN_MIC_ARRAY 0x0205 | ||
| 167 | |||
| 168 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 169 | #define AUDIO_TERMINAL_IN_PROCESSING_MIC 0x0206 | ||
| 170 | |||
| 171 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 172 | #define AUDIO_TERMINAL_IN_OUT_UNDEFINED 0x0300 | ||
| 173 | |||
| 174 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 175 | #define AUDIO_TERMINAL_OUT_SPEAKER 0x0301 | ||
| 176 | |||
| 177 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 178 | #define AUDIO_TERMINAL_OUT_HEADPHONES 0x0302 | ||
| 179 | |||
| 180 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 181 | #define AUDIO_TERMINAL_OUT_HEAD_MOUNTED 0x0303 | ||
| 182 | |||
| 183 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 184 | #define AUDIO_TERMINAL_OUT_DESKTOP 0x0304 | ||
| 185 | |||
| 186 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 187 | #define AUDIO_TERMINAL_OUT_ROOM 0x0305 | ||
| 188 | |||
| 189 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 190 | #define AUDIO_TERMINAL_OUT_COMMUNICATION 0x0306 | ||
| 191 | |||
| 192 | /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ | ||
| 193 | #define AUDIO_TERMINAL_OUT_LOWFREQ 0x0307 | ||
| 194 | //@} | ||
| 195 | |||
| 196 | /** Convenience macro to fill a 24-bit \ref USB_Audio_SampleFreq_t structure with the given sample rate as a 24-bit number. | ||
| 197 | * | ||
| 198 | * \param[in] freq Required audio sampling frequency in HZ | ||
| 199 | */ | ||
| 200 | #define AUDIO_SAMPLE_FREQ(freq) {.Byte1 = ((uint32_t)freq & 0xFF), .Byte2 = (((uint32_t)freq >> 8) & 0xFF), .Byte3 = (((uint32_t)freq >> 16) & 0xFF)} | ||
| 201 | |||
| 202 | /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint | ||
| 203 | * accepts only filled endpoint packets of audio samples. | ||
| 204 | */ | ||
| 205 | #define AUDIO_EP_FULL_PACKETS_ONLY (1 << 7) | ||
| 206 | |||
| 207 | /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint | ||
| 208 | * will accept partially filled endpoint packets of audio samples. | ||
| 209 | */ | ||
| 210 | #define AUDIO_EP_ACCEPTS_SMALL_PACKETS (0 << 7) | ||
| 211 | |||
| 212 | /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint | ||
| 213 | * allows for sampling frequency adjustments to be made via control requests directed at the endpoint. | ||
| 214 | */ | ||
| 215 | #define AUDIO_EP_SAMPLE_FREQ_CONTROL (1 << 0) | ||
| 216 | |||
| 217 | /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint | ||
| 218 | * allows for pitch adjustments to be made via control requests directed at the endpoint. | ||
| 219 | */ | ||
| 220 | #define AUDIO_EP_PITCH_CONTROL (1 << 1) | ||
| 221 | |||
| 222 | /* Enums: */ | ||
| 223 | /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the Audio | ||
| 224 | * device class. | ||
| 225 | */ | ||
| 226 | enum Audio_Descriptor_ClassSubclassProtocol_t | ||
| 227 | { | ||
| 228 | AUDIO_CSCP_AudioClass = 0x01, /**< Descriptor Class value indicating that the device or | ||
| 229 | * interface belongs to the USB Audio 1.0 class. | ||
| 230 | */ | ||
| 231 | AUDIO_CSCP_ControlSubclass = 0x01, /**< Descriptor Subclass value indicating that the device or | ||
| 232 | * interface belongs to the Audio Control subclass. | ||
| 233 | */ | ||
| 234 | AUDIO_CSCP_ControlProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or | ||
| 235 | * interface belongs to the Audio Control protocol. | ||
| 236 | */ | ||
| 237 | AUDIO_CSCP_AudioStreamingSubclass = 0x02, /**< Descriptor Subclass value indicating that the device or | ||
| 238 | * interface belongs to the MIDI Streaming subclass. | ||
| 239 | */ | ||
| 240 | AUDIO_CSCP_MIDIStreamingSubclass = 0x03, /**< Descriptor Subclass value indicating that the device or | ||
| 241 | * interface belongs to the Audio streaming subclass. | ||
| 242 | */ | ||
| 243 | AUDIO_CSCP_StreamingProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or | ||
| 244 | * interface belongs to the Streaming Audio protocol. | ||
| 245 | */ | ||
| 246 | }; | ||
| 247 | |||
| 248 | /** Audio class specific interface description subtypes, for the Audio Control interface. */ | ||
| 249 | enum Audio_CSInterface_AC_SubTypes_t | ||
| 250 | { | ||
| 251 | AUDIO_DSUBTYPE_CSInterface_Header = 0x01, /**< Audio class specific control interface header. */ | ||
| 252 | AUDIO_DSUBTYPE_CSInterface_InputTerminal = 0x02, /**< Audio class specific control interface Input Terminal. */ | ||
| 253 | AUDIO_DSUBTYPE_CSInterface_OutputTerminal = 0x03, /**< Audio class specific control interface Output Terminal. */ | ||
| 254 | AUDIO_DSUBTYPE_CSInterface_Mixer = 0x04, /**< Audio class specific control interface Mixer Unit. */ | ||
| 255 | AUDIO_DSUBTYPE_CSInterface_Selector = 0x05, /**< Audio class specific control interface Selector Unit. */ | ||
| 256 | AUDIO_DSUBTYPE_CSInterface_Feature = 0x06, /**< Audio class specific control interface Feature Unit. */ | ||
| 257 | AUDIO_DSUBTYPE_CSInterface_Processing = 0x07, /**< Audio class specific control interface Processing Unit. */ | ||
| 258 | AUDIO_DSUBTYPE_CSInterface_Extension = 0x08, /**< Audio class specific control interface Extension Unit. */ | ||
| 259 | }; | ||
| 260 | |||
| 261 | /** Audio class specific interface description subtypes, for the Audio Streaming interface. */ | ||
| 262 | enum Audio_CSInterface_AS_SubTypes_t | ||
| 263 | { | ||
| 264 | AUDIO_DSUBTYPE_CSInterface_General = 0x01, /**< Audio class specific streaming interface general descriptor. */ | ||
| 265 | AUDIO_DSUBTYPE_CSInterface_FormatType = 0x02, /**< Audio class specific streaming interface format type descriptor. */ | ||
| 266 | AUDIO_DSUBTYPE_CSInterface_FormatSpecific = 0x03, /**< Audio class specific streaming interface format information descriptor. */ | ||
| 267 | }; | ||
| 268 | |||
| 269 | /** Audio class specific endpoint description subtypes, for the Audio Streaming interface. */ | ||
| 270 | enum Audio_CSEndpoint_SubTypes_t | ||
| 271 | { | ||
| 272 | AUDIO_DSUBTYPE_CSEndpoint_General = 0x01, /**< Audio class specific endpoint general descriptor. */ | ||
| 273 | }; | ||
| 274 | |||
| 275 | /** Enum for the Audio class specific control requests that can be issued by the USB bus host. */ | ||
| 276 | enum Audio_ClassRequests_t | ||
| 277 | { | ||
| 278 | AUDIO_REQ_SetCurrent = 0x01, /**< Audio class-specific request to set the current value of a parameter within the device. */ | ||
| 279 | AUDIO_REQ_SetMinimum = 0x02, /**< Audio class-specific request to set the minimum value of a parameter within the device. */ | ||
| 280 | AUDIO_REQ_SetMaximum = 0x03, /**< Audio class-specific request to set the maximum value of a parameter within the device. */ | ||
| 281 | AUDIO_REQ_SetResolution = 0x04, /**< Audio class-specific request to set the resolution value of a parameter within the device. */ | ||
| 282 | AUDIO_REQ_SetMemory = 0x05, /**< Audio class-specific request to set the memory value of a parameter within the device. */ | ||
| 283 | AUDIO_REQ_GetCurrent = 0x81, /**< Audio class-specific request to get the current value of a parameter within the device. */ | ||
| 284 | AUDIO_REQ_GetMinimum = 0x82, /**< Audio class-specific request to get the minimum value of a parameter within the device. */ | ||
| 285 | AUDIO_REQ_GetMaximum = 0x83, /**< Audio class-specific request to get the maximum value of a parameter within the device. */ | ||
| 286 | AUDIO_REQ_GetResolution = 0x84, /**< Audio class-specific request to get the resolution value of a parameter within the device. */ | ||
| 287 | AUDIO_REQ_GetMemory = 0x85, /**< Audio class-specific request to get the memory value of a parameter within the device. */ | ||
| 288 | AUDIO_REQ_GetStatus = 0xFF, /**< Audio class-specific request to get the device status. */ | ||
| 289 | }; | ||
| 290 | |||
| 291 | /** Enum for Audio class specific Endpoint control modifiers which can be set and retrieved by a USB host, if the corresponding | ||
| 292 | * endpoint control is indicated to be supported in the Endpoint's Audio-class specific endpoint descriptor. | ||
| 293 | */ | ||
| 294 | enum Audio_EndpointControls_t | ||
| 295 | { | ||
| 296 | AUDIO_EPCONTROL_SamplingFreq = 0x01, /**< Sampling frequency adjustment of the endpoint. */ | ||
| 297 | AUDIO_EPCONTROL_Pitch = 0x02, /**< Pitch adjustment of the endpoint. */ | ||
| 298 | }; | ||
| 299 | |||
| 300 | /* Type Defines: */ | ||
| 301 | /** \brief Audio class-specific Input Terminal Descriptor (LUFA naming conventions). | ||
| 302 | * | ||
| 303 | * Type define for an Audio class-specific input terminal descriptor. This indicates to the host that the device | ||
| 304 | * contains an input audio source, either from a physical terminal on the device, or a logical terminal (for example, | ||
| 305 | * a USB endpoint). See the USB Audio specification for more details. | ||
| 306 | * | ||
| 307 | * \see \ref USB_Audio_StdDescriptor_InputTerminal_t for the version of this type with standard element names. | ||
| 308 | * | ||
| 309 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 310 | */ | ||
| 311 | typedef struct | ||
| 312 | { | ||
| 313 | USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ | ||
| 314 | uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 315 | * must be \ref AUDIO_DSUBTYPE_CSInterface_InputTerminal. | ||
| 316 | */ | ||
| 317 | |||
| 318 | uint8_t TerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */ | ||
| 319 | uint16_t TerminalType; /**< Type of terminal, a \c TERMINAL_* mask. */ | ||
| 320 | uint8_t AssociatedOutputTerminal; /**< ID of associated output terminal, for physically grouped terminals | ||
| 321 | * such as the speaker and microphone of a phone handset. | ||
| 322 | */ | ||
| 323 | uint8_t TotalChannels; /**< Total number of separate audio channels within this interface (right, left, etc.) */ | ||
| 324 | uint16_t ChannelConfig; /**< \c CHANNEL_* masks indicating what channel layout is supported by this terminal. */ | ||
| 325 | |||
| 326 | uint8_t ChannelStrIndex; /**< Index of a string descriptor describing this channel within the device. */ | ||
| 327 | uint8_t TerminalStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */ | ||
| 328 | } ATTR_PACKED USB_Audio_Descriptor_InputTerminal_t; | ||
| 329 | |||
| 330 | /** \brief Audio class-specific Input Terminal Descriptor (USB-IF naming conventions). | ||
| 331 | * | ||
| 332 | * Type define for an Audio class-specific input terminal descriptor. This indicates to the host that the device | ||
| 333 | * contains an input audio source, either from a physical terminal on the device, or a logical terminal (for example, | ||
| 334 | * a USB endpoint). See the USB Audio specification for more details. | ||
| 335 | * | ||
| 336 | * \see \ref USB_Audio_Descriptor_InputTerminal_t for the version of this type with non-standard LUFA specific | ||
| 337 | * element names. | ||
| 338 | * | ||
| 339 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 340 | */ | ||
| 341 | typedef struct | ||
| 342 | { | ||
| 343 | uint8_t bLength; /**< Size of the descriptor, in bytes. */ | ||
| 344 | uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value | ||
| 345 | * given by the specific class. | ||
| 346 | */ | ||
| 347 | |||
| 348 | uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 349 | * must be \ref AUDIO_DSUBTYPE_CSInterface_InputTerminal. | ||
| 350 | */ | ||
| 351 | uint8_t bTerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */ | ||
| 352 | uint16_t wTerminalType; /**< Type of terminal, a \c TERMINAL_* mask. */ | ||
| 353 | uint8_t bAssocTerminal; /**< ID of associated output terminal, for physically grouped terminals | ||
| 354 | * such as the speaker and microphone of a phone handset. | ||
| 355 | */ | ||
| 356 | uint8_t bNrChannels; /**< Total number of separate audio channels within this interface (right, left, etc.) */ | ||
| 357 | uint16_t wChannelConfig; /**< \c CHANNEL_* masks indicating what channel layout is supported by this terminal. */ | ||
| 358 | |||
| 359 | uint8_t iChannelNames; /**< Index of a string descriptor describing this channel within the device. */ | ||
| 360 | uint8_t iTerminal; /**< Index of a string descriptor describing this descriptor within the device. */ | ||
| 361 | } ATTR_PACKED USB_Audio_StdDescriptor_InputTerminal_t; | ||
| 362 | |||
| 363 | /** \brief Audio class-specific Output Terminal Descriptor (LUFA naming conventions). | ||
| 364 | * | ||
| 365 | * Type define for an Audio class-specific output terminal descriptor. This indicates to the host that the device | ||
| 366 | * contains an output audio sink, either to a physical terminal on the device, or a logical terminal (for example, | ||
| 367 | * a USB endpoint). See the USB Audio specification for more details. | ||
| 368 | * | ||
| 369 | * \see \ref USB_Audio_StdDescriptor_OutputTerminal_t for the version of this type with standard element names. | ||
| 370 | * | ||
| 371 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 372 | */ | ||
| 373 | typedef struct | ||
| 374 | { | ||
| 375 | USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ | ||
| 376 | uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 377 | * must be \ref AUDIO_DSUBTYPE_CSInterface_OutputTerminal. | ||
| 378 | */ | ||
| 379 | |||
| 380 | uint8_t TerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */ | ||
| 381 | uint16_t TerminalType; /**< Type of terminal, a \c TERMINAL_* mask. */ | ||
| 382 | uint8_t AssociatedInputTerminal; /**< ID of associated input terminal, for physically grouped terminals | ||
| 383 | * such as the speaker and microphone of a phone handset. | ||
| 384 | */ | ||
| 385 | uint8_t SourceID; /**< ID value of the unit this terminal's audio is sourced from. */ | ||
| 386 | |||
| 387 | uint8_t TerminalStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */ | ||
| 388 | } ATTR_PACKED USB_Audio_Descriptor_OutputTerminal_t; | ||
| 389 | |||
| 390 | /** \brief Audio class-specific Output Terminal Descriptor (USB-IF naming conventions). | ||
| 391 | * | ||
| 392 | * Type define for an Audio class-specific output terminal descriptor. This indicates to the host that the device | ||
| 393 | * contains an output audio sink, either to a physical terminal on the device, or a logical terminal (for example, | ||
| 394 | * a USB endpoint). See the USB Audio specification for more details. | ||
| 395 | * | ||
| 396 | * \see \ref USB_Audio_Descriptor_OutputTerminal_t for the version of this type with non-standard LUFA specific | ||
| 397 | * element names. | ||
| 398 | * | ||
| 399 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 400 | */ | ||
| 401 | typedef struct | ||
| 402 | { | ||
| 403 | uint8_t bLength; /**< Size of the descriptor, in bytes. */ | ||
| 404 | uint8_t bDescriptorType; /**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 405 | * must be \ref AUDIO_DSUBTYPE_CSInterface_OutputTerminal. | ||
| 406 | */ | ||
| 407 | |||
| 408 | uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 409 | * a value from the \ref Audio_CSInterface_AC_SubTypes_t enum. | ||
| 410 | */ | ||
| 411 | uint8_t bTerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */ | ||
| 412 | uint16_t wTerminalType; /**< Type of terminal, a \c TERMINAL_* mask. */ | ||
| 413 | uint8_t bAssocTerminal; /**< ID of associated input terminal, for physically grouped terminals | ||
| 414 | * such as the speaker and microphone of a phone handset. | ||
| 415 | */ | ||
| 416 | uint8_t bSourceID; /**< ID value of the unit this terminal's audio is sourced from. */ | ||
| 417 | |||
| 418 | uint8_t iTerminal; /**< Index of a string descriptor describing this descriptor within the device. */ | ||
| 419 | } ATTR_PACKED USB_Audio_StdDescriptor_OutputTerminal_t; | ||
| 420 | |||
| 421 | /** \brief Audio class-specific Interface Descriptor (LUFA naming conventions). | ||
| 422 | * | ||
| 423 | * Type define for an Audio class-specific interface descriptor. This follows a regular interface descriptor to | ||
| 424 | * supply extra information about the audio device's layout to the host. See the USB Audio specification for more | ||
| 425 | * details. | ||
| 426 | * | ||
| 427 | * \see \ref USB_Audio_StdDescriptor_Interface_AC_t for the version of this type with standard element names. | ||
| 428 | * | ||
| 429 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 430 | */ | ||
| 431 | typedef struct | ||
| 432 | { | ||
| 433 | USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ | ||
| 434 | uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 435 | * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum. | ||
| 436 | */ | ||
| 437 | |||
| 438 | uint16_t ACSpecification; /**< Binary Coded Decimal value, indicating the supported Audio Class specification version. | ||
| 439 | * | ||
| 440 | * \see \ref VERSION_BCD() utility macro. | ||
| 441 | */ | ||
| 442 | uint16_t TotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */ | ||
| 443 | |||
| 444 | uint8_t InCollection; /**< Total number of Audio Streaming interfaces linked to this Audio Control interface (must be 1). */ | ||
| 445 | uint8_t InterfaceNumber; /**< Interface number of the associated Audio Streaming interface. */ | ||
| 446 | } ATTR_PACKED USB_Audio_Descriptor_Interface_AC_t; | ||
| 447 | |||
| 448 | /** \brief Audio class-specific Interface Descriptor (USB-IF naming conventions). | ||
| 449 | * | ||
| 450 | * Type define for an Audio class-specific interface descriptor. This follows a regular interface descriptor to | ||
| 451 | * supply extra information about the audio device's layout to the host. See the USB Audio specification for more | ||
| 452 | * details. | ||
| 453 | * | ||
| 454 | * \see \ref USB_Audio_Descriptor_Interface_AC_t for the version of this type with non-standard LUFA specific | ||
| 455 | * element names. | ||
| 456 | * | ||
| 457 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 458 | */ | ||
| 459 | typedef struct | ||
| 460 | { | ||
| 461 | uint8_t bLength; /**< Size of the descriptor, in bytes. */ | ||
| 462 | uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value | ||
| 463 | * given by the specific class. | ||
| 464 | */ | ||
| 465 | |||
| 466 | uint8_t bDescriptorSubtype;/**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 467 | * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum. | ||
| 468 | */ | ||
| 469 | |||
| 470 | uint16_t bcdADC; /**< Binary coded decimal value, indicating the supported Audio Class specification version. | ||
| 471 | * | ||
| 472 | * \see \ref VERSION_BCD() utility macro. | ||
| 473 | */ | ||
| 474 | uint16_t wTotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */ | ||
| 475 | |||
| 476 | uint8_t bInCollection; /**< Total number of Audio Streaming interfaces linked to this Audio Control interface (must be 1). */ | ||
| 477 | uint8_t bInterfaceNumbers; /**< Interface number of the associated Audio Streaming interface. */ | ||
| 478 | } ATTR_PACKED USB_Audio_StdDescriptor_Interface_AC_t; | ||
| 479 | |||
| 480 | /** \brief Audio class-specific Feature Unit Descriptor (LUFA naming conventions). | ||
| 481 | * | ||
| 482 | * Type define for an Audio class-specific Feature Unit descriptor. This indicates to the host what features | ||
| 483 | * are present in the device's audio stream for basic control, such as per-channel volume. See the USB Audio | ||
| 484 | * specification for more details. | ||
| 485 | * | ||
| 486 | * \see \ref USB_Audio_StdDescriptor_FeatureUnit_t for the version of this type with standard element names. | ||
| 487 | * | ||
| 488 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 489 | */ | ||
| 490 | typedef struct | ||
| 491 | { | ||
| 492 | USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ | ||
| 493 | uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 494 | * must be \ref AUDIO_DSUBTYPE_CSInterface_Feature. | ||
| 495 | */ | ||
| 496 | |||
| 497 | uint8_t UnitID; /**< ID value of this feature unit - must be a unique value within the device. */ | ||
| 498 | uint8_t SourceID; /**< Source ID value of the audio source input into this feature unit. */ | ||
| 499 | |||
| 500 | uint8_t ControlSize; /**< Size of each element in the \c ChannelControls array. */ | ||
| 501 | uint8_t ChannelControls[3]; /**< Feature masks for the control channel, and each separate audio channel. */ | ||
| 502 | |||
| 503 | uint8_t FeatureUnitStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */ | ||
| 504 | } ATTR_PACKED USB_Audio_Descriptor_FeatureUnit_t; | ||
| 505 | |||
| 506 | /** \brief Audio class-specific Feature Unit Descriptor (USB-IF naming conventions). | ||
| 507 | * | ||
| 508 | * Type define for an Audio class-specific Feature Unit descriptor. This indicates to the host what features | ||
| 509 | * are present in the device's audio stream for basic control, such as per-channel volume. See the USB Audio | ||
| 510 | * specification for more details. | ||
| 511 | * | ||
| 512 | * \see \ref USB_Audio_Descriptor_FeatureUnit_t for the version of this type with non-standard LUFA specific | ||
| 513 | * element names. | ||
| 514 | * | ||
| 515 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 516 | */ | ||
| 517 | typedef struct | ||
| 518 | { | ||
| 519 | uint8_t bLength; /**< Size of the descriptor, in bytes. */ | ||
| 520 | uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value | ||
| 521 | * given by the specific class. | ||
| 522 | */ | ||
| 523 | |||
| 524 | uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 525 | * must be \ref AUDIO_DSUBTYPE_CSInterface_Feature. | ||
| 526 | */ | ||
| 527 | |||
| 528 | uint8_t bUnitID; /**< ID value of this feature unit - must be a unique value within the device. */ | ||
| 529 | uint8_t bSourceID; /**< Source ID value of the audio source input into this feature unit. */ | ||
| 530 | |||
| 531 | uint8_t bControlSize; /**< Size of each element in the \c ChannelControls array. */ | ||
| 532 | uint8_t bmaControls[3]; /**< Feature masks for the control channel, and each separate audio channel. */ | ||
| 533 | |||
| 534 | uint8_t iFeature; /**< Index of a string descriptor describing this descriptor within the device. */ | ||
| 535 | } ATTR_PACKED USB_Audio_StdDescriptor_FeatureUnit_t; | ||
| 536 | |||
| 537 | /** \brief Audio class-specific Streaming Audio Interface Descriptor (LUFA naming conventions). | ||
| 538 | * | ||
| 539 | * Type define for an Audio class-specific streaming interface descriptor. This indicates to the host | ||
| 540 | * how audio streams within the device are formatted. See the USB Audio specification for more details. | ||
| 541 | * | ||
| 542 | * \see \ref USB_Audio_StdDescriptor_Interface_AS_t for the version of this type with standard element names. | ||
| 543 | * | ||
| 544 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 545 | */ | ||
| 546 | typedef struct | ||
| 547 | { | ||
| 548 | USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ | ||
| 549 | uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 550 | * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum. | ||
| 551 | */ | ||
| 552 | |||
| 553 | uint8_t TerminalLink; /**< ID value of the output terminal this descriptor is describing. */ | ||
| 554 | |||
| 555 | uint8_t FrameDelay; /**< Delay in frames resulting from the complete sample processing from input to output. */ | ||
| 556 | uint16_t AudioFormat; /**< Format of the audio stream, see Audio Device Formats specification. */ | ||
| 557 | } ATTR_PACKED USB_Audio_Descriptor_Interface_AS_t; | ||
| 558 | |||
| 559 | /** \brief Audio class-specific Streaming Audio Interface Descriptor (USB-IF naming conventions). | ||
| 560 | * | ||
| 561 | * Type define for an Audio class-specific streaming interface descriptor. This indicates to the host | ||
| 562 | * how audio streams within the device are formatted. See the USB Audio specification for more details. | ||
| 563 | * | ||
| 564 | * \see \ref USB_Audio_Descriptor_Interface_AS_t for the version of this type with non-standard LUFA specific | ||
| 565 | * element names. | ||
| 566 | * | ||
| 567 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 568 | */ | ||
| 569 | typedef struct | ||
| 570 | { | ||
| 571 | uint8_t bLength; /**< Size of the descriptor, in bytes. */ | ||
| 572 | uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value | ||
| 573 | * given by the specific class. | ||
| 574 | */ | ||
| 575 | |||
| 576 | uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 577 | * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum. | ||
| 578 | */ | ||
| 579 | |||
| 580 | uint8_t bTerminalLink; /**< ID value of the output terminal this descriptor is describing. */ | ||
| 581 | |||
| 582 | uint8_t bDelay; /**< Delay in frames resulting from the complete sample processing from input to output. */ | ||
| 583 | uint16_t wFormatTag; /**< Format of the audio stream, see Audio Device Formats specification. */ | ||
| 584 | } ATTR_PACKED USB_Audio_StdDescriptor_Interface_AS_t; | ||
| 585 | |||
| 586 | /** \brief Audio class-specific Format Descriptor (LUFA naming conventions). | ||
| 587 | * | ||
| 588 | * Type define for an Audio class-specific audio format descriptor. This is used to give the host full details | ||
| 589 | * about the number of channels, the sample resolution, acceptable sample frequencies and encoding method used | ||
| 590 | * in the device's audio streams. See the USB Audio specification for more details. | ||
| 591 | * | ||
| 592 | * \attention This descriptor <b>must</b> be followed by one or more \ref USB_Audio_SampleFreq_t elements containing | ||
| 593 | * the continuous or discrete sample frequencies. | ||
| 594 | * | ||
| 595 | * \see \ref USB_Audio_StdDescriptor_Format_t for the version of this type with standard element names. | ||
| 596 | * | ||
| 597 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 598 | */ | ||
| 599 | typedef struct | ||
| 600 | { | ||
| 601 | USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ | ||
| 602 | uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 603 | * must be \ref AUDIO_DSUBTYPE_CSInterface_FormatType. | ||
| 604 | */ | ||
| 605 | |||
| 606 | uint8_t FormatType; /**< Format of the audio stream, see Audio Device Formats specification. */ | ||
| 607 | uint8_t Channels; /**< Total number of discrete channels in the stream. */ | ||
| 608 | |||
| 609 | uint8_t SubFrameSize; /**< Size in bytes of each channel's sample data in the stream. */ | ||
| 610 | uint8_t BitResolution; /**< Bits of resolution of each channel's samples in the stream. */ | ||
| 611 | |||
| 612 | uint8_t TotalDiscreteSampleRates; /**< Total number of discrete sample frequencies supported by the device. When | ||
| 613 | * zero, this must be followed by the lower and upper continuous sampling | ||
| 614 | * frequencies supported by the device; otherwise, this must be followed | ||
| 615 | * by the given number of discrete sampling frequencies supported. | ||
| 616 | */ | ||
| 617 | } ATTR_PACKED USB_Audio_Descriptor_Format_t; | ||
| 618 | |||
| 619 | /** \brief 24-Bit Audio Frequency Structure. | ||
| 620 | * | ||
| 621 | * Type define for a 24-bit audio sample frequency structure. As GCC does not contain a built in 24-bit datatype, | ||
| 622 | * this this structure is used to build up the value instead. Fill this structure with the \ref AUDIO_SAMPLE_FREQ() macro. | ||
| 623 | * | ||
| 624 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 625 | */ | ||
| 626 | typedef struct | ||
| 627 | { | ||
| 628 | uint8_t Byte1; /**< Lowest 8 bits of the 24-bit value. */ | ||
| 629 | uint8_t Byte2; /**< Middle 8 bits of the 24-bit value. */ | ||
| 630 | uint8_t Byte3; /**< Upper 8 bits of the 24-bit value. */ | ||
| 631 | } ATTR_PACKED USB_Audio_SampleFreq_t; | ||
| 632 | |||
| 633 | /** \brief Audio class-specific Format Descriptor (USB-IF naming conventions). | ||
| 634 | * | ||
| 635 | * Type define for an Audio class-specific audio format descriptor. This is used to give the host full details | ||
| 636 | * about the number of channels, the sample resolution, acceptable sample frequencies and encoding method used | ||
| 637 | * in the device's audio streams. See the USB Audio specification for more details. | ||
| 638 | * | ||
| 639 | * \attention This descriptor <b>must</b> be followed by one or more 24-bit integer elements containing the continuous | ||
| 640 | * or discrete sample frequencies. | ||
| 641 | * | ||
| 642 | * \see \ref USB_Audio_Descriptor_Format_t for the version of this type with non-standard LUFA specific | ||
| 643 | * element names. | ||
| 644 | * | ||
| 645 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 646 | */ | ||
| 647 | typedef struct | ||
| 648 | { | ||
| 649 | uint8_t bLength; /**< Size of the descriptor, in bytes. */ | ||
| 650 | uint8_t bDescriptorType; /**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 651 | * must be \ref AUDIO_DSUBTYPE_CSInterface_FormatType. | ||
| 652 | */ | ||
| 653 | |||
| 654 | uint8_t bDescriptorSubtype;/**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 655 | * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum. | ||
| 656 | */ | ||
| 657 | |||
| 658 | uint8_t bFormatType; /**< Format of the audio stream, see Audio Device Formats specification. */ | ||
| 659 | uint8_t bNrChannels; /**< Total number of discrete channels in the stream. */ | ||
| 660 | |||
| 661 | uint8_t bSubFrameSize; /**< Size in bytes of each channel's sample data in the stream. */ | ||
| 662 | uint8_t bBitResolution; /**< Bits of resolution of each channel's samples in the stream. */ | ||
| 663 | |||
| 664 | uint8_t bSampleFrequencyType; /**< Total number of sample frequencies supported by the device. When | ||
| 665 | * zero, this must be followed by the lower and upper continuous sampling | ||
| 666 | * frequencies supported by the device; otherwise, this must be followed | ||
| 667 | * by the given number of discrete sampling frequencies supported. | ||
| 668 | */ | ||
| 669 | } ATTR_PACKED USB_Audio_StdDescriptor_Format_t; | ||
| 670 | |||
| 671 | /** \brief Audio class-specific Streaming Endpoint Descriptor (LUFA naming conventions). | ||
| 672 | * | ||
| 673 | * Type define for an Audio class-specific endpoint descriptor. This contains a regular endpoint | ||
| 674 | * descriptor with a few Audio-class-specific extensions. See the USB Audio specification for more details. | ||
| 675 | * | ||
| 676 | * \see \ref USB_Audio_StdDescriptor_StreamEndpoint_Std_t for the version of this type with standard element names. | ||
| 677 | * | ||
| 678 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 679 | */ | ||
| 680 | typedef struct | ||
| 681 | { | ||
| 682 | USB_Descriptor_Endpoint_t Endpoint; /**< Standard endpoint descriptor describing the audio endpoint. */ | ||
| 683 | |||
| 684 | uint8_t Refresh; /**< Always set to zero for Audio class devices. */ | ||
| 685 | uint8_t SyncEndpointNumber; /**< Endpoint address to send synchronization information to, if needed (zero otherwise). */ | ||
| 686 | } ATTR_PACKED USB_Audio_Descriptor_StreamEndpoint_Std_t; | ||
| 687 | |||
| 688 | /** \brief Audio class-specific Streaming Endpoint Descriptor (USB-IF naming conventions). | ||
| 689 | * | ||
| 690 | * Type define for an Audio class-specific endpoint descriptor. This contains a regular endpoint | ||
| 691 | * descriptor with a few Audio-class-specific extensions. See the USB Audio specification for more details. | ||
| 692 | * | ||
| 693 | * \see \ref USB_Audio_Descriptor_StreamEndpoint_Std_t for the version of this type with non-standard LUFA specific | ||
| 694 | * element names. | ||
| 695 | * | ||
| 696 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 697 | */ | ||
| 698 | typedef struct | ||
| 699 | { | ||
| 700 | uint8_t bLength; /**< Size of the descriptor, in bytes. */ | ||
| 701 | uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a | ||
| 702 | * value given by the specific class. | ||
| 703 | */ | ||
| 704 | uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current | ||
| 705 | * configuration, including direction mask. | ||
| 706 | */ | ||
| 707 | uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (\c EP_TYPE_*) | ||
| 708 | * and attributes (\c ENDPOINT_ATTR_*) masks. | ||
| 709 | */ | ||
| 710 | uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size | ||
| 711 | * that the endpoint can receive at a time. | ||
| 712 | */ | ||
| 713 | uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or | ||
| 714 | * ISOCHRONOUS type. | ||
| 715 | */ | ||
| 716 | |||
| 717 | uint8_t bRefresh; /**< Always set to zero for Audio class devices. */ | ||
| 718 | uint8_t bSynchAddress; /**< Endpoint address to send synchronization information to, if needed (zero otherwise). */ | ||
| 719 | } ATTR_PACKED USB_Audio_StdDescriptor_StreamEndpoint_Std_t; | ||
| 720 | |||
| 721 | /** \brief Audio class-specific Extended Endpoint Descriptor (LUFA naming conventions). | ||
| 722 | * | ||
| 723 | * Type define for an Audio class-specific extended endpoint descriptor. This contains extra information | ||
| 724 | * on the usage of endpoints used to stream audio in and out of the USB Audio device, and follows an Audio | ||
| 725 | * class-specific extended endpoint descriptor. See the USB Audio specification for more details. | ||
| 726 | * | ||
| 727 | * \see \ref USB_Audio_StdDescriptor_StreamEndpoint_Spc_t for the version of this type with standard element names. | ||
| 728 | * | ||
| 729 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 730 | */ | ||
| 731 | typedef struct | ||
| 732 | { | ||
| 733 | USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ | ||
| 734 | uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 735 | * a value from the \ref Audio_CSEndpoint_SubTypes_t enum. | ||
| 736 | */ | ||
| 737 | |||
| 738 | uint8_t Attributes; /**< Audio class-specific endpoint attributes, such as \ref AUDIO_EP_FULL_PACKETS_ONLY. */ | ||
| 739 | |||
| 740 | uint8_t LockDelayUnits; /**< Units used for the LockDelay field, see Audio class specification. */ | ||
| 741 | uint16_t LockDelay; /**< Time required to internally lock endpoint's internal clock recovery circuitry. */ | ||
| 742 | } ATTR_PACKED USB_Audio_Descriptor_StreamEndpoint_Spc_t; | ||
| 743 | |||
| 744 | /** \brief Audio class-specific Extended Endpoint Descriptor (USB-IF naming conventions). | ||
| 745 | * | ||
| 746 | * Type define for an Audio class-specific extended endpoint descriptor. This contains extra information | ||
| 747 | * on the usage of endpoints used to stream audio in and out of the USB Audio device, and follows an Audio | ||
| 748 | * class-specific extended endpoint descriptor. See the USB Audio specification for more details. | ||
| 749 | * | ||
| 750 | * \see \ref USB_Audio_Descriptor_StreamEndpoint_Spc_t for the version of this type with non-standard LUFA specific | ||
| 751 | * element names. | ||
| 752 | * | ||
| 753 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 754 | */ | ||
| 755 | typedef struct | ||
| 756 | { | ||
| 757 | uint8_t bLength; /**< Size of the descriptor, in bytes. */ | ||
| 758 | uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value | ||
| 759 | * given by the specific class. | ||
| 760 | */ | ||
| 761 | |||
| 762 | uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors, | ||
| 763 | * a value from the \ref Audio_CSEndpoint_SubTypes_t enum. | ||
| 764 | */ | ||
| 765 | |||
| 766 | uint8_t bmAttributes; /**< Audio class-specific endpoint attributes, such as \ref AUDIO_EP_FULL_PACKETS_ONLY. */ | ||
| 767 | |||
| 768 | uint8_t bLockDelayUnits; /**< Units used for the LockDelay field, see Audio class specification. */ | ||
| 769 | uint16_t wLockDelay; /**< Time required to internally lock endpoint's internal clock recovery circuitry. */ | ||
| 770 | } ATTR_PACKED USB_Audio_StdDescriptor_StreamEndpoint_Spc_t; | ||
| 771 | |||
| 772 | /* Disable C linkage for C++ Compilers: */ | ||
| 773 | #if defined(__cplusplus) | ||
| 774 | } | ||
| 775 | #endif | ||
| 776 | |||
| 777 | #endif | ||
| 778 | |||
| 779 | /** @} */ | ||
| 780 | |||
diff --git a/lib/lufa/LUFA/Drivers/USB/Class/Common/CDCClassCommon.h b/lib/lufa/LUFA/Drivers/USB/Class/Common/CDCClassCommon.h new file mode 100644 index 000000000..1ad49eca1 --- /dev/null +++ b/lib/lufa/LUFA/Drivers/USB/Class/Common/CDCClassCommon.h | |||
| @@ -0,0 +1,391 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 12 | Permission to use, copy, modify, distribute, and sell this | ||
| 13 | software and its documentation for any purpose is hereby granted | ||
| 14 | without fee, provided that the above copyright notice appear in | ||
| 15 | all copies and that both that the copyright notice and this | ||
| 16 | permission notice and warranty disclaimer appear in supporting | ||
| 17 | documentation, and that the name of the author not be used in | ||
| 18 | advertising or publicity pertaining to distribution of the | ||
| 19 | software without specific, written prior permission. | ||
| 20 | |||
| 21 | The author disclaims all warranties with regard to this | ||
| 22 | software, including all implied warranties of merchantability | ||
| 23 | and fitness. In no event shall the author be liable for any | ||
| 24 | special, indirect or consequential damages or any damages | ||
| 25 | whatsoever resulting from loss of use, data or profits, whether | ||
| 26 | in an action of contract, negligence or other tortious action, | ||
| 27 | arising out of or in connection with the use or performance of | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | /** \file | ||
| 32 | * \brief Common definitions and declarations for the library USB CDC Class driver. | ||
| 33 | * | ||
| 34 | * Common definitions and declarations for the library USB CDC Class driver. | ||
| 35 | * | ||
| 36 | * \note This file should not be included directly. It is automatically included as needed by the USB module driver | ||
| 37 | * dispatch header located in LUFA/Drivers/USB.h. | ||
| 38 | */ | ||
| 39 | |||
| 40 | /** \ingroup Group_USBClassCDC | ||
| 41 | * \defgroup Group_USBClassCDCCommon Common Class Definitions | ||
| 42 | * | ||
| 43 | * \section Sec_USBClassCDCCommon_ModDescription Module Description | ||
| 44 | * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB | ||
| 45 | * CDC Class. | ||
| 46 | * | ||
| 47 | * @{ | ||
| 48 | */ | ||
| 49 | |||
| 50 | #ifndef _CDC_CLASS_COMMON_H_ | ||
| 51 | #define _CDC_CLASS_COMMON_H_ | ||
| 52 | |||
| 53 | /* Includes: */ | ||
| 54 | #include "../../Core/StdDescriptors.h" | ||
| 55 | |||
| 56 | /* Enable C linkage for C++ Compilers: */ | ||
| 57 | #if defined(__cplusplus) | ||
| 58 | extern "C" { | ||
| 59 | #endif | ||
| 60 | |||
| 61 | /* Preprocessor Checks: */ | ||
| 62 | #if !defined(__INCLUDE_FROM_CDC_DRIVER) | ||
| 63 | #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. | ||
| 64 | #endif | ||
| 65 | |||
| 66 | /* Macros: */ | ||
| 67 | /** \name Virtual Control Line Masks */ | ||
| 68 | //@{ | ||
| 69 | /** Mask for the DTR handshake line for use with the \ref CDC_REQ_SetControlLineState class-specific request | ||
| 70 | * from the host, to indicate that the DTR line state should be high. | ||
| 71 | */ | ||
| 72 | #define CDC_CONTROL_LINE_OUT_DTR (1 << 0) | ||
| 73 | |||
| 74 | /** Mask for the RTS handshake line for use with the \ref CDC_REQ_SetControlLineState class-specific request | ||
| 75 | * from the host, to indicate that the RTS line state should be high. | ||
| 76 | */ | ||
| 77 | #define CDC_CONTROL_LINE_OUT_RTS (1 << 1) | ||
| 78 | |||
| 79 | /** Mask for the DCD handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification | ||
| 80 | * from the device to the host, to indicate that the DCD line state is currently high. | ||
| 81 | */ | ||
| 82 | #define CDC_CONTROL_LINE_IN_DCD (1 << 0) | ||
| 83 | |||
| 84 | /** Mask for the DSR handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification | ||
| 85 | * from the device to the host, to indicate that the DSR line state is currently high. | ||
| 86 | */ | ||
| 87 | #define CDC_CONTROL_LINE_IN_DSR (1 << 1) | ||
| 88 | |||
| 89 | /** Mask for the BREAK handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification | ||
| 90 | * from the device to the host, to indicate that the BREAK line state is currently high. | ||
| 91 | */ | ||
| 92 | #define CDC_CONTROL_LINE_IN_BREAK (1 << 2) | ||
| 93 | |||
| 94 | /** Mask for the RING handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification | ||
| 95 | * from the device to the host, to indicate that the RING line state is currently high. | ||
| 96 | */ | ||
| 97 | #define CDC_CONTROL_LINE_IN_RING (1 << 3) | ||
| 98 | |||
| 99 | /** Mask for use with the \ref CDC_NOTIF_SerialState class-specific notification from the device to the host, | ||
| 100 | * to indicate that a framing error has occurred on the virtual serial port. | ||
| 101 | */ | ||
| 102 | #define CDC_CONTROL_LINE_IN_FRAMEERROR (1 << 4) | ||
| 103 | |||
| 104 | /** Mask for use with the \ref CDC_NOTIF_SerialState class-specific notification from the device to the host, | ||
| 105 | * to indicate that a parity error has occurred on the virtual serial port. | ||
| 106 | */ | ||
| 107 | #define CDC_CONTROL_LINE_IN_PARITYERROR (1 << 5) | ||
| 108 | |||
| 109 | /** Mask for use with the \ref CDC_NOTIF_SerialState class-specific notification from the device to the host, | ||
| 110 | * to indicate that a data overrun error has occurred on the virtual serial port. | ||
| 111 | */ | ||
| 112 | #define CDC_CONTROL_LINE_IN_OVERRUNERROR (1 << 6) | ||
| 113 | //@} | ||
| 114 | |||
| 115 | /** Macro to define a CDC class-specific functional descriptor. CDC functional descriptors have a | ||
| 116 | * uniform structure but variable sized data payloads, thus cannot be represented accurately by | ||
| 117 | * a single \c typedef \c struct. A macro is used instead so that functional descriptors can be created | ||
| 118 | * easily by specifying the size of the payload. This allows \c sizeof() to work correctly. | ||
| 119 | * | ||
| 120 | * \param[in] DataSize Size in bytes of the CDC functional descriptor's data payload. | ||
| 121 | */ | ||
| 122 | #define CDC_FUNCTIONAL_DESCRIPTOR(DataSize) \ | ||
| 123 | struct \ | ||
| 124 | { \ | ||
| 125 | USB_Descriptor_Header_t Header; \ | ||
| 126 | uint8_t SubType; \ | ||
| 127 | uint8_t Data[DataSize]; \ | ||
| 128 | } | ||
| 129 | |||
| 130 | /* Enums: */ | ||
| 131 | /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the CDC | ||
| 132 | * device class. | ||
| 133 | */ | ||
| 134 | enum CDC_Descriptor_ClassSubclassProtocol_t | ||
| 135 | { | ||
| 136 | CDC_CSCP_CDCClass = 0x02, /**< Descriptor Class value indicating that the device or interface | ||
| 137 | * belongs to the CDC class. | ||
| 138 | */ | ||
| 139 | CDC_CSCP_NoSpecificSubclass = 0x00, /**< Descriptor Subclass value indicating that the device or interface | ||
| 140 | * belongs to no specific subclass of the CDC class. | ||
| 141 | */ | ||
| 142 | CDC_CSCP_ACMSubclass = 0x02, /**< Descriptor Subclass value indicating that the device or interface | ||
| 143 | * belongs to the Abstract Control Model CDC subclass. | ||
| 144 | */ | ||
| 145 | CDC_CSCP_ATCommandProtocol = 0x01, /**< Descriptor Protocol value indicating that the device or interface | ||
| 146 | * belongs to the AT Command protocol of the CDC class. | ||
| 147 | */ | ||
| 148 | CDC_CSCP_NoSpecificProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface | ||
| 149 | * belongs to no specific protocol of the CDC class. | ||
| 150 | */ | ||
| 151 | CDC_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device or interface | ||
| 152 | * belongs to a vendor-specific protocol of the CDC class. | ||
| 153 | */ | ||
| 154 | CDC_CSCP_CDCDataClass = 0x0A, /**< Descriptor Class value indicating that the device or interface | ||
| 155 | * belongs to the CDC Data class. | ||
| 156 | */ | ||
| 157 | CDC_CSCP_NoDataSubclass = 0x00, /**< Descriptor Subclass value indicating that the device or interface | ||
| 158 | * belongs to no specific subclass of the CDC data class. | ||
| 159 | */ | ||
| 160 | CDC_CSCP_NoDataProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface | ||
| 161 | * belongs to no specific protocol of the CDC data class. | ||
| 162 | */ | ||
| 163 | }; | ||
| 164 | |||
| 165 | /** Enum for the CDC class specific control requests that can be issued by the USB bus host. */ | ||
| 166 | enum CDC_ClassRequests_t | ||
| 167 | { | ||
| 168 | CDC_REQ_SendEncapsulatedCommand = 0x00, /**< CDC class-specific request to send an encapsulated command to the device. */ | ||
| 169 | CDC_REQ_GetEncapsulatedResponse = 0x01, /**< CDC class-specific request to retrieve an encapsulated command response from the device. */ | ||
| 170 | CDC_REQ_SetLineEncoding = 0x20, /**< CDC class-specific request to set the current virtual serial port configuration settings. */ | ||
| 171 | CDC_REQ_GetLineEncoding = 0x21, /**< CDC class-specific request to get the current virtual serial port configuration settings. */ | ||
| 172 | CDC_REQ_SetControlLineState = 0x22, /**< CDC class-specific request to set the current virtual serial port handshake line states. */ | ||
| 173 | CDC_REQ_SendBreak = 0x23, /**< CDC class-specific request to send a break to the receiver via the carrier channel. */ | ||
| 174 | }; | ||
| 175 | |||
| 176 | /** Enum for the CDC class specific notification requests that can be issued by a CDC device to a host. */ | ||
| 177 | enum CDC_ClassNotifications_t | ||
| 178 | { | ||
| 179 | CDC_NOTIF_SerialState = 0x20, /**< Notification type constant for a change in the virtual serial port | ||
| 180 | * handshake line states, for use with a \ref USB_Request_Header_t | ||
| 181 | * notification structure when sent to the host via the CDC notification | ||
| 182 | * endpoint. | ||
| 183 | */ | ||
| 184 | }; | ||
| 185 | |||
| 186 | /** Enum for the CDC class specific interface descriptor subtypes. */ | ||
| 187 | enum CDC_DescriptorSubtypes_t | ||
| 188 | { | ||
| 189 | CDC_DSUBTYPE_CSInterface_Header = 0x00, /**< CDC class-specific Header functional descriptor. */ | ||
| 190 | CDC_DSUBTYPE_CSInterface_CallManagement = 0x01, /**< CDC class-specific Call Management functional descriptor. */ | ||
| 191 | CDC_DSUBTYPE_CSInterface_ACM = 0x02, /**< CDC class-specific Abstract Control Model functional descriptor. */ | ||
| 192 | CDC_DSUBTYPE_CSInterface_DirectLine = 0x03, /**< CDC class-specific Direct Line functional descriptor. */ | ||
| 193 | CDC_DSUBTYPE_CSInterface_TelephoneRinger = 0x04, /**< CDC class-specific Telephone Ringer functional descriptor. */ | ||
| 194 | CDC_DSUBTYPE_CSInterface_TelephoneCall = 0x05, /**< CDC class-specific Telephone Call functional descriptor. */ | ||
| 195 | CDC_DSUBTYPE_CSInterface_Union = 0x06, /**< CDC class-specific Union functional descriptor. */ | ||
| 196 | CDC_DSUBTYPE_CSInterface_CountrySelection = 0x07, /**< CDC class-specific Country Selection functional descriptor. */ | ||
| 197 | CDC_DSUBTYPE_CSInterface_TelephoneOpModes = 0x08, /**< CDC class-specific Telephone Operation Modes functional descriptor. */ | ||
| 198 | CDC_DSUBTYPE_CSInterface_USBTerminal = 0x09, /**< CDC class-specific USB Terminal functional descriptor. */ | ||
| 199 | CDC_DSUBTYPE_CSInterface_NetworkChannel = 0x0A, /**< CDC class-specific Network Channel functional descriptor. */ | ||
| 200 | CDC_DSUBTYPE_CSInterface_ProtocolUnit = 0x0B, /**< CDC class-specific Protocol Unit functional descriptor. */ | ||
| 201 | CDC_DSUBTYPE_CSInterface_ExtensionUnit = 0x0C, /**< CDC class-specific Extension Unit functional descriptor. */ | ||
| 202 | CDC_DSUBTYPE_CSInterface_MultiChannel = 0x0D, /**< CDC class-specific Multi-Channel Management functional descriptor. */ | ||
| 203 | CDC_DSUBTYPE_CSInterface_CAPI = 0x0E, /**< CDC class-specific Common ISDN API functional descriptor. */ | ||
| 204 | CDC_DSUBTYPE_CSInterface_Ethernet = 0x0F, /**< CDC class-specific Ethernet functional descriptor. */ | ||
| 205 | CDC_DSUBTYPE_CSInterface_ATM = 0x10, /**< CDC class-specific Asynchronous Transfer Mode functional descriptor. */ | ||
| 206 | }; | ||
| 207 | |||
| 208 | /** Enum for the possible line encoding formats of a virtual serial port. */ | ||
| 209 | enum CDC_LineEncodingFormats_t | ||
| 210 | { | ||
| 211 | CDC_LINEENCODING_OneStopBit = 0, /**< Each frame contains one stop bit. */ | ||
| 212 | CDC_LINEENCODING_OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits. */ | ||
| 213 | CDC_LINEENCODING_TwoStopBits = 2, /**< Each frame contains two stop bits. */ | ||
| 214 | }; | ||
| 215 | |||
| 216 | /** Enum for the possible line encoding parity settings of a virtual serial port. */ | ||
| 217 | enum CDC_LineEncodingParity_t | ||
| 218 | { | ||
| 219 | CDC_PARITY_None = 0, /**< No parity bit mode on each frame. */ | ||
| 220 | CDC_PARITY_Odd = 1, /**< Odd parity bit mode on each frame. */ | ||
| 221 | CDC_PARITY_Even = 2, /**< Even parity bit mode on each frame. */ | ||
| 222 | CDC_PARITY_Mark = 3, /**< Mark parity bit mode on each frame. */ | ||
| 223 | CDC_PARITY_Space = 4, /**< Space parity bit mode on each frame. */ | ||
| 224 | }; | ||
| 225 | |||
| 226 | /* Type Defines: */ | ||
| 227 | /** \brief CDC class-specific Functional Header Descriptor (LUFA naming conventions). | ||
| 228 | * | ||
| 229 | * Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device | ||
| 230 | * contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration. | ||
| 231 | * See the CDC class specification for more details. | ||
| 232 | * | ||
| 233 | * \see \ref USB_CDC_StdDescriptor_FunctionalHeader_t for the version of this type with standard element names. | ||
| 234 | * | ||
| 235 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 236 | */ | ||
| 237 | typedef struct | ||
| 238 | { | ||
| 239 | USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ | ||
| 240 | uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors, | ||
| 241 | * must be \ref CDC_DSUBTYPE_CSInterface_Header. | ||
| 242 | */ | ||
| 243 | uint16_t CDCSpecification; /**< Version number of the CDC specification implemented by the device, | ||
| 244 | * encoded in BCD format. | ||
| 245 | * | ||
| 246 | * \see \ref VERSION_BCD() utility macro. | ||
| 247 | */ | ||
| 248 | } ATTR_PACKED USB_CDC_Descriptor_FunctionalHeader_t; | ||
| 249 | |||
| 250 | /** \brief CDC class-specific Functional Header Descriptor (USB-IF naming conventions). | ||
| 251 | * | ||
| 252 | * Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device | ||
| 253 | * contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration. | ||
| 254 | * See the CDC class specification for more details. | ||
| 255 | * | ||
| 256 | * \see \ref USB_CDC_Descriptor_FunctionalHeader_t for the version of this type with non-standard LUFA specific | ||
| 257 | * element names. | ||
| 258 | * | ||
| 259 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 260 | */ | ||
| 261 | typedef struct | ||
| 262 | { | ||
| 263 | uint8_t bFunctionLength; /**< Size of the descriptor, in bytes. */ | ||
| 264 | uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value | ||
| 265 | * given by the specific class. | ||
| 266 | */ | ||
| 267 | uint8_t bDescriptorSubType; /**< Sub type value used to distinguish between CDC class-specific descriptors, | ||
| 268 | * must be \ref CDC_DSUBTYPE_CSInterface_Header. | ||
| 269 | */ | ||
| 270 | uint16_t bcdCDC; /**< Version number of the CDC specification implemented by the device, encoded in BCD format. | ||
| 271 | * | ||
| 272 | * \see \ref VERSION_BCD() utility macro. | ||
| 273 | */ | ||
| 274 | } ATTR_PACKED USB_CDC_StdDescriptor_FunctionalHeader_t; | ||
| 275 | |||
| 276 | /** \brief CDC class-specific Functional ACM Descriptor (LUFA naming conventions). | ||
| 277 | * | ||
| 278 | * Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface | ||
| 279 | * supports the CDC ACM subclass of the CDC specification. See the CDC class specification for more details. | ||
| 280 | * | ||
| 281 | * \see \ref USB_CDC_StdDescriptor_FunctionalACM_t for the version of this type with standard element names. | ||
| 282 | * | ||
| 283 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 284 | */ | ||
| 285 | typedef struct | ||
| 286 | { | ||
| 287 | USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ | ||
| 288 | uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors, | ||
| 289 | * must be \ref CDC_DSUBTYPE_CSInterface_ACM. | ||
| 290 | */ | ||
| 291 | uint8_t Capabilities; /**< Capabilities of the ACM interface, given as a bit mask. For most devices, | ||
| 292 | * this should be set to a fixed value of \c 0x06 - for other capabilities, refer | ||
| 293 | * to the CDC ACM specification. | ||
| 294 | */ | ||
| 295 | } ATTR_PACKED USB_CDC_Descriptor_FunctionalACM_t; | ||
| 296 | |||
| 297 | /** \brief CDC class-specific Functional ACM Descriptor (USB-IF naming conventions). | ||
| 298 | * | ||
| 299 | * Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface | ||
| 300 | * supports the CDC ACM subclass of the CDC specification. See the CDC class specification for more details. | ||
| 301 | * | ||
| 302 | * \see \ref USB_CDC_Descriptor_FunctionalACM_t for the version of this type with non-standard LUFA specific | ||
| 303 | * element names. | ||
| 304 | * | ||
| 305 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 306 | */ | ||
| 307 | typedef struct | ||
| 308 | { | ||
| 309 | uint8_t bFunctionLength; /**< Size of the descriptor, in bytes. */ | ||
| 310 | uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value | ||
| 311 | * given by the specific class. | ||
| 312 | */ | ||
| 313 | uint8_t bDescriptorSubType; /**< Sub type value used to distinguish between CDC class-specific descriptors, | ||
| 314 | * must be \ref CDC_DSUBTYPE_CSInterface_ACM. | ||
| 315 | */ | ||
| 316 | uint8_t bmCapabilities; /**< Capabilities of the ACM interface, given as a bit mask. For most devices, | ||
| 317 | * this should be set to a fixed value of 0x06 - for other capabilities, refer | ||
| 318 | * to the CDC ACM specification. | ||
| 319 | */ | ||
| 320 | } ATTR_PACKED USB_CDC_StdDescriptor_FunctionalACM_t; | ||
| 321 | |||
| 322 | /** \brief CDC class-specific Functional Union Descriptor (LUFA naming conventions). | ||
| 323 | * | ||
| 324 | * Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific | ||
| 325 | * CDC control and data interfaces are related. See the CDC class specification for more details. | ||
| 326 | * | ||
| 327 | * \see \ref USB_CDC_StdDescriptor_FunctionalUnion_t for the version of this type with standard element names. | ||
| 328 | * | ||
| 329 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 330 | */ | ||
| 331 | typedef struct | ||
| 332 | { | ||
| 333 | USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ | ||
| 334 | uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors, | ||
| 335 | * must be \ref CDC_DSUBTYPE_CSInterface_Union. | ||
| 336 | */ | ||
| 337 | uint8_t MasterInterfaceNumber; /**< Interface number of the CDC Control interface. */ | ||
| 338 | uint8_t SlaveInterfaceNumber; /**< Interface number of the CDC Data interface. */ | ||
| 339 | } ATTR_PACKED USB_CDC_Descriptor_FunctionalUnion_t; | ||
| 340 | |||
| 341 | /** \brief CDC class-specific Functional Union Descriptor (USB-IF naming conventions). | ||
| 342 | * | ||
| 343 | * Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific | ||
| 344 | * CDC control and data interfaces are related. See the CDC class specification for more details. | ||
| 345 | * | ||
| 346 | * \see \ref USB_CDC_Descriptor_FunctionalUnion_t for the version of this type with non-standard LUFA specific | ||
| 347 | * element names. | ||
| 348 | * | ||
| 349 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 350 | */ | ||
| 351 | typedef struct | ||
| 352 | { | ||
| 353 | uint8_t bFunctionLength; /**< Size of the descriptor, in bytes. */ | ||
| 354 | uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value | ||
| 355 | * given by the specific class. | ||
| 356 | */ | ||
| 357 | uint8_t bDescriptorSubType; /**< Sub type value used to distinguish between CDC class-specific descriptors, | ||
| 358 | * must be \ref CDC_DSUBTYPE_CSInterface_Union. | ||
| 359 | */ | ||
| 360 | uint8_t bMasterInterface; /**< Interface number of the CDC Control interface. */ | ||
| 361 | uint8_t bSlaveInterface0; /**< Interface number of the CDC Data interface. */ | ||
| 362 | } ATTR_PACKED USB_CDC_StdDescriptor_FunctionalUnion_t; | ||
| 363 | |||
| 364 | /** \brief CDC Virtual Serial Port Line Encoding Settings Structure. | ||
| 365 | * | ||
| 366 | * Type define for a CDC Line Encoding structure, used to hold the various encoding parameters for a virtual | ||
| 367 | * serial port. | ||
| 368 | * | ||
| 369 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 370 | */ | ||
| 371 | typedef struct | ||
| 372 | { | ||
| 373 | uint32_t BaudRateBPS; /**< Baud rate of the virtual serial port, in bits per second. */ | ||
| 374 | uint8_t CharFormat; /**< Character format of the virtual serial port, a value from the | ||
| 375 | * \ref CDC_LineEncodingFormats_t enum. | ||
| 376 | */ | ||
| 377 | uint8_t ParityType; /**< Parity setting of the virtual serial port, a value from the | ||
| 378 | * \ref CDC_LineEncodingParity_t enum. | ||
| 379 | */ | ||
| 380 | uint8_t DataBits; /**< Bits of data per character of the virtual serial port. */ | ||
| 381 | } ATTR_PACKED CDC_LineEncoding_t; | ||
| 382 | |||
| 383 | /* Disable C linkage for C++ Compilers: */ | ||
| 384 | #if defined(__cplusplus) | ||
| 385 | } | ||
| 386 | #endif | ||
| 387 | |||
| 388 | #endif | ||
| 389 | |||
| 390 | /** @} */ | ||
| 391 | |||
diff --git a/lib/lufa/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h b/lib/lufa/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h new file mode 100644 index 000000000..6e700a9b1 --- /dev/null +++ b/lib/lufa/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h | |||
| @@ -0,0 +1,681 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 12 | Permission to use, copy, modify, distribute, and sell this | ||
| 13 | software and its documentation for any purpose is hereby granted | ||
| 14 | without fee, provided that the above copyright notice appear in | ||
| 15 | all copies and that both that the copyright notice and this | ||
| 16 | permission notice and warranty disclaimer appear in supporting | ||
| 17 | documentation, and that the name of the author not be used in | ||
| 18 | advertising or publicity pertaining to distribution of the | ||
| 19 | software without specific, written prior permission. | ||
| 20 | |||
| 21 | The author disclaims all warranties with regard to this | ||
| 22 | software, including all implied warranties of merchantability | ||
| 23 | and fitness. In no event shall the author be liable for any | ||
| 24 | special, indirect or consequential damages or any damages | ||
| 25 | whatsoever resulting from loss of use, data or profits, whether | ||
| 26 | in an action of contract, negligence or other tortious action, | ||
| 27 | arising out of or in connection with the use or performance of | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | /** \file | ||
| 32 | * \brief Common definitions and declarations for the library USB HID Class driver. | ||
| 33 | * | ||
| 34 | * Common definitions and declarations for the library USB HID Class driver. | ||
| 35 | * | ||
| 36 | * \note This file should not be included directly. It is automatically included as needed by the USB module driver | ||
| 37 | * dispatch header located in LUFA/Drivers/USB.h. | ||
| 38 | */ | ||
| 39 | |||
| 40 | /** \ingroup Group_USBClassHID | ||
| 41 | * \defgroup Group_USBClassHIDCommon Common Class Definitions | ||
| 42 | * | ||
| 43 | * \section Sec_USBClassHIDCommon_ModDescription Module Description | ||
| 44 | * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB | ||
| 45 | * HID Class. | ||
| 46 | * | ||
| 47 | * @{ | ||
| 48 | */ | ||
| 49 | |||
| 50 | #ifndef _HID_CLASS_COMMON_H_ | ||
| 51 | #define _HID_CLASS_COMMON_H_ | ||
| 52 | |||
| 53 | /* Includes: */ | ||
| 54 | #include "../../Core/StdDescriptors.h" | ||
| 55 | #include "HIDParser.h" | ||
| 56 | |||
| 57 | /* Enable C linkage for C++ Compilers: */ | ||
| 58 | #if defined(__cplusplus) | ||
| 59 | extern "C" { | ||
| 60 | #endif | ||
| 61 | |||
| 62 | /* Preprocessor Checks: */ | ||
| 63 | #if !defined(__INCLUDE_FROM_HID_DRIVER) | ||
| 64 | #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. | ||
| 65 | #endif | ||
| 66 | |||
| 67 | /* Macros: */ | ||
| 68 | /** \name Keyboard Standard Report Modifier Masks */ | ||
| 69 | //@{ | ||
| 70 | /** Constant for a keyboard report modifier byte, indicating that the keyboard's left control key is currently pressed. */ | ||
| 71 | #define HID_KEYBOARD_MODIFIER_LEFTCTRL (1 << 0) | ||
| 72 | |||
| 73 | /** Constant for a keyboard report modifier byte, indicating that the keyboard's left shift key is currently pressed. */ | ||
| 74 | #define HID_KEYBOARD_MODIFIER_LEFTSHIFT (1 << 1) | ||
| 75 | |||
| 76 | /** Constant for a keyboard report modifier byte, indicating that the keyboard's left alt key is currently pressed. */ | ||
| 77 | #define HID_KEYBOARD_MODIFIER_LEFTALT (1 << 2) | ||
| 78 | |||
| 79 | /** Constant for a keyboard report modifier byte, indicating that the keyboard's left GUI key is currently pressed. */ | ||
| 80 | #define HID_KEYBOARD_MODIFIER_LEFTGUI (1 << 3) | ||
| 81 | |||
| 82 | /** Constant for a keyboard report modifier byte, indicating that the keyboard's right control key is currently pressed. */ | ||
| 83 | #define HID_KEYBOARD_MODIFIER_RIGHTCTRL (1 << 4) | ||
| 84 | |||
| 85 | /** Constant for a keyboard report modifier byte, indicating that the keyboard's right shift key is currently pressed. */ | ||
| 86 | #define HID_KEYBOARD_MODIFIER_RIGHTSHIFT (1 << 5) | ||
| 87 | |||
| 88 | /** Constant for a keyboard report modifier byte, indicating that the keyboard's right alt key is currently pressed. */ | ||
| 89 | #define HID_KEYBOARD_MODIFIER_RIGHTALT (1 << 6) | ||
| 90 | |||
| 91 | /** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */ | ||
| 92 | #define HID_KEYBOARD_MODIFIER_RIGHTGUI (1 << 7) | ||
| 93 | //@} | ||
| 94 | |||
| 95 | /** \name Keyboard Standard Report LED Masks */ | ||
| 96 | //@{ | ||
| 97 | /** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */ | ||
| 98 | #define HID_KEYBOARD_LED_NUMLOCK (1 << 0) | ||
| 99 | |||
| 100 | /** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */ | ||
| 101 | #define HID_KEYBOARD_LED_CAPSLOCK (1 << 1) | ||
| 102 | |||
| 103 | /** Constant for a keyboard output report LED byte, indicating that the host's SCROLL LOCK mode is currently set. */ | ||
| 104 | #define HID_KEYBOARD_LED_SCROLLLOCK (1 << 2) | ||
| 105 | |||
| 106 | /** Constant for a keyboard output report LED byte, indicating that the host's COMPOSE mode is currently set. */ | ||
| 107 | #define HID_KEYBOARD_LED_COMPOSE (1 << 3) | ||
| 108 | |||
| 109 | /** Constant for a keyboard output report LED byte, indicating that the host's KANA mode is currently set. */ | ||
| 110 | #define HID_KEYBOARD_LED_KANA (1 << 4) | ||
| 111 | //@} | ||
| 112 | |||
| 113 | /** \name Keyboard Standard Report Key Scan-codes */ | ||
| 114 | //@{ | ||
| 115 | #define HID_KEYBOARD_SC_ERROR_ROLLOVER 0x01 | ||
| 116 | #define HID_KEYBOARD_SC_POST_FAIL 0x02 | ||
| 117 | #define HID_KEYBOARD_SC_ERROR_UNDEFINED 0x03 | ||
| 118 | #define HID_KEYBOARD_SC_A 0x04 | ||
| 119 | #define HID_KEYBOARD_SC_B 0x05 | ||
| 120 | #define HID_KEYBOARD_SC_C 0x06 | ||
| 121 | #define HID_KEYBOARD_SC_D 0x07 | ||
| 122 | #define HID_KEYBOARD_SC_E 0x08 | ||
| 123 | #define HID_KEYBOARD_SC_F 0x09 | ||
| 124 | #define HID_KEYBOARD_SC_G 0x0A | ||
| 125 | #define HID_KEYBOARD_SC_H 0x0B | ||
| 126 | #define HID_KEYBOARD_SC_I 0x0C | ||
| 127 | #define HID_KEYBOARD_SC_J 0x0D | ||
| 128 | #define HID_KEYBOARD_SC_K 0x0E | ||
| 129 | #define HID_KEYBOARD_SC_L 0x0F | ||
| 130 | #define HID_KEYBOARD_SC_M 0x10 | ||
| 131 | #define HID_KEYBOARD_SC_N 0x11 | ||
| 132 | #define HID_KEYBOARD_SC_O 0x12 | ||
| 133 | #define HID_KEYBOARD_SC_P 0x13 | ||
| 134 | #define HID_KEYBOARD_SC_Q 0x14 | ||
| 135 | #define HID_KEYBOARD_SC_R 0x15 | ||
| 136 | #define HID_KEYBOARD_SC_S 0x16 | ||
| 137 | #define HID_KEYBOARD_SC_T 0x17 | ||
| 138 | #define HID_KEYBOARD_SC_U 0x18 | ||
| 139 | #define HID_KEYBOARD_SC_V 0x19 | ||
| 140 | #define HID_KEYBOARD_SC_W 0x1A | ||
| 141 | #define HID_KEYBOARD_SC_X 0x1B | ||
| 142 | #define HID_KEYBOARD_SC_Y 0x1C | ||
| 143 | #define HID_KEYBOARD_SC_Z 0x1D | ||
| 144 | #define HID_KEYBOARD_SC_1_AND_EXCLAMATION 0x1E | ||
| 145 | #define HID_KEYBOARD_SC_2_AND_AT 0x1F | ||
| 146 | #define HID_KEYBOARD_SC_3_AND_HASHMARK 0x20 | ||
| 147 | #define HID_KEYBOARD_SC_4_AND_DOLLAR 0x21 | ||
| 148 | #define HID_KEYBOARD_SC_5_AND_PERCENTAGE 0x22 | ||
| 149 | #define HID_KEYBOARD_SC_6_AND_CARET 0x23 | ||
| 150 | #define HID_KEYBOARD_SC_7_AND_AMPERSAND 0x24 | ||
| 151 | #define HID_KEYBOARD_SC_8_AND_ASTERISK 0x25 | ||
| 152 | #define HID_KEYBOARD_SC_9_AND_OPENING_PARENTHESIS 0x26 | ||
| 153 | #define HID_KEYBOARD_SC_0_AND_CLOSING_PARENTHESIS 0x27 | ||
| 154 | #define HID_KEYBOARD_SC_ENTER 0x28 | ||
| 155 | #define HID_KEYBOARD_SC_ESCAPE 0x29 | ||
| 156 | #define HID_KEYBOARD_SC_BACKSPACE 0x2A | ||
| 157 | #define HID_KEYBOARD_SC_TAB 0x2B | ||
| 158 | #define HID_KEYBOARD_SC_SPACE 0x2C | ||
| 159 | #define HID_KEYBOARD_SC_MINUS_AND_UNDERSCORE 0x2D | ||
| 160 | #define HID_KEYBOARD_SC_EQUAL_AND_PLUS 0x2E | ||
| 161 | #define HID_KEYBOARD_SC_OPENING_BRACKET_AND_OPENING_BRACE 0x2F | ||
| 162 | #define HID_KEYBOARD_SC_CLOSING_BRACKET_AND_CLOSING_BRACE 0x30 | ||
| 163 | #define HID_KEYBOARD_SC_BACKSLASH_AND_PIPE 0x31 | ||
| 164 | #define HID_KEYBOARD_SC_NON_US_HASHMARK_AND_TILDE 0x32 | ||
| 165 | #define HID_KEYBOARD_SC_SEMICOLON_AND_COLON 0x33 | ||
| 166 | #define HID_KEYBOARD_SC_APOSTROPHE_AND_QUOTE 0x34 | ||
| 167 | #define HID_KEYBOARD_SC_GRAVE_ACCENT_AND_TILDE 0x35 | ||
| 168 | #define HID_KEYBOARD_SC_COMMA_AND_LESS_THAN_SIGN 0x36 | ||
| 169 | #define HID_KEYBOARD_SC_DOT_AND_GREATER_THAN_SIGN 0x37 | ||
| 170 | #define HID_KEYBOARD_SC_SLASH_AND_QUESTION_MARK 0x38 | ||
| 171 | #define HID_KEYBOARD_SC_CAPS_LOCK 0x39 | ||
| 172 | #define HID_KEYBOARD_SC_F1 0x3A | ||
| 173 | #define HID_KEYBOARD_SC_F2 0x3B | ||
| 174 | #define HID_KEYBOARD_SC_F3 0x3C | ||
| 175 | #define HID_KEYBOARD_SC_F4 0x3D | ||
| 176 | #define HID_KEYBOARD_SC_F5 0x3E | ||
| 177 | #define HID_KEYBOARD_SC_F6 0x3F | ||
| 178 | #define HID_KEYBOARD_SC_F7 0x40 | ||
| 179 | #define HID_KEYBOARD_SC_F8 0x41 | ||
| 180 | #define HID_KEYBOARD_SC_F9 0x42 | ||
| 181 | #define HID_KEYBOARD_SC_F10 0x43 | ||
| 182 | #define HID_KEYBOARD_SC_F11 0x44 | ||
| 183 | #define HID_KEYBOARD_SC_F12 0x45 | ||
| 184 | #define HID_KEYBOARD_SC_PRINT_SCREEN 0x46 | ||
| 185 | #define HID_KEYBOARD_SC_SCROLL_LOCK 0x47 | ||
| 186 | #define HID_KEYBOARD_SC_PAUSE 0x48 | ||
| 187 | #define HID_KEYBOARD_SC_INSERT 0x49 | ||
| 188 | #define HID_KEYBOARD_SC_HOME 0x4A | ||
| 189 | #define HID_KEYBOARD_SC_PAGE_UP 0x4B | ||
| 190 | #define HID_KEYBOARD_SC_DELETE 0x4C | ||
| 191 | #define HID_KEYBOARD_SC_END 0x4D | ||
| 192 | #define HID_KEYBOARD_SC_PAGE_DOWN 0x4E | ||
| 193 | #define HID_KEYBOARD_SC_RIGHT_ARROW 0x4F | ||
| 194 | #define HID_KEYBOARD_SC_LEFT_ARROW 0x50 | ||
| 195 | #define HID_KEYBOARD_SC_DOWN_ARROW 0x51 | ||
| 196 | #define HID_KEYBOARD_SC_UP_ARROW 0x52 | ||
| 197 | #define HID_KEYBOARD_SC_NUM_LOCK 0x53 | ||
| 198 | #define HID_KEYBOARD_SC_KEYPAD_SLASH 0x54 | ||
| 199 | #define HID_KEYBOARD_SC_KEYPAD_ASTERISK 0x55 | ||
| 200 | #define HID_KEYBOARD_SC_KEYPAD_MINUS 0x56 | ||
| 201 | #define HID_KEYBOARD_SC_KEYPAD_PLUS 0x57 | ||
| 202 | #define HID_KEYBOARD_SC_KEYPAD_ENTER 0x58 | ||
| 203 | #define HID_KEYBOARD_SC_KEYPAD_1_AND_END 0x59 | ||
| 204 | #define HID_KEYBOARD_SC_KEYPAD_2_AND_DOWN_ARROW 0x5A | ||
| 205 | #define HID_KEYBOARD_SC_KEYPAD_3_AND_PAGE_DOWN 0x5B | ||
| 206 | #define HID_KEYBOARD_SC_KEYPAD_4_AND_LEFT_ARROW 0x5C | ||
| 207 | #define HID_KEYBOARD_SC_KEYPAD_5 0x5D | ||
| 208 | #define HID_KEYBOARD_SC_KEYPAD_6_AND_RIGHT_ARROW 0x5E | ||
| 209 | #define HID_KEYBOARD_SC_KEYPAD_7_AND_HOME 0x5F | ||
| 210 | #define HID_KEYBOARD_SC_KEYPAD_8_AND_UP_ARROW 0x60 | ||
| 211 | #define HID_KEYBOARD_SC_KEYPAD_9_AND_PAGE_UP 0x61 | ||
| 212 | #define HID_KEYBOARD_SC_KEYPAD_0_AND_INSERT 0x62 | ||
| 213 | #define HID_KEYBOARD_SC_KEYPAD_DOT_AND_DELETE 0x63 | ||
| 214 | #define HID_KEYBOARD_SC_NON_US_BACKSLASH_AND_PIPE 0x64 | ||
| 215 | #define HID_KEYBOARD_SC_APPLICATION 0x65 | ||
| 216 | #define HID_KEYBOARD_SC_POWER 0x66 | ||
| 217 | #define HID_KEYBOARD_SC_KEYPAD_EQUAL_SIGN 0x67 | ||
| 218 | #define HID_KEYBOARD_SC_F13 0x68 | ||
| 219 | #define HID_KEYBOARD_SC_F14 0x69 | ||
| 220 | #define HID_KEYBOARD_SC_F15 0x6A | ||
| 221 | #define HID_KEYBOARD_SC_F16 0x6B | ||
| 222 | #define HID_KEYBOARD_SC_F17 0x6C | ||
| 223 | #define HID_KEYBOARD_SC_F18 0x6D | ||
| 224 | #define HID_KEYBOARD_SC_F19 0x6E | ||
| 225 | #define HID_KEYBOARD_SC_F20 0x6F | ||
| 226 | #define HID_KEYBOARD_SC_F21 0x70 | ||
| 227 | #define HID_KEYBOARD_SC_F22 0x71 | ||
| 228 | #define HID_KEYBOARD_SC_F23 0x72 | ||
| 229 | #define HID_KEYBOARD_SC_F24 0x73 | ||
| 230 | #define HID_KEYBOARD_SC_EXECUTE 0x74 | ||
| 231 | #define HID_KEYBOARD_SC_HELP 0x75 | ||
| 232 | #define HID_KEYBOARD_SC_MENU 0x76 | ||
| 233 | #define HID_KEYBOARD_SC_SELECT 0x77 | ||
| 234 | #define HID_KEYBOARD_SC_STOP 0x78 | ||
| 235 | #define HID_KEYBOARD_SC_AGAIN 0x79 | ||
| 236 | #define HID_KEYBOARD_SC_UNDO 0x7A | ||
| 237 | #define HID_KEYBOARD_SC_CUT 0x7B | ||
| 238 | #define HID_KEYBOARD_SC_COPY 0x7C | ||
| 239 | #define HID_KEYBOARD_SC_PASTE 0x7D | ||
| 240 | #define HID_KEYBOARD_SC_FIND 0x7E | ||
| 241 | #define HID_KEYBOARD_SC_MUTE 0x7F | ||
| 242 | #define HID_KEYBOARD_SC_VOLUME_UP 0x80 | ||
| 243 | #define HID_KEYBOARD_SC_VOLUME_DOWN 0x81 | ||
| 244 | #define HID_KEYBOARD_SC_LOCKING_CAPS_LOCK 0x82 | ||
| 245 | #define HID_KEYBOARD_SC_LOCKING_NUM_LOCK 0x83 | ||
| 246 | #define HID_KEYBOARD_SC_LOCKING_SCROLL_LOCK 0x84 | ||
| 247 | #define HID_KEYBOARD_SC_KEYPAD_COMMA 0x85 | ||
| 248 | #define HID_KEYBOARD_SC_KEYPAD_EQUAL_SIGN_AS400 0x86 | ||
| 249 | #define HID_KEYBOARD_SC_INTERNATIONAL1 0x87 | ||
| 250 | #define HID_KEYBOARD_SC_INTERNATIONAL2 0x88 | ||
| 251 | #define HID_KEYBOARD_SC_INTERNATIONAL3 0x89 | ||
| 252 | #define HID_KEYBOARD_SC_INTERNATIONAL4 0x8A | ||
| 253 | #define HID_KEYBOARD_SC_INTERNATIONAL5 0x8B | ||
| 254 | #define HID_KEYBOARD_SC_INTERNATIONAL6 0x8C | ||
| 255 | #define HID_KEYBOARD_SC_INTERNATIONAL7 0x8D | ||
| 256 | #define HID_KEYBOARD_SC_INTERNATIONAL8 0x8E | ||
| 257 | #define HID_KEYBOARD_SC_INTERNATIONAL9 0x8F | ||
| 258 | #define HID_KEYBOARD_SC_LANG1 0x90 | ||
| 259 | #define HID_KEYBOARD_SC_LANG2 0x91 | ||
| 260 | #define HID_KEYBOARD_SC_LANG3 0x92 | ||
| 261 | #define HID_KEYBOARD_SC_LANG4 0x93 | ||
| 262 | #define HID_KEYBOARD_SC_LANG5 0x94 | ||
| 263 | #define HID_KEYBOARD_SC_LANG6 0x95 | ||
| 264 | #define HID_KEYBOARD_SC_LANG7 0x96 | ||
| 265 | #define HID_KEYBOARD_SC_LANG8 0x97 | ||
| 266 | #define HID_KEYBOARD_SC_LANG9 0x98 | ||
| 267 | #define HID_KEYBOARD_SC_ALTERNATE_ERASE 0x99 | ||
| 268 | #define HID_KEYBOARD_SC_SYSREQ 0x9A | ||
| 269 | #define HID_KEYBOARD_SC_CANCEL 0x9B | ||
| 270 | #define HID_KEYBOARD_SC_CLEAR 0x9C | ||
| 271 | #define HID_KEYBOARD_SC_PRIOR 0x9D | ||
| 272 | #define HID_KEYBOARD_SC_RETURN 0x9E | ||
| 273 | #define HID_KEYBOARD_SC_SEPARATOR 0x9F | ||
| 274 | #define HID_KEYBOARD_SC_OUT 0xA0 | ||
| 275 | #define HID_KEYBOARD_SC_OPER 0xA1 | ||
| 276 | #define HID_KEYBOARD_SC_CLEAR_AND_AGAIN 0xA2 | ||
| 277 | #define HID_KEYBOARD_SC_CRSEL_AND_PROPS 0xA3 | ||
| 278 | #define HID_KEYBOARD_SC_EXSEL 0xA4 | ||
| 279 | #define HID_KEYBOARD_SC_KEYPAD_00 0xB0 | ||
| 280 | #define HID_KEYBOARD_SC_KEYPAD_000 0xB1 | ||
| 281 | #define HID_KEYBOARD_SC_THOUSANDS_SEPARATOR 0xB2 | ||
| 282 | #define HID_KEYBOARD_SC_DECIMAL_SEPARATOR 0xB3 | ||
| 283 | #define HID_KEYBOARD_SC_CURRENCY_UNIT 0xB4 | ||
| 284 | #define HID_KEYBOARD_SC_CURRENCY_SUB_UNIT 0xB5 | ||
| 285 | #define HID_KEYBOARD_SC_KEYPAD_OPENING_PARENTHESIS 0xB6 | ||
| 286 | #define HID_KEYBOARD_SC_KEYPAD_CLOSING_PARENTHESIS 0xB7 | ||
| 287 | #define HID_KEYBOARD_SC_KEYPAD_OPENING_BRACE 0xB8 | ||
| 288 | #define HID_KEYBOARD_SC_KEYPAD_CLOSING_BRACE 0xB9 | ||
| 289 | #define HID_KEYBOARD_SC_KEYPAD_TAB 0xBA | ||
| 290 | #define HID_KEYBOARD_SC_KEYPAD_BACKSPACE 0xBB | ||
| 291 | #define HID_KEYBOARD_SC_KEYPAD_A 0xBC | ||
| 292 | #define HID_KEYBOARD_SC_KEYPAD_B 0xBD | ||
| 293 | #define HID_KEYBOARD_SC_KEYPAD_C 0xBE | ||
| 294 | #define HID_KEYBOARD_SC_KEYPAD_D 0xBF | ||
| 295 | #define HID_KEYBOARD_SC_KEYPAD_E 0xC0 | ||
| 296 | #define HID_KEYBOARD_SC_KEYPAD_F 0xC1 | ||
| 297 | #define HID_KEYBOARD_SC_KEYPAD_XOR 0xC2 | ||
| 298 | #define HID_KEYBOARD_SC_KEYPAD_CARET 0xC3 | ||
| 299 | #define HID_KEYBOARD_SC_KEYPAD_PERCENTAGE 0xC4 | ||
| 300 | #define HID_KEYBOARD_SC_KEYPAD_LESS_THAN_SIGN 0xC5 | ||
| 301 | #define HID_KEYBOARD_SC_KEYPAD_GREATER_THAN_SIGN 0xC6 | ||
| 302 | #define HID_KEYBOARD_SC_KEYPAD_AMP 0xC7 | ||
| 303 | #define HID_KEYBOARD_SC_KEYPAD_AMP_AMP 0xC8 | ||
| 304 | #define HID_KEYBOARD_SC_KEYPAD_PIPE 0xC9 | ||
| 305 | #define HID_KEYBOARD_SC_KEYPAD_PIPE_PIPE 0xCA | ||
| 306 | #define HID_KEYBOARD_SC_KEYPAD_COLON 0xCB | ||
| 307 | #define HID_KEYBOARD_SC_KEYPAD_HASHMARK 0xCC | ||
| 308 | #define HID_KEYBOARD_SC_KEYPAD_SPACE 0xCD | ||
| 309 | #define HID_KEYBOARD_SC_KEYPAD_AT 0xCE | ||
| 310 | #define HID_KEYBOARD_SC_KEYPAD_EXCLAMATION_SIGN 0xCF | ||
| 311 | #define HID_KEYBOARD_SC_KEYPAD_MEMORY_STORE 0xD0 | ||
| 312 | #define HID_KEYBOARD_SC_KEYPAD_MEMORY_RECALL 0xD1 | ||
| 313 | #define HID_KEYBOARD_SC_KEYPAD_MEMORY_CLEAR 0xD2 | ||
| 314 | #define HID_KEYBOARD_SC_KEYPAD_MEMORY_ADD 0xD3 | ||
| 315 | #define HID_KEYBOARD_SC_KEYPAD_MEMORY_SUBTRACT 0xD4 | ||
| 316 | #define HID_KEYBOARD_SC_KEYPAD_MEMORY_MULTIPLY 0xD5 | ||
| 317 | #define HID_KEYBOARD_SC_KEYPAD_MEMORY_DIVIDE 0xD6 | ||
| 318 | #define HID_KEYBOARD_SC_KEYPAD_PLUS_AND_MINUS 0xD7 | ||
| 319 | #define HID_KEYBOARD_SC_KEYPAD_CLEAR 0xD8 | ||
| 320 | #define HID_KEYBOARD_SC_KEYPAD_CLEAR_ENTRY 0xD9 | ||
| 321 | #define HID_KEYBOARD_SC_KEYPAD_BINARY 0xDA | ||
| 322 | #define HID_KEYBOARD_SC_KEYPAD_OCTAL 0xDB | ||
| 323 | #define HID_KEYBOARD_SC_KEYPAD_DECIMAL 0xDC | ||
| 324 | #define HID_KEYBOARD_SC_KEYPAD_HEXADECIMAL 0xDD | ||
| 325 | #define HID_KEYBOARD_SC_LEFT_CONTROL 0xE0 | ||
| 326 | #define HID_KEYBOARD_SC_LEFT_SHIFT 0xE1 | ||
| 327 | #define HID_KEYBOARD_SC_LEFT_ALT 0xE2 | ||
| 328 | #define HID_KEYBOARD_SC_LEFT_GUI 0xE3 | ||
| 329 | #define HID_KEYBOARD_SC_RIGHT_CONTROL 0xE4 | ||
| 330 | #define HID_KEYBOARD_SC_RIGHT_SHIFT 0xE5 | ||
| 331 | #define HID_KEYBOARD_SC_RIGHT_ALT 0xE6 | ||
| 332 | #define HID_KEYBOARD_SC_RIGHT_GUI 0xE7 | ||
| 333 | #define HID_KEYBOARD_SC_MEDIA_PLAY 0xE8 | ||
| 334 | #define HID_KEYBOARD_SC_MEDIA_STOP 0xE9 | ||
| 335 | #define HID_KEYBOARD_SC_MEDIA_PREVIOUS_TRACK 0xEA | ||
| 336 | #define HID_KEYBOARD_SC_MEDIA_NEXT_TRACK 0xEB | ||
| 337 | #define HID_KEYBOARD_SC_MEDIA_EJECT 0xEC | ||
| 338 | #define HID_KEYBOARD_SC_MEDIA_VOLUME_UP 0xED | ||
| 339 | #define HID_KEYBOARD_SC_MEDIA_VOLUME_DOWN 0xEE | ||
| 340 | #define HID_KEYBOARD_SC_MEDIA_MUTE 0xEF | ||
| 341 | #define HID_KEYBOARD_SC_MEDIA_WWW 0xF0 | ||
| 342 | #define HID_KEYBOARD_SC_MEDIA_BACKWARD 0xF1 | ||
| 343 | #define HID_KEYBOARD_SC_MEDIA_FORWARD 0xF2 | ||
| 344 | #define HID_KEYBOARD_SC_MEDIA_CANCEL 0xF3 | ||
| 345 | #define HID_KEYBOARD_SC_MEDIA_SEARCH 0xF4 | ||
| 346 | #define HID_KEYBOARD_SC_MEDIA_SLEEP 0xF8 | ||
| 347 | #define HID_KEYBOARD_SC_MEDIA_LOCK 0xF9 | ||
| 348 | #define HID_KEYBOARD_SC_MEDIA_RELOAD 0xFA | ||
| 349 | #define HID_KEYBOARD_SC_MEDIA_CALCULATOR 0xFB | ||
| 350 | //@} | ||
| 351 | |||
| 352 | /** \name Common HID Device Report Descriptors */ | ||
| 353 | //@{ | ||
| 354 | /** \hideinitializer | ||
| 355 | * A list of HID report item array elements that describe a typical HID USB Joystick. The resulting report | ||
| 356 | * descriptor is structured according to the following layout: | ||
| 357 | * | ||
| 358 | * \code | ||
| 359 | * struct | ||
| 360 | * { | ||
| 361 | * intA_t X; // Signed X axis value | ||
| 362 | * intA_t Y; // Signed Y axis value | ||
| 363 | * intA_t Z; // Signed Z axis value | ||
| 364 | * uintB_t Buttons; // Pressed buttons bitmask | ||
| 365 | * } Joystick_Report; | ||
| 366 | * \endcode | ||
| 367 | * | ||
| 368 | * Where \c uintA_t is a type large enough to hold the ranges of the signed \c MinAxisVal and \c MaxAxisVal values, | ||
| 369 | * and \c intB_t is a type large enough to hold one bit per button. | ||
| 370 | * | ||
| 371 | * \param[in] MinAxisVal Minimum logical axis value (16-bit). | ||
| 372 | * \param[in] MaxAxisVal Maximum logical axis value (16-bit). | ||
| 373 | * \param[in] MinPhysicalVal Minimum physical axis value, for movement resolution calculations (16-bit). | ||
| 374 | * \param[in] MaxPhysicalVal Maximum physical axis value, for movement resolution calculations (16-bit). | ||
| 375 | * \param[in] Buttons Total number of buttons in the device (8-bit). | ||
| 376 | */ | ||
| 377 | #define HID_DESCRIPTOR_JOYSTICK(MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons) \ | ||
| 378 | HID_RI_USAGE_PAGE(8, 0x01), \ | ||
| 379 | HID_RI_USAGE(8, 0x04), \ | ||
| 380 | HID_RI_COLLECTION(8, 0x01), \ | ||
| 381 | HID_RI_USAGE(8, 0x01), \ | ||
| 382 | HID_RI_COLLECTION(8, 0x00), \ | ||
| 383 | HID_RI_USAGE(8, 0x30), \ | ||
| 384 | HID_RI_USAGE(8, 0x31), \ | ||
| 385 | HID_RI_USAGE(8, 0x32), \ | ||
| 386 | HID_RI_LOGICAL_MINIMUM(16, MinAxisVal), \ | ||
| 387 | HID_RI_LOGICAL_MAXIMUM(16, MaxAxisVal), \ | ||
| 388 | HID_RI_PHYSICAL_MINIMUM(16, MinPhysicalVal), \ | ||
| 389 | HID_RI_PHYSICAL_MAXIMUM(16, MaxPhysicalVal), \ | ||
| 390 | HID_RI_REPORT_COUNT(8, 3), \ | ||
| 391 | HID_RI_REPORT_SIZE(8, (((MinAxisVal >= -128) && (MaxAxisVal <= 127)) ? 8 : 16)), \ | ||
| 392 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \ | ||
| 393 | HID_RI_END_COLLECTION(0), \ | ||
| 394 | HID_RI_USAGE_PAGE(8, 0x09), \ | ||
| 395 | HID_RI_USAGE_MINIMUM(8, 0x01), \ | ||
| 396 | HID_RI_USAGE_MAXIMUM(8, Buttons), \ | ||
| 397 | HID_RI_LOGICAL_MINIMUM(8, 0x00), \ | ||
| 398 | HID_RI_LOGICAL_MAXIMUM(8, 0x01), \ | ||
| 399 | HID_RI_REPORT_SIZE(8, 0x01), \ | ||
| 400 | HID_RI_REPORT_COUNT(8, Buttons), \ | ||
| 401 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \ | ||
| 402 | HID_RI_REPORT_SIZE(8, (Buttons % 8) ? (8 - (Buttons % 8)) : 0), \ | ||
| 403 | HID_RI_REPORT_COUNT(8, 0x01), \ | ||
| 404 | HID_RI_INPUT(8, HID_IOF_CONSTANT), \ | ||
| 405 | HID_RI_END_COLLECTION(0) | ||
| 406 | |||
| 407 | /** \hideinitializer | ||
| 408 | * A list of HID report item array elements that describe a typical HID USB keyboard. The resulting report descriptor | ||
| 409 | * is compatible with \ref USB_KeyboardReport_Data_t when \c MaxKeys is equal to 6. For other values, the report will | ||
| 410 | * be structured according to the following layout: | ||
| 411 | * | ||
| 412 | * \code | ||
| 413 | * struct | ||
| 414 | * { | ||
| 415 | * uint8_t Modifier; // Keyboard modifier byte indicating pressed modifier keys (\c HID_KEYBOARD_MODIFER_* masks) | ||
| 416 | * uint8_t Reserved; // Reserved for OEM use, always set to 0. | ||
| 417 | * uint8_t KeyCode[MaxKeys]; // Length determined by the number of keys that can be reported | ||
| 418 | * } Keyboard_Report; | ||
| 419 | * \endcode | ||
| 420 | * | ||
| 421 | * \param[in] MaxKeys Number of simultaneous keys that can be reported at the one time (8-bit). | ||
| 422 | */ | ||
| 423 | #define HID_DESCRIPTOR_KEYBOARD(MaxKeys) \ | ||
| 424 | HID_RI_USAGE_PAGE(8, 0x01), \ | ||
| 425 | HID_RI_USAGE(8, 0x06), \ | ||
| 426 | HID_RI_COLLECTION(8, 0x01), \ | ||
| 427 | HID_RI_USAGE_PAGE(8, 0x07), \ | ||
| 428 | HID_RI_USAGE_MINIMUM(8, 0xE0), \ | ||
| 429 | HID_RI_USAGE_MAXIMUM(8, 0xE7), \ | ||
| 430 | HID_RI_LOGICAL_MINIMUM(8, 0x00), \ | ||
| 431 | HID_RI_LOGICAL_MAXIMUM(8, 0x01), \ | ||
| 432 | HID_RI_REPORT_SIZE(8, 0x01), \ | ||
| 433 | HID_RI_REPORT_COUNT(8, 0x08), \ | ||
| 434 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \ | ||
| 435 | HID_RI_REPORT_COUNT(8, 0x01), \ | ||
| 436 | HID_RI_REPORT_SIZE(8, 0x08), \ | ||
| 437 | HID_RI_INPUT(8, HID_IOF_CONSTANT), \ | ||
| 438 | HID_RI_USAGE_PAGE(8, 0x08), \ | ||
| 439 | HID_RI_USAGE_MINIMUM(8, 0x01), \ | ||
| 440 | HID_RI_USAGE_MAXIMUM(8, 0x05), \ | ||
| 441 | HID_RI_REPORT_COUNT(8, 0x05), \ | ||
| 442 | HID_RI_REPORT_SIZE(8, 0x01), \ | ||
| 443 | HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), \ | ||
| 444 | HID_RI_REPORT_COUNT(8, 0x01), \ | ||
| 445 | HID_RI_REPORT_SIZE(8, 0x03), \ | ||
| 446 | HID_RI_OUTPUT(8, HID_IOF_CONSTANT), \ | ||
| 447 | HID_RI_LOGICAL_MINIMUM(8, 0x00), \ | ||
| 448 | HID_RI_LOGICAL_MAXIMUM(16, 0xFF), \ | ||
| 449 | HID_RI_USAGE_PAGE(8, 0x07), \ | ||
| 450 | HID_RI_USAGE_MINIMUM(8, 0x00), \ | ||
| 451 | HID_RI_USAGE_MAXIMUM(8, 0xFF), \ | ||
| 452 | HID_RI_REPORT_COUNT(8, MaxKeys), \ | ||
| 453 | HID_RI_REPORT_SIZE(8, 0x08), \ | ||
| 454 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), \ | ||
| 455 | HID_RI_END_COLLECTION(0) | ||
| 456 | |||
| 457 | /** \hideinitializer | ||
| 458 | * A list of HID report item array elements that describe a typical HID USB mouse. The resulting report descriptor | ||
| 459 | * is compatible with \ref USB_MouseReport_Data_t if the \c MinAxisVal and \c MaxAxisVal values fit within a \c int8_t range | ||
| 460 | * and the number of Buttons is less than 8. For other values, the report is structured according to the following layout: | ||
| 461 | * | ||
| 462 | * \code | ||
| 463 | * struct | ||
| 464 | * { | ||
| 465 | * uintA_t Buttons; // Pressed buttons bitmask | ||
| 466 | * intB_t X; // X axis value | ||
| 467 | * intB_t Y; // Y axis value | ||
| 468 | * } Mouse_Report; | ||
| 469 | * \endcode | ||
| 470 | * | ||
| 471 | * Where \c intA_t is a type large enough to hold one bit per button, and \c intB_t is a type large enough to hold the | ||
| 472 | * ranges of the signed \c MinAxisVal and \c MaxAxisVal values. | ||
| 473 | * | ||
| 474 | * \param[in] MinAxisVal Minimum X/Y logical axis value (16-bit). | ||
| 475 | * \param[in] MaxAxisVal Maximum X/Y logical axis value (16-bit). | ||
| 476 | * \param[in] MinPhysicalVal Minimum X/Y physical axis value, for movement resolution calculations (16-bit). | ||
| 477 | * \param[in] MaxPhysicalVal Maximum X/Y physical axis value, for movement resolution calculations (16-bit). | ||
| 478 | * \param[in] Buttons Total number of buttons in the device (8-bit). | ||
| 479 | * \param[in] AbsoluteCoords Boolean \c true to use absolute X/Y coordinates (e.g. touchscreen). | ||
| 480 | */ | ||
| 481 | #define HID_DESCRIPTOR_MOUSE(MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons, AbsoluteCoords) \ | ||
| 482 | HID_RI_USAGE_PAGE(8, 0x01), \ | ||
| 483 | HID_RI_USAGE(8, 0x02), \ | ||
| 484 | HID_RI_COLLECTION(8, 0x01), \ | ||
| 485 | HID_RI_USAGE(8, 0x01), \ | ||
| 486 | HID_RI_COLLECTION(8, 0x00), \ | ||
| 487 | HID_RI_USAGE_PAGE(8, 0x09), \ | ||
| 488 | HID_RI_USAGE_MINIMUM(8, 0x01), \ | ||
| 489 | HID_RI_USAGE_MAXIMUM(8, Buttons), \ | ||
| 490 | HID_RI_LOGICAL_MINIMUM(8, 0x00), \ | ||
| 491 | HID_RI_LOGICAL_MAXIMUM(8, 0x01), \ | ||
| 492 | HID_RI_REPORT_COUNT(8, Buttons), \ | ||
| 493 | HID_RI_REPORT_SIZE(8, 0x01), \ | ||
| 494 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \ | ||
| 495 | HID_RI_REPORT_COUNT(8, 0x01), \ | ||
| 496 | HID_RI_REPORT_SIZE(8, (Buttons % 8) ? (8 - (Buttons % 8)) : 0), \ | ||
| 497 | HID_RI_INPUT(8, HID_IOF_CONSTANT), \ | ||
| 498 | HID_RI_USAGE_PAGE(8, 0x01), \ | ||
| 499 | HID_RI_USAGE(8, 0x30), \ | ||
| 500 | HID_RI_USAGE(8, 0x31), \ | ||
| 501 | HID_RI_LOGICAL_MINIMUM(16, MinAxisVal), \ | ||
| 502 | HID_RI_LOGICAL_MAXIMUM(16, MaxAxisVal), \ | ||
| 503 | HID_RI_PHYSICAL_MINIMUM(16, MinPhysicalVal), \ | ||
| 504 | HID_RI_PHYSICAL_MAXIMUM(16, MaxPhysicalVal), \ | ||
| 505 | HID_RI_REPORT_COUNT(8, 0x02), \ | ||
| 506 | HID_RI_REPORT_SIZE(8, (((MinAxisVal >= -128) && (MaxAxisVal <= 127)) ? 8 : 16)), \ | ||
| 507 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | (AbsoluteCoords ? HID_IOF_ABSOLUTE : HID_IOF_RELATIVE)), \ | ||
| 508 | HID_RI_END_COLLECTION(0), \ | ||
| 509 | HID_RI_END_COLLECTION(0) | ||
| 510 | |||
| 511 | /** \hideinitializer | ||
| 512 | * A list of HID report item array elements that describe a typical Vendor Defined byte array HID report descriptor, | ||
| 513 | * used for transporting arbitrary data between the USB host and device via HID reports. The resulting report should be | ||
| 514 | * a \c uint8_t byte array of the specified length in both Device to Host (IN) and Host to Device (OUT) directions. | ||
| 515 | * | ||
| 516 | * \param[in] VendorPageNum Vendor Defined HID Usage Page index, ranging from 0x00 to 0xFF. | ||
| 517 | * \param[in] CollectionUsage Vendor Usage for the encompassing report IN and OUT collection, ranging from 0x00 to 0xFF. | ||
| 518 | * \param[in] DataINUsage Vendor Usage for the IN report data, ranging from 0x00 to 0xFF. | ||
| 519 | * \param[in] DataOUTUsage Vendor Usage for the OUT report data, ranging from 0x00 to 0xFF. | ||
| 520 | * \param[in] NumBytes Length of the data IN and OUT reports. | ||
| 521 | */ | ||
| 522 | #define HID_DESCRIPTOR_VENDOR(VendorPageNum, CollectionUsage, DataINUsage, DataOUTUsage, NumBytes) \ | ||
| 523 | HID_RI_USAGE_PAGE(16, (0xFF00 | VendorPageNum)), \ | ||
| 524 | HID_RI_USAGE(8, CollectionUsage), \ | ||
| 525 | HID_RI_COLLECTION(8, 0x01), \ | ||
| 526 | HID_RI_USAGE(8, DataINUsage), \ | ||
| 527 | HID_RI_LOGICAL_MINIMUM(8, 0x00), \ | ||
| 528 | HID_RI_LOGICAL_MAXIMUM(8, 0xFF), \ | ||
| 529 | HID_RI_REPORT_SIZE(8, 0x08), \ | ||
| 530 | HID_RI_REPORT_COUNT(8, NumBytes), \ | ||
| 531 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \ | ||
| 532 | HID_RI_USAGE(8, DataOUTUsage), \ | ||
| 533 | HID_RI_LOGICAL_MINIMUM(8, 0x00), \ | ||
| 534 | HID_RI_LOGICAL_MAXIMUM(8, 0xFF), \ | ||
| 535 | HID_RI_REPORT_SIZE(8, 0x08), \ | ||
| 536 | HID_RI_REPORT_COUNT(8, NumBytes), \ | ||
| 537 | HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), \ | ||
| 538 | HID_RI_END_COLLECTION(0) | ||
| 539 | //@} | ||
| 540 | |||
| 541 | /* Type Defines: */ | ||
| 542 | /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the HID | ||
| 543 | * device class. | ||
| 544 | */ | ||
| 545 | enum HID_Descriptor_ClassSubclassProtocol_t | ||
| 546 | { | ||
| 547 | HID_CSCP_HIDClass = 0x03, /**< Descriptor Class value indicating that the device or interface | ||
| 548 | * belongs to the HID class. | ||
| 549 | */ | ||
| 550 | HID_CSCP_NonBootSubclass = 0x00, /**< Descriptor Subclass value indicating that the device or interface | ||
| 551 | * does not implement a HID boot protocol. | ||
| 552 | */ | ||
| 553 | HID_CSCP_BootSubclass = 0x01, /**< Descriptor Subclass value indicating that the device or interface | ||
| 554 | * implements a HID boot protocol. | ||
| 555 | */ | ||
| 556 | HID_CSCP_NonBootProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface | ||
| 557 | * does not belong to a HID boot protocol. | ||
| 558 | */ | ||
| 559 | HID_CSCP_KeyboardBootProtocol = 0x01, /**< Descriptor Protocol value indicating that the device or interface | ||
| 560 | * belongs to the Keyboard HID boot protocol. | ||
| 561 | */ | ||
| 562 | HID_CSCP_MouseBootProtocol = 0x02, /**< Descriptor Protocol value indicating that the device or interface | ||
| 563 | * belongs to the Mouse HID boot protocol. | ||
| 564 | */ | ||
| 565 | }; | ||
| 566 | |||
| 567 | /** Enum for the HID class specific control requests that can be issued by the USB bus host. */ | ||
| 568 | enum HID_ClassRequests_t | ||
| 569 | { | ||
| 570 | HID_REQ_GetReport = 0x01, /**< HID class-specific Request to get the current HID report from the device. */ | ||
| 571 | HID_REQ_GetIdle = 0x02, /**< HID class-specific Request to get the current device idle count. */ | ||
| 572 | HID_REQ_GetProtocol = 0x03, /**< HID class-specific Request to get the current HID report protocol mode. */ | ||
| 573 | HID_REQ_SetReport = 0x09, /**< HID class-specific Request to set the current HID report to the device. */ | ||
| 574 | HID_REQ_SetIdle = 0x0A, /**< HID class-specific Request to set the device's idle count. */ | ||
| 575 | HID_REQ_SetProtocol = 0x0B, /**< HID class-specific Request to set the current HID report protocol mode. */ | ||
| 576 | }; | ||
| 577 | |||
| 578 | /** Enum for the HID class specific descriptor types. */ | ||
| 579 | enum HID_DescriptorTypes_t | ||
| 580 | { | ||
| 581 | HID_DTYPE_HID = 0x21, /**< Descriptor header type value, to indicate a HID class HID descriptor. */ | ||
| 582 | HID_DTYPE_Report = 0x22, /**< Descriptor header type value, to indicate a HID class HID report descriptor. */ | ||
| 583 | }; | ||
| 584 | |||
| 585 | /** Enum for the different types of HID reports. */ | ||
| 586 | enum HID_ReportItemTypes_t | ||
| 587 | { | ||
| 588 | HID_REPORT_ITEM_In = 0, /**< Indicates that the item is an IN report type. */ | ||
| 589 | HID_REPORT_ITEM_Out = 1, /**< Indicates that the item is an OUT report type. */ | ||
| 590 | HID_REPORT_ITEM_Feature = 2, /**< Indicates that the item is a FEATURE report type. */ | ||
| 591 | }; | ||
| 592 | |||
| 593 | /** \brief HID class-specific HID Descriptor (LUFA naming conventions). | ||
| 594 | * | ||
| 595 | * Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID | ||
| 596 | * specification for details on the structure elements. | ||
| 597 | * | ||
| 598 | * \see \ref USB_HID_StdDescriptor_HID_t for the version of this type with standard element names. | ||
| 599 | * | ||
| 600 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 601 | */ | ||
| 602 | typedef struct | ||
| 603 | { | ||
| 604 | USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ | ||
| 605 | |||
| 606 | uint16_t HIDSpec; /**< BCD encoded version that the HID descriptor and device complies to. | ||
| 607 | * | ||
| 608 | * \see \ref VERSION_BCD() utility macro. | ||
| 609 | */ | ||
| 610 | uint8_t CountryCode; /**< Country code of the localized device, or zero if universal. */ | ||
| 611 | |||
| 612 | uint8_t TotalReportDescriptors; /**< Total number of HID report descriptors for the interface. */ | ||
| 613 | |||
| 614 | uint8_t HIDReportType; /**< Type of HID report, set to \ref HID_DTYPE_Report. */ | ||
| 615 | uint16_t HIDReportLength; /**< Length of the associated HID report descriptor, in bytes. */ | ||
| 616 | } ATTR_PACKED USB_HID_Descriptor_HID_t; | ||
| 617 | |||
| 618 | /** \brief HID class-specific HID Descriptor (USB-IF naming conventions). | ||
| 619 | * | ||
| 620 | * Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID | ||
| 621 | * specification for details on the structure elements. | ||
| 622 | * | ||
| 623 | * \see \ref USB_HID_Descriptor_HID_t for the version of this type with non-standard LUFA specific | ||
| 624 | * element names. | ||
| 625 | * | ||
| 626 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 627 | */ | ||
| 628 | typedef struct | ||
| 629 | { | ||
| 630 | uint8_t bLength; /**< Size of the descriptor, in bytes. */ | ||
| 631 | uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value | ||
| 632 | * given by the specific class. | ||
| 633 | */ | ||
| 634 | |||
| 635 | uint16_t bcdHID; /**< BCD encoded version that the HID descriptor and device complies to. | ||
| 636 | * | ||
| 637 | * \see \ref VERSION_BCD() utility macro. | ||
| 638 | */ | ||
| 639 | uint8_t bCountryCode; /**< Country code of the localized device, or zero if universal. */ | ||
| 640 | |||
| 641 | uint8_t bNumDescriptors; /**< Total number of HID report descriptors for the interface. */ | ||
| 642 | |||
| 643 | uint8_t bDescriptorType2; /**< Type of HID report, set to \ref HID_DTYPE_Report. */ | ||
| 644 | uint16_t wDescriptorLength; /**< Length of the associated HID report descriptor, in bytes. */ | ||
| 645 | } ATTR_PACKED USB_HID_StdDescriptor_HID_t; | ||
| 646 | |||
| 647 | /** \brief Standard HID Boot Protocol Mouse Report. | ||
| 648 | * | ||
| 649 | * Type define for a standard Boot Protocol Mouse report | ||
| 650 | */ | ||
| 651 | typedef struct | ||
| 652 | { | ||
| 653 | uint8_t Button; /**< Button mask for currently pressed buttons in the mouse. */ | ||
| 654 | int8_t X; /**< Current delta X movement of the mouse. */ | ||
| 655 | int8_t Y; /**< Current delta Y movement on the mouse. */ | ||
| 656 | } ATTR_PACKED USB_MouseReport_Data_t; | ||
| 657 | |||
| 658 | /** \brief Standard HID Boot Protocol Keyboard Report. | ||
| 659 | * | ||
| 660 | * Type define for a standard Boot Protocol Keyboard report | ||
| 661 | */ | ||
| 662 | typedef struct | ||
| 663 | { | ||
| 664 | uint8_t Modifier; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of | ||
| 665 | * \c HID_KEYBOARD_MODIFER_* masks). | ||
| 666 | */ | ||
| 667 | uint8_t Reserved; /**< Reserved for OEM use, always set to 0. */ | ||
| 668 | uint8_t KeyCode[6]; /**< Key codes of the currently pressed keys. */ | ||
| 669 | } ATTR_PACKED USB_KeyboardReport_Data_t; | ||
| 670 | |||
| 671 | /** Type define for the data type used to store HID report descriptor elements. */ | ||
| 672 | typedef uint8_t USB_Descriptor_HIDReport_Datatype_t; | ||
| 673 | |||
| 674 | /* Disable C linkage for C++ Compilers: */ | ||
| 675 | #if defined(__cplusplus) | ||
| 676 | } | ||
| 677 | #endif | ||
| 678 | |||
| 679 | #endif | ||
| 680 | |||
| 681 | /** @} */ | ||
diff --git a/lib/lufa/LUFA/Drivers/USB/Class/Common/HIDParser.c b/lib/lufa/LUFA/Drivers/USB/Class/Common/HIDParser.c new file mode 100644 index 000000000..62f10c4e2 --- /dev/null +++ b/lib/lufa/LUFA/Drivers/USB/Class/Common/HIDParser.c | |||
| @@ -0,0 +1,389 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 12 | Permission to use, copy, modify, distribute, and sell this | ||
| 13 | software and its documentation for any purpose is hereby granted | ||
| 14 | without fee, provided that the above copyright notice appear in | ||
| 15 | all copies and that both that the copyright notice and this | ||
| 16 | permission notice and warranty disclaimer appear in supporting | ||
| 17 | documentation, and that the name of the author not be used in | ||
| 18 | advertising or publicity pertaining to distribution of the | ||
| 19 | software without specific, written prior permission. | ||
| 20 | |||
| 21 | The author disclaims all warranties with regard to this | ||
| 22 | software, including all implied warranties of merchantability | ||
| 23 | and fitness. In no event shall the author be liable for any | ||
| 24 | special, indirect or consequential damages or any damages | ||
| 25 | whatsoever resulting from loss of use, data or profits, whether | ||
| 26 | in an action of contract, negligence or other tortious action, | ||
| 27 | arising out of or in connection with the use or performance of | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | #define __INCLUDE_FROM_USB_DRIVER | ||
| 32 | #define __INCLUDE_FROM_HID_DRIVER | ||
| 33 | #include "HIDParser.h" | ||
| 34 | |||
| 35 | uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, | ||
| 36 | uint16_t ReportSize, | ||
| 37 | HID_ReportInfo_t* const ParserData) | ||
| 38 | { | ||
| 39 | HID_StateTable_t StateTable[HID_STATETABLE_STACK_DEPTH]; | ||
| 40 | HID_StateTable_t* CurrStateTable = &StateTable[0]; | ||
| 41 | HID_CollectionPath_t* CurrCollectionPath = NULL; | ||
| 42 | HID_ReportSizeInfo_t* CurrReportIDInfo = &ParserData->ReportIDSizes[0]; | ||
| 43 | uint16_t UsageList[HID_USAGE_STACK_DEPTH]; | ||
| 44 | uint8_t UsageListSize = 0; | ||
| 45 | HID_MinMax_t UsageMinMax = {0, 0}; | ||
| 46 | |||
| 47 | memset(ParserData, 0x00, sizeof(HID_ReportInfo_t)); | ||
| 48 | memset(CurrStateTable, 0x00, sizeof(HID_StateTable_t)); | ||
| 49 | memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t)); | ||
| 50 | |||
| 51 | ParserData->TotalDeviceReports = 1; | ||
| 52 | |||
| 53 | while (ReportSize) | ||
| 54 | { | ||
| 55 | uint8_t HIDReportItem = *ReportData; | ||
| 56 | uint32_t ReportItemData; | ||
| 57 | |||
| 58 | ReportData++; | ||
| 59 | ReportSize--; | ||
| 60 | |||
| 61 | switch (HIDReportItem & HID_RI_DATA_SIZE_MASK) | ||
| 62 | { | ||
| 63 | case HID_RI_DATA_BITS_32: | ||
| 64 | ReportItemData = (((uint32_t)ReportData[3] << 24) | ((uint32_t)ReportData[2] << 16) | | ||
| 65 | ((uint16_t)ReportData[1] << 8) | ReportData[0]); | ||
| 66 | ReportSize -= 4; | ||
| 67 | ReportData += 4; | ||
| 68 | break; | ||
| 69 | |||
| 70 | case HID_RI_DATA_BITS_16: | ||
| 71 | ReportItemData = (((uint16_t)ReportData[1] << 8) | (ReportData[0])); | ||
| 72 | ReportSize -= 2; | ||
| 73 | ReportData += 2; | ||
| 74 | break; | ||
| 75 | |||
| 76 | case HID_RI_DATA_BITS_8: | ||
| 77 | ReportItemData = ReportData[0]; | ||
| 78 | ReportSize -= 1; | ||
| 79 | ReportData += 1; | ||
| 80 | break; | ||
| 81 | |||
| 82 | default: | ||
| 83 | ReportItemData = 0; | ||
| 84 | break; | ||
| 85 | } | ||
| 86 | |||
| 87 | switch (HIDReportItem & (HID_RI_TYPE_MASK | HID_RI_TAG_MASK)) | ||
| 88 | { | ||
| 89 | case HID_RI_PUSH(0): | ||
| 90 | if (CurrStateTable == &StateTable[HID_STATETABLE_STACK_DEPTH - 1]) | ||
| 91 | return HID_PARSE_HIDStackOverflow; | ||
| 92 | |||
| 93 | memcpy((CurrStateTable + 1), | ||
| 94 | CurrStateTable, | ||
| 95 | sizeof(HID_ReportItem_t)); | ||
| 96 | |||
| 97 | CurrStateTable++; | ||
| 98 | break; | ||
| 99 | |||
| 100 | case HID_RI_POP(0): | ||
| 101 | if (CurrStateTable == &StateTable[0]) | ||
| 102 | return HID_PARSE_HIDStackUnderflow; | ||
| 103 | |||
| 104 | CurrStateTable--; | ||
| 105 | break; | ||
| 106 | |||
| 107 | case HID_RI_USAGE_PAGE(0): | ||
| 108 | if ((HIDReportItem & HID_RI_DATA_SIZE_MASK) == HID_RI_DATA_BITS_32) | ||
| 109 | CurrStateTable->Attributes.Usage.Page = (ReportItemData >> 16); | ||
| 110 | |||
| 111 | CurrStateTable->Attributes.Usage.Page = ReportItemData; | ||
| 112 | break; | ||
| 113 | |||
| 114 | case HID_RI_LOGICAL_MINIMUM(0): | ||
| 115 | CurrStateTable->Attributes.Logical.Minimum = ReportItemData; | ||
| 116 | break; | ||
| 117 | |||
| 118 | case HID_RI_LOGICAL_MAXIMUM(0): | ||
| 119 | CurrStateTable->Attributes.Logical.Maximum = ReportItemData; | ||
| 120 | break; | ||
| 121 | |||
| 122 | case HID_RI_PHYSICAL_MINIMUM(0): | ||
| 123 | CurrStateTable->Attributes.Physical.Minimum = ReportItemData; | ||
| 124 | break; | ||
| 125 | |||
| 126 | case HID_RI_PHYSICAL_MAXIMUM(0): | ||
| 127 | CurrStateTable->Attributes.Physical.Maximum = ReportItemData; | ||
| 128 | break; | ||
| 129 | |||
| 130 | case HID_RI_UNIT_EXPONENT(0): | ||
| 131 | CurrStateTable->Attributes.Unit.Exponent = ReportItemData; | ||
| 132 | break; | ||
| 133 | |||
| 134 | case HID_RI_UNIT(0): | ||
| 135 | CurrStateTable->Attributes.Unit.Type = ReportItemData; | ||
| 136 | break; | ||
| 137 | |||
| 138 | case HID_RI_REPORT_SIZE(0): | ||
| 139 | CurrStateTable->Attributes.BitSize = ReportItemData; | ||
| 140 | break; | ||
| 141 | |||
| 142 | case HID_RI_REPORT_COUNT(0): | ||
| 143 | CurrStateTable->ReportCount = ReportItemData; | ||
| 144 | break; | ||
| 145 | |||
| 146 | case HID_RI_REPORT_ID(0): | ||
| 147 | CurrStateTable->ReportID = ReportItemData; | ||
| 148 | |||
| 149 | if (ParserData->UsingReportIDs) | ||
| 150 | { | ||
| 151 | CurrReportIDInfo = NULL; | ||
| 152 | |||
| 153 | for (uint8_t i = 0; i < ParserData->TotalDeviceReports; i++) | ||
| 154 | { | ||
| 155 | if (ParserData->ReportIDSizes[i].ReportID == CurrStateTable->ReportID) | ||
| 156 | { | ||
| 157 | CurrReportIDInfo = &ParserData->ReportIDSizes[i]; | ||
| 158 | break; | ||
| 159 | } | ||
| 160 | } | ||
| 161 | |||
| 162 | if (CurrReportIDInfo == NULL) | ||
| 163 | { | ||
| 164 | if (ParserData->TotalDeviceReports == HID_MAX_REPORT_IDS) | ||
| 165 | return HID_PARSE_InsufficientReportIDItems; | ||
| 166 | |||
| 167 | CurrReportIDInfo = &ParserData->ReportIDSizes[ParserData->TotalDeviceReports++]; | ||
| 168 | memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t)); | ||
| 169 | } | ||
| 170 | } | ||
| 171 | |||
| 172 | ParserData->UsingReportIDs = true; | ||
| 173 | |||
| 174 | CurrReportIDInfo->ReportID = CurrStateTable->ReportID; | ||
| 175 | break; | ||
| 176 | |||
| 177 | case HID_RI_USAGE(0): | ||
| 178 | if (UsageListSize == HID_USAGE_STACK_DEPTH) | ||
| 179 | return HID_PARSE_UsageListOverflow; | ||
| 180 | |||
| 181 | UsageList[UsageListSize++] = ReportItemData; | ||
| 182 | break; | ||
| 183 | |||
| 184 | case HID_RI_USAGE_MINIMUM(0): | ||
| 185 | UsageMinMax.Minimum = ReportItemData; | ||
| 186 | break; | ||
| 187 | |||
| 188 | case HID_RI_USAGE_MAXIMUM(0): | ||
| 189 | UsageMinMax.Maximum = ReportItemData; | ||
| 190 | break; | ||
| 191 | |||
| 192 | case HID_RI_COLLECTION(0): | ||
| 193 | if (CurrCollectionPath == NULL) | ||
| 194 | { | ||
| 195 | CurrCollectionPath = &ParserData->CollectionPaths[0]; | ||
| 196 | } | ||
| 197 | else | ||
| 198 | { | ||
| 199 | HID_CollectionPath_t* ParentCollectionPath = CurrCollectionPath; | ||
| 200 | |||
| 201 | CurrCollectionPath = &ParserData->CollectionPaths[1]; | ||
| 202 | |||
| 203 | while (CurrCollectionPath->Parent != NULL) | ||
| 204 | { | ||
| 205 | if (CurrCollectionPath == &ParserData->CollectionPaths[HID_MAX_COLLECTIONS - 1]) | ||
| 206 | return HID_PARSE_InsufficientCollectionPaths; | ||
| 207 | |||
| 208 | CurrCollectionPath++; | ||
| 209 | } | ||
| 210 | |||
| 211 | CurrCollectionPath->Parent = ParentCollectionPath; | ||
| 212 | } | ||
| 213 | |||
| 214 | CurrCollectionPath->Type = ReportItemData; | ||
| 215 | CurrCollectionPath->Usage.Page = CurrStateTable->Attributes.Usage.Page; | ||
| 216 | |||
| 217 | if (UsageListSize) | ||
| 218 | { | ||
| 219 | CurrCollectionPath->Usage.Usage = UsageList[0]; | ||
| 220 | |||
| 221 | for (uint8_t i = 1; i < UsageListSize; i++) | ||
| 222 | UsageList[i - 1] = UsageList[i]; | ||
| 223 | |||
| 224 | UsageListSize--; | ||
| 225 | } | ||
| 226 | else if (UsageMinMax.Minimum <= UsageMinMax.Maximum) | ||
| 227 | { | ||
| 228 | CurrCollectionPath->Usage.Usage = UsageMinMax.Minimum++; | ||
| 229 | } | ||
| 230 | |||
| 231 | break; | ||
| 232 | |||
| 233 | case HID_RI_END_COLLECTION(0): | ||
| 234 | if (CurrCollectionPath == NULL) | ||
| 235 | return HID_PARSE_UnexpectedEndCollection; | ||
| 236 | |||
| 237 | CurrCollectionPath = CurrCollectionPath->Parent; | ||
| 238 | break; | ||
| 239 | |||
| 240 | case HID_RI_INPUT(0): | ||
| 241 | case HID_RI_OUTPUT(0): | ||
| 242 | case HID_RI_FEATURE(0): | ||
| 243 | for (uint8_t ReportItemNum = 0; ReportItemNum < CurrStateTable->ReportCount; ReportItemNum++) | ||
| 244 | { | ||
| 245 | HID_ReportItem_t NewReportItem; | ||
| 246 | |||
| 247 | memcpy(&NewReportItem.Attributes, | ||
| 248 | &CurrStateTable->Attributes, | ||
| 249 | sizeof(HID_ReportItem_Attributes_t)); | ||
| 250 | |||
| 251 | NewReportItem.ItemFlags = ReportItemData; | ||
| 252 | NewReportItem.CollectionPath = CurrCollectionPath; | ||
| 253 | NewReportItem.ReportID = CurrStateTable->ReportID; | ||
| 254 | |||
| 255 | if (UsageListSize) | ||
| 256 | { | ||
| 257 | NewReportItem.Attributes.Usage.Usage = UsageList[0]; | ||
| 258 | |||
| 259 | for (uint8_t i = 1; i < UsageListSize; i++) | ||
| 260 | UsageList[i - 1] = UsageList[i]; | ||
| 261 | |||
| 262 | UsageListSize--; | ||
| 263 | } | ||
| 264 | else if (UsageMinMax.Minimum <= UsageMinMax.Maximum) | ||
| 265 | { | ||
| 266 | NewReportItem.Attributes.Usage.Usage = UsageMinMax.Minimum++; | ||
| 267 | } | ||
| 268 | |||
| 269 | uint8_t ItemTypeTag = (HIDReportItem & (HID_RI_TYPE_MASK | HID_RI_TAG_MASK)); | ||
| 270 | |||
| 271 | if (ItemTypeTag == HID_RI_INPUT(0)) | ||
| 272 | NewReportItem.ItemType = HID_REPORT_ITEM_In; | ||
| 273 | else if (ItemTypeTag == HID_RI_OUTPUT(0)) | ||
| 274 | NewReportItem.ItemType = HID_REPORT_ITEM_Out; | ||
| 275 | else | ||
| 276 | NewReportItem.ItemType = HID_REPORT_ITEM_Feature; | ||
| 277 | |||
| 278 | NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType]; | ||
| 279 | |||
| 280 | CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType] += CurrStateTable->Attributes.BitSize; | ||
| 281 | |||
| 282 | ParserData->LargestReportSizeBits = MAX(ParserData->LargestReportSizeBits, CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType]); | ||
| 283 | |||
| 284 | if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS) | ||
| 285 | return HID_PARSE_InsufficientReportItems; | ||
| 286 | |||
| 287 | memcpy(&ParserData->ReportItems[ParserData->TotalReportItems], | ||
| 288 | &NewReportItem, sizeof(HID_ReportItem_t)); | ||
| 289 | |||
| 290 | if (!(ReportItemData & HID_IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem)) | ||
| 291 | ParserData->TotalReportItems++; | ||
| 292 | } | ||
| 293 | |||
| 294 | break; | ||
| 295 | |||
| 296 | default: | ||
| 297 | break; | ||
| 298 | } | ||
| 299 | |||
| 300 | if ((HIDReportItem & HID_RI_TYPE_MASK) == HID_RI_TYPE_MAIN) | ||
| 301 | { | ||
| 302 | UsageMinMax.Minimum = 0; | ||
| 303 | UsageMinMax.Maximum = 0; | ||
| 304 | UsageListSize = 0; | ||
| 305 | } | ||
| 306 | } | ||
| 307 | |||
| 308 | if (!(ParserData->TotalReportItems)) | ||
| 309 | return HID_PARSE_NoUnfilteredReportItems; | ||
| 310 | |||
| 311 | return HID_PARSE_Successful; | ||
| 312 | } | ||
| 313 | |||
| 314 | bool USB_GetHIDReportItemInfo(const uint8_t* ReportData, | ||
| 315 | HID_ReportItem_t* const ReportItem) | ||
| 316 | { | ||
| 317 | if (ReportItem == NULL) | ||
| 318 | return false; | ||
| 319 | |||
| 320 | uint16_t DataBitsRem = ReportItem->Attributes.BitSize; | ||
| 321 | uint16_t CurrentBit = ReportItem->BitOffset; | ||
| 322 | uint32_t BitMask = (1 << 0); | ||
| 323 | |||
| 324 | if (ReportItem->ReportID) | ||
| 325 | { | ||
| 326 | if (ReportItem->ReportID != ReportData[0]) | ||
| 327 | return false; | ||
| 328 | |||
| 329 | ReportData++; | ||
| 330 | } | ||
| 331 | |||
| 332 | ReportItem->PreviousValue = ReportItem->Value; | ||
| 333 | ReportItem->Value = 0; | ||
| 334 | |||
| 335 | while (DataBitsRem--) | ||
| 336 | { | ||
| 337 | if (ReportData[CurrentBit / 8] & (1 << (CurrentBit % 8))) | ||
| 338 | ReportItem->Value |= BitMask; | ||
| 339 | |||
| 340 | CurrentBit++; | ||
| 341 | BitMask <<= 1; | ||
| 342 | } | ||
| 343 | |||
| 344 | return true; | ||
| 345 | } | ||
| 346 | |||
| 347 | void USB_SetHIDReportItemInfo(uint8_t* ReportData, | ||
| 348 | HID_ReportItem_t* const ReportItem) | ||
| 349 | { | ||
| 350 | if (ReportItem == NULL) | ||
| 351 | return; | ||
| 352 | |||
| 353 | uint16_t DataBitsRem = ReportItem->Attributes.BitSize; | ||
| 354 | uint16_t CurrentBit = ReportItem->BitOffset; | ||
| 355 | uint32_t BitMask = (1 << 0); | ||
| 356 | |||
| 357 | if (ReportItem->ReportID) | ||
| 358 | { | ||
| 359 | ReportData[0] = ReportItem->ReportID; | ||
| 360 | ReportData++; | ||
| 361 | } | ||
| 362 | |||
| 363 | ReportItem->PreviousValue = ReportItem->Value; | ||
| 364 | |||
| 365 | while (DataBitsRem--) | ||
| 366 | { | ||
| 367 | if (ReportItem->Value & BitMask) | ||
| 368 | ReportData[CurrentBit / 8] |= (1 << (CurrentBit % 8)); | ||
| 369 | |||
| 370 | CurrentBit++; | ||
| 371 | BitMask <<= 1; | ||
| 372 | } | ||
| 373 | } | ||
| 374 | |||
| 375 | uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData, | ||
| 376 | const uint8_t ReportID, | ||
| 377 | const uint8_t ReportType) | ||
| 378 | { | ||
| 379 | for (uint8_t i = 0; i < HID_MAX_REPORT_IDS; i++) | ||
| 380 | { | ||
| 381 | uint16_t ReportSizeBits = ParserData->ReportIDSizes[i].ReportSizeBits[ReportType]; | ||
| 382 | |||
| 383 | if (ParserData->ReportIDSizes[i].ReportID == ReportID) | ||
| 384 | return (ReportSizeBits / 8) + ((ReportSizeBits % 8) ? 1 : 0); | ||
| 385 | } | ||
| 386 | |||
| 387 | return 0; | ||
| 388 | } | ||
| 389 | |||
diff --git a/lib/lufa/LUFA/Drivers/USB/Class/Common/HIDParser.h b/lib/lufa/LUFA/Drivers/USB/Class/Common/HIDParser.h new file mode 100644 index 000000000..023316d7e --- /dev/null +++ b/lib/lufa/LUFA/Drivers/USB/Class/Common/HIDParser.h | |||
| @@ -0,0 +1,364 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 12 | Permission to use, copy, modify, distribute, and sell this | ||
| 13 | software and its documentation for any purpose is hereby granted | ||
| 14 | without fee, provided that the above copyright notice appear in | ||
| 15 | all copies and that both that the copyright notice and this | ||
| 16 | permission notice and warranty disclaimer appear in supporting | ||
| 17 | documentation, and that the name of the author not be used in | ||
| 18 | advertising or publicity pertaining to distribution of the | ||
| 19 | software without specific, written prior permission. | ||
| 20 | |||
| 21 | The author disclaims all warranties with regard to this | ||
| 22 | software, including all implied warranties of merchantability | ||
| 23 | and fitness. In no event shall the author be liable for any | ||
| 24 | special, indirect or consequential damages or any damages | ||
| 25 | whatsoever resulting from loss of use, data or profits, whether | ||
| 26 | in an action of contract, negligence or other tortious action, | ||
| 27 | arising out of or in connection with the use or performance of | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | /** \file | ||
| 32 | * \brief USB Human Interface Device (HID) Class report descriptor parser. | ||
| 33 | * | ||
| 34 | * This file allows for the easy parsing of complex HID report descriptors, which describes the data that | ||
| 35 | * a HID device transmits to the host. It also provides an easy API for extracting and processing the data | ||
| 36 | * elements inside a HID report sent from an attached HID device. | ||
| 37 | */ | ||
| 38 | |||
| 39 | /** \ingroup Group_USB | ||
| 40 | * \defgroup Group_HIDParser HID Report Parser | ||
| 41 | * \brief USB Human Interface Device (HID) Class report descriptor parser. | ||
| 42 | * | ||
| 43 | * \section Sec_HIDParser_Dependencies Module Source Dependencies | ||
| 44 | * The following files must be built with any user project that uses this module: | ||
| 45 | * - LUFA/Drivers/USB/Class/Host/HIDParser.c <i>(Makefile source module name: LUFA_SRC_USB)</i> | ||
| 46 | * | ||
| 47 | * \section Sec_HIDParser_ModDescription Module Description | ||
| 48 | * Human Interface Device (HID) class report descriptor parser. This module implements a parser than is | ||
| 49 | * capable of processing a complete HID report descriptor, and outputting a flat structure containing the | ||
| 50 | * contents of the report in an a more friendly format. The parsed data may then be further processed and used | ||
| 51 | * within an application to process sent and received HID reports to and from an attached HID device. | ||
| 52 | * | ||
| 53 | * A HID report descriptor consists of a set of HID report items, which describe the function and layout | ||
| 54 | * of data exchanged between a HID device and a host, including both the physical encoding of each item | ||
| 55 | * (such as a button, key press or joystick axis) in the sent and received data packets - known as "reports" - | ||
| 56 | * as well as other information about each item such as the usages, data range, physical location and other | ||
| 57 | * characteristics. In this way a HID device can retain a high degree of flexibility in its capabilities, as it | ||
| 58 | * is not forced to comply with a given report layout or feature-set. | ||
| 59 | * | ||
| 60 | * This module also contains routines for the processing of data in an actual HID report, using the parsed report | ||
| 61 | * descriptor data as a guide for the encoding. | ||
| 62 | * | ||
| 63 | * @{ | ||
| 64 | */ | ||
| 65 | |||
| 66 | #ifndef __HIDPARSER_H__ | ||
| 67 | #define __HIDPARSER_H__ | ||
| 68 | |||
| 69 | /* Includes: */ | ||
| 70 | #include "../../../../Common/Common.h" | ||
| 71 | |||
| 72 | #include "HIDReportData.h" | ||
| 73 | #include "HIDClassCommon.h" | ||
| 74 | |||
| 75 | /* Enable C linkage for C++ Compilers: */ | ||
| 76 | #if defined(__cplusplus) | ||
| 77 | extern "C" { | ||
| 78 | #endif | ||
| 79 | |||
| 80 | /* Macros: */ | ||
| 81 | #if !defined(HID_STATETABLE_STACK_DEPTH) || defined(__DOXYGEN__) | ||
| 82 | /** Constant indicating the maximum stack depth of the state table. A larger state table | ||
| 83 | * allows for more PUSH/POP report items to be nested, but consumes more memory. By default | ||
| 84 | * this is set to 2 levels (allowing non-nested PUSH items) but this can be overridden by | ||
| 85 | * defining \c HID_STATETABLE_STACK_DEPTH to another value in the user project makefile, passing the | ||
| 86 | * define to the compiler using the -D compiler switch. | ||
| 87 | */ | ||
| 88 | #define HID_STATETABLE_STACK_DEPTH 2 | ||
| 89 | #endif | ||
| 90 | |||
| 91 | #if !defined(HID_USAGE_STACK_DEPTH) || defined(__DOXYGEN__) | ||
| 92 | /** Constant indicating the maximum stack depth of the usage table. A larger usage table | ||
| 93 | * allows for more USAGE items to be indicated sequentially for REPORT COUNT entries of more than | ||
| 94 | * one, but requires more stack space. By default this is set to 8 levels (allowing for a report | ||
| 95 | * item with a count of 8) but this can be overridden by defining \c HID_USAGE_STACK_DEPTH to another | ||
| 96 | * value in the user project makefile, passing the define to the compiler using the -D compiler | ||
| 97 | * switch. | ||
| 98 | */ | ||
| 99 | #define HID_USAGE_STACK_DEPTH 8 | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #if !defined(HID_MAX_COLLECTIONS) || defined(__DOXYGEN__) | ||
| 103 | /** Constant indicating the maximum number of COLLECTION items (nested or unnested) that can be | ||
| 104 | * processed in the report item descriptor. A large value allows for more COLLECTION items to be | ||
| 105 | * processed, but consumes more memory. By default this is set to 10 collections, but this can be | ||
| 106 | * overridden by defining \c HID_MAX_COLLECTIONS to another value in the user project makefile, passing | ||
| 107 | * the define to the compiler using the -D compiler switch. | ||
| 108 | */ | ||
| 109 | #define HID_MAX_COLLECTIONS 10 | ||
| 110 | #endif | ||
| 111 | |||
| 112 | #if !defined(HID_MAX_REPORTITEMS) || defined(__DOXYGEN__) | ||
| 113 | /** Constant indicating the maximum number of report items (IN, OUT or FEATURE) that can be processed | ||
| 114 | * in the report item descriptor and stored in the user HID Report Info structure. A large value allows | ||
| 115 | * for more report items to be stored, but consumes more memory. By default this is set to 20 items, | ||
| 116 | * but this can be overridden by defining \c HID_MAX_REPORTITEMS to another value in the user project | ||
| 117 | * makefile, and passing the define to the compiler using the -D compiler switch. | ||
| 118 | */ | ||
| 119 | #define HID_MAX_REPORTITEMS 20 | ||
| 120 | #endif | ||
| 121 | |||
| 122 | #if !defined(HID_MAX_REPORT_IDS) || defined(__DOXYGEN__) | ||
| 123 | /** Constant indicating the maximum number of unique report IDs that can be processed in the report item | ||
| 124 | * descriptor for the report size information array in the user HID Report Info structure. A large value | ||
| 125 | * allows for more report ID report sizes to be stored, but consumes more memory. By default this is set | ||
| 126 | * to 10 items, but this can be overridden by defining \c HID_MAX_REPORT_IDS to another value in the user project | ||
| 127 | * makefile, and passing the define to the compiler using the -D compiler switch. Note that IN, OUT and FEATURE | ||
| 128 | * items sharing the same report ID consume only one size item in the array. | ||
| 129 | */ | ||
| 130 | #define HID_MAX_REPORT_IDS 10 | ||
| 131 | #endif | ||
| 132 | |||
| 133 | /** Returns the value a given HID report item (once its value has been fetched via \ref USB_GetHIDReportItemInfo()) | ||
| 134 | * left-aligned to the given data type. This allows for signed data to be interpreted correctly, by shifting the data | ||
| 135 | * leftwards until the data's sign bit is in the correct position. | ||
| 136 | * | ||
| 137 | * \param[in] ReportItem HID Report Item whose retrieved value is to be aligned. | ||
| 138 | * \param[in] Type Data type to align the HID report item's value to. | ||
| 139 | * | ||
| 140 | * \return Left-aligned data of the given report item's pre-retrieved value for the given datatype. | ||
| 141 | */ | ||
| 142 | #define HID_ALIGN_DATA(ReportItem, Type) ((Type)(ReportItem->Value << ((8 * sizeof(Type)) - ReportItem->Attributes.BitSize))) | ||
| 143 | |||
| 144 | /* Public Interface - May be used in end-application: */ | ||
| 145 | /* Enums: */ | ||
| 146 | /** Enum for the possible error codes in the return value of the \ref USB_ProcessHIDReport() function. */ | ||
| 147 | enum HID_Parse_ErrorCodes_t | ||
| 148 | { | ||
| 149 | HID_PARSE_Successful = 0, /**< Successful parse of the HID report descriptor, no error. */ | ||
| 150 | HID_PARSE_HIDStackOverflow = 1, /**< More than \ref HID_STATETABLE_STACK_DEPTH nested PUSHes in the report. */ | ||
| 151 | HID_PARSE_HIDStackUnderflow = 2, /**< A POP was found when the state table stack was empty. */ | ||
| 152 | HID_PARSE_InsufficientReportItems = 3, /**< More than \ref HID_MAX_REPORTITEMS report items in the report. */ | ||
| 153 | HID_PARSE_UnexpectedEndCollection = 4, /**< An END COLLECTION item found without matching COLLECTION item. */ | ||
| 154 | HID_PARSE_InsufficientCollectionPaths = 5, /**< More than \ref HID_MAX_COLLECTIONS collections in the report. */ | ||
| 155 | HID_PARSE_UsageListOverflow = 6, /**< More than \ref HID_USAGE_STACK_DEPTH usages listed in a row. */ | ||
| 156 | HID_PARSE_InsufficientReportIDItems = 7, /**< More than \ref HID_MAX_REPORT_IDS report IDs in the device. */ | ||
| 157 | HID_PARSE_NoUnfilteredReportItems = 8, /**< All report items from the device were filtered by the filtering callback routine. */ | ||
| 158 | }; | ||
| 159 | |||
| 160 | /* Type Defines: */ | ||
| 161 | /** \brief HID Parser Report Item Min/Max Structure. | ||
| 162 | * | ||
| 163 | * Type define for an attribute with both minimum and maximum values (e.g. Logical Min/Max). | ||
| 164 | */ | ||
| 165 | typedef struct | ||
| 166 | { | ||
| 167 | uint32_t Minimum; /**< Minimum value for the attribute. */ | ||
| 168 | uint32_t Maximum; /**< Maximum value for the attribute. */ | ||
| 169 | } HID_MinMax_t; | ||
| 170 | |||
| 171 | /** \brief HID Parser Report Item Unit Structure. | ||
| 172 | * | ||
| 173 | * Type define for the Unit attributes of a report item. | ||
| 174 | */ | ||
| 175 | typedef struct | ||
| 176 | { | ||
| 177 | uint32_t Type; /**< Unit type (refer to HID specifications for details). */ | ||
| 178 | uint8_t Exponent; /**< Unit exponent (refer to HID specifications for details). */ | ||
| 179 | } HID_Unit_t; | ||
| 180 | |||
| 181 | /** \brief HID Parser Report Item Usage Structure. | ||
| 182 | * | ||
| 183 | * Type define for the Usage attributes of a report item. | ||
| 184 | */ | ||
| 185 | typedef struct | ||
| 186 | { | ||
| 187 | uint16_t Page; /**< Usage page of the report item. */ | ||
| 188 | uint16_t Usage; /**< Usage of the report item. */ | ||
| 189 | } HID_Usage_t; | ||
| 190 | |||
| 191 | /** \brief HID Parser Report Item Collection Path Structure. | ||
| 192 | * | ||
| 193 | * Type define for a COLLECTION object. Contains the collection attributes and a reference to the | ||
| 194 | * parent collection if any. | ||
| 195 | */ | ||
| 196 | typedef struct HID_CollectionPath | ||
| 197 | { | ||
| 198 | uint8_t Type; /**< Collection type (e.g. "Generic Desktop"). */ | ||
| 199 | HID_Usage_t Usage; /**< Collection usage. */ | ||
| 200 | struct HID_CollectionPath* Parent; /**< Reference to parent collection, or \c NULL if root collection. */ | ||
| 201 | } HID_CollectionPath_t; | ||
| 202 | |||
| 203 | /** \brief HID Parser Report Item Attributes Structure. | ||
| 204 | * | ||
| 205 | * Type define for all the data attributes of a report item, except flags. | ||
| 206 | */ | ||
| 207 | typedef struct | ||
| 208 | { | ||
| 209 | uint8_t BitSize; /**< Size in bits of the report item's data. */ | ||
| 210 | |||
| 211 | HID_Usage_t Usage; /**< Usage of the report item. */ | ||
| 212 | HID_Unit_t Unit; /**< Unit type and exponent of the report item. */ | ||
| 213 | HID_MinMax_t Logical; /**< Logical minimum and maximum of the report item. */ | ||
| 214 | HID_MinMax_t Physical; /**< Physical minimum and maximum of the report item. */ | ||
| 215 | } HID_ReportItem_Attributes_t; | ||
| 216 | |||
| 217 | /** \brief HID Parser Report Item Details Structure. | ||
| 218 | * | ||
| 219 | * Type define for a report item (IN, OUT or FEATURE) layout attributes and other details. | ||
| 220 | */ | ||
| 221 | typedef struct | ||
| 222 | { | ||
| 223 | uint16_t BitOffset; /**< Bit offset in the IN, OUT or FEATURE report of the item. */ | ||
| 224 | uint8_t ItemType; /**< Report item type, a value in \ref HID_ReportItemTypes_t. */ | ||
| 225 | uint16_t ItemFlags; /**< Item data flags, a mask of \c HID_IOF_* constants. */ | ||
| 226 | uint8_t ReportID; /**< Report ID this item belongs to, or 0x00 if device has only one report */ | ||
| 227 | HID_CollectionPath_t* CollectionPath; /**< Collection path of the item. */ | ||
| 228 | |||
| 229 | HID_ReportItem_Attributes_t Attributes; /**< Report item attributes. */ | ||
| 230 | |||
| 231 | uint32_t Value; /**< Current value of the report item - use \ref HID_ALIGN_DATA() when processing | ||
| 232 | * a retrieved value so that it is aligned to a specific type. | ||
| 233 | */ | ||
| 234 | uint32_t PreviousValue; /**< Previous value of the report item. */ | ||
| 235 | } HID_ReportItem_t; | ||
| 236 | |||
| 237 | /** \brief HID Parser Report Size Structure. | ||
| 238 | * | ||
| 239 | * Type define for a report item size information structure, to retain the size of a device's reports by ID. | ||
| 240 | */ | ||
| 241 | typedef struct | ||
| 242 | { | ||
| 243 | uint8_t ReportID; /**< Report ID of the report within the HID interface. */ | ||
| 244 | uint16_t ReportSizeBits[3]; /**< Total number of bits in each report type for the given Report ID, | ||
| 245 | * indexed by the \ref HID_ReportItemTypes_t enum. | ||
| 246 | */ | ||
| 247 | } HID_ReportSizeInfo_t; | ||
| 248 | |||
| 249 | /** \brief HID Parser State Structure. | ||
| 250 | * | ||
| 251 | * Type define for a complete processed HID report, including all report item data and collections. | ||
| 252 | */ | ||
| 253 | typedef struct | ||
| 254 | { | ||
| 255 | uint8_t TotalReportItems; /**< Total number of report items stored in the \c ReportItems array. */ | ||
| 256 | HID_ReportItem_t ReportItems[HID_MAX_REPORTITEMS]; /**< Report items array, including all IN, OUT | ||
| 257 | * and FEATURE items. | ||
| 258 | */ | ||
| 259 | HID_CollectionPath_t CollectionPaths[HID_MAX_COLLECTIONS]; /**< All collection items, referenced | ||
| 260 | * by the report items. | ||
| 261 | */ | ||
| 262 | uint8_t TotalDeviceReports; /**< Number of reports within the HID interface */ | ||
| 263 | HID_ReportSizeInfo_t ReportIDSizes[HID_MAX_REPORT_IDS]; /**< Report sizes for each report in the interface */ | ||
| 264 | uint16_t LargestReportSizeBits; /**< Largest report that the attached device will generate, in bits */ | ||
| 265 | bool UsingReportIDs; /**< Indicates if the device has at least one REPORT ID | ||
| 266 | * element in its HID report descriptor. | ||
| 267 | */ | ||
| 268 | } HID_ReportInfo_t; | ||
| 269 | |||
| 270 | /* Function Prototypes: */ | ||
| 271 | /** Function to process a given HID report returned from an attached device, and store it into a given | ||
| 272 | * \ref HID_ReportInfo_t structure. | ||
| 273 | * | ||
| 274 | * \param[in] ReportData Buffer containing the device's HID report table. | ||
| 275 | * \param[in] ReportSize Size in bytes of the HID report table. | ||
| 276 | * \param[out] ParserData Pointer to a \ref HID_ReportInfo_t instance for the parser output. | ||
| 277 | * | ||
| 278 | * \return A value in the \ref HID_Parse_ErrorCodes_t enum. | ||
| 279 | */ | ||
| 280 | uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, | ||
| 281 | uint16_t ReportSize, | ||
| 282 | HID_ReportInfo_t* const ParserData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); | ||
| 283 | |||
| 284 | /** Extracts the given report item's value out of the given HID report and places it into the Value | ||
| 285 | * member of the report item's \ref HID_ReportItem_t structure. | ||
| 286 | * | ||
| 287 | * When called on a report with an item that exists in that report, this copies the report item's \c Value | ||
| 288 | * to its \c PreviousValue element for easy checking to see if an item's value has changed before processing | ||
| 289 | * a report. If the given item does not exist in the report, the function does not modify the report item's | ||
| 290 | * data. | ||
| 291 | * | ||
| 292 | * \param[in] ReportData Buffer containing an IN or FEATURE report from an attached device. | ||
| 293 | * \param[in,out] ReportItem Pointer to the report item of interest in a \ref HID_ReportInfo_t ReportItem array. | ||
| 294 | * | ||
| 295 | * \returns Boolean \c true if the item to retrieve was located in the given report, \c false otherwise. | ||
| 296 | */ | ||
| 297 | bool USB_GetHIDReportItemInfo(const uint8_t* ReportData, | ||
| 298 | HID_ReportItem_t* const ReportItem) ATTR_NON_NULL_PTR_ARG(1); | ||
| 299 | |||
| 300 | /** Retrieves the given report item's value out of the \c Value member of the report item's | ||
| 301 | * \ref HID_ReportItem_t structure and places it into the correct position in the HID report | ||
| 302 | * buffer. The report buffer is assumed to have the appropriate bits cleared before calling | ||
| 303 | * this function (i.e., the buffer should be explicitly cleared before report values are added). | ||
| 304 | * | ||
| 305 | * When called, this copies the report item's \c Value element to its \c PreviousValue element for easy | ||
| 306 | * checking to see if an item's value has changed before sending a report. | ||
| 307 | * | ||
| 308 | * If the device has multiple HID reports, the first byte in the report is set to the report ID of the given item. | ||
| 309 | * | ||
| 310 | * \param[out] ReportData Buffer holding the current OUT or FEATURE report data. | ||
| 311 | * \param[in] ReportItem Pointer to the report item of interest in a \ref HID_ReportInfo_t ReportItem array. | ||
| 312 | */ | ||
| 313 | void USB_SetHIDReportItemInfo(uint8_t* ReportData, | ||
| 314 | HID_ReportItem_t* const ReportItem) ATTR_NON_NULL_PTR_ARG(1); | ||
| 315 | |||
| 316 | /** Retrieves the size of a given HID report in bytes from its Report ID. | ||
| 317 | * | ||
| 318 | * \param[in] ParserData Pointer to a \ref HID_ReportInfo_t instance containing the parser output. | ||
| 319 | * \param[in] ReportID Report ID of the report whose size is to be determined. | ||
| 320 | * \param[in] ReportType Type of the report whose size is to be determined, a value from the | ||
| 321 | * \ref HID_ReportItemTypes_t enum. | ||
| 322 | * | ||
| 323 | * \return Size of the report in bytes, or \c 0 if the report does not exist. | ||
| 324 | */ | ||
| 325 | uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData, | ||
| 326 | const uint8_t ReportID, | ||
| 327 | const uint8_t ReportType) ATTR_CONST ATTR_NON_NULL_PTR_ARG(1); | ||
| 328 | |||
| 329 | /** Callback routine for the HID Report Parser. This callback <b>must</b> be implemented by the user code when | ||
| 330 | * the parser is used, to determine what report IN, OUT and FEATURE item's information is stored into the user | ||
| 331 | * \ref HID_ReportInfo_t structure. This can be used to filter only those items the application will be using, so that | ||
| 332 | * no RAM is wasted storing the attributes for report items which will never be referenced by the application. | ||
| 333 | * | ||
| 334 | * Report item pointers passed to this callback function may be cached by the user application for later use | ||
| 335 | * when processing report items. This provides faster report processing in the user application than would | ||
| 336 | * a search of the entire parsed report item table for each received or sent report. | ||
| 337 | * | ||
| 338 | * \param[in] CurrentItem Pointer to the current report item for user checking. | ||
| 339 | * | ||
| 340 | * \return Boolean \c true if the item should be stored into the \ref HID_ReportInfo_t structure, \c false if | ||
| 341 | * it should be ignored. | ||
| 342 | */ | ||
| 343 | bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem); | ||
| 344 | |||
| 345 | /* Private Interface - For use in library only: */ | ||
| 346 | #if !defined(__DOXYGEN__) | ||
| 347 | /* Type Defines: */ | ||
| 348 | typedef struct | ||
| 349 | { | ||
| 350 | HID_ReportItem_Attributes_t Attributes; | ||
| 351 | uint8_t ReportCount; | ||
| 352 | uint8_t ReportID; | ||
| 353 | } HID_StateTable_t; | ||
| 354 | #endif | ||
| 355 | |||
| 356 | /* Disable C linkage for C++ Compilers: */ | ||
| 357 | #if defined(__cplusplus) | ||
| 358 | } | ||
| 359 | #endif | ||
| 360 | |||
| 361 | #endif | ||
| 362 | |||
| 363 | /** @} */ | ||
| 364 | |||
diff --git a/lib/lufa/LUFA/Drivers/USB/Class/Common/HIDReportData.h b/lib/lufa/LUFA/Drivers/USB/Class/Common/HIDReportData.h new file mode 100644 index 000000000..fe1c4df94 --- /dev/null +++ b/lib/lufa/LUFA/Drivers/USB/Class/Common/HIDReportData.h | |||
| @@ -0,0 +1,126 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 12 | Permission to use, copy, modify, distribute, and sell this | ||
| 13 | software and its documentation for any purpose is hereby granted | ||
| 14 | without fee, provided that the above copyright notice appear in | ||
| 15 | all copies and that both that the copyright notice and this | ||
| 16 | permission notice and warranty disclaimer appear in supporting | ||
| 17 | documentation, and that the name of the author not be used in | ||
| 18 | advertising or publicity pertaining to distribution of the | ||
| 19 | software without specific, written prior permission. | ||
| 20 | |||
| 21 | The author disclaims all warranties with regard to this | ||
| 22 | software, including all implied warranties of merchantability | ||
| 23 | and fitness. In no event shall the author be liable for any | ||
| 24 | special, indirect or consequential damages or any damages | ||
| 25 | whatsoever resulting from loss of use, data or profits, whether | ||
| 26 | in an action of contract, negligence or other tortious action, | ||
| 27 | arising out of or in connection with the use or performance of | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | /** \file | ||
| 32 | * \brief Constants for HID report item attributes. | ||
| 33 | * | ||
| 34 | * HID report item constants for report item attributes. Refer to the HID specification for | ||
| 35 | * details on each flag's meaning when applied to an IN, OUT or FEATURE item. | ||
| 36 | */ | ||
| 37 | |||
| 38 | /** \ingroup Group_HIDParser | ||
| 39 | * \defgroup Group_HIDReportItemConst HID Report Descriptor Item Constants | ||
| 40 | * | ||
| 41 | * General HID constant definitions for HID Report Descriptor elements. | ||
| 42 | * | ||
| 43 | * @{ | ||
| 44 | */ | ||
| 45 | |||
| 46 | #ifndef __HIDREPORTDATA_H__ | ||
| 47 | #define __HIDREPORTDATA_H__ | ||
| 48 | |||
| 49 | /* Private Interface - For use in library only: */ | ||
| 50 | #if !defined(__DOXYGEN__) | ||
| 51 | /* Macros: */ | ||
| 52 | #define HID_RI_DATA_SIZE_MASK 0x03 | ||
| 53 | #define HID_RI_TYPE_MASK 0x0C | ||
| 54 | #define HID_RI_TAG_MASK 0xF0 | ||
| 55 | |||
| 56 | #define HID_RI_TYPE_MAIN 0x00 | ||
| 57 | #define HID_RI_TYPE_GLOBAL 0x04 | ||
| 58 | #define HID_RI_TYPE_LOCAL 0x08 | ||
| 59 | |||
| 60 | #define HID_RI_DATA_BITS_0 0x00 | ||
| 61 | #define HID_RI_DATA_BITS_8 0x01 | ||
| 62 | #define HID_RI_DATA_BITS_16 0x02 | ||
| 63 | #define HID_RI_DATA_BITS_32 0x03 | ||
| 64 | #define HID_RI_DATA_BITS(DataBits) CONCAT_EXPANDED(HID_RI_DATA_BITS_, DataBits) | ||
| 65 | |||
| 66 | #define _HID_RI_ENCODE_0(Data) | ||
| 67 | #define _HID_RI_ENCODE_8(Data) , (Data & 0xFF) | ||
| 68 | #define _HID_RI_ENCODE_16(Data) _HID_RI_ENCODE_8(Data) _HID_RI_ENCODE_8(Data >> 8) | ||
| 69 | #define _HID_RI_ENCODE_32(Data) _HID_RI_ENCODE_16(Data) _HID_RI_ENCODE_16(Data >> 16) | ||
| 70 | #define _HID_RI_ENCODE(DataBits, ...) CONCAT_EXPANDED(_HID_RI_ENCODE_, DataBits(__VA_ARGS__)) | ||
| 71 | |||
| 72 | #define _HID_RI_ENTRY(Type, Tag, DataBits, ...) (Type | Tag | HID_RI_DATA_BITS(DataBits)) _HID_RI_ENCODE(DataBits, (__VA_ARGS__)) | ||
| 73 | #endif | ||
| 74 | |||
| 75 | /* Public Interface - May be used in end-application: */ | ||
| 76 | /* Macros: */ | ||
| 77 | /** \name HID Input, Output and Feature Report Descriptor Item Flags */ | ||
| 78 | //@{ | ||
| 79 | #define HID_IOF_CONSTANT (1 << 0) | ||
| 80 | #define HID_IOF_DATA (0 << 0) | ||
| 81 | #define HID_IOF_VARIABLE (1 << 1) | ||
| 82 | #define HID_IOF_ARRAY (0 << 1) | ||
| 83 | #define HID_IOF_RELATIVE (1 << 2) | ||
| 84 | #define HID_IOF_ABSOLUTE (0 << 2) | ||
| 85 | #define HID_IOF_WRAP (1 << 3) | ||
| 86 | #define HID_IOF_NO_WRAP (0 << 3) | ||
| 87 | #define HID_IOF_NON_LINEAR (1 << 4) | ||
| 88 | #define HID_IOF_LINEAR (0 << 4) | ||
| 89 | #define HID_IOF_NO_PREFERRED_STATE (1 << 5) | ||
| 90 | #define HID_IOF_PREFERRED_STATE (0 << 5) | ||
| 91 | #define HID_IOF_NULLSTATE (1 << 6) | ||
| 92 | #define HID_IOF_NO_NULL_POSITION (0 << 6) | ||
| 93 | #define HID_IOF_VOLATILE (1 << 7) | ||
| 94 | #define HID_IOF_NON_VOLATILE (0 << 7) | ||
| 95 | #define HID_IOF_BUFFERED_BYTES (1 << 8) | ||
| 96 | #define HID_IOF_BITFIELD (0 << 8) | ||
| 97 | //@} | ||
| 98 | |||
| 99 | /** \name HID Report Descriptor Item Macros */ | ||
| 100 | //@{ | ||
| 101 | #define HID_RI_INPUT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0x80, DataBits, __VA_ARGS__) | ||
| 102 | #define HID_RI_OUTPUT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0x90, DataBits, __VA_ARGS__) | ||
| 103 | #define HID_RI_COLLECTION(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0xA0, DataBits, __VA_ARGS__) | ||
| 104 | #define HID_RI_FEATURE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0xB0, DataBits, __VA_ARGS__) | ||
| 105 | #define HID_RI_END_COLLECTION(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0xC0, DataBits, __VA_ARGS__) | ||
| 106 | #define HID_RI_USAGE_PAGE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x00, DataBits, __VA_ARGS__) | ||
| 107 | #define HID_RI_LOGICAL_MINIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x10, DataBits, __VA_ARGS__) | ||
| 108 | #define HID_RI_LOGICAL_MAXIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x20, DataBits, __VA_ARGS__) | ||
| 109 | #define HID_RI_PHYSICAL_MINIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x30, DataBits, __VA_ARGS__) | ||
| 110 | #define HID_RI_PHYSICAL_MAXIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x40, DataBits, __VA_ARGS__) | ||
| 111 | #define HID_RI_UNIT_EXPONENT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x50, DataBits, __VA_ARGS__) | ||
| 112 | #define HID_RI_UNIT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x60, DataBits, __VA_ARGS__) | ||
| 113 | #define HID_RI_REPORT_SIZE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x70, DataBits, __VA_ARGS__) | ||
| 114 | #define HID_RI_REPORT_ID(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x80, DataBits, __VA_ARGS__) | ||
| 115 | #define HID_RI_REPORT_COUNT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x90, DataBits, __VA_ARGS__) | ||
| 116 | #define HID_RI_PUSH(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0xA0, DataBits, __VA_ARGS__) | ||
| 117 | #define HID_RI_POP(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0xB0, DataBits, __VA_ARGS__) | ||
| 118 | #define HID_RI_USAGE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_LOCAL , 0x00, DataBits, __VA_ARGS__) | ||
| 119 | #define HID_RI_USAGE_MINIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_LOCAL , 0x10, DataBits, __VA_ARGS__) | ||
| 120 | #define HID_RI_USAGE_MAXIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_LOCAL , 0x20, DataBits, __VA_ARGS__) | ||
| 121 | //@} | ||
| 122 | |||
| 123 | /** @} */ | ||
| 124 | |||
| 125 | #endif | ||
| 126 | |||
diff --git a/lib/lufa/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h b/lib/lufa/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h new file mode 100644 index 000000000..b6414bc06 --- /dev/null +++ b/lib/lufa/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h | |||
| @@ -0,0 +1,363 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 12 | Permission to use, copy, modify, distribute, and sell this | ||
| 13 | software and its documentation for any purpose is hereby granted | ||
| 14 | without fee, provided that the above copyright notice appear in | ||
| 15 | all copies and that both that the copyright notice and this | ||
| 16 | permission notice and warranty disclaimer appear in supporting | ||
| 17 | documentation, and that the name of the author not be used in | ||
| 18 | advertising or publicity pertaining to distribution of the | ||
| 19 | software without specific, written prior permission. | ||
| 20 | |||
| 21 | The author disclaims all warranties with regard to this | ||
| 22 | software, including all implied warranties of merchantability | ||
| 23 | and fitness. In no event shall the author be liable for any | ||
| 24 | special, indirect or consequential damages or any damages | ||
| 25 | whatsoever resulting from loss of use, data or profits, whether | ||
| 26 | in an action of contract, negligence or other tortious action, | ||
| 27 | arising out of or in connection with the use or performance of | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | /** \file | ||
| 32 | * \brief Common definitions and declarations for the library USB MIDI Class driver. | ||
| 33 | * | ||
| 34 | * Common definitions and declarations for the library USB MIDI Class driver. | ||
| 35 | * | ||
| 36 | * \note This file should not be included directly. It is automatically included as needed by the USB module driver | ||
| 37 | * dispatch header located in LUFA/Drivers/USB.h. | ||
| 38 | */ | ||
| 39 | |||
| 40 | /** \ingroup Group_USBClassMIDI | ||
| 41 | * \defgroup Group_USBClassMIDICommon Common Class Definitions | ||
| 42 | * | ||
| 43 | * \section Sec_USBClassMIDICommon_ModDescription Module Description | ||
| 44 | * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB | ||
| 45 | * MIDI Class. | ||
| 46 | * | ||
| 47 | * @{ | ||
| 48 | */ | ||
| 49 | |||
| 50 | #ifndef _MIDI_CLASS_COMMON_H_ | ||
| 51 | #define _MIDI_CLASS_COMMON_H_ | ||
| 52 | |||
| 53 | /* Macros: */ | ||
| 54 | #define __INCLUDE_FROM_AUDIO_DRIVER | ||
| 55 | |||
| 56 | /* Includes: */ | ||
| 57 | #include "../../Core/StdDescriptors.h" | ||
| 58 | #include "AudioClassCommon.h" | ||
| 59 | |||
| 60 | /* Enable C linkage for C++ Compilers: */ | ||
| 61 | #if defined(__cplusplus) | ||
| 62 | extern "C" { | ||
| 63 | #endif | ||
| 64 | |||
| 65 | /* Preprocessor Checks: */ | ||
| 66 | #if !defined(__INCLUDE_FROM_MIDI_DRIVER) | ||
| 67 | #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. | ||
| 68 | #endif | ||
| 69 | |||
| 70 | /* Macros: */ | ||
| 71 | /** \name MIDI Command Values | ||
| 72 | * See http://www.midi.org/techspecs/midimessages.php for more information. | ||
| 73 | */ | ||
| 74 | //@{ | ||
| 75 | /** MIDI command for System Exclusive (SysEx) single event that has one byte of data total. */ | ||
| 76 | #define MIDI_COMMAND_SYSEX_1BYTE MIDI_COMMAND_SYSEX_END_1BYTE | ||
| 77 | |||
| 78 | /** MIDI command for System Exclusive (SysEx) single event that has two bytes of data total. */ | ||
| 79 | #define MIDI_COMMAND_SYSEX_2BYTE 0x20 | ||
| 80 | |||
| 81 | /** MIDI command for System Exclusive (SysEx) single event that has three bytes of data total. */ | ||
| 82 | #define MIDI_COMMAND_SYSEX_3BYTE 0x30 | ||
| 83 | |||
| 84 | /** MIDI command for System Exclusive (SysEx) stream event that has at least four bytes of data total. */ | ||
| 85 | #define MIDI_COMMAND_SYSEX_START_3BYTE 0x40 | ||
| 86 | |||
| 87 | /** MIDI command for System Exclusive (SysEx) stream event terminator with one remaining data byte. */ | ||
| 88 | #define MIDI_COMMAND_SYSEX_END_1BYTE 0x50 | ||
| 89 | |||
| 90 | /** MIDI command for System Exclusive (SysEx) stream event terminator with two remaining data bytes. */ | ||
| 91 | #define MIDI_COMMAND_SYSEX_END_2BYTE 0x60 | ||
| 92 | |||
| 93 | /** MIDI command for System Exclusive (SysEx) stream event terminator with three remaining data bytes. */ | ||
| 94 | #define MIDI_COMMAND_SYSEX_END_3BYTE 0x70 | ||
| 95 | |||
| 96 | /** MIDI command for a note off (deactivation) event. */ | ||
| 97 | #define MIDI_COMMAND_NOTE_OFF 0x80 | ||
| 98 | |||
| 99 | /** MIDI command for a note on (activation) event. */ | ||
| 100 | #define MIDI_COMMAND_NOTE_ON 0x90 | ||
| 101 | |||
| 102 | /** MIDI command for a note pressure change event. */ | ||
| 103 | #define MIDI_COMMAND_NOTE_PRESSURE 0xA0 | ||
| 104 | |||
| 105 | /** MIDI command for a control change event. */ | ||
| 106 | #define MIDI_COMMAND_CONTROL_CHANGE 0xB0 | ||
| 107 | |||
| 108 | /** MIDI command for a control change event. */ | ||
| 109 | #define MIDI_COMMAND_PROGRAM_CHANGE 0xC0 | ||
| 110 | |||
| 111 | /** MIDI command for a channel pressure change event. */ | ||
| 112 | #define MIDI_COMMAND_CHANNEL_PRESSURE 0xD0 | ||
| 113 | |||
| 114 | /** MIDI command for a pitch change event. */ | ||
| 115 | #define MIDI_COMMAND_PITCH_WHEEL_CHANGE 0xE0 | ||
| 116 | //@} | ||
| 117 | |||
| 118 | /** Standard key press velocity value used for all note events. */ | ||
| 119 | #define MIDI_STANDARD_VELOCITY 64 | ||
| 120 | |||
| 121 | /** Convenience macro. MIDI channels are numbered from 1-10 (natural numbers) however the logical channel | ||
| 122 | * addresses are zero-indexed. This converts a natural MIDI channel number into the logical channel address. | ||
| 123 | * | ||
| 124 | * \param[in] channel MIDI channel number to address. | ||
| 125 | * | ||
| 126 | * \return Constructed MIDI channel ID. | ||
| 127 | */ | ||
| 128 | #define MIDI_CHANNEL(channel) ((channel) - 1) | ||
| 129 | |||
| 130 | /** Constructs a MIDI event ID from a given MIDI command and a virtual MIDI cable index. This can then be | ||
| 131 | * used to create and decode \ref MIDI_EventPacket_t MIDI event packets. | ||
| 132 | * | ||
| 133 | * \param[in] virtualcable Index of the virtual MIDI cable the event relates to | ||
| 134 | * \param[in] command MIDI command to send through the virtual MIDI cable | ||
| 135 | * | ||
| 136 | * \return Constructed MIDI event ID. | ||
| 137 | */ | ||
| 138 | #define MIDI_EVENT(virtualcable, command) (((virtualcable) << 4) | ((command) >> 4)) | ||
| 139 | |||
| 140 | /* Enums: */ | ||
| 141 | /** Enum for the possible MIDI jack types in a MIDI device jack descriptor. */ | ||
| 142 | enum MIDI_JackTypes_t | ||
| 143 | { | ||
| 144 | MIDI_JACKTYPE_Embedded = 0x01, /**< MIDI class descriptor jack type value for an embedded (logical) MIDI input or output jack. */ | ||
| 145 | MIDI_JACKTYPE_External = 0x02, /**< MIDI class descriptor jack type value for an external (physical) MIDI input or output jack. */ | ||
| 146 | }; | ||
| 147 | |||
| 148 | /* Type Defines: */ | ||
| 149 | /** \brief MIDI class-specific Streaming Interface Descriptor (LUFA naming conventions). | ||
| 150 | * | ||
| 151 | * Type define for an Audio class-specific MIDI streaming interface descriptor. This indicates to the host | ||
| 152 | * how MIDI the specification compliance of the device and the total length of the Audio class-specific descriptors. | ||
| 153 | * See the USB Audio specification for more details. | ||
| 154 | * | ||
| 155 | * \see \ref USB_MIDI_StdDescriptor_AudioInterface_AS_t for the version of this type with standard element names. | ||
| 156 | * | ||
| 157 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 158 | */ | ||
| 159 | typedef struct | ||
| 160 | { | ||
| 161 | USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ | ||
| 162 | uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ | ||
| 163 | |||
| 164 | uint16_t AudioSpecification; /**< Binary coded decimal value, indicating the supported Audio Class | ||
| 165 | * specification version. | ||
| 166 | * | ||
| 167 | * \see \ref VERSION_BCD() utility macro. | ||
| 168 | */ | ||
| 169 | uint16_t TotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */ | ||
| 170 | } ATTR_PACKED USB_MIDI_Descriptor_AudioInterface_AS_t; | ||
| 171 | |||
| 172 | /** \brief MIDI class-specific Streaming Interface Descriptor (USB-IF naming conventions). | ||
| 173 | * | ||
| 174 | * Type define for an Audio class-specific MIDI streaming interface descriptor. This indicates to the host | ||
| 175 | * how MIDI the specification compliance of the device and the total length of the Audio class-specific descriptors. | ||
| 176 | * See the USB Audio specification for more details. | ||
| 177 | * | ||
| 178 | * \see \ref USB_MIDI_Descriptor_AudioInterface_AS_t for the version of this type with non-standard LUFA specific | ||
| 179 | * element names. | ||
| 180 | * | ||
| 181 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 182 | */ | ||
| 183 | typedef struct | ||
| 184 | { | ||
| 185 | uint8_t bLength; /**< Size of the descriptor, in bytes. */ | ||
| 186 | uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value | ||
| 187 | * given by the specific class. | ||
| 188 | */ | ||
| 189 | |||
| 190 | uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ | ||
| 191 | |||
| 192 | uint16_t bcdMSC; /**< Binary coded decimal value, indicating the supported MIDI Class specification version. | ||
| 193 | * | ||
| 194 | * \see \ref VERSION_BCD() utility macro. | ||
| 195 | */ | ||
| 196 | uint16_t wTotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */ | ||
| 197 | } ATTR_PACKED USB_MIDI_StdDescriptor_AudioInterface_AS_t; | ||
| 198 | |||
| 199 | /** \brief MIDI class-specific Input Jack Descriptor (LUFA naming conventions). | ||
| 200 | * | ||
| 201 | * Type define for an Audio class-specific MIDI IN jack. This gives information to the host on a MIDI input, either | ||
| 202 | * a physical input jack, or a logical jack (receiving input data internally, or from the host via an endpoint). | ||
| 203 | * | ||
| 204 | * \see \ref USB_MIDI_StdDescriptor_InputJack_t for the version of this type with standard element names. | ||
| 205 | * | ||
| 206 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 207 | */ | ||
| 208 | typedef struct | ||
| 209 | { | ||
| 210 | USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ | ||
| 211 | uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ | ||
| 212 | |||
| 213 | uint8_t JackType; /**< Type of jack, one of the \c JACKTYPE_* mask values. */ | ||
| 214 | uint8_t JackID; /**< ID value of this jack - must be a unique value within the device. */ | ||
| 215 | |||
| 216 | uint8_t JackStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */ | ||
| 217 | } ATTR_PACKED USB_MIDI_Descriptor_InputJack_t; | ||
| 218 | |||
| 219 | /** \brief MIDI class-specific Input Jack Descriptor (USB-IF naming conventions). | ||
| 220 | * | ||
| 221 | * Type define for an Audio class-specific MIDI IN jack. This gives information to the host on a MIDI input, either | ||
| 222 | * a physical input jack, or a logical jack (receiving input data internally, or from the host via an endpoint). | ||
| 223 | * | ||
| 224 | * \see \ref USB_MIDI_Descriptor_InputJack_t for the version of this type with non-standard LUFA specific | ||
| 225 | * element names. | ||
| 226 | * | ||
| 227 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 228 | */ | ||
| 229 | typedef struct | ||
| 230 | { | ||
| 231 | uint8_t bLength; /**< Size of the descriptor, in bytes. */ | ||
| 232 | uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value | ||
| 233 | * given by the specific class. | ||
| 234 | */ | ||
| 235 | |||
| 236 | uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ | ||
| 237 | |||
| 238 | uint8_t bJackType; /**< Type of jack, one of the \c JACKTYPE_* mask values. */ | ||
| 239 | uint8_t bJackID; /**< ID value of this jack - must be a unique value within the device. */ | ||
| 240 | |||
| 241 | uint8_t iJack; /**< Index of a string descriptor describing this descriptor within the device. */ | ||
| 242 | } ATTR_PACKED USB_MIDI_StdDescriptor_InputJack_t; | ||
| 243 | |||
| 244 | /** \brief MIDI class-specific Output Jack Descriptor (LUFA naming conventions). | ||
| 245 | * | ||
| 246 | * Type define for an Audio class-specific MIDI OUT jack. This gives information to the host on a MIDI output, either | ||
| 247 | * a physical output jack, or a logical jack (sending output data internally, or to the host via an endpoint). | ||
| 248 | * | ||
| 249 | * \see \ref USB_MIDI_StdDescriptor_OutputJack_t for the version of this type with standard element names. | ||
| 250 | * | ||
| 251 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 252 | */ | ||
| 253 | typedef struct | ||
| 254 | { | ||
| 255 | USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ | ||
| 256 | uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ | ||
| 257 | |||
| 258 | uint8_t JackType; /**< Type of jack, one of the \c JACKTYPE_* mask values. */ | ||
| 259 | uint8_t JackID; /**< ID value of this jack - must be a unique value within the device. */ | ||
| 260 | |||
| 261 | uint8_t NumberOfPins; /**< Number of output channels within the jack, either physical or logical. */ | ||
| 262 | uint8_t SourceJackID[1]; /**< ID of each output pin's source data jack. */ | ||
| 263 | uint8_t SourcePinID[1]; /**< Pin number in the input jack of each output pin's source data. */ | ||
| 264 | |||
| 265 | uint8_t JackStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */ | ||
| 266 | } ATTR_PACKED USB_MIDI_Descriptor_OutputJack_t; | ||
| 267 | |||
| 268 | /** \brief MIDI class-specific Output Jack Descriptor (USB-IF naming conventions). | ||
| 269 | * | ||
| 270 | * Type define for an Audio class-specific MIDI OUT jack. This gives information to the host on a MIDI output, either | ||
| 271 | * a physical output jack, or a logical jack (sending output data internally, or to the host via an endpoint). | ||
| 272 | * | ||
| 273 | * \see \ref USB_MIDI_Descriptor_OutputJack_t for the version of this type with non-standard LUFA specific | ||
| 274 | * element names. | ||
| 275 | * | ||
| 276 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 277 | */ | ||
| 278 | typedef struct | ||
| 279 | { | ||
| 280 | uint8_t bLength; /**< Size of the descriptor, in bytes. */ | ||
| 281 | uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value | ||
| 282 | * given by the specific class. | ||
| 283 | */ | ||
| 284 | |||
| 285 | uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ | ||
| 286 | |||
| 287 | uint8_t bJackType; /**< Type of jack, one of the \c JACKTYPE_* mask values. */ | ||
| 288 | uint8_t bJackID; /**< ID value of this jack - must be a unique value within the device. */ | ||
| 289 | |||
| 290 | uint8_t bNrInputPins; /**< Number of output channels within the jack, either physical or logical. */ | ||
| 291 | uint8_t baSourceID[1]; /**< ID of each output pin's source data jack. */ | ||
| 292 | uint8_t baSourcePin[1]; /**< Pin number in the input jack of each output pin's source data. */ | ||
| 293 | |||
| 294 | uint8_t iJack; /**< Index of a string descriptor describing this descriptor within the device. */ | ||
| 295 | } ATTR_PACKED USB_MIDI_StdDescriptor_OutputJack_t; | ||
| 296 | |||
| 297 | /** \brief Audio class-specific Jack Endpoint Descriptor (LUFA naming conventions). | ||
| 298 | * | ||
| 299 | * Type define for an Audio class-specific extended MIDI jack endpoint descriptor. This contains extra information | ||
| 300 | * on the usage of MIDI endpoints used to stream MIDI events in and out of the USB Audio device, and follows an Audio | ||
| 301 | * class-specific extended MIDI endpoint descriptor. See the USB Audio specification for more details. | ||
| 302 | * | ||
| 303 | * \see \ref USB_MIDI_StdDescriptor_Jack_Endpoint_t for the version of this type with standard element names. | ||
| 304 | * | ||
| 305 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 306 | */ | ||
| 307 | typedef struct | ||
| 308 | { | ||
| 309 | USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ | ||
| 310 | uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ | ||
| 311 | |||
| 312 | uint8_t TotalEmbeddedJacks; /**< Total number of jacks inside this endpoint. */ | ||
| 313 | uint8_t AssociatedJackID[1]; /**< IDs of each jack inside the endpoint. */ | ||
| 314 | } ATTR_PACKED USB_MIDI_Descriptor_Jack_Endpoint_t; | ||
| 315 | |||
| 316 | /** \brief Audio class-specific Jack Endpoint Descriptor (USB-IF naming conventions). | ||
| 317 | * | ||
| 318 | * Type define for an Audio class-specific extended MIDI jack endpoint descriptor. This contains extra information | ||
| 319 | * on the usage of MIDI endpoints used to stream MIDI events in and out of the USB Audio device, and follows an Audio | ||
| 320 | * class-specific extended MIDI endpoint descriptor. See the USB Audio specification for more details. | ||
| 321 | * | ||
| 322 | * \see \ref USB_MIDI_Descriptor_Jack_Endpoint_t for the version of this type with non-standard LUFA specific | ||
| 323 | * element names. | ||
| 324 | * | ||
| 325 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 326 | */ | ||
| 327 | typedef struct | ||
| 328 | { | ||
| 329 | uint8_t bLength; /**< Size of the descriptor, in bytes. */ | ||
| 330 | uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value | ||
| 331 | * given by the specific class. | ||
| 332 | */ | ||
| 333 | |||
| 334 | uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ | ||
| 335 | |||
| 336 | uint8_t bNumEmbMIDIJack; /**< Total number of jacks inside this endpoint. */ | ||
| 337 | uint8_t bAssocJackID[1]; /**< IDs of each jack inside the endpoint. */ | ||
| 338 | } ATTR_PACKED USB_MIDI_StdDescriptor_Jack_Endpoint_t; | ||
| 339 | |||
| 340 | /** \brief MIDI Class Driver Event Packet. | ||
| 341 | * | ||
| 342 | * Type define for a USB MIDI event packet, used to encapsulate sent and received MIDI messages from a USB MIDI interface. | ||
| 343 | * | ||
| 344 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 345 | */ | ||
| 346 | typedef struct | ||
| 347 | { | ||
| 348 | uint8_t Event; /**< MIDI event type, constructed with the \ref MIDI_EVENT() macro. */ | ||
| 349 | |||
| 350 | uint8_t Data1; /**< First byte of data in the MIDI event. */ | ||
| 351 | uint8_t Data2; /**< Second byte of data in the MIDI event. */ | ||
| 352 | uint8_t Data3; /**< Third byte of data in the MIDI event. */ | ||
| 353 | } ATTR_PACKED MIDI_EventPacket_t; | ||
| 354 | |||
| 355 | /* Disable C linkage for C++ Compilers: */ | ||
| 356 | #if defined(__cplusplus) | ||
| 357 | } | ||
| 358 | #endif | ||
| 359 | |||
| 360 | #endif | ||
| 361 | |||
| 362 | /** @} */ | ||
| 363 | |||
diff --git a/lib/lufa/LUFA/Drivers/USB/Class/Common/MassStorageClassCommon.h b/lib/lufa/LUFA/Drivers/USB/Class/Common/MassStorageClassCommon.h new file mode 100644 index 000000000..d2ea37a82 --- /dev/null +++ b/lib/lufa/LUFA/Drivers/USB/Class/Common/MassStorageClassCommon.h | |||
| @@ -0,0 +1,368 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 12 | Permission to use, copy, modify, distribute, and sell this | ||
| 13 | software and its documentation for any purpose is hereby granted | ||
| 14 | without fee, provided that the above copyright notice appear in | ||
| 15 | all copies and that both that the copyright notice and this | ||
| 16 | permission notice and warranty disclaimer appear in supporting | ||
| 17 | documentation, and that the name of the author not be used in | ||
| 18 | advertising or publicity pertaining to distribution of the | ||
| 19 | software without specific, written prior permission. | ||
| 20 | |||
| 21 | The author disclaims all warranties with regard to this | ||
| 22 | software, including all implied warranties of merchantability | ||
| 23 | and fitness. In no event shall the author be liable for any | ||
| 24 | special, indirect or consequential damages or any damages | ||
| 25 | whatsoever resulting from loss of use, data or profits, whether | ||
| 26 | in an action of contract, negligence or other tortious action, | ||
| 27 | arising out of or in connection with the use or performance of | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | /** \file | ||
| 32 | * \brief Common definitions and declarations for the library USB Mass Storage Class driver. | ||
| 33 | * | ||
| 34 | * Common definitions and declarations for the library USB Mass Storage Class driver. | ||
| 35 | * | ||
| 36 | * \note This file should not be included directly. It is automatically included as needed by the USB module driver | ||
| 37 | * dispatch header located in LUFA/Drivers/USB.h. | ||
| 38 | */ | ||
| 39 | |||
| 40 | /** \ingroup Group_USBClassMS | ||
| 41 | * \defgroup Group_USBClassMSCommon Common Class Definitions | ||
| 42 | * | ||
| 43 | * \section Sec_USBClassMSCommon_ModDescription Module Description | ||
| 44 | * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB | ||
| 45 | * Mass Storage Class. | ||
| 46 | * | ||
| 47 | * @{ | ||
| 48 | */ | ||
| 49 | |||
| 50 | #ifndef _MS_CLASS_COMMON_H_ | ||
| 51 | #define _MS_CLASS_COMMON_H_ | ||
| 52 | |||
| 53 | /* Includes: */ | ||
| 54 | #include "../../Core/StdDescriptors.h" | ||
| 55 | |||
| 56 | /* Enable C linkage for C++ Compilers: */ | ||
| 57 | #if defined(__cplusplus) | ||
| 58 | extern "C" { | ||
| 59 | #endif | ||
| 60 | |||
| 61 | /* Preprocessor Checks: */ | ||
| 62 | #if !defined(__INCLUDE_FROM_MS_DRIVER) | ||
| 63 | #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. | ||
| 64 | #endif | ||
| 65 | |||
| 66 | /* Macros: */ | ||
| 67 | /** Magic signature for a Command Block Wrapper used in the Mass Storage Bulk-Only transport protocol. */ | ||
| 68 | #define MS_CBW_SIGNATURE 0x43425355UL | ||
| 69 | |||
| 70 | /** Magic signature for a Command Status Wrapper used in the Mass Storage Bulk-Only transport protocol. */ | ||
| 71 | #define MS_CSW_SIGNATURE 0x53425355UL | ||
| 72 | |||
| 73 | /** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from host-to-device. */ | ||
| 74 | #define MS_COMMAND_DIR_DATA_OUT (0 << 7) | ||
| 75 | |||
| 76 | /** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from device-to-host. */ | ||
| 77 | #define MS_COMMAND_DIR_DATA_IN (1 << 7) | ||
| 78 | |||
| 79 | /** \name SCSI Commands*/ | ||
| 80 | //@{ | ||
| 81 | /** SCSI Command Code for an INQUIRY command. */ | ||
| 82 | #define SCSI_CMD_INQUIRY 0x12 | ||
| 83 | |||
| 84 | /** SCSI Command Code for a REQUEST SENSE command. */ | ||
| 85 | #define SCSI_CMD_REQUEST_SENSE 0x03 | ||
| 86 | |||
| 87 | /** SCSI Command Code for a TEST UNIT READY command. */ | ||
| 88 | #define SCSI_CMD_TEST_UNIT_READY 0x00 | ||
| 89 | |||
| 90 | /** SCSI Command Code for a READ CAPACITY (10) command. */ | ||
| 91 | #define SCSI_CMD_READ_CAPACITY_10 0x25 | ||
| 92 | |||
| 93 | /** SCSI Command Code for a START STOP UNIT command. */ | ||
| 94 | #define SCSI_CMD_START_STOP_UNIT 0x1B | ||
| 95 | |||
| 96 | /** SCSI Command Code for a SEND DIAGNOSTIC command. */ | ||
| 97 | #define SCSI_CMD_SEND_DIAGNOSTIC 0x1D | ||
| 98 | |||
| 99 | /** SCSI Command Code for a PREVENT ALLOW MEDIUM REMOVAL command. */ | ||
| 100 | #define SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1E | ||
| 101 | |||
| 102 | /** SCSI Command Code for a WRITE (10) command. */ | ||
| 103 | #define SCSI_CMD_WRITE_10 0x2A | ||
| 104 | |||
| 105 | /** SCSI Command Code for a READ (10) command. */ | ||
| 106 | #define SCSI_CMD_READ_10 0x28 | ||
| 107 | |||
| 108 | /** SCSI Command Code for a WRITE (6) command. */ | ||
| 109 | #define SCSI_CMD_WRITE_6 0x0A | ||
| 110 | |||
| 111 | /** SCSI Command Code for a READ (6) command. */ | ||
| 112 | #define SCSI_CMD_READ_6 0x08 | ||
| 113 | |||
| 114 | /** SCSI Command Code for a VERIFY (10) command. */ | ||
| 115 | #define SCSI_CMD_VERIFY_10 0x2F | ||
| 116 | |||
| 117 | /** SCSI Command Code for a MODE SENSE (6) command. */ | ||
| 118 | #define SCSI_CMD_MODE_SENSE_6 0x1A | ||
| 119 | |||
| 120 | /** SCSI Command Code for a MODE SENSE (10) command. */ | ||
| 121 | #define SCSI_CMD_MODE_SENSE_10 0x5A | ||
| 122 | //@} | ||
| 123 | |||
| 124 | /** \name SCSI Sense Key Values */ | ||
| 125 | //@{ | ||
| 126 | /** SCSI Sense Code to indicate no error has occurred. */ | ||
| 127 | #define SCSI_SENSE_KEY_GOOD 0x00 | ||
| 128 | |||
| 129 | /** SCSI Sense Code to indicate that the device has recovered from an error. */ | ||
| 130 | #define SCSI_SENSE_KEY_RECOVERED_ERROR 0x01 | ||
| 131 | |||
| 132 | /** SCSI Sense Code to indicate that the device is not ready for a new command. */ | ||
| 133 | #define SCSI_SENSE_KEY_NOT_READY 0x02 | ||
| 134 | |||
| 135 | /** SCSI Sense Code to indicate an error whilst accessing the medium. */ | ||
| 136 | #define SCSI_SENSE_KEY_MEDIUM_ERROR 0x03 | ||
| 137 | |||
| 138 | /** SCSI Sense Code to indicate a hardware error has occurred. */ | ||
| 139 | #define SCSI_SENSE_KEY_HARDWARE_ERROR 0x04 | ||
| 140 | |||
| 141 | /** SCSI Sense Code to indicate that an illegal request has been issued. */ | ||
| 142 | #define SCSI_SENSE_KEY_ILLEGAL_REQUEST 0x05 | ||
| 143 | |||
| 144 | /** SCSI Sense Code to indicate that the unit requires attention from the host to indicate | ||
| 145 | * a reset event, medium removal or other condition. | ||
| 146 | */ | ||
| 147 | #define SCSI_SENSE_KEY_UNIT_ATTENTION 0x06 | ||
| 148 | |||
| 149 | /** SCSI Sense Code to indicate that a write attempt on a protected block has been made. */ | ||
| 150 | #define SCSI_SENSE_KEY_DATA_PROTECT 0x07 | ||
| 151 | |||
| 152 | /** SCSI Sense Code to indicate an error while trying to write to a write-once medium. */ | ||
| 153 | #define SCSI_SENSE_KEY_BLANK_CHECK 0x08 | ||
| 154 | |||
| 155 | /** SCSI Sense Code to indicate a vendor specific error has occurred. */ | ||
| 156 | #define SCSI_SENSE_KEY_VENDOR_SPECIFIC 0x09 | ||
| 157 | |||
| 158 | /** SCSI Sense Code to indicate that an EXTENDED COPY command has aborted due to an error. */ | ||
| 159 | #define SCSI_SENSE_KEY_COPY_ABORTED 0x0A | ||
| 160 | |||
| 161 | /** SCSI Sense Code to indicate that the device has aborted the issued command. */ | ||
| 162 | #define SCSI_SENSE_KEY_ABORTED_COMMAND 0x0B | ||
| 163 | |||
| 164 | /** SCSI Sense Code to indicate an attempt to write past the end of a partition has been made. */ | ||
| 165 | #define SCSI_SENSE_KEY_VOLUME_OVERFLOW 0x0D | ||
| 166 | |||
| 167 | /** SCSI Sense Code to indicate that the source data did not match the data read from the medium. */ | ||
| 168 | #define SCSI_SENSE_KEY_MISCOMPARE 0x0E | ||
| 169 | //@} | ||
| 170 | |||
| 171 | /** \name SCSI Additional Sense Codes */ | ||
| 172 | //@{ | ||
| 173 | /** SCSI Additional Sense Code to indicate no additional sense information is available. */ | ||
| 174 | #define SCSI_ASENSE_NO_ADDITIONAL_INFORMATION 0x00 | ||
| 175 | |||
| 176 | /** SCSI Additional Sense Code to indicate that the logical unit (LUN) addressed is not ready. */ | ||
| 177 | #define SCSI_ASENSE_LOGICAL_UNIT_NOT_READY 0x04 | ||
| 178 | |||
| 179 | /** SCSI Additional Sense Code to indicate an invalid field was encountered while processing the issued command. */ | ||
| 180 | #define SCSI_ASENSE_INVALID_FIELD_IN_CDB 0x24 | ||
| 181 | |||
| 182 | /** SCSI Additional Sense Code to indicate that a medium that was previously indicated as not ready has now | ||
| 183 | * become ready for use. | ||
| 184 | */ | ||
| 185 | #define SCSI_ASENSE_NOT_READY_TO_READY_CHANGE 0x28 | ||
| 186 | |||
| 187 | /** SCSI Additional Sense Code to indicate that an attempt to write to a protected area was made. */ | ||
| 188 | #define SCSI_ASENSE_WRITE_PROTECTED 0x27 | ||
| 189 | |||
| 190 | /** SCSI Additional Sense Code to indicate an error whilst formatting the device medium. */ | ||
| 191 | #define SCSI_ASENSE_FORMAT_ERROR 0x31 | ||
| 192 | |||
| 193 | /** SCSI Additional Sense Code to indicate an invalid command was issued. */ | ||
| 194 | #define SCSI_ASENSE_INVALID_COMMAND 0x20 | ||
| 195 | |||
| 196 | /** SCSI Additional Sense Code to indicate a write to a block out outside of the medium's range was issued. */ | ||
| 197 | #define SCSI_ASENSE_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE 0x21 | ||
| 198 | |||
| 199 | /** SCSI Additional Sense Code to indicate that no removable medium is inserted into the device. */ | ||
| 200 | #define SCSI_ASENSE_MEDIUM_NOT_PRESENT 0x3A | ||
| 201 | //@} | ||
| 202 | |||
| 203 | /** \name SCSI Additional Sense Key Code Qualifiers */ | ||
| 204 | //@{ | ||
| 205 | /** SCSI Additional Sense Qualifier Code to indicate no additional sense qualifier information is available. */ | ||
| 206 | #define SCSI_ASENSEQ_NO_QUALIFIER 0x00 | ||
| 207 | |||
| 208 | /** SCSI Additional Sense Qualifier Code to indicate that a medium format command failed to complete. */ | ||
| 209 | #define SCSI_ASENSEQ_FORMAT_COMMAND_FAILED 0x01 | ||
| 210 | |||
| 211 | /** SCSI Additional Sense Qualifier Code to indicate that an initializing command must be issued before the issued | ||
| 212 | * command can be executed. | ||
| 213 | */ | ||
| 214 | #define SCSI_ASENSEQ_INITIALIZING_COMMAND_REQUIRED 0x02 | ||
| 215 | |||
| 216 | /** SCSI Additional Sense Qualifier Code to indicate that an operation is currently in progress. */ | ||
| 217 | #define SCSI_ASENSEQ_OPERATION_IN_PROGRESS 0x07 | ||
| 218 | //@} | ||
| 219 | |||
| 220 | /* Enums: */ | ||
| 221 | /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the Mass | ||
| 222 | * Storage device class. | ||
| 223 | */ | ||
| 224 | enum MS_Descriptor_ClassSubclassProtocol_t | ||
| 225 | { | ||
| 226 | MS_CSCP_MassStorageClass = 0x08, /**< Descriptor Class value indicating that the device or interface | ||
| 227 | * belongs to the Mass Storage class. | ||
| 228 | */ | ||
| 229 | MS_CSCP_SCSITransparentSubclass = 0x06, /**< Descriptor Subclass value indicating that the device or interface | ||
| 230 | * belongs to the SCSI Transparent Command Set subclass of the Mass | ||
| 231 | * storage class. | ||
| 232 | */ | ||
| 233 | MS_CSCP_BulkOnlyTransportProtocol = 0x50, /**< Descriptor Protocol value indicating that the device or interface | ||
| 234 | * belongs to the Bulk Only Transport protocol of the Mass Storage class. | ||
| 235 | */ | ||
| 236 | }; | ||
| 237 | |||
| 238 | /** Enum for the Mass Storage class specific control requests that can be issued by the USB bus host. */ | ||
| 239 | enum MS_ClassRequests_t | ||
| 240 | { | ||
| 241 | MS_REQ_GetMaxLUN = 0xFE, /**< Mass Storage class-specific request to retrieve the total number of Logical | ||
| 242 | * Units (drives) in the SCSI device. | ||
| 243 | */ | ||
| 244 | MS_REQ_MassStorageReset = 0xFF, /**< Mass Storage class-specific request to reset the Mass Storage interface, | ||
| 245 | * ready for the next command. | ||
| 246 | */ | ||
| 247 | }; | ||
| 248 | |||
| 249 | /** Enum for the possible command status wrapper return status codes. */ | ||
| 250 | enum MS_CommandStatusCodes_t | ||
| 251 | { | ||
| 252 | MS_SCSI_COMMAND_Pass = 0, /**< Command completed with no error */ | ||
| 253 | MS_SCSI_COMMAND_Fail = 1, /**< Command failed to complete - host may check the exact error via a | ||
| 254 | * SCSI REQUEST SENSE command. | ||
| 255 | */ | ||
| 256 | MS_SCSI_COMMAND_PhaseError = 2, /**< Command failed due to being invalid in the current phase. */ | ||
| 257 | }; | ||
| 258 | |||
| 259 | /* Type Defines: */ | ||
| 260 | /** \brief Mass Storage Class Command Block Wrapper. | ||
| 261 | * | ||
| 262 | * Type define for a Command Block Wrapper, used in the Mass Storage Bulk-Only Transport protocol. | ||
| 263 | * | ||
| 264 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 265 | */ | ||
| 266 | typedef struct | ||
| 267 | { | ||
| 268 | uint32_t Signature; /**< Command block signature, must be \ref MS_CBW_SIGNATURE to indicate a valid Command Block. */ | ||
| 269 | uint32_t Tag; /**< Unique command ID value, to associate a command block wrapper with its command status wrapper. */ | ||
| 270 | uint32_t DataTransferLength; /**< Length of the optional data portion of the issued command, in bytes. */ | ||
| 271 | uint8_t Flags; /**< Command block flags, indicating command data direction. */ | ||
| 272 | uint8_t LUN; /**< Logical Unit number this command is issued to. */ | ||
| 273 | uint8_t SCSICommandLength; /**< Length of the issued SCSI command within the SCSI command data array. */ | ||
| 274 | uint8_t SCSICommandData[16]; /**< Issued SCSI command in the Command Block. */ | ||
| 275 | } ATTR_PACKED MS_CommandBlockWrapper_t; | ||
| 276 | |||
| 277 | /** \brief Mass Storage Class Command Status Wrapper. | ||
| 278 | * | ||
| 279 | * Type define for a Command Status Wrapper, used in the Mass Storage Bulk-Only Transport protocol. | ||
| 280 | * | ||
| 281 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 282 | */ | ||
| 283 | typedef struct | ||
| 284 | { | ||
| 285 | uint32_t Signature; /**< Status block signature, must be \ref MS_CSW_SIGNATURE to indicate a valid Command Status. */ | ||
| 286 | uint32_t Tag; /**< Unique command ID value, to associate a command block wrapper with its command status wrapper. */ | ||
| 287 | uint32_t DataTransferResidue; /**< Number of bytes of data not processed in the SCSI command. */ | ||
| 288 | uint8_t Status; /**< Status code of the issued command - a value from the \ref MS_CommandStatusCodes_t enum. */ | ||
| 289 | } ATTR_PACKED MS_CommandStatusWrapper_t; | ||
| 290 | |||
| 291 | /** \brief Mass Storage Class SCSI Sense Structure | ||
| 292 | * | ||
| 293 | * Type define for a SCSI Sense structure. Structures of this type are filled out by the | ||
| 294 | * device via the \ref MS_Host_RequestSense() function, indicating the current sense data of the | ||
| 295 | * device (giving explicit error codes for the last issued command). For details of the | ||
| 296 | * structure contents, refer to the SCSI specifications. | ||
| 297 | */ | ||
| 298 | typedef struct | ||
| 299 | { | ||
| 300 | uint8_t ResponseCode; | ||
| 301 | |||
| 302 | uint8_t SegmentNumber; | ||
| 303 | |||
| 304 | unsigned SenseKey : 4; | ||
| 305 | unsigned Reserved : 1; | ||
| 306 | unsigned ILI : 1; | ||
| 307 | unsigned EOM : 1; | ||
| 308 | unsigned FileMark : 1; | ||
| 309 | |||
| 310 | uint8_t Information[4]; | ||
| 311 | uint8_t AdditionalLength; | ||
| 312 | uint8_t CmdSpecificInformation[4]; | ||
| 313 | uint8_t AdditionalSenseCode; | ||
| 314 | uint8_t AdditionalSenseQualifier; | ||
| 315 | uint8_t FieldReplaceableUnitCode; | ||
| 316 | uint8_t SenseKeySpecific[3]; | ||
| 317 | } ATTR_PACKED SCSI_Request_Sense_Response_t; | ||
| 318 | |||
| 319 | /** \brief Mass Storage Class SCSI Inquiry Structure. | ||
| 320 | * | ||
| 321 | * Type define for a SCSI Inquiry structure. Structures of this type are filled out by the | ||
| 322 | * device via the \ref MS_Host_GetInquiryData() function, retrieving the attached device's | ||
| 323 | * information. | ||
| 324 | * | ||
| 325 | * For details of the structure contents, refer to the SCSI specifications. | ||
| 326 | */ | ||
| 327 | typedef struct | ||
| 328 | { | ||
| 329 | unsigned DeviceType : 5; | ||
| 330 | unsigned PeripheralQualifier : 3; | ||
| 331 | |||
| 332 | unsigned Reserved : 7; | ||
| 333 | unsigned Removable : 1; | ||
| 334 | |||
| 335 | uint8_t Version; | ||
| 336 | |||
| 337 | unsigned ResponseDataFormat : 4; | ||
| 338 | unsigned Reserved2 : 1; | ||
| 339 | unsigned NormACA : 1; | ||
| 340 | unsigned TrmTsk : 1; | ||
| 341 | unsigned AERC : 1; | ||
| 342 | |||
| 343 | uint8_t AdditionalLength; | ||
| 344 | uint8_t Reserved3[2]; | ||
| 345 | |||
| 346 | unsigned SoftReset : 1; | ||
| 347 | unsigned CmdQue : 1; | ||
| 348 | unsigned Reserved4 : 1; | ||
| 349 | unsigned Linked : 1; | ||
| 350 | unsigned Sync : 1; | ||
| 351 | unsigned WideBus16Bit : 1; | ||
| 352 | unsigned WideBus32Bit : 1; | ||
| 353 | unsigned RelAddr : 1; | ||
| 354 | |||
| 355 | uint8_t VendorID[8]; | ||
| 356 | uint8_t ProductID[16]; | ||
| 357 | uint8_t RevisionID[4]; | ||
| 358 | } ATTR_PACKED SCSI_Inquiry_Response_t; | ||
| 359 | |||
| 360 | /* Disable C linkage for C++ Compilers: */ | ||
| 361 | #if defined(__cplusplus) | ||
| 362 | } | ||
| 363 | #endif | ||
| 364 | |||
| 365 | #endif | ||
| 366 | |||
| 367 | /** @} */ | ||
| 368 | |||
diff --git a/lib/lufa/LUFA/Drivers/USB/Class/Common/PrinterClassCommon.h b/lib/lufa/LUFA/Drivers/USB/Class/Common/PrinterClassCommon.h new file mode 100644 index 000000000..2db830e04 --- /dev/null +++ b/lib/lufa/LUFA/Drivers/USB/Class/Common/PrinterClassCommon.h | |||
| @@ -0,0 +1,119 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 12 | Permission to use, copy, modify, distribute, and sell this | ||
| 13 | software and its documentation for any purpose is hereby granted | ||
| 14 | without fee, provided that the above copyright notice appear in | ||
| 15 | all copies and that both that the copyright notice and this | ||
| 16 | permission notice and warranty disclaimer appear in supporting | ||
| 17 | documentation, and that the name of the author not be used in | ||
| 18 | advertising or publicity pertaining to distribution of the | ||
| 19 | software without specific, written prior permission. | ||
| 20 | |||
| 21 | The author disclaims all warranties with regard to this | ||
| 22 | software, including all implied warranties of merchantability | ||
| 23 | and fitness. In no event shall the author be liable for any | ||
| 24 | special, indirect or consequential damages or any damages | ||
| 25 | whatsoever resulting from loss of use, data or profits, whether | ||
| 26 | in an action of contract, negligence or other tortious action, | ||
| 27 | arising out of or in connection with the use or performance of | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | /** \file | ||
| 32 | * \brief Common definitions and declarations for the library USB Printer Class driver. | ||
| 33 | * | ||
| 34 | * Common definitions and declarations for the library USB Printer Class driver. | ||
| 35 | * | ||
| 36 | * \note This file should not be included directly. It is automatically included as needed by the USB module driver | ||
| 37 | * dispatch header located in LUFA/Drivers/USB.h. | ||
| 38 | */ | ||
| 39 | |||
| 40 | /** \ingroup Group_USBClassPrinter | ||
| 41 | * \defgroup Group_USBClassPrinterCommon Common Class Definitions | ||
| 42 | * | ||
| 43 | * \section Sec_USBClassPrinterCommon_ModDescription Module Description | ||
| 44 | * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB | ||
| 45 | * Printer Class. | ||
| 46 | * | ||
| 47 | * @{ | ||
| 48 | */ | ||
| 49 | |||
| 50 | #ifndef _PRINTER_CLASS_COMMON_H_ | ||
| 51 | #define _PRINTER_CLASS_COMMON_H_ | ||
| 52 | |||
| 53 | /* Includes: */ | ||
| 54 | #include "../../Core/StdDescriptors.h" | ||
| 55 | |||
| 56 | /* Enable C linkage for C++ Compilers: */ | ||
| 57 | #if defined(__cplusplus) | ||
| 58 | extern "C" { | ||
| 59 | #endif | ||
| 60 | |||
| 61 | /* Preprocessor Checks: */ | ||
| 62 | #if !defined(__INCLUDE_FROM_PRINTER_DRIVER) | ||
| 63 | #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. | ||
| 64 | #endif | ||
| 65 | |||
| 66 | /* Macros: */ | ||
| 67 | /** \name Virtual Printer Status Line Masks */ | ||
| 68 | //@{ | ||
| 69 | /** Port status mask for a printer device, indicating that an error has *not* occurred. */ | ||
| 70 | #define PRNT_PORTSTATUS_NOTERROR (1 << 3) | ||
| 71 | |||
| 72 | /** Port status mask for a printer device, indicating that the device is currently selected. */ | ||
| 73 | #define PRNT_PORTSTATUS_SELECT (1 << 4) | ||
| 74 | |||
| 75 | /** Port status mask for a printer device, indicating that the device is currently out of paper. */ | ||
| 76 | #define PRNT_PORTSTATUS_PAPEREMPTY (1 << 5) | ||
| 77 | //@} | ||
| 78 | |||
| 79 | /* Enums: */ | ||
| 80 | /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the Printer | ||
| 81 | * device class. | ||
| 82 | */ | ||
| 83 | enum PRNT_Descriptor_ClassSubclassProtocol_t | ||
| 84 | { | ||
| 85 | PRNT_CSCP_PrinterClass = 0x07, /**< Descriptor Class value indicating that the device or interface | ||
| 86 | * belongs to the Printer class. | ||
| 87 | */ | ||
| 88 | PRNT_CSCP_PrinterSubclass = 0x01, /**< Descriptor Subclass value indicating that the device or interface | ||
| 89 | * belongs to the Printer subclass. | ||
| 90 | */ | ||
| 91 | PRNT_CSCP_BidirectionalProtocol = 0x02, /**< Descriptor Protocol value indicating that the device or interface | ||
| 92 | * belongs to the Bidirectional protocol of the Printer class. | ||
| 93 | */ | ||
| 94 | }; | ||
| 95 | |||
| 96 | /** Enum for the Printer class specific control requests that can be issued by the USB bus host. */ | ||
| 97 | enum PRNT_ClassRequests_t | ||
| 98 | { | ||
| 99 | PRNT_REQ_GetDeviceID = 0x00, /**< Printer class-specific request to retrieve the Unicode ID | ||
| 100 | * string of the device, containing the device's name, manufacturer | ||
| 101 | * and supported printer languages. | ||
| 102 | */ | ||
| 103 | PRNT_REQ_GetPortStatus = 0x01, /**< Printer class-specific request to get the current status of the | ||
| 104 | * virtual printer port, for device selection and ready states. | ||
| 105 | */ | ||
| 106 | PRNT_REQ_SoftReset = 0x02, /**< Printer class-specific request to reset the device, ready for new | ||
| 107 | * printer commands. | ||
| 108 | */ | ||
| 109 | }; | ||
| 110 | |||
| 111 | /* Disable C linkage for C++ Compilers: */ | ||
| 112 | #if defined(__cplusplus) | ||
| 113 | } | ||
| 114 | #endif | ||
| 115 | |||
| 116 | #endif | ||
| 117 | |||
| 118 | /** @} */ | ||
| 119 | |||
diff --git a/lib/lufa/LUFA/Drivers/USB/Class/Common/RNDISClassCommon.h b/lib/lufa/LUFA/Drivers/USB/Class/Common/RNDISClassCommon.h new file mode 100644 index 000000000..ade1af067 --- /dev/null +++ b/lib/lufa/LUFA/Drivers/USB/Class/Common/RNDISClassCommon.h | |||
| @@ -0,0 +1,411 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 12 | Permission to use, copy, modify, distribute, and sell this | ||
| 13 | software and its documentation for any purpose is hereby granted | ||
| 14 | without fee, provided that the above copyright notice appear in | ||
| 15 | all copies and that both that the copyright notice and this | ||
| 16 | permission notice and warranty disclaimer appear in supporting | ||
| 17 | documentation, and that the name of the author not be used in | ||
| 18 | advertising or publicity pertaining to distribution of the | ||
| 19 | software without specific, written prior permission. | ||
| 20 | |||
| 21 | The author disclaims all warranties with regard to this | ||
| 22 | software, including all implied warranties of merchantability | ||
| 23 | and fitness. In no event shall the author be liable for any | ||
| 24 | special, indirect or consequential damages or any damages | ||
| 25 | whatsoever resulting from loss of use, data or profits, whether | ||
| 26 | in an action of contract, negligence or other tortious action, | ||
| 27 | arising out of or in connection with the use or performance of | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | /** \file | ||
| 32 | * \brief Common definitions and declarations for the library USB RNDIS Class driver. | ||
| 33 | * | ||
| 34 | * Common definitions and declarations for the library USB RNDIS Class driver. | ||
| 35 | * | ||
| 36 | * \note This file should not be included directly. It is automatically included as needed by the USB module driver | ||
| 37 | * dispatch header located in LUFA/Drivers/USB.h. | ||
| 38 | */ | ||
| 39 | |||
| 40 | /** \ingroup Group_USBClassRNDIS | ||
| 41 | * \defgroup Group_USBClassRNDISCommon Common Class Definitions | ||
| 42 | * | ||
| 43 | * \section Sec_USBClassRNDISCommon_ModDescription Module Description | ||
| 44 | * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB | ||
| 45 | * RNDIS Class. | ||
| 46 | * | ||
| 47 | * @{ | ||
| 48 | */ | ||
| 49 | |||
| 50 | #ifndef _RNDIS_CLASS_COMMON_H_ | ||
| 51 | #define _RNDIS_CLASS_COMMON_H_ | ||
| 52 | |||
| 53 | /* Macros: */ | ||
| 54 | #define __INCLUDE_FROM_CDC_DRIVER | ||
| 55 | |||
| 56 | /* Includes: */ | ||
| 57 | #include "../../Core/StdDescriptors.h" | ||
| 58 | #include "CDCClassCommon.h" | ||
| 59 | |||
| 60 | /* Enable C linkage for C++ Compilers: */ | ||
| 61 | #if defined(__cplusplus) | ||
| 62 | extern "C" { | ||
| 63 | #endif | ||
| 64 | |||
| 65 | /* Preprocessor Checks: */ | ||
| 66 | #if !defined(__INCLUDE_FROM_RNDIS_DRIVER) | ||
| 67 | #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. | ||
| 68 | #endif | ||
| 69 | |||
| 70 | /* Macros: */ | ||
| 71 | /** Additional error code for RNDIS functions when a device returns a logical command failure. */ | ||
| 72 | #define RNDIS_ERROR_LOGICAL_CMD_FAILED 0x80 | ||
| 73 | |||
| 74 | /** Implemented RNDIS Version Major. */ | ||
| 75 | #define REMOTE_NDIS_VERSION_MAJOR 0x01 | ||
| 76 | |||
| 77 | /** Implemented RNDIS Version Minor. */ | ||
| 78 | #define REMOTE_NDIS_VERSION_MINOR 0x00 | ||
| 79 | |||
| 80 | /** \name RNDIS Message Values */ | ||
| 81 | //@{ | ||
| 82 | #define REMOTE_NDIS_PACKET_MSG 0x00000001UL | ||
| 83 | #define REMOTE_NDIS_INITIALIZE_MSG 0x00000002UL | ||
| 84 | #define REMOTE_NDIS_HALT_MSG 0x00000003UL | ||
| 85 | #define REMOTE_NDIS_QUERY_MSG 0x00000004UL | ||
| 86 | #define REMOTE_NDIS_SET_MSG 0x00000005UL | ||
| 87 | #define REMOTE_NDIS_RESET_MSG 0x00000006UL | ||
| 88 | #define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007UL | ||
| 89 | #define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008UL | ||
| 90 | //@} | ||
| 91 | |||
| 92 | /** \name RNDIS Response Values */ | ||
| 93 | //@{ | ||
| 94 | #define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002UL | ||
| 95 | #define REMOTE_NDIS_QUERY_CMPLT 0x80000004UL | ||
| 96 | #define REMOTE_NDIS_SET_CMPLT 0x80000005UL | ||
| 97 | #define REMOTE_NDIS_RESET_CMPLT 0x80000006UL | ||
| 98 | #define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008UL | ||
| 99 | //@} | ||
| 100 | |||
| 101 | /** \name RNDIS Status Values */ | ||
| 102 | //@{ | ||
| 103 | #define REMOTE_NDIS_STATUS_SUCCESS 0x00000000UL | ||
| 104 | #define REMOTE_NDIS_STATUS_FAILURE 0xC0000001UL | ||
| 105 | #define REMOTE_NDIS_STATUS_INVALID_DATA 0xC0010015UL | ||
| 106 | #define REMOTE_NDIS_STATUS_NOT_SUPPORTED 0xC00000BBUL | ||
| 107 | #define REMOTE_NDIS_STATUS_MEDIA_CONNECT 0x4001000BUL | ||
| 108 | #define REMOTE_NDIS_STATUS_MEDIA_DISCONNECT 0x4001000CUL | ||
| 109 | //@} | ||
| 110 | |||
| 111 | /** \name RNDIS Media States */ | ||
| 112 | //@{ | ||
| 113 | #define REMOTE_NDIS_MEDIA_STATE_CONNECTED 0x00000000UL | ||
| 114 | #define REMOTE_NDIS_MEDIA_STATE_DISCONNECTED 0x00000001UL | ||
| 115 | //@} | ||
| 116 | |||
| 117 | /** \name RNDIS Media Types */ | ||
| 118 | //@{ | ||
| 119 | #define REMOTE_NDIS_MEDIUM_802_3 0x00000000UL | ||
| 120 | //@} | ||
| 121 | |||
| 122 | /** \name RNDIS Connection Types */ | ||
| 123 | //@{ | ||
| 124 | #define REMOTE_NDIS_DF_CONNECTIONLESS 0x00000001UL | ||
| 125 | #define REMOTE_NDIS_DF_CONNECTION_ORIENTED 0x00000002UL | ||
| 126 | //@} | ||
| 127 | |||
| 128 | /** \name RNDIS Packet Types */ | ||
| 129 | //@{ | ||
| 130 | #define REMOTE_NDIS_PACKET_DIRECTED 0x00000001UL | ||
| 131 | #define REMOTE_NDIS_PACKET_MULTICAST 0x00000002UL | ||
| 132 | #define REMOTE_NDIS_PACKET_ALL_MULTICAST 0x00000004UL | ||
| 133 | #define REMOTE_NDIS_PACKET_BROADCAST 0x00000008UL | ||
| 134 | #define REMOTE_NDIS_PACKET_SOURCE_ROUTING 0x00000010UL | ||
| 135 | #define REMOTE_NDIS_PACKET_PROMISCUOUS 0x00000020UL | ||
| 136 | #define REMOTE_NDIS_PACKET_SMT 0x00000040UL | ||
| 137 | #define REMOTE_NDIS_PACKET_ALL_LOCAL 0x00000080UL | ||
| 138 | #define REMOTE_NDIS_PACKET_GROUP 0x00001000UL | ||
| 139 | #define REMOTE_NDIS_PACKET_ALL_FUNCTIONAL 0x00002000UL | ||
| 140 | #define REMOTE_NDIS_PACKET_FUNCTIONAL 0x00004000UL | ||
| 141 | #define REMOTE_NDIS_PACKET_MAC_FRAME 0x00008000UL | ||
| 142 | //@} | ||
| 143 | |||
| 144 | /** \name RNDIS OID Values */ | ||
| 145 | //@{ | ||
| 146 | #define OID_GEN_SUPPORTED_LIST 0x00010101UL | ||
| 147 | #define OID_GEN_HARDWARE_STATUS 0x00010102UL | ||
| 148 | #define OID_GEN_MEDIA_SUPPORTED 0x00010103UL | ||
| 149 | #define OID_GEN_MEDIA_IN_USE 0x00010104UL | ||
| 150 | #define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106UL | ||
| 151 | #define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111UL | ||
| 152 | #define OID_GEN_LINK_SPEED 0x00010107UL | ||
| 153 | #define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010AUL | ||
| 154 | #define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010BUL | ||
| 155 | #define OID_GEN_VENDOR_ID 0x0001010CUL | ||
| 156 | #define OID_GEN_VENDOR_DESCRIPTION 0x0001010DUL | ||
| 157 | #define OID_GEN_CURRENT_PACKET_FILTER 0x0001010EUL | ||
| 158 | #define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111UL | ||
| 159 | #define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114UL | ||
| 160 | #define OID_GEN_PHYSICAL_MEDIUM 0x00010202UL | ||
| 161 | #define OID_GEN_XMIT_OK 0x00020101UL | ||
| 162 | #define OID_GEN_RCV_OK 0x00020102UL | ||
| 163 | #define OID_GEN_XMIT_ERROR 0x00020103UL | ||
| 164 | #define OID_GEN_RCV_ERROR 0x00020104UL | ||
| 165 | #define OID_GEN_RCV_NO_BUFFER 0x00020105UL | ||
| 166 | #define OID_802_3_PERMANENT_ADDRESS 0x01010101UL | ||
| 167 | #define OID_802_3_CURRENT_ADDRESS 0x01010102UL | ||
| 168 | #define OID_802_3_MULTICAST_LIST 0x01010103UL | ||
| 169 | #define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104UL | ||
| 170 | #define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101UL | ||
| 171 | #define OID_802_3_XMIT_ONE_COLLISION 0x01020102UL | ||
| 172 | #define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103UL | ||
| 173 | //@} | ||
| 174 | |||
| 175 | /** Maximum size in bytes of an Ethernet frame according to the Ethernet standard. */ | ||
| 176 | #define ETHERNET_FRAME_SIZE_MAX 1500 | ||
| 177 | |||
| 178 | /* Enums: */ | ||
| 179 | /** Enum for the RNDIS class specific control requests that can be issued by the USB bus host. */ | ||
| 180 | enum RNDIS_ClassRequests_t | ||
| 181 | { | ||
| 182 | RNDIS_REQ_SendEncapsulatedCommand = 0x00, /**< RNDIS request to issue a host-to-device NDIS command. */ | ||
| 183 | RNDIS_REQ_GetEncapsulatedResponse = 0x01, /**< RNDIS request to issue a device-to-host NDIS response. */ | ||
| 184 | }; | ||
| 185 | |||
| 186 | /** Enum for the possible NDIS adapter states. */ | ||
| 187 | enum RNDIS_States_t | ||
| 188 | { | ||
| 189 | RNDIS_Uninitialized = 0, /**< Adapter currently uninitialized. */ | ||
| 190 | RNDIS_Initialized = 1, /**< Adapter currently initialized but not ready for data transfers. */ | ||
| 191 | RNDIS_Data_Initialized = 2, /**< Adapter currently initialized and ready for data transfers. */ | ||
| 192 | }; | ||
| 193 | |||
| 194 | /** Enum for the RNDIS class specific notification requests that can be issued by a RNDIS device to a host. */ | ||
| 195 | enum RNDIS_ClassNotifications_t | ||
| 196 | { | ||
| 197 | RNDIS_NOTIF_ResponseAvailable = 0x01, /**< Notification request value for a RNDIS Response Available notification. */ | ||
| 198 | }; | ||
| 199 | |||
| 200 | /** Enum for the NDIS hardware states. */ | ||
| 201 | enum NDIS_Hardware_Status_t | ||
| 202 | { | ||
| 203 | NDIS_HardwareStatus_Ready, /**< Hardware Ready to accept commands from the host. */ | ||
| 204 | NDIS_HardwareStatus_Initializing, /**< Hardware busy initializing. */ | ||
| 205 | NDIS_HardwareStatus_Reset, /**< Hardware reset. */ | ||
| 206 | NDIS_HardwareStatus_Closing, /**< Hardware currently closing. */ | ||
| 207 | NDIS_HardwareStatus_NotReady /**< Hardware not ready to accept commands from the host. */ | ||
| 208 | }; | ||
| 209 | |||
| 210 | /* Type Defines: */ | ||
| 211 | /** \brief MAC Address Structure. | ||
| 212 | * | ||
| 213 | * Type define for a physical MAC address of a device on a network. | ||
| 214 | */ | ||
| 215 | typedef struct | ||
| 216 | { | ||
| 217 | uint8_t Octets[6]; /**< Individual bytes of a MAC address */ | ||
| 218 | } ATTR_PACKED MAC_Address_t; | ||
| 219 | |||
| 220 | /** \brief RNDIS Common Message Header Structure. | ||
| 221 | * | ||
| 222 | * Type define for a RNDIS message header, sent before RNDIS messages. | ||
| 223 | * | ||
| 224 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 225 | */ | ||
| 226 | typedef struct | ||
| 227 | { | ||
| 228 | uint32_t MessageType; /**< RNDIS message type, a \c REMOTE_NDIS_*_MSG constant */ | ||
| 229 | uint32_t MessageLength; /**< Total length of the RNDIS message, in bytes */ | ||
| 230 | } ATTR_PACKED RNDIS_Message_Header_t; | ||
| 231 | |||
| 232 | /** \brief RNDIS Message Structure. | ||
| 233 | * | ||
| 234 | * Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter. | ||
| 235 | * | ||
| 236 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 237 | */ | ||
| 238 | typedef struct | ||
| 239 | { | ||
| 240 | uint32_t MessageType; | ||
| 241 | uint32_t MessageLength; | ||
| 242 | uint32_t DataOffset; | ||
| 243 | uint32_t DataLength; | ||
| 244 | uint32_t OOBDataOffset; | ||
| 245 | uint32_t OOBDataLength; | ||
| 246 | uint32_t NumOOBDataElements; | ||
| 247 | uint32_t PerPacketInfoOffset; | ||
| 248 | uint32_t PerPacketInfoLength; | ||
| 249 | uint32_t VcHandle; | ||
| 250 | uint32_t Reserved; | ||
| 251 | } ATTR_PACKED RNDIS_Packet_Message_t; | ||
| 252 | |||
| 253 | /** \brief RNDIS Initialization Message Structure. | ||
| 254 | * | ||
| 255 | * Type define for a RNDIS Initialize command message. | ||
| 256 | * | ||
| 257 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 258 | */ | ||
| 259 | typedef struct | ||
| 260 | { | ||
| 261 | uint32_t MessageType; | ||
| 262 | uint32_t MessageLength; | ||
| 263 | uint32_t RequestId; | ||
| 264 | |||
| 265 | uint32_t MajorVersion; | ||
| 266 | uint32_t MinorVersion; | ||
| 267 | uint32_t MaxTransferSize; | ||
| 268 | } ATTR_PACKED RNDIS_Initialize_Message_t; | ||
| 269 | |||
| 270 | /** \brief RNDIS Initialize Complete Message Structure. | ||
| 271 | * | ||
| 272 | * Type define for a RNDIS Initialize Complete response message. | ||
| 273 | * | ||
| 274 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 275 | */ | ||
| 276 | typedef struct | ||
| 277 | { | ||
| 278 | uint32_t MessageType; | ||
| 279 | uint32_t MessageLength; | ||
| 280 | uint32_t RequestId; | ||
| 281 | uint32_t Status; | ||
| 282 | |||
| 283 | uint32_t MajorVersion; | ||
| 284 | uint32_t MinorVersion; | ||
| 285 | uint32_t DeviceFlags; | ||
| 286 | uint32_t Medium; | ||
| 287 | uint32_t MaxPacketsPerTransfer; | ||
| 288 | uint32_t MaxTransferSize; | ||
| 289 | uint32_t PacketAlignmentFactor; | ||
| 290 | uint32_t AFListOffset; | ||
| 291 | uint32_t AFListSize; | ||
| 292 | } ATTR_PACKED RNDIS_Initialize_Complete_t; | ||
| 293 | |||
| 294 | /** \brief RNDIS Keep Alive Message Structure. | ||
| 295 | * | ||
| 296 | * Type define for a RNDIS Keep Alive command message. | ||
| 297 | * | ||
| 298 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 299 | */ | ||
| 300 | typedef struct | ||
| 301 | { | ||
| 302 | uint32_t MessageType; | ||
| 303 | uint32_t MessageLength; | ||
| 304 | uint32_t RequestId; | ||
| 305 | } ATTR_PACKED RNDIS_KeepAlive_Message_t; | ||
| 306 | |||
| 307 | /** \brief RNDIS Keep Alive Complete Message Structure. | ||
| 308 | * | ||
| 309 | * Type define for a RNDIS Keep Alive Complete response message. | ||
| 310 | * | ||
| 311 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 312 | */ | ||
| 313 | typedef struct | ||
| 314 | { | ||
| 315 | uint32_t MessageType; | ||
| 316 | uint32_t MessageLength; | ||
| 317 | uint32_t RequestId; | ||
| 318 | uint32_t Status; | ||
| 319 | } ATTR_PACKED RNDIS_KeepAlive_Complete_t; | ||
| 320 | |||
| 321 | /** \brief RNDIS Reset Complete Message Structure. | ||
| 322 | * | ||
| 323 | * Type define for a RNDIS Reset Complete response message. | ||
| 324 | * | ||
| 325 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 326 | */ | ||
| 327 | typedef struct | ||
| 328 | { | ||
| 329 | uint32_t MessageType; | ||
| 330 | uint32_t MessageLength; | ||
| 331 | uint32_t Status; | ||
| 332 | |||
| 333 | uint32_t AddressingReset; | ||
| 334 | } ATTR_PACKED RNDIS_Reset_Complete_t; | ||
| 335 | |||
| 336 | /** \brief RNDIS OID Property Set Message Structure. | ||
| 337 | * | ||
| 338 | * Type define for a RNDIS OID Property Set command message. | ||
| 339 | * | ||
| 340 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 341 | */ | ||
| 342 | typedef struct | ||
| 343 | { | ||
| 344 | uint32_t MessageType; | ||
| 345 | uint32_t MessageLength; | ||
| 346 | uint32_t RequestId; | ||
| 347 | |||
| 348 | uint32_t Oid; | ||
| 349 | uint32_t InformationBufferLength; | ||
| 350 | uint32_t InformationBufferOffset; | ||
| 351 | uint32_t DeviceVcHandle; | ||
| 352 | } ATTR_PACKED RNDIS_Set_Message_t; | ||
| 353 | |||
| 354 | /** \brief RNDIS OID Property Set Complete Message Structure. | ||
| 355 | * | ||
| 356 | * Type define for a RNDIS OID Property Set Complete response message. | ||
| 357 | * | ||
| 358 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 359 | */ | ||
| 360 | typedef struct | ||
| 361 | { | ||
| 362 | uint32_t MessageType; | ||
| 363 | uint32_t MessageLength; | ||
| 364 | uint32_t RequestId; | ||
| 365 | uint32_t Status; | ||
| 366 | } ATTR_PACKED RNDIS_Set_Complete_t; | ||
| 367 | |||
| 368 | /** \brief RNDIS OID Property Query Message Structure. | ||
| 369 | * | ||
| 370 | * Type define for a RNDIS OID Property Query command message. | ||
| 371 | * | ||
| 372 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 373 | */ | ||
| 374 | typedef struct | ||
| 375 | { | ||
| 376 | uint32_t MessageType; | ||
| 377 | uint32_t MessageLength; | ||
| 378 | uint32_t RequestId; | ||
| 379 | |||
| 380 | uint32_t Oid; | ||
| 381 | uint32_t InformationBufferLength; | ||
| 382 | uint32_t InformationBufferOffset; | ||
| 383 | uint32_t DeviceVcHandle; | ||
| 384 | } ATTR_PACKED RNDIS_Query_Message_t; | ||
| 385 | |||
| 386 | /** \brief RNDIS OID Property Query Complete Message Structure. | ||
| 387 | * | ||
| 388 | * Type define for a RNDIS OID Property Query Complete response message. | ||
| 389 | * | ||
| 390 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 391 | */ | ||
| 392 | typedef struct | ||
| 393 | { | ||
| 394 | uint32_t MessageType; | ||
| 395 | uint32_t MessageLength; | ||
| 396 | uint32_t RequestId; | ||
| 397 | uint32_t Status; | ||
| 398 | |||
| 399 | uint32_t InformationBufferLength; | ||
| 400 | uint32_t InformationBufferOffset; | ||
| 401 | } ATTR_PACKED RNDIS_Query_Complete_t; | ||
| 402 | |||
| 403 | /* Disable C linkage for C++ Compilers: */ | ||
| 404 | #if defined(__cplusplus) | ||
| 405 | } | ||
| 406 | #endif | ||
| 407 | |||
| 408 | #endif | ||
| 409 | |||
| 410 | /** @} */ | ||
| 411 | |||
diff --git a/lib/lufa/LUFA/Drivers/USB/Class/Common/StillImageClassCommon.h b/lib/lufa/LUFA/Drivers/USB/Class/Common/StillImageClassCommon.h new file mode 100644 index 000000000..7608b18cc --- /dev/null +++ b/lib/lufa/LUFA/Drivers/USB/Class/Common/StillImageClassCommon.h | |||
| @@ -0,0 +1,161 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 12 | Permission to use, copy, modify, distribute, and sell this | ||
| 13 | software and its documentation for any purpose is hereby granted | ||
| 14 | without fee, provided that the above copyright notice appear in | ||
| 15 | all copies and that both that the copyright notice and this | ||
| 16 | permission notice and warranty disclaimer appear in supporting | ||
| 17 | documentation, and that the name of the author not be used in | ||
| 18 | advertising or publicity pertaining to distribution of the | ||
| 19 | software without specific, written prior permission. | ||
| 20 | |||
| 21 | The author disclaims all warranties with regard to this | ||
| 22 | software, including all implied warranties of merchantability | ||
| 23 | and fitness. In no event shall the author be liable for any | ||
| 24 | special, indirect or consequential damages or any damages | ||
| 25 | whatsoever resulting from loss of use, data or profits, whether | ||
| 26 | in an action of contract, negligence or other tortious action, | ||
| 27 | arising out of or in connection with the use or performance of | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | /** \file | ||
| 32 | * \brief Common definitions and declarations for the library USB Still Image Class driver. | ||
| 33 | * | ||
| 34 | * Common definitions and declarations for the library USB Still Image Class driver. | ||
| 35 | * | ||
| 36 | * \note This file should not be included directly. It is automatically included as needed by the USB module driver | ||
| 37 | * dispatch header located in LUFA/Drivers/USB.h. | ||
| 38 | */ | ||
| 39 | |||
| 40 | /** \ingroup Group_USBClassSI | ||
| 41 | * \defgroup Group_USBClassSICommon Common Class Definitions | ||
| 42 | * | ||
| 43 | * \section Sec_USBClassSICommon_ModDescription Module Description | ||
| 44 | * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB | ||
| 45 | * Still Image Class. | ||
| 46 | * | ||
| 47 | * @{ | ||
| 48 | */ | ||
| 49 | |||
| 50 | #ifndef _SI_CLASS_COMMON_H_ | ||
| 51 | #define _SI_CLASS_COMMON_H_ | ||
| 52 | |||
| 53 | /* Includes: */ | ||
| 54 | #include "../../Core/StdDescriptors.h" | ||
| 55 | |||
| 56 | /* Enable C linkage for C++ Compilers: */ | ||
| 57 | #if defined(__cplusplus) | ||
| 58 | extern "C" { | ||
| 59 | #endif | ||
| 60 | |||
| 61 | /* Preprocessor Checks: */ | ||
| 62 | #if !defined(__INCLUDE_FROM_SI_DRIVER) | ||
| 63 | #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. | ||
| 64 | #endif | ||
| 65 | |||
| 66 | /* Macros: */ | ||
| 67 | /** Length in bytes of a given Unicode string's character length. | ||
| 68 | * | ||
| 69 | * \param[in] Chars Total number of Unicode characters in the string. | ||
| 70 | * | ||
| 71 | * \return Number of bytes of the given unicode string. | ||
| 72 | */ | ||
| 73 | #define UNICODE_STRING_LENGTH(Chars) ((Chars) << 1) | ||
| 74 | |||
| 75 | /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for | ||
| 76 | * a command container. | ||
| 77 | * | ||
| 78 | * \param[in] Params Number of parameters which are to be sent in the \c Param field of the container. | ||
| 79 | */ | ||
| 80 | #define PIMA_COMMAND_SIZE(Params) ((sizeof(PIMA_Container_t) - 12) + ((Params) * sizeof(uint32_t))) | ||
| 81 | |||
| 82 | /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for | ||
| 83 | * a data container. | ||
| 84 | * | ||
| 85 | * \param[in] DataLen Length in bytes of the data in the container. | ||
| 86 | */ | ||
| 87 | #define PIMA_DATA_SIZE(DataLen) ((sizeof(PIMA_Container_t) - 12) + (DataLen)) | ||
| 88 | |||
| 89 | /* Enums: */ | ||
| 90 | /** Enum for the possible PIMA contains types. */ | ||
| 91 | enum PIMA_Container_Types_t | ||
| 92 | { | ||
| 93 | PIMA_CONTAINER_Undefined = 0, /**< Undefined container type. */ | ||
| 94 | PIMA_CONTAINER_CommandBlock = 1, /**< Command Block container type. */ | ||
| 95 | PIMA_CONTAINER_DataBlock = 2, /**< Data Block container type. */ | ||
| 96 | PIMA_CONTAINER_ResponseBlock = 3, /**< Response container type. */ | ||
| 97 | PIMA_CONTAINER_EventBlock = 4, /**< Event Block container type. */ | ||
| 98 | }; | ||
| 99 | |||
| 100 | /* Enums: */ | ||
| 101 | /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the | ||
| 102 | * Still Image device class. | ||
| 103 | */ | ||
| 104 | enum SI_Descriptor_ClassSubclassProtocol_t | ||
| 105 | { | ||
| 106 | SI_CSCP_StillImageClass = 0x06, /**< Descriptor Class value indicating that the device or interface | ||
| 107 | * belongs to the Still Image class. | ||
| 108 | */ | ||
| 109 | SI_CSCP_StillImageSubclass = 0x01, /**< Descriptor Subclass value indicating that the device or interface | ||
| 110 | * belongs to the Still Image subclass. | ||
| 111 | */ | ||
| 112 | SI_CSCP_BulkOnlyProtocol = 0x01, /**< Descriptor Protocol value indicating that the device or interface | ||
| 113 | * belongs to the Bulk Only Transport protocol of the Still Image class. | ||
| 114 | */ | ||
| 115 | }; | ||
| 116 | |||
| 117 | /** Enums for the possible status codes of a returned Response Block from an attached PIMA compliant Still Image device. */ | ||
| 118 | enum PIMA_ResponseCodes_t | ||
| 119 | { | ||
| 120 | PIMA_RESPONSE_OK = 1, /**< Response code indicating no error in the issued command. */ | ||
| 121 | PIMA_RESPONSE_GeneralError = 2, /**< Response code indicating a general error while processing the | ||
| 122 | * issued command. | ||
| 123 | */ | ||
| 124 | PIMA_RESPONSE_SessionNotOpen = 3, /**< Response code indicating that the sent command requires an open | ||
| 125 | * session before being issued. | ||
| 126 | */ | ||
| 127 | PIMA_RESPONSE_InvalidTransaction = 4, /**< Response code indicating an invalid transaction occurred. */ | ||
| 128 | PIMA_RESPONSE_OperationNotSupported = 5, /**< Response code indicating that the issued command is not supported | ||
| 129 | * by the attached device. | ||
| 130 | */ | ||
| 131 | PIMA_RESPONSE_ParameterNotSupported = 6, /**< Response code indicating that one or more of the issued command's | ||
| 132 | * parameters are not supported by the device. | ||
| 133 | */ | ||
| 134 | }; | ||
| 135 | |||
| 136 | /* Type Defines: */ | ||
| 137 | /** \brief PIMA Still Image Device Command/Response Container. | ||
| 138 | * | ||
| 139 | * Type define for a PIMA container, use to send commands and receive responses to and from an | ||
| 140 | * attached Still Image device. | ||
| 141 | * | ||
| 142 | * \note Regardless of CPU architecture, these values should be stored as little endian. | ||
| 143 | */ | ||
| 144 | typedef struct | ||
| 145 | { | ||
| 146 | uint32_t DataLength; /**< Length of the container and data, in bytes. */ | ||
| 147 | uint16_t Type; /**< Container type, a value from the \ref PIMA_Container_Types_t enum. */ | ||
| 148 | uint16_t Code; /**< Command, event or response code of the container. */ | ||
| 149 | uint32_t TransactionID; /**< Unique container ID to link blocks together. */ | ||
| 150 | uint32_t Params[3]; /**< Block parameters to be issued along with the block code (command blocks only). */ | ||
| 151 | } ATTR_PACKED PIMA_Container_t; | ||
| 152 | |||
| 153 | /* Disable C linkage for C++ Compilers: */ | ||
| 154 | #if defined(__cplusplus) | ||
| 155 | } | ||
| 156 | #endif | ||
| 157 | |||
| 158 | #endif | ||
| 159 | |||
| 160 | /** @} */ | ||
| 161 | |||
