From a67bd74e3e8aad87dcee8cf0c0eaaccbe7d00552 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Thu, 4 Jun 2009 02:55:30 +0000 Subject: Minor documentation page updates. Redocumented all device demos, now that they have changed over to the new USB class drivers. Added C linkage to class drivers for C++ support. Added prefixes to most of the class driver constants to prevent name clashes. --- Demos/Device/AudioInput/AudioInput.c | 29 +++++++++++++++++++++++++---- Demos/Device/AudioInput/AudioInput.h | 13 ++++++++++--- Demos/Device/AudioInput/Descriptors.c | 2 +- 3 files changed, 36 insertions(+), 8 deletions(-) (limited to 'Demos/Device/AudioInput') diff --git a/Demos/Device/AudioInput/AudioInput.c b/Demos/Device/AudioInput/AudioInput.c index bcfb04be1..31b3159e0 100644 --- a/Demos/Device/AudioInput/AudioInput.c +++ b/Demos/Device/AudioInput/AudioInput.c @@ -28,16 +28,29 @@ 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_t Microphone_Audio_Interface = { - .InterfaceNumber = 0, + .StreamingInterfaceNumber = 1, - .DataINEndpointNumber = AUDIO_STREAM_EPNUM, - .DataINEndpointSize = AUDIO_STREAM_EPSIZE, + .DataINEndpointNumber = AUDIO_STREAM_EPNUM, + .DataINEndpointSize = AUDIO_STREAM_EPSIZE, }; - + +/** 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(); @@ -53,6 +66,7 @@ int main(void) } } +/** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { /* Disable watchdog if enabled by bootloader/fuses */ @@ -72,6 +86,9 @@ void SetupHardware(void) ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | MIC_IN_ADC_CHANNEL); } +/** Processes the next audio sample by reading the last ADC conversion and writing it to the audio + * interface, each time the sample reload timer period elapses to give a constant sample rate. + */ void ProcessNextSample(void) { if ((TIFR0 & (1 << OCF0A)) && USB_Audio_IsReadyForNextSample(&Microphone_Audio_Interface)) @@ -90,6 +107,7 @@ void ProcessNextSample(void) } } +/** Event handler for the library USB Connection event. */ void EVENT_USB_Connect(void) { LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); @@ -100,6 +118,7 @@ void EVENT_USB_Connect(void) TCCR0B = (1 << CS00); // Fcpu speed } +/** Event handler for the library USB Disconnection event. */ void EVENT_USB_Disconnect(void) { /* Stop the sample reload timer */ @@ -108,6 +127,7 @@ void EVENT_USB_Disconnect(void) LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); } +/** Event handler for the library USB Configuration Changed event. */ void EVENT_USB_ConfigurationChanged(void) { LEDs_SetAllLEDs(LEDMASK_USB_READY); @@ -116,6 +136,7 @@ void EVENT_USB_ConfigurationChanged(void) LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } +/** Event handler for the library USB Unhandled Control Packet event. */ void EVENT_USB_UnhandledControlPacket(void) { USB_Audio_ProcessControlPacket(&Microphone_Audio_Interface); diff --git a/Demos/Device/AudioInput/AudioInput.h b/Demos/Device/AudioInput/AudioInput.h index e9f56b30a..e4dd7fe66 100644 --- a/Demos/Device/AudioInput/AudioInput.h +++ b/Demos/Device/AudioInput/AudioInput.h @@ -52,18 +52,25 @@ /* Macros: */ /** ADC channel number for the microphone input. */ - #define MIC_IN_ADC_CHANNEL 2 + #define MIC_IN_ADC_CHANNEL 2 /** Maximum ADC sample value for the microphone input. */ - #define SAMPLE_MAX_RANGE 0xFFFF + #define SAMPLE_MAX_RANGE 0xFFFF /** Maximum ADC range for the microphone input. */ - #define ADC_MAX_RANGE 0x3FF + #define ADC_MAX_RANGE 0x3FF /* Macros: */ + /** 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: */ diff --git a/Demos/Device/AudioInput/Descriptors.c b/Demos/Device/AudioInput/Descriptors.c index b8de373d6..6697cfe1d 100644 --- a/Demos/Device/AudioInput/Descriptors.c +++ b/Demos/Device/AudioInput/Descriptors.c @@ -201,7 +201,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .BitResolution = 16, .SampleFrequencyType = (sizeof(ConfigurationDescriptor.AudioFormat.SampleFrequencies) / sizeof(AudioSampleFreq_t)), - .SampleFrequencies = {SAMPLE_FREQ(AUDIO_SAMPLE_FREQUENCY)} + .SampleFrequencies = {AUDIO_SAMPLE_FREQ(AUDIO_SAMPLE_FREQUENCY)} }, .AudioEndpoint = -- cgit v1.2.3