Changed AudioOutput demos to explicitly use timer 3 - the smaller USB AVRs where...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 28 Jul 2009 10:46:20 +0000 (10:46 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 28 Jul 2009 10:46:20 +0000 (10:46 +0000)
Fix Benito documentation indicating erronously that the project used the HID USB class instead of the CDC class.

Demos/Device/ClassDriver/AudioOutput/AudioOutput.c
Demos/Device/ClassDriver/AudioOutput/AudioOutput.h
Demos/Device/LowLevel/AudioInput/AudioInput.h
Demos/Device/LowLevel/AudioOutput/AudioOutput.c
Demos/Device/LowLevel/AudioOutput/AudioOutput.h
Projects/Benito/Benito.c
Projects/Benito/Benito.txt

index 129fca5..bbcd2fd 100644 (file)
@@ -108,19 +108,19 @@ void ProcessNextSample(void)
 \r
 #if defined(AUDIO_OUT_MONO)\r
                /* Load the sample into the PWM timer channel */\r
-               OCRxA = ((uint8_t)MixedSample_8Bit ^ (1 << 7));\r
+               OCR3A = ((uint8_t)MixedSample_8Bit ^ (1 << 7));\r
 #elif defined(AUDIO_OUT_STEREO)\r
                /* Load the dual 8-bit samples into the PWM timer channels */\r
-               OCRxA = ((uint8_t)LeftSample_8Bit  ^ (1 << 7));\r
-               OCRxB = ((uint8_t)RightSample_8Bit ^ (1 << 7));\r
+               OCR3A = ((uint8_t)LeftSample_8Bit  ^ (1 << 7));\r
+               OCR3B = ((uint8_t)RightSample_8Bit ^ (1 << 7));\r
 #elif defined(AUDIO_OUT_PORTC)\r
+               /* Load the 8-bit mixed sample into PORTC */\r
                PORTC = MixedSample_8Bit;\r
 #else\r
                uint8_t LEDMask = LEDS_NO_LEDS;\r
 \r
                /* Make mixed sample value positive (absolute) */\r
-               if (MixedSample_8Bit < 0)\r
-                 MixedSample_8Bit = -MixedSample_8Bit;\r
+               MixedSample_8Bit = abs(MixedSample_8Bit);\r
 \r
                if (MixedSample_8Bit > ((128 / 8) * 1))\r
                  LEDMask |= LEDS_LED1;\r
@@ -162,9 +162,9 @@ void EVENT_USB_Connect(void)
 \r
 #if (defined(AUDIO_OUT_MONO) || defined(AUDIO_OUT_STEREO))\r
        /* PWM speaker timer initialization */\r
-       TCCRxA  = ((1 << WGMx0) | (1 << COMxA1) | (1 << COMxA0)\r
-               | (1 << COMxB1) | (1 << COMxB0)); // Set on match, clear on TOP\r
-       TCCRxB  = ((1 << WGMx2) | (1 << CSx0));  // Fast 8-Bit PWM, Fcpu speed\r
+       TCCR3A  = ((1 << WGM30) | (1 << COM3A1) | (1 << COM3A0)\r
+               | (1 << COM3B1) | (1 << COM3B0)); // Set on match, clear on TOP\r
+       TCCR3B  = ((1 << WGM32) | (1 << CS30));  // Fast 8-Bit PWM, Fcpu speed\r
 #endif\r
 }\r
 \r
@@ -178,7 +178,7 @@ void EVENT_USB_Disconnect(void)
 \r
 #if (defined(AUDIO_OUT_MONO) || defined(AUDIO_OUT_STEREO))\r
        /* Stop the PWM generation timer */\r
-       TCCRxB = 0;\r
+       TCCR3B = 0;\r
 #endif\r
 \r
 #if defined(AUDIO_OUT_MONO)\r
index ecc4e6f..ea897c9 100644 (file)
                #include <LUFA/Drivers/USB/USB.h>\r
                #include <LUFA/Drivers/USB/Class/Audio.h>\r
        \r
