X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=FreeRTOS%2FDemo%2FCORTEX_A9_Zynq_ZC702%2FRTOSDemo%2Fsrc%2FFull_Demo%2Fmain_full.c;h=1d60f5062cfd9176e7bc8c9072d01171554e09c9;hb=e23c63709bf25dfbd3fc685c688de550b720f97c;hp=18e359506f54d732321d4a4b60bc7d9e333bea53;hpb=6918563766d74d4739c41212dcb3c04f423b6693;p=freertos diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/main_full.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/main_full.c index 18e359506..1d60f5062 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/main_full.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/main_full.c @@ -1,74 +1,36 @@ /* - FreeRTOS V8.0.0:rc1 - Copyright (C) 2014 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that has become a de facto standard. * - * * - * Help yourself get started quickly and support the FreeRTOS * - * project by purchasing a FreeRTOS tutorial book, reference * - * manual, or both from: http://www.FreeRTOS.org/Documentation * - * * - * Thank you! * - * * - *************************************************************************** - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - >>! NOTE: The modification to the GPL is included to allow you to distribute - >>! a combined work that includes FreeRTOS without being obliged to provide - >>! the source code for proprietary components outside of the FreeRTOS - >>! kernel. - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available from the following - link: http://www.freertos.org/a00114.html - - 1 tab == 4 spaces! - - *************************************************************************** - * * - * Having a problem? Start by reading the FAQ "My application does * - * not run, what could be wrong?" * - * * - * http://www.FreeRTOS.org/FAQHelp.html * - * * - *************************************************************************** - - http://www.FreeRTOS.org - Documentation, books, training, latest versions, - license and Real Time Engineers Ltd. contact details. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High - Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.1.1 + * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /****************************************************************************** - * NOTE 1: This project provides two demo applications. A simple blinky style - * project, and a more comprehensive test and demo application. The - * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select - * between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY - * in main.c. This file implements the comprehensive test and demo version. + * NOTE 1: This project provides three demo applications. A simple blinky + * style project, a more comprehensive test and demo application, and an + * lwIP example. The mainSELECTED_APPLICATION setting in main.c is used to + * select between the three. See the notes on using mainSELECTED_APPLICATION + * in main.c. This file implements the comprehensive version. * * NOTE 2: This file only contains the source code that is specific to the * full demo. Generic functions, such FreeRTOS hook functions, and functions @@ -143,6 +105,16 @@ #include "TimerDemo.h" #include "QueueOverwrite.h" #include "IntQueue.h" +#include "EventGroupsDemo.h" +#include "TaskNotify.h" +#include "IntSemTest.h" +#include "StaticAllocation.h" +#include "AbortDelay.h" +#include "MessageBufferDemo.h" +#include "StreamBufferDemo.h" +#include "StreamBufferInterrupt.h" +#include "MessageBufferAMP.h" + /* Priorities for the demo application tasks. */ #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1UL ) @@ -181,13 +153,11 @@ purpose of ensuring parameters are passed into tasks correctly. */ /* The base period used by the timer test tasks. */ #define mainTIMER_TEST_PERIOD ( 50 ) +/* Base stack size of tasks created in the message buffer demos. */ +#define mainMESSAGE_BUFFER_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 ) + /*-----------------------------------------------------------*/ -/* - * Called by main() to run the full demo (as opposed to the blinky demo) when - * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0. - */ -void main_full( void ); /* * The check task, as described at the top of this file. @@ -217,19 +187,29 @@ extern void vRegisterSampleCLICommands( void ); */ extern void vUARTCommandConsoleStart( uint16_t usStackSize, UBaseType_t uxPriority ); +/* + * A high priority task that does nothing other than execute at a pseudo random + * time to ensure the other test tasks don't just execute in a repeating + * pattern. + */ +static void prvPseudoRandomiser( void *pvParameters ); + /*-----------------------------------------------------------*/ /* The following two variables are used to communicate the status of the register check tasks to the check task. If the variables keep incrementing, -then the register check tasks has not discovered any errors. If a variable +then the register check tasks have not discovered any errors. If a variable stops incrementing, then an error has been found. */ volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL; +/* String for display in the web server. It is set to an error message if the +check task detects an error. */ +char *pcStatusMessage = "All tasks running without error"; /*-----------------------------------------------------------*/ void main_full( void ) { - /* Start all the other standard demo/test tasks. They have not particular + /* Start all the other standard demo/test tasks. They have no particular functionality, but do demonstrate how to use the FreeRTOS API and test the kernel port. */ vStartInterruptQueueTasks(); @@ -243,6 +223,15 @@ void main_full( void ) vStartMathTasks( mainFLOP_TASK_PRIORITY ); vStartTimerDemoTask( mainTIMER_TEST_PERIOD ); vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY ); + vStartEventGroupTasks(); + vStartTaskNotifyTask(); + vStartInterruptSemaphoreTasks(); + vStartStaticallyAllocatedTasks(); + vCreateAbortDelayTasks(); + vStartMessageBufferTasks( mainMESSAGE_BUFFER_STACK_SIZE ); + vStartStreamBufferTasks(); + vStartStreamBufferInterruptDemo(); + vStartMessageBufferAMPTasks( mainMESSAGE_BUFFER_STACK_SIZE ); /* Start the tasks that implements the command console on the UART, as described above. */ @@ -255,6 +244,9 @@ void main_full( void ) xTaskCreate( prvRegTestTaskEntry1, "Reg1", configMINIMAL_STACK_SIZE, mainREG_TEST_TASK_1_PARAMETER, tskIDLE_PRIORITY, NULL ); xTaskCreate( prvRegTestTaskEntry2, "Reg2", configMINIMAL_STACK_SIZE, mainREG_TEST_TASK_2_PARAMETER, tskIDLE_PRIORITY, NULL ); + /* Create the task that just adds a little random behaviour. */ + xTaskCreate( prvPseudoRandomiser, "Rnd", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL ); + /* Create the task that performs the 'check' functionality, as described at the top of this file. */ xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); @@ -281,8 +273,8 @@ void main_full( void ) static void prvCheckTask( void *pvParameters ) { -portTickType xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD; -portTickType xLastExecutionTime; +TickType_t xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD; +TickType_t xLastExecutionTime; static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0; unsigned long ulErrorFound = pdFALSE; @@ -308,75 +300,120 @@ unsigned long ulErrorFound = pdFALSE; that they are all still running, and that none have detected an error. */ if( xAreIntQueueTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 0UL; } if( xAreMathsTaskStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 1UL; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 2UL; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 3UL; } if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 4UL; } if ( xAreGenericQueueTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 5UL; } if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 6UL; } if( xIsCreateTaskStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 7UL; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 8UL; } - if( xAreTimerDemoTasksStillRunning( ( portTickType ) mainNO_ERROR_CHECK_TASK_PERIOD ) != pdPASS ) + if( xAreTimerDemoTasksStillRunning( ( TickType_t ) mainNO_ERROR_CHECK_TASK_PERIOD ) != pdPASS ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 9UL; } if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 10UL; } if( xIsQueueOverwriteTaskStillRunning() != pdPASS ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 11UL; + } + + if( xAreEventGroupTasksStillRunning() != pdPASS ) + { + ulErrorFound |= 1UL << 12UL; + } + + if( xAreTaskNotificationTasksStillRunning() != pdTRUE ) + { + ulErrorFound |= 1UL << 13UL; + } + + if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE ) + { + ulErrorFound |= 1UL << 14UL; + } + + if( xAreStaticAllocationTasksStillRunning() != pdPASS ) + { + ulErrorFound |= 1UL << 15UL; + } + + if( xAreAbortDelayTestTasksStillRunning() != pdPASS ) + { + ulErrorFound |= 1UL << 16UL; + } + + if( xAreStreamBufferTasksStillRunning() != pdTRUE ) + { + ulErrorFound |= 1UL << 17UL; + } + + if( xAreMessageBufferTasksStillRunning() != pdTRUE ) + { + ulErrorFound |= 1UL << 18UL; + } + + if( xIsInterruptStreamBufferDemoStillRunning() != pdPASS ) + { + ulErrorFound |= 1UL << 19UL; + } + + if( xAreMessageBufferAMPTasksStillRunning() != pdPASS ) + { + ulErrorFound |= 1UL << 20UL; } /* Check that the register test 1 task is still running. */ if( ulLastRegTest1Value == ulRegTest1LoopCounter ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 21UL; } ulLastRegTest1Value = ulRegTest1LoopCounter; /* Check that the register test 2 task is still running. */ if( ulLastRegTest2Value == ulRegTest2LoopCounter ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 22UL; } ulLastRegTest2Value = ulRegTest2LoopCounter; @@ -392,11 +429,18 @@ unsigned long ulErrorFound = pdFALSE; gone wrong (it might just be that the loop back connector required by the comtest tasks has not been fitted). */ xDelayPeriod = mainERROR_CHECK_TASK_PERIOD; + pcStatusMessage = "Error found in at least one task."; } } } /*-----------------------------------------------------------*/ +char *pcMainGetTaskStatusMessage( void ) +{ + return pcStatusMessage; +} +/*-----------------------------------------------------------*/ + static void prvRegTestTaskEntry1( void *pvParameters ) { /* Although the regtest task is written in assembler, its entry point is @@ -443,6 +487,40 @@ static void prvRegTestTaskEntry2( void *pvParameters ) } /*-----------------------------------------------------------*/ +static void prvPseudoRandomiser( void *pvParameters ) +{ +const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL, ulMinDelay = ( 35 / portTICK_PERIOD_MS ); +volatile uint32_t ulNextRand = ( uint32_t ) &pvParameters, ulValue; + + /* This task does nothing other than ensure there is a little bit of + disruption in the scheduling pattern of the other tasks. Normally this is + done by generating interrupts at pseudo random times. */ + for( ;; ) + { + ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement; + ulValue = ( ulNextRand >> 16UL ) & 0xffUL; + + if( ulValue < ulMinDelay ) + { + ulValue = ulMinDelay; + } + + vTaskDelay( ulValue ); + + while( ulValue > 0 ) + { + __asm volatile( "NOP" ); + __asm volatile( "NOP" ); + __asm volatile( "NOP" ); + __asm volatile( "NOP" ); + + ulValue--; + } + } +} + + +