X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=FreeRTOS%2FDemo%2FCommon%2FMinimal%2Fsp_flop.c;h=04e5677cdfa8c55b1e83a367bbe77c89562e94e7;hb=b15dfacb6026af3b0ba697e5753844923b468d2b;hp=2620fbaf745f1e0e7a43350c74ed969c9bd0f5be;hpb=04f5830e5a04fd6d0d953fefe62e3c2ae922a5b1;p=freertos diff --git a/FreeRTOS/Demo/Common/Minimal/sp_flop.c b/FreeRTOS/Demo/Common/Minimal/sp_flop.c index 2620fbaf7..04e5677cd 100644 --- a/FreeRTOS/Demo/Common/Minimal/sp_flop.c +++ b/FreeRTOS/Demo/Common/Minimal/sp_flop.c @@ -1,108 +1,40 @@ /* - FreeRTOS V8.2.0rc1 - Copyright (C) 2014 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - 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 on 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?". Have you defined configASSERT()? * - * * - * http://www.FreeRTOS.org/FAQHelp.html * - * * - *************************************************************************** - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - *************************************************************************** - * * - * Investing in training allows your team to be as productive as * - * possible as early as possible, lowering your overall development * - * cost, and enabling you to bring a more robust product to market * - * earlier than would otherwise be possible. Richard Barry is both * - * the architect and key author of FreeRTOS, and so also the world's * - * leading authority on what is the world's most popular real time * - * kernel for deeply embedded MCU designs. Obtaining your training * - * from Richard ensures your team will gain directly from his in-depth * - * product knowledge and years of usage experience. Contact Real Time * - * Engineers Ltd to enquire about the FreeRTOS Masterclass, presented * - * by Richard Barry: http://www.FreeRTOS.org/contact - * * - *************************************************************************** - - *************************************************************************** - * * - * You are receiving this top quality software for free. Please play * - * fair and reciprocate by reporting any suspected issues and * - * participating in the community forum: * - * http://www.FreeRTOS.org/support * - * * - * Thank you! * - * * - *************************************************************************** - - 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.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial 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.3.0 + * Copyright (C) 2020 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! + */ /* - * Creates eight tasks, each of which loops continuously performing a floating + * Creates eight tasks, each of which loops continuously performing a floating * point calculation - using single precision variables. * - * All the tasks run at the idle priority and never block or yield. This causes - * all eight tasks to time slice with the idle task. Running at the idle priority + * All the tasks run at the idle priority and never block or yield. This causes + * all eight tasks to time slice with the idle task. Running at the idle priority * means that these tasks will get pre-empted any time another task is ready to run - * or a time slice occurs. More often than not the pre-emption will occur mid - * calculation, creating a good test of the schedulers context switch mechanism - a - * calculation producing an unexpected result could be a symptom of a corruption in + * or a time slice occurs. More often than not the pre-emption will occur mid + * calculation, creating a good test of the schedulers context switch mechanism - a + * calculation producing an unexpected result could be a symptom of a corruption in * the context of a task. */ @@ -119,14 +51,14 @@ #define mathSTACK_SIZE configMINIMAL_STACK_SIZE #define mathNUMBER_OF_TASKS ( 8 ) -/* Four tasks, each of which performs a different floating point calculation. +/* Four tasks, each of which performs a different floating point calculation. Each of the four is created twice. */ static portTASK_FUNCTION_PROTO( vCompetingMathTask1, pvParameters ); static portTASK_FUNCTION_PROTO( vCompetingMathTask2, pvParameters ); static portTASK_FUNCTION_PROTO( vCompetingMathTask3, pvParameters ); static portTASK_FUNCTION_PROTO( vCompetingMathTask4, pvParameters ); -/* These variables are used to check that all the tasks are still running. If a +/* These variables are used to check that all the tasks are still running. If a task gets a calculation wrong it will stop incrementing its check variable. */ static volatile uint16_t usTaskCheck[ mathNUMBER_OF_TASKS ] = { ( uint16_t ) 0 }; @@ -159,7 +91,7 @@ short sError = pdFALSE; fAnswer = ( f1 + f2 ) * f3; - /* The variable this task increments to show it is still running is passed in + /* The variable this task increments to show it is still running is passed in as the parameter. */ pusTaskCheckVariable = ( uint16_t * ) pvParameters; @@ -176,7 +108,7 @@ short sError = pdFALSE; taskYIELD(); #endif - /* If the calculation does not match the expected constant, stop the + /* If the calculation does not match the expected constant, stop the increment of the check variable. */ if( fabs( f4 - fAnswer ) > 0.001F ) { @@ -185,7 +117,7 @@ short sError = pdFALSE; if( sError == pdFALSE ) { - /* If the calculation has always been correct, increment the check + /* If the calculation has always been correct, increment the check variable so we know this task is still running okay. */ ( *pusTaskCheckVariable )++; } @@ -212,7 +144,7 @@ short sError = pdFALSE; fAnswer = ( f1 / f2 ) * f3; - /* The variable this task increments to show it is still running is passed in + /* The variable this task increments to show it is still running is passed in as the parameter. */ pusTaskCheckVariable = ( uint16_t * ) pvParameters; @@ -228,8 +160,8 @@ short sError = pdFALSE; #if configUSE_PREEMPTION == 0 taskYIELD(); #endif - - /* If the calculation does not match the expected constant, stop the + + /* If the calculation does not match the expected constant, stop the increment of the check variable. */ if( fabs( f4 - fAnswer ) > 0.001F ) { @@ -238,7 +170,7 @@ short sError = pdFALSE; if( sError == pdFALSE ) { - /* If the calculation has always been correct, increment the check + /* If the calculation has always been correct, increment the check variable so we know this task is still running okay. */ ( *pusTaskCheckVariable )++; @@ -259,25 +191,25 @@ const size_t xArraySize = 10; size_t xPosition; short sError = pdFALSE; - /* The variable this task increments to show it is still running is passed in + /* The variable this task increments to show it is still running is passed in as the parameter. */ pusTaskCheckVariable = ( uint16_t * ) pvParameters; pfArray = ( float * ) pvPortMalloc( xArraySize * sizeof( float ) ); - /* Keep filling an array, keeping a running total of the values placed in the - array. Then run through the array adding up all the values. If the two totals + /* Keep filling an array, keeping a running total of the values placed in the + array. Then run through the array adding up all the values. If the two totals do not match, stop the check variable from incrementing. */ for( ;; ) { fTotal1 = 0.0F; fTotal2 = 0.0F; fPosition = 0.0F; - + for( xPosition = 0; xPosition < xArraySize; xPosition++ ) { pfArray[ xPosition ] = fPosition + 5.5F; - fTotal1 += fPosition + 5.5F; + fTotal1 += fPosition + 5.5F; } #if configUSE_PREEMPTION == 0 @@ -301,7 +233,7 @@ short sError = pdFALSE; if( sError == pdFALSE ) { - /* If the calculation has always been correct, increment the check + /* If the calculation has always been correct, increment the check variable so we know this task is still running okay. */ ( *pusTaskCheckVariable )++; } @@ -317,14 +249,14 @@ const size_t xArraySize = 10; size_t xPosition; short sError = pdFALSE; - /* The variable this task increments to show it is still running is passed in + /* The variable this task increments to show it is still running is passed in as the parameter. */ pusTaskCheckVariable = ( uint16_t * ) pvParameters; pfArray = ( float * ) pvPortMalloc( xArraySize * sizeof( float ) ); - /* Keep filling an array, keeping a running total of the values placed in the - array. Then run through the array adding up all the values. If the two totals + /* Keep filling an array, keeping a running total of the values placed in the + array. Then run through the array adding up all the values. If the two totals do not match, stop the check variable from incrementing. */ for( ;; ) { @@ -335,7 +267,7 @@ short sError = pdFALSE; for( xPosition = 0; xPosition < xArraySize; xPosition++ ) { pfArray[ xPosition ] = fPosition * 12.123F; - fTotal1 += fPosition * 12.123F; + fTotal1 += fPosition * 12.123F; } #if configUSE_PREEMPTION == 0 @@ -359,23 +291,23 @@ short sError = pdFALSE; if( sError == pdFALSE ) { - /* If the calculation has always been correct, increment the check + /* If the calculation has always been correct, increment the check variable so we know this task is still running okay. */ ( *pusTaskCheckVariable )++; } } -} +} /*-----------------------------------------------------------*/ /* This is called to check that all the created tasks are still running. */ BaseType_t xAreMathsTaskStillRunning( void ) { -/* Keep a history of the check variables so we know if they have been incremented +/* Keep a history of the check variables so we know if they have been incremented since the last call. */ static uint16_t usLastTaskCheck[ mathNUMBER_OF_TASKS ] = { ( uint16_t ) 0 }; BaseType_t xReturn = pdTRUE, xTask; - /* Check the maths tasks are still running by ensuring their check variables + /* Check the maths tasks are still running by ensuring their check variables are still incrementing. */ for( xTask = 0; xTask < mathNUMBER_OF_TASKS; xTask++ ) {