-       /* Macros: */\r
-               #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
-                       #define TCCRxA          TCCR3A\r
-                       #define TCCRxB          TCCR3B\r
-                       #define OCRxA           OCR3A\r
-                       #define OCRxB           OCR3B\r
-                       #define WGMx0           WGM30\r
-                       #define WGMx2           WGM32\r
-                       #define COMxA1          COM3A1\r
-                       #define COMxA0          COM3A0\r
-                       #define COMxB1          COM3B1\r
-                       #define COMxB0          COM3B0\r
-                       #define CSx0            CS30\r
-               #else\r
-                       /** Timer count register used for left channel PWM audio output (or mixed output in mono output mode) */\r
-                       #define TCCRxA          TCCR1A\r
-\r
-                       /** Timer count register used for right channel PWM audio output */\r
-                       #define TCCRxB          TCCR1B\r
-\r
-                       /** Timer compare register used for left channel PWM audio output (or mixed output in mono output mode) */\r
-                       #define OCRxA           OCR1A\r
-\r
-                       /** Timer compare register used for right channel PWM audio output */\r
-                       #define OCRxB           OCR1B\r
-\r
-                       /** Timer control register mask used to select PWM mode */\r
-                       #define WGMx0           WGM10\r
-\r
-                       /** Timer control register mask used to select PWM mode */\r
-                       #define WGMx2           WGM12\r
-\r
-                       /** Timer control register mask used to set, clear or toggle channel output pin on match */\r
-                       #define COMxA1          COM1A1\r
-\r
-                       /** Timer control register mask used to set, clear or toggle channel output pin on match */\r
-                       #define COMxA0          COM1A0\r
-\r
-                       /** Timer control register mask used to set, clear or toggle channel output pin on match */\r
-                       #define COMxB1          COM1B1\r
-\r
-                       /** Timer control register mask used to set, clear or toggle channel output pin on match */\r
-                       #define COMxB0          COM1B0\r
-\r
-                       /** Timer control register mask used to start the timer at Fcpu clock rate */\r
-                       #define CSx0            CS10\r
-               #endif\r
-               \r
+       /* Macros: */           \r
                /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
                #define LEDMASK_USB_NOTREADY      LEDS_LED1\r
 \r
index 082b055..591d3f3 100644 (file)
 \r
        /* Macros: */\r
                /** ADC channel number for the microphone input. */\r
-               #define MIC_IN_ADC_CHANNEL               2\r
+               #define MIC_IN_ADC_CHANNEL        2\r
                \r
                /** Maximum ADC sample value for the microphone input. */\r
-               #define SAMPLE_MAX_RANGE                 0xFFFF\r
+               #define SAMPLE_MAX_RANGE          0xFFFF\r
 \r
                /** Maximum ADC range for the microphone input. */\r
-               #define ADC_MAX_RANGE                    0x3FF\r
+               #define ADC_MAX_RANGE             0x3FF\r
 \r
                /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
                #define LEDMASK_USB_NOTREADY      LEDS_LED1\r
index 89c4446..9b2bb39 100644 (file)
@@ -96,9 +96,9 @@ void EVENT_USB_Connect(void)
 \r
 #if (defined(AUDIO_OUT_MONO) || defined(AUDIO_OUT_STEREO))\r
        /* PWM speaker timer initialization */\r
-       TCCRxA  = ((1 << WGMx0) | (1 << COMxA1) | (1 << COMxA0)\r
-                               | (1 << COMxB1) | (1 << COMxB0)); // Set on match, clear on TOP\r
-       TCCRxB  = ((1 << WGMx2) | (1 << CSx0));  // Fast 8-Bit PWM, Fcpu speed\r
+       TCCR3A  = ((1 << WGM30) | (1 << COM3A1) | (1 << COM3A0)\r
+                               | (1 << COM3B1) | (1 << COM3B0)); // Set on match, clear on TOP\r
+       TCCR3B  = ((1 << WGM32) | (1 << CS30));  // Fast 8-Bit PWM, Fcpu speed\r
 #endif \r
 }\r
 \r
@@ -110,7 +110,7 @@ void EVENT_USB_Disconnect(void)
        /* Stop the timers */\r
        TCCR0B = 0;\r
 #if (defined(AUDIO_OUT_MONO) || defined(AUDIO_OUT_STEREO))\r
-       TCCRxB = 0;\r
+       TCCR3B = 0;\r
 #endif         \r
 \r
 #if defined(AUDIO_OUT_MONO)\r
@@ -215,11 +215,11 @@ void USB_Audio_Task(void)
                int8_t  MixedSample_8Bit  = (((int16_t)LeftSample_8Bit + (int16_t)RightSample_8Bit) >> 1);\r
 \r
                /* Load the sample into the PWM timer channel */\r
-               OCRxA = ((uint8_t)MixedSample_8Bit ^ (1 << 7));\r
+               OCR3A = ((uint8_t)MixedSample_8Bit ^ (1 << 7));\r
 #elif defined(AUDIO_OUT_STEREO)\r
                /* Load the dual 8-bit samples into the PWM timer channels */\r
