Author: jaguarondi
Date: 2008-07-16 10:00:29 +0200 (Wed, 16 Jul 2008)
New Revision: 1326

Modified:
   firmware/tuxaudio/branches/new_rf/communication.c
   firmware/tuxaudio/branches/new_rf/main.c
Log:
* The redundancy in the RF makes it possible to have 2 frames with the same ID 
but with different valid audio samples.


Modified: firmware/tuxaudio/branches/new_rf/communication.c
===================================================================
--- firmware/tuxaudio/branches/new_rf/communication.c   2008-07-11 09:57:07 UTC 
(rev 1325)
+++ firmware/tuxaudio/branches/new_rf/communication.c   2008-07-16 08:00:29 UTC 
(rev 1326)
@@ -21,6 +21,7 @@
 
 #include <avr/io.h>
 #include <avr/interrupt.h>
+#include <stdio.h>
 
 #include "communication.h"
 #include "fifo.h"
@@ -356,25 +357,49 @@
                 /* Ack the data by toggling the bit */
                 config_out ^= CFG_ACK_MK;
             }
-            if (config_in & CFG_AUDIO_MK)
-            {
-                adapt_audio_rate();
-
-                for (i=0; i<AUDIO_SPK_SIZE; i++)
-                {
-                    FifoPut(PWMFifo, spi_in[i+SPI_AUDIO_OFFSET]);
-                    //XXX DEBUG: used to show when the stack overflows.
-                    //if (FifoPut(PWMFifo, spi_in[i+SPI_AUDIO_OFFSET]) != 
FIFO_OK)
-                        //PORTB |= 0x80; // XXX DEBUG
-                    //else
-                        //PORTB &= ~0x80; // XXX DEBUG
-                }
-            }
-            //PORTB &= ~0x80; // XXX DEBUG
         }
         //else
             //PORTB |= 0x80; // XXX DEBUG
+        if (config_in & CFG_AUDIO_MK)
+        {
+            adapt_audio_rate();
 
+            for (i=0; i<AUDIO_SPK_SIZE; i++)
+            {
+                FifoPut(PWMFifo, spi_in[i+SPI_AUDIO_OFFSET]);
+            }
+        }
+        else
+        PORTB ^= 0x80; // XXX DEBUG
+
+        /* DEBUG VERSION
+         * The first part checks a saw wave, the second part can check for
+         * stack overflow. */
+        //{
+            //uint8_t static tmp2;
+            //adapt_audio_rate();
+
+            //for (i=0; i<AUDIO_SPK_SIZE; i++)
+            //{
+                //uint8_t tmp1;
+                //tmp1 = spi_in[i+SPI_AUDIO_OFFSET];
+                //FifoPut(PWMFifo, tmp1);
+                //if (tmp1 != (uint8_t)(tmp2 + 1))
+                //{
+                    //PORTB ^= 0x80; // XXX DEBUG
+                    //queue_rf_cmd_p(0xFE, tmp1, tmp2, frame_in_idx);
+                //}
+                //tmp2 = tmp1;
+                //XXX DEBUG: used to show when the stack overflows.
+                //if (FifoPut(PWMFifo, spi_in[i+SPI_AUDIO_OFFSET]) != FIFO_OK)
+                //PORTB |= 0x80; // XXX DEBUG
+                //else
+                //PORTB &= ~0x80; // XXX DEBUG
+            //}
+        //}
+        /*else*/
+        /*PORTB ^= 0x80; // XXX DEBUG*/
+
         /* Outgoing data, add commands and/or audio. */
         spi_out[SPI_IDX_OFFSET] = frame_out_idx++;
         if ((!(config_out & CFG_DATA_MK)) == (!(config_in & CFG_ACK_MK)) &&
@@ -417,7 +442,7 @@
     {
         if (!parse_cmd(received_cmd))
             queue_rf_cmd(received_cmd);
-        received_cmd = 0;
+        received_cmd = NULL;
     }
 
     /* Send otherwise get commands. */

Modified: firmware/tuxaudio/branches/new_rf/main.c
===================================================================
--- firmware/tuxaudio/branches/new_rf/main.c    2008-07-11 09:57:07 UTC (rev 
1325)
+++ firmware/tuxaudio/branches/new_rf/main.c    2008-07-16 08:00:29 UTC (rev 
1326)
@@ -252,13 +252,13 @@
                     DDRD &= ~0x03;
             }
             /* XXX debug of the audio stack */
-            queue_rf_cmd_p(0xFE, FifoLength(PWMFifo), OCR0A, 0);
+            //queue_rf_cmd_p(0xFE, FifoLength(PWMFifo), OCR0A, 0);
         }
 
         /* Sleep mode */
         if (pre_sleep_delay == 1)
             sleep();
-        }
+    }
 }
 
 //static inline void audio_sampling(void) __attribute__ ( ( always_inline ) );


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to