From 636aa2a9522a40e90ed00a5508b40f14990be487 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Mon, 11 Apr 2011 19:59:12 +0000 Subject: [PATCH] Continue work on SmartFusion demo. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1352 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Demo/CORTEX_A2F200_SoftConsole/.cproject | 8 +- .../CreateProjectDirectoryStructure.bat | 2 +- .../FreeRTOSConfig.h | 11 +- Demo/CORTEX_A2F200_SoftConsole/ParTest.c | 20 ++- Demo/CORTEX_A2F200_SoftConsole/main-full.c | 150 ++++++++++++++++-- 5 files changed, 165 insertions(+), 26 deletions(-) diff --git a/Demo/CORTEX_A2F200_SoftConsole/.cproject b/Demo/CORTEX_A2F200_SoftConsole/.cproject index 00993904b..f671c1e98 100644 --- a/Demo/CORTEX_A2F200_SoftConsole/.cproject +++ b/Demo/CORTEX_A2F200_SoftConsole/.cproject @@ -66,7 +66,7 @@ - + @@ -454,12 +454,12 @@ @@ -485,7 +485,7 @@ - + diff --git a/Demo/CORTEX_A2F200_SoftConsole/CreateProjectDirectoryStructure.bat b/Demo/CORTEX_A2F200_SoftConsole/CreateProjectDirectoryStructure.bat index 688d1efed..14eb3a922 100644 --- a/Demo/CORTEX_A2F200_SoftConsole/CreateProjectDirectoryStructure.bat +++ b/Demo/CORTEX_A2F200_SoftConsole/CreateProjectDirectoryStructure.bat @@ -38,7 +38,7 @@ IF EXIST FreeRTOS_Source Goto END copy ..\..\Source\portable\GCC\ARM_CM3\*.* FreeRTOS_Source\portable\GCC\ARM_CM3 REM Copy the basic memory allocation files - copy ..\..\Source\portable\MemMang\heap_1.c FreeRTOS_Source\portable\MemMang + copy ..\..\Source\portable\MemMang\heap_2.c FreeRTOS_Source\portable\MemMang REM Copy the core FreeTCPIP (based on uIP) files copy ..\Common\ethernet\FreeTCPIP\psock.c FreeTCPIP diff --git a/Demo/CORTEX_A2F200_SoftConsole/FreeRTOSConfig.h b/Demo/CORTEX_A2F200_SoftConsole/FreeRTOSConfig.h index b2c9697e6..a4edf244c 100644 --- a/Demo/CORTEX_A2F200_SoftConsole/FreeRTOSConfig.h +++ b/Demo/CORTEX_A2F200_SoftConsole/FreeRTOSConfig.h @@ -82,7 +82,7 @@ #define configTICK_RATE_HZ ( ( portTickType ) 1000 ) #define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 ) #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) -#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 7 * 1024 ) ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 45 * 1024 ) ) #define configMAX_TASK_NAME_LEN ( 10 ) #define configUSE_TRACE_FACILITY 0 #define configUSE_16_BIT_TICKS 0 @@ -91,7 +91,7 @@ #define configQUEUE_REGISTRY_SIZE 0 #define configGENERATE_RUN_TIME_STATS 0 #define configCHECK_FOR_STACK_OVERFLOW 2 -#define configUSE_RECURSIVE_MUTEXES 0 +#define configUSE_RECURSIVE_MUTEXES 1 #define configUSE_MALLOC_FAILED_HOOK 1 #define configUSE_APPLICATION_TASK_TAG 0 #define configUSE_COUNTING_SEMAPHORES 0 @@ -103,7 +103,7 @@ /* Software timer definitions. */ #define configUSE_TIMERS 1 #define configTIMER_TASK_PRIORITY ( 3 ) -#define configTIMER_QUEUE_LENGTH 5 +#define configTIMER_QUEUE_LENGTH 10 #define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE ) /* Set the following definitions to 1 to include the API function, or zero @@ -116,6 +116,11 @@ to exclude the API function. */ #define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelay 1 +/* Override some of the priorities set in the common demo tasks. This is +required to ensure false positive timing errors are not reported. */ +#define bktPRIMARY_PRIORITY ( configMAX_PRIORITIES - 3 ) +#define bktSECONDARY_PRIORITY ( configMAX_PRIORITIES - 4 ) + /* Use the system definition, if there is one */ #ifdef __NVIC_PRIO_BITS #define configPRIO_BITS __NVIC_PRIO_BITS diff --git a/Demo/CORTEX_A2F200_SoftConsole/ParTest.c b/Demo/CORTEX_A2F200_SoftConsole/ParTest.c index 2820e1492..44f43c2fd 100644 --- a/Demo/CORTEX_A2F200_SoftConsole/ParTest.c +++ b/Demo/CORTEX_A2F200_SoftConsole/ParTest.c @@ -111,6 +111,24 @@ void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ) } /*-----------------------------------------------------------*/ +void vParTestSetLEDFromISR( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ) +{ + if( uxLED < partstMAX_LEDS ) + { + if( xValue == pdTRUE ) + { + ulGPIOState &= ~( 1UL << uxLED ); + } + else + { + ulGPIOState |= ( 1UL << uxLED ); + } + + MSS_GPIO_set_outputs( ulGPIOState ); + } +} +/*-----------------------------------------------------------*/ + void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) { if( uxLED < partstMAX_LEDS ) @@ -119,7 +137,7 @@ void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) interrupt. */ taskENTER_CRITICAL(); { - if( ( ulGPIOState & ( 1UL << uxLED ) != 0UL ) + if( ( ulGPIOState & ( 1UL << uxLED ) ) != 0UL ) { ulGPIOState &= ~( 1UL << uxLED ); } diff --git a/Demo/CORTEX_A2F200_SoftConsole/main-full.c b/Demo/CORTEX_A2F200_SoftConsole/main-full.c index 2d0afc19d..182ea4711 100644 --- a/Demo/CORTEX_A2F200_SoftConsole/main-full.c +++ b/Demo/CORTEX_A2F200_SoftConsole/main-full.c @@ -114,7 +114,15 @@ remain on until a full five seconds pass without the button being pressed. /* Common demo includes. */ #include "partest.h" - +#include "flash.h" +#include "BlockQ.h" +#include "death.h" +#include "blocktim.h" +#include "semtest.h" +#include "GenQTest.h" +#include "QPeek.h" +#include "recmutex.h" +#include "TimerDemo.h" /* Priorities at which the tasks are created. */ #define mainQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 ) @@ -127,10 +135,24 @@ converted to ticks using the portTICK_RATE_MS constant. */ /* The number of items the queue can hold. This is 1 as the receive task will remove items as they are added, meaning the send task should always find the queue empty. */ -#define mainQUEUE_LENGTH ( 1 ) +#define mainQUEUE_LENGTH ( 1 ) + +#define mainCHECK_LED 0x07UL +#define mainTIMER_CONTROLLED_LED 0x06UL +#define mainTASK_CONTROLLED_LED 0x05UL + +#define mainTIMER_TEST_PERIOD ( 50 ) + +#define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) +#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 1 ) +#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 ) +#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) +#define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) +#define mainuIP_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY ) +#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY ) -#define mainTASK_CONTROLLED_LED 0x01UL -#define mainTIMER_CONTROLLED_LED 0x02UL /*-----------------------------------------------------------*/ /* @@ -150,6 +172,14 @@ static void prvQueueSendTask( void *pvParameters ); */ static void vLEDTimerCallback( xTimerHandle xTimer ); +static void vCheckTimerCallback( xTimerHandle xTimer ); + +/* + * This is not a 'standard' partest function, so the prototype is not in + * partest.h. + */ +void vParTestSetLEDFromISR( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ); + /*-----------------------------------------------------------*/ /* The queue used by both tasks. */ @@ -159,6 +189,12 @@ static xQueueHandle xQueue = NULL; function. */ static xTimerHandle xLEDTimer = NULL; +static xTimerHandle xCheckTimer = NULL; + +/* The status message that is displayed at the bottom of the "task stats" web +page, which is served by the uIP task. This will report any errors picked up +by the reg test task. */ +static const char *pcStatusMessage = NULL; /*-----------------------------------------------------------*/ @@ -188,6 +224,22 @@ int main(void) vLEDTimerCallback /* The callback function that switches the LED off. */ ); + xCheckTimer = xTimerCreate( ( const signed char * ) "CheckTimer", /* A text name, purely to help debugging. */ + ( 3000 / portTICK_RATE_MS ), /* The timer period, in this case 3000ms (3s). */ + pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */ + ( void * ) 0, /* The ID is not used, so can be set to anything. */ + vCheckTimerCallback /* The callback function that inspects the status of all the other tasks. */ + ); + + vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); + vCreateBlockTimeTasks(); + vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); + vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY ); + vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY ); + vStartQueuePeekTasks(); + vStartRecursiveMutexTasks(); + vStartTimerDemoTask( mainTIMER_TEST_PERIOD ); + /* Start the tasks and timer running. */ vTaskStartScheduler(); } @@ -201,6 +253,73 @@ int main(void) } /*-----------------------------------------------------------*/ +static void vCheckTimerCallback( xTimerHandle xTimer ) +{ + /* Check the standard demo tasks are running without error. */ + if( xAreGenericQueueTasksStillRunning() != pdTRUE ) + { + /* Increase the rate at which this task cycles, which will increase the + rate at which mainCHECK_LED flashes to give visual feedback that an error + has occurred. */ + pcStatusMessage = "Error: GenQueue"; +// xPrintf( pcStatusMessage ); + } + + if( xAreQueuePeekTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: QueuePeek\r\n"; +// xPrintf( pcStatusMessage ); + } + + if( xAreBlockingQueuesStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: BlockQueue\r\n"; +// xPrintf( pcStatusMessage ); + } + + if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: BlockTime\r\n"; +// xPrintf( pcStatusMessage ); + } + + if( xAreSemaphoreTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: SemTest\r\n"; +// xPrintf( pcStatusMessage ); + } + + if( xIsCreateTaskStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: Death\r\n"; +// xPrintf( pcStatusMessage ); + } + + if( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: RecMutex\r\n"; +// xPrintf( pcStatusMessage ); + } + + if( xAreTimerDemoTasksStillRunning( ( 3000 / portTICK_RATE_MS ) ) != pdTRUE ) + { + pcStatusMessage = "Error: TimerDemo"; + } + + /* Toggle the check LED to give an indication of the system status. If + the LED toggles every 5 seconds then everything is ok. A faster toggle + indicates an error. */ + vParTestToggleLED( mainCHECK_LED ); + + if( pcStatusMessage != NULL ) + { + /* The block time is set to zero as a timer callback must *never* + attempt to block. */ + xTimerChangePeriod( xCheckTimer, ( 500 / portTICK_RATE_MS ), 0 ); + } +} +/*-----------------------------------------------------------*/ + static void vLEDTimerCallback( xTimerHandle xTimer ) { /* The timer has expired - so no button pushes have occurred in the last @@ -208,8 +327,7 @@ static void vLEDTimerCallback( xTimerHandle xTimer ) a critical section because it is accessed from multiple tasks, and the button interrupt - in this trivial case, for simplicity, the critical section is omitted. */ - ulGPIOState |= mainTIMER_CONTROLLED_LED; - MSS_GPIO_set_outputs( ulGPIOState ); + vParTestSetLED( mainTIMER_CONTROLLED_LED, pdFALSE ); } /*-----------------------------------------------------------*/ @@ -221,8 +339,7 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* The button was pushed, so ensure the LED is on before resetting the LED timer. The LED timer will turn the LED off if the button is not pushed within 5000ms. */ - ulGPIOState &= ~mainTIMER_CONTROLLED_LED; - MSS_GPIO_set_outputs( ulGPIOState ); + vParTestSetLEDFromISR( mainTIMER_CONTROLLED_LED, pdTRUE ); /* This interrupt safe FreeRTOS function can be called from this interrupt because the interrupt priority is below the @@ -246,6 +363,13 @@ static void prvQueueSendTask( void *pvParameters ) portTickType xNextWakeTime; const unsigned long ulValueToSend = 100UL; + /* The suicide tasks must be created last as they need to know how many + tasks were running prior to their creation in order to ascertain whether + or not the correct/expected number of tasks are running at any given time. */ + vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY ); + + xTimerStart( xCheckTimer, portMAX_DELAY ); + /* Initialise xNextWakeTime - this only needs to be done once. */ xNextWakeTime = xTaskGetTickCount(); @@ -285,15 +409,7 @@ unsigned long ulReceivedValue; because it is accessed from multiple tasks, and the button interrupt - in this trivial case, for simplicity, the critical section is omitted. */ - if( ( ulGPIOState & mainTASK_CONTROLLED_LED ) != 0 ) - { - ulGPIOState &= ~mainTASK_CONTROLLED_LED; - } - else - { - ulGPIOState |= mainTASK_CONTROLLED_LED; - } - MSS_GPIO_set_outputs( ulGPIOState ); + vParTestToggleLED( mainTASK_CONTROLLED_LED ); } } } -- 2.39.5