-               OCRxA = ((uint8_t)LeftSample_8Bit  ^ (1 << 7));\r
-               OCRxB = ((uint8_t)RightSample_8Bit ^ (1 << 7));\r
+               OCR3A = ((uint8_t)LeftSample_8Bit  ^ (1 << 7));\r
+               OCR3B = ((uint8_t)RightSample_8Bit ^ (1 << 7));\r
 #elif defined(AUDIO_OUT_PORTC)\r
                /* Mix the two channels together to produce a mono, 8-bit sample */\r
                int8_t  MixedSample_8Bit  = (((int16_t)LeftSample_8Bit + (int16_t)RightSample_8Bit) >> 1);\r
index 7970efe..8d7f16c 100644 (file)
                #include <LUFA/Drivers/Board/LEDs.h>
        \r
        /* Macros: */\r
-               #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
-                       #define TCCRxA          TCCR3A\r
-                       #define TCCRxB          TCCR3B\r
-                       #define OCRxA           OCR3A\r
-                       #define OCRxB           OCR3B\r
-                       #define WGMx0           WGM30\r
-                       #define WGMx2           WGM32\r
-                       #define COMxA1          COM3A1\r
-                       #define COMxA0          COM3A0\r
-                       #define COMxB1          COM3B1\r
-                       #define COMxB0          COM3B0\r
-                       #define CSx0            CS30\r
-               #else\r
-                       /** Timer count register used for left channel PWM audio output (or mixed output in mono output mode) */\r
-                       #define TCCRxA          TCCR1A\r
-\r
-                       /** Timer count register used for right channel PWM audio output */\r
-                       #define TCCRxB          TCCR1B\r
-\r
-                       /** Timer compare register used for left channel PWM audio output (or mixed output in mono output mode) */\r
-                       #define OCRxA           OCR1A\r
-\r
-                       /** Timer compare register used for right channel PWM audio output */\r
-                       #define OCRxB           OCR1B\r
-\r
-                       /** Timer control register mask used to select PWM mode */\r
-                       #define WGMx0           WGM10\r
-\r
-                       /** Timer control register mask used to select PWM mode */\r
-                       #define WGMx2           WGM12\r
-\r
-                       /** Timer control register mask used to set, clear or toggle channel output pin on match */\r
-                       #define COMxA1          COM1A1\r
-\r
-                       /** Timer control register mask used to set, clear or toggle channel output pin on match */\r
-                       #define COMxA0          COM1A0\r
-\r
-                       /** Timer control register mask used to set, clear or toggle channel output pin on match */\r
-                       #define COMxB1          COM1B1\r
-\r
-                       /** Timer control register mask used to set, clear or toggle channel output pin on match */\r
-                       #define COMxB0          COM1B0\r
-\r
-                       /** Timer control register mask used to start the timer at Fcpu clock rate */\r
-                       #define CSx0            CS10\r
-               #endif\r
-               \r
                /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
                #define LEDMASK_USB_NOTREADY      LEDS_LED1\r
 \r
index 9e85fbd..26c5664 100644 (file)
@@ -79,7 +79,7 @@ int main(void)
        for (;;)\r
        {\r
                /* Echo bytes from the host to the target via the hardware USART */\r
-               if (CDC_Device_BytesReceived(&VirtualSerial_CDC_Interface))\r
+               if (CDC_Device_BytesReceived(&VirtualSerial_CDC_Interface) > 0)\r
                {\r
                        Serial_TxByte(CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface));\r
 \r
index 857a28f..63f3ea8 100644 (file)
  *  </tr>\r
  *  <tr>\r
  *   <td><b>USB Class:</b></td>\r
- *   <td>Human Interface Device (HID)</td>\r
+ *   <td>Communications Device Class (CDC)</td>\r
  *  </tr>\r
  *  <tr> \r
  *   <td><b>USB Subclass:</b></td>\r
- *   <td>Keyboard</td>\r
+ *   <td>Abstract Control Model (ACM)</td>\r
  *  </tr>\r
  *  <tr>\r
  *   <td><b>Relevant Standards:</b></td>\r
- *   <td>USBIF HID Standard, USBIF HID Usage Tables</td>\r
+ *   <td>USBIF CDC Class Standard</td>\r
+ *   <td>Arduino Bootloader Specification</td>\r
  *  </tr>\r
  *  <tr>\r
  *   <td><b>Usable Speeds:</b></td>\r
- *   <td>Low Speed Mode, Full Speed Mode</td>\r
+ *   <td>Full Speed Mode</td>\r
  *  </tr>\r
  * </table>\r
  *\r