[tuxdroid-svn] r620 - in firmware/fuxusb/trunk: . modules/spi modules/usb
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-10-16 15:48:30
|
Author: jaguarondi Date: 2007-10-16 17:48:28 +0200 (Tue, 16 Oct 2007) New Revision: 620 Modified: firmware/fuxusb/trunk/config.h firmware/fuxusb/trunk/main.c firmware/fuxusb/trunk/modules/spi/spi_task.c firmware/fuxusb/trunk/modules/usb/usb_task.c Log: * Updated the debugging messages, added SPI_DEBUG. Modified: firmware/fuxusb/trunk/config.h =================================================================== --- firmware/fuxusb/trunk/config.h 2007-10-16 15:32:53 UTC (rev 619) +++ firmware/fuxusb/trunk/config.h 2007-10-16 15:48:28 UTC (rev 620) @@ -34,6 +34,7 @@ //#define USB_TASK_DEBUG //#define BOOTLOAD_DEBUG //#define USB_CMD_DEBUG +//#define SPI_DEBUG #define VERBOSE 0 #define DEBUG_1 P3_6 #define DEBUG_2 P4_0 Modified: firmware/fuxusb/trunk/main.c =================================================================== --- firmware/fuxusb/trunk/main.c 2007-10-16 15:32:53 UTC (rev 619) +++ firmware/fuxusb/trunk/main.c 2007-10-16 15:48:28 UTC (rev 620) @@ -68,7 +68,7 @@ #ifdef MAIN_DEBUG uart_init(); - printf("= TUX started ==\n"); + printf("\n\n= TUX started ==\n"); #endif while (1) usb_task(); Modified: firmware/fuxusb/trunk/modules/spi/spi_task.c =================================================================== --- firmware/fuxusb/trunk/modules/spi/spi_task.c 2007-10-16 15:32:53 UTC (rev 619) +++ firmware/fuxusb/trunk/modules/spi/spi_task.c 2007-10-16 15:48:28 UTC (rev 620) @@ -136,7 +136,8 @@ * return: none *---------------------------------------------------------------------------- * PURPOSE: -* Interrupt manages the DREADY Signal From RF Module +* This interrupt manages the READY signal from the rf module. +* Configured as falling edge. *---------------------------------------------------------------------------- * EXAMPLE: *---------------------------------------------------------------------------- @@ -145,11 +146,10 @@ * REQUIREMENTS: *****************************************************************************/ -void it_INT0(void) - interrupt IRQ_INT0 - { - spi_ready = 1; - } +void it_INT0(void) interrupt IRQ_INT0 +{ + spi_ready = 1; +} /*F************************************************************************** * NAME: spi_SendFrame @@ -167,7 +167,7 @@ *---------------------------------------------------------------------------- * REQUIREMENTS: *****************************************************************************/ - unsigned char spi_Send_InitFrame(Uchar * Data, unsigned char Length) +unsigned char spi_Send_InitFrame(Uchar * Data, unsigned char Length) { unsigned char i; unsigned long TimeOut = 100000, Delay = 100000; @@ -180,12 +180,18 @@ //-------------------------------------------------------------------------- // Wait the START Event //-------------------------------------------------------------------------- +#ifdef SPI_DEBUG + printf ("SPI: Init frame, waiting for the start signal.\n"); +#endif while (!SPI_START) // Wait start { if (!TimeOut) return 0; TimeOut--; } +#ifdef SPI_DEBUG + printf ("SPI: Transfer data:"); +#endif //-------------------------------------------------------------------------- // Transfer Data //-------------------------------------------------------------------------- @@ -197,9 +203,15 @@ spi_ready = 0; SPDAT = *Data; +#ifdef SPI_DEBUG + printf (" %Bx", *Data); +#endif while (!(SPSTA == 0x80)) ; // Wait SPI response Data++; } SPI_CSn = 1; // Chip select +#ifdef SPI_DEBUG + printf ("\nSPI: Transfer done.\n"); +#endif return 1; } Modified: firmware/fuxusb/trunk/modules/usb/usb_task.c =================================================================== --- firmware/fuxusb/trunk/modules/usb/usb_task.c 2007-10-16 15:32:53 UTC (rev 619) +++ firmware/fuxusb/trunk/modules/usb/usb_task.c 2007-10-16 15:48:28 UTC (rev 620) @@ -1041,7 +1041,7 @@ else if (RF_Connection_Status == RF_TO_CONNECT) { #ifdef USB_CMD_DEBUG - printf("Status RF_TO_CONNECT"); + printf("USB: Connect RF\n"); #endif rf_reset_signal = 1; if (spi_Send_InitFrame(RF_InitFrame, 23)) @@ -1053,14 +1053,14 @@ while (ConnectionDelay) ConnectionDelay--; #ifdef USB_CMD_DEBUG - printf(" => RF_CONNECTED \n"); + printf(" => CONNECTED \n"); #endif } else { RF_Connection_Status = RF_DISCONNECTED; #ifdef USB_CMD_DEBUG - printf(" => RF_DISCONNECTED \n"); + printf(" => DISCONNECTED \n"); #endif } } @@ -1070,7 +1070,7 @@ else if (RF_Connection_Status == RF_REQUEST_ID) { #ifdef USB_CMD_DEBUG - printf("Status RF_REQUEST_ID"); + printf("USB: Request ID\n"); #endif rf_reset_signal = 1; if (spi_Send_InitFrame(RF_InitFrame, 23)) @@ -1082,14 +1082,14 @@ while (ConnectionDelay) ConnectionDelay--; #ifdef USB_CMD_DEBUG - printf(" => RF_CONNECTED \n"); + printf(" => RF_CONNECTED \n"); #endif } else { RF_Connection_Status = RF_DISCONNECTED; #ifdef USB_CMD_DEBUG - printf(" => RF_DISCONNECTED \n"); + printf(" => RF_DISCONNECTED \n"); #endif } @@ -1100,7 +1100,7 @@ else if (RF_Connection_Status == RF_CHANGE_ID) { #ifdef USB_CMD_DEBUG - printf("Status RF_CHANGE_ID"); + printf("USB: Change ID\n"); #endif rf_reset_signal = 1; if (spi_Send_InitFrame(RF_InitFrame, 23)) @@ -1112,14 +1112,14 @@ while (ConnectionDelay) ConnectionDelay--; #ifdef USB_CMD_DEBUG - printf(" => RF_CONNECTED \n"); + printf(" => RF_CONNECTED \n"); #endif } else { RF_Connection_Status = RF_DISCONNECTED; #ifdef USB_CMD_DEBUG - printf(" => RF_DISCONNECTED \n"); + printf(" => RF_DISCONNECTED \n"); #endif } } @@ -1140,6 +1140,9 @@ //-------------------------------------------------------------------------- if ((SPI_START) && (spi_enable)) // Wait start { +#ifdef SPI_DEBUG + printf ("SPI: Transaction:\n"); +#endif spi_watchdog_ctr = SPI_WATCHDOG_MAX; spi_ready = 0; spi_count = 0; // Reset spi counter @@ -1158,6 +1161,9 @@ //-------------------------------------------------------------------------- if (spi_Start_Flag) { +#ifdef SPI_DEBUG + printf (" f"); +#endif //-------------------------------------------------------------------------- // @@ -1168,6 +1174,9 @@ //-------------------------------------------------------------------------- if (spi_ready) { +#ifdef SPI_DEBUG + printf ("r "); +#endif Spi_Overflow_Ctr = 0; do { @@ -1175,6 +1184,7 @@ //-------------------------------------------------------------------------- // Prepare the Byte to Send //-------------------------------------------------------------------------- + /* XXX simplify this bit setting */ if (spi_slave == HEADERS) { if (Fifoready_SPK) // FIFO ready to be empty @@ -1251,7 +1261,12 @@ { while (!(SPSTA == 0x80)) // Wait SPI response if (RF_OFFLINE) + { +#ifdef SPI_DEBUG + printf ("\nRF_OFFLINE!\n"); +#endif return; + } spi_master_config = SPDAT; @@ -1265,7 +1280,12 @@ { while (!(SPSTA == 0x80)) // Wait SPI response if (RF_OFFLINE) + { +#ifdef SPI_DEBUG + printf ("\nRF_OFFLINE!\n"); +#endif return; + } if (spi_master_config & RF_AUDIO_HDR) { @@ -1280,10 +1300,14 @@ { while (!(SPSTA == 0x80)) // Wait SPI response if (RF_OFFLINE) + { +#ifdef SPI_DEBUG + printf ("\nRF_OFFLINE!\n"); +#endif return; + } if (spi_master_config & RF_CMD_HDR) { - if (spi_count <= spi_lenght_data + 5) received_status[spi_count - spi_lenght_data - 2] = @@ -1340,16 +1364,24 @@ } //if (spi_slave_config & RF_CMD_HDR) //printf("\n"); +#ifdef SPI_DEBUG + printf ("\n"); +#endif return; } } +#ifdef SPI_DEBUG + printf("%Bd:0x%Bx ", spi_count, SPDAT); +#endif Spi_Overflow_Ctr++; } while (spi_ready && (Spi_Overflow_Ctr < 5)); +#ifdef SPI_DEBUG + printf ("\n"); +#endif } } } - } else // if RF_OFFLINE { @@ -1371,5 +1403,4 @@ } } } - } |