From 838c16e127782904ebe8eabe84243213ba81c17e Mon Sep 17 00:00:00 2001 From: richardbarry Date: Sun, 12 Jul 2009 14:02:12 +0000 Subject: [PATCH] Prepare for release. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@809 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Demo/CORTEX_LPC1768_GCC_Rowley/ParTest.c | 50 ++++--- Demo/CORTEX_LPC1768_GCC_Rowley/RTOSDemo.hzs | 12 +- Demo/CORTEX_LPC1768_GCC_Rowley/main.c | 126 ++++-------------- .../webserver/emac.c | 8 +- .../webserver/httpd-cgi.c | 15 +-- .../webserver/uIP_Task.c | 50 ++----- 6 files changed, 86 insertions(+), 175 deletions(-) diff --git a/Demo/CORTEX_LPC1768_GCC_Rowley/ParTest.c b/Demo/CORTEX_LPC1768_GCC_Rowley/ParTest.c index 48ca1fcf0..3439f72a9 100644 --- a/Demo/CORTEX_LPC1768_GCC_Rowley/ParTest.c +++ b/Demo/CORTEX_LPC1768_GCC_Rowley/ParTest.c @@ -59,7 +59,7 @@ #define partstFIO2_BITS ( ( unsigned long ) 0x0000007C ) #define partstFIO1_BITS ( ( unsigned long ) 0xB0000000 ) #define partstNUM_LEDS ( 5 ) -#define partstALL_OUTPUTS_OFF ( ( unsigned portLONG ) 0xff ) +#define partstALL_OUTPUTS_OFF ( ( unsigned long ) 0xff ) /*----------------------------------------------------------- * Simple parallel port IO routines. @@ -77,14 +77,16 @@ void vParTestInitialise( void ) } /*-----------------------------------------------------------*/ -void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ) +void vParTestSetLED( unsigned long ulLEDIn, signed long xValue ) { -unsigned portLONG ulLED = partstFIRST_IO; +unsigned long ulLED = partstFIRST_IO; - if( uxLED < partstNUM_LEDS ) + /* Used to set and clear LEDs on FIO2. */ + + if( ulLEDIn < partstNUM_LEDS ) { /* Rotate to the wanted bit of port */ - ulLED <<= ( unsigned portLONG ) uxLED; + ulLED <<= ( unsigned long ) ulLEDIn; /* Set of clear the output. */ if( xValue ) @@ -99,15 +101,17 @@ unsigned portLONG ulLED = partstFIRST_IO; } /*-----------------------------------------------------------*/ -void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) +void vParTestToggleLED( unsigned long ulLEDIn ) { -unsigned portLONG ulLED = partstFIRST_IO, ulCurrentState; +unsigned long ulLED = partstFIRST_IO, ulCurrentState; + + /* Used to toggle LEDs on FIO2. */ - if( uxLED < partstNUM_LEDS ) + if( ulLEDIn < partstNUM_LEDS ) { /* Rotate to the wanted bit of port 0. Only P10 to P13 have an LED attached. */ - ulLED <<= ( unsigned portLONG ) uxLED; + ulLED <<= ( unsigned long ) ulLEDIn; /* If this bit is already set, clear it, and visa versa. */ ulCurrentState = GPIO2->FIOPIN; @@ -123,19 +127,31 @@ unsigned portLONG ulLED = partstFIRST_IO, ulCurrentState; } /*-----------------------------------------------------------*/ -unsigned portBASE_TYPE uxParTextGetLED( unsigned portBASE_TYPE uxLED ) +long lParTestGetLEDState( void ) { -unsigned portLONG ulLED = partstFIRST_IO; - - ulLED <<= ( unsigned portLONG ) uxLED; - - return ( GPIO2->FIOPIN & ulLED ); + /* Returns the state of the LEDs on FIO1. */ + if( ( GPIO1->FIOPIN & partstFIO1_BITS ) != 0 ) + { + return pdFALSE; + } + else + { + return pdTRUE; + } } /*-----------------------------------------------------------*/ -long lParTestGetLEDState( unsigned portBASE_TYPE uxLED ) +void vParTestSetLEDState( long lState ) { - return 0; + /* Used to set and clear the LEDs on FIO1. */ + if( lState != pdFALSE ) + { + GPIO1->FIOSET = partstFIO1_BITS; + } + else + { + GPIO1->FIOCLR = partstFIO1_BITS; + } } /*-----------------------------------------------------------*/ diff --git a/Demo/CORTEX_LPC1768_GCC_Rowley/RTOSDemo.hzs b/Demo/CORTEX_LPC1768_GCC_Rowley/RTOSDemo.hzs index 6d67b0f66..feca37148 100644 --- a/Demo/CORTEX_LPC1768_GCC_Rowley/RTOSDemo.hzs +++ b/Demo/CORTEX_LPC1768_GCC_Rowley/RTOSDemo.hzs @@ -2,8 +2,8 @@ - - + + @@ -22,7 +22,6 @@ - @@ -53,12 +52,7 @@ - - - - - - + diff --git a/Demo/CORTEX_LPC1768_GCC_Rowley/main.c b/Demo/CORTEX_LPC1768_GCC_Rowley/main.c index 6d258abab..289732538 100644 --- a/Demo/CORTEX_LPC1768_GCC_Rowley/main.c +++ b/Demo/CORTEX_LPC1768_GCC_Rowley/main.c @@ -1,5 +1,5 @@ /* - FreeRTOS.org V5.3.1 - Copyright (C) 2003-2009 Richard Barry. + FreeRTOS.org V5.4.0 - Copyright (C) 2003-2009 Richard Barry. This file is part of the FreeRTOS.org distribution. @@ -59,40 +59,18 @@ * In addition to the standard demo tasks, the following tasks and tests are * defined and/or created within this file: * - * "LCD" task - the LCD task is a 'gatekeeper' task. It is the only task that - * is permitted to access the display directly. Other tasks wishing to write a - * message to the LCD send the message on a queue to the LCD task instead of - * accessing the LCD themselves. The LCD task just blocks on the queue waiting - * for messages - waking and displaying the messages as they arrive. The use - * of a gatekeeper in this manner permits both tasks and interrupts to write to - * the LCD without worrying about mutual exclusion. This is demonstrated by the - * check hook (see below) which sends messages to the display even though it - * executes from an interrupt context. - * * "Check" hook - This only executes fully every five seconds from the tick * hook. Its main function is to check that all the standard demo tasks are - * still operational. Should any unexpected behaviour be discovered within a - * demo task then the tick hook will write an error to the LCD (via the LCD task). - * If all the demo tasks are executing with their expected behaviour then the - * check hook writes PASS to the LCD (again via the LCD task), as described above. - * The check hook also toggles LED 4 each time it executes. - * - * LED tasks - These just demonstrate how multiple instances of a single task - * definition can be created. Each LED task simply toggles an LED. The task - * parameter is used to pass the number of the LED to be toggled into the task. + * still operational. The status can be viewed using on the Task Stats page + * served by the WEB server. * * "uIP" task - This is the task that handles the uIP stack. All TCP/IP * processing is performed in this task. */ -/* Standard includes. */ -#include - /* Scheduler includes. */ #include "FreeRTOS.h" #include "task.h" -#include "queue.h" -#include "semphr.h" /* Demo app includes. */ #include "BlockQ.h" @@ -108,11 +86,8 @@ /*-----------------------------------------------------------*/ -/* The number of LED tasks that will be created. */ -#define mainNUM_LED_TASKS ( 6 ) - /* The time between cycles of the 'check' functionality (defined within the -tick hook. */ +tick hook). */ #define mainCHECK_DELAY ( ( portTickType ) 5000 / portTICK_RATE_MS ) /* Task priorities. */ @@ -120,7 +95,6 @@ tick hook. */ #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 ) #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 ) #define mainUIP_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) -#define mainLCD_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 ) #define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY ) #define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY ) #define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 ) @@ -129,11 +103,10 @@ tick hook. */ handling library calls. */ #define mainBASIC_WEB_STACK_SIZE ( configMINIMAL_STACK_SIZE * 4 ) -/* The length of the queue used to send messages to the LCD task. */ -#define mainQUEUE_SIZE ( 3 ) +/* The message displayed by the WEB server when all tasks are executing +without an error being reported. */ +#define mainPASS_STATUS_MESSAGE "All tasks are executing without error." -/* The task that is toggled by the check task. */ -#define mainCHECK_TASK_LED ( 4 ) /*-----------------------------------------------------------*/ /* @@ -141,11 +114,6 @@ handling library calls. */ */ static void prvSetupHardware( void ); -/* - * Very simple task that toggles an LED. - */ -static void vLEDTask( void *pvParameters ); - /* * The task that handles the uIP stack. All TCP/IP processing is performed in * this task. @@ -153,14 +121,14 @@ static void vLEDTask( void *pvParameters ); extern void vuIP_Task( void *pvParameters ); /* - * The LCD gatekeeper task as described in the comments at the top of this file. - * */ -static void vLCDTask( void *pvParameters ); + * Simply returns the current status message for display on served WEB pages. + */ +char *pcGetTaskStatusMessage( void ); /*-----------------------------------------------------------*/ -/* The queue used to send messages to the LCD task. */ -xQueueHandle xLCDQueue; +/* Holds the status message displayed by the WEB server. */ +static char *pcStatusMessage = mainPASS_STATUS_MESSAGE; /*-----------------------------------------------------------*/ @@ -184,14 +152,6 @@ int main( void ) /* Create the uIP task. The WEB server runs in this task. */ xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY, NULL ); - /* Create the queue used by the LCD task. Messages for display on the LCD - are received via this queue. */ - xLCDQueue = xQueueCreate( mainQUEUE_SIZE, sizeof( xLCDMessage ) ); - - /* Start the LCD gatekeeper task - as described in the comments at the top - of this file. */ - xTaskCreate( vLCDTask, ( signed portCHAR * ) "LCD", configMINIMAL_STACK_SIZE * 2, NULL, mainLCD_TASK_PRIORITY, NULL ); - /* Start the scheduler. */ vTaskStartScheduler(); @@ -201,35 +161,9 @@ int main( void ) } /*-----------------------------------------------------------*/ -void vLCDTask( void *pvParameters ) -{ -xLCDMessage xMessage; -unsigned long ulRow = 0; -char cIPAddr[ 17 ]; /* To fit max IP address length of xxx.xxx.xxx.xxx\0 */ - - ( void ) pvParameters; - - /* The LCD gatekeeper task as described in the comments at the top of this - file. */ - - /* Initialise the LCD and display a startup message that includes the - configured IP address. */ - sprintf( cIPAddr, "%d.%d.%d.%d", configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 ); - - for( ;; ) - { - /* Wait for a message to arrive to be displayed. */ - while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS ); - - } -} -/*-----------------------------------------------------------*/ - void vApplicationTickHook( void ) { -static xLCDMessage xMessage = { "PASS" }; static unsigned portLONG ulTicksSinceLastDisplay = 0; -portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* Called from every tick interrupt as described in the comments at the top of this file. @@ -246,51 +180,47 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* Has an error been found in any task? */ if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { - xMessage.pcMessage = "ERROR: GEN Q"; + pcStatusMessage = "An error has been detected in the Generic Queue test/demo."; } else if( xAreQueuePeekTasksStillRunning() != pdTRUE ) { - xMessage.pcMessage = "ERROR: PEEK Q"; + pcStatusMessage = "An error has been detected in the Peek Queue test/demo."; } else if( xAreBlockingQueuesStillRunning() != pdTRUE ) { - xMessage.pcMessage = "ERROR: BLOCK Q"; + pcStatusMessage = "An error has been detected in the Block Queue test/demo."; } else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { - xMessage.pcMessage = "ERROR: BLOCK TIME"; + pcStatusMessage = "An error has been detected in the Block Time test/demo."; } else if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { - xMessage.pcMessage = "ERROR: SEMAPHR"; + pcStatusMessage = "An error has been detected in the Semaphore test/demo."; } else if( xArePollingQueuesStillRunning() != pdTRUE ) { - xMessage.pcMessage = "ERROR: POLL Q"; + pcStatusMessage = "An error has been detected in the Poll Queue test/demo."; } else if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { - xMessage.pcMessage = "ERROR: INT MATH"; + pcStatusMessage = "An error has been detected in the Int Math test/demo."; } else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { - xMessage.pcMessage = "ERROR: REC MUTEX"; + pcStatusMessage = "An error has been detected in the Mutex test/demo."; } - - /* Send the message to the OLED gatekeeper for display. The - xHigherPriorityTaskWoken parameter is not actually used here - as this function is running in the tick interrupt anyway - but - it must still be supplied. */ - xHigherPriorityTaskWoken = pdFALSE; - xQueueSendFromISR( xLCDQueue, &xMessage, &xHigherPriorityTaskWoken ); - - /* Also toggle and LED. This can be done from here because in this port - the LED toggling functions don't use critical sections. */ - vParTestToggleLED( mainCHECK_TASK_LED ); } } /*-----------------------------------------------------------*/ +char *pcGetTaskStatusMessage( void ) +{ + /* Not bothered about a critical section here. */ + return pcStatusMessage; +} +/*-----------------------------------------------------------*/ + void prvSetupHardware( void ) { /* Disable peripherals power. */ @@ -372,7 +302,7 @@ const unsigned long TCR_COUNT_RESET = 2, CTCR_CTM_TIMER = 0x00, TCR_COUNT_ENABLE collecting run time statistical information - basically the percentage of CPU time that each task is utilising. It is called automatically when the scheduler is started (assuming configGENERATE_RUN_TIME_STATS is set - to 1. */ + to 1). */ /* Power up and feed the timer. */ SC->PCONP |= 0x02UL; diff --git a/Demo/CORTEX_LPC1768_GCC_Rowley/webserver/emac.c b/Demo/CORTEX_LPC1768_GCC_Rowley/webserver/emac.c index 7e92422e0..768c8d40a 100644 --- a/Demo/CORTEX_LPC1768_GCC_Rowley/webserver/emac.c +++ b/Demo/CORTEX_LPC1768_GCC_Rowley/webserver/emac.c @@ -269,7 +269,7 @@ long x, lNextBuffer = 0; used. */ for( x = 0; x < NUM_TX_FRAG; x++ ) { - TX_DESC_PACKET( x ) = NULL; + TX_DESC_PACKET( x ) = ( unsigned long ) NULL; TX_DESC_CTRL( x ) = 0; TX_STAT_INFO( x ) = 0; } @@ -418,7 +418,7 @@ static void prvReturnBuffer( unsigned char *pucBuffer ) { unsigned long ul; - /* Mark a buffer as free for use. */ + /* Return a buffer to the pool of free buffers. */ for( ul = 0; ul < ETH_NUM_BUFFERS; ul++ ) { if( ETH_BUF( ul ) == ( unsigned long ) pucBuffer ) @@ -470,7 +470,7 @@ unsigned long ulAttempts = 0UL; /* Check to see if the Tx descriptor is free, indicated by its buffer being NULL. */ - while( TX_DESC_PACKET( emacTX_DESC_INDEX ) != NULL ) + while( TX_DESC_PACKET( emacTX_DESC_INDEX ) != ( unsigned long ) NULL ) { /* Wait for the Tx descriptor to become available. */ vTaskDelay( emacBUFFER_WAIT_DELAY ); @@ -594,7 +594,7 @@ long lHigherPriorityTaskWoken = pdFALSE; { /* The Tx buffer is no longer required. */ prvReturnBuffer( ( unsigned char * ) TX_DESC_PACKET( emacTX_DESC_INDEX ) ); - TX_DESC_PACKET( emacTX_DESC_INDEX ) = NULL; + TX_DESC_PACKET( emacTX_DESC_INDEX ) = ( unsigned long ) NULL; } } diff --git a/Demo/CORTEX_LPC1768_GCC_Rowley/webserver/httpd-cgi.c b/Demo/CORTEX_LPC1768_GCC_Rowley/webserver/httpd-cgi.c index 7967c175c..dfcedb833 100644 --- a/Demo/CORTEX_LPC1768_GCC_Rowley/webserver/httpd-cgi.c +++ b/Demo/CORTEX_LPC1768_GCC_Rowley/webserver/httpd-cgi.c @@ -208,14 +208,15 @@ PT_THREAD(net_stats(struct httpd_state *s, char *ptr)) /*---------------------------------------------------------------------------*/ extern void vTaskList( signed char *pcWriteBuffer ); -static char cCountBuf[ 32 ]; +extern char *pcGetTaskStatusMessage( void ); +static char cCountBuf[ 128 ]; long lRefreshCount = 0; static unsigned short generate_rtos_stats(void *arg) { ( void ) arg; lRefreshCount++; - sprintf( cCountBuf, "


