Please see my note book http://mbed.org/users/kenjiArai/notebook/freertos-on-mbed-board-with-mbed-cloud-ide--never-/

This is too old.
Below is another FreeRTOS on mbed.
http://developer.mbed.org/users/rgrover1/code/FreeRTOS/
I don't know it works well or not.
I have not evaluated it.

Committer:
kenjiArai
Date:
Sat Jan 01 11:17:45 2011 +0000
Revision:
0:d4960fcea8ff

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenjiArai 0:d4960fcea8ff 1 /*
kenjiArai 0:d4960fcea8ff 2 FreeRTOS V6.0.3 - Copyright (C) 2010 Real Time Engineers Ltd.
kenjiArai 0:d4960fcea8ff 3
kenjiArai 0:d4960fcea8ff 4 ***************************************************************************
kenjiArai 0:d4960fcea8ff 5 * *
kenjiArai 0:d4960fcea8ff 6 * If you are: *
kenjiArai 0:d4960fcea8ff 7 * *
kenjiArai 0:d4960fcea8ff 8 * + New to FreeRTOS, *
kenjiArai 0:d4960fcea8ff 9 * + Wanting to learn FreeRTOS or multitasking in general quickly *
kenjiArai 0:d4960fcea8ff 10 * + Looking for basic training, *
kenjiArai 0:d4960fcea8ff 11 * + Wanting to improve your FreeRTOS skills and productivity *
kenjiArai 0:d4960fcea8ff 12 * *
kenjiArai 0:d4960fcea8ff 13 * then take a look at the FreeRTOS eBook *
kenjiArai 0:d4960fcea8ff 14 * *
kenjiArai 0:d4960fcea8ff 15 * "Using the FreeRTOS Real Time Kernel - a Practical Guide" *
kenjiArai 0:d4960fcea8ff 16 * http://www.FreeRTOS.org/Documentation *
kenjiArai 0:d4960fcea8ff 17 * *
kenjiArai 0:d4960fcea8ff 18 * A pdf reference manual is also available. Both are usually delivered *
kenjiArai 0:d4960fcea8ff 19 * to your inbox within 20 minutes to two hours when purchased between 8am *
kenjiArai 0:d4960fcea8ff 20 * and 8pm GMT (although please allow up to 24 hours in case of *
kenjiArai 0:d4960fcea8ff 21 * exceptional circumstances). Thank you for your support! *
kenjiArai 0:d4960fcea8ff 22 * *
kenjiArai 0:d4960fcea8ff 23 ***************************************************************************
kenjiArai 0:d4960fcea8ff 24
kenjiArai 0:d4960fcea8ff 25 This file is part of the FreeRTOS distribution.
kenjiArai 0:d4960fcea8ff 26
kenjiArai 0:d4960fcea8ff 27 FreeRTOS is free software; you can redistribute it and/or modify it under
kenjiArai 0:d4960fcea8ff 28 the terms of the GNU General Public License (version 2) as published by the
kenjiArai 0:d4960fcea8ff 29 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
kenjiArai 0:d4960fcea8ff 30 ***NOTE*** The exception to the GPL is included to allow you to distribute
kenjiArai 0:d4960fcea8ff 31 a combined work that includes FreeRTOS without being obliged to provide the
kenjiArai 0:d4960fcea8ff 32 source code for proprietary components outside of the FreeRTOS kernel.
kenjiArai 0:d4960fcea8ff 33 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
kenjiArai 0:d4960fcea8ff 34 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
kenjiArai 0:d4960fcea8ff 35 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
kenjiArai 0:d4960fcea8ff 36 more details. You should have received a copy of the GNU General Public
kenjiArai 0:d4960fcea8ff 37 License and the FreeRTOS license exception along with FreeRTOS; if not it
kenjiArai 0:d4960fcea8ff 38 can be viewed here: http://www.freertos.org/a00114.html and also obtained
kenjiArai 0:d4960fcea8ff 39 by writing to Richard Barry, contact details for whom are available on the
kenjiArai 0:d4960fcea8ff 40 FreeRTOS WEB site.
kenjiArai 0:d4960fcea8ff 41
kenjiArai 0:d4960fcea8ff 42 1 tab == 4 spaces!
kenjiArai 0:d4960fcea8ff 43
kenjiArai 0:d4960fcea8ff 44 http://www.FreeRTOS.org - Documentation, latest information, license and
kenjiArai 0:d4960fcea8ff 45 contact details.
kenjiArai 0:d4960fcea8ff 46
kenjiArai 0:d4960fcea8ff 47 http://www.SafeRTOS.com - A version that is certified for use in safety
kenjiArai 0:d4960fcea8ff 48 critical systems.
kenjiArai 0:d4960fcea8ff 49
kenjiArai 0:d4960fcea8ff 50 http://www.OpenRTOS.com - Commercial support, development, porting,
kenjiArai 0:d4960fcea8ff 51 licensing and training services.
kenjiArai 0:d4960fcea8ff 52 */
kenjiArai 0:d4960fcea8ff 53
kenjiArai 0:d4960fcea8ff 54 /*
kenjiArai 0:d4960fcea8ff 55 * Creates six tasks that operate on three queues as follows:
kenjiArai 0:d4960fcea8ff 56 *
kenjiArai 0:d4960fcea8ff 57 * The first two tasks send and receive an incrementing number to/from a queue.
kenjiArai 0:d4960fcea8ff 58 * One task acts as a producer and the other as the consumer. The consumer is a
kenjiArai 0:d4960fcea8ff 59 * higher priority than the producer and is set to block on queue reads. The queue
kenjiArai 0:d4960fcea8ff 60 * only has space for one item - as soon as the producer posts a message on the
kenjiArai 0:d4960fcea8ff 61 * queue the consumer will unblock, pre-empt the producer, and remove the item.
kenjiArai 0:d4960fcea8ff 62 *
kenjiArai 0:d4960fcea8ff 63 * The second two tasks work the other way around. Again the queue used only has
kenjiArai 0:d4960fcea8ff 64 * enough space for one item. This time the consumer has a lower priority than the
kenjiArai 0:d4960fcea8ff 65 * producer. The producer will try to post on the queue blocking when the queue is
kenjiArai 0:d4960fcea8ff 66 * full. When the consumer wakes it will remove the item from the queue, causing
kenjiArai 0:d4960fcea8ff 67 * the producer to unblock, pre-empt the consumer, and immediately re-fill the
kenjiArai 0:d4960fcea8ff 68 * queue.
kenjiArai 0:d4960fcea8ff 69 *
kenjiArai 0:d4960fcea8ff 70 * The last two tasks use the same queue producer and consumer functions. This time the queue has
kenjiArai 0:d4960fcea8ff 71 * enough space for lots of items and the tasks operate at the same priority. The
kenjiArai 0:d4960fcea8ff 72 * producer will execute, placing items into the queue. The consumer will start
kenjiArai 0:d4960fcea8ff 73 * executing when either the queue becomes full (causing the producer to block) or
kenjiArai 0:d4960fcea8ff 74 * a context switch occurs (tasks of the same priority will time slice).
kenjiArai 0:d4960fcea8ff 75 *
kenjiArai 0:d4960fcea8ff 76 */
kenjiArai 0:d4960fcea8ff 77
kenjiArai 0:d4960fcea8ff 78 /*
kenjiArai 0:d4960fcea8ff 79
kenjiArai 0:d4960fcea8ff 80 Changes from V4.1.1
kenjiArai 0:d4960fcea8ff 81
kenjiArai 0:d4960fcea8ff 82 + The second set of tasks were created the wrong way around. This has been
kenjiArai 0:d4960fcea8ff 83 corrected.
kenjiArai 0:d4960fcea8ff 84 */
kenjiArai 0:d4960fcea8ff 85
kenjiArai 0:d4960fcea8ff 86
kenjiArai 0:d4960fcea8ff 87 #include <stdlib.h>
kenjiArai 0:d4960fcea8ff 88
kenjiArai 0:d4960fcea8ff 89 /* Scheduler include files. */
kenjiArai 0:d4960fcea8ff 90 #include "FreeRTOS.h"
kenjiArai 0:d4960fcea8ff 91 #include "task.h"
kenjiArai 0:d4960fcea8ff 92 #include "queue.h"
kenjiArai 0:d4960fcea8ff 93
kenjiArai 0:d4960fcea8ff 94 /* Demo program include files. */
kenjiArai 0:d4960fcea8ff 95 #include "BlockQ.h"
kenjiArai 0:d4960fcea8ff 96
kenjiArai 0:d4960fcea8ff 97 #define blckqSTACK_SIZE configMINIMAL_STACK_SIZE
kenjiArai 0:d4960fcea8ff 98 #define blckqNUM_TASK_SETS ( 3 )
kenjiArai 0:d4960fcea8ff 99
kenjiArai 0:d4960fcea8ff 100 /* Structure used to pass parameters to the blocking queue tasks. */
kenjiArai 0:d4960fcea8ff 101 typedef struct BLOCKING_QUEUE_PARAMETERS
kenjiArai 0:d4960fcea8ff 102 {
kenjiArai 0:d4960fcea8ff 103 xQueueHandle xQueue; /*< The queue to be used by the task. */
kenjiArai 0:d4960fcea8ff 104 portTickType xBlockTime; /*< The block time to use on queue reads/writes. */
kenjiArai 0:d4960fcea8ff 105 volatile short *psCheckVariable; /*< Incremented on each successful cycle to check the task is still running. */
kenjiArai 0:d4960fcea8ff 106 } xBlockingQueueParameters;
kenjiArai 0:d4960fcea8ff 107
kenjiArai 0:d4960fcea8ff 108 /* Task function that creates an incrementing number and posts it on a queue. */
kenjiArai 0:d4960fcea8ff 109 static portTASK_FUNCTION_PROTO( vBlockingQueueProducer, pvParameters );
kenjiArai 0:d4960fcea8ff 110
kenjiArai 0:d4960fcea8ff 111 /* Task function that removes the incrementing number from a queue and checks that
kenjiArai 0:d4960fcea8ff 112 it is the expected number. */
kenjiArai 0:d4960fcea8ff 113 static portTASK_FUNCTION_PROTO( vBlockingQueueConsumer, pvParameters );
kenjiArai 0:d4960fcea8ff 114
kenjiArai 0:d4960fcea8ff 115 /* Variables which are incremented each time an item is removed from a queue, and
kenjiArai 0:d4960fcea8ff 116 found to be the expected value.
kenjiArai 0:d4960fcea8ff 117 These are used to check that the tasks are still running. */
kenjiArai 0:d4960fcea8ff 118 static volatile short sBlockingConsumerCount[ blckqNUM_TASK_SETS ] = { ( unsigned short ) 0, ( unsigned short ) 0, ( unsigned short ) 0 };
kenjiArai 0:d4960fcea8ff 119
kenjiArai 0:d4960fcea8ff 120 /* Variable which are incremented each time an item is posted on a queue. These
kenjiArai 0:d4960fcea8ff 121 are used to check that the tasks are still running. */
kenjiArai 0:d4960fcea8ff 122 static volatile short sBlockingProducerCount[ blckqNUM_TASK_SETS ] = { ( unsigned short ) 0, ( unsigned short ) 0, ( unsigned short ) 0 };
kenjiArai 0:d4960fcea8ff 123
kenjiArai 0:d4960fcea8ff 124 /*-----------------------------------------------------------*/
kenjiArai 0:d4960fcea8ff 125
kenjiArai 0:d4960fcea8ff 126 void vStartBlockingQueueTasks( unsigned portBASE_TYPE uxPriority )
kenjiArai 0:d4960fcea8ff 127 {
kenjiArai 0:d4960fcea8ff 128 xBlockingQueueParameters *pxQueueParameters1, *pxQueueParameters2;
kenjiArai 0:d4960fcea8ff 129 xBlockingQueueParameters *pxQueueParameters3, *pxQueueParameters4;
kenjiArai 0:d4960fcea8ff 130 xBlockingQueueParameters *pxQueueParameters5, *pxQueueParameters6;
kenjiArai 0:d4960fcea8ff 131 const unsigned portBASE_TYPE uxQueueSize1 = 1, uxQueueSize5 = 5;
kenjiArai 0:d4960fcea8ff 132 const portTickType xBlockTime = ( portTickType ) 1000 / portTICK_RATE_MS;
kenjiArai 0:d4960fcea8ff 133 const portTickType xDontBlock = ( portTickType ) 0;
kenjiArai 0:d4960fcea8ff 134
kenjiArai 0:d4960fcea8ff 135 /* Create the first two tasks as described at the top of the file. */
kenjiArai 0:d4960fcea8ff 136
kenjiArai 0:d4960fcea8ff 137 /* First create the structure used to pass parameters to the consumer tasks. */
kenjiArai 0:d4960fcea8ff 138 pxQueueParameters1 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
kenjiArai 0:d4960fcea8ff 139
kenjiArai 0:d4960fcea8ff 140 /* Create the queue used by the first two tasks to pass the incrementing number.
kenjiArai 0:d4960fcea8ff 141 Pass a pointer to the queue in the parameter structure. */
kenjiArai 0:d4960fcea8ff 142 pxQueueParameters1->xQueue = xQueueCreate( uxQueueSize1, ( unsigned portBASE_TYPE ) sizeof( unsigned short ) );
kenjiArai 0:d4960fcea8ff 143
kenjiArai 0:d4960fcea8ff 144 /* The consumer is created first so gets a block time as described above. */
kenjiArai 0:d4960fcea8ff 145 pxQueueParameters1->xBlockTime = xBlockTime;
kenjiArai 0:d4960fcea8ff 146
kenjiArai 0:d4960fcea8ff 147 /* Pass in the variable that this task is going to increment so we can check it
kenjiArai 0:d4960fcea8ff 148 is still running. */
kenjiArai 0:d4960fcea8ff 149 pxQueueParameters1->psCheckVariable = &( sBlockingConsumerCount[ 0 ] );
kenjiArai 0:d4960fcea8ff 150
kenjiArai 0:d4960fcea8ff 151 /* Create the structure used to pass parameters to the producer task. */
kenjiArai 0:d4960fcea8ff 152 pxQueueParameters2 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
kenjiArai 0:d4960fcea8ff 153
kenjiArai 0:d4960fcea8ff 154 /* Pass the queue to this task also, using the parameter structure. */
kenjiArai 0:d4960fcea8ff 155 pxQueueParameters2->xQueue = pxQueueParameters1->xQueue;
kenjiArai 0:d4960fcea8ff 156
kenjiArai 0:d4960fcea8ff 157 /* The producer is not going to block - as soon as it posts the consumer will
kenjiArai 0:d4960fcea8ff 158 wake and remove the item so the producer should always have room to post. */
kenjiArai 0:d4960fcea8ff 159 pxQueueParameters2->xBlockTime = xDontBlock;
kenjiArai 0:d4960fcea8ff 160
kenjiArai 0:d4960fcea8ff 161 /* Pass in the variable that this task is going to increment so we can check
kenjiArai 0:d4960fcea8ff 162 it is still running. */
kenjiArai 0:d4960fcea8ff 163 pxQueueParameters2->psCheckVariable = &( sBlockingProducerCount[ 0 ] );
kenjiArai 0:d4960fcea8ff 164
kenjiArai 0:d4960fcea8ff 165
kenjiArai 0:d4960fcea8ff 166 /* Note the producer has a lower priority than the consumer when the tasks are
kenjiArai 0:d4960fcea8ff 167 spawned. */
kenjiArai 0:d4960fcea8ff 168 xTaskCreate( vBlockingQueueConsumer, ( signed char * ) "QConsB1", blckqSTACK_SIZE, ( void * ) pxQueueParameters1, uxPriority, NULL );
kenjiArai 0:d4960fcea8ff 169 xTaskCreate( vBlockingQueueProducer, ( signed char * ) "QProdB2", blckqSTACK_SIZE, ( void * ) pxQueueParameters2, tskIDLE_PRIORITY, NULL );
kenjiArai 0:d4960fcea8ff 170
kenjiArai 0:d4960fcea8ff 171
kenjiArai 0:d4960fcea8ff 172
kenjiArai 0:d4960fcea8ff 173 /* Create the second two tasks as described at the top of the file. This uses
kenjiArai 0:d4960fcea8ff 174 the same mechanism but reverses the task priorities. */
kenjiArai 0:d4960fcea8ff 175
kenjiArai 0:d4960fcea8ff 176 pxQueueParameters3 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
kenjiArai 0:d4960fcea8ff 177 pxQueueParameters3->xQueue = xQueueCreate( uxQueueSize1, ( unsigned portBASE_TYPE ) sizeof( unsigned short ) );
kenjiArai 0:d4960fcea8ff 178 pxQueueParameters3->xBlockTime = xDontBlock;
kenjiArai 0:d4960fcea8ff 179 pxQueueParameters3->psCheckVariable = &( sBlockingProducerCount[ 1 ] );
kenjiArai 0:d4960fcea8ff 180
kenjiArai 0:d4960fcea8ff 181 pxQueueParameters4 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
kenjiArai 0:d4960fcea8ff 182 pxQueueParameters4->xQueue = pxQueueParameters3->xQueue;
kenjiArai 0:d4960fcea8ff 183 pxQueueParameters4->xBlockTime = xBlockTime;
kenjiArai 0:d4960fcea8ff 184 pxQueueParameters4->psCheckVariable = &( sBlockingConsumerCount[ 1 ] );
kenjiArai 0:d4960fcea8ff 185
kenjiArai 0:d4960fcea8ff 186 xTaskCreate( vBlockingQueueConsumer, ( signed char * ) "QProdB3", blckqSTACK_SIZE, ( void * ) pxQueueParameters3, tskIDLE_PRIORITY, NULL );
kenjiArai 0:d4960fcea8ff 187 xTaskCreate( vBlockingQueueProducer, ( signed char * ) "QConsB4", blckqSTACK_SIZE, ( void * ) pxQueueParameters4, uxPriority, NULL );
kenjiArai 0:d4960fcea8ff 188
kenjiArai 0:d4960fcea8ff 189
kenjiArai 0:d4960fcea8ff 190
kenjiArai 0:d4960fcea8ff 191 /* Create the last two tasks as described above. The mechanism is again just
kenjiArai 0:d4960fcea8ff 192 the same. This time both parameter structures are given a block time. */
kenjiArai 0:d4960fcea8ff 193 pxQueueParameters5 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
kenjiArai 0:d4960fcea8ff 194 pxQueueParameters5->xQueue = xQueueCreate( uxQueueSize5, ( unsigned portBASE_TYPE ) sizeof( unsigned short ) );
kenjiArai 0:d4960fcea8ff 195 pxQueueParameters5->xBlockTime = xBlockTime;
kenjiArai 0:d4960fcea8ff 196 pxQueueParameters5->psCheckVariable = &( sBlockingProducerCount[ 2 ] );
kenjiArai 0:d4960fcea8ff 197
kenjiArai 0:d4960fcea8ff 198 pxQueueParameters6 = ( xBlockingQueueParameters * ) pvPortMalloc( sizeof( xBlockingQueueParameters ) );
kenjiArai 0:d4960fcea8ff 199 pxQueueParameters6->xQueue = pxQueueParameters5->xQueue;
kenjiArai 0:d4960fcea8ff 200 pxQueueParameters6->xBlockTime = xBlockTime;
kenjiArai 0:d4960fcea8ff 201 pxQueueParameters6->psCheckVariable = &( sBlockingConsumerCount[ 2 ] );
kenjiArai 0:d4960fcea8ff 202
kenjiArai 0:d4960fcea8ff 203 xTaskCreate( vBlockingQueueProducer, ( signed char * ) "QProdB5", blckqSTACK_SIZE, ( void * ) pxQueueParameters5, tskIDLE_PRIORITY, NULL );
kenjiArai 0:d4960fcea8ff 204 xTaskCreate( vBlockingQueueConsumer, ( signed char * ) "QConsB6", blckqSTACK_SIZE, ( void * ) pxQueueParameters6, tskIDLE_PRIORITY, NULL );
kenjiArai 0:d4960fcea8ff 205 }
kenjiArai 0:d4960fcea8ff 206 /*-----------------------------------------------------------*/
kenjiArai 0:d4960fcea8ff 207
kenjiArai 0:d4960fcea8ff 208 static portTASK_FUNCTION( vBlockingQueueProducer, pvParameters )
kenjiArai 0:d4960fcea8ff 209 {
kenjiArai 0:d4960fcea8ff 210 unsigned short usValue = 0;
kenjiArai 0:d4960fcea8ff 211 xBlockingQueueParameters *pxQueueParameters;
kenjiArai 0:d4960fcea8ff 212 short sErrorEverOccurred = pdFALSE;
kenjiArai 0:d4960fcea8ff 213
kenjiArai 0:d4960fcea8ff 214 pxQueueParameters = ( xBlockingQueueParameters * ) pvParameters;
kenjiArai 0:d4960fcea8ff 215
kenjiArai 0:d4960fcea8ff 216 for( ;; )
kenjiArai 0:d4960fcea8ff 217 {
kenjiArai 0:d4960fcea8ff 218 if( xQueueSend( pxQueueParameters->xQueue, ( void * ) &usValue, pxQueueParameters->xBlockTime ) != pdPASS )
kenjiArai 0:d4960fcea8ff 219 {
kenjiArai 0:d4960fcea8ff 220 sErrorEverOccurred = pdTRUE;
kenjiArai 0:d4960fcea8ff 221 }
kenjiArai 0:d4960fcea8ff 222 else
kenjiArai 0:d4960fcea8ff 223 {
kenjiArai 0:d4960fcea8ff 224 /* We have successfully posted a message, so increment the variable
kenjiArai 0:d4960fcea8ff 225 used to check we are still running. */
kenjiArai 0:d4960fcea8ff 226 if( sErrorEverOccurred == pdFALSE )
kenjiArai 0:d4960fcea8ff 227 {
kenjiArai 0:d4960fcea8ff 228 ( *pxQueueParameters->psCheckVariable )++;
kenjiArai 0:d4960fcea8ff 229 }
kenjiArai 0:d4960fcea8ff 230
kenjiArai 0:d4960fcea8ff 231 /* Increment the variable we are going to post next time round. The
kenjiArai 0:d4960fcea8ff 232 consumer will expect the numbers to follow in numerical order. */
kenjiArai 0:d4960fcea8ff 233 ++usValue;
kenjiArai 0:d4960fcea8ff 234 }
kenjiArai 0:d4960fcea8ff 235 }
kenjiArai 0:d4960fcea8ff 236 }
kenjiArai 0:d4960fcea8ff 237 /*-----------------------------------------------------------*/
kenjiArai 0:d4960fcea8ff 238
kenjiArai 0:d4960fcea8ff 239 static portTASK_FUNCTION( vBlockingQueueConsumer, pvParameters )
kenjiArai 0:d4960fcea8ff 240 {
kenjiArai 0:d4960fcea8ff 241 unsigned short usData, usExpectedValue = 0;
kenjiArai 0:d4960fcea8ff 242 xBlockingQueueParameters *pxQueueParameters;
kenjiArai 0:d4960fcea8ff 243 short sErrorEverOccurred = pdFALSE;
kenjiArai 0:d4960fcea8ff 244
kenjiArai 0:d4960fcea8ff 245 pxQueueParameters = ( xBlockingQueueParameters * ) pvParameters;
kenjiArai 0:d4960fcea8ff 246
kenjiArai 0:d4960fcea8ff 247 for( ;; )
kenjiArai 0:d4960fcea8ff 248 {
kenjiArai 0:d4960fcea8ff 249 if( xQueueReceive( pxQueueParameters->xQueue, &usData, pxQueueParameters->xBlockTime ) == pdPASS )
kenjiArai 0:d4960fcea8ff 250 {
kenjiArai 0:d4960fcea8ff 251 if( usData != usExpectedValue )
kenjiArai 0:d4960fcea8ff 252 {
kenjiArai 0:d4960fcea8ff 253 /* Catch-up. */
kenjiArai 0:d4960fcea8ff 254 usExpectedValue = usData;
kenjiArai 0:d4960fcea8ff 255
kenjiArai 0:d4960fcea8ff 256 sErrorEverOccurred = pdTRUE;
kenjiArai 0:d4960fcea8ff 257 }
kenjiArai 0:d4960fcea8ff 258 else
kenjiArai 0:d4960fcea8ff 259 {
kenjiArai 0:d4960fcea8ff 260 /* We have successfully received a message, so increment the
kenjiArai 0:d4960fcea8ff 261 variable used to check we are still running. */
kenjiArai 0:d4960fcea8ff 262 if( sErrorEverOccurred == pdFALSE )
kenjiArai 0:d4960fcea8ff 263 {
kenjiArai 0:d4960fcea8ff 264 ( *pxQueueParameters->psCheckVariable )++;
kenjiArai 0:d4960fcea8ff 265 }
kenjiArai 0:d4960fcea8ff 266
kenjiArai 0:d4960fcea8ff 267 /* Increment the value we expect to remove from the queue next time
kenjiArai 0:d4960fcea8ff 268 round. */
kenjiArai 0:d4960fcea8ff 269 ++usExpectedValue;
kenjiArai 0:d4960fcea8ff 270 }
kenjiArai 0:d4960fcea8ff 271 }
kenjiArai 0:d4960fcea8ff 272 }
kenjiArai 0:d4960fcea8ff 273 }
kenjiArai 0:d4960fcea8ff 274 /*-----------------------------------------------------------*/
kenjiArai 0:d4960fcea8ff 275
kenjiArai 0:d4960fcea8ff 276 /* This is called to check that all the created tasks are still running. */
kenjiArai 0:d4960fcea8ff 277 portBASE_TYPE xAreBlockingQueuesStillRunning( void )
kenjiArai 0:d4960fcea8ff 278 {
kenjiArai 0:d4960fcea8ff 279 static short sLastBlockingConsumerCount[ blckqNUM_TASK_SETS ] = { ( unsigned short ) 0, ( unsigned short ) 0, ( unsigned short ) 0 };
kenjiArai 0:d4960fcea8ff 280 static short sLastBlockingProducerCount[ blckqNUM_TASK_SETS ] = { ( unsigned short ) 0, ( unsigned short ) 0, ( unsigned short ) 0 };
kenjiArai 0:d4960fcea8ff 281 portBASE_TYPE xReturn = pdPASS, xTasks;
kenjiArai 0:d4960fcea8ff 282
kenjiArai 0:d4960fcea8ff 283 /* Not too worried about mutual exclusion on these variables as they are 16
kenjiArai 0:d4960fcea8ff 284 bits and we are only reading them. We also only care to see if they have
kenjiArai 0:d4960fcea8ff 285 changed or not.
kenjiArai 0:d4960fcea8ff 286
kenjiArai 0:d4960fcea8ff 287 Loop through each check variable to and return pdFALSE if any are found not
kenjiArai 0:d4960fcea8ff 288 to have changed since the last call. */
kenjiArai 0:d4960fcea8ff 289
kenjiArai 0:d4960fcea8ff 290 for( xTasks = 0; xTasks < blckqNUM_TASK_SETS; xTasks++ )
kenjiArai 0:d4960fcea8ff 291 {
kenjiArai 0:d4960fcea8ff 292 if( sBlockingConsumerCount[ xTasks ] == sLastBlockingConsumerCount[ xTasks ] )
kenjiArai 0:d4960fcea8ff 293 {
kenjiArai 0:d4960fcea8ff 294 xReturn = pdFALSE;
kenjiArai 0:d4960fcea8ff 295 }
kenjiArai 0:d4960fcea8ff 296 sLastBlockingConsumerCount[ xTasks ] = sBlockingConsumerCount[ xTasks ];
kenjiArai 0:d4960fcea8ff 297
kenjiArai 0:d4960fcea8ff 298
kenjiArai 0:d4960fcea8ff 299 if( sBlockingProducerCount[ xTasks ] == sLastBlockingProducerCount[ xTasks ] )
kenjiArai 0:d4960fcea8ff 300 {
kenjiArai 0:d4960fcea8ff 301 xReturn = pdFALSE;
kenjiArai 0:d4960fcea8ff 302 }
kenjiArai 0:d4960fcea8ff 303 sLastBlockingProducerCount[ xTasks ] = sBlockingProducerCount[ xTasks ];
kenjiArai 0:d4960fcea8ff 304 }
kenjiArai 0:d4960fcea8ff 305
kenjiArai 0:d4960fcea8ff 306 return xReturn;
kenjiArai 0:d4960fcea8ff 307 }
kenjiArai 0:d4960fcea8ff 308