Add svn:eol-style property to source files, so that the line endings are correctly converted to the target system's native end of line style.
This commit is contained in:
parent
e331b531c6
commit
071e02c6b6
839 changed files with 274562 additions and 274562 deletions
|
@ -1,326 +1,326 @@
|
|||
/*
|
||||
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
|
||||
*
|
||||
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special
|
||||
* computer-readable structures which the host requests upon device enumeration, to determine
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||
* device characteristics, including the supported USB version, control endpoint size and the
|
||||
* number of device configurations. The descriptor is read out by the USB host when the enumeration
|
||||
* process begins.
|
||||
*/
|
||||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = 0x00,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = 0x00,
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x2048,
|
||||
.ReleaseNumber = 0x0000,
|
||||
|
||||
.ManufacturerStrIndex = 0x01,
|
||||
.ProductStrIndex = 0x02,
|
||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
|
||||
* of the device in one of its supported configurations, including information about any device interfaces
|
||||
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
|
||||
* a configuration so that the host may correctly communicate with the USB device.
|
||||
*/
|
||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 2,
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.Audio_ControlInterface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
.TotalEndpoints = 0,
|
||||
|
||||
.Class = 0x01,
|
||||
.SubClass = 0x01,
|
||||
.Protocol = 0x00,
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.Audio_ControlInterface_SPC =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Audio_Interface_AC_t), .Type = DTYPE_AudioInterface},
|
||||
.Subtype = DSUBTYPE_Header,
|
||||
|
||||
.ACSpecification = VERSION_BCD(01.00),
|
||||
.TotalLength = sizeof(USB_Audio_Interface_AC_t),
|
||||
|
||||
.InCollection = 1,
|
||||
.InterfaceNumbers = {1},
|
||||
},
|
||||
|
||||
.Audio_StreamInterface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 1,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
.TotalEndpoints = 2,
|
||||
|
||||
.Class = 0x01,
|
||||
.SubClass = 0x03,
|
||||
.Protocol = 0x00,
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.Audio_StreamInterface_SPC =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Audio_Interface_MIDI_AS_t), .Type = DTYPE_AudioInterface},
|
||||
.Subtype = DSUBTYPE_General,
|
||||
|
||||
.AudioSpecification = VERSION_BCD(01.00),
|
||||
|
||||
.TotalLength = (sizeof(USB_Descriptor_Configuration_t) -
|
||||
offsetof(USB_Descriptor_Configuration_t, Audio_StreamInterface_SPC))
|
||||
},
|
||||
|
||||
.MIDI_In_Jack_Emb =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_MIDI_In_Jack_t), .Type = DTYPE_AudioInterface},
|
||||
.Subtype = DSUBTYPE_InputJack,
|
||||
|
||||
.JackType = JACKTYPE_EMBEDDED,
|
||||
.JackID = 0x01,
|
||||
|
||||
.JackStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.MIDI_In_Jack_Ext =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_MIDI_In_Jack_t), .Type = DTYPE_AudioInterface},
|
||||
.Subtype = DSUBTYPE_InputJack,
|
||||
|
||||
.JackType = JACKTYPE_EXTERNAL,
|
||||
.JackID = 0x02,
|
||||
|
||||
.JackStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.MIDI_Out_Jack_Emb =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_MIDI_Out_Jack_t), .Type = DTYPE_AudioInterface},
|
||||
.Subtype = DSUBTYPE_OutputJack,
|
||||
|
||||
.JackType = JACKTYPE_EMBEDDED,
|
||||
.JackID = 0x03,
|
||||
|
||||
.NumberOfPins = 1,
|
||||
.SourceJackID = {0x02},
|
||||
.SourcePinID = {0x01},
|
||||
|
||||
.JackStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.MIDI_Out_Jack_Ext =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_MIDI_Out_Jack_t), .Type = DTYPE_AudioInterface},
|
||||
.Subtype = DSUBTYPE_OutputJack,
|
||||
|
||||
.JackType = JACKTYPE_EXTERNAL,
|
||||
.JackID = 0x04,
|
||||
|
||||
.NumberOfPins = 1,
|
||||
.SourceJackID = {0x01},
|
||||
.SourcePinID = {0x01},
|
||||
|
||||
.JackStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.MIDI_In_Jack_Endpoint =
|
||||
{
|
||||
.Endpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Audio_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | MIDI_STREAM_OUT_EPNUM),
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = MIDI_STREAM_EPSIZE,
|
||||
.PollingIntervalMS = 0
|
||||
},
|
||||
|
||||
.Refresh = 0,
|
||||
.SyncEndpointNumber = 0
|
||||
},
|
||||
|
||||
.MIDI_In_Jack_Endpoint_SPC =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_MIDI_Jack_Endpoint_t), .Type = DTYPE_AudioEndpoint},
|
||||
.Subtype = DSUBTYPE_General,
|
||||
|
||||
.TotalEmbeddedJacks = 0x01,
|
||||
.AssociatedJackID = {0x01}
|
||||
},
|
||||
|
||||
.MIDI_Out_Jack_Endpoint =
|
||||
{
|
||||
.Endpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Audio_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | MIDI_STREAM_IN_EPNUM),
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = MIDI_STREAM_EPSIZE,
|
||||
.PollingIntervalMS = 0
|
||||
},
|
||||
|
||||
.Refresh = 0,
|
||||
.SyncEndpointNumber = 0
|
||||
},
|
||||
|
||||
.MIDI_Out_Jack_Endpoint_SPC =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_MIDI_Jack_Endpoint_t), .Type = DTYPE_AudioEndpoint},
|
||||
.Subtype = DSUBTYPE_General,
|
||||
|
||||
.TotalEmbeddedJacks = 0x01,
|
||||
.AssociatedJackID = {0x03}
|
||||
}
|
||||
};
|
||||
|
||||
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
||||
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
|
||||
* via the language ID table available at USB.org what languages the device supports for its string descriptors.
|
||||
*/
|
||||
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable
|
||||
* form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"Dean Camera"
|
||||
};
|
||||
|
||||
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
|
||||
* and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
USB_Descriptor_String_t PROGMEM ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(14), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"LUFA MIDI Demo"
|
||||
};
|
||||
|
||||
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
||||
* documentation) by the application code so that the address and size of a requested descriptor can be given
|
||||
* to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
|
||||
* is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
|
||||
* USB host.
|
||||
*/
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
|
||||
{
|
||||
const uint8_t DescriptorType = (wValue >> 8);
|
||||
const uint8_t DescriptorNumber = (wValue & 0xFF);
|
||||
|
||||
void* Address = NULL;
|
||||
uint16_t Size = NO_DESCRIPTOR;
|
||||
|
||||
switch (DescriptorType)
|
||||
{
|
||||
case DTYPE_Device:
|
||||
Address = (void*)&DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
Address = (void*)&ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case 0x00:
|
||||
Address = (void*)&LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
break;
|
||||
case 0x01:
|
||||
Address = (void*)&ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
break;
|
||||
case 0x02:
|
||||
Address = (void*)&ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
/*
|
||||
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
|
||||
*
|
||||
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special
|
||||
* computer-readable structures which the host requests upon device enumeration, to determine
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||
* device characteristics, including the supported USB version, control endpoint size and the
|
||||
* number of device configurations. The descriptor is read out by the USB host when the enumeration
|
||||
* process begins.
|
||||
*/
|
||||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = 0x00,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = 0x00,
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x2048,
|
||||
.ReleaseNumber = 0x0000,
|
||||
|
||||
.ManufacturerStrIndex = 0x01,
|
||||
.ProductStrIndex = 0x02,
|
||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
|
||||
* of the device in one of its supported configurations, including information about any device interfaces
|
||||
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
|
||||
* a configuration so that the host may correctly communicate with the USB device.
|
||||
*/
|
||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 2,
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.Audio_ControlInterface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
.TotalEndpoints = 0,
|
||||
|
||||
.Class = 0x01,
|
||||
.SubClass = 0x01,
|
||||
.Protocol = 0x00,
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.Audio_ControlInterface_SPC =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Audio_Interface_AC_t), .Type = DTYPE_AudioInterface},
|
||||
.Subtype = DSUBTYPE_Header,
|
||||
|
||||
.ACSpecification = VERSION_BCD(01.00),
|
||||
.TotalLength = sizeof(USB_Audio_Interface_AC_t),
|
||||
|
||||
.InCollection = 1,
|
||||
.InterfaceNumbers = {1},
|
||||
},
|
||||
|
||||
.Audio_StreamInterface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 1,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
.TotalEndpoints = 2,
|
||||
|
||||
.Class = 0x01,
|
||||
.SubClass = 0x03,
|
||||
.Protocol = 0x00,
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.Audio_StreamInterface_SPC =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Audio_Interface_MIDI_AS_t), .Type = DTYPE_AudioInterface},
|
||||
.Subtype = DSUBTYPE_General,
|
||||
|
||||
.AudioSpecification = VERSION_BCD(01.00),
|
||||
|
||||
.TotalLength = (sizeof(USB_Descriptor_Configuration_t) -
|
||||
offsetof(USB_Descriptor_Configuration_t, Audio_StreamInterface_SPC))
|
||||
},
|
||||
|
||||
.MIDI_In_Jack_Emb =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_MIDI_In_Jack_t), .Type = DTYPE_AudioInterface},
|
||||
.Subtype = DSUBTYPE_InputJack,
|
||||
|
||||
.JackType = JACKTYPE_EMBEDDED,
|
||||
.JackID = 0x01,
|
||||
|
||||
.JackStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.MIDI_In_Jack_Ext =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_MIDI_In_Jack_t), .Type = DTYPE_AudioInterface},
|
||||
.Subtype = DSUBTYPE_InputJack,
|
||||
|
||||
.JackType = JACKTYPE_EXTERNAL,
|
||||
.JackID = 0x02,
|
||||
|
||||
.JackStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.MIDI_Out_Jack_Emb =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_MIDI_Out_Jack_t), .Type = DTYPE_AudioInterface},
|
||||
.Subtype = DSUBTYPE_OutputJack,
|
||||
|
||||
.JackType = JACKTYPE_EMBEDDED,
|
||||
.JackID = 0x03,
|
||||
|
||||
.NumberOfPins = 1,
|
||||
.SourceJackID = {0x02},
|
||||
.SourcePinID = {0x01},
|
||||
|
||||
.JackStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.MIDI_Out_Jack_Ext =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_MIDI_Out_Jack_t), .Type = DTYPE_AudioInterface},
|
||||
.Subtype = DSUBTYPE_OutputJack,
|
||||
|
||||
.JackType = JACKTYPE_EXTERNAL,
|
||||
.JackID = 0x04,
|
||||
|
||||
.NumberOfPins = 1,
|
||||
.SourceJackID = {0x01},
|
||||
.SourcePinID = {0x01},
|
||||
|
||||
.JackStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.MIDI_In_Jack_Endpoint =
|
||||
{
|
||||
.Endpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Audio_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | MIDI_STREAM_OUT_EPNUM),
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = MIDI_STREAM_EPSIZE,
|
||||
.PollingIntervalMS = 0
|
||||
},
|
||||
|
||||
.Refresh = 0,
|
||||
.SyncEndpointNumber = 0
|
||||
},
|
||||
|
||||
.MIDI_In_Jack_Endpoint_SPC =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_MIDI_Jack_Endpoint_t), .Type = DTYPE_AudioEndpoint},
|
||||
.Subtype = DSUBTYPE_General,
|
||||
|
||||
.TotalEmbeddedJacks = 0x01,
|
||||
.AssociatedJackID = {0x01}
|
||||
},
|
||||
|
||||
.MIDI_Out_Jack_Endpoint =
|
||||
{
|
||||
.Endpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Audio_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | MIDI_STREAM_IN_EPNUM),
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = MIDI_STREAM_EPSIZE,
|
||||
.PollingIntervalMS = 0
|
||||
},
|
||||
|
||||
.Refresh = 0,
|
||||
.SyncEndpointNumber = 0
|
||||
},
|
||||
|
||||
.MIDI_Out_Jack_Endpoint_SPC =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_MIDI_Jack_Endpoint_t), .Type = DTYPE_AudioEndpoint},
|
||||
.Subtype = DSUBTYPE_General,
|
||||
|
||||
.TotalEmbeddedJacks = 0x01,
|
||||
.AssociatedJackID = {0x03}
|
||||
}
|
||||
};
|
||||
|
||||
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
||||
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
|
||||
* via the language ID table available at USB.org what languages the device supports for its string descriptors.
|
||||
*/
|
||||
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable
|
||||
* form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"Dean Camera"
|
||||
};
|
||||
|
||||
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
|
||||
* and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
USB_Descriptor_String_t PROGMEM ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(14), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"LUFA MIDI Demo"
|
||||
};
|
||||
|
||||
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
||||
* documentation) by the application code so that the address and size of a requested descriptor can be given
|
||||
* to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
|
||||
* is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
|
||||
* USB host.
|
||||
*/
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
|
||||
{
|
||||
const uint8_t DescriptorType = (wValue >> 8);
|
||||
const uint8_t DescriptorNumber = (wValue & 0xFF);
|
||||
|
||||
void* Address = NULL;
|
||||
uint16_t Size = NO_DESCRIPTOR;
|
||||
|
||||
switch (DescriptorType)
|
||||
{
|
||||
case DTYPE_Device:
|
||||
Address = (void*)&DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
Address = (void*)&ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case 0x00:
|
||||
Address = (void*)&LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
break;
|
||||
case 0x01:
|
||||
Address = (void*)&ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
break;
|
||||
case 0x02:
|
||||
Address = (void*)&ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
|
|
@ -1,189 +1,189 @@
|
|||
/*
|
||||
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 file for Descriptors.c.
|
||||
*/
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
/* Macros: */
|
||||
/** Descriptor header constant to indicate a Audio class interface descriptor. */
|
||||
#define DTYPE_AudioInterface 0x24
|
||||
|
||||
/** Descriptor header constant to indicate a Audio class endpoint descriptor. */
|
||||
#define DTYPE_AudioEndpoint 0x25
|
||||
|
||||
/** Audio class descriptor subtype value for a Audio class specific header descriptor. */
|
||||
#define DSUBTYPE_Header 0x01
|
||||
|
||||
/** Audio class descriptor subtype value for 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 OUT endpoint, for host-to-device data transfers. */
|
||||
#define MIDI_STREAM_OUT_EPNUM 1
|
||||
|
||||
/** Endpoint number of the MIDI streaming data IN endpoint, for device-to-host data transfers. */
|
||||
#define MIDI_STREAM_IN_EPNUM 2
|
||||
|
||||
/** Endpoint size in bytes of the Audio isochronous streaming data IN and OUT endpoints. */
|
||||
#define MIDI_STREAM_EPSIZE 64
|
||||
|
||||
/* 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 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
|
||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||
* vary between devices, and which describe the device's usage to the host.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
USB_Descriptor_Interface_t Audio_ControlInterface;
|
||||
USB_Audio_Interface_AC_t Audio_ControlInterface_SPC;
|
||||
USB_Descriptor_Interface_t Audio_StreamInterface;
|
||||
USB_Audio_Interface_MIDI_AS_t Audio_StreamInterface_SPC;
|
||||
USB_MIDI_In_Jack_t MIDI_In_Jack_Emb;
|
||||
USB_MIDI_In_Jack_t MIDI_In_Jack_Ext;
|
||||
USB_MIDI_Out_Jack_t MIDI_Out_Jack_Emb;
|
||||
USB_MIDI_Out_Jack_t MIDI_Out_Jack_Ext;
|
||||
USB_Audio_StreamEndpoint_Std_t MIDI_In_Jack_Endpoint;
|
||||
USB_MIDI_Jack_Endpoint_t MIDI_In_Jack_Endpoint_SPC;
|
||||
USB_Audio_StreamEndpoint_Std_t MIDI_Out_Jack_Endpoint;
|
||||
USB_MIDI_Jack_Endpoint_t MIDI_Out_Jack_Endpoint_SPC;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
/*
|
||||
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 file for Descriptors.c.
|
||||
*/
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
/* Macros: */
|
||||
/** Descriptor header constant to indicate a Audio class interface descriptor. */
|
||||
#define DTYPE_AudioInterface 0x24
|
||||
|
||||
/** Descriptor header constant to indicate a Audio class endpoint descriptor. */
|
||||
#define DTYPE_AudioEndpoint 0x25
|
||||
|
||||
/** Audio class descriptor subtype value for a Audio class specific header descriptor. */
|
||||
#define DSUBTYPE_Header 0x01
|
||||
|
||||
/** Audio class descriptor subtype value for 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 OUT endpoint, for host-to-device data transfers. */
|
||||
#define MIDI_STREAM_OUT_EPNUM 1
|
||||
|
||||
/** Endpoint number of the MIDI streaming data IN endpoint, for device-to-host data transfers. */
|
||||
#define MIDI_STREAM_IN_EPNUM 2
|
||||
|
||||
/** Endpoint size in bytes of the Audio isochronous streaming data IN and OUT endpoints. */
|
||||
#define MIDI_STREAM_EPSIZE 64
|
||||
|
||||
/* 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 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
|
||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||
* vary between devices, and which describe the device's usage to the host.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
USB_Descriptor_Interface_t Audio_ControlInterface;
|
||||
USB_Audio_Interface_AC_t Audio_ControlInterface_SPC;
|
||||
USB_Descriptor_Interface_t Audio_StreamInterface;
|
||||
USB_Audio_Interface_MIDI_AS_t Audio_StreamInterface_SPC;
|
||||
USB_MIDI_In_Jack_t MIDI_In_Jack_Emb;
|
||||
USB_MIDI_In_Jack_t MIDI_In_Jack_Ext;
|
||||
USB_MIDI_Out_Jack_t MIDI_Out_Jack_Emb;
|
||||
USB_MIDI_Out_Jack_t MIDI_Out_Jack_Ext;
|
||||
USB_Audio_StreamEndpoint_Std_t MIDI_In_Jack_Endpoint;
|
||||
USB_MIDI_Jack_Endpoint_t MIDI_In_Jack_Endpoint_SPC;
|
||||
USB_Audio_StreamEndpoint_Std_t MIDI_Out_Jack_Endpoint;
|
||||
USB_MIDI_Jack_Endpoint_t MIDI_Out_Jack_Endpoint_SPC;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,217 +1,217 @@
|
|||
/*
|
||||
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
|
||||
*
|
||||
* Main source file for the MIDI input demo. This file contains the main tasks of the demo and
|
||||
* is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
#include "MIDI.h"
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
sei();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
MIDI_Task();
|
||||
USB_USBTask();
|
||||
}
|
||||
}
|
||||
|
||||
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
||||
void SetupHardware(void)
|
||||
{
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
|
||||
/* Hardware Initialization */
|
||||
Joystick_Init();
|
||||
LEDs_Init();
|
||||
Buttons_Init();
|
||||
USB_Init();
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */
|
||||
void EVENT_USB_Device_Connect(void)
|
||||
{
|
||||
/* Indicate USB enumerating */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
|
||||
* the status LEDs, disables the sample update and PWM output timers and stops the USB and MIDI management tasks.
|
||||
*/
|
||||
void EVENT_USB_Device_Disconnect(void)
|
||||
{
|
||||
/* Indicate USB not ready */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration
|
||||
* of the USB device after enumeration - the device endpoints are configured and the MIDI management task started.
|
||||
*/
|
||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
/* Indicate USB connected and ready */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
|
||||
/* Setup MIDI stream endpoints */
|
||||
if (!(Endpoint_ConfigureEndpoint(MIDI_STREAM_OUT_EPNUM, EP_TYPE_BULK,
|
||||
ENDPOINT_DIR_OUT, MIDI_STREAM_EPSIZE,
|
||||
ENDPOINT_BANK_SINGLE)))
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
if (!(Endpoint_ConfigureEndpoint(MIDI_STREAM_IN_EPNUM, EP_TYPE_BULK,
|
||||
ENDPOINT_DIR_IN, MIDI_STREAM_EPSIZE,
|
||||
ENDPOINT_BANK_SINGLE)))
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/** Task to handle the generation of MIDI note change events in response to presses of the board joystick, and send them
|
||||
* to the host.
|
||||
*/
|
||||
void MIDI_Task(void)
|
||||
{
|
||||
static uint8_t PrevJoystickStatus;
|
||||
|
||||
/* Device must be connected and configured for the task to run */
|
||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||
return;
|
||||
|
||||
Endpoint_SelectEndpoint(MIDI_STREAM_IN_EPNUM);
|
||||
|
||||
if (Endpoint_IsINReady())
|
||||
{
|
||||
uint8_t MIDICommand = 0;
|
||||
uint8_t MIDIPitch;
|
||||
|
||||
uint8_t JoystickStatus = Joystick_GetStatus();
|
||||
uint8_t JoystickChanges = (JoystickStatus ^ PrevJoystickStatus);
|
||||
|
||||
/* Get board button status - if pressed use channel 10 (percussion), otherwise use channel 1 */
|
||||
uint8_t Channel = ((Buttons_GetStatus() & BUTTONS_BUTTON1) ? MIDI_CHANNEL(10) : MIDI_CHANNEL(1));
|
||||
|
||||
if (JoystickChanges & JOY_LEFT)
|
||||
{
|
||||
MIDICommand = ((JoystickStatus & JOY_LEFT)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||
MIDIPitch = 0x3C;
|
||||
}
|
||||
|
||||
if (JoystickChanges & JOY_UP)
|
||||
{
|
||||
MIDICommand = ((JoystickStatus & JOY_UP)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||
MIDIPitch = 0x3D;
|
||||
}
|
||||
|
||||
if (JoystickChanges & JOY_RIGHT)
|
||||
{
|
||||
MIDICommand = ((JoystickStatus & JOY_RIGHT)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||
MIDIPitch = 0x3E;
|
||||
}
|
||||
|
||||
if (JoystickChanges & JOY_DOWN)
|
||||
{
|
||||
MIDICommand = ((JoystickStatus & JOY_DOWN)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||
MIDIPitch = 0x3F;
|
||||
}
|
||||
|
||||
if (JoystickChanges & JOY_PRESS)
|
||||
{
|
||||
MIDICommand = ((JoystickStatus & JOY_PRESS)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||
MIDIPitch = 0x3B;
|
||||
}
|
||||
|
||||
/* Check if a MIDI command is to be sent */
|
||||
if (MIDICommand)
|
||||
{
|
||||
USB_MIDI_EventPacket_t MIDIEvent = (USB_MIDI_EventPacket_t)
|
||||
{
|
||||
.CableNumber = 0,
|
||||
.Command = (MIDICommand >> 4),
|
||||
|
||||
.Data1 = MIDICommand | Channel,
|
||||
.Data2 = MIDIPitch,
|
||||
.Data3 = MIDI_STANDARD_VELOCITY,
|
||||
};
|
||||
|
||||
/* Write the MIDI event packet to the endpoint */
|
||||
Endpoint_Write_Stream_LE(&MIDIEvent, sizeof(MIDIEvent));
|
||||
|
||||
/* Send the data in the endpoint to the host */
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
/* Save previous joystick value for next joystick change detection */
|
||||
PrevJoystickStatus = JoystickStatus;
|
||||
}
|
||||
|
||||
/* Select the MIDI OUT stream */
|
||||
Endpoint_SelectEndpoint(MIDI_STREAM_OUT_EPNUM);
|
||||
|
||||
/* Check if a MIDI command has been received */
|
||||
if (Endpoint_IsOUTReceived())
|
||||
{
|
||||
USB_MIDI_EventPacket_t MIDIEvent;
|
||||
|
||||
/* Read the MIDI event packet from the endpoint */
|
||||
Endpoint_Read_Stream_LE(&MIDIEvent, sizeof(MIDIEvent));
|
||||
|
||||
/* Check to see if the sent command is a note on message with a non-zero velocity */
|
||||
if ((MIDIEvent.Command == (MIDI_COMMAND_NOTE_ON >> 4)) && (MIDIEvent.Data3 > 0))
|
||||
{
|
||||
/* Change LEDs depending on the pitch of the sent note */
|
||||
LEDs_SetAllLEDs(MIDIEvent.Data2 > 64 ? LEDS_LED1 : LEDS_LED2);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Turn off all LEDs in response to non Note On messages */
|
||||
LEDs_SetAllLEDs(LEDS_NO_LEDS);
|
||||
}
|
||||
|
||||
/* Clear the endpoint ready for new packet */
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
}
|
||||
/*
|
||||
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
|
||||
*
|
||||
* Main source file for the MIDI input demo. This file contains the main tasks of the demo and
|
||||
* is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
#include "MIDI.h"
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
sei();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
MIDI_Task();
|
||||
USB_USBTask();
|
||||
}
|
||||
}
|
||||
|
||||
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
||||
void SetupHardware(void)
|
||||
{
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
|
||||
/* Hardware Initialization */
|
||||
Joystick_Init();
|
||||
LEDs_Init();
|
||||
Buttons_Init();
|
||||
USB_Init();
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */
|
||||
void EVENT_USB_Device_Connect(void)
|
||||
{
|
||||
/* Indicate USB enumerating */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
|
||||
* the status LEDs, disables the sample update and PWM output timers and stops the USB and MIDI management tasks.
|
||||
*/
|
||||
void EVENT_USB_Device_Disconnect(void)
|
||||
{
|
||||
/* Indicate USB not ready */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration
|
||||
* of the USB device after enumeration - the device endpoints are configured and the MIDI management task started.
|
||||
*/
|
||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
/* Indicate USB connected and ready */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
|
||||
/* Setup MIDI stream endpoints */
|
||||
if (!(Endpoint_ConfigureEndpoint(MIDI_STREAM_OUT_EPNUM, EP_TYPE_BULK,
|
||||
ENDPOINT_DIR_OUT, MIDI_STREAM_EPSIZE,
|
||||
ENDPOINT_BANK_SINGLE)))
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
if (!(Endpoint_ConfigureEndpoint(MIDI_STREAM_IN_EPNUM, EP_TYPE_BULK,
|
||||
ENDPOINT_DIR_IN, MIDI_STREAM_EPSIZE,
|
||||
ENDPOINT_BANK_SINGLE)))
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/** Task to handle the generation of MIDI note change events in response to presses of the board joystick, and send them
|
||||
* to the host.
|
||||
*/
|
||||
void MIDI_Task(void)
|
||||
{
|
||||
static uint8_t PrevJoystickStatus;
|
||||
|
||||
/* Device must be connected and configured for the task to run */
|
||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||
return;
|
||||
|
||||
Endpoint_SelectEndpoint(MIDI_STREAM_IN_EPNUM);
|
||||
|
||||
if (Endpoint_IsINReady())
|
||||
{
|
||||
uint8_t MIDICommand = 0;
|
||||
uint8_t MIDIPitch;
|
||||
|
||||
uint8_t JoystickStatus = Joystick_GetStatus();
|
||||
uint8_t JoystickChanges = (JoystickStatus ^ PrevJoystickStatus);
|
||||
|
||||
/* Get board button status - if pressed use channel 10 (percussion), otherwise use channel 1 */
|
||||
uint8_t Channel = ((Buttons_GetStatus() & BUTTONS_BUTTON1) ? MIDI_CHANNEL(10) : MIDI_CHANNEL(1));
|
||||
|
||||
if (JoystickChanges & JOY_LEFT)
|
||||
{
|
||||
MIDICommand = ((JoystickStatus & JOY_LEFT)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||
MIDIPitch = 0x3C;
|
||||
}
|
||||
|
||||
if (JoystickChanges & JOY_UP)
|
||||
{
|
||||
MIDICommand = ((JoystickStatus & JOY_UP)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||
MIDIPitch = 0x3D;
|
||||
}
|
||||
|
||||
if (JoystickChanges & JOY_RIGHT)
|
||||
{
|
||||
MIDICommand = ((JoystickStatus & JOY_RIGHT)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||
MIDIPitch = 0x3E;
|
||||
}
|
||||
|
||||
if (JoystickChanges & JOY_DOWN)
|
||||
{
|
||||
MIDICommand = ((JoystickStatus & JOY_DOWN)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||
MIDIPitch = 0x3F;
|
||||
}
|
||||
|
||||
if (JoystickChanges & JOY_PRESS)
|
||||
{
|
||||
MIDICommand = ((JoystickStatus & JOY_PRESS)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||
MIDIPitch = 0x3B;
|
||||
}
|
||||
|
||||
/* Check if a MIDI command is to be sent */
|
||||
if (MIDICommand)
|
||||
{
|
||||
USB_MIDI_EventPacket_t MIDIEvent = (USB_MIDI_EventPacket_t)
|
||||
{
|
||||
.CableNumber = 0,
|
||||
.Command = (MIDICommand >> 4),
|
||||
|
||||
.Data1 = MIDICommand | Channel,
|
||||
.Data2 = MIDIPitch,
|
||||
.Data3 = MIDI_STANDARD_VELOCITY,
|
||||
};
|
||||
|
||||
/* Write the MIDI event packet to the endpoint */
|
||||
Endpoint_Write_Stream_LE(&MIDIEvent, sizeof(MIDIEvent));
|
||||
|
||||
/* Send the data in the endpoint to the host */
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
/* Save previous joystick value for next joystick change detection */
|
||||
PrevJoystickStatus = JoystickStatus;
|
||||
}
|
||||
|
||||
/* Select the MIDI OUT stream */
|
||||
Endpoint_SelectEndpoint(MIDI_STREAM_OUT_EPNUM);
|
||||
|
||||
/* Check if a MIDI command has been received */
|
||||
if (Endpoint_IsOUTReceived())
|
||||
{
|
||||
USB_MIDI_EventPacket_t MIDIEvent;
|
||||
|
||||
/* Read the MIDI event packet from the endpoint */
|
||||
Endpoint_Read_Stream_LE(&MIDIEvent, sizeof(MIDIEvent));
|
||||
|
||||
/* Check to see if the sent command is a note on message with a non-zero velocity */
|
||||
if ((MIDIEvent.Command == (MIDI_COMMAND_NOTE_ON >> 4)) && (MIDIEvent.Data3 > 0))
|
||||
{
|
||||
/* Change LEDs depending on the pitch of the sent note */
|
||||
LEDs_SetAllLEDs(MIDIEvent.Data2 > 64 ? LEDS_LED1 : LEDS_LED2);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Turn off all LEDs in response to non Note On messages */
|
||||
LEDs_SetAllLEDs(LEDS_NO_LEDS);
|
||||
}
|
||||
|
||||
/* Clear the endpoint ready for new packet */
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,103 +1,103 @@
|
|||
/*
|
||||
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 file for AudioOutput.c.
|
||||
*/
|
||||
|
||||
#ifndef _AUDIO_OUTPUT_H_
|
||||
#define _AUDIO_OUTPUT_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/power.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
#include <LUFA/Version.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/Board/Joystick.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/Board/Buttons.h>
|
||||
|
||||
/* 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. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
|
||||
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
|
||||
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
|
||||
|
||||
/** 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)
|
||||
|
||||
/* 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: */
|
||||
void SetupHardware(void);
|
||||
void MIDI_Task(void);
|
||||
|
||||
void EVENT_USB_Device_Connect(void);
|
||||
void EVENT_USB_Device_Disconnect(void);
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
|
||||
#endif
|
||||
/*
|
||||
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 file for AudioOutput.c.
|
||||
*/
|
||||
|
||||
#ifndef _AUDIO_OUTPUT_H_
|
||||
#define _AUDIO_OUTPUT_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/power.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
#include <LUFA/Version.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/Board/Joystick.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/Board/Buttons.h>
|
||||
|
||||
/* 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. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
|
||||
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
|
||||
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
|
||||
|
||||
/** 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)
|
||||
|
||||
/* 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: */
|
||||
void SetupHardware(void);
|
||||
void MIDI_Task(void);
|
||||
|
||||
void EVENT_USB_Device_Connect(void);
|
||||
void EVENT_USB_Device_Disconnect(void);
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,74 +1,74 @@
|
|||
/** \file
|
||||
*
|
||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
/** \mainpage MIDI Input Device Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
*
|
||||
* The following list indicates what microcontrollers are compatible with this demo.
|
||||
*
|
||||
* - Series 7 USB AVRs
|
||||
* - Series 6 USB AVRs
|
||||
* - Series 4 USB AVRs
|
||||
* - Series 2 USB AVRs
|
||||
*
|
||||
* \section SSec_Info USB Information:
|
||||
*
|
||||
* The following table gives a rundown of the USB utilization of this demo.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>USB Mode:</b></td>
|
||||
* <td>Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Class:</b></td>
|
||||
* <td>Audio Class</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Standard Audio Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Relevant Standards:</b></td>
|
||||
* <td>USBIF Audio Class Specification \n
|
||||
* USB-MIDI Audio Class Extension Specification \n
|
||||
* General MIDI Specification</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Usable Speeds:</b></td>
|
||||
* <td>Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* MIDI demonstration application. This gives a simple reference
|
||||
* application for implementing the USB-MIDI class in USB devices.
|
||||
* It is built upon the USB Audio class.
|
||||
*
|
||||
* Joystick movements are translated into note on/off messages and
|
||||
* are sent to the host PC as MIDI streams which can be read by any
|
||||
* MIDI program supporting MIDI IN devices.
|
||||
*
|
||||
* If the HWB is not pressed, channel 1 (default piano) is used. If
|
||||
* the HWB is set, then channel 10 (default percussion) is selected.
|
||||
*
|
||||
* This device implements MIDI-THRU mode, with the IN MIDI data being
|
||||
* generated by the device itself. OUT MIDI data is discarded.
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td>
|
||||
* None
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
/** \file
|
||||
*
|
||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
/** \mainpage MIDI Input Device Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
*
|
||||
* The following list indicates what microcontrollers are compatible with this demo.
|
||||
*
|
||||
* - Series 7 USB AVRs
|
||||
* - Series 6 USB AVRs
|
||||
* - Series 4 USB AVRs
|
||||
* - Series 2 USB AVRs
|
||||
*
|
||||
* \section SSec_Info USB Information:
|
||||
*
|
||||
* The following table gives a rundown of the USB utilization of this demo.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>USB Mode:</b></td>
|
||||
* <td>Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Class:</b></td>
|
||||
* <td>Audio Class</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Standard Audio Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Relevant Standards:</b></td>
|
||||
* <td>USBIF Audio Class Specification \n
|
||||
* USB-MIDI Audio Class Extension Specification \n
|
||||
* General MIDI Specification</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Usable Speeds:</b></td>
|
||||
* <td>Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* MIDI demonstration application. This gives a simple reference
|
||||
* application for implementing the USB-MIDI class in USB devices.
|
||||
* It is built upon the USB Audio class.
|
||||
*
|
||||
* Joystick movements are translated into note on/off messages and
|
||||
* are sent to the host PC as MIDI streams which can be read by any
|
||||
* MIDI program supporting MIDI IN devices.
|
||||
*
|
||||
* If the HWB is not pressed, channel 1 (default piano) is used. If
|
||||
* the HWB is set, then channel 10 (default percussion) is selected.
|
||||
*
|
||||
* This device implements MIDI-THRU mode, with the IN MIDI data being
|
||||
* generated by the device itself. OUT MIDI data is discarded.
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td>
|
||||
* None
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue