diff options
author | Dean Camera <[email protected]> | 2009-07-30 14:06:52 +0000 |
---|---|---|
committer | Dean Camera <[email protected]> | 2009-07-30 14:06:52 +0000 |
commit | 41babf1cb78a2a8e05f40f5de61c3f52bb794fc4 (patch) | |
tree | 0ad2a05c55c83817a9cfefa6c2b68cd6ae0324d5 /Demos/Device/ClassDriver/AudioOutput/AudioOutput.c | |
parent | 41b54a2acd2d5515cc7f3f1ed1c3d3b17d1988a1 (diff) | |
download | qmk_firmware-41babf1cb78a2a8e05f40f5de61c3f52bb794fc4.tar.gz qmk_firmware-41babf1cb78a2a8e05f40f5de61c3f52bb794fc4.zip |
Fix incorrect configuration in the ClassDriver AudioOutput demo.
Make all audio device Class Driver functions require a reference to the Audio class instance, so that the endpoint size can be checked (and to standardize the APIs).
Make LEDs more responsive in the AudioOutput device demos.
Diffstat (limited to 'Demos/Device/ClassDriver/AudioOutput/AudioOutput.c')
-rw-r--r-- | Demos/Device/ClassDriver/AudioOutput/AudioOutput.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c b/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c index 9a63af68a2..2caf6faa6d 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);
|