[tuxdroid-svn] r1065 - in firmware/fuxusb/branches/0.3: . modules/fifo modules/spi modules/usb modu
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2008-05-02 08:19:28
|
Author: Paul_R Date: 2008-05-02 10:19:25 +0200 (Fri, 02 May 2008) New Revision: 1065 Modified: firmware/fuxusb/branches/0.3/config.h firmware/fuxusb/branches/0.3/global.c firmware/fuxusb/branches/0.3/global.h firmware/fuxusb/branches/0.3/modules/fifo/fifo_mic.c firmware/fuxusb/branches/0.3/modules/spi/spi_task.c firmware/fuxusb/branches/0.3/modules/usb/usb_task.c firmware/fuxusb/branches/0.3/modules/usb_enum/USB_ENUM.H firmware/fuxusb/branches/0.3/modules/usb_enum/usb_enum.c Log: * Merged back HID branch to 0.3 Modified: firmware/fuxusb/branches/0.3/config.h =================================================================== --- firmware/fuxusb/branches/0.3/config.h 2008-05-01 12:16:13 UTC (rev 1064) +++ firmware/fuxusb/branches/0.3/config.h 2008-05-02 08:19:25 UTC (rev 1065) @@ -81,10 +81,10 @@ /* CONFIGURATION DESCRIPTOR */ #ifdef TTS_INTERFACE_ENABLED -# define CONF_LENGTH 0x2001 // 288 +# define CONF_LENGTH 0x2901 // 297 # define NB_INTERFACE 6 #else -# define CONF_LENGTH 0xC500 // 197 +# define CONF_LENGTH 0xCE00 // 206 # define NB_INTERFACE 4 #endif @@ -130,12 +130,10 @@ #define USB_SERIAL_NUMBER {'1'<<8, '0'<<8, '0'<<8, '0'<<8, '1'<<8} #define USB_SN_LENGTH 5 - #define USB_CONFIG_NAME {'T'<<8, 'u'<<8, 'x'<<8, 'D'<<8, \ 'r'<<8, 'o'<<8, 'i'<<8, 'd'<<8} #define USB_CONFIG_LENGTH 8 - #define AUDIO_NORMAL_NAME {'T'<<8, 'u'<<8, 'x'<<8, 'D'<<8, \ 'r'<<8, 'o'<<8, 'i'<<8, 'd'<<8, '-'<<8, 'A'<<8, 'u'<<8, 'd'<<8, \ 'i'<<8, 'o'<<8} Modified: firmware/fuxusb/branches/0.3/global.c =================================================================== --- firmware/fuxusb/branches/0.3/global.c 2008-05-01 12:16:13 UTC (rev 1064) +++ firmware/fuxusb/branches/0.3/global.c 2008-05-02 08:19:25 UTC (rev 1065) @@ -29,17 +29,17 @@ //------------------------------------------------------- // SPI Controler //------------------------------------------------------- -bit spi_task_on_Flag; // = 1; // to turn ON the RF Task -// = 0; // to turn OFF the RF Task +bit spi_task_on_Flag; // = 1; // to turn ON the RF Task +// = 0; // to turn OFF the RF Task //------------------------------------------------------- // USB Controler //------------------------------------------------------- -unsigned int usb_sof_counter; -unsigned char usb_configuration_nb; -bit usb_connected_Flag; +unsigned int usb_sof_counter; +unsigned char usb_configuration_nb; +bit usb_connected_Flag; -bit CMD_OUT_Bank_Nb; // To store the number of the Bank used for the CMD_OUT Endpoint -unsigned char CMD_IN_Bank_Nb; +bit CMD_OUT_Bank_Nb; // To store the number of the Bank used for the CMD_OUT Endpoint +unsigned char CMD_IN_Bank_Nb; bit USB_ParserProcess_Permit_Flag; bit USB_StatusProcess_Permit_Flag; @@ -49,8 +49,8 @@ // I2C Controler //------------------------------------------------------- -unsigned char i2c_wait_counter = 0; -bit i2c_task_on_Flag; +unsigned char i2c_wait_counter = 0; +bit i2c_task_on_Flag; //------------------------------------------------------- // RF Controler @@ -58,13 +58,13 @@ // RF Header //------------------------------------------------------- -#define RF_2FRAMES_HDR 0x80 -#define RF_AUDIO_HDR 0x02 -#define RF_CMD_HDR 0x08 +#define RF_2FRAMES_HDR 0x80 +#define RF_AUDIO_HDR 0x02 +#define RF_CMD_HDR 0x08 //------------------------------------------------------- -bit RF_OFFLine_Back; +bit RF_OFFLine_Back; unsigned char RF_Status; unsigned char RF_Status_Temp; @@ -76,21 +76,21 @@ // From USB //------------------------------------------------------- -unsigned char USBCommand_ForDongle[65]; // For Dongle -unsigned char USBCommand_ForRF[65]; // For RF -unsigned char USBCommand_Ctr; // Store the number of byte sent by the LIBUSB -bit USBCommand_NewRequest_Flag; -unsigned char USBCommand_Header; // Needed to analyze the LIBUSB command : to RF or to I2C +unsigned char USBCommand_ForDongle[65]; // For Dongle +unsigned char USBCommand_ForRF[65]; // For RF +unsigned char USBCommand_Ctr; // Store the number of byte sent by the LIBUSB +bit USBCommand_NewRequest_Flag; +unsigned char USBCommand_Header; // Needed to analyze the LIBUSB command : to RF or to I2C -#define LIBUSB_TUX_CMD_HDR 0 -#define LIBUSB_DONGLE_CMD_HDR 1 -#define LIBUSB_BOOTLOADER_CMD_HDR 2 +#define LIBUSB_TUX_CMD_HDR 0 +#define LIBUSB_DONGLE_CMD_HDR 1 +#define LIBUSB_BOOTLOADER_CMD_HDR 2 //------------------------------------------------------- // Dongle Info //------------------------------------------------------- -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}; +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/branches/0.3/global.h =================================================================== --- firmware/fuxusb/branches/0.3/global.h 2008-05-01 12:16:13 UTC (rev 1064) +++ firmware/fuxusb/branches/0.3/global.h 2008-05-02 08:19:25 UTC (rev 1065) @@ -24,8 +24,8 @@ /*_____ D E F I N I T I O N ________________________________________________*/ // Hardware -#define rf_reset_signal P0_1 -#define RF_OFFLINE P2_3 +#define rf_reset_signal P0_1 +#define RF_OFFLINE P2_3 /*_____ D E C L A R A T I O N ______________________________________________*/ @@ -34,21 +34,21 @@ //------------------------------------------------------- // SPI Controler //------------------------------------------------------- -extern bit spi_task_on_Flag; // = 1; // to turn ON the RF Task -// = 0; // to turn OFF the RF Task -extern unsigned int spi_watchdog_ctr; +extern bit spi_task_on_Flag; // = 1; // to turn ON the RF Task +// = 0; // to turn OFF the RF Task +extern unsigned int spi_watchdog_ctr; #define SPI_WATCHDOG_MAX (6000) //------------------------------------------------------- // USB Controler //------------------------------------------------------- -extern unsigned int usb_sof_counter; -extern unsigned char usb_configuration_nb; -extern bit usb_connected_Flag; +extern unsigned int usb_sof_counter; +extern unsigned char usb_configuration_nb; +extern bit usb_connected_Flag; -extern bit CMD_OUT_Bank_Nb; // To store the number of the Bank used for the CMD_OUT Endpoint -extern unsigned char CMD_IN_Bank_Nb; +extern bit CMD_OUT_Bank_Nb;// To store the number of the Bank used for the CMD_OUT Endpoint +extern unsigned char CMD_IN_Bank_Nb; extern bit USB_ParserProcess_Permit_Flag; extern bit USB_StatusProcess_Permit_Flag; @@ -60,7 +60,7 @@ //------------------------------------------------------- extern unsigned char i2c_wait_counter; -extern bit i2c_task_on_Flag; +extern bit i2c_task_on_Flag; //------------------------------------------------------- // RF Controler @@ -68,13 +68,13 @@ // RF Header //------------------------------------------------------- -#define RF_2FRAMES_HDR 0x80 -#define RF_AUDIO_HDR 0x02 -#define RF_CMD_HDR 0x08 +#define RF_2FRAMES_HDR 0x80 +#define RF_AUDIO_HDR 0x02 +#define RF_CMD_HDR 0x08 //------------------------------------------------------- -extern bit RF_OFFLine_Back; +extern bit RF_OFFLine_Back; extern unsigned char RF_Status; extern unsigned char RF_Status_Temp; @@ -86,17 +86,17 @@ // From USB //------------------------------------------------------- -extern unsigned char USBCommand_ForRF[]; // Store the USB Command -extern unsigned char USBCommand_ForDongle[]; // For Dongle -extern unsigned char USBCommand_Ctr; // Store the number of byte sent by the LIBUSB +extern unsigned char USBCommand_ForRF[]; // Store the USB Command +extern unsigned char USBCommand_ForDongle[]; // For Dongle +extern unsigned char USBCommand_Ctr; // Store the number of byte sent by the LIBUSB -extern bit USBCommand_NewRequest_Flag; -extern unsigned char USBCommand_Header; // Needed to analyze the LIBUSB command : to RF or to I2C +extern bit USBCommand_NewRequest_Flag; +extern unsigned char USBCommand_Header; // Needed to analyze the LIBUSB command : to RF or to I2C -#define LIBUSB_TUX_CMD_HDR 0 -#define LIBUSB_DONGLE_CMD_HDR 1 -#define LIBUSB_BOOTLOADER_CMD_HDR 2 +#define LIBUSB_TUX_CMD_HDR 0 +#define LIBUSB_DONGLE_CMD_HDR 1 +#define LIBUSB_BOOTLOADER_CMD_HDR 2 @@ -104,8 +104,8 @@ // Dongle Info //------------------------------------------------------- -extern code version_t info_version; -extern code revision_t info_revision; -extern code author_t info_author; +extern code version_t info_version; +extern code revision_t info_revision; +extern code author_t info_author; #endif /* _GLOBAL_H_ */ Modified: firmware/fuxusb/branches/0.3/modules/fifo/fifo_mic.c =================================================================== --- firmware/fuxusb/branches/0.3/modules/fifo/fifo_mic.c 2008-05-01 12:16:13 UTC (rev 1064) +++ firmware/fuxusb/branches/0.3/modules/fifo/fifo_mic.c 2008-05-02 08:19:25 UTC (rev 1065) @@ -19,7 +19,7 @@ //------------------------------------------------------------------------ -#define FIFOTBL_MIC_MAX 256 +#define FIFOTBL_MIC_MAX 256 #define FIFO_MIC_OVERLOAD FIFOTBL_MIC_MAX + 1 Modified: firmware/fuxusb/branches/0.3/modules/spi/spi_task.c =================================================================== --- firmware/fuxusb/branches/0.3/modules/spi/spi_task.c 2008-05-01 12:16:13 UTC (rev 1064) +++ firmware/fuxusb/branches/0.3/modules/spi/spi_task.c 2008-05-02 08:19:25 UTC (rev 1065) @@ -33,9 +33,9 @@ data unsigned char spi_count; data unsigned char spi_lenght_data; -bit spi_enable = 1; -bit spi_ready = 0; -bit spi_Start_Flag = 0; +bit spi_enable = 1; +bit spi_ready = 0; +bit spi_Start_Flag = 0; unsigned char spi_TestCtr ; // Debug @@ -91,33 +91,33 @@ #ifdef X2_MODE Set_spi_x2_mode(); #endif - SPCON |= MSK_MSTR; /* Master mode */ + SPCON |= MSK_MSTR; /* Master mode */ #ifdef SPI_Clock_Div128 SPCON |= 0x82; /* Fclk Periph/128 */ #endif #ifdef SPI_Clock_Div4 - SPCON |= 0x01; /* Fclk Periph/4 */ + SPCON |= 0x01; /* Fclk Periph/4 */ #endif #ifdef SPI_Clock_Div8 - SPCON |= 0x02; /* Fclk Periph/8 */ + SPCON |= 0x02; /* Fclk Periph/8 */ #endif #ifdef SPI_Clock_Div16 - SPCON |= 0x03; /* Fclk Periph/8 */ + SPCON |= 0x03; /* Fclk Periph/8 */ #endif - SPCON &= ~MSK_CPOL; /* CPOL=0; transmit mode example */ - SPCON &= ~MSK_CPHA; /* CPHA=0; transmit mode example */ + SPCON &= ~MSK_CPOL; /* CPOL=0; transmit mode example */ + SPCON &= ~MSK_CPHA; /* CPHA=0; transmit mode example */ SPCON |= MSK_SSDIS; - SPCON |= MSK_SPEN; /* run spi */ + SPCON |= MSK_SPEN; /* run spi */ - SPI_DREADY = 1; - SPI_START = 1; - SPI_CSn = 1; - IT0 = 1; // Falling Edge On Int0 - EX0 = 1; /* enable Int0 interrupt */ + SPI_DREADY = 1; + SPI_START = 1; + SPI_CSn = 1; + IT0 = 1; // Falling Edge On Int0 + EX0 = 1; /* enable Int0 interrupt */ - spi_slave = 0; // Reset State Machine of spi_task() - spi_master = 0; // Reset State Machine of spi_task() + spi_slave = 0; // Reset State Machine of spi_task() + spi_master = 0; // Reset State Machine of spi_task() spi_task_on_Flag = 0; } Modified: firmware/fuxusb/branches/0.3/modules/usb/usb_task.c =================================================================== --- firmware/fuxusb/branches/0.3/modules/usb/usb_task.c 2008-05-01 12:16:13 UTC (rev 1064) +++ firmware/fuxusb/branches/0.3/modules/usb/usb_task.c 2008-05-02 08:19:25 UTC (rev 1065) @@ -33,22 +33,22 @@ /*_____ D E F I N I T I O N ________________________________________________*/ -#define PONG_CHECK 0 /* count the pongs here */ -#define STATUS_CHECK 0 /* check validity of status bytes */ +#define PONG_CHECK 0 /* count the pongs here */ +#define STATUS_CHECK 0 /* check validity of status bytes */ void data_to_send(void); /*_____ D E C L A R A T I O N ______________________________________________*/ #if (PONG_CHECK) -unsigned char pong_received; /* value of the pong received from the sound cpu */ +unsigned char pong_received; /* value of the pong received from the sound cpu */ 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 EP_AUDIOIN_Loaded = 0; +bit i2c_bootloading_Flag = 0; /* bootloader mode */ uint16_t address_tracking; -bit ReadStatus_USBRequest_Flag = 0; -bit Cpu_reset = 0; -bit Speaker_TTS_Select_Flag = 0; +bit ReadStatus_USBRequest_Flag = 0; +bit Cpu_reset = 0; +bit Speaker_TTS_Select_Flag = 0; fifo_t statusBuf; fifo_t *statusFifo = &statusBuf; @@ -56,7 +56,8 @@ data unsigned char received_status[4]; data unsigned char received_data[34]; data unsigned char Sample8; -data unsigned char Spi_Overflow_Ctr; +data unsigned char Spi_Overflow_Ctr; + /*F************************************************************************** * NAME: usb_task_init *---------------------------------------------------------------------------- @@ -104,7 +105,7 @@ P1_0 = 0; spi_task_on_Flag = 0; - RF_Status = 0; + RF_Status = 0; RF_OFFLine_Back = 0; Speaker_TTS_Select_Flag = 0; USB_ParserProcess_Permit_Flag = TRUE; @@ -162,7 +163,6 @@ if((USB_Status_NewCmd_Flag) && (CMD_IN_Bank_Nb < 2)) { - // &&(!(spi_master_config & RF_2FRAMES_HDR)) && (USB_StatusProcess_Permit_Flag) /* * If the bank number == 2, that means that both banks has been filled. */ @@ -207,22 +207,22 @@ void usb_Bootloader_command_process_task(void) { data Uchar i; - if((USB_Bootloader_NewCmd_Flag) && (CMD_IN_Bank_Nb < 2)) - { + if((USB_Bootloader_NewCmd_Flag) && (CMD_IN_Bank_Nb < 2)) + { Usb_select_ep(EP_CMD_IN); #ifdef BOOTLOAD_USB_DEBUG - printf ("BUSB: TX ready, UEPSTAX=0x%BX\n", UEPSTAX); + printf ("BUSB: TX ready, UEPSTAX=0x%BX\n", UEPSTAX); #endif - for(i=0;i<FifoIn_STT_Idx;i++) - { - Usb_write_byte(FIFO_STT_get()); - } + for(i=0;i<FifoIn_STT_Idx;i++) + { + Usb_write_byte(FIFO_STT_get()); + } FIFO_STT_flush(); CMD_IN_Bank_Nb ++; // Increase the bank number - USB_Bootloader_NewCmd_Flag = FALSE; + USB_Bootloader_NewCmd_Flag = FALSE; data_to_send(); - } + } } void data_to_send(void) @@ -256,7 +256,7 @@ FIFO_STT_put(p1); FIFO_STT_put(p2); FIFO_STT_put(p3); - USB_Bootloader_NewCmd_Flag = TRUE; + USB_Bootloader_NewCmd_Flag = TRUE; usb_Bootloader_command_process_task(); } @@ -294,6 +294,7 @@ if (USBCommand_ForDongle[0] == 0x01) { if (USBCommand_ForDongle[1] == 0x00) + { if(USBCommand_ForDongle[2] == 0x00) { @@ -305,15 +306,14 @@ USB_Status_NewCmd_Flag = TRUE; //DEBUG_2 = 0; } - // Complete reset - //////////////////////////////////////// - if(USBCommand_ForDongle[3] == 0xfe) + // Complete reset + //////////////////////////////////////// + if(USBCommand_ForDongle[3] == 0xfe) { - //--------------------------- - IEN0 = 0; - IEN1 = 0; - SPCON = 0x14; - tc=10000; + IEN0 = 0; + IEN1 = 0; + SPCON = 0x14; + tc=10000; Usb_detach(); while(tc) tc --; //tempo(TIMER_5_MS); Usb_attach(); @@ -326,10 +326,9 @@ if(USBCommand_ForDongle[3] == 0xff) { //--------------------------- - IEN0 = 0; - IEN1 = 0; - SPCON = 0x14; - + IEN0 = 0; + IEN1 = 0; + SPCON = 0x14; __api_clr_BLJB(); __api_wr_SBV (0xF4); tc=10000; @@ -342,14 +341,15 @@ WDTRST = 0xE1; while(1); } - } + } + } } - //-------------------------------------------------------------------------- + //------------------------------------------------------------------------- // Text To Speech // // USBCommand_ForDongle[1] == 0x01 Text To Speech Selected // USBCommand_ForDongle[1] == 0x00 Text To Speech UnSelected - //-------------------------------------------------------------------------- + //------------------------------------------------------------------------- if (USBCommand_ForDongle[0] == 0x02) { if (USBCommand_ForDongle[1] == 0x01) @@ -370,7 +370,7 @@ while (data_length > i) { - if (commands[i] == INFO_FUXUSB_CMD) // + if (commands[i] == INFO_FUXUSB_CMD) { // VERSION_CMD //------------------------------------- @@ -417,9 +417,6 @@ -void usb_task(void) -{ - data Uchar i; /*F************************************************************************** * NAME: usb_task *---------------------------------------------------------------------------- @@ -428,6 +425,9 @@ *---------------------------------------------------------------------------- * NOTE: *****************************************************************************/ +void usb_task(void) +{ + data Uchar i; if (!usb_connected_Flag) { if (Usb_resume()) @@ -440,9 +440,9 @@ Usb_clear_suspend(); Usb_clear_resume(); Usb_clear_sof(); - // FIFO_SPK_init(); - // FIFO_MIC_init(); - // spi_task_init(); + //FIFO_SPK_init(); + //FIFO_MIC_init(); + //spi_task_init(); } } else @@ -498,11 +498,11 @@ if (Usb_sof()) { Usb_clear_sof(); - usb_sof_counter ++; // == 0xFF == 250ms + usb_sof_counter ++; // == 0xFF == 250ms if(spi_watchdog_ctr) { - spi_watchdog_ctr--; // Decrement Watchdog + spi_watchdog_ctr--; // Decrement Watchdog } //--------------------------------------------------------- // Reset SPI Transfer @@ -510,10 +510,10 @@ else if (!i2c_bootloading_Flag) { //Led_1_on(); - spi_slave = HEADERS; // Set state machine + spi_slave = HEADERS; // Set state machine spi_master = HEADERM; - spi_enable = 1; // Communication Authorized - SPI_CSn = 1; // Chip select + spi_enable = 1; // Communication Authorized + SPI_CSn = 1; // Chip select spi_Start_Flag = 0; spi_ready = 0; } @@ -523,7 +523,6 @@ //-------------------------------------------------------------------------- if (i2c_wait_counter) i2c_wait_counter--; - //-------------------------------------------------------------------------- // Led Behavior //-------------------------------------------------------------------------- @@ -531,7 +530,6 @@ { if(RF_OFFLINE) { - if(RF_OFFLine_Back == 0) { Configure_led(0,LED_PORT_2MA); @@ -542,12 +540,12 @@ Led_0_off(); if (usb_sof_counter == 0x2FF) Led_0_on(); - if (usb_sof_counter == 0x3FF) // 0x0400 ==> Time Base = 1sec + if (usb_sof_counter == 0x3FF) //==> Time Base = 1sec usb_sof_counter = 0xFFFE; } - else // RF ON Line + else // RF ON Line { if(RF_OFFLine_Back == 1) { @@ -560,7 +558,7 @@ Led_0_off(); if (usb_sof_counter == 0x10) Led_0_on(); - if (usb_sof_counter == 0x20) // 0x0400 ==> Time Base = 1sec + if (usb_sof_counter == 0x20) //Time Base = 1sec usb_sof_counter = 0xFFFE; } } @@ -573,7 +571,7 @@ // //-------------------------------------------------------------------------- usb_Satus_command_process_task(); - usb_Bootloader_command_process_task(); + usb_Bootloader_command_process_task(); //-------------------------------------------------------------------------- // @@ -615,8 +613,8 @@ CMD_IN_Bank_Nb--; if (CMD_IN_Bank_Nb<0) CMD_IN_Bank_Nb = 0; - if (CMD_IN_Bank_Nb != 0) - Usb_set_tx_ready(); + if (CMD_IN_Bank_Nb != 0) + Usb_set_tx_ready(); } } @@ -660,7 +658,8 @@ i=8; do { - FIFO_SPK_put(Usb_read_byte()); // Use Only one Call to Get 8 Bytes + // Use Only one Call to Get 8 Bytes + FIFO_SPK_put(Usb_read_byte()); i--; }while(i); } @@ -686,13 +685,13 @@ i=8; do { - FIFO_SPK_put(Usb_read_byte()); // Use Only one Call to Get 8 Bytes + // Use Only one Call to Get 8 Bytes + FIFO_SPK_put(Usb_read_byte()); i--; }while(i); } - Usb_clear_rx(); - //DEBUG_1 = 0; + //DEBUG_1 = 0; } //-------------------------------------------------------------------------- @@ -709,7 +708,8 @@ if(Usb_tx_complete()) { Usb_clear_tx_complete(); - EP_AUDIOIN_Loaded = 0; // -> Enable a new Loading of the FIFO + // -> Enable a new Loading of the FIFO + EP_AUDIOIN_Loaded = 0; } } @@ -724,11 +724,9 @@ { if(Usb_test_it_ep(EP_CMD_OUT)) { - #ifdef FIFO_DEBUG printf("CMD OUT\n"); #endif - if(!USBCommand_NewRequest_Flag) { //DEBUG_2 = 1; @@ -736,9 +734,10 @@ //DEBUG_2 = 0; if(Usb_rx_complete()) { - USBCommand_Ctr = usb_get_nb_byte(); // Capture the number of Byte in USB FIFO - USBCommand_Header = Usb_read_byte(); // Read the Header - + // Capture the number of Byte in USB FIFO + USBCommand_Ctr = usb_get_nb_byte(); + // Read the Header + USBCommand_Header = Usb_read_byte(); //-------------------------------------------------------------------------- // // TUX CMD HEADER received @@ -749,12 +748,12 @@ //-------------------------------------------------------------------------- if(USBCommand_Header == LIBUSB_TUX_CMD_HDR) { - // printf (" LIBUSB_TUX_CMD_HDR \n"); if (!RF_OFFLINE) - USBCommand_NewRequest_Flag = 1; // to inform SPI_task that a new command is arrived + USBCommand_NewRequest_Flag = 1; for(i=0;i<(USBCommand_Ctr-1);i++) USBCommand_ForRF[i] = Usb_read_byte(); - tux_command_parser(USBCommand_ForRF, USBCommand_Ctr); + tux_command_parser(USBCommand_ForRF, \ + USBCommand_Ctr); } /* @@ -763,7 +762,7 @@ else if(USBCommand_Header == LIBUSB_DONGLE_CMD_HDR) { for(i=0;i<(USBCommand_Ctr-1);i++) - USBCommand_ForDongle[i] = Usb_read_byte(); + USBCommand_ForDongle[i] = Usb_read_byte(); #ifdef FIFO_DEBUG printf("usb command parser\n"); #endif @@ -1039,19 +1038,17 @@ //-------------------------------------------------------------------------- if ((SPI_START) && (spi_enable)) // Wait start { - spi_watchdog_ctr = SPI_WATCHDOG_MAX; - 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_watchdog_ctr = SPI_WATCHDOG_MAX; + 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; - USB_ParserProcess_Permit_Flag = FALSE; - USB_StatusProcess_Permit_Flag = FALSE; - - + SPI_CSn = 0; // Chip select + spi_Start_Flag = 1; + USB_ParserProcess_Permit_Flag = FALSE; + USB_StatusProcess_Permit_Flag = FALSE; } //-------------------------------------------------------------------------- @@ -1061,12 +1058,11 @@ //-------------------------------------------------------------------------- if(spi_Start_Flag) { - //-------------------------------------------------------------------------- // // Excecute When RF Module is Ready // -// Falling Edge on spi_ready +// Falling Edge on spi_ready // //-------------------------------------------------------------------------- if(spi_ready) @@ -1084,23 +1080,26 @@ { if (USBCommand_NewRequest_Flag) // { - spi_slave_config = RF_AUDIO_HDR | RF_CMD_HDR; // Config byte + spi_slave_config = RF_AUDIO_HDR | + RF_CMD_HDR; // Config byte SPDAT = spi_slave_config; // Header byte - // printf ("CMD For RF \n"); } else { - spi_slave_config = RF_AUDIO_HDR; // Config byte - SPDAT = spi_slave_config; // Header byte + // Config byte + spi_slave_config = RF_AUDIO_HDR; + // Header byte + SPDAT = spi_slave_config; } } else { - if (USBCommand_NewRequest_Flag) // + if (USBCommand_NewRequest_Flag) { - - spi_slave_config = RF_CMD_HDR; // Config byte - SPDAT = spi_slave_config; // Header byte + // Config byte + spi_slave_config = RF_CMD_HDR; + // Header byte + SPDAT = spi_slave_config; #ifdef FIFO_DEBUG printf ("CMD For RF \n"); #endif @@ -1119,7 +1118,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 @@ -1138,8 +1137,7 @@ } if (spi_slave_config & RF_CMD_HDR) { - SPDAT =USBCommand_ForRF[spi_count-18]; //0x00; // Get command from buffer - // printf (" %BX ", USBCommand_ForRF[spi_count-18]); + SPDAT =USBCommand_ForRF[spi_count-18]; } else SPDAT = 0x00; // No command to transmit @@ -1177,23 +1175,22 @@ if (spi_master_config & RF_AUDIO_HDR) { P1_0 = 1; - received_data[spi_count-2] = SPDAT; //FIFO_MIC_put(SPDAT); + received_data[spi_count-2] = SPDAT; } - if (spi_count == (spi_lenght_data + 1)) - spi_master = READ_COMMAND; // Go to the next state + // Go to the next state + spi_master = READ_COMMAND; } else if (spi_master == READ_COMMAND) { - while (!(SPSTA == 0x80)) // Wait SPI response + while (!(SPSTA == 0x80)) // Wait SPI response if(RF_OFFLINE) return; if (spi_master_config & RF_CMD_HDR) { - - if (spi_count <= spi_lenght_data + 5) - received_status[spi_count - spi_lenght_data - 2] = SPDAT; + received_status[spi_count - \ + spi_lenght_data - 2] = SPDAT; if (spi_count == spi_lenght_data + 6) { @@ -1214,7 +1211,9 @@ // // Store Sound Data in the FIFO MIC // - if (spi_master_config & (RF_2FRAMES_HDR|RF_AUDIO_HDR)) // Double frame + // Double frame + if (spi_master_config & (RF_2FRAMES_HDR | \ + RF_AUDIO_HDR)) { //Led_0_off(); i = 0; @@ -1222,16 +1221,16 @@ { FIFO_MIC_put(received_data[i]); i++; - }while(i<spi_lenght_data); + } while(i<spi_lenght_data); //Led_0_on(); } // // Store STATUS in the FIFO // - if (spi_master_config & RF_CMD_HDR) // Double frame + if (spi_master_config & RF_CMD_HDR) { if(received_status[0]) - { + { //Led_0_off(); i = 0; do{ Modified: firmware/fuxusb/branches/0.3/modules/usb_enum/USB_ENUM.H =================================================================== --- firmware/fuxusb/branches/0.3/modules/usb_enum/USB_ENUM.H 2008-05-01 12:16:13 UTC (rev 1064) +++ firmware/fuxusb/branches/0.3/modules/usb_enum/USB_ENUM.H 2008-05-02 08:19:25 UTC (rev 1065) @@ -1,461 +1,480 @@ -/*H************************************************************************** - * NAME: usb_cdc_enum.h - *---------------------------------------------------------------------------- - * Copyright (c) 2004 Atmel. - *---------------------------------------------------------------------------- - * RELEASE: c5131-usb-cdc-1_0_2 - * REVISION: 1.2 - *---------------------------------------------------------------------------- - * PURPOSE: - * This file contains the USB task definition - *****************************************************************************/ - -#ifndef _USB_ENUM_H_ -#define _USB_ENUM_H_ - -/*_____ I N C L U D E S ____________________________________________________*/ - - -/*_____ M A C R O S ________________________________________________________*/ - - - - -/*_____ S T A N D A R D R E Q U E S T S ______bRequest____________________*/ - -#define GET_STATUS 0x00 -#define GET_DEVICE 0x01 -#define CLEAR_FEATURE 0x01 /* see FEATURES below */ -#define GET_STRING 0x03 -#define SET_FEATURE 0x03 /* see FEATURES below */ -#define SET_ADDRESS 0x05 -#define GET_DESCRIPTOR 0x06 -#define SET_DESCRIPTOR 0x07 -#define GET_CONFIGURATION 0x08 -#define SET_CONFIGURATION 0x09 -#define GET_INTERFACE 0x0A -#define SET_INTERFACE 0x0B -#define SYNCH_FRAME 0x0C - -/*_____ A U D I O C L A S S R E Q U E S T S_____________________________*/ - -#define SET_CURRENT 0x01 -#define SET_MIN 0x02 -#define SET_MAX 0x03 -#define SET_RES 0x04 - -#define GET_CURRENT 0x81 -#define GET_MIN 0x82 -#define GET_MAX 0x83 -#define GET_RES 0x84 - - -#define GET_DEVICE_DESCRIPTOR 1 -#define GET_CONFIGURATION_DESCRIPTOR 4 - -/* CDC specific */ -#define GET_LINE_CODING 0x21 -#define SET_LINE_CODING 0x20 -#define SET_CONTROL_LINE_STATE 0x22 -#define SEND_BREAK 0x23 -#define SEND_ENCAPSULATED_COMMAND 0x00 -#define GET_ENCAPSULATED_COMMAND 0x01 -/* *** */ - -#define REQUEST_DEVICE_STATUS 0x80 -#define REQUEST_INTERFACE_STATUS 0x81 -#define REQUEST_ENDPOINT_STATUS 0x82 - -#define ZERO_TYPE 0x00 -#define INTERFACE_TYPE 0x01 -#define ENDPOINT_TYPE 0x02 - -/*_____ D E S C R I P T O R T Y P E S ____________________________________*/ - -#define DEVICE 0x01 -#define CONFIGURATION 0x02 -#define STRING 0x03 -#define INTERFACE 0x04 -#define ENDPOINT 0x05 - - -/*_____ S T A N D A R D F E A T U R E S __________________________________*/ - -#define DEVICE_REMOTE_WAKEUP_FEATURE 0x01 -#define ENDPOINT_HALT_FEATURE 0x00 - -/*_____ D E V I C E S T A T U S ___________________________________________*/ - -#define SELF_POWERED 1 - -/*_____ D E V I C E S T A T E _____________________________________________*/ - -#define ATTACHED 0 -#define POWERED 1 -#define DEFAULT 2 -#define ADDRESSED 3 -#define CONFIGURED 4 -#define SUSPENDED 5 - -#define USB_CONFIG_BUSPOWERED 0x80 -#define USB_CONFIG_SELFPOWERED 0x40 -#define USB_CONFIG_REMOTEWAKEUP 0x20 - -/*_____ E N D P O I N T _____________________________________________*/ - -#define OUT_ENDPOINT1 0x01 -#define OUT_ENDPOINT2 0x02 -#define OUT_ENDPOINT3 0x03 -#define OUT_ENDPOINT4 0x04 -#define OUT_ENDPOINT5 0x05 -#define OUT_ENDPOINT6 0x06 - -#define IN_ENDPOINT1 0x81 -#define IN_ENDPOINT2 0x82 -#define IN_ENDPOINT3 0x83 -#define IN_ENDPOINT4 0x84 -#define IN_ENDPOINT5 0x85 -#define IN_ENDPOINT6 0x86 - -/*_________________________________________________________ S T R U C T _____*/ -/*_____ U S B D E V I C E R E Q U E S T _________________________________*/ -struct Endpoint_information_st -{ - Uint16 fifo_size ; /* size of the endpoint FIFO */ - Uint16 fifo_left ; -}; - -struct USB_request_st -{ - Uchar bmRequestType; /* Characteristics of the request */ - Uchar bRequest; /* Specific request */ - Uint16 wValue; /* field that varies according to request */ - Uint16 wIndex; /* field that varies according to request */ - Uint16 wLength; /* Number of bytes to transfer if Data */ -}; - - -/*_____ U S B D E V I C E D E S C R I P T O R ___________________________*/ - -struct usb_st_device_descriptor -{ - Uchar bLength; /* Size of this descriptor in bytes */ - Uchar bDescriptorType; /* DEVICE descriptor type */ - Uint16 bscUSB; /* Binay Coded Decimal Spec. release */ - Uchar bDeviceClass; /* Class code assigned by the USB */ - Uchar bDeviceSubClass; /* Sub-class code assigned by the USB */ - Uchar bDeviceProtocol; /* Protocol code assigned by the USB */ - Uchar bMaxPacketSize0; /* Max packet size for EP0 */ - Uint16 idVendor; /* Vendor ID. ATMEL = 0x03EB */ - Uint16 idProduct; /* Product ID assigned by the manufacturer */ - Uint16 bcdDevice; /* Device release number */ - Uchar iManufacturer; /* Index of manu. string descriptor */ - Uchar iProduct; /* Index of prod. string descriptor */ - Uchar iSerialNumber; /* Index of S.N. string descriptor */ - Uchar bNumConfigurations; /* Number of possible configurations */ -}; - - -/*_____ U S B C O N F I G U R A T I O N D E S C R I P T O R _____________*/ - -struct usb_st_configuration_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* CONFIGURATION descriptor type */ - Uint16 wTotalLength; /* total length of data returned */ - Uchar bNumInterfaces; /* number of interfaces for this conf. */ - Uchar bConfigurationValue; /* value for SetConfiguration resquest */ - Uchar iConfiguration; /* index of string descriptor */ - Uchar bmAttibutes; /* Configuration characteristics */ - Uchar MaxPower; /* maximum power consumption */ -}; - - -/*_____ U S B I N T E R F A C E D E S C R I P T O R _____________________*/ - -struct usb_st_interface_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bInterfaceNumber; /* Number of interface */ - Uchar bAlternateSetting; /* value to select alternate setting */ - Uchar bNumEndpoints; /* Number of EP except EP 0 */ - Uchar bInterfaceClass; /* Class code assigned by the USB */ - Uchar bInterfaceSubClass; /* Sub-class code assigned by the USB */ - Uchar bInterfaceProtocol; /* Protocol code assigned by the USB */ - Uchar iInterface; /* Index of string descriptor */ -}; - -/*_____ U S B E N D P O I N T D E S C R I P T O R _______________________*/ - -struct usb_st_endpoint_descriptor -{ - Uchar bLength; /* Size of this descriptor in bytes */ - Uchar bDescriptorType; /* ENDPOINT descriptor type */ - Uchar bEndpointAddress; /* Address of the endpoint */ - Uchar bmAttributes; /* Endpoint's attributes */ - Uint16 wMaxPacketSize; /* Maximum packet size for this EP */ - Uchar bInterval; /* Interval for polling EP in ms */ -}; - - -/*_____ U S B M A N U F A C T U R E R D E S C R I P T O R _______________*/ - -struct usb_st_manufacturer -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[USB_MN_LENGTH];/* unicode characters */ -}; - - -/*_____ U S B P R O D U C T D E S C R I P T O R _________________________*/ - -struct usb_st_product -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[USB_PN_LENGTH];/* unicode characters */ -}; - - -/*_____ U S B S E R I A L N U M B E R D E S C R I P T O R _____________*/ - -struct usb_st_serial_number -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[USB_SN_LENGTH];/* unicode characters */ -}; - -/*_____ U S B C O N F I G D E S C R I P T O R _________________________*/ - -struct usb_st_config -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[USB_CONFIG_LENGTH];/* unicode characters */ -}; - -/*_____ U S B L A N G U A G E D E S C R I P T O R ______________________*/ - -struct usb_st_language_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[USB_CONFIG_LENGTH]; /* language id */ -}; - - -/*_____ U S B L A N G U A G E D E S C R I P T O R ______________________*/ - -struct usb_st_speaker_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[AUDIO_SPEAKER_LENGTH]; /* language id */ -}; - -/*_____ U S B L A N G U A G E D E S C R I P T O R ______________________*/ - -struct usb_st_micro_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[AUDIO_MICRO_LENGTH]; /* language id */ -}; - -/*_____ U S B L A N G U A G E D E S C R I P T O R ______________________*/ - -struct usb_st_tts_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[AUDIO_TTS_LENGTH]; /* language id */ /* language id */ -}; - - -struct usb_st_audio_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[AUDIO_NORMAL_LENGTH]; /* language id */ /* language id */ -}; - - -/* HID specific */ -/*_____ U S B H I D D E S C R I P T O R __________________________________*/ - -struct usb_st_hid_descriptor -{ - Uchar bLength; /* Size of this descriptor in bytes */ - Uchar bDescriptorType; /* HID descriptor type */ - Uint16 bscHID; /* Binay Coded Decimal Spec. release */ - Uchar bCountryCode; /* Hardware target country */ - Uchar bNumDescriptors; /* Number of HID class descriptors to follow */ - Uchar bRDescriptorType; /* Report descriptor type */ - Uint16 wDescriptorLength; /* Total length of Report descriptor */ -}; - -/* Audio Class specific */ - -/*_____ U S B S T D AUDIO CONTROL I N T E R F A C E D E S C R I P T O R _____________________*/ - -struct usb_Audio_st_ACinterface_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bInterfaceNumber; /* Number of interface */ - Uchar bAlternateSetting; /* value to select alternate setting */ - Uchar bNumEndpoints; /* Number of EP except EP 0 */ - Uchar bInterfaceClass; /* Class code assigned by the USB */ - Uchar bInterfaceSubClass; /* Sub-class code assigned by the USB */ - Uchar bInterfaceProtocol; /* Protocol code assigned by the USB */ - Uchar iInterface; /* Index of string descriptor */ -}; - -/*_____ U S B C S AUDIO CONTROL I N T E R F A C E D E S C R I P T O R _____________________*/ - -struct usb_Audio_cs_ACinterface_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bDescriptorSubtype; /* HEADER descriptor subtype.*/ - Uint16 bcdADC; /* Audio Device Class Specification Release Number in Binary-Coded Decimal */ - Uint16 wTotalLength; /* Total number of bytes returned for the class-specific AudioControl interface descriptor */ - Uchar bInCollection; /* Number of EP except EP 0 */ - Uchar baInterfaceNr[2]; /* Class code assigned by the USB */ -}; - -struct usb_Audio_cs_ACinterface_descriptor_NbCol1 -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bDescriptorSubtype; /* HEADER descriptor subtype.*/ - Uint16 bcdADC; /* Audio Device Class Specification Release Number in Binary-Coded Decimal */ - Uint16 wTotalLength; /* Total number of bytes returned for the class-specific AudioControl interface descriptor */ - Uchar bInCollection; /* Number of EP except EP 0 */ - Uchar baInterfaceNr[1]; /* Class code assigned by the USB */ -}; - -/*_____ U S B I N P U T T E R M I N A L D E S C R I P T O R ___________________________*/ - -struct usb_Audio_InputTerminal_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bDescriptorSubtype; /* HEADER descriptor subtype.*/ - Uchar bTerminalID; /* CConstant characterizing the type of Termina*/ - Uint16 wTerminalType; /* Constant characterizing the type of Terminal.*/ - Uchar bAssocTerminal; /* ID of the Output Terminal to which this Input Terminal is associated */ - Uchar bNrChannels; /* Number of logical output channels in the Terminals output audio channel cluster. */ - Uint16 wChannelConfig; /* Describes the spatial location of the logical channels.*/ - Uchar iChannelNames; /*Index of a string descriptor, describing the name of the first logical channel */ - Uchar iTerminal; /*Index of a string descriptor, describing the Input Terminal. */ -}; - -/*_____ U S B O U T P U T T E R M I N A L D E S C R I P T O R ___________________________*/ - -struct usb_Audio_OutputTerminal_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bDescriptorSubtype; /* HEADER descriptor subtype.*/ - Uchar bTerminalID; /* CConstant characterizing the type of Termina*/ - Uint16 wTerminalType; /* Constant characterizing the type of Terminal.*/ - Uchar bAssocTerminal; /* ID of the Output Terminal to which this Input Terminal is associated */ - Uchar bSourceID; /*ID of the Unit or Terminal to which this Terminal is connected */ - Uchar iTerminal; /*Index of a string descriptor, describing the Input Terminal. */ -}; - -/*_____ U S B F E A T U R E U N I T D E S C R I P T O R ___________________________*/ - -struct usb_Audio_FeatureUnit_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bDescriptorSubtype; /* HEADER descriptor subtype.*/ - Uchar bUnitID; /* Constant uniquely identifying the Unit within the audio function.*/ - Uchar bSourceID; /* Constant characterizing the type of Terminal.*/ - Uchar bControlSize; /* Size in bytes of an element of the bmaControls() array: n*/ - Uchar bmaControls[2]; /*ID of the Unit or Terminal to which this Terminal is connected */ - Uchar iFeature; /*Index of a string descriptor, describing this Feature Unit.. */ -}; - -/*_____ U S B S T D AUDIO STREAM I N T E R F A C E D E S C R I P T O R _____________________*/ - -struct usb_Audio_st_ASinterface_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bInterfaceNumber; /* Number of interface */ - Uchar bAlternateSetting; /* value to select alternate setting */ - Uchar bNumEndpoints; /* Number of EP except EP 0 */ - Uchar bInterfaceClass; /* Class code assigned by the USB */ - Uchar bInterfaceSubClass; /* Sub-class code assigned by the USB */ - Uchar bInterfaceProtocol; /* Protocol code assigned by the USB */ - Uchar iInterface; /* Index of string descriptor */ -}; - -/*_____ U S B C S AUDIO STREAM I N T E R F A C E D E S C R I P T O R _____________________*/ - -struct usb_Audio_cs_ASinterface_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bDescriptorSubtype; /* AS_GENERAL descriptor subtype.*/ - Uchar bTerminalLink; /* The Terminal ID of the Terminal to which the endpoint of this interface is connected.*/ - Uchar bDelay; /* Delay (d) introduced by the data path */ - Uint16 wFormatTag; /* Class code assigned by the USB */ -}; - -/*_____ U S B AUDIO ST E N D P O I N T D E S C R I P T O R _______________________*/ - -struct usb_Audio_st_endpoint_descriptor -{ - Uchar bLength; /* Size of this descriptor in bytes */ - Uchar bDescriptorType; /* ENDPOINT descriptor type */ - Uchar bEndpointAddress; /* Address of the endpoint */ - Uchar bmAttributes; /* Endpoint's attributes */ - Uint16 wMaxPacketSize; /* Maximum packet size for this EP */ - Uchar bInterval; /* Interval for polling EP in ms */ - Uchar bRefresh; /* Reset to 0.*/ - Uchar bSynchAddress; /* The address of the endpoint used to communicate synchronization information if required by this endpoint..*/ -}; - -/*_____ U S B AUDIO S T E N D P O I N T D E S C R I P T O R _______________________*/ - -struct usb_Audio_cs_ASendpoint_descriptor -{ - Uchar bLength; /* Size of this descriptor in bytes */ - Uchar bDescriptorType; /* ENDPOINT descriptor type */ - Uchar bDescriptorSubtype; /* EP_GENERAL descriptor subtype. */ - Uchar bmAttributes; /* Endpoint's attributes */ - Uchar bLockDelayUnits; /*Indicates the units used for the wLockDelay field:*/ - Uint16 wLockDelay; /* Reset to 0.*/ -}; - -/*_____ U S B AUDIO S T E N D P O I N T D E S C R I P T O R _______________________*/ - -struct usb_Audio_TYPEI_FormatType_descriptor -{ - Uchar bLength; /* Size of this descriptor in bytes */ - Uchar bDescriptorType; /* ENDPOINT descriptor type */ - Uchar bDescriptorSubtype; /* EP_GENERAL descriptor subtype. */ - Uchar bFormatType; /* FORMAT_TYPE_I. Constant identifying the Format Type the AudioStreaming interface is using.*/ - Uchar bNrChannels; /*Indicates the number of physical channels in the audio data stream.:*/ - Uchar bSubframeSize; /* The number of bytes occupied by one audio subframe. Can be 1, 2, 3 or 4.*/ - Uchar bBitResolution; /* The number of effectively used bits from the available bits in an audio subframe.*/ - Uchar bSamFreqType; /*Indicates how the sampling frequency can be programmed */ - Uchar bSamFreqTbl[3]; /*See sampling frequency tables*/ -}; - -/*_____ D E C L A R A T I O N ______________________________________________*/ - - -void usb_var_init(void); -void usb_ep_init(void); -void usb_enumeration_process(void); - - -#endif /* _USB_ENUM_H_ */ +/*H************************************************************************** + * NAME: usb_cdc_enum.h + *---------------------------------------------------------------------------- + * Copyright (c) 2004 Atmel. + *---------------------------------------------------------------------------- + * RELEASE: c5131-usb-cdc-1_0_2 + * REVISION: 1.2 + *---------------------------------------------------------------------------- + * PURPOSE: + * This file contains the USB task definition + *****************************************************************************/ + +#ifndef _USB_ENUM_H_ +#define _USB_ENUM_H_ + +/*_____ I N C L U D E S ____________________________________________________*/ + + +/*_____ M A C R O S ________________________________________________________*/ + + + + +/*_____ S T A N D A R D R E Q U E S T S ______bRequest____________________*/ + +#define GET_STATUS 0x00 +#define GET_DEVICE 0x01 +#define CLEAR_FEATURE 0x01 /* see FEATURES below */ +#define GET_STRING 0x03 +#define SET_FEATURE 0x03 /* see FEATURES below */ +#define SET_ADDRESS 0x05 +#define GET_DESCRIPTOR 0x06 +#define SET_DESCRIPTOR 0x07 +#define GET_CONFIGURATION 0x08 +#define SET_CONFIGURATION 0x09 +#define GET_INTERFACE 0x0A +#define SET_INTERFACE 0x0B +#define SYNCH_FRAME 0x0C + +/* HID specific */ +#define HID_SET_IDLE 0x0A +#define HID_GET_IDLE 0x02 +/* *** */ + +/*_____ A U D I O C L A S S R E Q U E S T S_____________________________*/ + +#define SET_CURRENT 0x01 +#define SET_MIN 0x02 +#define SET_MAX 0x03 +#define SET_RES 0x04 + +#define GET_CURRENT 0x81 +#define GET_MIN 0x82 +#define GET_MAX 0x83 +#define GET_RES 0x84 + + +#define GET_DEVICE_DESCRIPTOR 1 +#define GET_CONFIGURATION_DESCRIPTOR 4 + +/* CDC specific */ +#define GET_LINE_CODING 0x21 +#define SET_LINE_CODING 0x20 +#define SET_CONTROL_LINE_STATE 0x22 +#define SEND_BREAK 0x23 +#define SEND_ENCAPSULATED_COMMAND 0x00 +#define GET_ENCAPSULATED_COMMAND 0x01 +/* *** */ + +/* HID specific */ +#define HID 0x21 +#define REPORT 0x22 +/* *** */ + +#define REQUEST_DEVICE_STATUS 0x80 +#define REQUEST_INTERFACE_STATUS 0x81 +#define REQUEST_ENDPOINT_STATUS 0x82 + +#define ZERO_TYPE 0x00 +#define INTERFACE_TYPE 0x01 +#define ENDPOINT_TYPE 0x02 + +/*_____ D E S C R I P T O R T Y P E S ____________________________________*/ + +#define DEVICE 0x01 +#define CONFIGURATION 0x02 +#define STRING 0x03 +#define INTERFACE 0x04 +#define ENDPOINT 0x05 + + +/*_____ S T A N D A R D F E A T U R E S __________________________________*/ + +#define DEVICE_REMOTE_WAKEUP_FEATURE 0x01 +#define ENDPOINT_HALT_FEATURE 0x00 + +/*_____ D E V I C E S T A T U S ___________________________________________*/ + +#define SELF_POWERED 1 + +/*_____ D E V I C E S T A T E _____________________________________________*/ + +#define ATTACHED 0 +#define POWERED 1 +#define DEFAULT 2 +#define ADDRESSED 3 +#define CONFIGURED 4 +#define SUSPENDED 5 + +#define USB_CONFIG_BUSPOWERED 0x80 +#define USB_CONFIG_SELFPOWERED 0x40 +#define USB_CONFIG_REMOTEWAKEUP 0x20 + +/*_____ E N D P O I N T _____________________________________________*/ + +#define OUT_ENDPOINT1 0x01 +#define OUT_ENDPOINT2 0x02 +#define OUT_ENDPOINT3 0x03 +#define OUT_ENDPOINT4 0x04 +#define OUT_ENDPOINT5 0x05 +#define OUT_ENDPOINT6 0x06 + +#define IN_ENDPOINT1 0x81 +#define IN_ENDPOINT2 0x82 +#define IN_ENDPOINT3 0x83 +#define IN_ENDPOINT4 0x84 +#define IN_ENDPOINT5 0x85 +#define IN_ENDPOINT6 0x86 + +/*_________________________________________________________ S T R U C T _____*/ +/*_____ U S B D E V I C E R E Q U E S T _________________________________*/ +struct Endpoint_information_st +{ + Uint16 fifo_size ; /* size of the endpoint FIFO */ + Uint16 fifo_left ; +}; + +struct USB_request_st +{ + Uchar bmRequestType; /* Characteristics of the request */ + Uchar bRequest; /* Specific request */ + Uint16 wValue; /* field that varies according to request */ + Uint16 wIndex; /* field that varies according to request */ + Uint16 wLength; /* Number of bytes to transfer if Data */ +}; + + +/*____... [truncated message content] |