All USB class drivers are now automatically included when LUFA/Drivers/USB.h is included, and no longer need to be seperately included.

All LowLevel demos changed to use the constants and types defined in the USB class drivers.
This commit is contained in:
Dean Camera 2010-10-24 22:53:57 +00:00
parent 8f3bee7d86
commit b37d77eab3
208 changed files with 589 additions and 2910 deletions

View File

@ -47,7 +47,6 @@
#include <LUFA/Drivers/Board/Buttons.h> #include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/Peripheral/ADC.h> #include <LUFA/Drivers/Peripheral/ADC.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/Audio.h>
#include "Descriptors.h" #include "Descriptors.h"

View File

@ -38,7 +38,6 @@
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/Audio.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>

View File

@ -48,7 +48,6 @@
#include <LUFA/Version.h> #include <LUFA/Version.h>
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/Audio.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -38,7 +38,6 @@
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/Audio.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
@ -82,4 +81,3 @@
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
#endif #endif

View File

@ -40,7 +40,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/CDC.h>
/* Macros: */ /* Macros: */
/** Endpoint number of the first CDC interface's device-to-host notification IN endpoint. */ /** Endpoint number of the first CDC interface's device-to-host notification IN endpoint. */
@ -102,4 +101,3 @@
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
#endif #endif

View File

@ -49,7 +49,6 @@
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Board/Joystick.h> #include <LUFA/Drivers/Board/Joystick.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/CDC.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -40,7 +40,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Type Defines: */ /* Type Defines: */
/** Type define for the device configuration descriptor structure. This must be defined in the /** Type define for the device configuration descriptor structure. This must be defined in the

View File

@ -48,7 +48,6 @@
#include <LUFA/Version.h> #include <LUFA/Version.h>
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -40,7 +40,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Type Defines: */ /* Type Defines: */
/** Type define for the device configuration descriptor structure. This must be defined in the /** Type define for the device configuration descriptor structure. This must be defined in the

View File

@ -50,7 +50,6 @@
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Board/Buttons.h> #include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Type Defines: */ /* Type Defines: */
/** Type define for the joystick HID report structure, for creating and sending HID reports to the host PC. /** Type define for the joystick HID report structure, for creating and sending HID reports to the host PC.

View File

@ -40,7 +40,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Type Defines: */ /* Type Defines: */
/** Type define for the device configuration descriptor structure. This must be defined in the /** Type define for the device configuration descriptor structure. This must be defined in the

View File

@ -51,7 +51,6 @@
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Board/Buttons.h> #include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -40,7 +40,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Type Defines: */ /* Type Defines: */
/** Type define for the device configuration descriptor structure. This must be defined in the /** Type define for the device configuration descriptor structure. This must be defined in the

View File

@ -46,7 +46,6 @@
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Board/Buttons.h> #include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -38,7 +38,6 @@
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/MIDI.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>

View File

@ -51,7 +51,6 @@
#include <LUFA/Drivers/Board/Joystick.h> #include <LUFA/Drivers/Board/Joystick.h>
#include <LUFA/Drivers/Board/Buttons.h> #include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/MIDI.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -40,7 +40,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/MassStorage.h>
/* Macros: */ /* Macros: */
/** Endpoint number of the Mass Storage device-to-host data IN endpoint. */ /** Endpoint number of the Mass Storage device-to-host data IN endpoint. */

View File

@ -44,7 +44,6 @@
#include <LUFA/Common/Common.h> #include <LUFA/Common/Common.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/MassStorage.h>
#include <LUFA/Drivers/Board/Dataflash.h> #include <LUFA/Drivers/Board/Dataflash.h>
/* Preprocessor Checks: */ /* Preprocessor Checks: */

View File

@ -41,7 +41,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/MassStorage.h>
#include "MassStorage.h" #include "MassStorage.h"
#include "Descriptors.h" #include "Descriptors.h"

View File

@ -51,7 +51,6 @@
#include <LUFA/Version.h> #include <LUFA/Version.h>
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/MassStorage.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -41,8 +41,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/MassStorage.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Macros: */ /* Macros: */
/** Endpoint number of the Keyboard HID reporting IN endpoint. */ /** Endpoint number of the Keyboard HID reporting IN endpoint. */

View File

@ -41,7 +41,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/MassStorage.h>
#include "MassStorageKeyboard.h" #include "MassStorageKeyboard.h"
#include "Descriptors.h" #include "Descriptors.h"

View File

@ -56,8 +56,6 @@
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Board/Buttons.h> #include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/MassStorage.h>
#include <LUFA/Drivers/USB/Class/Device/HID.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -38,7 +38,6 @@
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>

View File

@ -52,7 +52,6 @@
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Board/Buttons.h> #include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -38,7 +38,6 @@
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/RNDIS.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>

View File

@ -41,7 +41,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <stdio.h> #include <stdio.h>
#include <LUFA/Drivers/USB/Class/RNDIS.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Peripheral/SerialStream.h>
#include "EthernetProtocols.h" #include "EthernetProtocols.h"

View File

@ -54,7 +54,6 @@
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/RNDIS.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -40,7 +40,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/CDC.h>
/* Macros: */ /* Macros: */
/** Endpoint number of the CDC device-to-host notification IN endpoint. */ /** Endpoint number of the CDC device-to-host notification IN endpoint. */

View File

@ -50,7 +50,6 @@
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Board/Joystick.h> #include <LUFA/Drivers/Board/Joystick.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/CDC.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -40,8 +40,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/CDC.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Macros: */ /* Macros: */
/** Endpoint number of the CDC device-to-host notification IN endpoint. */ /** Endpoint number of the CDC device-to-host notification IN endpoint. */

View File

@ -50,8 +50,6 @@
#include <LUFA/Drivers/Board/Joystick.h> #include <LUFA/Drivers/Board/Joystick.h>
#include <LUFA/Drivers/Board/Buttons.h> #include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/CDC.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -185,7 +185,7 @@ void USB_Audio_Task(void)
/* Microphone is biased to half rail voltage, subtract the bias from the sample value */ /* Microphone is biased to half rail voltage, subtract the bias from the sample value */
AudioSample -= (SAMPLE_MAX_RANGE / 2); AudioSample -= (SAMPLE_MAX_RANGE / 2);
#endif #endif
#end if #endif
/* Write the sample to the buffer */ /* Write the sample to the buffer */
Endpoint_Write_Word_LE(AudioSample); Endpoint_Write_Word_LE(AudioSample);

View File

