2 FreeRTOS.org V5.0.0 - Copyright (C) 2003-2008 Richard Barry.
\r
4 This file is part of the FreeRTOS.org distribution.
\r
6 FreeRTOS.org is free software; you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation; either version 2 of the License, or
\r
9 (at your option) any later version.
\r
11 FreeRTOS.org is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with FreeRTOS.org; if not, write to the Free Software
\r
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
20 A special exception to the GPL can be applied should you wish to distribute
\r
21 a combined work that includes FreeRTOS.org, without being obliged to provide
\r
22 the source code for any proprietary components. See the licensing section
\r
23 of http://www.FreeRTOS.org for full details of how and when the exception
\r
26 ***************************************************************************
\r
27 ***************************************************************************
\r
29 * SAVE TIME AND MONEY! We can port FreeRTOS.org to your own hardware, *
\r
30 * and even write all or part of your application on your behalf. *
\r
31 * See http://www.OpenRTOS.com for details of the services we provide to *
\r
32 * expedite your project. *
\r
34 ***************************************************************************
\r
35 ***************************************************************************
\r
37 Please ensure to read the configuration and relevant port sections of the
\r
38 online documentation.
\r
40 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
43 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
46 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
47 licensing and training services.
\r
51 * This file defines one of the more complex set of demo/test tasks. They are
\r
52 * designed to stress test the queue implementation though pseudo simultaneous
\r
53 * multiple reads and multiple writes from both tasks of varying priority and
\r
54 * interrupts. The interrupts are prioritised such to ensure that nesting
\r
55 * occurs (for those ports that support it).
\r
57 * The test ensures that, while being accessed from three tasks and two
\r
58 * interrupts, all the data sent to the queues is also received from
\r
59 * the same queue, and that no duplicate items are either sent or received.
\r
60 * The tests also ensure that a low priority task is never able to successfully
\r
61 * read from or write to a queue when a task of higher priority is attempting
\r
62 * the same operation.
\r
65 /* Standard includes. */
\r
68 /* SafeRTOS includes. */
\r
69 #include "FreeRTOS.h"
\r
73 /* Demo app includes. */
\r
74 #include "IntQueue.h"
\r
75 #include "IntQueueTimer.h"
\r
77 /* Priorities used by test tasks. */
\r
78 #define intqHIGHER_PRIORITY 1
\r
79 #define intqLOWER_PRIORITY 0
\r
81 /* The number of values to send/receive before checking that all values were
\r
82 processed as expected. */
\r
83 #define intqNUM_VALUES_TO_LOG ( 200 )
\r
84 #define intqSHORT_DELAY ( 75 )
\r
86 /* The value by which the value being sent to or received from a queue should
\r
87 increment past intqNUM_VALUES_TO_LOG before we check that all values have been
\r
88 sent/received correctly. This is done to ensure that all tasks and interrupts
\r
89 accessing the queue have completed their accesses with the
\r
90 intqNUM_VALUES_TO_LOG range. */
\r
91 #define intqVALUE_OVERRUN ( 50 )
\r
93 /* The delay used by the polling task. A short delay is used for code
\r
95 #define intqONE_TICK_DELAY ( 1 )
\r
97 /* Each task and interrupt is given a unique identifier. This value is used to
\r
98 identify which task sent or received each value. The identifier is also used
\r
99 to distinguish between two tasks that are running the same task function. */
\r
100 #define intqHIGH_PRIROITY_TASK1 ( ( unsigned portBASE_TYPE ) 1 )
\r
101 #define intqHIGH_PRIROITY_TASK2 ( ( unsigned portBASE_TYPE ) 2 )
\r
102 #define intqLOW_PRIROITY_TASK ( ( unsigned portBASE_TYPE ) 3 )
\r
103 #define intqFIRST_INTERRUPT ( ( unsigned portBASE_TYPE ) 4 )
\r
104 #define intqSECOND_INTERRUPT ( ( unsigned portBASE_TYPE ) 5 )
\r
105 #define intqQUEUE_LENGTH ( ( unsigned portBASE_TYPE ) 10 )
\r
107 /* At least intqMIN_ACCEPTABLE_TASK_COUNT values should be sent to/received
\r
108 from each queue by each task, otherwise an error is detected. */
\r
109 #define intqMIN_ACCEPTABLE_TASK_COUNT ( 5 )
\r
111 /* Send the next value to the queue that is normally empty. This is called
\r
112 from within the interrupts. */
\r
113 #define timerNORMALLY_EMPTY_TX() \
\r
114 if( xQueueIsQueueFullFromISR( xNormallyEmptyQueue ) != pdTRUE ) \
\r
116 unsigned portBASE_TYPE uxSavedInterruptStatus; \
\r
117 uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); \
\r
119 xQueueSendFromISR( xNormallyEmptyQueue, ( void * ) &uxValueForNormallyEmptyQueue, &xHigherPriorityTaskWoken ); \
\r
120 uxValueForNormallyEmptyQueue++; \
\r
122 portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); \
\r
125 /* Send the next value to the queue that is normally full. This is called
\r
126 from within the interrupts. */
\r
127 #define timerNORMALLY_FULL_TX() \
\r
128 if( xQueueIsQueueFullFromISR( xNormallyFullQueue ) != pdTRUE ) \
\r
130 unsigned portBASE_TYPE uxSavedInterruptStatus; \
\r
131 uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); \
\r
133 xQueueSendFromISR( xNormallyFullQueue, ( void * ) &uxValueForNormallyFullQueue, &xHigherPriorityTaskWoken ); \
\r
134 uxValueForNormallyFullQueue++; \
\r
136 portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); \
\r
139 /* Receive a value from the normally empty queue. This is called from within
\r
141 #define timerNORMALLY_EMPTY_RX() \
\r
142 if( xQueueReceiveFromISR( xNormallyEmptyQueue, &uxRxedValue, &xHigherPriorityTaskWoken ) != pdPASS ) \
\r
144 prvQueueAccessLogError( __LINE__ ); \
\r
148 prvRecordValue_NormallyEmpty( uxRxedValue, intqSECOND_INTERRUPT ); \
\r
151 /* Receive a value from the normally full queue. This is called from within
\r
153 #define timerNORMALLY_FULL_RX() \
\r
154 if( xQueueReceiveFromISR( xNormallyFullQueue, &uxRxedValue, &xHigherPriorityTaskWoken ) == pdPASS ) \
\r
156 prvRecordValue_NormallyFull( uxRxedValue, intqSECOND_INTERRUPT ); \
\r
160 /*-----------------------------------------------------------*/
\r
162 /* The two queues used by the test. */
\r
163 static xQueueHandle xNormallyEmptyQueue, xNormallyFullQueue;
\r
165 /* Variables used to detect a stall in one of the tasks. */
\r
166 static unsigned portBASE_TYPE uxHighPriorityLoops1 = 0, uxHighPriorityLoops2 = 0, uxLowPriorityLoops1 = 0, uxLowPriorityLoops2 = 0;
\r
168 /* Any unexpected behaviour sets xErrorStatus to fail and log the line that
\r
169 caused the error in xErrorLine. */
\r
170 static portBASE_TYPE xErrorStatus = pdPASS;
\r
171 static unsigned portBASE_TYPE xErrorLine = ( unsigned portBASE_TYPE ) 0;
\r
173 /* Used for sequencing between tasks. */
\r
174 static portBASE_TYPE xWasSuspended = pdFALSE;
\r
176 /* The values that are sent to the queues. An incremented value is sent each
\r
177 time to each queue. */
\r
178 volatile unsigned portBASE_TYPE uxValueForNormallyEmptyQueue = 0, uxValueForNormallyFullQueue = 0;
\r
180 /* A handle to some of the tasks is required so they can be suspended/resumed. */
\r
181 xTaskHandle xHighPriorityNormallyEmptyTask1, xHighPriorityNormallyEmptyTask2, xHighPriorityNormallyFullTask1, xHighPriorityNormallyFullTask2;
\r
183 /* When a value is received in a queue the value is ticked off in the array
\r
184 the array position of the value is set to a the identifier of the task or
\r
185 interrupt that accessed the queue. This way missing or duplicate values can be
\r
187 static unsigned portCHAR ucNormallyEmptyReceivedValues[ intqNUM_VALUES_TO_LOG ] = { 0 };
\r
188 static unsigned portCHAR ucNormallyFullReceivedValues[ intqNUM_VALUES_TO_LOG ] = { 0 };
\r
190 /* The test tasks themselves. */
\r
191 static void prvLowerPriorityNormallyEmptyTask( void *pvParameters );
\r
192 static void prvLowerPriorityNormallyFullTask( void *pvParameters );
\r
193 static void prvHigherPriorityNormallyEmptyTask( void *pvParameters );
\r
194 static void prv1stHigherPriorityNormallyFullTask( void *pvParameters );
\r
195 static void prv2ndHigherPriorityNormallyFullTask( void *pvParameters );
\r
197 /* Used to mark the positions within the ucNormallyEmptyReceivedValues and
\r
198 ucNormallyFullReceivedValues arrays, while checking for duplicates. */
\r
199 static void prvRecordValue_NormallyEmpty( unsigned portBASE_TYPE uxValue, unsigned portBASE_TYPE uxSource );
\r
200 static void prvRecordValue_NormallyFull( unsigned portBASE_TYPE uxValue, unsigned portBASE_TYPE uxSource );
\r
202 /* Logs the line on which an error occurred. */
\r
203 static void prvQueueAccessLogError( unsigned portBASE_TYPE uxLine );
\r
205 /*-----------------------------------------------------------*/
\r
207 void vStartInterruptQueueTasks( void )
\r
209 /* Start the test tasks. */
\r
210 xTaskCreate( prvHigherPriorityNormallyEmptyTask, ( signed portCHAR * ) "H1QRx", configMINIMAL_STACK_SIZE, ( void * ) intqHIGH_PRIROITY_TASK1, intqHIGHER_PRIORITY, &xHighPriorityNormallyEmptyTask1 );
\r
211 xTaskCreate( prvHigherPriorityNormallyEmptyTask, ( signed portCHAR * ) "H2QRx", configMINIMAL_STACK_SIZE, ( void * ) intqHIGH_PRIROITY_TASK2, intqHIGHER_PRIORITY, &xHighPriorityNormallyEmptyTask2 );
\r
212 xTaskCreate( prvLowerPriorityNormallyEmptyTask, ( signed portCHAR * ) "LQRx", configMINIMAL_STACK_SIZE, NULL, intqLOWER_PRIORITY, NULL );
\r
213 xTaskCreate( prv1stHigherPriorityNormallyFullTask, ( signed portCHAR * ) "H1QTx", configMINIMAL_STACK_SIZE, ( void * ) intqHIGH_PRIROITY_TASK1, intqHIGHER_PRIORITY, &xHighPriorityNormallyFullTask1 );
\r
214 xTaskCreate( prv2ndHigherPriorityNormallyFullTask, ( signed portCHAR * ) "H1QTx", configMINIMAL_STACK_SIZE, ( void * ) intqHIGH_PRIROITY_TASK2, intqHIGHER_PRIORITY, &xHighPriorityNormallyFullTask2 );
\r
215 xTaskCreate( prvLowerPriorityNormallyFullTask, ( signed portCHAR * ) "LQRx", configMINIMAL_STACK_SIZE, NULL, intqLOWER_PRIORITY, NULL );
\r
217 /* Create the queues that are accessed by multiple tasks and multiple
\r
219 xNormallyFullQueue = xQueueCreate( intqQUEUE_LENGTH, ( unsigned portBASE_TYPE ) sizeof( unsigned portBASE_TYPE ) );
\r
220 xNormallyEmptyQueue = xQueueCreate( intqQUEUE_LENGTH, ( unsigned portBASE_TYPE ) sizeof( unsigned portBASE_TYPE ) );
\r
222 /*-----------------------------------------------------------*/
\r
224 static void prvRecordValue_NormallyFull( unsigned portBASE_TYPE uxValue, unsigned portBASE_TYPE uxSource )
\r
226 if( uxValue < intqNUM_VALUES_TO_LOG )
\r
228 /* We don't expect to receive the same value twice, so if the value
\r
229 has already been marked as received an error has occurred. */
\r
230 if( ucNormallyFullReceivedValues[ uxValue ] != 0x00 )
\r
232 prvQueueAccessLogError( __LINE__ );
\r
235 /* Log that this value has been received. */
\r
236 ucNormallyFullReceivedValues[ uxValue ] = uxSource;
\r
239 /*-----------------------------------------------------------*/
\r
241 static void prvRecordValue_NormallyEmpty( unsigned portBASE_TYPE uxValue, unsigned portBASE_TYPE uxSource )
\r
243 if( uxValue < intqNUM_VALUES_TO_LOG )
\r
245 /* We don't expect to receive the same value twice, so if the value
\r
246 has already been marked as received an error has occurred. */
\r
247 if( ucNormallyEmptyReceivedValues[ uxValue ] != 0x00 )
\r
249 prvQueueAccessLogError( __LINE__ );
\r
252 /* Log that this value has been received. */
\r
253 ucNormallyEmptyReceivedValues[ uxValue ] = uxSource;
\r
256 /*-----------------------------------------------------------*/
\r
258 static void prvQueueAccessLogError( unsigned portBASE_TYPE uxLine )
\r
260 /* Latch the line number that caused the error. */
\r
261 xErrorLine = uxLine;
\r
262 xErrorStatus = pdFAIL;
\r
264 /*-----------------------------------------------------------*/
\r
266 static void prvHigherPriorityNormallyEmptyTask( void *pvParameters )
\r
268 unsigned portBASE_TYPE uxRxed, ux, uxTask1, uxTask2;
\r
270 /* The timer should not be started until after the scheduler has started.
\r
271 More than one task is running this code so we check the parameter value
\r
272 to determine which task should start the timer. */
\r
273 if( ( unsigned portBASE_TYPE ) pvParameters == intqHIGH_PRIROITY_TASK1 )
\r
275 vInitialiseTimerForIntQueueTest();
\r
280 /* Block waiting to receive a value from the normally empty queue.
\r
281 Interrupts will write to the queue so we should receive a value. */
\r
282 if( xQueueReceive( xNormallyEmptyQueue, &uxRxed, intqSHORT_DELAY ) != pdPASS )
\r
284 prvQueueAccessLogError( __LINE__ );
\r
288 /* Note which value was received so we can check all expected
\r
289 values are received and no values are duplicated. */
\r
290 prvRecordValue_NormallyEmpty( uxRxed, ( unsigned portBASE_TYPE ) pvParameters );
\r
293 /* Ensure the other task running this code gets a chance to execute. */
\r
296 if( ( unsigned portBASE_TYPE ) pvParameters == intqHIGH_PRIROITY_TASK1 )
\r
298 /* Have we received all the expected values? */
\r
299 if( uxValueForNormallyEmptyQueue > ( intqNUM_VALUES_TO_LOG + intqVALUE_OVERRUN ) )
\r
301 vTaskSuspend( xHighPriorityNormallyEmptyTask2 );
\r
306 /* Loop through the array, checking that both tasks have
\r
307 placed values into the array, and that no values are missing. */
\r
308 for( ux = 0; ux < intqNUM_VALUES_TO_LOG; ux++ )
\r
310 if( ucNormallyEmptyReceivedValues[ ux ] == 0 )
\r
312 /* A value is missing. */
\r
313 prvQueueAccessLogError( __LINE__ );
\r
317 if( ucNormallyEmptyReceivedValues[ ux ] == intqHIGH_PRIROITY_TASK1 )
\r
319 /* Value was placed into the array by task 1. */
\r
322 else if( ucNormallyEmptyReceivedValues[ ux ] == intqHIGH_PRIROITY_TASK2 )
\r
324 /* Value was placed into the array by task 2. */
\r
330 if( uxTask1 < intqMIN_ACCEPTABLE_TASK_COUNT )
\r
332 /* Only task 2 seemed to log any values. */
\r
333 prvQueueAccessLogError( __LINE__ );
\r
336 if( uxTask2 < intqMIN_ACCEPTABLE_TASK_COUNT )
\r
338 /* Only task 1 seemed to log any values. */
\r
339 prvQueueAccessLogError( __LINE__ );
\r
342 /* Clear the array again, ready to start a new cycle. */
\r
343 memset( ucNormallyEmptyReceivedValues, 0x00, sizeof( ucNormallyEmptyReceivedValues ) );
\r
345 uxHighPriorityLoops1++;
\r
346 uxValueForNormallyEmptyQueue = 0;
\r
348 /* Suspend ourselves, allowing the lower priority task to
\r
349 actually receive something from the queue. Until now it
\r
350 will have been prevented from doing so by the higher
\r
351 priority tasks. The lower priority task will resume us
\r
352 if it receives something. We will then resume the other
\r
353 higher priority task. */
\r
354 vTaskSuspend( NULL );
\r
355 vTaskResume( xHighPriorityNormallyEmptyTask2 );
\r
360 /*-----------------------------------------------------------*/
\r
362 static void prvLowerPriorityNormallyEmptyTask( void *pvParameters )
\r
364 unsigned portBASE_TYPE uxValue, uxRxed;
\r
365 portBASE_TYPE xQueueStatus;
\r
367 /* The parameters are not being used so avoid compiler warnings. */
\r
368 ( void ) pvParameters;
\r
372 if( ( xQueueStatus = xQueueReceive( xNormallyEmptyQueue, &uxRxed, intqONE_TICK_DELAY ) ) != errQUEUE_EMPTY )
\r
374 /* We should only obtain a value when the high priority task is
\r
376 if( xTaskIsTaskSuspended( xHighPriorityNormallyEmptyTask1 ) == pdFALSE )
\r
378 prvQueueAccessLogError( __LINE__ );
\r
381 prvRecordValue_NormallyEmpty( uxRxed, intqLOW_PRIROITY_TASK );
\r
383 /* Wake the higher priority task again. */
\r
384 vTaskResume( xHighPriorityNormallyEmptyTask1 );
\r
385 uxLowPriorityLoops1++;
\r
389 /* Raise our priority while we send so we can preempt the higher
\r
390 priority task, and ensure we get the Tx value into the queue. */
\r
391 vTaskPrioritySet( NULL, intqHIGHER_PRIORITY + 1 );
\r
393 portENTER_CRITICAL();
\r
395 uxValue = uxValueForNormallyEmptyQueue;
\r
396 uxValueForNormallyEmptyQueue++;
\r
398 portEXIT_CRITICAL();
\r
400 if( xQueueSend( xNormallyEmptyQueue, &uxValue, portMAX_DELAY ) != pdPASS )
\r
402 prvQueueAccessLogError( __LINE__ );
\r
405 vTaskPrioritySet( NULL, intqLOWER_PRIORITY );
\r
409 /*-----------------------------------------------------------*/
\r
411 static void prv1stHigherPriorityNormallyFullTask( void *pvParameters )
\r
413 unsigned portBASE_TYPE uxValueToTx, ux;
\r
414 portBASE_TYPE xQueueStatus;
\r
416 /* The parameters are not being used so avoid compiler warnings. */
\r
417 ( void ) pvParameters;
\r
419 /* Make sure the queue starts full or near full. >> 1 as there are two
\r
420 high priority tasks. */
\r
421 for( ux = 0; ux < ( intqQUEUE_LENGTH >> 1 ); ux++ )
\r
423 portENTER_CRITICAL();
\r
425 uxValueToTx = uxValueForNormallyFullQueue;
\r
426 uxValueForNormallyFullQueue++;
\r
428 portEXIT_CRITICAL();
\r
430 xQueueSend( xNormallyFullQueue, &uxValueToTx, intqSHORT_DELAY );
\r
435 portENTER_CRITICAL();
\r
437 uxValueToTx = uxValueForNormallyFullQueue;
\r
438 uxValueForNormallyFullQueue++;
\r
440 portEXIT_CRITICAL();
\r
442 if( ( xQueueStatus = xQueueSend( xNormallyFullQueue, &uxValueToTx, intqSHORT_DELAY ) ) != pdPASS )
\r
444 /* intqHIGH_PRIROITY_TASK2 is never suspended so we would not
\r
445 expect it to ever time out. */
\r
446 prvQueueAccessLogError( __LINE__ );
\r
449 /* Allow the other task running this code to run. */
\r
452 /* Have all the expected values been sent to the queue? */
\r
453 if( uxValueToTx > ( intqNUM_VALUES_TO_LOG + intqVALUE_OVERRUN ) )
\r
455 /* Make sure the other high priority task completes its send of
\r
456 any values below intqNUM_VALUE_TO_LOG. */
\r
457 vTaskDelay( intqSHORT_DELAY );
\r
459 vTaskSuspend( xHighPriorityNormallyFullTask2 );
\r
461 if( xWasSuspended == pdTRUE )
\r
463 /* We would have expected the other high priority task to have
\r
464 set this back to false by now. */
\r
465 prvQueueAccessLogError( __LINE__ );
\r
468 /* Set the suspended flag so an error is not logged if the other
\r
469 task recognises a time out when it is unsuspended. */
\r
470 xWasSuspended = pdTRUE;
\r
472 for( ux = 0; ux < intqNUM_VALUES_TO_LOG; ux++ )
\r
474 if( ucNormallyFullReceivedValues[ ux ] == 0 )
\r
476 /* A value was missing. */
\r
477 prvQueueAccessLogError( __LINE__ );
\r
481 /* Reset the array ready for the next cycle. */
\r
482 memset( ucNormallyFullReceivedValues, 0x00, sizeof( ucNormallyFullReceivedValues ) );
\r
484 uxHighPriorityLoops2++;
\r
485 uxValueForNormallyFullQueue = 0;
\r
487 /* Suspend ourselves, allowing the lower priority task to
\r
488 actually receive something from the queue. Until now it
\r
489 will have been prevented from doing so by the higher
\r
490 priority tasks. The lower priority task will resume us
\r
491 if it receives something. We will then resume the other
\r
492 higher priority task. */
\r
493 vTaskSuspend( NULL );
\r
494 vTaskResume( xHighPriorityNormallyFullTask2 );
\r
498 /*-----------------------------------------------------------*/
\r
500 static void prv2ndHigherPriorityNormallyFullTask( void *pvParameters )
\r
502 unsigned portBASE_TYPE uxValueToTx, ux;
\r
503 portBASE_TYPE xQueueStatus;
\r
505 /* The parameters are not being used so avoid compiler warnings. */
\r
506 ( void ) pvParameters;
\r
508 /* Make sure the queue starts full or near full. >> 1 as there are two
\r
509 high priority tasks. */
\r
510 for( ux = 0; ux < ( intqQUEUE_LENGTH >> 1 ); ux++ )
\r
512 portENTER_CRITICAL();
\r
514 uxValueToTx = uxValueForNormallyFullQueue;
\r
515 uxValueForNormallyFullQueue++;
\r
517 portEXIT_CRITICAL();
\r
519 xQueueSend( xNormallyFullQueue, &uxValueToTx, intqSHORT_DELAY );
\r
524 portENTER_CRITICAL();
\r
526 uxValueToTx = uxValueForNormallyFullQueue;
\r
527 uxValueForNormallyFullQueue++;
\r
529 portEXIT_CRITICAL();
\r
531 if( ( xQueueStatus = xQueueSend( xNormallyFullQueue, &uxValueToTx, intqSHORT_DELAY ) ) != pdPASS )
\r
533 if( xWasSuspended != pdTRUE )
\r
535 /* It is ok to time out if the task has been suspended. */
\r
536 prvQueueAccessLogError( __LINE__ );
\r
540 xWasSuspended = pdFALSE;
\r
545 /*-----------------------------------------------------------*/
\r
547 static void prvLowerPriorityNormallyFullTask( void *pvParameters )
\r
549 unsigned portBASE_TYPE uxValue, uxTxed = 9999;
\r
550 portBASE_TYPE xQueueStatus;
\r
552 /* The parameters are not being used so avoid compiler warnings. */
\r
553 ( void ) pvParameters;
\r
557 if( ( xQueueStatus = xQueueSend( xNormallyFullQueue, &uxTxed, intqONE_TICK_DELAY ) ) != errQUEUE_FULL )
\r
559 /* We would only expect to succeed when the higher priority task
\r
561 if( xTaskIsTaskSuspended( xHighPriorityNormallyFullTask1 ) == pdFALSE )
\r
563 prvQueueAccessLogError( __LINE__ );
\r
566 vTaskResume( xHighPriorityNormallyFullTask1 );
\r
567 uxLowPriorityLoops2++;
\r
571 /* Raise our priority while we receive so we can preempt the higher
\r
572 priority task, and ensure we get the value from the queue. */
\r
573 vTaskPrioritySet( NULL, intqHIGHER_PRIORITY + 1 );
\r
575 if( xQueueReceive( xNormallyFullQueue, &uxValue, portMAX_DELAY ) != pdPASS )
\r
577 prvQueueAccessLogError( __LINE__ );
\r
581 prvRecordValue_NormallyFull( uxValue, intqLOW_PRIROITY_TASK );
\r
584 vTaskPrioritySet( NULL, intqLOWER_PRIORITY );
\r
588 /*-----------------------------------------------------------*/
\r
590 portBASE_TYPE xFirstTimerHandler( void )
\r
592 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE, uxRxedValue;
\r
593 static unsigned portBASE_TYPE uxNextOperation = 0;
\r
595 /* Called from a timer interrupt. Perform various read and write
\r
596 accesses on the queues. */
\r
600 if( uxNextOperation & ( unsigned portBASE_TYPE ) 0x01 )
\r
602 timerNORMALLY_EMPTY_TX();
\r
603 timerNORMALLY_EMPTY_TX();
\r
604 timerNORMALLY_EMPTY_TX();
\r
608 timerNORMALLY_FULL_RX();
\r
609 timerNORMALLY_FULL_RX();
\r
610 timerNORMALLY_FULL_RX();
\r
613 return xHigherPriorityTaskWoken;
\r
615 /*-----------------------------------------------------------*/
\r
617 portBASE_TYPE xSecondTimerHandler( void )
\r
619 unsigned portBASE_TYPE uxRxedValue;
\r
620 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
\r
621 static unsigned portBASE_TYPE uxNextOperation = 0;
\r
623 /* Called from a timer interrupt. Perform various read and write
\r
624 accesses on the queues. */
\r
628 if( uxNextOperation & ( unsigned portBASE_TYPE ) 0x01 )
\r
630 timerNORMALLY_EMPTY_TX();
\r
631 timerNORMALLY_EMPTY_TX();
\r
633 timerNORMALLY_EMPTY_RX();
\r
634 timerNORMALLY_EMPTY_RX();
\r
638 timerNORMALLY_FULL_RX();
\r
639 timerNORMALLY_FULL_TX();
\r
640 timerNORMALLY_FULL_TX();
\r
641 timerNORMALLY_FULL_TX();
\r
642 timerNORMALLY_FULL_TX();
\r
645 return xHigherPriorityTaskWoken;
\r
647 /*-----------------------------------------------------------*/
\r
650 portBASE_TYPE xAreIntQueueTasksStillRunning( void )
\r
652 static unsigned portBASE_TYPE uxLastHighPriorityLoops1 = 0, uxLastHighPriorityLoops2 = 0, uxLastLowPriorityLoops1 = 0, uxLastLowPriorityLoops2 = 0;
\r
654 /* xErrorStatus can be set outside of this function. This function just
\r
655 checks that all the tasks are still cycling. */
\r
657 if( uxHighPriorityLoops1 == uxLastHighPriorityLoops1 )
\r
659 /* The high priority 1 task has stalled. */
\r
660 prvQueueAccessLogError( __LINE__ );
\r
663 uxLastHighPriorityLoops1 = uxHighPriorityLoops1;
\r
665 if( uxHighPriorityLoops2 == uxLastHighPriorityLoops2 )
\r
667 /* The high priority 2 task has stalled. */
\r
668 prvQueueAccessLogError( __LINE__ );
\r
671 uxLastHighPriorityLoops2 = uxHighPriorityLoops2;
\r
673 if( uxLowPriorityLoops1 == uxLastLowPriorityLoops1 )
\r
675 /* The low priority 1 task has stalled. */
\r
676 prvQueueAccessLogError( __LINE__ );
\r
679 uxLastLowPriorityLoops1 = uxLowPriorityLoops1;
\r
681 if( uxLowPriorityLoops2 == uxLastLowPriorityLoops2 )
\r
683 /* The low priority 2 task has stalled. */
\r
684 prvQueueAccessLogError( __LINE__ );
\r
687 uxLastLowPriorityLoops2 = uxLowPriorityLoops2;
\r
689 return xErrorStatus;
\r