[tuxdroid-svn] r623 - firmware/tuxaudio/trunk
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2007-10-17 09:05:07
|
Author: Paul_R Date: 2007-10-17 11:05:07 +0200 (Wed, 17 Oct 2007) New Revision: 623 Modified: firmware/tuxaudio/trunk/PC_communication.c firmware/tuxaudio/trunk/communication.c firmware/tuxaudio/trunk/communication.h firmware/tuxaudio/trunk/flash.c firmware/tuxaudio/trunk/main.c Log: * Added some status when the flash memory is used * Added some protections when a play or write command is received : An write command has the highest priority. Modified: firmware/tuxaudio/trunk/PC_communication.c =================================================================== --- firmware/tuxaudio/trunk/PC_communication.c 2007-10-17 08:33:59 UTC (rev 622) +++ firmware/tuxaudio/trunk/PC_communication.c 2007-10-17 09:05:07 UTC (rev 623) @@ -66,8 +66,6 @@ || (rf_data_sent_ack == RF_DATA_SENT_DROPPED)) { spi_headerb |= 0x08; /* resend the previous status if nacked */ - cli(); - sei(); } else if (rf_data_sent_ack != RF_DATA_SENT_BUSY) /* wait the end of transmission */ if (!popStatus(spi_commandTX)) /* fetch the next status */ @@ -82,7 +80,9 @@ 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 Modified: firmware/tuxaudio/trunk/communication.c =================================================================== --- firmware/tuxaudio/trunk/communication.c 2007-10-17 08:33:59 UTC (rev 622) +++ firmware/tuxaudio/trunk/communication.c 2007-10-17 09:05:07 UTC (rev 623) @@ -79,6 +79,20 @@ , *statusFifo = &_statusBuf; + +void send_status(uint8_t status ,uint8_t byte1 ,uint8_t byte2 ,uint8_t byte3) +{ + uint8_t buf[4]; + buf[0] = status; + buf[1] = byte1; + buf[2] = byte2; + buf[3] = byte3; + cli(); + i2cSlaveReceiveService(4, buf); + sei(); +} + + /* * Initializes (clear) the communication buffers */ Modified: firmware/tuxaudio/trunk/communication.h =================================================================== --- firmware/tuxaudio/trunk/communication.h 2007-10-17 08:33:59 UTC (rev 622) +++ firmware/tuxaudio/trunk/communication.h 2007-10-17 09:05:07 UTC (rev 623) @@ -46,6 +46,7 @@ /* From i2c to RF */ void acceptData(void); void i2cSlaveReceiveService(uint8_t receiveDataLength, uint8_t * receiveData); +void send_status(uint8_t status ,uint8_t byte1 ,uint8_t byte2 ,uint8_t byte3); uint8_t popStatus(uint8_t * command); /* XXX move to a global definition file */ Modified: firmware/tuxaudio/trunk/flash.c =================================================================== --- firmware/tuxaudio/trunk/flash.c 2007-10-17 08:33:59 UTC (rev 622) +++ firmware/tuxaudio/trunk/flash.c 2007-10-17 09:05:07 UTC (rev 623) @@ -22,6 +22,7 @@ #include <avr/io.h> #include <avr/interrupt.h> #include "varis.h" +#include "communication.h" #include "spi.h" #include "i2c.h" #include "flash.h" @@ -78,7 +79,10 @@ erasingFlash(); else if (!(read_status() & BUSY)) + { + send_status(STATUS_AUDIO_CMD, 0, 1, 0); f_state ++; + } } else if (f_state == FIRST_PROG_STATE) { @@ -88,12 +92,20 @@ else if (f_state == PROG_TOC_STATE) { if (TOCRX) + { + send_status(STATUS_AUDIO_CMD, 0, 2, 0); programmingToc(); + } + if (flash_state) + { + send_status(STATUS_AUDIO_CMD, 0, 3, 0); f_state ++; + } } else if (f_state == INIT_SOUND_PROG_STATE) { + send_status(STATUS_AUDIO_CMD, 0, 4, 0); initSoundProgramming(); if (flash_state) f_state ++; @@ -108,6 +120,7 @@ else if (f_state == END_STATE) { endProgramming(); + send_status(STATUS_AUDIO_CMD, 0, 0, 0); f_state = 0; } } @@ -302,6 +315,7 @@ static void stopPlaying(void) { flashPlay = 0; + send_status(STATUS_AUDIO_CMD, 0, 0, 0); PORTB |= 0x01; // Set the HOLD signal PORTB |= 0x02; // Chip Deselect } Modified: firmware/tuxaudio/trunk/main.c =================================================================== --- firmware/tuxaudio/trunk/main.c 2007-10-17 08:33:59 UTC (rev 622) +++ firmware/tuxaudio/trunk/main.c 2007-10-17 09:05:07 UTC (rev 623) @@ -161,11 +161,12 @@ /* audioBuf[2] : mic sound intensity */ { /* postpone the command if a sound is already playing */ - if (flashPlay) + if (flashPlay || programmingFlash) return; audioLevel = audioBuf[2]; //playingAudio(audioBuf[1]); /* start playing the sound */ soundNum = audioBuf[1]; + send_status(STATUS_AUDIO_CMD, audioBuf[1], 0, 0); flashPlay = 1; flash_state = 1; } @@ -199,6 +200,8 @@ { if (command[0] == STORE_SOUND_CMD) { + if (flashPlay) + flashPlay = 0; /* param: command[1] : number of sounds */ numSound = command[1]; f_state =0; /* First programming state */ @@ -332,11 +335,13 @@ DDRD &= ~0x02; } } - sendCommands(); /* Send commands on I2C */ - if (audioBufIdx) audioIntParser(); + sendCommands(); /* Send commands on I2C */ + + + /* Send information to the computer. */ if (info_flg) send_info(); @@ -344,7 +349,8 @@ /* Sleep mode */ if (pre_sleep_delay == 1) sleep(); - } + + } } // External Interrupt 0 service routine PD2 |