aboutsummaryrefslogtreecommitdiffstats
path: root/Demos
diff options
context:
space:
mode:
Diffstat (limited to 'Demos')
-rw-r--r--Demos/Device/ClassDriver/AudioInput/AudioInput.c6
-rw-r--r--Demos/Device/ClassDriver/AudioInput/Descriptors.h8
-rw-r--r--Demos/Device/ClassDriver/AudioOutput/AudioOutput.c20
-rw-r--r--Demos/Device/ClassDriver/AudioOutput/AudioOutput.h1
-rw-r--r--Demos/Device/ClassDriver/AudioOutput/Descriptors.h8
-rw-r--r--Demos/Device/LowLevel/AudioInput/Descriptors.h8
-rw-r--r--Demos/Device/LowLevel/AudioOutput/AudioOutput.c10
-rw-r--r--Demos/Device/LowLevel/AudioOutput/AudioOutput.h1
-rw-r--r--Demos/Device/LowLevel/AudioOutput/Descriptors.h8
9 files changed, 28 insertions, 42 deletions
diff --git a/Demos/Device/ClassDriver/AudioInput/AudioInput.c b/Demos/Device/ClassDriver/AudioInput/AudioInput.c
index 7b7ca2c11..59d2129f4 100644
--- a/Demos/Device/ClassDriver/AudioInput/AudioInput.c
+++ b/Demos/Device/ClassDriver/AudioInput/AudioInput.c
@@ -62,8 +62,7 @@ int main(void)
for (;;)
{
- if (Microphone_Audio_Interface.State.InterfaceEnabled)
- ProcessNextSample();
+ ProcessNextSample();
Audio_Device_USBTask(&Microphone_Audio_Interface);
USB_USBTask();
@@ -95,6 +94,7 @@ void SetupHardware(void)
*/
void ProcessNextSample(void)
{
+ /* Check if the sample reload timer period has elapsed, and that the USB bus is ready for a new sample */
if ((TIFR0 & (1 << OCF0A)) && Audio_Device_IsReadyForNextSample(&Microphone_Audio_Interface))
{
TIFR0 |= (1 << OCF0A);
@@ -107,7 +107,7 @@ void ProcessNextSample(void)
AudioSample -= (SAMPLE_MAX_RANGE / 2));
#endif
- Audio_Device_WriteSample16(AudioSample);
+ Audio_Device_WriteSample16(&Microphone_Audio_Interface, AudioSample);
}
}
diff --git a/Demos/Device/ClassDriver/AudioInput/Descriptors.h b/Demos/Device/ClassDriver/AudioInput/Descriptors.h
index dca176117..be6415683 100644
--- a/Demos/Device/ClassDriver/AudioInput/Descriptors.h
+++ b/Demos/Device/ClassDriver/AudioInput/Descriptors.h
@@ -43,12 +43,8 @@
#include <avr/pgmspace.h>
/* Macros: */
- #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
- /** Endpoint number of the Audio isochronous streaming data endpoint. */
- #define AUDIO_STREAM_EPNUM 1
- #else
- #define AUDIO_STREAM_EPNUM 3
- #endif
+ /** Endpoint number of the Audio isochronous streaming data endpoint. */
+ #define AUDIO_STREAM_EPNUM 1
/** Endpoint size in bytes of the Audio isochronous streaming data endpoint. The Windows audio stack requires
* at least 192 bytes for correct output, thus the smaller 128 byte maximum endpoint size on some of the smaller
diff --git a/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c b/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c
index 9a63af68a..2caf6faa6 100644
--- a/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c
+++ b/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c
@@ -46,8 +46,8 @@ USB_ClassInfo_Audio_Device_t Speaker_Audio_Interface =
{
.StreamingInterfaceNumber = 1,
- .DataINEndpointNumber = AUDIO_STREAM_EPNUM,
- .DataINEndpointSize = AUDIO_STREAM_EPSIZE,
+ .DataOUTEndpointNumber = AUDIO_STREAM_EPNUM,
+ .DataOUTEndpointSize = AUDIO_STREAM_EPSIZE,
},
};
@@ -62,8 +62,7 @@ int main(void)
for (;;)
{
- if (Speaker_Audio_Interface.State.InterfaceEnabled)
- ProcessNextSample();
+ ProcessNextSample();
Audio_Device_USBTask(&Speaker_Audio_Interface);
USB_USBTask();
@@ -90,14 +89,15 @@ void SetupHardware(void)
*/
void ProcessNextSample(void)
{
+ /* Check if the sample reload timer period has elapsed, and that the USB bus is ready for a new sample */
if ((TIFR0 & (1 << OCF0A)) && Audio_Device_IsSampleReceived(&Speaker_Audio_Interface))
{
/* Clear the sample reload timer */
TIFR0 |= (1 << OCF0A);
/* Retrieve the signed 16-bit left and right audio samples */
- int16_t LeftSample_16Bit = (int16_t)Audio_Device_ReadSample16();
- int16_t RightSample_16Bit = (int16_t)Audio_Device_ReadSample16();
+ int16_t LeftSample_16Bit = Audio_Device_ReadSample16(&Speaker_Audio_Interface);
+ int16_t RightSample_16Bit = Audio_Device_ReadSample16(&Speaker_Audio_Interface);
/* Massage signed 16-bit left and right audio samples into signed 8-bit */
int8_t LeftSample_8Bit = (LeftSample_16Bit >> 8);
@@ -124,16 +124,16 @@ void ProcessNextSample(void)
/* Make mixed sample value positive (absolute) */
MixedSample_8Bit = abs(MixedSample_8Bit);
- if (MixedSample_8Bit > ((128 / 8) * 1))
+ if (MixedSample_8Bit > 2)
LEDMask |= LEDS_LED1;
- if (MixedSample_8Bit > ((128 / 8) * 2))
+ if (MixedSample_8Bit > 4)
LEDMask |= LEDS_LED2;
- if (MixedSample_8Bit > ((128 / 8) * 3))
+ if (MixedSample_8Bit > 8)
LEDMask |= LEDS_LED3;
- if (MixedSample_8Bit > ((128 / 8) * 4))
+ if (MixedSample_8Bit > 16)
LEDMask |= LEDS_LED4;
LEDs_SetAllLEDs(LEDMask);
diff --git a/Demos/Device/ClassDriver/AudioOutput/AudioOutput.h b/Demos/Device/ClassDriver/AudioOutput/AudioOutput.h
index ea897c954..9846a7634 100644
--- a/Demos/Device/ClassDriver/AudioOutput/AudioOutput.h
+++ b/Demos/Device/ClassDriver/AudioOutput/AudioOutput.h
@@ -40,6 +40,7 @@
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/power.h>
+ #include <stdlib.h>
#include "Descriptors.h"
diff --git a/Demos/Device/ClassDriver/AudioOutput/Descriptors.h b/Demos/Device/ClassDriver/AudioOutput/Descriptors.h
index bc894285c..a9b00a7e9 100644
--- a/Demos/Device/ClassDriver/AudioOutput/Descriptors.h
+++ b/Demos/Device/ClassDriver/AudioOutput/Descriptors.h
@@ -43,12 +43,8 @@
#include <avr/pgmspace.h>
/* Macros: */
- #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
- /** Endpoint number of the Audio isochronous streaming data endpoint. */
- #define AUDIO_STREAM_EPNUM 1
- #else
- #define AUDIO_STREAM_EPNUM 3
- #endif
+ /** Endpoint number of the Audio isochronous streaming data endpoint. */
+ #define AUDIO_STREAM_EPNUM 1
/** Endpoint size in bytes of the Audio isochronous streaming data endpoint. The Windows audio stack requires
* at least 192 bytes for correct output, thus the smaller 128 byte maximum endpoint size on some of the smaller
diff --git a/Demos/Device/LowLevel/AudioInput/Descriptors.h b/Demos/Device/LowLevel/AudioInput/Descriptors.h
index 678eaafd3..3a3174b9b 100644
--- a/Demos/Device/LowLevel/AudioInput/Descriptors.h
+++ b/Demos/Device/LowLevel/AudioInput/Descriptors.h
@@ -137,12 +137,8 @@
*/
#define EP_ACCEPTS_SMALL_PACKETS (0 << 7)
- #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
- /** Endpoint number of the Audio isochronous streaming data endpoint. */
- #define AUDIO_STREAM_EPNUM 1
- #else
- #define AUDIO_STREAM_EPNUM 3
- #endif
+ /** Endpoint number of the Audio isochronous streaming data endpoint. */
+ #define AUDIO_STREAM_EPNUM 1
/** Endpoint size in bytes of the Audio isochronous streaming data endpoint. The Windows audio stack requires
* at least 192 bytes for correct output, thus the smaller 128 byte maximum endpoint size on some of the smaller
diff --git a/Demos/Device/LowLevel/AudioOutput/AudioOutput.c b/Demos/Device/LowLevel/AudioOutput/AudioOutput.c
index c814c8ce5..352d07482 100644
--- a/Demos/Device/LowLevel/AudioOutput/AudioOutput.c
+++ b/Demos/Device/LowLevel/AudioOutput/AudioOutput.c
@@ -30,7 +30,7 @@
/** \file
*
- * Main source file for the Audio Output demo. This file contains the main tasks of the demo and
+ * Main source file for the AudioOutput demo. This file contains the main tasks of the demo and
* is responsible for the initial application hardware configuration.
*/
@@ -231,16 +231,16 @@ void USB_Audio_Task(void)
/* Make mixed sample value positive (absolute) */
MixedSample_8Bit = abs(MixedSample_8Bit);
- if (MixedSample_8Bit > ((128 / 8) * 1))
+ if (MixedSample_8Bit > 2)
LEDMask |= LEDS_LED1;
- if (MixedSample_8Bit > ((128 / 8) * 2))
+ if (MixedSample_8Bit > 4)
LEDMask |= LEDS_LED2;
- if (MixedSample_8Bit > ((128 / 8) * 3))
+ if (MixedSample_8Bit > 8)
LEDMask |= LEDS_LED3;
- if (MixedSample_8Bit > ((128 / 8) * 4))
+ if (MixedSample_8Bit > 16)
LEDMask |= LEDS_LED4;
LEDs_SetAllLEDs(LEDMask);
diff --git a/Demos/Device/LowLevel/AudioOutput/AudioOutput.h b/Demos/Device/LowLevel/AudioOutput/AudioOutput.h
index 8d7f16c5f..6c8d733f3 100644
--- a/Demos/Device/LowLevel/AudioOutput/AudioOutput.h
+++ b/Demos/Device/LowLevel/AudioOutput/AudioOutput.h
@@ -40,6 +40,7 @@
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/power.h>
+ #include <stdlib.h>
#include "Descriptors.h"
diff --git a/Demos/Device/LowLevel/AudioOutput/Descriptors.h b/Demos/Device/LowLevel/AudioOutput/Descriptors.h
index a16a76f19..0623c7775 100644
--- a/Demos/Device/LowLevel/AudioOutput/Descriptors.h
+++ b/Demos/Device/LowLevel/AudioOutput/Descriptors.h
@@ -137,12 +137,8 @@
*/
#define EP_ACCEPTS_SMALL_PACKETS (0 << 7)
- #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
- /** Endpoint number of the Audio isochronous streaming data endpoint. */
- #define AUDIO_STREAM_EPNUM 1
- #else
- #define AUDIO_STREAM_EPNUM 3
- #endif
+ /** Endpoint number of the Audio isochronous streaming data endpoint. */
+ #define AUDIO_STREAM_EPNUM 1
/** Endpoint size in bytes of the Audio isochronous streaming data endpoint. The Windows audio stack requires
* at least 192 bytes for correct output, thus the smaller 128 byte maximum endpoint size on some of the smaller