Refresh count = %d", (int)lRefreshCount ); + sprintf( cCountBuf, "


Refresh count = %d


%s", (int)lRefreshCount, pcGetTaskStatusMessage() ); vTaskList( uip_appdata ); strcat( uip_appdata, cCountBuf ); @@ -239,11 +240,12 @@ unsigned long ulString; static unsigned short generate_io_state( void *arg ) { -extern long lParTestGetLEDState( unsigned long ulLED ); +extern long lParTestGetLEDState( void ); ( void ) arg; - if( lParTestGetLEDState( 1 << 7 ) == 0 ) + /* Get the state of the LEDs that are on the FIO1 port. */ + if( lParTestGetLEDState() ) { pcStatus = ""; } @@ -253,10 +255,7 @@ extern long lParTestGetLEDState( unsigned long ulLED ); } sprintf( uip_appdata, - "LED 7"\ - "

"\ - "", - pcStatus ); + "LED

", pcStatus ); return strlen( uip_appdata ); } diff --git a/Demo/CORTEX_LPC1768_GCC_Rowley/webserver/uIP_Task.c b/Demo/CORTEX_LPC1768_GCC_Rowley/webserver/uIP_Task.c index 75ba96d59..261baa505 100644 --- a/Demo/CORTEX_LPC1768_GCC_Rowley/webserver/uIP_Task.c +++ b/Demo/CORTEX_LPC1768_GCC_Rowley/webserver/uIP_Task.c @@ -69,12 +69,10 @@ #include "EthDev.h" #include "ParTest.h" -#include "LPC17xx.h" -#include "core_cm3.h" /*-----------------------------------------------------------*/ /* How long to wait before attempting to connect the MAC again. */ -#define uipINIT_WAIT 100 +#define uipINIT_WAIT ( 100 / portTICK_RATE_MS ) /* Shortcut to the header within the Rx buffer. */ #define xHeader ((struct uip_eth_hdr *) &uip_buf[ 0 ]) @@ -145,9 +143,12 @@ extern void ( vEMAC_ISR_Wrapper )( void ); portENTER_CRITICAL(); { EMAC->IntEnable = ( INT_RX_DONE | INT_TX_DONE ); - /* set the interrupt priority */ + + /* Set the interrupt priority to the max permissible to cause some + interrupt nesting. */ NVIC_SetPriority( ENET_IRQn, configMAX_SYSCALL_INTERRUPT_PRIORITY ); - /* enable the interrupt */ + + /* Enable the interrupt. */ NVIC_EnableIRQ( ENET_IRQn ); prvSetMACAddress(); } @@ -245,52 +246,23 @@ struct uip_eth_addr xAddr; void vApplicationProcessFormInput( portCHAR *pcInputString ) { -char *c, *pcText; -static portCHAR cMessageForDisplay[ 32 ]; -extern xQueueHandle xLCDQueue; -xLCDMessage xLCDMessage; +char *c; +extern void vParTestSetLEDState( long lState ); /* Process the form input sent by the IO page of the served HTML. */ c = strstr( pcInputString, "?" ); if( c ) { - /* Turn LED's on or off in accordance with the check box status. */ + /* Turn the FIO1 LED's on or off in accordance with the check box status. */ if( strstr( c, "LED0=1" ) != NULL ) { - /* Set LED7. */ - vParTestSetLED( 1 << 7, 1 ); + vParTestSetLEDState( pdTRUE ); } else { - /* Clear LED7. */ - vParTestSetLED( 1 << 7, 0 ); + vParTestSetLEDState( pdFALSE ); } - - /* Find the start of the text to be displayed on the LCD. */ - pcText = strstr( c, "LCD=" ); - pcText += strlen( "LCD=" ); - - /* Terminate the file name for further processing within uIP. */ - *c = 0x00; - - /* Terminate the LCD string. */ - c = strstr( pcText, " " ); - if( c != NULL ) - { - *c = 0x00; - } - - /* Add required spaces. */ - while( ( c = strstr( pcText, "+" ) ) != NULL ) - { - *c = ' '; - } - - /* Write the message to the LCD. */ - strcpy( cMessageForDisplay, pcText ); - xLCDMessage.pcMessage = cMessageForDisplay; - xQueueSend( xLCDQueue, &xLCDMessage, portMAX_DELAY ); } } -- 2.39.5