summaryrefslogtreecommitdiffstats
path: root/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput')
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/AudioInput.c274
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/AudioInput.h94
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/AudioInput.txt92
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Config/AppConfig.h51
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Config/LUFAConfig.h93
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Descriptors.c312
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Descriptors.h106
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/asf.xml52
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/doxyfile2364
-rw-r--r--tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/makefile38
10 files changed, 3476 insertions, 0 deletions
diff --git a/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/AudioInput.c b/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/AudioInput.c
new file mode 100644
index 0000000000..7c1cf46076
--- /dev/null
+++ b/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/AudioInput.c
@@ -0,0 +1,274 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2014.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2014 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 disclaims 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 AudioInput demo. This file contains the main tasks of
+ * the demo and is responsible for the initial application hardware configuration.
+ */
+
+#include "AudioInput.h"
+
+/** LUFA Audio Class driver interface configuration and state information. This structure is
+ * passed to all Audio Class driver functions, so that multiple instances of the same class
+ * within a device can be differentiated from one another.
+ */
+USB_ClassInfo_Audio_Device_t Microphone_Audio_Interface =
+ {
+ .Config =
+ {
+ .ControlInterfaceNumber = INTERFACE_ID_AudioControl,
+ .StreamingInterfaceNumber = INTERFACE_ID_AudioStream,
+ .DataINEndpoint =
+ {
+ .Address = AUDIO_STREAM_EPADDR,
+ .Size = AUDIO_STREAM_EPSIZE,
+ .Banks = 2,
+ },
+ },
+ };
+
+/** Current audio sampling frequency of the streaming audio endpoint. */
+static uint32_t CurrentAudioSampleFrequency = 48000;
+
+
+/** Main program entry point. This routine contains the overall program flow, including initial
+ * setup of all components and the main program loop.
+ */
+int main(void)
+{
+ SetupHardware();
+
+ LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
+ GlobalInterruptEnable();
+
+ for (;;)
+ {
+ Audio_Device_USBTask(&Microphone_Audio_Interface);
+ USB_USBTask();
+ }
+}
+
+/** Configures the board hardware and chip peripherals for the demo's functionality. */
+void SetupHardware(void)
+{
+#if (ARCH == ARCH_AVR8)
+ /* Disable watchdog if enabled by bootloader/fuses */
+ MCUSR &= ~(1 << WDRF);
+ wdt_disable();
+
+ /* Disable clock division */
+ clock_prescale_set(clock_div_1);
+#endif
+
+ /* Hardware Initialization */
+ LEDs_Init();
+ Buttons_Init();
+ ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_32);
+ ADC_SetupChannel(MIC_IN_ADC_CHANNEL);
+ USB_Init();
+
+ /* Start the ADC conversion in free running mode */
+ ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | ADC_GET_CHANNEL_MASK(MIC_IN_ADC_CHANNEL));
+}
+
+/** ISR to handle the reloading of the data endpoint with the next sample. */
+ISR(TIMER0_COMPA_vect, ISR_BLOCK)
+{
+ uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint();
+
+ /* Check that the USB bus is ready for the next sample to write */
+ if (Audio_Device_IsReadyForNextSample(&Microphone_Audio_Interface))
+ {
+ int16_t AudioSample;
+
+ #if defined(USE_TEST_TONE)
+ static uint8_t SquareWaveSampleCount;
+ static int16_t CurrentWaveValue;
+
+ /* In test tone mode, generate a square wave at 1/256 of the sample rate */
+ if (SquareWaveSampleCount++ == 0xFF)
+ CurrentWaveValue ^= 0x8000;
+
+ /* Only generate audio if the board button is being pressed */
+ AudioSample = (Buttons_GetStatus() & BUTTONS_BUTTON1) ? CurrentWaveValue : 0;
+ #else
+ /* Audio sample is ADC value scaled to fit the entire range */
+ AudioSample = ((SAMPLE_MAX_RANGE / ADC_MAX_RANGE) * ADC_GetResult());
+
+ #if defined(MICROPHONE_BIASED_TO_HALF_RAIL)
+ /* Microphone is biased to half rail voltage, subtract the bias from the sample value */
+ AudioSample -= (SAMPLE_MAX_RANGE / 2);
+ #endif
+ #endif
+
+ Audio_Device_WriteSample16(&Microphone_Audio_Interface, AudioSample);
+ }
+
+ Endpoint_SelectEndpoint(PrevEndpoint);
+}
+
+/** Event handler for the library USB Connection event. */
+void EVENT_USB_Device_Connect(void)
+{
+ LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
+
+ /* Sample reload timer initialization */
+ TIMSK0 = (1 << OCIE0A);
+ OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1);
+ TCCR0A = (1 << WGM01); // CTC mode
+ TCCR0B = (1 << CS01); // Fcpu/8 speed
+}
+
+/** Event handler for the library USB Disconnection event. */
+void EVENT_USB_Device_Disconnect(void)
+{
+ /* Stop the sample reload timer */
+ TCCR0B = 0;
+
+ LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
+}
+
+/** Event handler for the library USB Configuration Changed event. */
+void EVENT_USB_Device_ConfigurationChanged(void)
+{
+ bool ConfigSuccess = true;
+
+ ConfigSuccess &= Audio_Device_ConfigureEndpoints(&Microphone_Audio_Interface);
+
+ LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
+}
+
+/** Event handler for the library USB Control Request reception event. */
+void EVENT_USB_Device_ControlRequest(void)
+{
+ Audio_Device_ProcessControlRequest(&Microphone_Audio_Interface);
+}
+
+/** Audio class driver callback for the setting and retrieval of streaming endpoint properties. This callback must be implemented
+ * in the user application to handle property manipulations on streaming audio endpoints.
+ *
+ * When the DataLength parameter is NULL, this callback should only indicate whether the specified operation is valid for
+ * the given endpoint index, and should return as fast as possible. When non-NULL, this value may be altered for GET operations
+ * to indicate the size of the retrieved data.
+ *
+ * \note The length of the retrieved data stored into the Data buffer on GET operations should not exceed the initial value
+ * of the \c DataLength parameter.
+ *
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
+ * \param[in] EndpointProperty Property of the endpoint to get or set, a value from Audio_ClassRequests_t.
+ * \param[in] EndpointAddress Address of the streaming endpoint whose property is being referenced.
+ * \param[in] EndpointControl Parameter of the endpoint to get or set, a value from Audio_EndpointControls_t.
+ * \param[in,out] DataLength For SET operations, the length of the parameter data to set. For GET operations, the maximum
+ * length of the retrieved data. When NULL, the function should return whether the given property
+ * and parameter is valid for the requested endpoint without reading or modifying the Data buffer.
+ * \param[in,out] Data Pointer to a location where the parameter data is stored for SET operations, or where
+ * the retrieved data is to be stored for GET operations.
+ *
+ * \return Boolean \c true if the property get/set was successful, \c false otherwise
+ */
+bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
+ const uint8_t EndpointProperty,
+ const uint8_t EndpointAddress,
+ const uint8_t EndpointControl,
+ uint16_t* const DataLength,
+ uint8_t* Data)
+{
+ /* Check the requested endpoint to see if a supported endpoint is being manipulated */
+ if (EndpointAddress == Microphone_Audio_Interface.Config.DataINEndpoint.Address)
+ {
+ /* Check the requested control to see if a supported control is being manipulated */
+ if (EndpointControl == AUDIO_EPCONTROL_SamplingFreq)
+ {
+ switch (EndpointProperty)
+ {
+ case AUDIO_REQ_SetCurrent:
+ /* Check if we are just testing for a valid property, or actually adjusting it */
+ if (DataLength != NULL)
+ {
+ /* Set the new sampling frequency to the value given by the host */
+ CurrentAudioSampleFrequency = (((uint32_t)Data[2] << 16) | ((uint32_t)Data[1] << 8) | (uint32_t)Data[0]);
+
+ /* Adjust sample reload timer to the new frequency */
+ OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1);
+ }
+
+ return true;
+ case AUDIO_REQ_GetCurrent:
+ /* Check if we are just testing for a valid property, or actually reading it */
+ if (DataLength != NULL)
+ {
+ *DataLength = 3;
+
+ Data[2] = (CurrentAudioSampleFrequency >> 16);
+ Data[1] = (CurrentAudioSampleFrequency >> 8);
+ Data[0] = (CurrentAudioSampleFrequency & 0xFF);
+ }
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+/** Audio class driver callback for the setting and retrieval of streaming interface properties. This callback must be implemented
+ * in the user application to handle property manipulations on streaming audio interfaces.
+ *
+ * When the DataLength parameter is NULL, this callback should only indicate whether the specified operation is valid for
+ * the given entity and should return as fast as possible. When non-NULL, this value may be altered for GET operations
+ * to indicate the size of the retrieved data.
+ *
+ * \note The length of the retrieved data stored into the Data buffer on GET operations should not exceed the initial value
+ * of the \c DataLength parameter.
+ *
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.
+ * \param[in] Property Property of the interface to get or set, a value from Audio_ClassRequests_t.
+ * \param[in] EntityAddress Address of the audio entity whose property is being referenced.
+ * \param[in] Parameter Parameter of the entity to get or set, specific to each type of entity (see USB Audio specification).
+ * \param[in,out] DataLength For SET operations, the length of the parameter data to set. For GET operations, the maximum
+ * length of the retrieved data. When NULL, the function should return whether the given property
+ * and parameter is valid for the requested endpoint without reading or modifying the Data buffer.
+ * \param[in,out] Data Pointer to a location where the parameter data is stored for SET operations, or where
+ * the retrieved data is to be stored for GET operations.
+ *
+ * \return Boolean \c true if the property GET/SET was successful, \c false otherwise
+ */
+bool CALLBACK_Audio_Device_GetSetInterfaceProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
+ const uint8_t Property,
+ const uint8_t EntityAddress,
+ const uint16_t Parameter,
+ uint16_t* const DataLength,
+ uint8_t* Data)
+{
+ /* No audio interface entities in the device descriptor, thus no properties to get or set. */
+ return false;
+}
diff --git a/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/AudioInput.h b/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/AudioInput.h
new file mode 100644
index 0000000000..0090f2a0f2
--- /dev/null
+++ b/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/AudioInput.h
@@ -0,0 +1,94 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2014.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2014 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 disclaims 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 AudioInput.c.
+ */
+
+#ifndef _AUDIO_INPUT_H_
+#define _AUDIO_INPUT_H_
+
+ /* Includes: */
+ #include <avr/io.h>
+ #include <avr/wdt.h>
+ #include <avr/power.h>
+ #include <avr/interrupt.h>
+
+ #include <LUFA/Drivers/Board/LEDs.h>
+ #include <LUFA/Drivers/Board/Buttons.h>
+ #include <LUFA/Drivers/Peripheral/ADC.h>
+ #include <LUFA/Drivers/USB/USB.h>
+ #include <LUFA/Platform/Platform.h>
+
+ #include "Descriptors.h"
+ #include "Config/AppConfig.h"
+
+ /* Macros: */
+ /** Maximum audio sample value for the microphone input. */
+ #define SAMPLE_MAX_RANGE 0xFFFF
+
+ /** Maximum ADC range for the microphone input. */
+ #define ADC_MAX_RANGE 0x3FF
+
+ /** 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)
+
+ /* Function Prototypes: */
+ void SetupHardware(void);
+
+ void EVENT_USB_Device_Connect(void);
+ void EVENT_USB_Device_Disconnect(void);
+ void EVENT_USB_Device_ConfigurationChanged(void);
+ void EVENT_USB_Device_ControlRequest(void);
+
+ bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
+ const uint8_t EndpointProperty,
+ const uint8_t EndpointAddress,
+ const uint8_t EndpointControl,
+ uint16_t* const DataLength,
+ uint8_t* Data) ATTR_NON_NULL_PTR_ARG(1);
+ bool CALLBACK_Audio_Device_GetSetInterfaceProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,
+ const uint8_t Property,
+ const uint8_t EntityAddress,
+ const uint16_t Parameter,
+ uint16_t* const DataLength,
+ uint8_t* Data);
+#endif
+
diff --git a/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/AudioInput.txt b/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/AudioInput.txt
new file mode 100644
index 0000000000..4b0594244d
--- /dev/null
+++ b/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/AudioInput.txt
@@ -0,0 +1,92 @@
+/** \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 Audio Input Device Demo
+ *
+ * \section Sec_Compat Demo Compatibility:
+ *
+ * The following list indicates what microcontrollers are compatible with this demo.
+ *
+ * \li Series 7 USB AVRs (AT90USBxxx7)
+ * \li Series 6 USB AVRs (AT90USBxxx6)
+ * \li Series 4 USB AVRs (ATMEGAxxU4)
+ *
+ * \section Sec_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 1.0 Class Specification \n
+ * USBIF Audio 1.0 Class Terminal Types Specification \n
+ * USBIF Audio 1.0 Data Formats Specification</td>
+ * </tr>
+ * <tr>
+ * <td><b>Supported USB Speeds:</b></td>
+ * <td>Full Speed Mode</td>
+ * </tr>
+ * </table>
+ *
+ * \section Sec_Description Project Description:
+ *
+ * Audio demonstration application. This gives a simple reference
+ * application for implementing a USB Audio Input device using the
+ * basic USB Audio 1.0 drivers in all modern OSes (i.e. no special drivers
+ * required).
+ *
+ * On start-up the system will automatically enumerate and function as a
+ * USB microphone. By default, the demo will produce a square wave test tone
+ * when the board button is pressed. If USE_TEST_TONE is not defined in the
+ * project makefile, incoming audio from the ADC channel 1 will be sampled
+ * and sent to the host computer instead.
+ *
+ * When in microphone mode, connect a microphone to the ADC channel 2.
+ *
+ * Under Windows, if a driver request dialogue pops up, select the option
+ * to automatically install the appropriate drivers.
+ *
+ * \section Sec_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>
+ * <th><b>Define Name:</b></th>
+ * <th><b>Location:</b></th>
+ * <th><b>Description:</b></th>
+ * </tr>
+ * <tr>
+ * <td>MIC_IN_ADC_CHANNEL</td>
+ * <td>AppConfig.h</td>
+ * <td>Sets the ADC channel used by the demo for the input audio samples from an attached microphone.</td>
+ * </tr>
+ * <tr>
+ * <td>USE_TEST_TONE</td>
+ * <td>AppConfig.h</td>
+ * <td>When defined, this alters the demo to produce a square wave test tone when the first board button is pressed
+ * instead of sampling the board microphone.</td>
+ * </tr>
+ * <tr>
+ * <td>MICROPHONE_BIASED_TO_HALF_RAIL</td>
+ * <td>AppConfig.h</td>
+ * <td>When defined, this alters the demo so that the half VCC bias of the microphone input is subtracted.</td>
+ * </tr>
+ * </table>
+ */
+
diff --git a/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Config/AppConfig.h b/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Config/AppConfig.h
new file mode 100644
index 0000000000..8360102f64
--- /dev/null
+++ b/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Config/AppConfig.h
@@ -0,0 +1,51 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2014.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2014 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 disclaims 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
+ * \brief Application Configuration Header File
+ *
+ * This is a header file which is be used to configure some of
+ * the application's compile time options, as an alternative to
+ * specifying the compile time constants supplied through a
+ * makefile or build system.
+ *
+ * For information on what each token does, refer to the
+ * \ref Sec_Options section of the application documentation.
+ */
+
+#ifndef _APP_CONFIG_H_
+#define _APP_CONFIG_H_
+
+ #define MIC_IN_ADC_CHANNEL 2
+
+ #define MICROPHONE_BIASED_TO_HALF_RAIL
+ #define USE_TEST_TONE
+
+#endif
diff --git a/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Config/LUFAConfig.h b/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Config/LUFAConfig.h
new file mode 100644
index 0000000000..796221604d
--- /dev/null
+++ b/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Config/LUFAConfig.h
@@ -0,0 +1,93 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2014.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2014 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 disclaims 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
+ * \brief LUFA Library Configuration Header File
+ *
+ * This header file is used to configure LUFA's compile time options,
+ * as an alternative to the compile time constants supplied through
+ * a makefile.
+ *
+ * For information on what each token does, refer to the LUFA
+ * manual section "Summary of Compile Tokens".
+ */
+
+#ifndef _LUFA_CONFIG_H_
+#define _LUFA_CONFIG_H_
+
+ #if (ARCH == ARCH_AVR8)
+
+ /* Non-USB Related Configuration Tokens: */
+// #define DISABLE_TERMINAL_CODES
+
+ /* USB Class Driver Related Tokens: */
+// #define HID_HOST_BOOT_PROTOCOL_ONLY
+// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}
+// #define HID_USAGE_STACK_DEPTH {Insert Value Here}
+// #define HID_MAX_COLLECTIONS {Insert Value Here}
+// #define HID_MAX_REPORTITEMS {Insert Value Here}
+// #define HID_MAX_REPORT_IDS {Insert Value Here}
+// #define NO_CLASS_DRIVER_AUTOFLUSH
+
+ /* General USB Driver Related Tokens: */
+// #define ORDERED_EP_CONFIG
+ #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)
+ #define USB_DEVICE_ONLY
+// #define USB_HOST_ONLY
+// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}
+// #define NO_LIMITED_CONTROLLER_CONNECT
+// #define NO_SOF_EVENTS
+
+ /* USB Device Mode Driver Related Tokens: */
+// #define USE_RAM_DESCRIPTORS
+ #define USE_FLASH_DESCRIPTORS
+// #define USE_EEPROM_DESCRIPTORS
+// #define NO_INTERNAL_SERIAL
+ #define FIXED_CONTROL_ENDPOINT_SIZE 8
+// #define DEVICE_STATE_AS_GPIOR {Insert Value Here}
+ #define FIXED_NUM_CONFIGURATIONS 1
+// #define CONTROL_ONLY_DEVICE
+// #define INTERRUPT_CONTROL_ENDPOINT
+// #define NO_DEVICE_REMOTE_WAKEUP
+// #define NO_DEVICE_SELF_POWER
+
+ /* USB Host Mode Driver Related Tokens: */
+// #define HOST_STATE_AS_GPIOR {Insert Value Here}
+// #define USB_HOST_TIMEOUT_MS {Insert Value Here}
+// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}
+// #define NO_AUTO_VBUS_MANAGEMENT
+// #define INVERTED_VBUS_ENABLE_LINE
+
+ #else
+
+ #error Unsupported architecture for this LUFA configuration file.
+
+ #endif
+#endif
diff --git a/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Descriptors.c b/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Descriptors.c
new file mode 100644
index 0000000000..f87ed9761d
--- /dev/null
+++ b/tmk_core/protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Descriptors.c
@@ -0,0 +1,312 @@
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2014.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2014 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 disclaims 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.
+ */
+const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
+{
+ .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
+
+ .USBSpecification = VERSION_BCD(2,0,0),
+ .Class = USB_CSCP_NoDeviceClass,
+ .SubClass = USB_CSCP_NoDeviceSubclass,
+ .Protocol = USB_CSCP_NoDeviceProtocol,
+
+ .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
+
+ .VendorID = 0x03EB,
+ .ProductID = 0x2047,
+ .ReleaseNumber = VERSION_BCD(0,0,2),
+
+ .ManufacturerStrIndex = STRING_ID_Manufacturer,
+ .ProductStrIndex = STRING_ID_Product,
+ .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.
+ */
+const 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_RESERVED | USB_CONFIG_ATTR_SELFPOWERED),
+
+ .MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
+ },
+
+ .Audio_ControlInterface =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
+
+ .InterfaceNumber = INTERFACE_ID_AudioControl,
+ .AlternateSetting = 0,
+
+ .TotalEndpoints = 0,
+
+ .Class = AUDIO_CSCP_AudioClass,
+ .SubClass = AUDIO_CSCP_ControlSubclass,
+ .Protocol = AUDIO_CSCP_ControlProtocol,
+
+ .InterfaceStrIndex = NO_DESCRIPTOR
+ },
+
+ .Audio_ControlInterface_SPC =
+ {
+ .Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface},
+ .Subtype = AUDIO_DSUBTYPE_CSInterface_Header,
+
+ .ACSpecification = VERSION_BCD(1,0,0),
+ .TotalLength = (sizeof(USB_Audio_Descriptor_Interface_AC_t) +
+ sizeof(USB_Audio_Descriptor_InputTerminal_t) +
+ sizeof(USB_Audio_Descriptor_OutputTerminal_t)),
+
+ .InCollection = 1,
+ .InterfaceNumber = INTERFACE_ID_AudioStream,
+ },
+
+ .Audio_InputTerminal =
+ {
+ .Header = {.Size = sizeof(USB_Audio_Descriptor_InputTerminal_t), .Type = DTYPE_CSInterface},
+ .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
+
+ .TerminalID = 0x01,
+ .TerminalType = AUDIO_TERMINAL_IN_MIC,
+ .AssociatedOutputTerminal = 0x00,
+
+ .TotalChannels = 1,
+ .ChannelConfig = 0,
+
+ .ChannelStrIndex = NO_DESCRIPTOR,
+ .TerminalStrIndex = NO_DESCRIPTOR
+ },
+
+ .Audio_OutputTerminal =
+ {
+ .Header = {.Size = sizeof(USB_Audio_Descriptor_OutputTerminal_t), .Type = DTYPE_CSInterface},
+ .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
+
+ .TerminalID = 0x02,
+ .TerminalType = AUDIO_TERMINAL_STREAMING,
+ .AssociatedInputTerminal = 0x00,
+
+ .SourceID = 0x01,
+
+ .TerminalStrIndex = NO_DESCRIPTOR
+ },
+
+ .Audio_StreamInterface_Alt0 =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
+
+ .InterfaceNumber = INTERFACE_ID_AudioStream,
+ .AlternateSetting = 0,
+
+ .TotalEndpoints = 0,
+
+ .Class = AUDIO_CSCP_AudioClass,
+ .SubClass = AUDIO_CSCP_AudioStreamingSubclass,
+ .Protocol = AUDIO_CSCP_StreamingProtocol,
+
+ .InterfaceStrIndex = NO_DESCRIPTOR
+ },
+
+ .Audio_StreamInterface_Alt1 =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
+
+ .InterfaceNumber = INTERFACE_ID_AudioStream,
+ .AlternateSetting = 1,
+
+ .TotalEndpoints = 1,
+
+ .Class = AUDIO_CSCP_AudioClass,
+ .SubClass = AUDIO_CSCP_AudioStreamingSubclass,
+ .Protocol = AUDIO_CSCP_StreamingProtocol,
+
+ .InterfaceStrIndex = NO_DESCRIPTOR
+ },
+
+ .Audio_StreamInterface_SPC =
+ {
+ .Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AS_t), .Type = DTYPE_CSInterface},
+ .Subtype = AUDIO_DSUBTYPE_CSInterface_General,
+
+ .TerminalLink = 0x02,
+
+ .FrameDelay = 1,
+ .AudioFormat = 0x0001
+ },
+
+ .Audio_AudioFormat =
+ {
+ .Header = {.Size = sizeof(USB_Audio_Descriptor_Format_t) +
+ sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates),
+ .Type = DTYPE_CSInterface},
+ .Subtype = AUDIO_DSUBTYPE_CSInterface_FormatType,
+
+ .FormatType = 0x01,
+ .Channels = 0x01,
+
+ .SubFrameSize = 0x02,
+ .BitResolution = 16,
+
+ .TotalDiscreteSampleRates = (sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates) / sizeof(USB_Audio_SampleFreq_t))
+ },
+
+ .Audio_AudioFormatSampleRates =
+ {
+ AUDIO_SAMPLE_FREQ(8000),
+ AUDIO_SAMPLE_FREQ(11025),
+ AUDIO_SAMPLE_FREQ(22050),
+ AUDIO_SAMPLE_FREQ(44100),
+ AUDIO_SAMPLE_FREQ(48000),
+ },
+
+ .Audio_StreamEndpoint =
+ {
+ .Endpoint =
+ {
+ .Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
+
+ .EndpointAddress = AUDIO_STREAM_EPADDR,
+ .Attributes = (EP_TYPE_ISOCHRONOUS | ENDPOINT_ATTR_SYNC | ENDPOINT_USAGE_DATA),
+ .EndpointSize = AUDIO_STREAM_EPSIZE,
+ .PollingIntervalMS = 0x01
+ },
+
+ .Refresh = 0,