[tuxdroid-svn] r497 - firmware/tuxaudio/branches/audio_cleanup
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2007-09-07 13:01:38
|
Author: Paul_R Date: 2007-09-07 15:01:38 +0200 (Fri, 07 Sep 2007) New Revision: 497 Modified: firmware/tuxaudio/branches/audio_cleanup/spi.c firmware/tuxaudio/branches/audio_cleanup/varis.c firmware/tuxaudio/branches/audio_cleanup/varis.h Log: * Reverted the changes of the rev. 455 Modified: firmware/tuxaudio/branches/audio_cleanup/spi.c =================================================================== --- firmware/tuxaudio/branches/audio_cleanup/spi.c 2007-09-07 12:33:20 UTC (rev 496) +++ firmware/tuxaudio/branches/audio_cleanup/spi.c 2007-09-07 13:01:38 UTC (rev 497) @@ -58,26 +58,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 @@ -165,20 +156,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/branches/audio_cleanup/varis.c =================================================================== --- firmware/tuxaudio/branches/audio_cleanup/varis.c 2007-09-07 12:33:20 UTC (rev 496) +++ firmware/tuxaudio/branches/audio_cleanup/varis.c 2007-09-07 13:01:38 UTC (rev 497) @@ -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/branches/audio_cleanup/varis.h =================================================================== --- firmware/tuxaudio/branches/audio_cleanup/varis.h 2007-09-07 12:33:20 UTC (rev 496) +++ firmware/tuxaudio/branches/audio_cleanup/varis.h 2007-09-07 13:01:38 UTC (rev 497) @@ -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 |