[tuxdroid-svn] r575 - in firmware/fuxusb/trunk: . modules/usb
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-10-02 18:09:51
|
Author: jaguarondi Date: 2007-10-02 20:09:47 +0200 (Tue, 02 Oct 2007) New Revision: 575 Modified: firmware/fuxusb/trunk/config.h firmware/fuxusb/trunk/modules/usb/usb_task.c Log: * Further improved debug messages of the USB commands. Modified: firmware/fuxusb/trunk/config.h =================================================================== --- firmware/fuxusb/trunk/config.h 2007-10-02 16:50:42 UTC (rev 574) +++ firmware/fuxusb/trunk/config.h 2007-10-02 18:09:47 UTC (rev 575) @@ -26,11 +26,15 @@ /*_____ M A C R O S ________________________________________________________*/ +/* + * Debugging configuration + */ //#define USB_ENUM_DEBUG //#define MAIN_DEBUG //#define USB_TASK_DEBUG //#define BOOTLOAD_DEBUG //#define USB_CMD_DEBUG +#define VERBOSE 0 #define DEBUG_1 P3_6 #define DEBUG_2 P4_0 Modified: firmware/fuxusb/trunk/modules/usb/usb_task.c =================================================================== --- firmware/fuxusb/trunk/modules/usb/usb_task.c 2007-10-02 16:50:42 UTC (rev 574) +++ firmware/fuxusb/trunk/modules/usb/usb_task.c 2007-10-02 18:09:47 UTC (rev 575) @@ -119,8 +119,9 @@ if (status_requested && FifoIn_STT_Idx && !tx_data_ready) { #ifdef USB_CMD_DEBUG - printf("Stacking %Bu data from status on USB fifo.\n", - FifoIn_STT_Idx); + if (VERBOSE) + printf("Stacking %Bu data from status on USB fifo.\n", + FifoIn_STT_Idx); #endif //Led_0_off(); Usb_select_ep(EP_CMD_IN); @@ -431,7 +432,7 @@ else { #ifdef USB_CMD_DEBUG - if(Usb_rx_complete()) + if(VERBOSE && Usb_rx_complete()) printf("LOOP: interrupt flags: %Bx\n", Usb_rx_complete()); #endif //-------------------------------------------------------------------------- @@ -491,7 +492,7 @@ if (tx_data_ready == 1) { #ifdef USB_CMD_DEBUG - printf ("USB: Status ready to be sent.\n"); + if (VERBOSE) printf ("USB: Status ready to be sent.\n"); #endif tx_data_ready = 2; Usb_select_ep(EP_CMD_IN); @@ -626,7 +627,7 @@ if(Usb_tx_complete()) { #ifdef USB_CMD_DEBUG - printf ("USB: Status sent.\n"); + if (VERBOSE) printf ("USB: Status sent.\n"); #endif Usb_clear_tx_complete(); tx_data_ready = 0; @@ -739,8 +740,8 @@ { Usb_select_ep(EP_CMD_OUT); #ifdef USB_CMD_DEBUG - printf("Event on EP_CMD_OUT, data received:\n"); - printf("EP_CMD_OUT interrupt flags: %Bx\n", Usb_rx_complete()); + if (VERBOSE) + printf("EP_CMD_OUT: new event, flags: %Bx\n", Usb_rx_complete()); #endif if(Usb_rx_complete()) { @@ -750,7 +751,8 @@ { USBCommand_Header = Usb_read_byte(); // Read the Header #ifdef USB_CMD_DEBUG - printf("EP_CMD_OUT processing %Bd data.\n", USBCommand_Ctr); + if (VERBOSE) + printf("EP_CMD_OUT: now processing %Bd bytes.\n", USBCommand_Ctr); #endif //-------------------------------------------------------------------------- @@ -789,21 +791,26 @@ //-------------------------------------------------------------------------- else if(USBCommand_Header == LIBUSB_DONGLE_CMD_HDR) { + for(i=0;i<(USBCommand_Ctr-1);i++) + { + USBCommand_ForDongle[i] = Usb_read_byte(); + } #ifdef USB_CMD_DEBUG - printf("DONGLE command "); + if (VERBOSE || !((USBCommand_ForDongle[0] == 1) && + (USBCommand_ForDongle[1] == 0) && + (USBCommand_ForDongle[2] == 0) && + (USBCommand_ForDongle[3] == 0))) + { + printf("DONGLE command "); + for(i=0;i<(USBCommand_Ctr-1);i++) + { + printf("%BX ",USBCommand_ForDongle[i]); + } + printf("\n"); + } #endif - for(i=0;i<(USBCommand_Ctr-1);i++) - { - USBCommand_ForDongle[i] = Usb_read_byte(); -#ifdef USB_CMD_DEBUG - printf("%BX ",USBCommand_ForDongle[i]); -#endif - } -#ifdef USB_CMD_DEBUG - printf("\n"); -#endif - usb_command_parser(); - } + usb_command_parser(); + } //-------------------------------------------------------------------------- // // BOOTLOADER HEADER received @@ -812,7 +819,7 @@ else if(USBCommand_Header == LIBUSB_BOOTLOADER_CMD_HDR) { #ifdef USB_CMD_DEBUG - printf("BOOTLOADER command\n"); + printf("BOOTLOADER command: "); #endif i2c_bootloading_Flag = 1; //printf ("LIBUSB_BOOTLOADER_CMD_HDR \n"); @@ -821,7 +828,7 @@ if (Command_FromUSB_bootload_cmd == BOOT_INIT) /* initialize a new page programming */ { #ifdef BOOTLOAD_DEBUG - printf ("\nBOOT_INIT\n"); + printf ("BOOT_INIT\n"); #endif rf_reset_signal = 0; /* disables the RF module */ SPI_CSn = 0; /* clear CS to enter bootloader mode */ @@ -904,24 +911,26 @@ /* TODO add an error return function on the USB */ } } - Usb_select_ep(EP_CMD_OUT); /* release the bank */ - if(CMD_OUT_usb_Bank==0) - { - if (Usb_rx_bank0_complete()) - Usb_clear_rx_bank0(); - } - else if(CMD_OUT_usb_Bank) - { - if(Usb_rx_bank1_complete()) + /* Release the bank */ + /* XXX there's a bug here when the USB will + * desynchronise with CMD_OUT_usb_Bank. I don't know + * how to achieve that but it's possible and I already + * saw it. */ + //Usb_select_ep(EP_CMD_OUT); + if(CMD_OUT_usb_Bank == 0) + //if (Usb_rx_bank0_complete()) + Usb_clear_rx_bank0(); + else + //if(Usb_rx_bank1_complete()) Usb_clear_rx_bank1(); - } CMD_OUT_usb_Bank ^=1; } } #ifdef USB_CMD_DEBUG else - printf("ERROR: got EP OUT event but Usb_rx_complete returns false.\n"); - printf("END of EP_CMD_OUT, interrupt flags: %Bx\n", Usb_rx_complete()); + printf("ERROR: got EP OUT event but Usb_rx_complete returns False.\n"); + if (VERBOSE) + printf("END of EP_CMD_OUT, interrupt flags: %Bx\n", Usb_rx_complete()); #endif } /* if(Usb_test_it_ep(EP_CMD_OUT)) */ } /* if(Usb_endpoint_interrupt()) */ |