[tuxdroid-svn] r1187 - firmware/fuxusb/trunk/src
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2008-05-22 09:41:35
|
Author: Paul_R Date: 2008-05-22 11:41:39 +0200 (Thu, 22 May 2008) New Revision: 1187 Modified: firmware/fuxusb/trunk/src/bootloader.c firmware/fuxusb/trunk/src/fifo_mic.c firmware/fuxusb/trunk/src/global.c firmware/fuxusb/trunk/src/global.h firmware/fuxusb/trunk/src/i2c.c firmware/fuxusb/trunk/src/main.c firmware/fuxusb/trunk/src/misc.c firmware/fuxusb/trunk/src/spi_task.c firmware/fuxusb/trunk/src/usb_commands.c firmware/fuxusb/trunk/src/usb_enum.c firmware/fuxusb/trunk/src/usb_ep.c Log: * Comments, typo and cleanup. Modified: firmware/fuxusb/trunk/src/bootloader.c =================================================================== --- firmware/fuxusb/trunk/src/bootloader.c 2008-05-22 08:53:29 UTC (rev 1186) +++ firmware/fuxusb/trunk/src/bootloader.c 2008-05-22 09:41:39 UTC (rev 1187) @@ -36,13 +36,24 @@ bit i2c_bootloading_Flag; /* Statics defs */ +/** This flag indicate if the bootloader is activated or not. + * It's used in the main loop to switch between the SPI task and the i2c task. + */ bit i2c_task_on_Flag; +/** \name Data control + * @{ */ +/** Page size */ uint8_t page_size; +/** Number of packets per page */ uint8_t packets_per_page; +/** Adress number */ uint8_t address_idx; +/** Packet number */ uint8_t packet_idx; +/** Address tracking */ uint16_t address_tracking; blHeader_t blHeader; +/* @} */ static void bl_init(void); static void bl_exit(void); Modified: firmware/fuxusb/trunk/src/fifo_mic.c =================================================================== --- firmware/fuxusb/trunk/src/fifo_mic.c 2008-05-22 08:53:29 UTC (rev 1186) +++ firmware/fuxusb/trunk/src/fifo_mic.c 2008-05-22 09:41:39 UTC (rev 1187) @@ -93,7 +93,7 @@ return; } - FifoTbl_MIC[FifoIn_MIC_Idx] = received_data[n - i]; + FifoTbl_MIC[FifoIn_MIC_Idx] = received_rf_data[n - i]; FifoIn_MIC_Idx++; // Update FIFO in index if (FifoIn_MIC_Idx == FIFOTBL_MIC_MAX) FifoIn_MIC_Idx = 0; Modified: firmware/fuxusb/trunk/src/global.c =================================================================== --- firmware/fuxusb/trunk/src/global.c 2008-05-22 08:53:29 UTC (rev 1186) +++ firmware/fuxusb/trunk/src/global.c 2008-05-22 09:41:39 UTC (rev 1187) @@ -23,19 +23,27 @@ #include "config.h" #include "version.h" +/** Command_Ctr contain the number of bytes received in the CMD_OUT EP. */ uint8_t Command_Ctr; -/* Counters */ +/** This counter is used to wait before sending data on the i2c bus */ uint8_t i2c_wait_counter; -/* Buffers */ +/* \name Buffers + * @{ */ +/** Commands received on the CMD_OUT EP. The EP size is 64 */ uint8_t idata command_received[64]; -uint8_t received_data[34]; +/** Data received from the RF. The maximum byte in a frame is 34 */ +uint8_t received_rf_data[34]; +/** Commands received from USB for the RF. */ uint8_t idata rf_commands[4]; +/* @} */ -/* Dongle infos */ +/** \name Dongle infos + * @{ */ code version_t info_version ={VERSION_CMD, CPU_VER_JOIN(FUXUSB_CPU_NUM, VER_MAJOR), VER_MINOR, VER_UPDATE}; code revision_t info_revision={REVISION_CMD, REVISION_NUMBER, RELEASE_TYPE}; code author_t info_author={AUTHOR_CMD, AUTHOR_ID, VARIATION}; +/* @} */ Modified: firmware/fuxusb/trunk/src/global.h =================================================================== --- firmware/fuxusb/trunk/src/global.h 2008-05-22 08:53:29 UTC (rev 1186) +++ firmware/fuxusb/trunk/src/global.h 2008-05-22 09:41:39 UTC (rev 1187) @@ -159,7 +159,7 @@ /* USB buffers */ extern uint8_t idata command_received[]; -extern uint8_t received_data[]; +extern uint8_t received_rf_data[]; extern uint8_t idata rf_commands[]; /* Dongle infos */ Modified: firmware/fuxusb/trunk/src/i2c.c =================================================================== --- firmware/fuxusb/trunk/src/i2c.c 2008-05-22 08:53:29 UTC (rev 1186) +++ firmware/fuxusb/trunk/src/i2c.c 2008-05-22 09:41:39 UTC (rev 1187) @@ -25,18 +25,26 @@ #include "i2c.h" -/* I2C status and address variables */ +/** \name I2C status and address variables + * @{ */ uint8_t i2cDeviceAddrRW; volatile I2C_FLAGS i2cFlags; -/* send/transmit buffer (outgoing data) */ +/* @} */ + +/** \name send/transmit buffer (outgoing data) + * @} */ uint8_t xdata i2cSendData[I2C_SEND_DATA_BUFFER_SIZE]; uint8_t *i2cDataToSend; uint8_t i2cSendDataIndex; uint8_t i2cSendDataLength; -/* receive buffer (incoming data) */ +/* @} */ + +/** \name receive buffer (incoming data) + * @{ */ uint8_t xdata i2cReceiveData[I2C_RECEIVE_DATA_BUFFER_SIZE]; uint8_t i2cReceiveDataIndex; uint8_t i2cReceiveDataLength; +/* @} */ /* function pointer to i2c receive routine */ /* I2cSlaveReceive is called when this processor is addressed as a slave for Modified: firmware/fuxusb/trunk/src/main.c =================================================================== --- firmware/fuxusb/trunk/src/main.c 2008-05-22 08:53:29 UTC (rev 1186) +++ firmware/fuxusb/trunk/src/main.c 2008-05-22 09:41:39 UTC (rev 1187) @@ -19,9 +19,6 @@ /* $Id$ */ - - - /** \file main.c * \brief Fuxusb main function * \ingroup main Modified: firmware/fuxusb/trunk/src/misc.c =================================================================== --- firmware/fuxusb/trunk/src/misc.c 2008-05-22 08:53:29 UTC (rev 1186) +++ firmware/fuxusb/trunk/src/misc.c 2008-05-22 09:41:39 UTC (rev 1187) @@ -28,6 +28,7 @@ #include "global.h" #include "misc.h" +/** Start of frame counter */ static uint16_t usb_sof_counter = 0; /** Modified: firmware/fuxusb/trunk/src/spi_task.c =================================================================== --- firmware/fuxusb/trunk/src/spi_task.c 2008-05-22 08:53:29 UTC (rev 1186) +++ firmware/fuxusb/trunk/src/spi_task.c 2008-05-22 09:41:39 UTC (rev 1187) @@ -54,9 +54,21 @@ } spi_master; /* Externs defs */ +/** Indicate the RF state. + */ uint8_t RF_Status; +/** This flag is set when a new command can be received from the USB. + * When a command for tux is received, this flag = False. When the commands has + * been sent to the RF, this flag is set. + */ bit new_cmd_enabled; +/** This flag is set when a command for tux is received. It indicate the + * 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 */ @@ -288,7 +300,7 @@ if (spi_master_config & RF_AUDIO_HDR) { P1_0 = 1; - received_data[spi_count-2] = SPDAT; + received_rf_data[spi_count-2] = SPDAT; } if (spi_count == (spi_lenght_data + 1)) // Go to the next state @@ -316,8 +328,7 @@ if (spi_count == spi_lenght_data + 6) { new_cmd_enabled = True; - //new_cmd_enabled = True; -// USB_StatusProcess_Permit_Flag = True; + spi_Start_Flag = 0; SPI_CSn = 1; // Chip deselect spi_enable = 1; Modified: firmware/fuxusb/trunk/src/usb_commands.c =================================================================== --- firmware/fuxusb/trunk/src/usb_commands.c 2008-05-22 08:53:29 UTC (rev 1186) +++ firmware/fuxusb/trunk/src/usb_commands.c 2008-05-22 09:41:39 UTC (rev 1187) @@ -71,6 +71,7 @@ case DONGLE_CMD_HDR: dongle_cmd_parser(); break; + /* Commands for Tux */ case TUX_CMD_HDR: new_cmd_enabled = False; @@ -79,6 +80,7 @@ for(i=0;i < 4;i++) rf_commands[i] = command_received[i]; break; + /* Bootloader commands */ case BOOTLOADER_CMD_HDR: bootloader_cmd_parser(); @@ -95,7 +97,6 @@ void prepare_status(void) { uint8_t data i; - if((status_requested) && (CMD_IN_Bank_Nb < 2)) { @@ -167,12 +168,15 @@ case STATUS_REQUEST: status_requested = True; break; + case RF_RESET: reset_rf(); break; + case USB_RESET: reset_dongle(); break; + case ISP_MODE: jump_bootloader(); break; @@ -250,6 +254,7 @@ SPCON = 0x14; /* Switch off the LED */ Led_0_off(); + /* * Set bootloader fuse, detach and attach usb, and active * bootloader mode. Modified: firmware/fuxusb/trunk/src/usb_enum.c =================================================================== --- firmware/fuxusb/trunk/src/usb_enum.c 2008-05-22 08:53:29 UTC (rev 1186) +++ firmware/fuxusb/trunk/src/usb_enum.c 2008-05-22 09:41:39 UTC (rev 1187) @@ -55,7 +55,8 @@ uint8_t usb_configuration_nb = 0; /*! @} */ - +/** \name Standard enumeration functions + * @{ */ static void usb_get_descriptor(void); static void usb_read_request(void); static void usb_set_address(void); @@ -66,8 +67,10 @@ static void usb_get_configuration(void); static void usb_get_interface(void); static void usb_set_interface(void); +/* @} */ -/* AUDIO SPECIFIC REQUESTS */ +/** \name Audio enumeration functions + * @{ */ static void usb_get_current(void); static void usb_get_min(void); static void usb_get_max(void); @@ -76,15 +79,20 @@ static void usb_set_min(void); static void usb_set_max(void); static void usb_set_res(void); +/* @} */ -/* HID SPECIFIC REQUESTS */ +/** \name HID enumeration function + * @{ */ static void usb_hid_set_report(void); static void usb_hid_set_idle(void); static void usb_hid_get_idle(void); +/* @} */ -/* MISC COMMANDS */ +/** \name Misc functions + * @{ */ static void stall_request(void); static void send_zlp(void); +/* @} */ /** \name Init functions * @{ */ Modified: firmware/fuxusb/trunk/src/usb_ep.c =================================================================== --- firmware/fuxusb/trunk/src/usb_ep.c 2008-05-22 08:53:29 UTC (rev 1186) +++ firmware/fuxusb/trunk/src/usb_ep.c 2008-05-22 09:41:39 UTC (rev 1187) @@ -34,9 +34,16 @@ #include "lib_mcu\usb\usb_drv.h" /* Externs defs */ +/** \name Banks control. + * EP 4 and 5 uses ping-pong mode. The banks number must be controlled by + * firmware. + * @{ */ uint8_t CMD_OUT_Bank_Nb; uint8_t CMD_IN_Bank_Nb; +/* @} */ +/** Flag to switch between the normal speaker pipe and the tts pipe */ bit tts_pipe_selected = False; +/** Flag to indicate that the statuses must be sent to the PC */ bit status_requested = False; /* Statics defs */ @@ -54,7 +61,7 @@ */ void endpoints_parser(void) { - + /* EP0 : enumeration EP */ if (Usb_test_it_ep(0)) { Usb_select_ep(EP_CONTROL); @@ -62,15 +69,26 @@ usb_enumeration_process(); } - if(Usb_test_it_ep(EP_AUDIO_OUT_TTS)) - read_tts_ep(); + /* EP1 : Microphone EP */ + if(Usb_test_it_ep(EP_AUDIO_IN)) + { + clear_mic_ep(); + } + /* EP2 : Speaker EP */ if(Usb_test_it_ep(EP_AUDIO_OUT)) + { read_spk_ep(); + } - if(Usb_test_it_ep(EP_AUDIO_IN)) - clear_mic_ep(); + /* EP3 : TTS EP */ + if(Usb_test_it_ep(EP_AUDIO_OUT_TTS)) + { + read_tts_ep(); + } + + /* EP5 : Command out EP (PC -> dongle) */ if(Usb_test_it_ep(EP_CMD_OUT)) { if (new_cmd_enabled) @@ -79,8 +97,12 @@ clear_cmdout_ep(); } } + + /* EP4 : Command in EP (dongle -> PC) */ if (Usb_test_it_ep(EP_CMD_IN)) + { clear_cmdin_ep(); + } } /** |