2 FreeRTOS V8.2.0rc1 - Copyright (C) 2014 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 This file is part of the FreeRTOS distribution.
\r
9 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
10 the terms of the GNU General Public License (version 2) as published by the
\r
11 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
\r
13 >>! NOTE: The modification to the GPL is included to allow you to !<<
\r
14 >>! distribute a combined work that includes FreeRTOS without being !<<
\r
15 >>! obliged to provide the source code for proprietary components !<<
\r
16 >>! outside of the FreeRTOS kernel. !<<
\r
18 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
19 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
20 FOR A PARTICULAR PURPOSE. Full license text is available on the following
\r
21 link: http://www.freertos.org/a00114.html
\r
25 ***************************************************************************
\r
27 * Having a problem? Start by reading the FAQ "My application does *
\r
28 * not run, what could be wrong?". Have you defined configASSERT()? *
\r
30 * http://www.FreeRTOS.org/FAQHelp.html *
\r
32 ***************************************************************************
\r
34 ***************************************************************************
\r
36 * FreeRTOS provides completely free yet professionally developed, *
\r
37 * robust, strictly quality controlled, supported, and cross *
\r
38 * platform software that is more than just the market leader, it *
\r
39 * is the industry's de facto standard. *
\r
41 * Help yourself get started quickly while simultaneously helping *
\r
42 * to support the FreeRTOS project by purchasing a FreeRTOS *
\r
43 * tutorial book, reference manual, or both: *
\r
44 * http://www.FreeRTOS.org/Documentation *
\r
46 ***************************************************************************
\r
48 ***************************************************************************
\r
50 * Investing in training allows your team to be as productive as *
\r
51 * possible as early as possible, lowering your overall development *
\r
52 * cost, and enabling you to bring a more robust product to market *
\r
53 * earlier than would otherwise be possible. Richard Barry is both *
\r
54 * the architect and key author of FreeRTOS, and so also the world's *
\r
55 * leading authority on what is the world's most popular real time *
\r
56 * kernel for deeply embedded MCU designs. Obtaining your training *
\r
57 * from Richard ensures your team will gain directly from his in-depth *
\r
58 * product knowledge and years of usage experience. Contact Real Time *
\r
59 * Engineers Ltd to enquire about the FreeRTOS Masterclass, presented *
\r
60 * by Richard Barry: http://www.FreeRTOS.org/contact
\r
62 ***************************************************************************
\r
64 ***************************************************************************
\r
66 * You are receiving this top quality software for free. Please play *
\r
67 * fair and reciprocate by reporting any suspected issues and *
\r
68 * participating in the community forum: *
\r
69 * http://www.FreeRTOS.org/support *
\r
73 ***************************************************************************
\r
75 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
\r
76 license and Real Time Engineers Ltd. contact details.
\r
78 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
79 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
80 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
82 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
\r
83 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
\r
85 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
\r
86 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
87 licenses offer ticketed support, indemnification and commercial middleware.
\r
89 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
90 engineered and independently SIL3 certified version for use in safety and
\r
91 mission critical applications that require provable dependability.
\r
97 *******************************************************************************
\r
98 * NOTE 1: The Win32 port is a simulation (or is that emulation?) only! Do not
\r
99 * expect to get real time behaviour from the Win32 port or this demo
\r
100 * application. It is provided as a convenient development and demonstration
\r
101 * test bed only. This was tested using Windows XP on a dual core laptop.
\r
103 * Windows will not be running the FreeRTOS simulator threads continuously, so
\r
104 * the timing information in the FreeRTOS+Trace logs have no meaningful units.
\r
105 * See the documentation page for the Windows simulator for an explanation of
\r
107 * http://www.freertos.org/FreeRTOS-Windows-Simulator-Emulator-for-Visual-Studio-and-Eclipse-MingW.html
\r
108 * - READ THE WEB DOCUMENTATION FOR THIS PORT FOR MORE INFORMATION ON USING IT -
\r
110 * NOTE 2: This project provides two demo applications. A simple blinky style
\r
111 * project, and a more comprehensive test and demo application. The
\r
112 * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select
\r
113 * between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY
\r
114 * in main.c. This file implements the comprehensive test and demo version.
\r
116 * NOTE 3: This file only contains the source code that is specific to the
\r
117 * basic demo. Generic functions, such FreeRTOS hook functions, are defined in
\r
119 *******************************************************************************
\r
121 * main() creates all the demo application tasks, then starts the scheduler.
\r
122 * The web documentation provides more details of the standard demo application
\r
123 * tasks, which provide no particular functionality but do provide a good
\r
124 * example of how to use the FreeRTOS API.
\r
126 * In addition to the standard demo tasks, the following tasks and tests are
\r
127 * defined and/or created within this file:
\r
129 * "Check" task - This only executes every five seconds but has a high priority
\r
130 * to ensure it gets processor time. Its main function is to check that all the
\r
131 * standard demo tasks are still operational. While no errors have been
\r
132 * discovered the check task will print out "OK" and the current simulated tick
\r
133 * time. If an error is discovered in the execution of a task then the check
\r
134 * task will print out an appropriate error message.
\r
139 /* Standard includes. */
\r
141 #include <stdlib.h>
\r
143 /* Kernel includes. */
\r
144 #include <FreeRTOS.h>
\r
147 #include <timers.h>
\r
148 #include <semphr.h>
\r
150 /* Standard demo includes. */
\r
151 #include "BlockQ.h"
\r
152 #include "integer.h"
\r
153 #include "semtest.h"
\r
155 #include "GenQTest.h"
\r
157 #include "recmutex.h"
\r
159 #include "TimerDemo.h"
\r
160 #include "countsem.h"
\r
162 #include "dynamic.h"
\r
163 #include "QueueSet.h"
\r
164 #include "QueueOverwrite.h"
\r
165 #include "EventGroupsDemo.h"
\r
166 #include "IntSemTest.h"
\r
167 #include "TaskNotify.h"
\r
169 /* Priorities at which the tasks are created. */
\r
170 #define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
\r
171 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
172 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
173 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
174 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
175 #define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
176 #define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
177 #define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
178 #define mainFLOP_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
179 #define mainQUEUE_OVERWRITE_PRIORITY ( tskIDLE_PRIORITY )
\r
181 #define mainTIMER_TEST_PERIOD ( 50 )
\r
183 /* Task function prototypes. */
\r
184 static void prvCheckTask( void *pvParameters );
\r
186 /* A task that is created from the idle task to test the functionality of
\r
187 eTaskStateGet(). */
\r
188 static void prvTestTask( void *pvParameters );
\r
191 * Called from the idle task hook function to demonstrate a few utility
\r
192 * functions that are not demonstrated by any of the standard demo tasks.
\r
194 static void prvDemonstrateTaskStateAndHandleGetFunctions( void );
\r
197 * Called from the idle task hook function to demonstrate the use of
\r
198 * xTimerPendFunctionCall() as xTimerPendFunctionCall() is not demonstrated by
\r
199 * any of the standard demo tasks.
\r
201 static void prvDemonstratePendingFunctionCall( void );
\r
204 * The function that is pended by prvDemonstratePendingFunctionCall().
\r
206 static void prvPendedFunction( void *pvParameter1, uint32_t ulParameter2 );
\r
209 * A task to demonstrate the use of the xQueueSpacesAvailable() function.
\r
211 static void prvDemoQueueSpaceFunctions( void *pvParameters );
\r
213 /*-----------------------------------------------------------*/
\r
215 /* The variable into which error messages are latched. */
\r
216 static char *pcStatusMessage = "OK";
\r
218 /* This semaphore is created purely to test using the vSemaphoreDelete() and
\r
219 semaphore tracing API functions. It has no other purpose. */
\r
220 static SemaphoreHandle_t xMutexToDelete = NULL;
\r
222 /*-----------------------------------------------------------*/
\r
224 int main_full( void )
\r
226 /* Start the check task as described at the top of this file. */
\r
227 xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
229 /* Create the standard demo tasks. */
\r
230 vStartTaskNotifyTask();
\r
231 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
232 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
233 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
234 vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
\r
235 vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
\r
236 vStartQueuePeekTasks();
\r
237 vStartMathTasks( mainFLOP_TASK_PRIORITY );
\r
238 vStartRecursiveMutexTasks();
\r
239 vStartCountingSemaphoreTasks();
\r
240 vStartDynamicPriorityTasks();
\r
241 vStartQueueSetTasks();
\r
242 vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );
\r
243 xTaskCreate( prvDemoQueueSpaceFunctions, "QSpace", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
\r
244 vStartEventGroupTasks();
\r
245 vStartInterruptSemaphoreTasks();
\r
247 #if( configUSE_PREEMPTION != 0 )
\r
249 /* Don't expect these tasks to pass when preemption is not used. */
\r
250 vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
\r
254 /* The suicide tasks must be created last as they need to know how many
\r
255 tasks were running prior to their creation. This then allows them to
\r
256 ascertain whether or not the correct/expected number of tasks are running at
\r
258 vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
\r
260 /* Create the semaphore that will be deleted in the idle task hook. This
\r
261 is done purely to test the use of vSemaphoreDelete(). */
\r
262 xMutexToDelete = xSemaphoreCreateMutex();
\r
264 /* Start the scheduler itself. */
\r
265 vTaskStartScheduler();
\r
267 /* Should never get here unless there was not enough heap space to create
\r
268 the idle and other system tasks. */
\r
271 /*-----------------------------------------------------------*/
\r
273 static void prvCheckTask( void *pvParameters )
\r
275 TickType_t xNextWakeTime;
\r
276 const TickType_t xCycleFrequency = 2500 / portTICK_PERIOD_MS;
\r
278 /* Just to remove compiler warning. */
\r
279 ( void ) pvParameters;
\r
281 /* Initialise xNextWakeTime - this only needs to be done once. */
\r
282 xNextWakeTime = xTaskGetTickCount();
\r
286 /* Place this task in the blocked state until it is time to run again. */
\r
287 vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );
\r
289 /* Check the standard demo tasks are running without error. */
\r
290 #if( configUSE_PREEMPTION != 0 )
\r
292 /* These tasks are only created when preemption is used. */
\r
293 if( xAreTimerDemoTasksStillRunning( xCycleFrequency ) != pdTRUE )
\r
295 pcStatusMessage = "Error: TimerDemo";
\r
300 if( xAreTaskNotificationTasksStillRunning() != pdTRUE )
\r
302 pcStatusMessage = "Error: Notification";
\r
305 if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )
\r
307 pcStatusMessage = "Error: IntSem";
\r
309 else if( xAreEventGroupTasksStillRunning() != pdTRUE )
\r
311 pcStatusMessage = "Error: EventGroup";
\r
313 else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
315 pcStatusMessage = "Error: IntMath";
\r
317 else if( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
319 pcStatusMessage = "Error: GenQueue";
\r
321 else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
\r
323 pcStatusMessage = "Error: QueuePeek";
\r
325 else if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
327 pcStatusMessage = "Error: BlockQueue";
\r
329 else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
331 pcStatusMessage = "Error: SemTest";
\r
333 else if( xArePollingQueuesStillRunning() != pdTRUE )
\r
335 pcStatusMessage = "Error: PollQueue";
\r
337 else if( xAreMathsTaskStillRunning() != pdPASS )
\r
339 pcStatusMessage = "Error: Flop";
\r
341 else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
\r
343 pcStatusMessage = "Error: RecMutex";
\r
345 else if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )
\r
347 pcStatusMessage = "Error: CountSem";
\r
349 else if( xIsCreateTaskStillRunning() != pdTRUE )
\r
351 pcStatusMessage = "Error: Death";
\r
353 else if( xAreDynamicPriorityTasksStillRunning() != pdPASS )
\r
355 pcStatusMessage = "Error: Dynamic";
\r
357 else if( xAreQueueSetTasksStillRunning() != pdPASS )
\r
359 pcStatusMessage = "Error: Queue set";
\r
361 else if( xIsQueueOverwriteTaskStillRunning() != pdPASS )
\r
363 pcStatusMessage = "Error: Queue overwrite";
\r
366 /* This is the only task that uses stdout so its ok to call printf()
\r
368 printf( "%s - %d\r\n", pcStatusMessage, xTaskGetTickCount() );
\r
371 /*-----------------------------------------------------------*/
\r
373 static void prvTestTask( void *pvParameters )
\r
375 const unsigned long ulMSToSleep = 5;
\r
377 /* Just to remove compiler warnings. */
\r
378 ( void ) pvParameters;
\r
380 /* This task is just used to test the eTaskStateGet() function. It
\r
381 does not have anything to do. */
\r
384 /* Sleep to reduce CPU load, but don't sleep indefinitely in case there are
\r
385 tasks waiting to be terminated by the idle task. */
\r
386 Sleep( ulMSToSleep );
\r
389 /*-----------------------------------------------------------*/
\r
391 /* Called from vApplicationIdleHook(), which is defined in main.c. */
\r
392 void vFullDemoIdleFunction( void )
\r
394 const unsigned long ulMSToSleep = 15;
\r
397 /* Sleep to reduce CPU load, but don't sleep indefinitely in case there are
\r
398 tasks waiting to be terminated by the idle task. */
\r
399 Sleep( ulMSToSleep );
\r
401 /* Demonstrate a few utility functions that are not demonstrated by any of
\r
402 the standard demo tasks. */
\r
403 prvDemonstrateTaskStateAndHandleGetFunctions();
\r
405 /* Demonstrate the use of xTimerPendFunctionCall(), which is not
\r
406 demonstrated by any of the standard demo tasks. */
\r
407 prvDemonstratePendingFunctionCall();
\r
409 /* If xMutexToDelete has not already been deleted, then delete it now.
\r
410 This is done purely to demonstrate the use of, and test, the
\r
411 vSemaphoreDelete() macro. Care must be taken not to delete a semaphore
\r
412 that has tasks blocked on it. */
\r
413 if( xMutexToDelete != NULL )
\r
415 vSemaphoreDelete( xMutexToDelete );
\r
416 xMutexToDelete = NULL;
\r
419 /* Exercise heap_5 a bit. The malloc failed hook will trap failed
\r
420 allocations so there is no need to test here. */
\r
421 pvAllocated = pvPortMalloc( ( rand() % 100 ) + 1 );
\r
422 vPortFree( pvAllocated );
\r
424 /*-----------------------------------------------------------*/
\r
426 /* Called by vApplicationTickHook(), which is defined in main.c. */
\r
427 void vFullDemoTickHookFunction( void )
\r
429 TaskHandle_t xTimerTask;
\r
431 /* Call the periodic timer test, which tests the timer API functions that
\r
432 can be called from an ISR. */
\r
433 #if( configUSE_PREEMPTION != 0 )
\r
435 /* Only created when preemption is used. */
\r
436 vTimerPeriodicISRTests();
\r
440 /* Call the periodic queue overwrite from ISR demo. */
\r
441 vQueueOverwritePeriodicISRDemo();
\r
443 /* Write to a queue that is in use as part of the queue set demo to
\r
444 demonstrate using queue sets from an ISR. */
\r
445 vQueueSetAccessQueueSetFromISR();
\r
447 /* Exercise event groups from interrupts. */
\r
448 vPeriodicEventGroupsProcessing();
\r
450 /* Exercise giving mutexes from an interrupt. */
\r
451 vInterruptSemaphorePeriodicTest();
\r
453 /* Exercise using task notifications from an interrupt. */
\r
454 xNotifyTaskFromISR();
\r
456 /* For code coverage purposes. */
\r
457 xTimerTask = xTimerGetTimerDaemonTaskHandle();
\r
458 configASSERT( uxTaskPriorityGetFromISR( xTimerTask ) == configTIMER_TASK_PRIORITY );
\r
460 /*-----------------------------------------------------------*/
\r
462 static void prvPendedFunction( void *pvParameter1, uint32_t ulParameter2 )
\r
464 static uint32_t ulLastParameter1 = 1000UL, ulLastParameter2 = 0UL;
\r
465 uint32_t ulParameter1;
\r
467 ulParameter1 = ( uint32_t ) pvParameter1;
\r
469 /* Ensure the parameters are as expected. */
\r
470 configASSERT( ulParameter1 == ( ulLastParameter1 + 1 ) );
\r
471 configASSERT( ulParameter2 == ( ulLastParameter2 + 1 ) );
\r
473 /* Remember the parameters for the next time the function is called. */
\r
474 ulLastParameter1 = ulParameter1;
\r
475 ulLastParameter2 = ulParameter2;
\r
477 /*-----------------------------------------------------------*/
\r
479 static void prvDemonstratePendingFunctionCall( void )
\r
481 static uint32_t ulParameter1 = 1000UL, ulParameter2 = 0UL;
\r
482 const TickType_t xDontBlock = 0; /* This is called from the idle task so must *not* attempt to block. */
\r
484 /* prvPendedFunction() just expects the parameters to be incremented by one
\r
485 each time it is called. */
\r
489 /* Pend the function call, sending the parameters. */
\r
490 xTimerPendFunctionCall( prvPendedFunction, ( void * ) ulParameter1, ulParameter2, xDontBlock );
\r
492 /*-----------------------------------------------------------*/
\r
494 static void prvDemonstrateTaskStateAndHandleGetFunctions( void )
\r
496 TaskHandle_t xIdleTaskHandle, xTimerTaskHandle;
\r
498 static portBASE_TYPE xPerformedOneShotTests = pdFALSE;
\r
499 TaskHandle_t xTestTask;
\r
501 /* Demonstrate the use of the xTimerGetTimerDaemonTaskHandle() and
\r
502 xTaskGetIdleTaskHandle() functions. Also try using the function that sets
\r
503 the task number. */
\r
504 xIdleTaskHandle = xTaskGetIdleTaskHandle();
\r
505 xTimerTaskHandle = xTimerGetTimerDaemonTaskHandle();
\r
507 /* This is the idle hook, so the current task handle should equal the
\r
508 returned idle task handle. */
\r
509 if( xTaskGetCurrentTaskHandle() != xIdleTaskHandle )
\r
511 pcStatusMessage = "Error: Returned idle task handle was incorrect";
\r
514 /* Check the timer task handle was returned correctly. */
\r
515 pcTaskName = pcTaskGetTaskName( xTimerTaskHandle );
\r
516 if( strcmp( pcTaskName, "Tmr Svc" ) != 0 )
\r
518 pcStatusMessage = "Error: Returned timer task handle was incorrect";
\r
521 /* This task is running, make sure it's state is returned as running. */
\r
522 if( eTaskStateGet( xIdleTaskHandle ) != eRunning )
\r
524 pcStatusMessage = "Error: Returned idle task state was incorrect";
\r
527 /* If this task is running, then the timer task must be blocked. */
\r
528 if( eTaskStateGet( xTimerTaskHandle ) != eBlocked )
\r
530 pcStatusMessage = "Error: Returned timer task state was incorrect";
\r
533 /* Other tests that should only be performed once follow. The test task
\r
534 is not created on each iteration because to do so would cause the death
\r
535 task to report an error (too many tasks running). */
\r
536 if( xPerformedOneShotTests == pdFALSE )
\r
538 /* Don't run this part of the test again. */
\r
539 xPerformedOneShotTests = pdTRUE;
\r
541 /* Create a test task to use to test other eTaskStateGet() return values. */
\r
542 if( xTaskCreate( prvTestTask, "Test", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, &xTestTask ) == pdPASS )
\r
544 /* If this task is running, the test task must be in the ready state. */
\r
545 if( eTaskStateGet( xTestTask ) != eReady )
\r
547 pcStatusMessage = "Error: Returned test task state was incorrect 1";
\r
550 /* Now suspend the test task and check its state is reported correctly. */
\r
551 vTaskSuspend( xTestTask );
\r
552 if( eTaskStateGet( xTestTask ) != eSuspended )
\r
554 pcStatusMessage = "Error: Returned test task state was incorrect 2";
\r
557 /* Now delete the task and check its state is reported correctly. */
\r
558 vTaskDelete( xTestTask );
\r
559 if( eTaskStateGet( xTestTask ) != eDeleted )
\r
561 pcStatusMessage = "Error: Returned test task state was incorrect 3";
\r
566 /*-----------------------------------------------------------*/
\r
568 static void prvDemoQueueSpaceFunctions( void *pvParameters )
\r
570 QueueHandle_t xQueue = NULL;
\r
571 const unsigned portBASE_TYPE uxQueueLength = 10;
\r
572 unsigned portBASE_TYPE uxReturn, x;
\r
574 /* Remove compiler warnings. */
\r
575 ( void ) pvParameters;
\r
577 /* Create the queue that will be used. Nothing is actually going to be
\r
578 sent or received so the queue item size is set to 0. */
\r
579 xQueue = xQueueCreate( uxQueueLength, 0 );
\r
580 configASSERT( xQueue );
\r
584 for( x = 0; x < uxQueueLength; x++ )
\r
586 /* Ask how many messages are available... */
\r
587 uxReturn = uxQueueMessagesWaiting( xQueue );
\r
589 /* Check the number of messages being reported as being available
\r
590 is as expected, and force an assert if not. */
\r
591 if( uxReturn != x )
\r
593 /* xQueue cannot be NULL so this is deliberately causing an
\r
594 assert to be triggered as there is an error. */
\r
595 configASSERT( xQueue == NULL );
\r
598 /* Ask how many spaces remain in the queue... */
\r
599 uxReturn = uxQueueSpacesAvailable( xQueue );
\r
601 /* Check the number of spaces being reported as being available
\r
602 is as expected, and force an assert if not. */
\r
603 if( uxReturn != ( uxQueueLength - x ) )
\r
605 /* xQueue cannot be NULL so this is deliberately causing an
\r
606 assert to be triggered as there is an error. */
\r
607 configASSERT( xQueue == NULL );
\r
610 /* Fill one more space in the queue. */
\r
611 xQueueSendToBack( xQueue, NULL, 0 );
\r
614 /* Perform the same check while the queue is full. */
\r
615 uxReturn = uxQueueMessagesWaiting( xQueue );
\r
616 if( uxReturn != uxQueueLength )
\r
618 configASSERT( xQueue == NULL );
\r
621 uxReturn = uxQueueSpacesAvailable( xQueue );
\r
623 if( uxReturn != 0 )
\r
625 configASSERT( xQueue == NULL );
\r
628 /* The queue is full, start again. */
\r
629 xQueueReset( xQueue );
\r
631 #if( configUSE_PREEMPTION == 0 )
\r