aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Class/Common
diff options
context:
space:
mode:
Diffstat (limited to 'LUFA/Drivers/USB/Class/Common')
-rw-r--r--LUFA/Drivers/USB/Class/Common/Audio.h381
-rw-r--r--LUFA/Drivers/USB/Class/Common/CDC.h184
-rw-r--r--LUFA/Drivers/USB/Class/Common/HID.h112
-rw-r--r--LUFA/Drivers/USB/Class/Common/MIDI.h171
-rw-r--r--LUFA/Drivers/USB/Class/Common/MassStorage.h135
-rw-r--r--LUFA/Drivers/USB/Class/Common/RNDIS.h274
6 files changed, 1257 insertions, 0 deletions
diff --git a/LUFA/Drivers/USB/Class/Common/Audio.h b/LUFA/Drivers/USB/Class/Common/Audio.h
new file mode 100644
index 000000000..51cdfc6f4
--- /dev/null
+++ b/LUFA/Drivers/USB/Class/Common/Audio.h
@@ -0,0 +1,381 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2009.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, and distribute this software
+ and its documentation for any purpose and without fee is hereby
+ granted, provided that the above copyright notice appear in all
+ copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \ingroup Group_USBClassAudio
+ * @{
+ */
+
+#ifndef _AUDIO_CLASS_COMMON_H_
+#define _AUDIO_CLASS_COMMON_H_
+
+ /* Includes: */
+ #include "../../USB.h"
+
+ #include <string.h>
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Macros: */
+ /** Descriptor header constant to indicate a Audio class interface descriptor. */
+ #define DTYPE_AudioInterface 0x24
+
+ /** Descriptor header constant to indicate a Audio class endpoint descriptor. */
+ #define DTYPE_AudioEndpoint 0x25
+
+ /** Audio class descriptor subtype value for a Audio class specific header descriptor. */
+ #define DSUBTYPE_Header 0x01
+
+ /** Audio class descriptor subtype value for an Output Terminal Audio class specific descriptor. */
+ #define DSUBTYPE_InputTerminal 0x02
+
+ /** Audio class descriptor subtype value for an Input Terminal Audio class specific descriptor. */
+ #define DSUBTYPE_OutputTerminal 0x03
+
+ /** Audio class descriptor subtype value for a Feature Unit Audio class specific descriptor. */
+ #define DSUBTYPE_FeatureUnit 0x06
+
+ /** Audio class descriptor subtype value for a general Audio class specific descriptor. */
+ #define DSUBTYPE_General 0x01
+
+ /** Audio class descriptor subtype value for an Audio class specific descriptor indicating the format of an audio stream. */
+ #define DSUBTYPE_Format 0x02
+
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define CHANNEL_LEFT_FRONT (1 << 0)
+
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define CHANNEL_RIGHT_FRONT (1 << 1)
+
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define CHANNEL_CENTER_FRONT (1 << 2)
+
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define CHANNEL_LOW_FREQ_ENHANCE (1 << 3)
+
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define CHANNEL_LEFT_SURROUND (1 << 4)
+
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define CHANNEL_RIGHT_SURROUND (1 << 5)
+
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define CHANNEL_LEFT_OF_CENTER (1 << 6)
+
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define CHANNEL_RIGHT_OF_CENTER (1 << 7)
+
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define CHANNEL_SURROUND (1 << 8)
+
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define CHANNEL_SIDE_LEFT (1 << 9)
+
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define CHANNEL_SIDE_RIGHT (1 << 10)
+
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define CHANNEL_TOP (1 << 11)
+
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
+ #define FEATURE_MUTE (1 << 0)
+
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
+ #define FEATURE_VOLUME (1 << 1)
+
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
+ #define FEATURE_BASS (1 << 2)
+
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
+ #define FEATURE_MID (1 << 3)
+
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
+ #define FEATURE_TREBLE (1 << 4)
+
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
+ #define FEATURE_GRAPHIC_EQUALIZER (1 << 5)
+
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
+
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
+ #define FEATURE_AUTOMATIC_GAIN (1 << 6)
+
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
+ #define FEATURE_DELAY (1 << 7)
+
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
+ #define FEATURE_BASS_BOOST (1 << 8)
+
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */
+ #define FEATURE_BASS_LOUDNESS (1 << 9)
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_UNDEFINED 0x0100
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_STREAMING 0x0101
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_VENDOR 0x01FF
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_IN_UNDEFINED 0x0200
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_IN_MIC 0x0201
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_IN_DESKTOP_MIC 0x0202
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_IN_PERSONAL_MIC 0x0203
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_IN_OMNIDIR_MIC 0x0204
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_IN_MIC_ARRAY 0x0205
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_IN_PROCESSING_MIC 0x0206
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_IN_OUT_UNDEFINED 0x0300
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_OUT_SPEAKER 0x0301
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_OUT_HEADPHONES 0x0302
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_OUT_HEAD_MOUNTED 0x0303
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_OUT_DESKTOP 0x0304
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_OUT_ROOM 0x0305
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_OUT_COMMUNICATION 0x0306
+
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */
+ #define TERMINAL_OUT_LOWFREQ 0x0307
+
+ /** Convenience macro, to fill a 24-bit AudioSampleFreq_t structure with the given sample rate as a 24-bit number.
+ *
+ * \param freq Required audio sampling frequency in HZ
+ */
+ #define AUDIO_SAMPLE_FREQ(freq) {LowWord: ((uint32_t)freq & 0x00FFFF), HighByte: (((uint32_t)freq >> 16) & 0x0000FF)}
+
+ /** Mask for the attributes parameter of an Audio class specific Endpoint descriptor, indicating that the endpoint
+ * accepts only filled endpoint packets of audio samples.
+ */
+ #define EP_ACCEPTS_ONLY_FULL_PACKETS (1 << 7)
+
+ /** Mask for the attributes parameter of an Audio class specific Endpoint descriptor, indicating that the endpoint
+ * will accept partially filled endpoint packets of audio samples.
+ */
+ #define EP_ACCEPTS_SMALL_PACKETS (0 << 7)
+
+ /* Type Defines: */
+ /** Type define for an Audio class specific interface descriptor. This follows a regular interface descriptor to
+ * supply extra information about the audio device's layout to the host. See the USB Audio specification for more
+ * details.
+ */
+ typedef struct
+ {
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class specific descriptors */
+
+ uint16_t ACSpecification; /**< Binary coded decimal value, indicating the supported Audio Class specification version */
+ uint16_t TotalLength; /**< Total length of the Audio class specific descriptors, including this descriptor */
+
+ uint8_t InCollection; /**< Total number of audio class interfaces within this device */
+ uint8_t InterfaceNumbers[1]; /**< Interface numbers of each audio interface */
+ } USB_AudioInterface_AC_t;
+
+ /** Type define for an Audio class specific Feature Unit descriptor. This indicates to the host what features
+ * are present in the device's audio stream for basic control, such as per-channel volume. See the USB Audio
+ * specification for more details.
+ */
+ typedef struct
+ {
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class specific descriptors */
+
+ uint8_t UnitID; /**< ID value of this feature unit - must be a unique value within the device */
+ uint8_t SourceID; /**< Source ID value of the audio source input into this feature unit */
+
+ uint8_t ControlSize; /**< Size of each element in the ChanelControlls array */
+ uint8_t ChannelControls[3]; /**< Feature masks for the control channel, and each separate audio channel */
+
+ uint8_t FeatureUnitStrIndex; /**< Index of a string descriptor describing this descriptor within the device */
+ } USB_AudioFeatureUnit_t;
+
+ /** Type define for an Audio class specific input terminal descriptor. This indicates to the host that the device
+ * contains an input audio source, either from a physical terminal on the device, or a logical terminal (for example,
+ * a USB endpoint). See the USB Audio specification for more details.
+ */
+ typedef struct
+ {
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class specific descriptors */
+
+ uint8_t TerminalID; /**< ID value of this terminal unit - must be a unique value within the device */
+ uint16_t TerminalType; /**< Type of terminal, a TERMINAL_* mask */
+ uint8_t AssociatedOutputTerminal; /**< ID of associated output terminal, for physically grouped terminals
+ * such as the speaker and microphone of a phone handset
+ */
+ uint8_t TotalChannels; /**< Total number of separate audio channels within this interface (right, left, etc.) */
+ uint16_t ChannelConfig; /**< CHANNEL_* masks indicating what channel layout is supported by this terminal */
+
+ uint8_t ChannelStrIndex; /**< Index of a string descriptor describing this channel within the device */
+ uint8_t TerminalStrIndex; /**< Index of a string descriptor describing this descriptor within the device */
+ } USB_AudioInputTerminal_t;
+
+ /** Type define for an Audio class specific output terminal descriptor. This indicates to the host that the device
+ * contains an output audio sink, either to a physical terminal on the device, or a logical terminal (for example,
+ * a USB endpoint). See the USB Audio specification for more details.
+ */
+ typedef struct
+ {
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class specific descriptors */
+
+ uint8_t TerminalID; /**< ID value of this terminal unit - must be a unique value within the device */
+ uint16_t TerminalType; /**< Type of terminal, a TERMINAL_* mask */
+ uint8_t AssociatedInputTerminal; /**< ID of associated input terminal, for physically grouped terminals
+ * such as the speaker and microphone of a phone handset
+ */
+ uint8_t SourceID; /**< ID value of the unit this terminal's audio is sourced from */
+
+ uint8_t TerminalStrIndex; /**< Index of a string descriptor describing this descriptor within the device */
+ } USB_AudioOutputTerminal_t;
+
+ /** Type define for an Audio class specific streaming interface descriptor. This indicates to the host
+ * how audio streams within the device are formatted. See the USB Audio specification for more details.
+ */
+ typedef struct
+ {
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class specific descriptors */
+
+ uint8_t TerminalLink; /**< ID value of the output terminal this descriptor is describing */
+
+ uint8_t FrameDelay; /**< Delay in frames resulting from the complete sample processing from input to output */
+ uint16_t AudioFormat; /**< Format of the audio stream, see Audio Device Formats specification */
+ } USB_AudioInterface_AS_t;
+
+ /** Type define for a 24bit audio sample frequency structure. GCC does not contain a built in 24bit datatype,
+ * this this structure is used to build up the value instead. Fill this structure with the SAMPLE_FREQ() macro.
+ */
+ typedef struct
+ {
+ uint16_t LowWord; /**< Low 16 bits of the 24-bit value */
+ uint8_t HighByte; /**< Upper 8 bits of the 24-bit value */
+ } AudioSampleFreq_t;
+
+ /** Type define for an Audio class specific audio format descriptor. This is used to give the host full details
+ * about the number of channels, the sample resolution, acceptable sample frequencies and encoding method used
+ * in the device's audio streams. See the USB Audio specification for more details.
+ */
+ typedef struct
+ {
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class specific descriptors */
+
+ uint8_t FormatType; /**< Format of the audio stream, see Audio Device Formats specification */
+ uint8_t Channels; /**< Total number of discrete channels in the stream */
+
+ uint8_t SubFrameSize; /**< Size in bytes of each channel's sample data in the stream */
+ uint8_t BitResolution; /**< Bits of resolution of each channel's samples in the stream */
+
+ uint8_t SampleFrequencyType; /**< Total number of sample frequencies supported by the device */
+ AudioSampleFreq_t SampleFrequencies[1]; /**< Sample frequencies supported by the device */
+ } USB_AudioFormat_t;
+
+ /** Type define for an Audio class specific endpoint descriptor. This contains a regular endpoint
+ * descriptor with a few Audio-class specific extensions. See the USB Audio specification for more details.
+ */
+ typedef struct
+ {
+ USB_Descriptor_Endpoint_t Endpoint; /**< Standard endpoint descriptor describing the audio endpoint */
+
+ uint8_t Refresh; /**< Always set to zero */
+ uint8_t SyncEndpointNumber; /**< Endpoint address to send synchronisation information to, if needed (zero otherwise) */
+ } USB_AudioStreamEndpoint_Std_t;
+
+ /** Type define for an Audio class specific extended endpoint descriptor. This contains extra information
+ * on the usage of endpoints used to stream audio in and out of the USB Audio device, and follows an Audio
+ * class specific extended endpoint descriptor. See the USB Audio specification for more details.
+ */
+ typedef struct
+ {
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class specific descriptors */
+
+ uint8_t Attributes; /**< Audio class specific endpoint attributes, such as ACCEPTS_SMALL_PACKETS */
+
+ uint8_t LockDelayUnits; /**< Units used for the LockDelay field, see Audio class specification */
+ uint16_t LockDelay; /**< Time required to internally lock endpoint's internal clock recovery circuitry */
+ } USB_AudioStreamEndpoint_Spc_t;
+
+ /** Class state structure. An instance of this structure should be made for each Audio interface
+ * within the user application, and passed to each of the Audio class driver functions as the
+ * AudioInterfaceInfo parameter. The contents of this structure should be set to their correct
+ * values when used, or ommitted to force the library to use default values.
+ */
+ typedef struct
+ {
+ uint8_t StreamingInterfaceNumber; /**< Index of the Audio Streaming interface within the device this structure controls */
+
+ uint8_t DataINEndpointNumber; /**< Endpoint number of the incomming Audio Streaming data, if available (zero if unused) */
+ uint16_t DataINEndpointSize; /**< Size in bytes of the incomming Audio Streaming data endpoint, if available (zero if unused) */
+
+ uint8_t DataOUTEndpointNumber; /**< Endpoint number of the outgoing Audio Streaming data, if available (zero if unused) */
+ uint16_t DataOUTEndpointSize; /**< Size in bytes of the outgoing Audio Streaming data endpoint, if available (zero if unused) */
+
+ bool InterfaceEnabled; /**< Set and cleared by the class driver to indicate if the host has enabled the streaming endpoints
+ * of the Audio Streaming interface
+ */
+ } USB_ClassInfo_Audio_t;
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
diff --git a/LUFA/Drivers/USB/Class/Common/CDC.h b/LUFA/Drivers/USB/Class/Common/CDC.h
new file mode 100644
index 000000000..12f8b8381
--- /dev/null
+++ b/LUFA/Drivers/USB/Class/Common/CDC.h
@@ -0,0 +1,184 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2009.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, and distribute this software
+ and its documentation for any purpose and without fee is hereby
+ granted, provided that the above copyright notice appear in all
+ copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \ingroup Group_USBClassCDC
+ * @{
+ */
+
+#ifndef _CDC_CLASS_COMMON_H_
+#define _CDC_CLASS_COMMON_H_
+
+ /* Includes: */
+ #include "../../USB.h"
+
+ #include <string.h>
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Macros: */
+ /** CDC Class specific request to get the current virtual serial port configuration settings. */
+ #define REQ_GetLineEncoding 0x21
+
+ /** CDC Class specific request to set the current virtual serial port configuration settings. */
+ #define REQ_SetLineEncoding 0x20
+
+ /** CDC Class specific request to set the current virtual serial port handshake line states. */
+ #define REQ_SetControlLineState 0x22
+
+ /** Notification type constant for a change in the virtual serial port handshake line states, for
+ * use with a USB_Notification_Header_t notification structure when sent to the host via the CDC
+ * notification endpoint.
+ */
+ #define NOTIF_SerialState 0x20
+
+ /** Mask for the DTR handshake line for use with the REQ_SetControlLineState class specific request
+ * from the host, to indicate that the DTR line state should be high.
+ */
+ #define CDC_CONTROL_LINE_OUT_DTR (1 << 0)
+
+ /** Mask for the RTS handshake line for use with the REQ_SetControlLineState class specific request
+ * from the host, to indicate that theRTS line state should be high.
+ */
+ #define CDC_CONTROL_LINE_OUT_RTS (1 << 1)
+
+ /** Mask for the DCD handshake line for use with the a NOTIF_SerialState class specific notification
+ * from the device to the host, to indicate that the DCD line state is currently high.
+ */
+ #define CDC_CONTROL_LINE_IN_DCD (1 << 0)
+
+ /** Mask for the DSR handshake line for use with the a NOTIF_SerialState class specific notification
+ * from the device to the host, to indicate that the DSR line state is currently high.
+ */
+ #define CDC_CONTROL_LINE_IN_DSR (1 << 1)
+
+ /** Mask for the BREAK handshake line for use with the a NOTIF_SerialState class specific notification
+ * from the device to the host, to indicate that the BREAK line state is currently high.
+ */
+ #define CDC_CONTROL_LINE_IN_BREAK (1 << 2)
+
+ /** Mask for the RING handshake line for use with the a NOTIF_SerialState class specific notification
+ * from the device to the host, to indicate that the RING line state is currently high.
+ */
+ #define CDC_CONTROL_LINE_IN_RING (1 << 3)
+
+ /** Mask for use with the a NOTIF_SerialState class specific notification from the device to the host,
+ * to indicate that a framing error has occurred on the virtual serial port.
+ */
+ #define CDC_CONTROL_LINE_IN_FRAMEERROR (1 << 4)
+
+ /** Mask for use with the a NOTIF_SerialState class specific notification from the device to the host,
+ * to indicate that a parity error has occurred on the virtual serial port.
+ */
+ #define CDC_CONTROL_LINE_IN_PARITYERROR (1 << 5)
+
+ /** Mask for use with the a NOTIF_SerialState class specific notification from the device to the host,
+ * to indicate that a data overrun error has occurred on the virtual serial port.
+ */
+ #define CDC_CONTROL_LINE_IN_OVERRUNERROR (1 << 6)
+
+ /** Macro to define a CDC class-specific functional descriptor. CDC functional descriptors have a
+ * uniform structure but variable sized data payloads, thus cannot be represented accurately by
+ * a single typedef struct. A macro is used instead so that functional descriptors can be created
+ * easily by specifying the size of the payload. This allows sizeof() to work correctly.
+ *
+ * \param DataSize Size in bytes of the CDC functional descriptor's data payload
+ */
+ #define CDC_FUNCTIONAL_DESCRIPTOR(DataSize) \
+ struct \
+ { \
+ USB_Descriptor_Header_t Header; \
+ uint8_t SubType; \
+ uint8_t Data[DataSize]; \
+ }
+
+ /* Enums: */
+ /** Enum for the possible line encoding formats of a virtual serial port. */
+ enum CDCDevice_CDC_LineCodingFormats_t
+ {
+ CDC_LINEENCODING_OneStopBit = 0, /**< Each frame contains one stop bit */
+ CDC_LINEENCODING_OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits */
+ CDC_LINEENCODING_TwoStopBits = 2, /**< Each frame contains two stop bits */
+ };
+
+ /** Enum for the possible line encoding parity settings of a virtual serial port. */
+ enum CDCDevice_LineCodingParity_t
+ {
+ CDC_PARITY_None = 0, /**< No parity bit mode on each frame */
+ CDC_PARITY_Odd = 1, /**< Odd parity bit mode on each frame */
+ CDC_PARITY_Even = 2, /**< Even parity bit mode on each frame */
+ CDC_PARITY_Mark = 3, /**< Mark parity bit mode on each frame */
+ CDC_PARITY_Space = 4, /**< Space parity bit mode on each frame */
+ };
+
+ /* Type Defines: */
+ /** Class state structure. An instance of this structure should be made for each CDC interface
+ * within the user application, and passed to each of the CDC class driver functions as the
+ * CDCInterfaceInfo parameter. The contents of this structure should be set to their correct
+ * values when used, or ommitted to force the library to use default values.
+ */
+ typedef struct
+ {
+ uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device */
+
+ uint8_t DataINEndpointNumber; /**< Endpoint number of the CDC interface's IN data endpoint */
+ uint16_t DataINEndpointSize; /**< Size in bytes of the CDC interface's IN data endpoint */
+
+ uint8_t DataOUTEndpointNumber; /**< Endpoint number of the CDC interface's OUT data endpoint */
+ uint16_t DataOUTEndpointSize; /**< Size in bytes of the CDC interface's OUT data endpoint */
+
+ uint8_t NotificationEndpointNumber; /**< Endpoint number of the CDC interface's IN notification endpoint, if used */
+ uint16_t NotificationEndpointSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used */
+
+ uint8_t ControlLineState; /**< Current control line states, as set by the host */
+
+ struct
+ {
+ uint32_t BaudRateBPS; /**< Baud rate of the virtual serial port, in bits per second */
+ uint8_t CharFormat; /**< Character format of the virtual serial port, a value from the
+ * CDCDevice_CDC_LineCodingFormats_t enum
+ */
+ uint8_t ParityType; /**< Parity setting of the virtual serial port, a value from the
+ * CDCDevice_LineCodingParity_t enum
+ */
+ uint8_t DataBits; /**< Bits of data per character of the virtual serial port */
+ } LineEncoding;
+ } USB_ClassInfo_CDC_t;
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
diff --git a/LUFA/Drivers/USB/Class/Common/HID.h b/LUFA/Drivers/USB/Class/Common/HID.h
new file mode 100644
index 000000000..07ed94b56
--- /dev/null
+++ b/LUFA/Drivers/USB/Class/Common/HID.h
@@ -0,0 +1,112 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2009.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, and distribute this software
+ and its documentation for any purpose and without fee is hereby
+ granted, provided that the above copyright notice appear in all
+ copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \ingroup Group_USBClassHID
+ * @{
+ */
+
+#ifndef _HID_CLASS_COMMON_H_
+#define _HID_CLASS_COMMON_H_
+
+ /* Includes: */
+ #include "../../USB.h"
+
+ #include <string.h>
+
+ /* Macros: */
+ /** HID Class Specific Request to get the current HID report from the device. */
+ #define REQ_GetReport 0x01
+
+ /** HID Class Specific Request to get the current device idle count. */
+ #define REQ_GetIdle 0x02
+
+ /** HID Class Specific Request to set the current HID report to the device. */
+ #define REQ_SetReport 0x09
+
+ /** HID Class Specific Request to set the device's idle count. */
+ #define REQ_SetIdle 0x0A
+
+ /** HID Class Specific Request to get the current HID report protocol mode. */
+ #define REQ_GetProtocol 0x03
+
+ /** HID Class Specific Request to set the current HID report protocol mode. */
+ #define REQ_SetProtocol 0x0B
+
+ /** Descriptor header type value, to indicate a HID class HID descriptor. */
+ #define DTYPE_HID 0x21
+
+ /** Descriptor header type value, to indicate a HID class HID report descriptor. */
+ #define DTYPE_Report 0x22
+
+ /* Type Defines: */
+ /** Type define for the HID class specific HID descriptor, to describe the HID device's specifications. Refer to the HID
+ * specification for details on the structure elements.
+ */
+ typedef struct
+ {
+ USB_Descriptor_Header_t Header;
+
+ uint16_t HIDSpec;
+ uint8_t CountryCode;
+
+ uint8_t TotalReportDescriptors;
+
+ uint8_t HIDReportType;
+ uint16_t HIDReportLength;
+ } USB_Descriptor_HID_t;
+
+ /** Type define for the data type used to store HID report descriptor elements. */
+ typedef uint8_t USB_Descriptor_HIDReport_Datatype_t;
+
+ /** Class state structure. An instance of this structure should be made for each HID interface
+ * within the user application, and passed to each of the HID class driver functions as the
+ * HIDInterfaceInfo parameter. The contents of this structure should be set to their correct
+ * values when used, or ommitted to force the library to use default values.
+ *
+ * Note that for the HID class driver, host-to-device reports are received via HID class requests
+ * rather than a dedicated endpoint to simplify the driver and its interface.
+ */
+ typedef struct
+ {
+ uint8_t InterfaceNumber; /**< Interface number of the HID interface within the device */
+
+ uint8_t ReportINEndpointNumber; /**< Endpoint number of the HID interface's IN report endpoint */
+ uint16_t ReportINEndpointSize; /**< Size in bytes of the HID interface's IN report endpoint */
+
+ uint8_t ReportINBufferSize; /**< Size of the largest possible report to send to the host, for buffer allocation purposes */
+
+ bool UsingReportProtocol; /**< Indicates if the HID interface is set to Boot or Report protocol mode */
+ uint16_t IdleCount; /**< Report idle period, in ms, set by the host */
+ uint16_t IdleMSRemaining; /**< Total number of ms remaining before the idle period elapses */
+ } USB_ClassInfo_HID_t;
+
+#endif
+
+/** @} */
diff --git a/LUFA/Drivers/USB/Class/Common/MIDI.h b/LUFA/Drivers/USB/Class/Common/MIDI.h
new file mode 100644
index 000000000..05bd84630
--- /dev/null
+++ b/LUFA/Drivers/USB/Class/Common/MIDI.h
@@ -0,0 +1,171 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2009.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, and distribute this software
+ and its documentation for any purpose and without fee is hereby
+ granted, provided that the above copyright notice appear in all
+ copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \ingroup Group_USBClassMIDI
+ * @{
+ */
+
+#ifndef _MIDI_CLASS_COMMON_H_
+#define _MIDI_CLASS_COMMON_H_
+
+ /* Includes: */
+ #include "../../USB.h"
+ #include "Audio.h"
+
+ #include <string.h>
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Macros: */
+ /** Audio class descriptor subtype value for a Audio class specific MIDI input jack descriptor. */
+ #define DSUBTYPE_InputJack 0x02
+
+ /** Audio class descriptor subtype value for a Audio class specific MIDI output jack descriptor. */
+ #define DSUBTYPE_OutputJack 0x03
+
+ /** Audio class descriptor jack type value for an embedded (logical) MIDI input or output jack. */
+ #define MIDI_JACKTYPE_EMBEDDED 0x01
+
+ /** Audio class descriptor jack type value for an external (physical) MIDI input or output jack. */
+ #define MIDI_JACKTYPE_EXTERNAL 0x02
+
+ /** MIDI command for a note on (activation) event */
+ #define MIDI_COMMAND_NOTE_ON 0x09
+
+ /** MIDI command for a note off (deactivation) event */
+ #define MIDI_COMMAND_NOTE_OFF 0x08
+
+ /** Standard key press velocity value used for all note events */
+ #define MIDI_STANDARD_VELOCITY 64
+
+ /** Convenience macro. MIDI channels are numbered from 1-10 (natural numbers) however the logical channel
+ * addresses are zero-indexed. This converts a natural MIDI channel number into the logical channel address.
+ *
+ * \param channel MIDI channel number to address
+ */
+ #define MIDI_CHANNEL(channel) (channel - 1)
+
+ /* Type Defines: */
+ /** Type define for an Audio class specific MIDI streaming interface descriptor. This indicates to the host
+ * how MIDI the specification compliance of the device and the total length of the Audio class specific descriptors.
+ * See the USB Audio specification for more details.
+ */
+ typedef struct
+ {
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class specific descriptors */
+
+ uint16_t AudioSpecification; /**< Binary coded decimal value, indicating the supported Audio Class specification version */
+ uint16_t TotalLength; /**< Total length of the Audio class specific descriptors, including this descriptor */
+ } USB_AudioInterface_MIDI_AS_t;
+
+ /** Type define for an Audio class specific MIDI IN jack. This gives information to the host on a MIDI input, either
+ * a physical input jack, or a logical jack (receiving input data internally, or from the host via an endpoint).
+ */
+ typedef struct
+ {
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class specific descriptors */
+
+ uint8_t JackType; /**< Type of jack, one of the JACKTYPE_* mask values */
+ uint8_t JackID; /**< ID value of this jack - must be a unique value within the device */
+
+ uint8_t JackStrIndex; /**< Index of a string descriptor describing this descriptor within the device */
+ } USB_MIDI_In_Jack_t;
+
+ /** Type define for an Audio class specific MIDI OUT jack. This gives information to the host on a MIDI output, either
+ * a physical output jack, or a logical jack (sending output data internally, or to the host via an endpoint).
+ */
+ typedef struct
+ {
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class specific descriptors */
+
+ uint8_t JackType; /**< Type of jack, one of the JACKTYPE_* mask values */
+ uint8_t JackID; /**< ID value of this jack - must be a unique value within the device */
+
+ uint8_t NumberOfPins; /**< Number of output channels within the jack, either physical or logical */
+ uint8_t SourceJackID[1]; /**< ID of each output pin's source data jack */
+ uint8_t SourcePinID[1]; /**< Pin number in the input jack of each output pin's source data */
+
+ uint8_t JackStrIndex; /**< Index of a string descriptor describing this descriptor within the device */
+ } USB_MIDI_Out_Jack_t;
+
+ /** Type define for an Audio class specific extended MIDI jack endpoint descriptor. This contains extra information
+ * on the usage of MIDI endpoints used to stream MIDI events in and out of the USB Audio device, and follows an Audio
+ * class specific extended MIDI endpoint descriptor. See the USB Audio specification for more details.
+ */
+ typedef struct
+ {
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class specific descriptors */
+
+ uint8_t TotalEmbeddedJacks; /**< Total number of jacks inside this endpoint */
+ uint8_t AssociatedJackID[1]; /**< IDs of each jack inside the endpoint */
+ } USB_MIDI_Jack_Endpoint_t;
+
+ /** Type define for a USB MIDI event packet, used to encapsulate sent and received MIDI messages from a USB MIDI interface. */
+ typedef struct
+ {
+ unsigned char Command : 4; /**< MIDI command being sent or received in the event packet */
+ unsigned char CableNumber : 4; /**< Virtual cable number of the event being sent or received in the given MIDI interface */
+
+ uint8_t Data1; /**< First byte of data in the MIDI event */
+ uint8_t Data2; /**< Second byte of data in the MIDI event */
+ uint8_t Data3; /**< Third byte of data in the MIDI event */
+ } USB_MIDI_EventPacket_t;
+
+ /** Class state structure. An instance of this structure should be made for each MIDI interface
+ * within the user application, and passed to each of the MIDI class driver functions as the
+ * MIDIInterfaceInfo parameter. The contents of this structure should be set to their correct
+ * values when used, or ommitted to force the library to use default values.
+ */
+ typedef struct
+ {
+ uint8_t StreamingInterfaceNumber; /**< Index of the Audio Streaming interface within the device this structure controls */
+
+ uint8_t DataINEndpointNumber; /**< Endpoint number of the incomming MIDI data, if available (zero if unused) */
+ uint16_t DataINEndpointSize; /**< Size in bytes of the incomming MIDI data endpoint, if available (zero if unused) */
+
+ uint8_t DataOUTEndpointNumber; /**< Endpoint number of the outgoing MIDI data, if available (zero if unused) */
+ uint16_t DataOUTEndpointSize; /**< Size in bytes of the outgoing MIDI data endpoint, if available (zero if unused) */
+ } USB_ClassInfo_MIDI_t;
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
diff --git a/LUFA/Drivers/USB/Class/Common/MassStorage.h b/LUFA/Drivers/USB/Class/Common/MassStorage.h
new file mode 100644
index 000000000..b4ba0908f
--- /dev/null
+++ b/LUFA/Drivers/USB/Class/Common/MassStorage.h
@@ -0,0 +1,135 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2009.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, and distribute this software
+ and its documentation for any purpose and without fee is hereby
+ granted, provided that the above copyright notice appear in all
+ copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \ingroup Group_USBClassMS
+ * @{
+ */
+
+#ifndef _MS_CLASS_COMMON_H_
+#define _MS_CLASS_COMMON_H_
+
+ /* Includes: */
+ #include "../../USB.h"
+
+ #include <string.h>
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Macros: */
+ /** Mass Storage Class specific request to reset the Mass Storage interface, ready for the next command. */
+ #define REQ_MassStorageReset 0xFF
+
+ /** Mass Storage Class specific request to retrieve the total number of Logical Units (drives) in the SCSI device. */
+ #define REQ_GetMaxLUN 0xFE
+
+ /** Magic signature for a Command Block Wrapper used in the Mass Storage Bulk-Only transport protocol. */
+ #define MS_CBW_SIGNATURE 0x43425355UL
+
+ /** Magic signature for a Command Status Wrapper used in the Mass Storage Bulk-Only transport protocol. */
+ #define MS_CSW_SIGNATURE 0x53425355UL
+
+ /** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from host-to-device. */
+ #define MS_COMMAND_DIR_DATA_OUT (0 << 7)
+
+ /** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from device-to-host. */
+ #define MS_COMMAND_DIR_DATA_IN (1 << 7)
+
+ /* Type defines: */
+ /** Type define for a Command Block Wrapper, used in the Mass Storage Bulk-Only Transport protocol. */
+ typedef struct
+ {
+ uint32_t Signature; /**< Command block signature, must be CBW_SIGNATURE to indicate a valid Command Block */
+ uint32_t Tag; /**< Unique command ID value, to associate a command block wrapper with its command status wrapper */
+ uint32_t DataTransferLength; /** Length of the optional data portion of the issued command, in bytes */
+ uint8_t Flags; /**< Command block flags, indicating command data direction */
+ uint8_t LUN; /**< Logical Unit number this command is issued to */
+ uint8_t SCSICommandLength; /**< Length of the issued SCSI command within the SCSI command data array */
+ uint8_t SCSICommandData[16]; /**< Issued SCSI command in the Command Block */
+ } CommandBlockWrapper_t;
+
+ /** Type define for a Command Status Wrapper, used in the Mass Storage Bulk-Only Transport protocol. */
+ typedef struct
+ {
+ uint32_t Signature; /**< Status block signature, must be CSW_SIGNATURE to indicate a valid Command Status */
+ uint32_t Tag; /**< Unique command ID value, to associate a command block wrapper with its command status wrapper */
+ uint32_t DataTransferResidue; /**< Number of bytes of data not processed in the SCSI command */
+ uint8_t Status; /**< Status code of the issued command - a value from the MassStorage_CommandStatusCodes_t enum */
+ } CommandStatusWrapper_t;
+
+ /* Enums: */
+ /** Enum for the possible command status wrapper return status codes. */
+ enum MassStorage_CommandStatusCodes_t
+ {
+ SCSI_Command_Pass = 0, /**< Command completed with no error */
+ SCSI_Command_Fail = 1, /**< Command failed to complete - host may check the exact error via a SCSI REQUEST SENSE command */
+ SCSI_Phase_Error = 2 /**< Command failed due to being invalid in the current phase */
+ };
+
+ /* Type Defines: */
+ /** Class state structure. An instance of this structure should be made for each Mass Storage interface
+ * within the user application, and passed to each of the Mass Storage class driver functions as the
+ * MSInterfaceInfo parameter. The contents of this structure should be set to their correct
+ * values when used, or ommitted to force the library to use default values.
+ */
+ typedef struct
+ {
+ uint8_t InterfaceNumber; /**< Interface number of the Mass Storage interface within the device */
+
+ uint8_t DataINEndpointNumber; /**< Endpoint number of the Mass Storage interface's IN data endpoint */
+ uint16_t DataINEndpointSize; /**< Size in bytes of the Mass Storage interface's IN data endpoint */
+
+ uint8_t DataOUTEndpointNumber; /**< Endpoint number of the Mass Storage interface's OUT data endpoint */
+ uint16_t DataOUTEndpointSize; /**< Size in bytes of the Mass Storage interface's OUT data endpoint */
+
+ uint8_t TotalLUNs; /**< Total number of logical drives in the Mass Storage interface */
+
+ CommandBlockWrapper_t CommandBlock; /**< Mass Storage class command block structure, used internally
+ * by the class driver
+ */
+ CommandStatusWrapper_t CommandStatus; /**< Mass Storage class command status structure, used internally
+ * by the class driver
+ */
+
+ bool IsMassStoreReset; /**< Flag indicating that the host has requested that the Mass Storage interface be reset
+ * and that all current Mass Storage operations should immediately abort
+ */
+ } USB_ClassInfo_MS_t;
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
diff --git a/LUFA/Drivers/USB/Class/Common/RNDIS.h b/LUFA/Drivers/USB/Class/Common/RNDIS.h
new file mode 100644
index 000000000..abc17334a
--- /dev/null
+++ b/LUFA/Drivers/USB/Class/Common/RNDIS.h
@@ -0,0 +1,274 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2009.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.fourwalledcubicle.com
+*/
+
+/*
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, and distribute this software
+ and its documentation for any purpose and without fee is hereby
+ granted, provided that the above copyright notice appear in all
+ copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \ingroup Group_USBClassRNDIS
+ * @{
+ */
+
+#ifndef _RNDIS_CLASS_COMMON_H_
+#define _RNDIS_CLASS_COMMON_H_
+
+ /* Includes: */
+ #include "../../USB.h"
+
+ #include <string.h>
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Macros: */
+ /** Implemented RNDIS Version Major */
+ #define REMOTE_NDIS_VERSION_MAJOR 0x01
+
+ /** Implemented RNDIS Version Minor */
+ #define REMOTE_NDIS_VERSION_MINOR 0x00
+
+ /** RNDIS request to issue a host-to-device NDIS command */
+ #define REQ_SendEncapsulatedCommand 0x00
+
+ /** RNDIS request to issue a device-to-host NDIS response */
+ #define REQ_GetEncapsulatedResponse 0x01
+
+ /** Maximum size in bytes of a RNDIS control message which can be sent or received */
+ #define RNDIS_MESSAGE_BUFFER_SIZE 128
+
+ /** Maximum size in bytes of an Ethernet frame which can be sent or received */
+ #define ETHERNET_FRAME_SIZE_MAX 1500
+
+ /** Notification request value for a RNDIS Response Available notification */
+ #define NOTIF_ResponseAvailable 1
+
+ /* Enums: */
+ /** Enum for the possible NDIS adapter states. */
+ enum RNDIS_States_t
+ {
+ RNDIS_Uninitialized = 0, /**< Adapter currently uninitialized */
+ RNDIS_Initialized = 1, /**< Adapter currently initialized but not ready for data transfers */
+ RNDIS_Data_Initialized = 2, /**< Adapter currently initialized and ready for data transfers */
+ };
+
+ /** Enum for the NDIS hardware states */
+ enum NDIS_Hardware_Status_t
+ {
+ NDIS_HardwareStatus_Ready, /**< Hardware Ready to accept commands from the host */
+ NDIS_HardwareStatus_Initializing, /**< Hardware busy initializing */
+ NDIS_HardwareStatus_Reset, /**< Hardware reset */
+ NDIS_HardwareStatus_Closing, /**< Hardware currently closing */
+ NDIS_HardwareStatus_NotReady /**< Hardware not ready to accept commands from the host */
+ };
+
+ /* Type Defines: */
+ /** Type define for a physical MAC address of a device on a network */
+ typedef struct
+ {
+ uint8_t Octets[6]; /**< Individual bytes of a MAC address */
+ } MAC_Address_t;
+
+ /** Type define for a RNDIS message header, sent before RNDIS messages */
+ typedef struct
+ {
+ uint32_t MessageType; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */
+ uint32_t MessageLength; /**< Total length of the RNDIS message, in bytes */
+ } RNDIS_Message_Header_t;
+
+ /** Type define for an Ethernet frame buffer. */
+ typedef struct
+ {
+ uint8_t FrameData[ETHERNET_FRAME_SIZE_MAX]; /**< Ethernet frame contents */
+ uint16_t FrameLength; /**< Length in bytes of the Ethernet frame stored in the buffer */
+ bool FrameInBuffer; /**< Indicates if a frame is currently stored in the buffer */
+ } Ethernet_Frame_Info_t;
+
+ /** Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter */
+ typedef struct
+ {
+ uint32_t MessageType;
+ uint32_t MessageLength;
+ uint32_t DataOffset;
+ uint32_t DataLength;
+ uint32_t OOBDataOffset;
+ uint32_t OOBDataLength;
+ uint32_t NumOOBDataElements;
+ uint32_t PerPacketInfoOffset;
+ uint32_t PerPacketInfoLength;
+ uint32_t VcHandle;
+ uint32_t Reserved;
+ } RNDIS_PACKET_MSG_t;
+
+ /** Type define for a RNDIS Initialize command message */
+ typedef struct
+ {
+ uint32_t MessageType;
+ uint32_t MessageLength;
+ uint32_t RequestId;
+
+ uint32_t MajorVersion;
+ uint32_t MinorVersion;
+ uint32_t MaxTransferSize;
+ } RNDIS_INITIALIZE_MSG_t;
+
+ /** Type define for a RNDIS Initialize complete response message */
+ typedef struct
+ {
+ uint32_t MessageType;
+ uint32_t MessageLength;
+ uint32_t RequestId;
+ uint32_t Status;
+
+ uint32_t MajorVersion;
+ uint32_t MinorVersion;
+ uint32_t DeviceFlags;
+ uint32_t Medium;
+ uint32_t MaxPacketsPerTransfer;
+ uint32_t MaxTransferSize;
+ uint32_t PacketAlignmentFactor;
+ uint32_t AFListOffset;
+ uint32_t AFListSize;
+ } RNDIS_INITIALIZE_CMPLT_t;
+
+ /** Type define for a RNDIS Keepalive command message */
+ typedef struct
+ {
+ uint32_t MessageType;
+ uint32_t MessageLength;
+ uint32_t RequestId;
+ } RNDIS_KEEPALIVE_MSG_t;
+
+ /** Type define for a RNDIS Keepalive complete message */
+ typedef struct
+ {
+ uint32_t MessageType;
+ uint32_t MessageLength;
+ uint32_t RequestId;
+ uint32_t Status;
+ } RNDIS_KEEPALIVE_CMPLT_t;
+
+ /** Type define for a RNDIS Reset complete message */
+ typedef struct
+ {
+ uint32_t MessageType;
+ uint32_t MessageLength;
+ uint32_t Status;
+
+ uint32_t AddressingReset;
+ } RNDIS_RESET_CMPLT_t;
+
+ /** Type define for a RNDIS Set command message */
+ typedef struct
+ {
+ uint32_t MessageType;
+ uint32_t MessageLength;
+ uint32_t RequestId;
+
+ uint32_t Oid;
+ uint32_t InformationBufferLength;
+ uint32_t InformationBufferOffset;
+ uint32_t DeviceVcHandle;
+ } RNDIS_SET_MSG_t;
+
+ /** Type define for a RNDIS Set complete response message */
+ typedef struct
+ {
+ uint32_t MessageType;
+ uint32_t MessageLength;
+ uint32_t RequestId;
+ uint32_t Status;
+ } RNDIS_SET_CMPLT_t;
+
+ /** Type define for a RNDIS Query command message */
+ typedef struct
+ {
+ uint32_t MessageType;
+ uint32_t MessageLength;
+ uint32_t RequestId;
+
+ uint32_t Oid;
+ uint32_t InformationBufferLength;
+ uint32_t InformationBufferOffset;
+ uint32_t DeviceVcHandle;
+ } RNDIS_QUERY_MSG_t;
+
+ /** Type define for a RNDIS Query complete response message */
+ typedef struct
+ {
+ uint32_t MessageType;
+ uint32_t MessageLength;
+ uint32_t RequestId;
+ uint32_t Status;
+
+ uint32_t InformationBufferLength;
+ uint32_t InformationBufferOffset;
+ } RNDIS_QUERY_CMPLT_t;
+
+ /** Class state structure. An instance of this structure should be made for each RNDIS interface
+ * within the user application, and passed to each of the RNDIS class driver functions as the
+ * RNDISInterfaceInfo parameter. The contents of this structure should be set to their correct
+ * values when used, or ommitted to force the library to use default values.
+ */
+ typedef struct
+ {
+ uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device */
+
+ uint8_t DataINEndpointNumber; /**< Endpoint number of the CDC interface's IN data endpoint */
+ uint16_t DataINEndpointSize; /**< Size in bytes of the CDC interface's IN data endpoint */
+
+ uint8_t DataOUTEndpointNumber; /**< Endpoint number of the CDC interface's OUT data endpoint */
+ uint16_t DataOUTEndpointSize; /**< Size in bytes of the CDC interface's OUT data endpoint */
+
+ uint8_t NotificationEndpointNumber; /**< Endpoint number of the CDC interface's IN notification endpoint, if used */
+ uint16_t NotificationEndpointSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used */
+
+ char* AdapterVendorDescription; /**< String description of the adapter vendor */
+ MAC_Address_t AdapterMACAddress; /**< MAC address of the adapter */
+
+ uint8_t RNDISMessageBuffer[RNDIS_MESSAGE_BUFFER_SIZE]; /**< Buffer to hold RNDIS messages to and from the host,
+ * managed by the class driver
+ */
+ bool ResponseReady; /**< Internal flag indicating if a RNDIS message is waiting to be returned to the host */
+ uint8_t CurrRNDISState; /**< Current RNDIS state of the adapter, a value from the RNDIS_States_t enum */
+ uint32_t CurrPacketFilter; /**< Current packet filter mode, used internally by the class driver */
+ Ethernet_Frame_Info_t FrameIN; /**< Structure holding the last received Ethernet frame from the host, for user
+ * processing
+ */
+ Ethernet_Frame_Info_t FrameOUT; /**< Structure holding the next Ethernet frame to send to the host, populated by the
+ * user application
+ */
+ } USB_ClassInfo_RNDIS_t;
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */