[tuxdroid-svn] r1266 - firmware/fuxusb/branches/new_rf/src
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2008-06-25 11:11:16
|
Author: jaguarondi Date: 2008-06-25 13:11:17 +0200 (Wed, 25 Jun 2008) New Revision: 1266 Modified: firmware/fuxusb/branches/new_rf/src/fifo_mic.c firmware/fuxusb/branches/new_rf/src/fifo_mic.h firmware/fuxusb/branches/new_rf/src/fifo_spk.c firmware/fuxusb/branches/new_rf/src/fifo_spk.h firmware/fuxusb/branches/new_rf/src/spi_task.c firmware/fuxusb/branches/new_rf/src/usb_ep.c firmware/fuxusb/branches/new_rf/src/usb_ep.h firmware/fuxusb/branches/new_rf/src/usb_task.c Log: * Had some trouble to add the microphone. Now it works but the audio output is disturbed when recording. Some optimizations have to be done in the USB. Modified: firmware/fuxusb/branches/new_rf/src/fifo_mic.c =================================================================== --- firmware/fuxusb/branches/new_rf/src/fifo_mic.c 2008-06-25 08:30:11 UTC (rev 1265) +++ firmware/fuxusb/branches/new_rf/src/fifo_mic.c 2008-06-25 11:11:17 UTC (rev 1266) @@ -28,6 +28,7 @@ #include "config.h" #include "global.h" #include "fifo_mic.h" +#include "lib_mcu\usb\usb_drv.h" /** \name Fifo's constants * @{ */ @@ -89,6 +90,16 @@ Mic_buf[FifoIn_MIC_Idx++ & (MIC_BUF_SIZE-1)] = \ p[n-i]; } while (-- i); +/*void FIFO_MIC_put_n(uint8_t *p, uint8_t n)*/ +/*{ */ + /*uint8_t i=0;*/ + /*do*/ + /*{*/ + /*if ((FifoIn_MIC_Idx - FifoOut_MIC_Idx) == MIC_BUF_SIZE)*/ + /*return;*/ + + /*Mic_buf[FifoIn_MIC_Idx++ & (MIC_BUF_SIZE-1)] = p[i++];*/ + /*} while (--n);*/ } /** @@ -96,11 +107,18 @@ * \param Data : The data to push. * \ingroup fifo_mic */ -uint8_t FIFO_MIC_get (void) +void FIFO_MIC_get (void) { - /* Fifo empty */ - if (FifoOut_MIC_Idx == FifoIn_MIC_Idx) - return 0x80; - - return Mic_buf[FifoOut_MIC_Idx++ & (MIC_BUF_SIZE - 1)]; + uint8_t i = 8; + do { + if (FifoOut_MIC_Idx == FifoIn_MIC_Idx) + { + Usb_write_byte(0x80); + } + else + { + Usb_write_byte(Mic_buf[FifoOut_MIC_Idx++ & (MIC_BUF_SIZE - 1)]); + } + i--; + } while(i); } Modified: firmware/fuxusb/branches/new_rf/src/fifo_mic.h =================================================================== --- firmware/fuxusb/branches/new_rf/src/fifo_mic.h 2008-06-25 08:30:11 UTC (rev 1265) +++ firmware/fuxusb/branches/new_rf/src/fifo_mic.h 2008-06-25 11:11:17 UTC (rev 1266) @@ -31,6 +31,6 @@ extern void FIFO_MIC_init (void); extern bit FIFO_MIC_ready(void); extern void FIFO_MIC_put_n(uint8_t *p, uint8_t const n); -extern uint8_t FIFO_MIC_get (void); +extern void FIFO_MIC_get (void); #endif /*_FIFO_MIC_H_*/ Modified: firmware/fuxusb/branches/new_rf/src/fifo_spk.c =================================================================== --- firmware/fuxusb/branches/new_rf/src/fifo_spk.c 2008-06-25 08:30:11 UTC (rev 1265) +++ firmware/fuxusb/branches/new_rf/src/fifo_spk.c 2008-06-25 11:11:17 UTC (rev 1266) @@ -94,11 +94,11 @@ * \return The popped byte. * \ingroup fifo_spk */ -uint8_t FIFO_SPK_get(void) +void FIFO_SPK_get_n(uint8_t *p, uint8_t n) { - /* Fifo empty */ - if (FifoOut_SPK_Idx == FifoIn_SPK_Idx) - return 0x80; - - return Spk_buf[FifoOut_SPK_Idx++ & (SPK_BUF_SIZE - 1)]; + uint8_t i; + for (i=0; i<n; i++) + { + p[i] = Spk_buf[FifoOut_SPK_Idx++ & (SPK_BUF_SIZE - 1)]; + } } Modified: firmware/fuxusb/branches/new_rf/src/fifo_spk.h =================================================================== --- firmware/fuxusb/branches/new_rf/src/fifo_spk.h 2008-06-25 08:30:11 UTC (rev 1265) +++ firmware/fuxusb/branches/new_rf/src/fifo_spk.h 2008-06-25 11:11:17 UTC (rev 1266) @@ -32,6 +32,6 @@ extern void FIFO_SPK_init (void); extern uint8_t FIFO_SPK_length(void); extern void FIFO_SPK_put_n (uint8_t const n); -extern uint8_t FIFO_SPK_get (void); +extern void FIFO_SPK_get_n (uint8_t *, uint8_t); #endif /* _FIFO_SPK_H_*/ Modified: firmware/fuxusb/branches/new_rf/src/spi_task.c =================================================================== --- firmware/fuxusb/branches/new_rf/src/spi_task.c 2008-06-25 08:30:11 UTC (rev 1265) +++ firmware/fuxusb/branches/new_rf/src/spi_task.c 2008-06-25 11:11:17 UTC (rev 1266) @@ -76,8 +76,8 @@ * @{ */ /** Size of the audio data in the SPI frame */ // XXX Double frame -//#define AUDIO_SIZE 34 -#define AUDIO_SIZE 17 +#define AUDIO_SPK_SIZE 34 +#define AUDIO_MIC_SIZE 17 /* Bits of the config byte */ #define _BV(x) (1<<x) @@ -92,7 +92,6 @@ #define SPI_CONFIG_OFFSET 1 #define SPI_DATA_OFFSET 3 #define SPI_AUDIO_OFFSET (SPI_DATA_OFFSET + CMD_SIZE) -#define SPI_PREVAUDIO_OFFSET (SPI_AUDIO_OFFSET + AUDIO_SIZE) /*! @} */ static uint8_t spi_in[SPI_SIZE], spi_out[SPI_SIZE], spi_idx; @@ -241,30 +240,16 @@ spi_out[i+SPI_DATA_OFFSET] = command_received[i]; } } - if (FIFO_SPK_length() >= 34)//AUDIO_SIZE) + if (FIFO_SPK_length() >= AUDIO_SPK_SIZE) { config |= CFG_AUDIO_MK; - //for (i=0; i<AUDIO_SIZE; i++) - for (i=0; i<34; i++) - { - //static uint8_t cnt = 0; - //static bit dir = 1; - spi_out[i+SPI_AUDIO_OFFSET] = FIFO_SPK_get(); - //spi_out[i+SPI_AUDIO_OFFSET] = cnt; - //if (dir) - //cnt++; - //else - //cnt--; - //if ((cnt == 0xFF) || (cnt == 0)) - //dir = !dir; - } + FIFO_SPK_get_n(&spi_out[SPI_AUDIO_OFFSET], AUDIO_SPK_SIZE); } /* Store the frame index and the config byte. */ spi_out[SPI_IDX_OFFSET] = idx_out++; spi_out[SPI_CONFIG_OFFSET] = config; - spi_out[2] = 0x81; //XXX debug /* XXX debug */ /*for (i=0; i<SPI_SIZE; i++)*/ @@ -290,19 +275,9 @@ FIFO_STT_put(spi_in[i+SPI_DATA_OFFSET]); } } - if (config & CFG_PREVAUDIO_MK) - { - for (i=0; i<AUDIO_SIZE; i++) - { - FIFO_MIC_put_n(&spi_in[i+SPI_PREVAUDIO_OFFSET], AUDIO_SIZE); - } - } if (config & CFG_AUDIO_MK) { - for (i=0; i<AUDIO_SIZE; i++) - { - FIFO_MIC_put_n(&spi_in[i+SPI_AUDIO_OFFSET], AUDIO_SIZE); - } + FIFO_MIC_put_n(&spi_in[SPI_AUDIO_OFFSET], AUDIO_MIC_SIZE); } } } @@ -396,7 +371,7 @@ spi_slave = PUT_COMMAND; // Next state if (spi_slave_config & RF_AUDIO_HDR) { - SPDAT = FIFO_SPK_get(); // Get data from FIFO +// SPDAT = FIFO_SPK_get(); // Get data from FIFO } else SPDAT = 0x00; // No data to transmit Modified: firmware/fuxusb/branches/new_rf/src/usb_ep.c =================================================================== --- firmware/fuxusb/branches/new_rf/src/usb_ep.c 2008-06-25 08:30:11 UTC (rev 1265) +++ firmware/fuxusb/branches/new_rf/src/usb_ep.c 2008-06-25 11:11:17 UTC (rev 1266) @@ -53,7 +53,7 @@ static void clear_cmdout_ep(void); static void clear_cmdin_ep(void); -static bit fifo_mic_loaded = False; +bit fifo_mic_loaded = False; /** * \brief Parse all endpoints @@ -128,17 +128,18 @@ */ void fill_mic_ep(void) { - if(usb_configuration_nb && FIFO_MIC_ready() && !fifo_mic_loaded) + //if(usb_configuration_nb && FIFO_MIC_ready() && !fifo_mic_loaded) { - uint8_t i; +// uint8_t i; Usb_select_ep(EP_AUDIO_IN); - i = 8; - do { - Usb_write_byte(FIFO_MIC_get()); - i--; - } while(i); + FIFO_MIC_get(); + /*i = 8;*/ + /*do {*/ + /*Usb_write_byte(FIFO_MIC_get());*/ + /*i--;*/ + /*} while(i);*/ Usb_set_tx_ready(); fifo_mic_loaded = True; Modified: firmware/fuxusb/branches/new_rf/src/usb_ep.h =================================================================== --- firmware/fuxusb/branches/new_rf/src/usb_ep.h 2008-06-25 08:30:11 UTC (rev 1265) +++ firmware/fuxusb/branches/new_rf/src/usb_ep.h 2008-06-25 11:11:17 UTC (rev 1266) @@ -37,5 +37,6 @@ void endpoints_parser(void); void send_status(void); void fill_mic_ep(void); +extern bit fifo_mic_loaded; #endif // _USB_EP_H_ Modified: firmware/fuxusb/branches/new_rf/src/usb_task.c =================================================================== --- firmware/fuxusb/branches/new_rf/src/usb_task.c 2008-06-25 08:30:11 UTC (rev 1265) +++ firmware/fuxusb/branches/new_rf/src/usb_task.c 2008-06-25 11:11:17 UTC (rev 1266) @@ -33,6 +33,8 @@ #include "usb_commands.h" #include "usb_ep.h" #include "misc.h" +#include "fifo_mic.h" +#include "usb_ep.h" #include "lib_mcu\usb\usb_drv.h" /** @@ -98,7 +100,8 @@ * Load the microphone EP if it's not already loaded and if the micro * fifo is ready. */ - fill_mic_ep(); + if(usb_configuration_nb && FIFO_MIC_ready() && !fifo_mic_loaded) + fill_mic_ep(); /* * Prepare the statuses when a request has been received |