[tuxdroid-svn] r499 - firmware/tuxaudio/trunk
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-09-07 13:55:42
|
Author: jaguarondi Date: 2007-09-07 15:55:42 +0200 (Fri, 07 Sep 2007) New Revision: 499 Modified: firmware/tuxaudio/trunk/spi.c firmware/tuxaudio/trunk/varis.c firmware/tuxaudio/trunk/varis.h Log: * Reverted changes of r455 as it's not fully compatible with the current RF firmware. We'll check this again when finishing implementing the sleep. Modified: firmware/tuxaudio/trunk/spi.c =================================================================== --- firmware/tuxaudio/trunk/spi.c 2007-09-07 13:54:12 UTC (rev 498) +++ firmware/tuxaudio/trunk/spi.c 2007-09-07 13:55:42 UTC (rev 499) @@ -57,26 +57,17 @@ else spi_headerb = 0x00; /* no sound in frame */ - /* Resend the previous command if nacked */ - if ((rf_data_sent_ack == RF_DATA_SENT_NACKED) && - (unlockCommand)) + /* Status */ + if ((rf_data_sent_ack == RF_DATA_SENT_NACKED) + || (rf_data_sent_ack == RF_DATA_SENT_DROPPED)) { - spi_headerb |= 0x08; - unlockCommand = 0x00; + spi_headerb |= 0x08; /* resend the previous status if nacked */ + cli(); + sei(); } - /* Wait the end of transmission */ - else if ((rf_data_sent_ack != RF_DATA_SENT_BUSY) && - (unlockCommand)) - { - /* fetch the next status */ - if (!popStatus(spi_commandTX)) - { - /* indicate that the frame contains status */ - spi_headerb |= 0x08; - rf_data_sent_ack = RF_DATA_SENT_BUSY; - unlockCommand = 0x00; - } - } + else if (rf_data_sent_ack != RF_DATA_SENT_BUSY) /* wait the end of transmission */ + if (!popStatus(spi_commandTX)) /* fetch the next status */ + spi_headerb |= 0x08; /* indicate that the frame contains status */ SPDR = spi_headerb; // Header byte spi_slave = GET_SOUND_FIFO; // Next state @@ -164,20 +155,15 @@ spi_commandRX[spi_count - 36] = SPDR; // Put command into the buffer else spi_commandRX[spi_count - 19] = SPDR; // Put command into the buffer - if (spi_count == spi_lenght_data + 6) - { - if ((spi_commandRX[4] == RF_DATA_SENT_ACKED) || - (spi_commandRX[4] == RF_DATA_SENT_NACKED)) - /* Get acknowledge of previous sent data */ - rf_data_sent_ack = spi_commandRX[4]; - } } - else if ((rf_data_sent_ack == RF_DATA_SENT_ACKED) || - (rf_data_sent_ack == RF_DATA_SENT_NACKED)) - /* Wait radio ready to send the next command */ - unlockCommand = 1; if (spi_count == spi_lenght_data + 6) { + /* Check the acknowledge from the rf */ + if (spi_headerb & 0x08) /* if data was sent in the current SPI transaction, mark buffer as full and drop the received status */ + rf_data_sent_ack = RF_DATA_SENT_BUSY; /* status buffer of the rf filled */ + else + rf_data_sent_ack = spi_commandRX[4]; /* get the acknowledge of the previous sent data */ + PORTB |= 0x04; // Chip deselect spi_enable = 1; break; Modified: firmware/tuxaudio/trunk/varis.c =================================================================== --- firmware/tuxaudio/trunk/varis.c 2007-09-07 13:54:12 UTC (rev 498) +++ firmware/tuxaudio/trunk/varis.c 2007-09-07 13:55:42 UTC (rev 499) @@ -43,7 +43,6 @@ volatile unsigned char spi_commandRX[5]; unsigned char commandRX = 0; uint8_t rf_data_sent_ack; -uint8_t unlockCommand = 1; // FIFO Variable volatile uint8_t PWMbuffer[128]; Modified: firmware/tuxaudio/trunk/varis.h =================================================================== --- firmware/tuxaudio/trunk/varis.h 2007-09-07 13:54:12 UTC (rev 498) +++ firmware/tuxaudio/trunk/varis.h 2007-09-07 13:55:42 UTC (rev 499) @@ -45,7 +45,6 @@ extern volatile unsigned char spi_commandRX[5]; extern unsigned char commandRX; extern uint8_t rf_data_sent_ack; -extern uint8_t unlockCommand; #define RF_DATA_SENT_FREE 0x00 #define RF_DATA_SENT_BUSY 0x01 |