X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=Demo%2FPC%2Fmain.c;h=0250b1267c9bd4c6b55577a559dcfc349e2c1462;hb=921b32a7bf83d65e25cbeecde3b87b43da084dbb;hp=0effc4435c708226072505359a6095b6a2bcc500;hpb=b3d7a98a7532d7841874f4e478766bc0239dd133;p=freertos diff --git a/Demo/PC/main.c b/Demo/PC/main.c index 0effc4435..0250b1267 100644 --- a/Demo/PC/main.c +++ b/Demo/PC/main.c @@ -1,52 +1,54 @@ /* - FreeRTOS.org V5.2.0 - Copyright (C) 2003-2009 Richard Barry. - - This file is part of the FreeRTOS.org distribution. - - FreeRTOS.org 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. - - FreeRTOS.org 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. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along - with FreeRTOS.org; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA. - - A special exception to the GPL is included to allow you to distribute a - combined work that includes FreeRTOS.org without being obliged to provide - the source code for any proprietary components. See the licensing section - of http://www.FreeRTOS.org for full details. - - - *************************************************************************** - * * - * Get the FreeRTOS eBook! See http://www.FreeRTOS.org/Documentation * - * * - * This is a concise, step by step, 'hands on' guide that describes both * - * general multitasking concepts and FreeRTOS specifics. It presents and * - * explains numerous examples that are written using the FreeRTOS API. * - * Full source code for all the examples is provided in an accompanying * - * .zip file. * - * * - *************************************************************************** - - 1 tab == 4 spaces! - - Please ensure to read the configuration and relevant port sections of the - online documentation. - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. + FreeRTOS V7.0.2 - Copyright (C) 2011 Real Time Engineers Ltd. + - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. + *************************************************************************** + * * + * FreeRTOS tutorial books are available in pdf and paperback. * + * Complete, revised, and edited pdf reference manuals are also * + * available. * + * * + * Purchasing FreeRTOS documentation will not only help you, by * + * ensuring you get running as quickly as possible and with an * + * in-depth knowledge of how to use FreeRTOS, it will also help * + * the FreeRTOS project to continue with its mission of providing * + * professional grade, cross platform, de facto standard solutions * + * for microcontrollers - completely free of charge! * + * * + * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * + * * + * Thank you for using FreeRTOS, and thank you for your support! * + * * + *************************************************************************** + + + 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. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. */ /** @@ -122,8 +124,8 @@ #define mainSEMAPHORE_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) #define mainGENERIC_QUEUE_PRIORITY ( tskIDLE_PRIORITY ) -#define mainPRINT_STACK_SIZE ( ( unsigned portSHORT ) 512 ) -#define mainDEBUG_LOG_BUFFER_SIZE ( ( unsigned portSHORT ) 20480 ) +#define mainPRINT_STACK_SIZE ( ( unsigned short ) 512 ) +#define mainDEBUG_LOG_BUFFER_SIZE ( ( unsigned short ) 20480 ) /* The number of flash co-routines to create. */ #define mainNUM_FLASH_CO_ROUTINES ( 8 ) @@ -142,11 +144,11 @@ static void prvCheckForKeyPresses( void ); /* Buffer used by the trace visualisation utility so only needed if the trace being used. */ #if configUSE_TRACE_FACILITY == 1 - static portCHAR pcWriteBuffer[ mainDEBUG_LOG_BUFFER_SIZE ]; + static char pcWriteBuffer[ mainDEBUG_LOG_BUFFER_SIZE ]; #endif /* Constant definition used to turn on/off the pre-emptive scheduler. */ -static const portSHORT sUsingPreemption = configUSE_PREEMPTION; +static const short sUsingPreemption = configUSE_PREEMPTION; /* Start the math tasks appropriate to the build. The Borland port does not yet support floating point so uses the integer equivalent. */ @@ -160,12 +162,12 @@ static portBASE_TYPE prvExampleTaskHook( void * pvParameter ); /* Just used to count the number of times the example task callback function is called, and the number of times a queue send passes. */ -static unsigned portLONG portLONG uxCheckTaskHookCallCount = 0; -static unsigned portLONG portLONG uxQueueSendPassedCount = 0; +static unsigned long long uxCheckTaskHookCallCount = 0; +static unsigned long long uxQueueSendPassedCount = 0; /*-----------------------------------------------------------*/ -portSHORT main( void ) +short main( void ) { /* Initialise hardware and utilities. */ vParTestInitialise(); @@ -239,16 +241,23 @@ static void vErrorChecks( void *pvParameters ) { portTickType xExpectedWakeTime; const portTickType xPrintRate = ( portTickType ) 5000 / portTICK_RATE_MS; -const portLONG lMaxAllowableTimeDifference = ( portLONG ) 0; +const long lMaxAllowableTimeDifference = ( long ) 0; portTickType xWakeTime; -portLONG lTimeDifference; -const portCHAR *pcReceivedMessage; -const portCHAR * const pcTaskBlockedTooLongMsg = "Print task blocked too long!\r\n"; +long lTimeDifference; +const char *pcReceivedMessage; +const char * const pcTaskBlockedTooLongMsg = "Print task blocked too long!\r\n"; +const char * const pcUnexpectedHookValueMsg = "Task hook has unexpected value!\r\n"; ( void ) pvParameters; /* Register our callback function. */ vTaskSetApplicationTaskTag( NULL, prvExampleTaskHook ); + + /* Just for test purposes. */ + if( xTaskGetApplicationTaskTag( NULL ) != prvExampleTaskHook ) + { + vPrintDisplayMessage( &pcUnexpectedHookValueMsg ); + } /* Loop continuously, blocking, then checking all the other tasks are still running, before blocking once again. This task blocks on the queue of @@ -276,11 +285,11 @@ const portCHAR * const pcTaskBlockedTooLongMsg = "Print task blocked too long!\r time we should have unblocked. */ if( xWakeTime > xExpectedWakeTime ) { - lTimeDifference = ( portLONG ) ( xWakeTime - xExpectedWakeTime ); + lTimeDifference = ( long ) ( xWakeTime - xExpectedWakeTime ); } else { - lTimeDifference = ( portLONG ) ( xExpectedWakeTime - xWakeTime ); + lTimeDifference = ( long ) ( xExpectedWakeTime - xWakeTime ); } if( lTimeDifference > lMaxAllowableTimeDifference ) @@ -314,7 +323,7 @@ const portCHAR * const pcTaskBlockedTooLongMsg = "Print task blocked too long!\r static void prvCheckForKeyPresses( void ) { -portSHORT sIn; +short sIn; taskENTER_CRITICAL(); #ifdef DEBUG_BUILD @@ -343,7 +352,7 @@ portSHORT sIn; break; case 'e' : { - unsigned portLONG ulBufferLength; + unsigned long ulBufferLength; ulBufferLength = ulTaskEndTrace(); vWriteBufferToDisk( pcWriteBuffer, ulBufferLength ); } @@ -359,8 +368,8 @@ portSHORT sIn; static void prvCheckOtherTasksAreStillRunning( void ) { -static portSHORT sErrorHasOccurred = pdFALSE; -static unsigned portLONG portLONG uxLastHookCallCount = 0, uxLastQueueSendCount = 0; +static short sErrorHasOccurred = pdFALSE; +static unsigned long long uxLastHookCallCount = 0, uxLastQueueSendCount = 0; if( prvCheckMathTasksAreStillRunning() != pdTRUE ) {