[tuxdroid-svn] r616 - firmware/tuxaudio/trunk
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2007-10-16 10:41:38
|
Author: Paul_R Date: 2007-10-16 12:41:28 +0200 (Tue, 16 Oct 2007) New Revision: 616 Modified: firmware/tuxaudio/trunk/PC_communication.c firmware/tuxaudio/trunk/flash.c firmware/tuxaudio/trunk/main.c Log: * Changed the play sound process. Now, the data bytes are stored in a fifo. When a sound is played from the flash, the RF still work. Modified: firmware/tuxaudio/trunk/PC_communication.c =================================================================== --- firmware/tuxaudio/trunk/PC_communication.c 2007-10-15 13:52:20 UTC (rev 615) +++ firmware/tuxaudio/trunk/PC_communication.c 2007-10-16 10:41:28 UTC (rev 616) @@ -38,7 +38,7 @@ spi_count = 0; // Reset spi counter spi_slave = HEADERS; // Set state machine spi_master = HEADERM; - if (programmingFlash) + if (programmingFlash || flashPlay) HOLD_ON; // Reset SPI to fix strange bug on the spi SPCR = 0x50; @@ -82,9 +82,7 @@ spi_slave = PUT_COMMAND; // Next state if (spi_headerb & 0x02) { - cli(); SPDR = pullFifo(&ADCFifo); // Get data from FIFO - sei(); } else SPDR = 0x00; // No data to transmit @@ -119,15 +117,13 @@ spi_lenght_data = 17; spi_master = PUT_SOUND_FIFO; // Go to the next state - if (!programmingFlash) // XXX code must be review it's very strange ..... + if (!programmingFlash && !flashPlay) // XXX code must be review it's very strange ..... { if (!(spi_master_config & 0x02)) { if (!lockAdaptFifo) { - cli(); adaptFifo(&PWMFifo); // Adaptative FIFO - sei(); lockAdaptFifo = 1; } else @@ -144,12 +140,12 @@ { if (spi_master_config & 0x02) { - cli(); - pushFifo(&PWMFifo, SPDR); // Put into the FIFO - sei(); + if (!flashPlay) + pushFifo(&PWMFifo, SPDR); // Put into the FIFO } if (spi_count == (spi_lenght_data + 1)) spi_master = READ_COMMAND; // Go to the next state + } else if (spi_master == READ_COMMAND) { Modified: firmware/tuxaudio/trunk/flash.c =================================================================== --- firmware/tuxaudio/trunk/flash.c 2007-10-15 13:52:20 UTC (rev 615) +++ firmware/tuxaudio/trunk/flash.c 2007-10-16 10:41:28 UTC (rev 616) @@ -152,7 +152,7 @@ { uint8_t count, i; uint8_t adp1, adp0, sounds_stored; // Address pointer varaible - + HOLD_OFF; sounds_stored = read_data(0x00, 0x00, 0x00); if (sounds_stored == 0xFF) /* if unprogrammed we have 0xFF stored in flash */ { @@ -235,7 +235,7 @@ } } } - + resetFifo(&PWMFifo); FLASH_CS_ON; // Chip Select spiSend(0x03); // Send Read Page Command @@ -260,12 +260,10 @@ static void playingSound(void) { uint8_t sound; - cli(); - if (!isFifoFull(&PWMFifo)) + HOLD_OFF; + while (spi_start && !isFifoFull(&PWMFifo)) { - HOLD_OFF; // Set the HOLD signal sound = spiSend(0x00); // Wait response - HOLD_ON; // Reset the HOLD signal sound = sound >> audioLevel; pushFifo(&PWMFifo, sound); @@ -277,15 +275,21 @@ { ad[0]++; if (ad[0] == 0x08) // Address overflow + { stopPlaying(); + break; + } } } if (ad[0] == ad[3]) // Test end of sound if (ad[1] == ad[4]) if (ad[2] == ad[5]) + { stopPlaying(); + break; + } } - sei(); + HOLD_ON; } /* Static functions */ @@ -392,7 +396,7 @@ spiSend(ad2); spiSend(ad1); spiSend(ad0); - + resetFifo(&PWMFifo); while (!spi_start) // Send first byte into the page flash { if (!isFifoEmpty(&PWMFifo)) // Fifo not empty Modified: firmware/tuxaudio/trunk/main.c =================================================================== --- firmware/tuxaudio/trunk/main.c 2007-10-15 13:52:20 UTC (rev 615) +++ firmware/tuxaudio/trunk/main.c 2007-10-16 10:41:28 UTC (rev 616) @@ -285,8 +285,7 @@ { sei(); // Reactivate global interrupt in case of flash programmation - if (!flashPlay) - spiTransaction(); // Spi transaction from radio + spiTransaction(); // Spi transaction from radio if (commandRX) // commend RX from radio { |