@ -104,25 +104,25 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.Audio_ControlInterface_SPC = .Audio_ControlInterface_SPC =
{ {
.Header = {.Size = sizeof(USB_Audio_Interface_AC_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_AudioHeader, .Subtype = AUDIO_DSUBTYPE_CSInterface_Header,
.ACSpecification = VERSION_BCD(01.00), .ACSpecification = VERSION_BCD(01.00),
.TotalLength = (sizeof(USB_Audio_Interface_AC_t) + .TotalLength = (sizeof(USB_Audio_Descriptor_Interface_AC_t) +
sizeof(USB_Audio_InputTerminal_t) + sizeof(USB_Audio_Descriptor_InputTerminal_t) +
sizeof(USB_Audio_OutputTerminal_t)), sizeof(USB_Audio_Descriptor_OutputTerminal_t)),
.InCollection = 1, .InCollection = 1,
.InterfaceNumbers = {1}, .InterfaceNumber = 1,
}, },
.Audio_InputTerminal = .Audio_InputTerminal =
{ {
.Header = {.Size = sizeof(USB_Audio_InputTerminal_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_Audio_Descriptor_InputTerminal_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_InputTerminal, .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
.TerminalID = 0x01, .TerminalID = 0x01,
.TerminalType = TERMINAL_IN_MIC, .TerminalType = AUDIO_TERMINAL_IN_MIC,
.AssociatedOutputTerminal = 0x00, .AssociatedOutputTerminal = 0x00,
.TotalChannels = 1, .TotalChannels = 1,
@ -134,11 +134,11 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.Audio_OutputTerminal = .Audio_OutputTerminal =
{ {
.Header = {.Size = sizeof(USB_Audio_OutputTerminal_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_Audio_Descriptor_OutputTerminal_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_OutputTerminal, .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
.TerminalID = 0x02, .TerminalID = 0x02,
.TerminalType = TERMINAL_STREAMING, .TerminalType = AUDIO_TERMINAL_STREAMING,
.AssociatedInputTerminal = 0x00, .AssociatedInputTerminal = 0x00,
.SourceID = 0x01, .SourceID = 0x01,
@ -180,8 +180,8 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.Audio_StreamInterface_SPC = .Audio_StreamInterface_SPC =
{ {
.Header = {.Size = sizeof(USB_Audio_Interface_AS_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AS_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_General, .Subtype = AUDIO_DSUBTYPE_CSInterface_General,
.TerminalLink = 0x02, .TerminalLink = 0x02,
@ -191,25 +191,24 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.Audio_AudioFormat = .Audio_AudioFormat =
{ {
.Header = {.Size = sizeof(USB_Audio_Format_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_Audio_Descriptor_Format_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_Format, .Subtype = AUDIO_DSUBTYPE_CSInterface_FormatType,
.FormatType = 0x01, .FormatType = 0x01,
.Channels = 0x01, .Channels = 0x01,
.SubFrameSize = 0x02, .SubFrameSize = 0x02,
.BitResolution = 16, .BitResolution = 16,
.SampleFrequencyType = (sizeof(ConfigurationDescriptor.Audio_AudioFormat.SampleFrequencies) / .SampleFrequencyType = AUDIO_TOTAL_SAMPLE_RATES,
sizeof(Audio_SampleFreq_t)),
.SampleFrequencies = {SAMPLE_FREQ(AUDIO_SAMPLE_FREQUENCY)} .SampleFrequencies = {AUDIO_SAMPLE_FREQ(AUDIO_SAMPLE_FREQUENCY)}
}, },
.Audio_StreamEndpoint = .Audio_StreamEndpoint =
{ {
.Endpoint = .Endpoint =
{ {
.Header = {.Size = sizeof(USB_Audio_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint}, .Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | AUDIO_STREAM_EPNUM), .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | AUDIO_STREAM_EPNUM),
.Attributes = (EP_TYPE_ISOCHRONOUS | ENDPOINT_ATTR_SYNC | ENDPOINT_USAGE_DATA), .Attributes = (EP_TYPE_ISOCHRONOUS | ENDPOINT_ATTR_SYNC | ENDPOINT_USAGE_DATA),
@ -223,10 +222,10 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.Audio_StreamEndpoint_SPC = .Audio_StreamEndpoint_SPC =
{ {
.Header = {.Size = sizeof(USB_Audio_StreamEndpoint_Spc_t), .Type = DTYPE_CSEndpoint}, .Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Spc_t), .Type = DTYPE_CSEndpoint},
.Subtype = DSUBTYPE_General, .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
.Attributes = EP_ACCEPTS_SMALL_PACKETS, .Attributes = AUDIO_EP_ACCEPTS_SMALL_PACKETS,
.LockDelayUnits = 0x00, .LockDelayUnits = 0x00,
.LockDelay = 0x0000 .LockDelay = 0x0000

View File

@ -42,95 +42,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
/* Macros: */ /* Macros: */
/** Audio class descriptor subtype value for a Audio class specific header descriptor. */
#define DSUBTYPE_AudioHeader 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)
#define CHANNEL_RIGHT_FRONT (1 << 1)
#define CHANNEL_CENTER_FRONT (1 << 2)
#define CHANNEL_LOW_FREQ_ENHANCE (1 << 3)
#define CHANNEL_LEFT_SURROUND (1 << 4)
#define CHANNEL_RIGHT_SURROUND (1 << 5)
#define CHANNEL_LEFT_OF_CENTER (1 << 6)
#define CHANNEL_RIGHT_OF_CENTER (1 << 7)
#define CHANNEL_SURROUND (1 << 8)
#define CHANNEL_SIDE_LEFT (1 << 9)
#define CHANNEL_SIDE_RIGHT (1 << 10)
#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)
#define FEATURE_VOLUME (1 << 1)
#define FEATURE_BASS (1 << 2)
#define FEATURE_MID (1 << 3)
#define FEATURE_TREBLE (1 << 4)
#define FEATURE_GRAPHIC_EQUALIZER (1 << 5)
#define FEATURE_AUTOMATIC_GAIN (1 << 6)
#define FEATURE_DELAY (1 << 7)
#define FEATURE_BASS_BOOST (1 << 8)
#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
#define TERMINAL_STREAMING 0x0101
#define TERMINAL_VENDOR 0x01FF
#define TERMINAL_IN_UNDEFINED 0x0200
#define TERMINAL_IN_MIC 0x0201
#define TERMINAL_IN_DESKTOP_MIC 0x0202
#define TERMINAL_IN_PERSONAL_MIC 0x0203
#define TERMINAL_IN_OMNIDIR_MIC 0x0204
#define TERMINAL_IN_MIC_ARRAY 0x0205
#define TERMINAL_IN_PROCESSING_MIC 0x0206
#define TERMINAL_IN_OUT_UNDEFINED 0x0300
#define TERMINAL_OUT_SPEAKER 0x0301
#define TERMINAL_OUT_HEADPHONES 0x0302
#define TERMINAL_OUT_HEAD_MOUNTED 0x0303
#define TERMINAL_OUT_DESKTOP 0x0304
#define TERMINAL_OUT_ROOM 0x0305
#define TERMINAL_OUT_COMMUNICATION 0x0306
#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[in] freq Required audio sampling frequency in HZ
*/
#define 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)
/** Endpoint number of the Audio isochronous streaming data endpoint. */ /** Endpoint number of the Audio isochronous streaming data endpoint. */
#define AUDIO_STREAM_EPNUM 1 #define AUDIO_STREAM_EPNUM 1
@ -144,165 +55,23 @@
#define AUDIO_SAMPLE_FREQUENCY 48000 #define AUDIO_SAMPLE_FREQUENCY 48000
/* Type Defines: */ /* 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_Audio_Interface_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_Audio_FeatureUnit_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_Audio_InputTerminal_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_Audio_OutputTerminal_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_Audio_Interface_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 */
} Audio_SampleFreq_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 */
Audio_SampleFreq_t SampleFrequencies[1]; /**< Sample frequencies supported by the device */
} USB_Audio_Format_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 synchronization information to, if needed (zero otherwise) */
} USB_Audio_StreamEndpoint_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_Audio_StreamEndpoint_Spc_t;
/** Type define for the device configuration descriptor structure. This must be defined in the /** Type define for the device configuration descriptor structure. This must be defined in the
* application code, as the configuration descriptor contains several sub-descriptors which * application code, as the configuration descriptor contains several sub-descriptors which
* vary between devices, and which describe the device's usage to the host. * vary between devices, and which describe the device's usage to the host.
*/ */
typedef struct typedef struct
{ {
USB_Descriptor_Configuration_Header_t Config; USB_Descriptor_Configuration_Header_t Config;
USB_Descriptor_Interface_t Audio_ControlInterface; USB_Descriptor_Interface_t Audio_ControlInterface;
USB_Audio_Interface_AC_t Audio_ControlInterface_SPC; USB_Audio_Descriptor_Interface_AC_t Audio_ControlInterface_SPC;
USB_Audio_InputTerminal_t Audio_InputTerminal; USB_Audio_Descriptor_InputTerminal_t Audio_InputTerminal;
USB_Audio_OutputTerminal_t Audio_OutputTerminal; USB_Audio_Descriptor_OutputTerminal_t Audio_OutputTerminal;
USB_Descriptor_Interface_t Audio_StreamInterface_Alt0; USB_Descriptor_Interface_t Audio_StreamInterface_Alt0;
USB_Descriptor_Interface_t Audio_StreamInterface_Alt1; USB_Descriptor_Interface_t Audio_StreamInterface_Alt1;
USB_Audio_Interface_AS_t Audio_StreamInterface_SPC; USB_Audio_Descriptor_Interface_AS_t Audio_StreamInterface_SPC;
USB_Audio_Format_t Audio_AudioFormat; USB_Audio_Descriptor_Format_t Audio_AudioFormat;
USB_Audio_StreamEndpoint_Std_t Audio_StreamEndpoint; USB_Audio_Descriptor_StreamEndpoint_Std_t Audio_StreamEndpoint;
USB_Audio_StreamEndpoint_Spc_t Audio_StreamEndpoint_SPC; USB_Audio_Descriptor_StreamEndpoint_Spc_t Audio_StreamEndpoint_SPC;
} USB_Descriptor_Configuration_t; } USB_Descriptor_Configuration_t;
/* Function Prototypes: */ /* Function Prototypes: */

View File

@ -104,29 +104,29 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.Audio_ControlInterface_SPC = .Audio_ControlInterface_SPC =
{ {
.Header = {.Size = sizeof(USB_Audio_Interface_AC_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_AudioHeader, .Subtype = AUDIO_DSUBTYPE_CSInterface_Header,
.ACSpecification = VERSION_BCD(01.00), .ACSpecification = VERSION_BCD(01.00),
.TotalLength = (sizeof(USB_Audio_Interface_AC_t) + .TotalLength = (sizeof(USB_Audio_Descriptor_Interface_AC_t) +
sizeof(USB_Audio_InputTerminal_t) + sizeof(USB_Audio_Descriptor_InputTerminal_t) +
sizeof(USB_Audio_OutputTerminal_t)), sizeof(USB_Audio_Descriptor_OutputTerminal_t)),
.InCollection = 1, .InCollection = 1,
.InterfaceNumbers = {1}, .InterfaceNumber = 1,
}, },
.Audio_InputTerminal = .Audio_InputTerminal =
{ {
.Header = {.Size = sizeof(USB_Audio_InputTerminal_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_Audio_Descriptor_InputTerminal_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_InputTerminal, .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
.TerminalID = 0x01, .TerminalID = 0x01,
.TerminalType = TERMINAL_STREAMING, .TerminalType = AUDIO_TERMINAL_STREAMING,
.AssociatedOutputTerminal = 0x00, .AssociatedOutputTerminal = 0x00,
.TotalChannels = 2, .TotalChannels = 2,
.ChannelConfig = (CHANNEL_LEFT_FRONT | CHANNEL_RIGHT_FRONT), .ChannelConfig = (AUDIO_CHANNEL_LEFT_FRONT | AUDIO_CHANNEL_RIGHT_FRONT),
.ChannelStrIndex = NO_DESCRIPTOR, .ChannelStrIndex = NO_DESCRIPTOR,
.TerminalStrIndex = NO_DESCRIPTOR .TerminalStrIndex = NO_DESCRIPTOR
@ -134,11 +134,11 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.Audio_OutputTerminal = .Audio_OutputTerminal =
{ {
.Header = {.Size = sizeof(USB_Audio_OutputTerminal_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_Audio_Descriptor_OutputTerminal_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_OutputTerminal, .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
.TerminalID = 0x02, .TerminalID = 0x02,
.TerminalType = TERMINAL_OUT_SPEAKER, .TerminalType = AUDIO_TERMINAL_OUT_SPEAKER,
.AssociatedInputTerminal = 0x00, .AssociatedInputTerminal = 0x00,
.SourceID = 0x01, .SourceID = 0x01,
@ -180,8 +180,8 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.Audio_StreamInterface_SPC = .Audio_StreamInterface_SPC =
{ {
.Header = {.Size = sizeof(USB_Audio_Interface_AS_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AS_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_General, .Subtype = AUDIO_DSUBTYPE_CSInterface_General,
.TerminalLink = 0x01, .TerminalLink = 0x01,
@ -191,8 +191,8 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.Audio_AudioFormat = .Audio_AudioFormat =
{ {
.Header = {.Size = sizeof(USB_Audio_Format_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_Audio_Descriptor_Format_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_Format, .Subtype = AUDIO_DSUBTYPE_CSInterface_FormatType,
.FormatType = 0x01, .FormatType = 0x01,
.Channels = 0x02, .Channels = 0x02,
@ -200,16 +200,15 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.SubFrameSize = 0x02, .SubFrameSize = 0x02,
.BitResolution = 16, .BitResolution = 16,
.SampleFrequencyType = (sizeof(ConfigurationDescriptor.Audio_AudioFormat.SampleFrequencies) / .SampleFrequencyType = AUDIO_TOTAL_SAMPLE_RATES,
sizeof(Audio_SampleFreq_t)), .SampleFrequencies = {AUDIO_SAMPLE_FREQ(AUDIO_SAMPLE_FREQUENCY)}
.SampleFrequencies = {SAMPLE_FREQ(AUDIO_SAMPLE_FREQUENCY)}
}, },
.Audio_StreamEndpoint = .Audio_StreamEndpoint =
{ {
.Endpoint = .Endpoint =
{ {
.Header = {.Size = sizeof(USB_Audio_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint}, .Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | AUDIO_STREAM_EPNUM), .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | AUDIO_STREAM_EPNUM),
.Attributes = (EP_TYPE_ISOCHRONOUS | ENDPOINT_ATTR_SYNC | ENDPOINT_USAGE_DATA), .Attributes = (EP_TYPE_ISOCHRONOUS | ENDPOINT_ATTR_SYNC | ENDPOINT_USAGE_DATA),
@ -223,10 +222,10 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.Audio_StreamEndpoint_SPC = .Audio_StreamEndpoint_SPC =
{ {
.Header = {.Size = sizeof(USB_Audio_StreamEndpoint_Spc_t), .Type = DTYPE_CSEndpoint}, .Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Spc_t), .Type = DTYPE_CSEndpoint},
.Subtype = DSUBTYPE_General, .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
.Attributes = EP_ACCEPTS_SMALL_PACKETS, .Attributes = AUDIO_EP_ACCEPTS_SMALL_PACKETS,
.LockDelayUnits = 0x00, .LockDelayUnits = 0x00,
.LockDelay = 0x0000 .LockDelay = 0x0000

View File

@ -42,95 +42,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
/* Macros: */ /* Macros: */
/** Audio class descriptor subtype value for a Audio class specific header descriptor. */
#define DSUBTYPE_AudioHeader 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)
#define CHANNEL_RIGHT_FRONT (1 << 1)
#define CHANNEL_CENTER_FRONT (1 << 2)
#define CHANNEL_LOW_FREQ_ENHANCE (1 << 3)
#define CHANNEL_LEFT_SURROUND (1 << 4)
#define CHANNEL_RIGHT_SURROUND (1 << 5)
#define CHANNEL_LEFT_OF_CENTER (1 << 6)
#define CHANNEL_RIGHT_OF_CENTER (1 << 7)
#define CHANNEL_SURROUND (1 << 8)
#define CHANNEL_SIDE_LEFT (1 << 9)
#define CHANNEL_SIDE_RIGHT (1 << 10)
#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)
#define FEATURE_VOLUME (1 << 1)
#define FEATURE_BASS (1 << 2)
#define FEATURE_MID (1 << 3)
#define FEATURE_TREBLE (1 << 4)
#define FEATURE_GRAPHIC_EQUALIZER (1 << 5)
#define FEATURE_AUTOMATIC_GAIN (1 << 6)
#define FEATURE_DELAY (1 << 7)
#define FEATURE_BASS_BOOST (1 << 8)
#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
#define TERMINAL_STREAMING 0x0101
#define TERMINAL_VENDOR 0x01FF
#define TERMINAL_IN_UNDEFINED 0x0200
#define TERMINAL_IN_MIC 0x0201
#define TERMINAL_IN_DESKTOP_MIC 0x0202
#define TERMINAL_IN_PERSONAL_MIC 0x0203
#define TERMINAL_IN_OMNIDIR_MIC 0x0204
#define TERMINAL_IN_MIC_ARRAY 0x0205
#define TERMINAL_IN_PROCESSING_MIC 0x0206
#define TERMINAL_IN_OUT_UNDEFINED 0x0300
#define TERMINAL_OUT_SPEAKER 0x0301
#define TERMINAL_OUT_HEADPHONES 0x0302
#define TERMINAL_OUT_HEAD_MOUNTED 0x0303
#define TERMINAL_OUT_DESKTOP 0x0304
#define TERMINAL_OUT_ROOM 0x0305
#define TERMINAL_OUT_COMMUNICATION 0x0306
#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[in] freq Required audio sampling frequency in HZ
*/
#define 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)
/** Endpoint number of the Audio isochronous streaming data endpoint. */ /** Endpoint number of the Audio isochronous streaming data endpoint. */
#define AUDIO_STREAM_EPNUM 1 #define AUDIO_STREAM_EPNUM 1
@ -144,165 +55,23 @@
#define AUDIO_SAMPLE_FREQUENCY 48000 #define AUDIO_SAMPLE_FREQUENCY 48000
/* Type Defines: */ /* 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_Audio_Interface_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_Audio_FeatureUnit_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_Audio_InputTerminal_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_Audio_OutputTerminal_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_Audio_Interface_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 */
} Audio_SampleFreq_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 */
Audio_SampleFreq_t SampleFrequencies[1]; /**< Sample frequencies supported by the device */
} USB_Audio_Format_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 synchronization information to, if needed (zero otherwise) */
} USB_Audio_StreamEndpoint_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_Audio_StreamEndpoint_Spc_t;
/** Type define for the device configuration descriptor structure. This must be defined in the /** Type define for the device configuration descriptor structure. This must be defined in the
* application code, as the configuration descriptor contains several sub-descriptors which * application code, as the configuration descriptor contains several sub-descriptors which
* vary between devices, and which describe the device's usage to the host. * vary between devices, and which describe the device's usage to the host.
*/ */
typedef struct typedef struct
{ {
USB_Descriptor_Configuration_Header_t Config; USB_Descriptor_Configuration_Header_t Config;
USB_Descriptor_Interface_t Audio_ControlInterface; USB_Descriptor_Interface_t Audio_ControlInterface;
USB_Audio_Interface_AC_t Audio_ControlInterface_SPC; USB_Audio_Descriptor_Interface_AC_t Audio_ControlInterface_SPC;
USB_Audio_InputTerminal_t Audio_InputTerminal; USB_Audio_Descriptor_InputTerminal_t Audio_InputTerminal;
USB_Audio_OutputTerminal_t Audio_OutputTerminal; USB_Audio_Descriptor_OutputTerminal_t Audio_OutputTerminal;
USB_Descriptor_Interface_t Audio_StreamInterface_Alt0; USB_Descriptor_Interface_t Audio_StreamInterface_Alt0;
USB_Descriptor_Interface_t Audio_StreamInterface_Alt1; USB_Descriptor_Interface_t Audio_StreamInterface_Alt1;
USB_Audio_Interface_AS_t Audio_StreamInterface_SPC; USB_Audio_Descriptor_Interface_AS_t Audio_StreamInterface_SPC;
USB_Audio_Format_t Audio_AudioFormat; USB_Audio_Descriptor_Format_t Audio_AudioFormat;
USB_Audio_StreamEndpoint_Std_t Audio_StreamEndpoint; USB_Audio_Descriptor_StreamEndpoint_Std_t Audio_StreamEndpoint;
USB_Audio_StreamEndpoint_Spc_t Audio_StreamEndpoint_SPC; USB_Audio_Descriptor_StreamEndpoint_Spc_t Audio_StreamEndpoint_SPC;
} USB_Descriptor_Configuration_t; } USB_Descriptor_Configuration_t;
/* Function Prototypes: */ /* Function Prototypes: */
@ -312,4 +81,3 @@
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
#endif #endif

View File

@ -130,24 +130,24 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.CDC1_Functional_Header = .CDC1_Functional_Header =
{ {
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalHeader_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
.Subtype = 0x00, .Subtype = CDC_DSUBTYPE_CSInterface_Header,
.CDCSpecification = VERSION_BCD(01.10), .CDCSpecification = VERSION_BCD(01.10),
}, },
.CDC1_Functional_ACM = .CDC1_Functional_ACM =
{ {
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalACM_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
.Subtype = 0x02, .Subtype = CDC_DSUBTYPE_CSInterface_ACM,
.Capabilities = 0x06, .Capabilities = 0x06,
}, },
.CDC1_Functional_Union = .CDC1_Functional_Union =
{ {
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalUnion_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
.Subtype = 0x06, .Subtype = CDC_DSUBTYPE_CSInterface_Union,
.MasterInterfaceNumber = 0, .MasterInterfaceNumber = 0,
.SlaveInterfaceNumber = 1, .SlaveInterfaceNumber = 1,
@ -231,24 +231,24 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.CDC2_Functional_Header = .CDC2_Functional_Header =
{ {
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalHeader_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
.Subtype = 0x00, .Subtype = CDC_DSUBTYPE_CSInterface_Header,
.CDCSpecification = VERSION_BCD(01.10), .CDCSpecification = VERSION_BCD(01.10),
}, },
.CDC2_Functional_ACM = .CDC2_Functional_ACM =
{ {
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalACM_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
.Subtype = 0x02, .Subtype = CDC_DSUBTYPE_CSInterface_ACM,
.Capabilities = 0x06, .Capabilities = 0x06,
}, },
.CDC2_Functional_Union = .CDC2_Functional_Union =
{ {
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalUnion_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
.Subtype = 0x06, .Subtype = CDC_DSUBTYPE_CSInterface_Union,
.MasterInterfaceNumber = 2, .MasterInterfaceNumber = 2,
.SlaveInterfaceNumber = 3, .SlaveInterfaceNumber = 3,

View File

@ -42,23 +42,23 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
/* Macros: */ /* Macros: */
/** Endpoint number of the first CDC interface's device-to-host notification IN endpoint. */
#define CDC1_NOTIFICATION_EPNUM 3
/** Endpoint number of the first CDC interface's device-to-host data IN endpoint. */ /** Endpoint number of the first CDC interface's device-to-host data IN endpoint. */
#define CDC1_TX_EPNUM 1 #define CDC1_TX_EPNUM 1
/** Endpoint number of the first CDC interface's host-to-device data OUT endpoint. */ /** Endpoint number of the first CDC interface's host-to-device data OUT endpoint. */
#define CDC1_RX_EPNUM 2 #define CDC1_RX_EPNUM 2
/** Endpoint number of the first CDC interface's device-to-host notification IN endpoint. */ /** Endpoint number of the second CDC interface's device-to-host notification IN endpoint. */
#define CDC1_NOTIFICATION_EPNUM 3 #define CDC2_NOTIFICATION_EPNUM 4
/** Endpoint number of the second CDC interface's device-to-host data IN endpoint. */ /** Endpoint number of the second CDC interface's device-to-host data IN endpoint. */
#define CDC2_TX_EPNUM 4 #define CDC2_TX_EPNUM 5
/** Endpoint number of the second CDC interface's host-to-device data OUT endpoint. */ /** Endpoint number of the second CDC interface's host-to-device data OUT endpoint. */
#define CDC2_RX_EPNUM 5 #define CDC2_RX_EPNUM 6
/** Endpoint number of the second CDC interface's device-to-host notification IN endpoint. */
#define CDC2_NOTIFICATION_EPNUM 6
/** Size in bytes of the CDC device-to-host notification IN endpoints. */ /** Size in bytes of the CDC device-to-host notification IN endpoints. */
#define CDC_NOTIFICATION_EPSIZE 8 #define CDC_NOTIFICATION_EPSIZE 8
@ -67,40 +67,6 @@
#define CDC_TXRX_EPSIZE 16 #define CDC_TXRX_EPSIZE 16
/* Type Defines: */ /* Type Defines: */
/** Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device
* contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration.
* See the CDC class 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 CDC class-specific descriptors. */
uint16_t CDCSpecification; /**< Version number of the CDC specification implemented by the device,
* encoded in BCD format.
*/
} USB_Descriptor_CDC_FunctionalHeader_t;
/** Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface
* supports the CDC ACM subclass of the CDC specification. See the CDC class 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 CDC class-specific descriptors. */
uint8_t Capabilities; /**< Capabilities of the ACM interface, given as a bit mask. */
} USB_Descriptor_CDC_FunctionalACM_t;
/** Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific
* CDC control and data interfaces are related. See the CDC class 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 CDC class-specific descriptors. */
uint8_t MasterInterfaceNumber; /**< Interface number of the CDC Control interface. */
uint8_t SlaveInterfaceNumber; /**< Interface number of the CDC Data interface. */
} USB_Descriptor_CDC_FunctionalUnion_t;
/** Type define for the device configuration descriptor structure. This must be defined in the /** Type define for the device configuration descriptor structure. This must be defined in the
* application code, as the configuration descriptor contains several sub-descriptors which * application code, as the configuration descriptor contains several sub-descriptors which
* vary between devices, and which describe the device's usage to the host. * vary between devices, and which describe the device's usage to the host.
@ -110,18 +76,18 @@
USB_Descriptor_Configuration_Header_t Config; USB_Descriptor_Configuration_Header_t Config;
USB_Descriptor_Interface_Association_t CDC1_IAD; USB_Descriptor_Interface_Association_t CDC1_IAD;
USB_Descriptor_Interface_t CDC1_CCI_Interface; USB_Descriptor_Interface_t CDC1_CCI_Interface;
USB_Descriptor_CDC_FunctionalHeader_t CDC1_Functional_Header; USB_CDC_Descriptor_FunctionalHeader_t CDC1_Functional_Header;
USB_Descriptor_CDC_FunctionalACM_t CDC1_Functional_ACM; USB_CDC_Descriptor_FunctionalACM_t CDC1_Functional_ACM;
USB_Descriptor_CDC_FunctionalUnion_t CDC1_Functional_Union; USB_CDC_Descriptor_FunctionalUnion_t CDC1_Functional_Union;
USB_Descriptor_Endpoint_t CDC1_ManagementEndpoint; USB_Descriptor_Endpoint_t CDC1_ManagementEndpoint;
USB_Descriptor_Interface_t CDC1_DCI_Interface; USB_Descriptor_Interface_t CDC1_DCI_Interface;
USB_Descriptor_Endpoint_t CDC1_DataOutEndpoint; USB_Descriptor_Endpoint_t CDC1_DataOutEndpoint;
USB_Descriptor_Endpoint_t CDC1_DataInEndpoint; USB_Descriptor_Endpoint_t CDC1_DataInEndpoint;
USB_Descriptor_Interface_Association_t CDC2_IAD; USB_Descriptor_Interface_Association_t CDC2_IAD;
USB_Descriptor_Interface_t CDC2_CCI_Interface; USB_Descriptor_Interface_t CDC2_CCI_Interface;
USB_Descriptor_CDC_FunctionalHeader_t CDC2_Functional_Header; USB_CDC_Descriptor_FunctionalHeader_t CDC2_Functional_Header;
USB_Descriptor_CDC_FunctionalACM_t CDC2_Functional_ACM; USB_CDC_Descriptor_FunctionalACM_t CDC2_Functional_ACM;
USB_Descriptor_CDC_FunctionalUnion_t CDC2_Functional_Union; USB_CDC_Descriptor_FunctionalUnion_t CDC2_Functional_Union;
USB_Descriptor_Endpoint_t CDC2_ManagementEndpoint; USB_Descriptor_Endpoint_t CDC2_ManagementEndpoint;
USB_Descriptor_Interface_t CDC2_DCI_Interface; USB_Descriptor_Interface_t CDC2_DCI_Interface;
USB_Descriptor_Endpoint_t CDC2_DataOutEndpoint; USB_Descriptor_Endpoint_t CDC2_DataOutEndpoint;
@ -135,4 +101,3 @@
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
#endif #endif

View File

@ -44,10 +44,10 @@
* It is possible to completely ignore these value or use other settings as the host is completely unaware of the physical * It is possible to completely ignore these value or use other settings as the host is completely unaware of the physical
* serial link characteristics and instead sends and receives data in endpoint streams. * serial link characteristics and instead sends and receives data in endpoint streams.
*/ */
CDC_Line_Coding_t LineEncoding1 = { .BaudRateBPS = 0, CDC_LineEncoding_t LineEncoding1 = { .BaudRateBPS = 0,
.CharFormat = OneStopBit, .CharFormat = CDC_LINEENCODING_OneStopBit,
.ParityType = Parity_None, .ParityType = CDC_PARITY_None,
.DataBits = 8 }; .DataBits = 8 };
/** Contains the current baud rate and other settings of the second virtual serial port. While this demo does not use /** Contains the current baud rate and other settings of the second virtual serial port. While this demo does not use
* the physical USART and thus does not use these settings, they must still be retained and returned to the host * the physical USART and thus does not use these settings, they must still be retained and returned to the host
@ -57,10 +57,10 @@ CDC_Line_Coding_t LineEncoding1 = { .BaudRateBPS = 0,
* It is possible to completely ignore these value or use other settings as the host is completely unaware of the physical * It is possible to completely ignore these value or use other settings as the host is completely unaware of the physical
* serial link characteristics and instead sends and receives data in endpoint streams. * serial link characteristics and instead sends and receives data in endpoint streams.
*/ */
CDC_Line_Coding_t LineEncoding2 = { .BaudRateBPS = 0, CDC_LineEncoding_t LineEncoding2 = { .BaudRateBPS = 0,
.CharFormat = OneStopBit, .CharFormat = CDC_LINEENCODING_OneStopBit,
.ParityType = Parity_None, .ParityType = CDC_PARITY_None,
.DataBits = 8 }; .DataBits = 8 };
/** Main program entry point. This routine configures the hardware required by the application, then /** Main program entry point. This routine configures the hardware required by the application, then
@ -158,29 +158,29 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
/* Process CDC specific control requests */ /* Process CDC specific control requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)
{ {
case REQ_GetLineEncoding: case CDC_REQ_GetLineEncoding:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
/* Write the line coding data to the control endpoint */ /* Write the line coding data to the control endpoint */
Endpoint_Write_Control_Stream_LE(LineEncodingData, sizeof(CDC_Line_Coding_t)); Endpoint_Write_Control_Stream_LE(LineEncodingData, sizeof(CDC_LineEncoding_t));
Endpoint_ClearOUT(); Endpoint_ClearOUT();
} }
break; break;
case REQ_SetLineEncoding: case CDC_REQ_SetLineEncoding:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
/* Read the line coding data in from the host into the global struct */ /* Read the line coding data in from the host into the global struct */
Endpoint_Read_Control_Stream_LE(LineEncodingData, sizeof(CDC_Line_Coding_t)); Endpoint_Read_Control_Stream_LE(LineEncodingData, sizeof(CDC_LineEncoding_t));
Endpoint_ClearIN(); Endpoint_ClearIN();
} }
break; break;
case REQ_SetControlLineState: case CDC_REQ_SetControlLineState:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();

View File

@ -51,15 +51,6 @@
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
/* Macros: */ /* 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
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1 #define LEDMASK_USB_NOTREADY LEDS_LED1
@ -72,41 +63,6 @@
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
/* Type Defines: */
/** Type define for the virtual serial port line encoding settings, for storing the current USART configuration
* as set by the host via a class specific request.
*/
typedef 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 */
} CDC_Line_Coding_t;
/* Enums: */
/** Enum for the possible line encoding formats of a virtual serial port. */
enum CDCDevice_CDC_LineCodingFormats_t
{
OneStopBit = 0, /**< Each frame contains one stop bit */
OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits */
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
{
Parity_None = 0, /**< No parity bit mode on each frame */
Parity_Odd = 1, /**< Odd parity bit mode on each frame */
Parity_Even = 2, /**< Even parity bit mode on each frame */
Parity_Mark = 3, /**< Mark parity bit mode on each frame */
Parity_Space = 4, /**< Space parity bit mode on each frame */
};
/* Function Prototypes: */ /* Function Prototypes: */
void CDC1_Task(void); void CDC1_Task(void);
void CDC2_Task(void); void CDC2_Task(void);

View File

@ -130,12 +130,12 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.HID_GenericHID = .HID_GenericHID =
{ {
.Header = {.Size = sizeof(USB_Descriptor_HID_t), .Type = DTYPE_HID}, .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
.HIDSpec = VERSION_BCD(01.11), .HIDSpec = VERSION_BCD(01.11),
.CountryCode = 0x00, .CountryCode = 0x00,
.TotalReportDescriptors = 1, .TotalReportDescriptors = 1,
.HIDReportType = DTYPE_Report, .HIDReportType = HID_DTYPE_Report,
.HIDReportLength = sizeof(GenericReport) .HIDReportLength = sizeof(GenericReport)
}, },
@ -237,11 +237,11 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
} }
break; break;
case DTYPE_HID: case HID_DTYPE_HID:
Address = &ConfigurationDescriptor.HID_GenericHID; Address = &ConfigurationDescriptor.HID_GenericHID;
Size = sizeof(USB_Descriptor_HID_t); Size = sizeof(USB_HID_Descriptor_HID_t);
break; break;
case DTYPE_Report: case HID_DTYPE_Report:
Address = &GenericReport; Address = &GenericReport;
Size = sizeof(GenericReport); Size = sizeof(GenericReport);
break; break;

View File

@ -42,25 +42,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
/* Type Defines: */ /* 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;
/** Type define for the device configuration descriptor structure. This must be defined in the /** Type define for the device configuration descriptor structure. This must be defined in the
* application code, as the configuration descriptor contains several sub-descriptors which * application code, as the configuration descriptor contains several sub-descriptors which
* vary between devices, and which describe the device's usage to the host. * vary between devices, and which describe the device's usage to the host.
@ -69,7 +50,7 @@
{ {
USB_Descriptor_Configuration_Header_t Config; USB_Descriptor_Configuration_Header_t Config;
USB_Descriptor_Interface_t HID_Interface; USB_Descriptor_Interface_t HID_Interface;
USB_Descriptor_HID_t HID_GenericHID; USB_HID_Descriptor_HID_t HID_GenericHID;
USB_Descriptor_Endpoint_t HID_ReportINEndpoint; USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
USB_Descriptor_Endpoint_t HID_ReportOUTEndpoint; USB_Descriptor_Endpoint_t HID_ReportOUTEndpoint;
} USB_Descriptor_Configuration_t; } USB_Descriptor_Configuration_t;
@ -87,12 +68,6 @@
/** Size in bytes of the Generic HID reports (including report ID byte). */ /** Size in bytes of the Generic HID reports (including report ID byte). */
#define GENERIC_REPORT_SIZE 8 #define GENERIC_REPORT_SIZE 8
/** 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
/* Function Prototypes: */ /* Function Prototypes: */
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex, const uint8_t wIndex,

View File

@ -116,7 +116,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
/* Handle HID Class specific requests */ /* Handle HID Class specific requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)
{ {
case REQ_GetReport: case HID_REQ_GetReport:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
uint8_t GenericData[GENERIC_REPORT_SIZE]; uint8_t GenericData[GENERIC_REPORT_SIZE];
@ -130,7 +130,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
} }
break; break;
case REQ_SetReport: case HID_REQ_SetReport:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
uint8_t GenericData[GENERIC_REPORT_SIZE]; uint8_t GenericData[GENERIC_REPORT_SIZE];

View File

@ -51,12 +51,6 @@
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
/* Macros: */ /* Macros: */
/** HID Class specific request to get the next HID report from the device. */
#define REQ_GetReport 0x01
/** HID Class specific request to send the next HID report to the device. */
#define REQ_SetReport 0x09
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1 #define LEDMASK_USB_NOTREADY LEDS_LED1

View File

@ -140,12 +140,12 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.HID_JoystickHID = .HID_JoystickHID =
{ {
.Header = {.Size = sizeof(USB_Descriptor_HID_t), .Type = DTYPE_HID}, .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
.HIDSpec = VERSION_BCD(01.11), .HIDSpec = VERSION_BCD(01.11),
.CountryCode = 0x00, .CountryCode = 0x00,
.TotalReportDescriptors = 1, .TotalReportDescriptors = 1,
.HIDReportType = DTYPE_Report, .HIDReportType = HID_DTYPE_Report,
.HIDReportLength = sizeof(JoystickReport) .HIDReportLength = sizeof(JoystickReport)
}, },
@ -239,7 +239,7 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
break; break;
case DTYPE_HID: case DTYPE_HID:
Address = &ConfigurationDescriptor.HID_JoystickHID; Address = &ConfigurationDescriptor.HID_JoystickHID;
Size = sizeof(USB_Descriptor_HID_t); Size = sizeof(USB_HID_Descriptor_HID_t);
break; break;
case DTYPE_Report: case DTYPE_Report:
Address = &JoystickReport; Address = &JoystickReport;

View File

@ -42,25 +42,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
/* Type Defines: */ /* 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;
/** Type define for the device configuration descriptor structure. This must be defined in the /** Type define for the device configuration descriptor structure. This must be defined in the
* application code, as the configuration descriptor contains several sub-descriptors which * application code, as the configuration descriptor contains several sub-descriptors which
* vary between devices, and which describe the device's usage to the host. * vary between devices, and which describe the device's usage to the host.
@ -69,7 +50,7 @@
{ {
USB_Descriptor_Configuration_Header_t Config; USB_Descriptor_Configuration_Header_t Config;
USB_Descriptor_Interface_t HID_Interface; USB_Descriptor_Interface_t HID_Interface;
USB_Descriptor_HID_t HID_JoystickHID; USB_HID_Descriptor_HID_t HID_JoystickHID;
USB_Descriptor_Endpoint_t HID_ReportINEndpoint; USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
} USB_Descriptor_Configuration_t; } USB_Descriptor_Configuration_t;

View File

@ -112,7 +112,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
/* Handle HID Class specific requests */ /* Handle HID Class specific requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)
{ {
case REQ_GetReport: case HID_REQ_GetReport:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
USB_JoystickReport_Data_t JoystickReportData; USB_JoystickReport_Data_t JoystickReportData;

View File

@ -52,9 +52,6 @@
#include <LUFA/Drivers/Board/Buttons.h> #include <LUFA/Drivers/Board/Buttons.h>
/* Macros: */ /* Macros: */
/** HID Class specific request to get the next HID report from the device. */
#define REQ_GetReport 0x01
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1 #define LEDMASK_USB_NOTREADY LEDS_LED1

View File

@ -147,12 +147,12 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.HID_KeyboardHID = .HID_KeyboardHID =
{ {
.Header = {.Size = sizeof(USB_Descriptor_HID_t), .Type = DTYPE_HID}, .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
.HIDSpec = VERSION_BCD(01.11), .HIDSpec = VERSION_BCD(01.11),
.CountryCode = 0x00, .CountryCode = 0x00,
.TotalReportDescriptors = 1, .TotalReportDescriptors = 1,
.HIDReportType = DTYPE_Report, .HIDReportType = HID_DTYPE_Report,
.HIDReportLength = sizeof(KeyboardReport) .HIDReportLength = sizeof(KeyboardReport)
}, },
@ -254,11 +254,11 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
} }
break; break;
case DTYPE_HID: case HID_DTYPE_HID:
Address = &ConfigurationDescriptor.HID_KeyboardHID; Address = &ConfigurationDescriptor.HID_KeyboardHID;
Size = sizeof(USB_Descriptor_HID_t); Size = sizeof(USB_HID_Descriptor_HID_t);
break; break;
case DTYPE_Report: case HID_DTYPE_Report:
Address = &KeyboardReport; Address = &KeyboardReport;
Size = sizeof(KeyboardReport); Size = sizeof(KeyboardReport);
break; break;

View File

@ -43,25 +43,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
/* Type Defines: */ /* 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;
/** Type define for the device configuration descriptor structure. This must be defined in the /** Type define for the device configuration descriptor structure. This must be defined in the
* application code, as the configuration descriptor contains several sub-descriptors which * application code, as the configuration descriptor contains several sub-descriptors which
* vary between devices, and which describe the device's usage to the host. * vary between devices, and which describe the device's usage to the host.
@ -70,7 +51,7 @@
{ {
USB_Descriptor_Configuration_Header_t Config; USB_Descriptor_Configuration_Header_t Config;
USB_Descriptor_Interface_t HID_Interface; USB_Descriptor_Interface_t HID_Interface;
USB_Descriptor_HID_t HID_KeyboardHID; USB_HID_Descriptor_HID_t HID_KeyboardHID;
USB_Descriptor_Endpoint_t HID_ReportINEndpoint; USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
USB_Descriptor_Endpoint_t HID_ReportOUTEndpoint; USB_Descriptor_Endpoint_t HID_ReportOUTEndpoint;
} USB_Descriptor_Configuration_t; } USB_Descriptor_Configuration_t;
@ -85,12 +66,6 @@
/** Size in bytes of the Keyboard HID reporting IN and OUT endpoints. */ /** Size in bytes of the Keyboard HID reporting IN and OUT endpoints. */
#define KEYBOARD_EPSIZE 8 #define KEYBOARD_EPSIZE 8
/** 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
/* Function Prototypes: */ /* Function Prototypes: */
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex, const uint8_t wIndex,

View File

@ -138,7 +138,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
/* Handle HID Class specific requests */ /* Handle HID Class specific requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)
{ {
case REQ_GetReport: case HID_REQ_GetReport:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
USB_KeyboardReport_Data_t KeyboardReportData; USB_KeyboardReport_Data_t KeyboardReportData;
@ -154,7 +154,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
} }
break; break;
case REQ_SetReport: case HID_REQ_SetReport:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
@ -177,7 +177,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
} }
break; break;
case REQ_GetProtocol: case HID_REQ_GetProtocol:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
@ -190,7 +190,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
} }
break; break;
case REQ_SetProtocol: case HID_REQ_SetProtocol:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
@ -201,7 +201,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
} }
break; break;
case REQ_SetIdle: case HID_REQ_SetIdle:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
@ -212,7 +212,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
} }
break; break;
case REQ_GetIdle: case HID_REQ_GetIdle:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
@ -251,7 +251,7 @@ void CreateKeyboardReport(USB_KeyboardReport_Data_t* const ReportData)
memset(ReportData, 0, sizeof(USB_KeyboardReport_Data_t)); memset(ReportData, 0, sizeof(USB_KeyboardReport_Data_t));
/* Make sent key uppercase by indicating that the left shift key is pressed */ /* Make sent key uppercase by indicating that the left shift key is pressed */
ReportData->Modifier = KEYBOARD_MODIFER_LEFTSHIFT; ReportData->Modifier = HID_KEYBOARD_MODIFER_LEFTSHIFT;
if (JoyStatus_LCL & JOY_UP) if (JoyStatus_LCL & JOY_UP)
ReportData->KeyCode[UsedKeyCodes++] = 0x04; // A ReportData->KeyCode[UsedKeyCodes++] = 0x04; // A
@ -278,13 +278,13 @@ void ProcessLEDReport(const uint8_t LEDReport)
{ {
uint8_t LEDMask = LEDS_LED2; uint8_t LEDMask = LEDS_LED2;
if (LEDReport & KEYBOARD_LED_NUMLOCK) if (LEDReport & HID_KEYBOARD_LED_NUMLOCK)
LEDMask |= LEDS_LED1; LEDMask |= LEDS_LED1;
if (LEDReport & KEYBOARD_LED_CAPSLOCK) if (LEDReport & HID_KEYBOARD_LED_CAPSLOCK)
LEDMask |= LEDS_LED3; LEDMask |= LEDS_LED3;
if (LEDReport & KEYBOARD_LED_SCROLLLOCK) if (LEDReport & HID_KEYBOARD_LED_SCROLLLOCK)
LEDMask |= LEDS_LED4; LEDMask |= LEDS_LED4;
/* Set the status LEDs to the current Keyboard LED status */ /* Set the status LEDs to the current Keyboard LED status */
@ -305,7 +305,7 @@ void SendNextReport(void)
SendReport = (memcmp(&PrevKeyboardReportData, &KeyboardReportData, sizeof(USB_KeyboardReport_Data_t)) != 0); SendReport = (memcmp(&PrevKeyboardReportData, &KeyboardReportData, sizeof(USB_KeyboardReport_Data_t)) != 0);
/* Check if the idle period is set and has elapsed */ /* Check if the idle period is set and has elapsed */
if ((IdleCount != HID_IDLE_CHANGESONLY) && (!(IdleMSRemaining))) if (IdleCount && (!(IdleMSRemaining)))
{ {
/* Reset the idle time remaining counter */ /* Reset the idle time remaining counter */
IdleMSRemaining = IdleCount; IdleMSRemaining = IdleCount;

View File

@ -54,63 +54,6 @@
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
/* Macros: */ /* Macros: */
/** Idle period indicating that reports should be sent only when the inputs have changed. */
#define HID_IDLE_CHANGESONLY 0
/** HID Class specific request to get the next HID report from the device. */
#define REQ_GetReport 0x01
/** HID Class specific request to get the idle timeout period of the device. */
#define REQ_GetIdle 0x02
/** HID Class specific request to send the next HID report to the device. */
#define REQ_SetReport 0x09
/** HID Class specific request to set the idle timeout period of the device. */
#define REQ_SetIdle 0x0A
/** HID Class specific request to get the current HID protocol in use, either report or boot. */
#define REQ_GetProtocol 0x03
/** HID Class specific request to set the current HID protocol in use, either report or boot. */
#define REQ_SetProtocol 0x0B
/** Constant for a keyboard report modifier byte, indicating that the keyboard's left control key is currently pressed. */
#define KEYBOARD_MODIFER_LEFTCTRL (1 << 0)
/** Constant for a keyboard report modifier byte, indicating that the keyboard's left shift key is currently pressed. */
#define KEYBOARD_MODIFER_LEFTSHIFT (1 << 1)
/** Constant for a keyboard report modifier byte, indicating that the keyboard's left alt key is currently pressed. */
#define KEYBOARD_MODIFER_LEFTALT (1 << 2)
/** Constant for a keyboard report modifier byte, indicating that the keyboard's left GUI key is currently pressed. */
#define KEYBOARD_MODIFER_LEFTGUI (1 << 3)
/** Constant for a keyboard report modifier byte, indicating that the keyboard's right control key is currently pressed. */
#define KEYBOARD_MODIFER_RIGHTCTRL (1 << 4)
/** Constant for a keyboard report modifier byte, indicating that the keyboard's right shift key is currently pressed. */
#define KEYBOARD_MODIFER_RIGHTSHIFT (1 << 5)
/** Constant for a keyboard report modifier byte, indicating that the keyboard's right alt key is currently pressed. */
#define KEYBOARD_MODIFER_RIGHTALT (1 << 6)
/** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */
#define KEYBOARD_MODIFER_RIGHTGUI (1 << 7)
/** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */
#define KEYBOARD_LED_NUMLOCK (1 << 0)
/** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */
#define KEYBOARD_LED_CAPSLOCK (1 << 1)
/** Constant for a keyboard output report LED byte, indicating that the host's SCROLL LOCK mode is currently set. */
#define KEYBOARD_LED_SCROLLLOCK (1 << 2)
/** Constant for a keyboard output report LED byte, indicating that the host's KATANA mode is currently set. */
#define KEYBOARD_LED_KATANA (1 << 3)
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1 #define LEDMASK_USB_NOTREADY LEDS_LED1
@ -123,17 +66,6 @@
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
/* Type Defines: */
/** Type define for the keyboard HID report structure, for creating and sending HID reports to the host PC.
* This mirrors the layout described to the host in the HID report descriptor, in Descriptors.c.
*/
typedef struct
{
uint8_t Modifier; /**< Modifier mask byte, containing a mask of modifier keys set (such as shift or CTRL) */
uint8_t Reserved; /**< Reserved, always set as 0x00 */
uint8_t KeyCode[6]; /**< Array of up to six simultaneous key codes of pressed keys */
} USB_KeyboardReport_Data_t;
/* Function Prototypes: */ /* Function Prototypes: */
void SetupHardware(void); void SetupHardware(void);
void HID_Task(void); void HID_Task(void);

View File

@ -180,12 +180,12 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.HID1_KeyboardHID = .HID1_KeyboardHID =
{ {
.Header = {.Size = sizeof(USB_Descriptor_HID_t), .Type = DTYPE_HID}, .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
.HIDSpec = VERSION_BCD(01.11), .HIDSpec = VERSION_BCD(01.11),
.CountryCode = 0x00, .CountryCode = 0x00,
.TotalReportDescriptors = 1, .TotalReportDescriptors = 1,
.HIDReportType = DTYPE_Report, .HIDReportType = HID_DTYPE_Report,
.HIDReportLength = sizeof(KeyboardReport) .HIDReportLength = sizeof(KeyboardReport)
}, },
@ -227,12 +227,12 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.HID2_MouseHID = .HID2_MouseHID =
{ {
.Header = {.Size = sizeof(USB_Descriptor_HID_t), .Type = DTYPE_HID}, .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
.HIDSpec = VERSION_BCD(01.11), .HIDSpec = VERSION_BCD(01.11),
.CountryCode = 0x00, .CountryCode = 0x00,
.TotalReportDescriptors = 1, .TotalReportDescriptors = 1,
.HIDReportType = DTYPE_Report, .HIDReportType = HID_DTYPE_Report,
.HIDReportLength = sizeof(MouseReport) .HIDReportLength = sizeof(MouseReport)
}, },
@ -324,19 +324,19 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
} }
break; break;
case DTYPE_HID: case HID_DTYPE_HID:
if (!(wIndex)) if (!(wIndex))
{ {
Address = &ConfigurationDescriptor.HID1_KeyboardHID; Address = &ConfigurationDescriptor.HID1_KeyboardHID;
Size = sizeof(USB_Descriptor_HID_t); Size = sizeof(USB_HID_Descriptor_HID_t);
} }
else else
{ {
Address = &ConfigurationDescriptor.HID2_MouseHID; Address = &ConfigurationDescriptor.HID2_MouseHID;
Size = sizeof(USB_Descriptor_HID_t); Size = sizeof(USB_HID_Descriptor_HID_t);
} }
break; break;
case DTYPE_Report: case HID_DTYPE_Report:
if (!(wIndex)) if (!(wIndex))
{ {
Address = &KeyboardReport; Address = &KeyboardReport;

View File

@ -43,25 +43,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
/* Type Defines: */ /* 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;
/** Type define for the device configuration descriptor structure. This must be defined in the /** Type define for the device configuration descriptor structure. This must be defined in the
* application code, as the configuration descriptor contains several sub-descriptors which * application code, as the configuration descriptor contains several sub-descriptors which
* vary between devices, and which describe the device's usage to the host. * vary between devices, and which describe the device's usage to the host.
@ -70,11 +51,11 @@
{ {
USB_Descriptor_Configuration_Header_t Config; USB_Descriptor_Configuration_Header_t Config;
USB_Descriptor_Interface_t HID1_KeyboardInterface; USB_Descriptor_Interface_t HID1_KeyboardInterface;
USB_Descriptor_HID_t HID1_KeyboardHID; USB_HID_Descriptor_HID_t HID1_KeyboardHID;
USB_Descriptor_Endpoint_t HID1_ReportINEndpoint; USB_Descriptor_Endpoint_t HID1_ReportINEndpoint;
USB_Descriptor_Endpoint_t HID1_ReportOUTEndpoint; USB_Descriptor_Endpoint_t HID1_ReportOUTEndpoint;
USB_Descriptor_Interface_t HID2_MouseInterface; USB_Descriptor_Interface_t HID2_MouseInterface;
USB_Descriptor_HID_t HID2_MouseHID; USB_HID_Descriptor_HID_t HID2_MouseHID;
USB_Descriptor_Endpoint_t HID2_ReportINEndpoint; USB_Descriptor_Endpoint_t HID2_ReportINEndpoint;
} USB_Descriptor_Configuration_t; } USB_Descriptor_Configuration_t;
@ -91,12 +72,6 @@
/** Size in bytes of each of the HID reporting IN and OUT endpoints. */ /** Size in bytes of each of the HID reporting IN and OUT endpoints. */
#define HID_EPSIZE 8 #define HID_EPSIZE 8
/** 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
/* Function Prototypes: */ /* Function Prototypes: */
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex, const uint8_t wIndex,

View File

@ -129,7 +129,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
/* Handle HID Class specific requests */ /* Handle HID Class specific requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)
{ {
case REQ_GetReport: case HID_REQ_GetReport:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
@ -155,7 +155,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
} }
break; break;
case REQ_SetReport: case HID_REQ_SetReport:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
@ -190,13 +190,13 @@ void Keyboard_ProcessLEDReport(const uint8_t LEDStatus)
{ {
uint8_t LEDMask = LEDS_LED2; uint8_t LEDMask = LEDS_LED2;
if (LEDStatus & KEYBOARD_LED_NUMLOCK) if (LEDStatus & HID_KEYBOARD_LED_NUMLOCK)
LEDMask |= LEDS_LED1; LEDMask |= LEDS_LED1;
if (LEDStatus & KEYBOARD_LED_CAPSLOCK) if (LEDStatus & HID_KEYBOARD_LED_CAPSLOCK)
LEDMask |= LEDS_LED3; LEDMask |= LEDS_LED3;
if (LEDStatus & KEYBOARD_LED_SCROLLLOCK) if (LEDStatus & HID_KEYBOARD_LED_SCROLLLOCK)
LEDMask |= LEDS_LED4; LEDMask |= LEDS_LED4;
/* Set the status LEDs to the current Keyboard LED status */ /* Set the status LEDs to the current Keyboard LED status */
@ -219,7 +219,7 @@ void Keyboard_HID_Task(void)
if (!(Buttons_GetStatus() & BUTTONS_BUTTON1)) if (!(Buttons_GetStatus() & BUTTONS_BUTTON1))
{ {
/* Make sent key uppercase by indicating that the left shift key is pressed */ /* Make sent key uppercase by indicating that the left shift key is pressed */
KeyboardReportData.Modifier = KEYBOARD_MODIFER_LEFTSHIFT; KeyboardReportData.Modifier = HID_KEYBOARD_MODIFER_LEFTSHIFT;
if (JoyStatus_LCL & JOY_UP) if (JoyStatus_LCL & JOY_UP)
KeyboardReportData.KeyCode[0] = 0x04; // A KeyboardReportData.KeyCode[0] = 0x04; // A

View File

@ -49,54 +49,6 @@
#include <LUFA/Drivers/Board/Buttons.h> #include <LUFA/Drivers/Board/Buttons.h>
/* Macros: */ /* Macros: */
/** HID Class specific request to get the next HID report from the device. */
#define REQ_GetReport 0x01
/** HID Class specific request to send the next HID report to the device. */
#define REQ_SetReport 0x09
/** HID Class specific request to get the current HID protocol in use, either report or boot. */
#define REQ_GetProtocol 0x03
/** HID Class specific request to set the current HID protocol in use, either report or boot. */
#define REQ_SetProtocol 0x0B
/** Constant for a keyboard report modifier byte, indicating that the keyboard's left control key is currently pressed. */
#define KEYBOARD_MODIFER_LEFTCTRL (1 << 0)
/** Constant for a keyboard report modifier byte, indicating that the keyboard's left shift key is currently pressed. */
#define KEYBOARD_MODIFER_LEFTSHIFT (1 << 1)
/** Constant for a keyboard report modifier byte, indicating that the keyboard's left alt key is currently pressed. */
#define KEYBOARD_MODIFER_LEFTALT (1 << 2)
/** Constant for a keyboard report modifier byte, indicating that the keyboard's left GUI key is currently pressed. */
#define KEYBOARD_MODIFER_LEFTGUI (1 << 3)
/** Constant for a keyboard report modifier byte, indicating that the keyboard's right control key is currently pressed. */
#define KEYBOARD_MODIFER_RIGHTCTRL (1 << 4)
/** Constant for a keyboard report modifier byte, indicating that the keyboard's right shift key is currently pressed. */
#define KEYBOARD_MODIFER_RIGHTSHIFT (1 << 5)
/** Constant for a keyboard report modifier byte, indicating that the keyboard's right alt key is currently pressed. */
#define KEYBOARD_MODIFER_RIGHTALT (1 << 6)
/** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */
#define KEYBOARD_MODIFER_RIGHTGUI (1 << 7)
/** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */
#define KEYBOARD_LED_NUMLOCK (1 << 0)
/** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */
#define KEYBOARD_LED_CAPSLOCK (1 << 1)
/** Constant for a keyboard output report LED byte, indicating that the host's SCROLL LOCK mode is currently set. */
#define KEYBOARD_LED_SCROLLLOCK (1 << 2)
/** Constant for a keyboard output report LED byte, indicating that the host's KATANA mode is currently set. */
#define KEYBOARD_LED_KATANA (1 << 3)
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1 #define LEDMASK_USB_NOTREADY LEDS_LED1
@ -109,27 +61,6 @@
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
/* Type Defines: */
/** Type define for the keyboard HID report structure, for creating and sending HID reports to the host PC.
* This mirrors the layout described to the host in the HID report descriptor, in Descriptors.c.
*/
typedef struct
{
uint8_t Modifier; /**< Modifier mask byte, containing a mask of modifier keys set (such as shift or CTRL) */
uint8_t Reserved; /**< Reserved, always set as 0x00 */
uint8_t KeyCode[6]; /**< Array of up to six simultaneous key codes of pressed keys */
} USB_KeyboardReport_Data_t;
/** Type define for the mouse HID report structure, for creating and sending HID reports to the host PC.
* This mirrors the layout described to the host in the HID report descriptor, in Descriptors.c.
*/
typedef struct
{
uint8_t Button; /**< Bit mask of the currently pressed mouse buttons */
int8_t X; /**< Current mouse delta X movement, as a signed 8-bit integer */
int8_t Y; /**< Current mouse delta Y movement, as a signed 8-bit integer */
} USB_MouseReport_Data_t;
/* Function Prototypes: */ /* Function Prototypes: */
void SetupHardware(void); void SetupHardware(void);
void Keyboard_ProcessLEDReport(const uint8_t LEDStatus); void Keyboard_ProcessLEDReport(const uint8_t LEDStatus);

View File

@ -104,14 +104,14 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.Audio_ControlInterface_SPC = .Audio_ControlInterface_SPC =
{ {
.Header = {.Size = sizeof(USB_Audio_Interface_AC_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_AudioHeader, .Subtype = AUDIO_DSUBTYPE_CSInterface_Header,
.AudioSpecification = VERSION_BCD(01.00), .ACSpecification = VERSION_BCD(01.00),
.TotalLength = sizeof(USB_Audio_Interface_AC_t), .TotalLength = sizeof(USB_Audio_Descriptor_Interface_AC_t),
.InCollection = 1, .InCollection = 1,
.InterfaceNumbers = {1}, .InterfaceNumber = 1,
}, },
.Audio_StreamInterface = .Audio_StreamInterface =
@ -132,8 +132,8 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.Audio_StreamInterface_SPC = .Audio_StreamInterface_SPC =
{ {
.Header = {.Size = sizeof(USB_Audio_Interface_MIDI_AS_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_MIDI_Descriptor_AudioInterface_AS_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_General, .Subtype = AUDIO_DSUBTYPE_CSInterface_General,
.AudioSpecification = VERSION_BCD(01.00), .AudioSpecification = VERSION_BCD(01.00),
@ -143,10 +143,10 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.MIDI_In_Jack_Emb = .MIDI_In_Jack_Emb =
{ {
.Header = {.Size = sizeof(USB_MIDI_In_Jack_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_MIDI_Descriptor_InputJack_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_InputJack, .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
.JackType = JACKTYPE_EMBEDDED, .JackType = MIDI_JACKTYPE_Embedded,
.JackID = 0x01, .JackID = 0x01,
.JackStrIndex = NO_DESCRIPTOR .JackStrIndex = NO_DESCRIPTOR
@ -154,10 +154,10 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.MIDI_In_Jack_Ext = .MIDI_In_Jack_Ext =
{ {
.Header = {.Size = sizeof(USB_MIDI_In_Jack_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_MIDI_Descriptor_InputJack_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_InputJack, .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
.JackType = JACKTYPE_EXTERNAL, .JackType = MIDI_JACKTYPE_External,
.JackID = 0x02, .JackID = 0x02,
.JackStrIndex = NO_DESCRIPTOR .JackStrIndex = NO_DESCRIPTOR
@ -165,10 +165,10 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.MIDI_Out_Jack_Emb = .MIDI_Out_Jack_Emb =
{ {
.Header = {.Size = sizeof(USB_MIDI_Out_Jack_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_MIDI_Descriptor_OutputJack_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_OutputJack, .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
.JackType = JACKTYPE_EMBEDDED, .JackType = MIDI_JACKTYPE_Embedded,
.JackID = 0x03, .JackID = 0x03,
.NumberOfPins = 1, .NumberOfPins = 1,
@ -180,10 +180,10 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.MIDI_Out_Jack_Ext = .MIDI_Out_Jack_Ext =
{ {
.Header = {.Size = sizeof(USB_MIDI_Out_Jack_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_MIDI_Descriptor_OutputJack_t), .Type = DTYPE_CSInterface},
.Subtype = DSUBTYPE_OutputJack, .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
.JackType = JACKTYPE_EXTERNAL, .JackType = MIDI_JACKTYPE_External,
.JackID = 0x04, .JackID = 0x04,
.NumberOfPins = 1, .NumberOfPins = 1,
@ -197,7 +197,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
{ {
.Endpoint = .Endpoint =
{ {
.Header = {.Size = sizeof(USB_Audio_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint}, .Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | MIDI_STREAM_OUT_EPNUM), .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | MIDI_STREAM_OUT_EPNUM),
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
@ -211,8 +211,8 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.MIDI_In_Jack_Endpoint_SPC = .MIDI_In_Jack_Endpoint_SPC =
{ {
.Header = {.Size = sizeof(USB_MIDI_Jack_Endpoint_t), .Type = DTYPE_CSEndpoint}, .Header = {.Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t), .Type = DTYPE_CSEndpoint},
.Subtype = DSUBTYPE_General, .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
.TotalEmbeddedJacks = 0x01, .TotalEmbeddedJacks = 0x01,
.AssociatedJackID = {0x01} .AssociatedJackID = {0x01}
@ -222,7 +222,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
{ {
.Endpoint = .Endpoint =
{ {
.Header = {.Size = sizeof(USB_Audio_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint}, .Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | MIDI_STREAM_IN_EPNUM), .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | MIDI_STREAM_IN_EPNUM),
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
@ -236,8 +236,8 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.MIDI_Out_Jack_Endpoint_SPC = .MIDI_Out_Jack_Endpoint_SPC =
{ {
.Header = {.Size = sizeof(USB_MIDI_Jack_Endpoint_t), .Type = DTYPE_CSEndpoint}, .Header = {.Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t), .Type = DTYPE_CSEndpoint},
.Subtype = DSUBTYPE_General, .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
.TotalEmbeddedJacks = 0x01, .TotalEmbeddedJacks = 0x01,
.AssociatedJackID = {0x03} .AssociatedJackID = {0x03}

View File

@ -42,24 +42,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
/* Macros: */ /* Macros: */
/** Audio class descriptor subtype value for a Audio class specific header descriptor. */
#define DSUBTYPE_AudioHeader 0x01
/** 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 subtype value for a general Audio class specific descriptor. */
#define DSUBTYPE_General 0x01
/** Audio class descriptor jack type value for an embedded (logical) MIDI input or output jack. */
#define JACKTYPE_EMBEDDED 0x01
/** Audio class descriptor jack type value for an external (physical) MIDI input or output jack. */
#define JACKTYPE_EXTERNAL 0x02
/** Endpoint number of the MIDI streaming data IN endpoint, for device-to-host data transfers. */ /** Endpoint number of the MIDI streaming data IN endpoint, for device-to-host data transfers. */
#define MIDI_STREAM_IN_EPNUM 1 #define MIDI_STREAM_IN_EPNUM 1
@ -70,110 +52,25 @@
#define MIDI_STREAM_EPSIZE 64 #define MIDI_STREAM_EPSIZE 64
/* Type Defines: */ /* 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 AudioSpecification; /**< Binary coded decimal value, indicating the supported Audio Class specification version */
uint16_t TotalLength; /**< Total length of the Audio class specific control 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_Audio_Interface_AC_t;
/** 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_Audio_Interface_MIDI_AS_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 synchronization information to, if needed (zero otherwise) */
} USB_Audio_StreamEndpoint_Std_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 the device configuration descriptor structure. This must be defined in the /** Type define for the device configuration descriptor structure. This must be defined in the
* application code, as the configuration descriptor contains several sub-descriptors which * application code, as the configuration descriptor contains several sub-descriptors which
* vary between devices, and which describe the device's usage to the host. * vary between devices, and which describe the device's usage to the host.
*/ */
typedef struct typedef struct
{ {
USB_Descriptor_Configuration_Header_t Config; USB_Descriptor_Configuration_Header_t Config;
USB_Descriptor_Interface_t Audio_ControlInterface; USB_Descriptor_Interface_t Audio_ControlInterface;
USB_Audio_Interface_AC_t Audio_ControlInterface_SPC; USB_Audio_Descriptor_Interface_AC_t Audio_ControlInterface_SPC;
USB_Descriptor_Interface_t Audio_StreamInterface; USB_Descriptor_Interface_t Audio_StreamInterface;
USB_Audio_Interface_MIDI_AS_t Audio_StreamInterface_SPC; USB_MIDI_Descriptor_AudioInterface_AS_t Audio_StreamInterface_SPC;
USB_MIDI_In_Jack_t MIDI_In_Jack_Emb; USB_MIDI_Descriptor_InputJack_t MIDI_In_Jack_Emb;
USB_MIDI_In_Jack_t MIDI_In_Jack_Ext; USB_MIDI_Descriptor_InputJack_t MIDI_In_Jack_Ext;
USB_MIDI_Out_Jack_t MIDI_Out_Jack_Emb; USB_MIDI_Descriptor_OutputJack_t MIDI_Out_Jack_Emb;
USB_MIDI_Out_Jack_t MIDI_Out_Jack_Ext; USB_MIDI_Descriptor_OutputJack_t MIDI_Out_Jack_Ext;
USB_Audio_StreamEndpoint_Std_t MIDI_In_Jack_Endpoint; USB_Audio_Descriptor_StreamEndpoint_Std_t MIDI_In_Jack_Endpoint;
USB_MIDI_Jack_Endpoint_t MIDI_In_Jack_Endpoint_SPC; USB_MIDI_Descriptor_Jack_Endpoint_t MIDI_In_Jack_Endpoint_SPC;
USB_Audio_StreamEndpoint_Std_t MIDI_Out_Jack_Endpoint; USB_Audio_Descriptor_StreamEndpoint_Std_t MIDI_Out_Jack_Endpoint;
USB_MIDI_Jack_Endpoint_t MIDI_Out_Jack_Endpoint_SPC; USB_MIDI_Descriptor_Jack_Endpoint_t MIDI_Out_Jack_Endpoint_SPC;
} USB_Descriptor_Configuration_t; } USB_Descriptor_Configuration_t;
/* Function Prototypes: */ /* Function Prototypes: */

View File

@ -160,7 +160,7 @@ void MIDI_Task(void)
/* Check if a MIDI command is to be sent */ /* Check if a MIDI command is to be sent */
if (MIDICommand) if (MIDICommand)
{ {
USB_MIDI_EventPacket_t MIDIEvent = (USB_MIDI_EventPacket_t) MIDI_EventPacket_t MIDIEvent = (MIDI_EventPacket_t)
{ {
.CableNumber = 0, .CableNumber = 0,
.Command = (MIDICommand >> 4), .Command = (MIDICommand >> 4),
@ -187,7 +187,7 @@ void MIDI_Task(void)
/* Check if a MIDI command has been received */ /* Check if a MIDI command has been received */
if (Endpoint_IsOUTReceived()) if (Endpoint_IsOUTReceived())
{ {
USB_MIDI_EventPacket_t MIDIEvent; MIDI_EventPacket_t MIDIEvent;
/* Read the MIDI event packet from the endpoint */ /* Read the MIDI event packet from the endpoint */
Endpoint_Read_Stream_LE(&MIDIEvent, sizeof(MIDIEvent)); Endpoint_Read_Stream_LE(&MIDIEvent, sizeof(MIDIEvent));

View File

@ -52,22 +52,6 @@
#include <LUFA/Drivers/Board/Buttons.h> #include <LUFA/Drivers/Board/Buttons.h>
/* Macros: */ /* Macros: */
/** MIDI command for a note on (activation) event. */
#define MIDI_COMMAND_NOTE_ON 0x90
/** MIDI command for a note off (deactivation) event. */
#define MIDI_COMMAND_NOTE_OFF 0x80
/** Standard key press velocity value used for all note events, as no pressure sensor is mounted. */
#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[in] channel MIDI channel number to address
*/
#define MIDI_CHANNEL(channel) ((channel) - 1)
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1 #define LEDMASK_USB_NOTREADY LEDS_LED1
@ -80,18 +64,6 @@
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
/* Type Defines: */
/** 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;
/* Function Prototypes: */ /* Function Prototypes: */
void SetupHardware(void); void SetupHardware(void);
void MIDI_Task(void); void MIDI_Task(void);

View File

@ -47,7 +47,6 @@
#include "MassStorage.h" #include "MassStorage.h"
#include "Descriptors.h" #include "Descriptors.h"
#include "DataflashManager.h" #include "DataflashManager.h"
#include "SCSI_Codes.h"
/* Macros: */ /* Macros: */
/** Macro to set the current SCSI sense data to the given key, additional sense code and additional sense qualifier. This /** Macro to set the current SCSI sense data to the given key, additional sense code and additional sense qualifier. This
@ -109,7 +108,7 @@
uint8_t VendorID[8]; uint8_t VendorID[8];
uint8_t ProductID[16]; uint8_t ProductID[16];
uint8_t RevisionID[4]; uint8_t RevisionID[4];
} SCSI_Inquiry_Response_t; } MS_SCSI_Inquiry_Response_t;
/** Type define for a SCSI sense structure to a SCSI REQUEST SENSE command. For details of the /** Type define for a SCSI sense structure to a SCSI REQUEST SENSE command. For details of the
* structure contents, refer to the SCSI specifications. * structure contents, refer to the SCSI specifications.
@ -133,7 +132,7 @@
uint8_t AdditionalSenseQualifier; uint8_t AdditionalSenseQualifier;
uint8_t FieldReplaceableUnitCode; uint8_t FieldReplaceableUnitCode;
uint8_t SenseKeySpecific[3]; uint8_t SenseKeySpecific[3];
} SCSI_Request_Sense_Response_t; } MS_SCSI_Request_Sense_Response_t;
/* Function Prototypes: */ /* Function Prototypes: */
bool SCSI_DecodeSCSICommand(void); bool SCSI_DecodeSCSICommand(void);

View File

@ -1,87 +0,0 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, 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.
*/
/** \file
*
* Header containing macros for possible SCSI commands and SENSE data. Refer to
* the SCSI standard documentation for more information on each SCSI command and
* the SENSE data.
*/
#ifndef _SCSI_CODES_H_
#define _SCSI_CODES_H_
/* Macros: */
#define SCSI_CMD_INQUIRY 0x12
#define SCSI_CMD_REQUEST_SENSE 0x03
#define SCSI_CMD_TEST_UNIT_READY 0x00
#define SCSI_CMD_READ_CAPACITY_10 0x25
#define SCSI_CMD_SEND_DIAGNOSTIC 0x1D
#define SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1E
#define SCSI_CMD_WRITE_10 0x2A
#define SCSI_CMD_READ_10 0x28
#define SCSI_CMD_WRITE_6 0x0A
#define SCSI_CMD_READ_6 0x08
#define SCSI_CMD_VERIFY_10 0x2F
#define SCSI_CMD_MODE_SENSE_6 0x1A
#define SCSI_CMD_MODE_SENSE_10 0x5A
#define SCSI_SENSE_KEY_GOOD 0x00
#define SCSI_SENSE_KEY_RECOVERED_ERROR 0x01
#define SCSI_SENSE_KEY_NOT_READY 0x02
#define SCSI_SENSE_KEY_MEDIUM_ERROR 0x03
#define SCSI_SENSE_KEY_HARDWARE_ERROR 0x04
#define SCSI_SENSE_KEY_ILLEGAL_REQUEST 0x05
#define SCSI_SENSE_KEY_UNIT_ATTENTION 0x06
#define SCSI_SENSE_KEY_DATA_PROTECT 0x07
#define SCSI_SENSE_KEY_BLANK_CHECK 0x08
#define SCSI_SENSE_KEY_VENDOR_SPECIFIC 0x09
#define SCSI_SENSE_KEY_COPY_ABORTED 0x0A
#define SCSI_SENSE_KEY_ABORTED_COMMAND 0x0B
#define SCSI_SENSE_KEY_VOLUME_OVERFLOW 0x0D
#define SCSI_SENSE_KEY_MISCOMPARE 0x0E
#define SCSI_ASENSE_NO_ADDITIONAL_INFORMATION 0x00
#define SCSI_ASENSE_LOGICAL_UNIT_NOT_READY 0x04
#define SCSI_ASENSE_INVALID_COMMAND 0x20
#define SCSI_ASENSE_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE 0x21
#define SCSI_ASENSE_INVALID_FIELD_IN_CDB 0x24
#define SCSI_ASENSE_WRITE_PROTECTED 0x27
#define SCSI_ASENSE_NOT_READY_TO_READY_CHANGE 0x28
#define SCSI_ASENSE_FORMAT_ERROR 0x31
#define SCSI_ASENSE_MEDIUM_NOT_PRESENT 0x3A
#define SCSI_ASENSEQ_NO_QUALIFIER 0x00
#define SCSI_ASENSEQ_FORMAT_COMMAND_FAILED 0x01
#define SCSI_ASENSEQ_INITIALIZING_COMMAND_REQUIRED 0x02
#define SCSI_ASENSEQ_OPERATION_IN_PROGRESS 0x07
#endif

View File

@ -38,13 +38,13 @@
#include "MassStorage.h" #include "MassStorage.h"
/** Structure to hold the latest Command Block Wrapper issued by the host, containing a SCSI command to execute. */ /** Structure to hold the latest Command Block Wrapper issued by the host, containing a SCSI command to execute. */
CommandBlockWrapper_t CommandBlock; MS_CommandBlockWrapper_t CommandBlock;
/** Structure to hold the latest Command Status Wrapper to return to the host, containing the status of the last issued command. */ /** Structure to hold the latest Command Status Wrapper to return to the host, containing the status of the last issued command. */
CommandStatusWrapper_t CommandStatus = { .Signature = CSW_SIGNATURE }; MS_CommandStatusWrapper_t CommandStatus = { .Signature = MS_CSW_SIGNATURE };
/** Flag to asynchronously abort any in-progress data transfers upon the reception of a mass storage reset command. */ /** Flag to asynchronously abort any in-progress data transfers upon the reception of a mass storage reset command. */
volatile bool IsMassStoreReset = false; volatile bool IsMassStoreReset = false;
/** Main program entry point. This routine configures the hardware required by the application, then /** Main program entry point. This routine configures the hardware required by the application, then
@ -129,7 +129,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
/* Process UFI specific control requests */ /* Process UFI specific control requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)
{ {
case REQ_MassStorageReset: case MS_REQ_MassStorageReset:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
@ -140,7 +140,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
} }
break; break;
case REQ_GetMaxLUN: case MS_REQ_GetMaxLUN:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
@ -172,11 +172,11 @@ void MassStorage_Task(void)
LEDs_SetAllLEDs(LEDMASK_USB_BUSY); LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
/* Check direction of command, select Data IN endpoint if data is from the device */ /* Check direction of command, select Data IN endpoint if data is from the device */
if (CommandBlock.Flags & COMMAND_DIRECTION_DATA_IN) if (CommandBlock.Flags & MS_COMMAND_DIR_DATA_IN)
Endpoint_SelectEndpoint(MASS_STORAGE_IN_EPNUM); Endpoint_SelectEndpoint(MASS_STORAGE_IN_EPNUM);
/* Decode the received SCSI command, set returned status code */ /* Decode the received SCSI command, set returned status code */
CommandStatus.Status = SCSI_DecodeSCSICommand() ? Command_Pass : Command_Fail; CommandStatus.Status = SCSI_DecodeSCSICommand() ? MS_SCSI_COMMAND_Pass : MS_SCSI_COMMAND_Fail;
/* Load in the CBW tag into the CSW to link them together */ /* Load in the CBW tag into the CSW to link them together */
CommandStatus.Tag = CommandBlock.Tag; CommandStatus.Tag = CommandBlock.Tag;
@ -185,7 +185,7 @@ void MassStorage_Task(void)
CommandStatus.DataTransferResidue = CommandBlock.DataTransferLength; CommandStatus.DataTransferResidue = CommandBlock.DataTransferLength;
/* Stall the selected data pipe if command failed (if data is still to be transferred) */ /* Stall the selected data pipe if command failed (if data is still to be transferred) */
if ((CommandStatus.Status == Command_Fail) && (CommandStatus.DataTransferResidue)) if ((CommandStatus.Status == MS_SCSI_COMMAND_Fail) && (CommandStatus.DataTransferResidue))
Endpoint_StallTransaction(); Endpoint_StallTransaction();
/* Return command status block to the host */ /* Return command status block to the host */
@ -237,11 +237,11 @@ static bool ReadInCommandBlock(void)
return false; return false;
/* Verify the command block - abort if invalid */ /* Verify the command block - abort if invalid */
if ((CommandBlock.Signature != CBW_SIGNATURE) || if ((CommandBlock.Signature != MS_CBW_SIGNATURE) ||
(CommandBlock.LUN >= TOTAL_LUNS) || (CommandBlock.LUN >= TOTAL_LUNS) ||
(CommandBlock.Flags & 0x1F) || (CommandBlock.Flags & 0x1F) ||
(CommandBlock.SCSICommandLength == 0) || (CommandBlock.SCSICommandLength == 0) ||
(CommandBlock.SCSICommandLength > MAX_SCSI_COMMAND_LENGTH)) (CommandBlock.SCSICommandLength > sizeof(CommandBlock.SCSICommandData)))
{ {
/* Stall both data pipes until reset by host */ /* Stall both data pipes until reset by host */
Endpoint_StallTransaction(); Endpoint_StallTransaction();

View File

@ -53,27 +53,6 @@
#include <LUFA/Drivers/Board/Dataflash.h> #include <LUFA/Drivers/Board/Dataflash.h>
/* Macros: */ /* 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
/** Maximum length of a SCSI command which can be issued by the device or host in a Mass Storage bulk wrapper. */
#define MAX_SCSI_COMMAND_LENGTH 16
/** Magic signature for a Command Block Wrapper used in the Mass Storage Bulk-Only transport protocol. */
#define CBW_SIGNATURE 0x43425355UL
/** Magic signature for a Command Status Wrapper used in the Mass Storage Bulk-Only transport protocol. */
#define CSW_SIGNATURE 0x53425355UL
/** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from host-to-device. */
#define COMMAND_DIRECTION_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 COMMAND_DIRECTION_DATA_IN (1 << 7)
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1 #define LEDMASK_USB_NOTREADY LEDS_LED1
@ -89,41 +68,10 @@
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */ /** LED mask for the library LED driver, to indicate that the USB interface is busy. */
#define LEDMASK_USB_BUSY LEDS_LED2 #define LEDMASK_USB_BUSY LEDS_LED2
/* 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[MAX_SCSI_COMMAND_LENGTH]; /**< 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
{
Command_Pass = 0, /**< Command completed with no error */
Command_Fail = 1, /**< Command failed to complete - host may check the exact error via a SCSI REQUEST SENSE command */
Phase_Error = 2 /**< Command failed due to being invalid in the current phase */
};
/* Global Variables: */ /* Global Variables: */
extern CommandBlockWrapper_t CommandBlock; extern MS_CommandBlockWrapper_t CommandBlock;
extern CommandStatusWrapper_t CommandStatus; extern MS_CommandStatusWrapper_t CommandStatus;
extern volatile bool IsMassStoreReset; extern volatile bool IsMassStoreReset;
/* Function Prototypes: */ /* Function Prototypes: */
void SetupHardware(void); void SetupHardware(void);

View File

@ -140,12 +140,12 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.HID_MouseHID = .HID_MouseHID =
{ {
.Header = {.Size = sizeof(USB_Descriptor_HID_t), .Type = DTYPE_HID}, .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
.HIDSpec = VERSION_BCD(01.11), .HIDSpec = VERSION_BCD(01.11),
.CountryCode = 0x00, .CountryCode = 0x00,
.TotalReportDescriptors = 1, .TotalReportDescriptors = 1,
.HIDReportType = DTYPE_Report, .HIDReportType = HID_DTYPE_Report,
.HIDReportLength = sizeof(MouseReport) .HIDReportLength = sizeof(MouseReport)
}, },
@ -237,11 +237,11 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
} }
break; break;
case DTYPE_HID: case HID_DTYPE_HID:
Address = &ConfigurationDescriptor.HID_MouseHID; Address = &ConfigurationDescriptor.HID_MouseHID;
Size = sizeof(USB_Descriptor_HID_t); Size = sizeof(USB_HID_Descriptor_HID_t);
break; break;
case DTYPE_Report: case HID_DTYPE_Report:
Address = &MouseReport; Address = &MouseReport;
Size = sizeof(MouseReport); Size = sizeof(MouseReport);
break; break;

View File

@ -42,25 +42,6 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
/* Type Defines: */ /* 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;
/** Type define for the device configuration descriptor structure. This must be defined in the /** Type define for the device configuration descriptor structure. This must be defined in the
* application code, as the configuration descriptor contains several sub-descriptors which * application code, as the configuration descriptor contains several sub-descriptors which
* vary between devices, and which describe the device's usage to the host. * vary between devices, and which describe the device's usage to the host.
@ -69,7 +50,7 @@
{ {
USB_Descriptor_Configuration_Header_t Config; USB_Descriptor_Configuration_Header_t Config;
USB_Descriptor_Interface_t HID_Interface; USB_Descriptor_Interface_t HID_Interface;
USB_Descriptor_HID_t HID_MouseHID; USB_HID_Descriptor_HID_t HID_MouseHID;
USB_Descriptor_Endpoint_t HID_ReportINEndpoint; USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
} USB_Descriptor_Configuration_t; } USB_Descriptor_Configuration_t;
@ -80,12 +61,6 @@
/** Size in bytes of the Mouse HID reporting IN endpoint. */ /** Size in bytes of the Mouse HID reporting IN endpoint. */
#define MOUSE_EPSIZE 8 #define MOUSE_EPSIZE 8
/** 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
/* Function Prototypes: */ /* Function Prototypes: */
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex, const uint8_t wIndex,

View File

@ -44,7 +44,7 @@ bool UsingReportProtocol = true;
/** Current Idle period. This is set by the host via a Set Idle HID class request to silence the device's reports /** Current Idle period. This is set by the host via a Set Idle HID class request to silence the device's reports
* for either the entire idle duration, or until the report status changes (e.g. the user moves the mouse). * for either the entire idle duration, or until the report status changes (e.g. the user moves the mouse).
*/ */
uint16_t IdleCount = HID_IDLE_CHANGESONLY; uint16_t IdleCount = 0;
/** Current Idle period remaining. When the IdleCount value is set, this tracks the remaining number of idle /** Current Idle period remaining. When the IdleCount value is set, this tracks the remaining number of idle
* milliseconds. This is separate to the IdleCount timer and is incremented and compared as the host may request * milliseconds. This is separate to the IdleCount timer and is incremented and compared as the host may request
@ -135,7 +135,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
/* Handle HID Class specific requests */ /* Handle HID Class specific requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)
{ {
case REQ_GetReport: case HID_REQ_GetReport:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
USB_MouseReport_Data_t MouseReportData; USB_MouseReport_Data_t MouseReportData;
@ -154,7 +154,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
} }
break; break;
case REQ_GetProtocol: case HID_REQ_GetProtocol:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
@ -167,7 +167,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
} }
break; break;
case REQ_SetProtocol: case HID_REQ_SetProtocol:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
@ -178,7 +178,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
} }
break; break;
case REQ_SetIdle: case HID_REQ_SetIdle:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
@ -189,7 +189,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
} }
break; break;
case REQ_GetIdle: case HID_REQ_GetIdle:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
@ -261,7 +261,7 @@ void SendNextReport(void)
SendReport = true; SendReport = true;
/* Check if the idle period is set and has elapsed */ /* Check if the idle period is set and has elapsed */
if ((IdleCount != HID_IDLE_CHANGESONLY) && (!(IdleMSRemaining))) if (IdleCount && (!(IdleMSRemaining)))
{ {
/* Reset the idle time remaining counter */ /* Reset the idle time remaining counter */
IdleMSRemaining = IdleCount; IdleMSRemaining = IdleCount;

View File

@ -53,27 +53,6 @@
#include <LUFA/Drivers/Board/Buttons.h> #include <LUFA/Drivers/Board/Buttons.h>
/* Macros: */ /* Macros: */
/** Idle period indicating that reports should be sent only when the inputs have changed */
#define HID_IDLE_CHANGESONLY 0
/** HID Class specific request to get the next HID report from the device. */
#define REQ_GetReport 0x01
/** HID Class specific request to get the idle timeout period of the device. */
#define REQ_GetIdle 0x02
/** HID Class specific request to send the next HID report to the device. */
#define REQ_SetReport 0x09
/** HID Class specific request to set the idle timeout period of the device. */
#define REQ_SetIdle 0x0A
/** HID Class specific request to get the current HID protocol in use, either report or boot. */
#define REQ_GetProtocol 0x03
/** HID Class specific request to set the current HID protocol in use, either report or boot. */
#define REQ_SetProtocol 0x0B
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1 #define LEDMASK_USB_NOTREADY LEDS_LED1
@ -86,17 +65,6 @@
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
/* Type Defines: */
/** Type define for the mouse HID report structure, for creating and sending HID reports to the host PC.
* This mirrors the layout described to the host in the HID report descriptor, in Descriptors.c.
*/
typedef struct
{
uint8_t Button; /**< Bit mask of the currently pressed mouse buttons */
int8_t X; /**< Current mouse delta X movement, as a signed 8-bit integer */
int8_t Y; /**< Current mouse delta Y movement, as a signed 8-bit integer */
} USB_MouseReport_Data_t;
/* Function Prototypes: */ /* Function Prototypes: */
void SetupHardware(void); void SetupHardware(void);
void Mouse_Task(void); void Mouse_Task(void);

View File

@ -104,24 +104,24 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.CDC_Functional_Header = .CDC_Functional_Header =
{ {
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalHeader_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
.Subtype = 0x00, .Subtype = CDC_DSUBTYPE_CSInterface_Header,
.CDCSpecification = VERSION_BCD(01.10), .CDCSpecification = VERSION_BCD(01.10),
}, },
.CDC_Functional_ACM = .CDC_Functional_ACM =
{ {
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalACM_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
.Subtype = 0x02, .Subtype = CDC_DSUBTYPE_CSInterface_ACM,
.Capabilities = 0x00, .Capabilities = 0x00,
}, },
.CDC_Functional_Union = .CDC_Functional_Union =
{ {
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalUnion_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
.Subtype = 0x06, .Subtype = CDC_DSUBTYPE_CSInterface_Union,
.MasterInterfaceNumber = 0, .MasterInterfaceNumber = 0,
.SlaveInterfaceNumber = 1, .SlaveInterfaceNumber = 1,

View File

@ -58,40 +58,6 @@
#define CDC_NOTIFICATION_EPSIZE 8 #define CDC_NOTIFICATION_EPSIZE 8
/* Type Defines: */ /* Type Defines: */
/** Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device
* contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration.
* See the CDC class 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 CDC class-specific descriptors. */
uint16_t CDCSpecification; /**< Version number of the CDC specification implemented by the device,
* encoded in BCD format.
*/
} USB_Descriptor_CDC_FunctionalHeader_t;
/** Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface
* supports the CDC ACM subclass of the CDC specification. See the CDC class 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 CDC class-specific descriptors. */
uint8_t Capabilities; /**< Capabilities of the ACM interface, given as a bit mask. */
} USB_Descriptor_CDC_FunctionalACM_t;
/** Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific
* CDC control and data interfaces are related. See the CDC class 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 CDC class-specific descriptors. */
uint8_t MasterInterfaceNumber; /**< Interface number of the CDC Control interface. */
uint8_t SlaveInterfaceNumber; /**< Interface number of the CDC Data interface. */
} USB_Descriptor_CDC_FunctionalUnion_t;
/** Type define for the device configuration descriptor structure. This must be defined in the /** Type define for the device configuration descriptor structure. This must be defined in the
* application code, as the configuration descriptor contains several sub-descriptors which * application code, as the configuration descriptor contains several sub-descriptors which
* vary between devices, and which describe the device's usage to the host. * vary between devices, and which describe the device's usage to the host.
@ -100,9 +66,9 @@
{ {
USB_Descriptor_Configuration_Header_t Config; USB_Descriptor_Configuration_Header_t Config;
USB_Descriptor_Interface_t CDC_CCI_Interface; USB_Descriptor_Interface_t CDC_CCI_Interface;
USB_Descriptor_CDC_FunctionalHeader_t CDC_Functional_Header; USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header;
USB_Descriptor_CDC_FunctionalACM_t CDC_Functional_ACM; USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM;
USB_Descriptor_CDC_FunctionalUnion_t CDC_Functional_Union; USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union;
USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; USB_Descriptor_Endpoint_t CDC_NotificationEndpoint;
USB_Descriptor_Interface_t CDC_DCI_Interface; USB_Descriptor_Interface_t CDC_DCI_Interface;
USB_Descriptor_Endpoint_t RNDIS_DataOutEndpoint; USB_Descriptor_Endpoint_t RNDIS_DataOutEndpoint;

View File

@ -40,6 +40,8 @@
#include <avr/io.h> #include <avr/io.h>
#include <string.h> #include <string.h>
#include <LUFA/Drivers/USB/USB.h>
#include "EthernetProtocols.h" #include "EthernetProtocols.h"
#include "Ethernet.h" #include "Ethernet.h"
#include "ProtocolDecoders.h" #include "ProtocolDecoders.h"

View File

@ -81,14 +81,6 @@
#define NO_PROCESS -1 #define NO_PROCESS -1
/* Type Defines: */ /* Type Defines: */
/** 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 an Ethernet frame header. */ /** Type define for an Ethernet frame header. */
typedef struct typedef struct
{ {

View File

@ -76,7 +76,7 @@
typedef struct typedef struct
{ {
uint8_t Octets[6]; /**< Individual bytes of a MAC address */ uint8_t Octets[6]; /**< Individual bytes of a MAC address */
} MAC_Address_t; } RNDIS_MAC_Address_t;
/** Type define for a protocol IP address of a device on a network. */ /** Type define for a protocol IP address of a device on a network. */
typedef struct typedef struct

View File

@ -264,7 +264,7 @@ static bool ProcessNDISQuery(const uint32_t OId, void* QueryData, uint16_t Query
*ResponseSize = sizeof(uint32_t); *ResponseSize = sizeof(uint32_t);
/* Always indicate hardware ready */ /* Always indicate hardware ready */
*((uint32_t*)ResponseData) = NdisHardwareStatusReady; *((uint32_t*)ResponseData) = NDIS_HardwareStatus_Ready;
return true; return true;
case OID_GEN_MEDIA_SUPPORTED: case OID_GEN_MEDIA_SUPPORTED:

View File

@ -44,167 +44,6 @@
#include "RNDISConstants.h" #include "RNDISConstants.h"
#include "Ethernet.h" #include "Ethernet.h"
/* 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
/* 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
{
NdisHardwareStatusReady, /**< Hardware Ready to accept commands from the host */
NdisHardwareStatusInitializing, /**< Hardware busy initializing */
NdisHardwareStatusReset, /**< Hardware reset */
NdisHardwareStatusClosing, /**< Hardware currently closing */
NdisHardwareStatusNotReady /**< Hardware not ready to accept commands from the host */
};
/* Type Defines: */
/** 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 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_Message_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_Message_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_Complete_t;
/** Type define for a RNDIS Keep-alive command message. */
typedef struct
{
uint32_t MessageType;
uint32_t MessageLength;
uint32_t RequestId;
} RNDIS_KeepAlive_Message_t;
/** Type define for a RNDIS Keep-alive complete message. */
typedef struct
{
uint32_t MessageType;
uint32_t MessageLength;
uint32_t RequestId;
uint32_t Status;
} RNDIS_KeepAlive_Complete_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_Complete_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_Message_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_Complete_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_Message_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_Complete_t;
/* External Variables: */ /* External Variables: */
extern uint8_t RNDISMessageBuffer[]; extern uint8_t RNDISMessageBuffer[];
extern RNDIS_Message_Header_t* MessageHeader; extern RNDIS_Message_Header_t* MessageHeader;

View File

@ -1,113 +0,0 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, 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.
*/
/** \file
*
* RNDIS specification related constants. For more information on these
* constants, please refer to the Microsoft RNDIS specification.
*/
#ifndef _RNDIS_CONSTANTS_DEVICE_H_
#define _RNDIS_CONSTANTS_DEVICE_H_
/* Macros: */
#define REMOTE_NDIS_PACKET_MSG 0x00000001UL
#define REMOTE_NDIS_INITIALIZE_MSG 0x00000002UL
#define REMOTE_NDIS_HALT_MSG 0x00000003UL
#define REMOTE_NDIS_QUERY_MSG 0x00000004UL
#define REMOTE_NDIS_SET_MSG 0x00000005UL
#define REMOTE_NDIS_RESET_MSG 0x00000006UL
#define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007UL
#define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008UL
#define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002UL
#define REMOTE_NDIS_QUERY_CMPLT 0x80000004UL
#define REMOTE_NDIS_SET_CMPLT 0x80000005UL
#define REMOTE_NDIS_RESET_CMPLT 0x80000006UL
#define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008UL
#define REMOTE_NDIS_STATUS_SUCCESS 0x00000000UL
#define REMOTE_NDIS_STATUS_FAILURE 0xC0000001UL
#define REMOTE_NDIS_STATUS_INVALID_DATA 0xC0010015UL
#define REMOTE_NDIS_STATUS_NOT_SUPPORTED 0xC00000BBUL
#define REMOTE_NDIS_STATUS_MEDIA_CONNECT 0x4001000BUL
#define REMOTE_NDIS_STATUS_MEDIA_DISCONNECT 0x4001000CUL
#define REMOTE_NDIS_MEDIA_STATE_CONNECTED 0x00000000UL
#define REMOTE_NDIS_MEDIA_STATE_DISCONNECTED 0x00000001UL
#define REMOTE_NDIS_MEDIUM_802_3 0x00000000UL
#define REMOTE_NDIS_DF_CONNECTIONLESS 0x00000001UL
#define REMOTE_NDIS_DF_CONNECTION_ORIENTED 0x00000002UL
#define REMOTE_NDIS_PACKET_DIRECTED 0x00000001UL
#define REMOTE_NDIS_PACKET_MULTICAST 0x00000002UL
#define REMOTE_NDIS_PACKET_ALL_MULTICAST 0x00000004UL
#define REMOTE_NDIS_PACKET_BROADCAST 0x00000008UL
#define REMOTE_NDIS_PACKET_SOURCE_ROUTING 0x00000010UL
#define REMOTE_NDIS_PACKET_PROMISCUOUS 0x00000020UL
#define REMOTE_NDIS_PACKET_SMT 0x00000040UL
#define REMOTE_NDIS_PACKET_ALL_LOCAL 0x00000080UL
#define REMOTE_NDIS_PACKET_GROUP 0x00001000UL
#define REMOTE_NDIS_PACKET_ALL_FUNCTIONAL 0x00002000UL
#define REMOTE_NDIS_PACKET_FUNCTIONAL 0x00004000UL
#define REMOTE_NDIS_PACKET_MAC_FRAME 0x00008000UL
#define OID_GEN_SUPPORTED_LIST 0x00010101UL
#define OID_GEN_HARDWARE_STATUS 0x00010102UL
#define OID_GEN_MEDIA_SUPPORTED 0x00010103UL
#define OID_GEN_MEDIA_IN_USE 0x00010104UL
#define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106UL
#define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111UL
#define OID_GEN_LINK_SPEED 0x00010107UL
#define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010AUL
#define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010BUL
#define OID_GEN_VENDOR_ID 0x0001010CUL
#define OID_GEN_VENDOR_DESCRIPTION 0x0001010DUL
#define OID_GEN_CURRENT_PACKET_FILTER 0x0001010EUL
#define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111UL
#define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114UL
#define OID_GEN_PHYSICAL_MEDIUM 0x00010202UL
#define OID_GEN_XMIT_OK 0x00020101UL
#define OID_GEN_RCV_OK 0x00020102UL
#define OID_GEN_XMIT_ERROR 0x00020103UL
#define OID_GEN_RCV_ERROR 0x00020104UL
#define OID_GEN_RCV_NO_BUFFER 0x00020105UL
#define OID_802_3_PERMANENT_ADDRESS 0x01010101UL
#define OID_802_3_CURRENT_ADDRESS 0x01010102UL
#define OID_802_3_MULTICAST_LIST 0x01010103UL
#define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104UL
#define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101UL
#define OID_802_3_XMIT_ONE_COLLISION 0x01020102UL
#define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103UL
#endif

View File

@ -121,7 +121,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
/* Process RNDIS class commands */ /* Process RNDIS class commands */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)
{ {
case REQ_SendEncapsulatedCommand: case RNDIS_REQ_SendEncapsulatedCommand:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
@ -135,7 +135,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
} }
break; break;
case REQ_GetEncapsulatedResponse: case RNDIS_REQ_GetEncapsulatedResponse:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
/* Check if a response to the last message is ready */ /* Check if a response to the last message is ready */
@ -172,10 +172,10 @@ void RNDIS_Task(void)
/* Check if a message response is ready for the host */ /* Check if a message response is ready for the host */
if (Endpoint_IsINReady() && ResponseReady) if (Endpoint_IsINReady() && ResponseReady)
{ {
USB_Notification_t Notification = (USB_Notification_t) USB_Request_Header_t Notification = (USB_Request_Header_t)
{ {
.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE), .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
.bNotification = NOTIF_RESPONSE_AVAILABLE, .bRequest = RNDIS_NOTIF_ResponseAvailable,
.wValue = 0, .wValue = 0,
.wIndex = 0, .wIndex = 0,
.wLength = 0, .wLength = 0,

View File

@ -75,19 +75,6 @@
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */ /** LED mask for the library LED driver, to indicate that the USB interface is busy. */
#define LEDMASK_USB_BUSY LEDS_LED2 #define LEDMASK_USB_BUSY LEDS_LED2
/* Type Defines: */
/** Type define for a RNDIS notification message, for transmission to the RNDIS host via the notification
* Endpoint.
*/
typedef struct
{
uint8_t bmRequestType; /**< Notification type, a mask of values from SrdRequestType.h */
uint8_t bNotification; /**< Notification index, indicating what the RNDIS notification relates to */
uint16_t wValue; /**< Two byte notification value parameter */
uint16_t wIndex; /**< Two byte notification index parameter */
uint16_t wLength; /**< Size of data payload following the notification header */
} USB_Notification_t;
/* Function Prototypes: */ /* Function Prototypes: */
void SetupHardware(void); void SetupHardware(void);
void RNDIS_Task(void); void RNDIS_Task(void);

View File

@ -116,24 +116,24 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.CDC_Functional_Header = .CDC_Functional_Header =
{ {
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalHeader_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
.Subtype = 0x00, .Subtype = CDC_DSUBTYPE_CSInterface_Header,
.CDCSpecification = VERSION_BCD(01.10), .CDCSpecification = VERSION_BCD(01.10),
}, },
.CDC_Functional_ACM = .CDC_Functional_ACM =
{ {
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalACM_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
.Subtype = 0x02, .Subtype = CDC_DSUBTYPE_CSInterface_ACM,
.Capabilities = 0x06, .Capabilities = 0x06,
}, },
.CDC_Functional_Union = .CDC_Functional_Union =
{ {
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalUnion_t), .Type = DTYPE_CSInterface}, .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
.Subtype = 0x06, .Subtype = CDC_DSUBTYPE_CSInterface_Union,
.MasterInterfaceNumber = 0, .MasterInterfaceNumber = 0,
.SlaveInterfaceNumber = 1, .SlaveInterfaceNumber = 1,

View File

@ -58,40 +58,6 @@
#define CDC_TXRX_EPSIZE 16 #define CDC_TXRX_EPSIZE 16
/* Type Defines: */ /* Type Defines: */
/** Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device
* contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration.
* See the CDC class 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 CDC class-specific descriptors. */
uint16_t CDCSpecification; /**< Version number of the CDC specification implemented by the device,
* encoded in BCD format.
*/
} USB_Descriptor_CDC_FunctionalHeader_t;
/** Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface
* supports the CDC ACM subclass of the CDC specification. See the CDC class 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 CDC class-specific descriptors. */
uint8_t Capabilities; /**< Capabilities of the ACM interface, given as a bit mask. */
} USB_Descriptor_CDC_FunctionalACM_t;
/** Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific
* CDC control and data interfaces are related. See the CDC class 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 CDC class-specific descriptors. */
uint8_t MasterInterfaceNumber; /**< Interface number of the CDC Control interface. */
uint8_t SlaveInterfaceNumber; /**< Interface number of the CDC Data interface. */
} USB_Descriptor_CDC_FunctionalUnion_t;
/** Type define for the device configuration descriptor structure. This must be defined in the /** Type define for the device configuration descriptor structure. This must be defined in the
* application code, as the configuration descriptor contains several sub-descriptors which * application code, as the configuration descriptor contains several sub-descriptors which
* vary between devices, and which describe the device's usage to the host. * vary between devices, and which describe the device's usage to the host.
@ -100,9 +66,9 @@
{ {
USB_Descriptor_Configuration_Header_t Config; USB_Descriptor_Configuration_Header_t Config;
USB_Descriptor_Interface_t CDC_CCI_Interface; USB_Descriptor_Interface_t CDC_CCI_Interface;
USB_Descriptor_CDC_FunctionalHeader_t CDC_Functional_Header; USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header;
USB_Descriptor_CDC_FunctionalACM_t CDC_Functional_ACM; USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM;
USB_Descriptor_CDC_FunctionalUnion_t CDC_Functional_Union; USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union;
USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; USB_Descriptor_Endpoint_t CDC_NotificationEndpoint;
USB_Descriptor_Interface_t CDC_DCI_Interface; USB_Descriptor_Interface_t CDC_DCI_Interface;
USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; USB_Descriptor_Endpoint_t CDC_DataOutEndpoint;

View File

@ -44,10 +44,10 @@
* It is possible to completely ignore these value or use other settings as the host is completely unaware of the physical * It is possible to completely ignore these value or use other settings as the host is completely unaware of the physical
* serial link characteristics and instead sends and receives data in endpoint streams. * serial link characteristics and instead sends and receives data in endpoint streams.
*/ */
CDC_Line_Coding_t LineEncoding = { .BaudRateBPS = 0, CDC_LineEncoding_t LineEncoding = { .BaudRateBPS = 0,
.CharFormat = OneStopBit, .CharFormat = CDC_LINEENCODING_OneStopBit,
.ParityType = Parity_None, .ParityType = CDC_PARITY_None,
.DataBits = 8 }; .DataBits = 8 };
/** Main program entry point. This routine contains the overall program flow, including initial /** Main program entry point. This routine contains the overall program flow, including initial
* setup of all components and the main program loop. * setup of all components and the main program loop.
@ -131,29 +131,29 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
/* Process CDC specific control requests */ /* Process CDC specific control requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)
{ {
case REQ_GetLineEncoding: case CDC_REQ_GetLineEncoding:
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
/* Write the line coding data to the control endpoint */ /* Write the line coding data to the control endpoint */
Endpoint_Write_Control_Stream_LE(&LineEncoding, sizeof(CDC_Line_Coding_t)); Endpoint_Write_Control_Stream_LE(&LineEncoding, sizeof(CDC_LineEncoding_t));
Endpoint_ClearOUT(); Endpoint_ClearOUT();
} }
break; break;
case REQ_SetLineEncoding: case CDC_REQ_SetLineEncoding:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
/* Read the line coding data in from the host into the global struct */ /* Read the line coding data in from the host into the global struct */
Endpoint_Read_Control_Stream_LE(&LineEncoding, sizeof(CDC_Line_Coding_t)); Endpoint_Read_Control_Stream_LE(&LineEncoding, sizeof(CDC_LineEncoding_t));
Endpoint_ClearIN(); Endpoint_ClearIN();
} }
break; break;
case REQ_SetControlLineState: case CDC_REQ_SetControlLineState:
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
{ {
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
@ -180,29 +180,6 @@ void CDC_Task(void)
if (USB_DeviceState != DEVICE_STATE_Configured) if (USB_DeviceState != DEVICE_STATE_Configured)
return; return;
#if 0
/* NOTE: Here you can use the notification endpoint to send back line state changes to the host, for the special RS-232
* handshake signal lines (and some error states), via the CONTROL_LINE_IN_* masks and the following code:
*/
USB_Notification_Header_t Notification = (USB_Notification_Header_t)
{
.NotificationType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
.Notification = NOTIF_SerialState,
.wValue = 0,
.wIndex = 0,
.wLength = sizeof(uint16_t),
};
uint16_t LineStateMask;
// Set LineStateMask here to a mask of CONTROL_LINE_IN_* masks to set the input handshake line states to send to the host
Endpoint_SelectEndpoint(CDC_NOTIFICATION_EPNUM);
Endpoint_Write_Stream_LE(&Notification, sizeof(Notification));
Endpoint_Write_Stream_LE(&LineStateMask, sizeof(LineStateMask));
Endpoint_ClearIN();
#endif
/* Determine if a joystick action has occurred */ /* Determine if a joystick action has occurred */
if (JoyStatus_LCL & JOY_UP) if (JoyStatus_LCL & JOY_UP)
ReportString = "Joystick Up\r\n"; ReportString = "Joystick Up\r\n";

View File

@ -51,66 +51,6 @@
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
/* Macros: */ /* 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 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 CONTROL_LINE_OUT_RTS (1 << 1)
/** Mask for the DCD handshake line for use with the NOTIF_SerialState class specific notification
* from the device to the host, to indicate that the DCD line state is currently high.
*/
#define CONTROL_LINE_IN_DCD (1 << 0)
/** Mask for the DSR handshake line for use with the NOTIF_SerialState class specific notification
* from the device to the host, to indicate that the DSR line state is currently high.
*/
#define CONTROL_LINE_IN_DSR (1 << 1)
/** Mask for the BREAK handshake line for use with the NOTIF_SerialState class specific notification
* from the device to the host, to indicate that the BREAK line state is currently high.
*/
#define CONTROL_LINE_IN_BREAK (1 << 2)
/** Mask for the RING handshake line for use with the NOTIF_SerialState class specific notification
* from the device to the host, to indicate that the RING line state is currently high.
*/
#define CONTROL_LINE_IN_RING (1 << 3)
/** Mask for use with the 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 CONTROL_LINE_IN_FRAMEERROR (1 << 4)
/** Mask for use with the 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 CONTROL_LINE_IN_PARITYERROR (1 << 5)
/** Mask for use with the 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 CONTROL_LINE_IN_OVERRUNERROR (1 << 6)
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1 #define LEDMASK_USB_NOTREADY LEDS_LED1
@ -123,55 +63,6 @@
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
/* Type Defines: */
/** Type define for the virtual serial port line encoding settings, for storing the current USART configuration
* as set by the host via a class specific request.
*/
typedef 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 */
} CDC_Line_Coding_t;
/** Type define for a CDC notification, sent to the host via the CDC notification endpoint to indicate a
* change in the device state asynchronously.
*/
typedef struct
{
uint8_t NotificationType; /**< Notification type, a mask of REQDIR_*, REQTYPE_* and REQREC_* constants
* from the library StdRequestType.h header
*/
uint8_t Notification; /**< Notification value, a NOTIF_* constant */
uint16_t wValue; /**< Notification wValue, notification-specific */
uint16_t wIndex; /**< Notification wIndex, notification-specific */
uint16_t wLength; /**< Notification wLength, notification-specific */
} USB_Notification_Header_t;
/* Enums: */
/** Enum for the possible line encoding formats of a virtual serial port. */
enum CDCDevice_CDC_LineCodingFormats_t
{
OneStopBit = 0, /**< Each frame contains one stop bit */
OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits */
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
{
Parity_None = 0, /**< No parity bit mode on each frame */
Parity_Odd = 1, /**< Odd parity bit mode on each frame */
Parity_Even = 2, /**< Even parity bit mode on each frame */
Parity_Mark = 3, /**< Mark parity bit mode on each frame */
Parity_Space = 4, /**< Space parity bit mode on each frame */
};
/* Function Prototypes: */ /* Function Prototypes: */
void SetupHardware(void); void SetupHardware(void);
void CDC_Task(void); void CDC_Task(void);

View File

@ -38,7 +38,6 @@
/* Includes: */ /* Includes: */
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>

View File

@ -51,7 +51,6 @@
#include <LUFA/Drivers/Board/Joystick.h> #include <LUFA/Drivers/Board/Joystick.h>
#include <LUFA/Drivers/Board/Buttons.h> #include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
#include "Descriptors.h" #include "Descriptors.h"
#include "DeviceFunctions.h" #include "DeviceFunctions.h"

View File

@ -49,7 +49,6 @@
#include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -49,7 +49,6 @@
#include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -49,7 +49,6 @@
#include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -51,7 +51,6 @@
#include <LUFA/Drivers/Board/Buttons.h> #include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/Board/Joystick.h> #include <LUFA/Drivers/Board/Joystick.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/MIDI.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -50,7 +50,6 @@
#include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/MassStorage.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -49,7 +49,6 @@
#include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -49,7 +49,6 @@
#include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/HID.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -49,7 +49,6 @@
#include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/Printer.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -49,7 +49,6 @@
#include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/RNDIS.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -49,7 +49,6 @@
#include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/StillImage.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -49,7 +49,6 @@
#include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/Class/CDC.h>
/* Macros: */ /* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */

View File

@ -212,7 +212,7 @@ void WriteNextReport(uint8_t* ReportOUTData,
USB_ControlRequest = (USB_Request_Header_t) USB_ControlRequest = (USB_Request_Header_t)
{ {
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
.bRequest = REQ_SetReport, .bRequest = HID_REQ_SetReport,
.wValue = ((ReportType << 8) | ReportIndex), .wValue = ((ReportType << 8) | ReportIndex),
.wIndex = 0, .wIndex = 0,
.wLength = ReportLength, .wLength = ReportLength,

View File

@ -53,9 +53,6 @@
#include "ConfigDescriptor.h" #include "ConfigDescriptor.h"
/* Macros: */ /* Macros: */
/** HID Class specific request to send a HID report to the device. */
#define REQ_SetReport 0x09
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1 #define LEDMASK_USB_NOTREADY LEDS_LED1

View File

@ -52,7 +52,7 @@ uint8_t ProcessConfigurationDescriptor(void)
uint16_t CurrConfigBytesRem; uint16_t CurrConfigBytesRem;
USB_Descriptor_Interface_t* HIDInterface = NULL; USB_Descriptor_Interface_t* HIDInterface = NULL;
USB_Descriptor_HID_t* HIDDescriptor = NULL; USB_HID_Descriptor_HID_t* HIDDescriptor = NULL;
USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;
/* Retrieve the entire configuration descriptor into the allocated buffer */ /* Retrieve the entire configuration descriptor into the allocated buffer */
@ -95,7 +95,7 @@ uint8_t ProcessConfigurationDescriptor(void)
} }
/* Save the HID descriptor for later use */ /* Save the HID descriptor for later use */
HIDDescriptor = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_HID_t); HIDDescriptor = DESCRIPTOR_PCAST(CurrConfigLocation, USB_HID_Descriptor_HID_t);
/* Skip the remainder of the loop as we have not found an endpoint yet */ /* Skip the remainder of the loop as we have not found an endpoint yet */
continue; continue;
@ -178,7 +178,7 @@ uint8_t DComp_NextJoystickInterfaceDataEndpoint(void* CurrentDescriptor)
*/ */
uint8_t DComp_NextHID(void* CurrentDescriptor) uint8_t DComp_NextHID(void* CurrentDescriptor)
{ {
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_HID) if (DESCRIPTOR_TYPE(CurrentDescriptor) == HID_DTYPE_HID)
return DESCRIPTOR_SEARCH_Found; return DESCRIPTOR_SEARCH_Found;
else else
return DESCRIPTOR_SEARCH_NotFound; return DESCRIPTOR_SEARCH_NotFound;

View File

@ -48,12 +48,6 @@
/** Interface Protocol value for a Boot Protocol Mouse compliant device. */ /** Interface Protocol value for a Boot Protocol Mouse compliant device. */
#define JOYSTICK_PROTOCOL 0x02 #define JOYSTICK_PROTOCOL 0x02
/** Descriptor header type constant for a HID descriptor. */
#define DTYPE_HID 0x21
/** Descriptor header type constant for a HID report descriptor. */
#define DTYPE_Report 0x22
/** Pipe number for the joystick report data pipe. */ /** Pipe number for the joystick report data pipe. */
#define JOYSTICK_DATA_IN_PIPE 1 #define JOYSTICK_DATA_IN_PIPE 1

Some files were not shown because too many files have changed in this diff Show More