Corrected AudioInput and AudioOutput demos, to fix endpoint underflows due to roundin...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 14 Apr 2009 12:07:41 +0000 (12:07 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 14 Apr 2009 12:07:41 +0000 (12:07 +0000)
Demos/Device/AudioInput/AudioInput.c
Demos/Device/AudioOutput/AudioOutput.c
LUFA/ChangeLog.txt

index b0c0295..fca24c3 100644 (file)
@@ -95,7 +95,7 @@ EVENT_HANDLER(USB_Connect)
        UpdateStatus(Status_USBEnumerating);\r
 \r
        /* Sample reload timer initialization */\r
        UpdateStatus(Status_USBEnumerating);\r
 \r
        /* Sample reload timer initialization */\r
-       OCR0A   = (F_CPU / AUDIO_SAMPLE_FREQUENCY) - ((F_CPU % AUDIO_SAMPLE_FREQUENCY) == 0 ? 1 : 0);\r
+       OCR0A   = (F_CPU / AUDIO_SAMPLE_FREQUENCY) - 1;\r
        TCCR0A  = (1 << WGM01);  // CTC mode\r
        TCCR0B  = (1 << CS00);   // Fcpu speed\r
 }\r
        TCCR0A  = (1 << WGM01);  // CTC mode\r
        TCCR0B  = (1 << CS00);   // Fcpu speed\r
 }\r
index 0554361..ffeee41 100644 (file)
@@ -90,7 +90,7 @@ EVENT_HANDLER(USB_Connect)
        UpdateStatus(Status_USBEnumerating);\r
        \r
        /* Sample reload timer initialization */\r
        UpdateStatus(Status_USBEnumerating);\r
        \r
        /* Sample reload timer initialization */\r
-       OCR0A   = (F_CPU / AUDIO_SAMPLE_FREQUENCY) - ((F_CPU % AUDIO_SAMPLE_FREQUENCY) == 0 ? 1 : 0);\r
+       OCR0A   = (F_CPU / AUDIO_SAMPLE_FREQUENCY) - 1;\r
        TCCR0A  = (1 << WGM01);  // CTC mode\r
        TCCR0B  = (1 << CS00);   // Fcpu speed\r
                        \r
        TCCR0A  = (1 << WGM01);  // CTC mode\r
        TCCR0B  = (1 << CS00);   // Fcpu speed\r
                        \r
index 80436f6..e85b35c 100644 (file)
@@ -29,8 +29,8 @@
   *  - Fixed GenericHID demo not starting USB and HID management tasks when not using interrupt driven modes (thanks to Carl Kjeldsen)\r
   *  - Fixed RNDISEthenet demo checking the incorrect message field for packet size constraints (thanks to Jonathan)\r
   *  - Fixed WriteNextReport code in the GenericHIDHost demo using incorrect parameter types and not selecting the correct endpoint\r
   *  - Fixed GenericHID demo not starting USB and HID management tasks when not using interrupt driven modes (thanks to Carl Kjeldsen)\r
   *  - Fixed RNDISEthenet demo checking the incorrect message field for packet size constraints (thanks to Jonathan)\r
   *  - Fixed WriteNextReport code in the GenericHIDHost demo using incorrect parameter types and not selecting the correct endpoint\r
-  *  - Adjusted sample CTC timer calculations in the AudioOutput and AudioInput demos to account for situations where the division results\r
-  *    in a value with no remainder, requiring one to be subtracted from the result (thanks to Robin Theunis)\r
+  *  - Adjusted sample CTC timer calculations in the AudioOutput and AudioInput demos to match the CTC calculations in the AVR datasheet,\r
+  *    and to fix instances where rounding caused the endpoint to underflow (thanks to Robin Theunis)\r
   *  - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0), so that other control type\r
   *    pipes can be used with the function\r
   *  - The USB Host management task now saves and restores the currently selected pipe before and after the task completes\r
   *  - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0), so that other control type\r
   *    pipes can be used with the function\r
   *  - The USB Host management task now saves and restores the currently selected pipe before and after the task completes\r