X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=Demo%2FCommon%2FFull%2FBlockQ.c;h=54987b68f525ab4035fb9c9a25efbd2a78eb1146;hb=3ffe89d18ef2c06d06203b1b1091e65a98a395d2;hp=1edcc2342410f987e50f6ccd43a5f159633eb00a;hpb=9cd9de73ef9aacabfee26818b16407462341d86c;p=freertos diff --git a/Demo/Common/Full/BlockQ.c b/Demo/Common/Full/BlockQ.c index 1edcc2342..54987b68f 100644 --- a/Demo/Common/Full/BlockQ.c +++ b/Demo/Common/Full/BlockQ.c @@ -1,33 +1,67 @@ /* - FreeRTOS.org V4.2.0 - Copyright (C) 2003-2007 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 as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - 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 can be applied should you wish 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 of how and when the exception - can be applied. - - *************************************************************************** - See http://www.FreeRTOS.org for documentation, latest information, license - and contact details. Please ensure to read the configuration and relevant - port sections of the online documentation. - *************************************************************************** + FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd. + + + *************************************************************************** + * * + * 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! + + *************************************************************************** + * * + * 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, training, latest information, + license and contact details. + + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, + including FreeRTOS+Trace - an indispensable productivity tool. + + Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell + the code with commercial support, indemnification, and middleware, under + the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also + provide a safety engineered and independently SIL3 certified version under + the SafeRTOS brand: http://www.SafeRTOS.com. */ /** @@ -66,7 +100,7 @@ Changes from V1.00: Changes from V2.0.0 + Delay periods are now specified using variables and constants of - portTickType rather than unsigned portLONG. + portTickType rather than unsigned long. Changes from V4.0.2 @@ -86,7 +120,7 @@ Changes from V4.0.2 #include "BlockQ.h" #include "print.h" -#define blckqSTACK_SIZE ( ( unsigned portSHORT ) 128 ) +#define blckqSTACK_SIZE ( ( unsigned short ) configMINIMAL_STACK_SIZE ) #define blckqNUM_TASK_SETS ( 3 ) /* Structure used to pass parameters to the blocking queue tasks. */ @@ -94,7 +128,7 @@ typedef struct BLOCKING_QUEUE_PARAMETERS { xQueueHandle xQueue; /*< The queue to be used by the task. */ portTickType xBlockTime; /*< The block time to use on queue reads/writes. */ - volatile portSHORT *psCheckVariable; /*< Incremented on each successful cycle to check the task is still running. */ + volatile short *psCheckVariable; /*< Incremented on each successful cycle to check the task is still running. */ } xBlockingQueueParameters; /* Task function that creates an incrementing number and posts it on a queue. */ @@ -107,11 +141,11 @@ static void vBlockingQueueConsumer( void *pvParameters ); /* Variables which are incremented each time an item is removed from a queue, and found to be the expected value. These are used to check that the tasks are still running. */ -static volatile portSHORT sBlockingConsumerCount[ blckqNUM_TASK_SETS ] = { ( portSHORT ) 0, ( portSHORT ) 0, ( portSHORT ) 0 }; +static volatile short sBlockingConsumerCount[ blckqNUM_TASK_SETS ] = { ( short ) 0, ( short ) 0, ( short ) 0 }; /* Variable which are incremented each time an item is posted on a queue. These are used to check that the tasks are still running. */ -static volatile portSHORT sBlockingProducerCount[ blckqNUM_TASK_SETS ] = { ( portSHORT ) 0, ( portSHORT ) 0, ( portSHORT ) 0 }; +static volatile short sBlockingProducerCount[ blckqNUM_TASK_SETS ] = { ( short ) 0, ( short ) 0, ( short ) 0 }; /*-----------------------------------------------------------*/ @@ -131,7 +165,7 @@ const portTickType xDontBlock = ( portTickType ) 0; /* Create the queue used by the first two tasks to pass the incrementing number. Pass a pointer to the queue in the parameter structure. */ - pxQueueParameters1->xQueue = xQueueCreate( uxQueueSize1, ( unsigned portBASE_TYPE ) sizeof( unsigned portSHORT ) ); + pxQueueParameters1->xQueue = xQueueCreate( uxQueueSize1, ( unsigned portBASE_TYPE ) sizeof( unsigned short ) ); /* The consumer is created first so gets a block time as described above. */ pxQueueParameters1->xBlockTime = xBlockTime; @@ -166,7 +200,7 @@ const portTickType xDontBlock = ( portTickType ) 0; the same mechanism but reverses the task priorities. */ pxQueueParameters3 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) ); - pxQueueParameters3->xQueue = xQueueCreate( uxQueueSize1, ( unsigned portBASE_TYPE ) sizeof( unsigned portSHORT ) ); + pxQueueParameters3->xQueue = xQueueCreate( uxQueueSize1, ( unsigned portBASE_TYPE ) sizeof( unsigned short ) ); pxQueueParameters3->xBlockTime = xDontBlock; pxQueueParameters3->psCheckVariable = &( sBlockingProducerCount[ 1 ] ); @@ -183,7 +217,7 @@ const portTickType xDontBlock = ( portTickType ) 0; /* Create the last two tasks as described above. The mechanism is again just the same. This time both parameter structures are given a block time. */ pxQueueParameters5 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) ); - pxQueueParameters5->xQueue = xQueueCreate( uxQueueSize5, ( unsigned portBASE_TYPE ) sizeof( unsigned portSHORT ) ); + pxQueueParameters5->xQueue = xQueueCreate( uxQueueSize5, ( unsigned portBASE_TYPE ) sizeof( unsigned short ) ); pxQueueParameters5->xBlockTime = xBlockTime; pxQueueParameters5->psCheckVariable = &( sBlockingProducerCount[ 2 ] ); @@ -199,11 +233,11 @@ const portTickType xDontBlock = ( portTickType ) 0; static void vBlockingQueueProducer( void *pvParameters ) { -unsigned portSHORT usValue = 0; +unsigned short usValue = 0; xBlockingQueueParameters *pxQueueParameters; -const portCHAR * const pcTaskStartMsg = "Blocking queue producer started.\r\n"; -const portCHAR * const pcTaskErrorMsg = "Could not post on blocking queue\r\n"; -portSHORT sErrorEverOccurred = pdFALSE; +const char * const pcTaskStartMsg = "Blocking queue producer started.\r\n"; +const char * const pcTaskErrorMsg = "Could not post on blocking queue\r\n"; +short sErrorEverOccurred = pdFALSE; pxQueueParameters = ( xBlockingQueueParameters * ) pvParameters; @@ -212,7 +246,7 @@ portSHORT sErrorEverOccurred = pdFALSE; for( ;; ) { - if( xQueueSend( pxQueueParameters->xQueue, ( void * ) &usValue, pxQueueParameters->xBlockTime ) != pdPASS ) + if( xQueueSendToBack( pxQueueParameters->xQueue, ( void * ) &usValue, pxQueueParameters->xBlockTime ) != pdPASS ) { vPrintDisplayMessage( &pcTaskErrorMsg ); sErrorEverOccurred = pdTRUE; @@ -236,11 +270,11 @@ portSHORT sErrorEverOccurred = pdFALSE; static void vBlockingQueueConsumer( void *pvParameters ) { -unsigned portSHORT usData, usExpectedValue = 0; +unsigned short usData, usExpectedValue = 0; xBlockingQueueParameters *pxQueueParameters; -const portCHAR * const pcTaskStartMsg = "Blocking queue consumer started.\r\n"; -const portCHAR * const pcTaskErrorMsg = "Incorrect value received on blocking queue.\r\n"; -portSHORT sErrorEverOccurred = pdFALSE; +const char * const pcTaskStartMsg = "Blocking queue consumer started.\r\n"; +const char * const pcTaskErrorMsg = "Incorrect value received on blocking queue.\r\n"; +short sErrorEverOccurred = pdFALSE; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg ); @@ -281,8 +315,8 @@ portSHORT sErrorEverOccurred = pdFALSE; /* This is called to check that all the created tasks are still running. */ portBASE_TYPE xAreBlockingQueuesStillRunning( void ) { -static portSHORT sLastBlockingConsumerCount[ blckqNUM_TASK_SETS ] = { ( portSHORT ) 0, ( portSHORT ) 0, ( portSHORT ) 0 }; -static portSHORT sLastBlockingProducerCount[ blckqNUM_TASK_SETS ] = { ( portSHORT ) 0, ( portSHORT ) 0, ( portSHORT ) 0 }; +static short sLastBlockingConsumerCount[ blckqNUM_TASK_SETS ] = { ( short ) 0, ( short ) 0, ( short ) 0 }; +static short sLastBlockingProducerCount[ blckqNUM_TASK_SETS ] = { ( short ) 0, ( short ) 0, ( short ) 0 }; portBASE_TYPE xReturn = pdPASS, xTasks; /* Not too worried about mutual exclusion on these variables as they are 16