[tuxdroid-svn] r1188 - in firmware/fuxusb/trunk: . src
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2008-05-22 09:48:28
|
Author: Paul_R Date: 2008-05-22 11:48:32 +0200 (Thu, 22 May 2008) New Revision: 1188 Modified: firmware/fuxusb/trunk/fuxusb.Opt firmware/fuxusb/trunk/src/bootloader.c firmware/fuxusb/trunk/src/spi_task.c firmware/fuxusb/trunk/src/spi_task.h Log: * Removed spi_task_on_Flag : flag with no effect. Modified: firmware/fuxusb/trunk/fuxusb.Opt =================================================================== (Binary files differ) Modified: firmware/fuxusb/trunk/src/bootloader.c =================================================================== --- firmware/fuxusb/trunk/src/bootloader.c 2008-05-22 09:41:39 UTC (rev 1187) +++ firmware/fuxusb/trunk/src/bootloader.c 2008-05-22 09:48:32 UTC (rev 1188) @@ -68,9 +68,6 @@ */ void bootloader_cmd_parser(void) { - /* Disable spi_task */ - spi_task_on_Flag = False; - if (command_received[0] == BOOT_INIT) { init_bootloader(); @@ -242,7 +239,6 @@ i2c_bootloading_Flag = False; reset_rf(); spi_task_reset(); - spi_task_on_Flag = True; } Modified: firmware/fuxusb/trunk/src/spi_task.c =================================================================== --- firmware/fuxusb/trunk/src/spi_task.c 2008-05-22 09:41:39 UTC (rev 1187) +++ firmware/fuxusb/trunk/src/spi_task.c 2008-05-22 09:48:32 UTC (rev 1188) @@ -66,10 +66,6 @@ * RF that a command must be included in the frame. */ bit new_command_received; -/** This flag allow to process the SPI task. It's cleared when the bootloader mode - * is activated. - */ -bit spi_task_on_Flag = True; /* Static defs */ static uint8_t spi_slave_config; @@ -161,209 +157,206 @@ uint8_t Spi_Overflow_Ctr; uint8_t i; uint8_t received_status[4]; - - if(spi_task_on_Flag) + + //-------------------------------------------------------------------------- + // + // Wait the START Event + // + //-------------------------------------------------------------------------- + if (SPI_START) { - //-------------------------------------------------------------------------- - // - // Wait the START Event - // - //-------------------------------------------------------------------------- - if (SPI_START) - { - spi_ready = 0; - spi_count = 0; // Reset spi counter - spi_slave = HEADERS; // Set state machine - spi_master = HEADERM; - spi_enable = 0; // Communication in progress + spi_ready = 0; + spi_count = 0; // Reset spi counter + spi_slave = HEADERS; // Set state machine + spi_master = HEADERM; + spi_enable = 0; // Communication in progress - SPI_CSn = 0; // Chip select - spi_Start_Flag = 1; - } + SPI_CSn = 0; // Chip select + spi_Start_Flag = 1; + } + //-------------------------------------------------------------------------- + // + // SPI Streaming Analyze + // + //-------------------------------------------------------------------------- + if(spi_Start_Flag) + { //-------------------------------------------------------------------------- // - // SPI Streaming Analyze + // Excecute When RF Module is Ready // + // Falling Edge on spi_ready + // //-------------------------------------------------------------------------- - if(spi_Start_Flag) - { - //-------------------------------------------------------------------------- - // - // Excecute When RF Module is Ready - // - // Falling Edge on spi_ready - // - //-------------------------------------------------------------------------- - if(spi_ready) + if(spi_ready) + { + Spi_Overflow_Ctr = 0; + do { - Spi_Overflow_Ctr = 0; - do + spi_ready = 0; + //-------------------------------------------------------------------------- + // Prepare the Byte to Send + //-------------------------------------------------------------------------- + if (spi_slave == HEADERS) { - spi_ready = 0; - //-------------------------------------------------------------------------- - // Prepare the Byte to Send - //-------------------------------------------------------------------------- - if (spi_slave == HEADERS) + if (Fifoready_SPK) // FIFO ready to be empty { - if (Fifoready_SPK) // FIFO ready to be empty + if (new_command_received) // { - if (new_command_received) // - { - spi_slave_config = RF_AUDIO_HDR | - RF_CMD_HDR; // Config byte - SPDAT = spi_slave_config; // Header byte - } - else - { - // Config byte - spi_slave_config = RF_AUDIO_HDR; - // Header byte - SPDAT = spi_slave_config; - } + spi_slave_config = RF_AUDIO_HDR | + RF_CMD_HDR; // Config byte + SPDAT = spi_slave_config; // Header byte } else { - if (new_command_received) - { - // Config byte - spi_slave_config = RF_CMD_HDR; - // Header byte - SPDAT = spi_slave_config; - } - else - { - spi_slave_config = 0x00; // Config byte - SPDAT = spi_slave_config; // Header byte - } + // Config byte + spi_slave_config = RF_AUDIO_HDR; + // Header byte + SPDAT = spi_slave_config; } - spi_slave = GET_SOUND_FIFO; // Next state } - else if (spi_slave == GET_SOUND_FIFO) + else { - if (spi_count == 17) - spi_slave = PUT_COMMAND; // Next state - if (spi_slave_config & RF_AUDIO_HDR) - { - SPDAT = FIFO_SPK_get(); // Get data from FIFO + if (new_command_received) + { + // Config byte + spi_slave_config = RF_CMD_HDR; + // Header byte + SPDAT = spi_slave_config; } else - SPDAT = 0x00; // No data to transmit - + { + spi_slave_config = 0x00; // Config byte + SPDAT = spi_slave_config; // Header byte + } } - else if (spi_slave == PUT_COMMAND) + spi_slave = GET_SOUND_FIFO; // Next state + } + else if (spi_slave == GET_SOUND_FIFO) + { + if (spi_count == 17) + spi_slave = PUT_COMMAND; // Next state + if (spi_slave_config & RF_AUDIO_HDR) + { + SPDAT = FIFO_SPK_get(); // Get data from FIFO + } + else + SPDAT = 0x00; // No data to transmit + + } + else if (spi_slave == PUT_COMMAND) + { + if (spi_count == 21) { - if (spi_count == 21) + if(spi_slave_config & RF_CMD_HDR) { - if(spi_slave_config & RF_CMD_HDR) - { - new_command_received = False; - } - spi_slave = DUMMY; // Next state + new_command_received = False; } - if (spi_slave_config & RF_CMD_HDR) - { - SPDAT = rf_commands[spi_count-18]; - } - else - SPDAT = 0x00; // No command to transmit + spi_slave = DUMMY; // Next state } - else if (spi_slave == DUMMY) + if (spi_slave_config & RF_CMD_HDR) { - SPDAT = 0x00; // Dummy byte in case of big frame + SPDAT = rf_commands[spi_count-18]; } + else + SPDAT = 0x00; // No command to transmit + } + else if (spi_slave == DUMMY) + { + SPDAT = 0x00; // Dummy byte in case of big frame + } - spi_count++; - //-------------------------------------------------------------------------- - // Analyze the byte received - //-------------------------------------------------------------------------- - if (spi_master == HEADERM) - { - while (!(SPSTA == 0x80)); // Wait SPI response - if(RF_OFFLINE) - return; + spi_count++; + //-------------------------------------------------------------------------- + // Analyze the byte received + //-------------------------------------------------------------------------- + if (spi_master == HEADERM) + { + while (!(SPSTA == 0x80)); // Wait SPI response + if(RF_OFFLINE) + return; - spi_master_config = SPDAT; + spi_master_config = SPDAT; - if (SPDAT & RF_2FRAMES_HDR) // Double frame - spi_lenght_data = 34; - else - spi_lenght_data = 17; - spi_master = PUT_SOUND_FIFO; // Go to the next state + if (SPDAT & RF_2FRAMES_HDR) // Double frame + spi_lenght_data = 34; + else + spi_lenght_data = 17; + spi_master = PUT_SOUND_FIFO; // Go to the next state + } + else if (spi_master == PUT_SOUND_FIFO) + { + while (!(SPSTA == 0x80)); // Wait SPI response + if(RF_OFFLINE) + return; + + if (spi_master_config & RF_AUDIO_HDR) + { + P1_0 = 1; + received_rf_data[spi_count-2] = SPDAT; } - else if (spi_master == PUT_SOUND_FIFO) + if (spi_count == (spi_lenght_data + 1)) + // Go to the next state + spi_master = READ_COMMAND; + } + else if (spi_master == READ_COMMAND) + { + while (!(SPSTA == 0x80)); // Wait SPI response + if(RF_OFFLINE) + return; + + if (spi_master_config & RF_CMD_HDR) { - while (!(SPSTA == 0x80)); // Wait SPI response - if(RF_OFFLINE) - return; + if (spi_count <= spi_lenght_data + 5) + received_status[spi_count - \ + spi_lenght_data - 2] = SPDAT; - if (spi_master_config & RF_AUDIO_HDR) + if (spi_count == spi_lenght_data + 6) { - P1_0 = 1; - received_rf_data[spi_count-2] = SPDAT; + RF_Status_Temp = SPDAT; + if(RF_Status < RF_Status_Temp) + RF_Status = RF_Status_Temp; } - if (spi_count == (spi_lenght_data + 1)) - // Go to the next state - spi_master = READ_COMMAND; } - else if (spi_master == READ_COMMAND) + if (spi_count == spi_lenght_data + 6) { - while (!(SPSTA == 0x80)); // Wait SPI response - if(RF_OFFLINE) - return; + new_cmd_enabled = True; - if (spi_master_config & RF_CMD_HDR) - { - if (spi_count <= spi_lenght_data + 5) - received_status[spi_count - \ - spi_lenght_data - 2] = SPDAT; + spi_Start_Flag = 0; + SPI_CSn = 1; // Chip deselect + spi_enable = 1; - if (spi_count == spi_lenght_data + 6) - { - RF_Status_Temp = SPDAT; - if(RF_Status < RF_Status_Temp) - RF_Status = RF_Status_Temp; - } - } - if (spi_count == spi_lenght_data + 6) + // + // Store Sound Data in the FIFO MIC + // + // Double frame + if (spi_master_config & (RF_2FRAMES_HDR | \ + RF_AUDIO_HDR)) { - new_cmd_enabled = True; - - spi_Start_Flag = 0; - SPI_CSn = 1; // Chip deselect - spi_enable = 1; - - // - // Store Sound Data in the FIFO MIC - // - // Double frame - if (spi_master_config & (RF_2FRAMES_HDR | \ - RF_AUDIO_HDR)) + FIFO_MIC_put_n(spi_lenght_data); + } + // + // Store STATUS in the FIFO + // + if (spi_master_config & RF_CMD_HDR) + { + if(received_status[0]) { - FIFO_MIC_put_n(spi_lenght_data); - } - // - // Store STATUS in the FIFO - // - if (spi_master_config & RF_CMD_HDR) - { - if(received_status[0]) - { - i = 0; - do{ - FIFO_STT_put(received_status[i]); - i++; - } while (i<4); - } - } - //if (spi_slave_config & RF_CMD_HDR) - //printf("\n"); - return; - } + i = 0; + do{ + FIFO_STT_put(received_status[i]); + i++; + } while (i<4); + } + } + //if (spi_slave_config & RF_CMD_HDR) + //printf("\n"); + return; } - Spi_Overflow_Ctr++; - } while (spi_ready&&(Spi_Overflow_Ctr<5)); - } - } + } + Spi_Overflow_Ctr++; + } while (spi_ready&&(Spi_Overflow_Ctr<5)); + } } } Modified: firmware/fuxusb/trunk/src/spi_task.h =================================================================== --- firmware/fuxusb/trunk/src/spi_task.h 2008-05-22 09:41:39 UTC (rev 1187) +++ firmware/fuxusb/trunk/src/spi_task.h 2008-05-22 09:48:32 UTC (rev 1188) @@ -34,7 +34,6 @@ extern uint8_t RF_Status; extern bit new_cmd_enabled; extern bit new_command_received; -extern bit spi_task_on_Flag; /* Functions */ void spi_task_init(void); |