[tuxdroid-svn] r455 - firmware/tuxaudio/trunk
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-06-26 13:41:21
|
Author: jaguarondi Date: 2007-06-26 15:41:18 +0200 (Tue, 26 Jun 2007) New Revision: 455 Modified: firmware/tuxaudio/trunk/spi.c firmware/tuxaudio/trunk/varis.c firmware/tuxaudio/trunk/varis.h Log: * Changed the acknowledge of the status sent by spi so that it's compatible with the new RF firmware (Modification from Pascal.) Modified: firmware/tuxaudio/trunk/spi.c =================================================================== --- firmware/tuxaudio/trunk/spi.c 2007-06-26 09:30:43 UTC (rev 454) +++ firmware/tuxaudio/trunk/spi.c 2007-06-26 13:41:18 UTC (rev 455) @@ -57,17 +57,26 @@ else spi_headerb = 0x00; /* no sound in frame */ - /* Status */ - if ((rf_data_sent_ack == RF_DATA_SENT_NACKED) - || (rf_data_sent_ack == RF_DATA_SENT_DROPPED)) + /* Resend the previous command if nacked */ + if ((rf_data_sent_ack == RF_DATA_SENT_NACKED) && + (unlockCommand)) { - spi_headerb |= 0x08; /* resend the previous status if nacked */ - cli(); - sei(); + spi_headerb |= 0x08; + 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 */ + /* 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; + } + } SPDR = spi_headerb; // Header byte spi_slave = GET_SOUND_FIFO; // Next state @@ -155,15 +164,20 @@ 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-06-26 09:30:43 UTC (rev 454) +++ firmware/tuxaudio/trunk/varis.c 2007-06-26 13:41:18 UTC (rev 455) @@ -43,6 +43,7 @@ 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-06-26 09:30:43 UTC (rev 454) +++ firmware/tuxaudio/trunk/varis.h 2007-06-26 13:41:18 UTC (rev 455) @@ -45,6 +45,7 @@ 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 |