[tuxdroid-svn] r1114 - in firmware/fuxusb/branches/usb_cleanup: . bootloader usb
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2008-05-06 10:08:33
|
Author: Paul_R Date: 2008-05-06 12:08:37 +0200 (Tue, 06 May 2008) New Revision: 1114 Modified: firmware/fuxusb/branches/usb_cleanup/bootloader/bootloading.c firmware/fuxusb/branches/usb_cleanup/bootloader/bootloading.h firmware/fuxusb/branches/usb_cleanup/main.c firmware/fuxusb/branches/usb_cleanup/usb/usb_misc.c firmware/fuxusb/branches/usb_cleanup/usb/usb_misc.h firmware/fuxusb/branches/usb_cleanup/usb/usb_task.c firmware/fuxusb/branches/usb_cleanup/usb/usb_task.h Log: * Moved the calls of spi_task() and i2c_task() from usb_task.c to main.c * Moved some stuff from usb_task to usb_misc Modified: firmware/fuxusb/branches/usb_cleanup/bootloader/bootloading.c =================================================================== --- firmware/fuxusb/branches/usb_cleanup/bootloader/bootloading.c 2008-05-06 10:00:17 UTC (rev 1113) +++ firmware/fuxusb/branches/usb_cleanup/bootloader/bootloading.c 2008-05-06 10:08:37 UTC (rev 1114) @@ -22,6 +22,8 @@ uint8_t packet_idx; uint16_t address_tracking; +bit i2c_bootloading_Flag = 0; /* bootloader mode */ + blHeader_t blHeader; /* header for bootloading */ /* Modified: firmware/fuxusb/branches/usb_cleanup/bootloader/bootloading.h =================================================================== --- firmware/fuxusb/branches/usb_cleanup/bootloader/bootloading.h 2008-05-06 10:00:17 UTC (rev 1113) +++ firmware/fuxusb/branches/usb_cleanup/bootloader/bootloading.h 2008-05-06 10:08:37 UTC (rev 1114) @@ -35,6 +35,7 @@ } blHeader_t; extern blHeader_t blHeader; +extern bit i2c_bootloading_Flag; /* * Extern declarations Modified: firmware/fuxusb/branches/usb_cleanup/main.c =================================================================== --- firmware/fuxusb/branches/usb_cleanup/main.c 2008-05-06 10:00:17 UTC (rev 1113) +++ firmware/fuxusb/branches/usb_cleanup/main.c 2008-05-06 10:08:37 UTC (rev 1114) @@ -16,6 +16,10 @@ #include "lib_c/stdint.h" #include "global.h" #include "usb\usb_task.h" +#include "rf.h" +#include "spi/spi_task.h" +#include "bootloader/i2c.h" +#include "bootloader/bootloading.h" #ifdef MAIN_DEBUG #include "lib_mcu\uart\uart_lib.h" @@ -67,17 +71,29 @@ #ifdef MAIN_DEBUG uart_init(); - printf("\n\n= TUX started ==\n"); + printf("\n== Tux started ==\n"); #endif + while(1) { usb_task(); - /* XXX - if (BOOT_MODE) - bootloader_task(); - else - spi_task(); - */ + if(usb_connected_Flag) + { + if (i2c_bootloading_Flag) /* I2C bootloading */ + { + i2c_task(); + } + else if(!RF_OFFLINE) + { + spi_task(); + } + else // if RF_OFFLINE + { + if (Cpu_reset) + rf_reset(); + Cpu_reset = 0; + } + } } } Modified: firmware/fuxusb/branches/usb_cleanup/usb/usb_misc.c =================================================================== --- firmware/fuxusb/branches/usb_cleanup/usb/usb_misc.c 2008-05-06 10:00:17 UTC (rev 1113) +++ firmware/fuxusb/branches/usb_cleanup/usb/usb_misc.c 2008-05-06 10:08:37 UTC (rev 1114) @@ -4,6 +4,8 @@ #include "usb/usb_drv.h" #include "usb/usb_enum.h" #include "spi/spi_task.h" +#include "spi/spi_lib.h" +#include "bootloader/bootloading.h" #include "modules/fifo/fifo.h" #include "modules/fifo/fifo_spk.h" #include "modules/fifo/fifo_mic.h" @@ -97,3 +99,38 @@ } } +void tick_1ms(void) +{ +Usb_clear_sof(); + usb_sof_counter ++; // == 0xFF == 250ms + + if(spi_watchdog_ctr) + { + spi_watchdog_ctr--; // Decrement Watchdog + } + //--------------------------------------------------------- + // Reset SPI Transfer + //--------------------------------------------------------- + else if (!i2c_bootloading_Flag) + { + //Led_1_on(); + spi_slave = HEADERS; // Set state machine + spi_master = HEADERM; + spi_enable = 1; // Communication Authorized + SPI_CSn = 1; // Chip select + spi_Start_Flag = 0; + spi_ready = 0; + } + + //-------------------------------------------------------------------------- + // I2C pause timer + //-------------------------------------------------------------------------- + if (i2c_wait_counter) i2c_wait_counter--; + + //-------------------------------------------------------------------------- + // Led Behavior + //-------------------------------------------------------------------------- + if(usb_connected_Flag && usb_configuration_nb) + led_behavior(); +} + Modified: firmware/fuxusb/branches/usb_cleanup/usb/usb_misc.h =================================================================== --- firmware/fuxusb/branches/usb_cleanup/usb/usb_misc.h 2008-05-06 10:00:17 UTC (rev 1113) +++ firmware/fuxusb/branches/usb_cleanup/usb/usb_misc.h 2008-05-06 10:08:37 UTC (rev 1114) @@ -1,4 +1,5 @@ void resume(void); void reset(void); void suspend(void); +void tick_1ms(void); void led_behavior(void); Modified: firmware/fuxusb/branches/usb_cleanup/usb/usb_task.c =================================================================== --- firmware/fuxusb/branches/usb_cleanup/usb/usb_task.c 2008-05-06 10:00:17 UTC (rev 1113) +++ firmware/fuxusb/branches/usb_cleanup/usb/usb_task.c 2008-05-06 10:08:37 UTC (rev 1114) @@ -13,16 +13,11 @@ #include "config.h" #include "global.h" #include "rf.h" -#include "spi\spi_lib.h" #include "usb\usb_drv.h" #include "usb/usb_misc.h" #include "usb/usb_endpoints.h" - #include "usb\usb_task.h" -#include "spi\spi_task.h" #include "usb\usb_enum.h" -#include "modules\timer_soft\timer_soft.h" -#include "modules\fifo\fifo_spk.h" #include "modules\fifo\fifo_mic.h" #include "modules\fifo\fifo.h" #include "modules\fifo_stt\fifo_stt.h" @@ -43,9 +38,9 @@ unsigned char pong_missed; /* counting the pong missed on the SPI */ #endif bit EP_AUDIOIN_Loaded = 0; -bit i2c_bootloading_Flag = 0; /* bootloader mode */ + bit ReadStatus_USBRequest_Flag = 0; bit Cpu_reset = 0; bit Speaker_TTS_Select_Flag = 0; @@ -114,8 +109,6 @@ USB_Bootloader_NewCmd_Flag = FALSE; } - - /*F************************************************************************** * NAME: usb_command_parser *---------------------------------------------------------------------------- @@ -179,8 +172,6 @@ } } - - void data_to_send(void) { if (CMD_IN_Bank_Nb) @@ -191,10 +182,6 @@ } } - - - - /*F************************************************************************** * NAME: usb_task *---------------------------------------------------------------------------- @@ -220,40 +207,8 @@ reset(); if (Usb_sof()) - { - Usb_clear_sof(); - usb_sof_counter ++; // == 0xFF == 250ms + tick_1ms(); - if(spi_watchdog_ctr) - { - spi_watchdog_ctr--; // Decrement Watchdog - } - //--------------------------------------------------------- - // Reset SPI Transfer - //--------------------------------------------------------- - else if (!i2c_bootloading_Flag) - { - //Led_1_on(); - spi_slave = HEADERS; // Set state machine - spi_master = HEADERM; - spi_enable = 1; // Communication Authorized - SPI_CSn = 1; // Chip select - spi_Start_Flag = 0; - spi_ready = 0; - } - - //-------------------------------------------------------------------------- - // I2C pause timer - //-------------------------------------------------------------------------- - if (i2c_wait_counter) i2c_wait_counter--; - - //-------------------------------------------------------------------------- - // Led Behavior - //-------------------------------------------------------------------------- - if(usb_connected_Flag && usb_configuration_nb) - led_behavior(); - } - //-------------------------------------------------------------------------- // // Process to load Status Data in the USB FIFO @@ -274,14 +229,12 @@ if(Fifoready_MIC) { Usb_select_ep(EP_AUDIO_IN); - //DEBUG_1 = 1; i=8; do { Usb_write_byte(FIFO_MIC_get()); // No data to transmit i--; } while(i); - //DEBUG_1 = 0; Usb_set_tx_ready(); EP_AUDIOIN_Loaded = 1; } @@ -291,29 +244,7 @@ // USB Events // //-------------------------------------------------------------------------- - if(Usb_endpoint_interrupt()) - { + if(Usb_endpoint_interrupt()) endpoints_ctr(); - } } - - - if(!usb_connected_Flag) - return; - - - if (i2c_bootloading_Flag) /* I2C bootloading */ - { - i2c_task(); - } - else if(!RF_OFFLINE) - { - spi_task(); - } - else // if RF_OFFLINE - { - if (Cpu_reset) - rf_reset(); - Cpu_reset = 0; - } } Modified: firmware/fuxusb/branches/usb_cleanup/usb/usb_task.h =================================================================== --- firmware/fuxusb/branches/usb_cleanup/usb/usb_task.h 2008-05-06 10:00:17 UTC (rev 1113) +++ firmware/fuxusb/branches/usb_cleanup/usb/usb_task.h 2008-05-06 10:08:37 UTC (rev 1114) @@ -25,7 +25,7 @@ /*_____ D E C L A R A T I O N ______________________________________________*/ extern bit Cpu_reset; -extern bit i2c_bootloading_Flag; + extern bit Speaker_TTS_Select_Flag; extern bit EP_AUDIOIN_Loaded; |