]> begriffs open source - cmsis-freertos/blob - Demo/WIN32-MingW/main_full.c
Update cmsis_os2.c
[cmsis-freertos] / Demo / WIN32-MingW / main_full.c
1 /*
2     FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
3     All rights reserved
4
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
6
7     This file is part of the FreeRTOS distribution.
8
9     FreeRTOS is free software; you can redistribute it and/or modify it under
10     the terms of the GNU General Public License (version 2) as published by the
11     Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
12
13     ***************************************************************************
14     >>!   NOTE: The modification to the GPL is included to allow you to     !<<
15     >>!   distribute a combined work that includes FreeRTOS without being   !<<
16     >>!   obliged to provide the source code for proprietary components     !<<
17     >>!   outside of the FreeRTOS kernel.                                   !<<
18     ***************************************************************************
19
20     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
21     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22     FOR A PARTICULAR PURPOSE.  Full license text is available on the following
23     link: http://www.freertos.org/a00114.html
24
25     ***************************************************************************
26      *                                                                       *
27      *    FreeRTOS provides completely free yet professionally developed,    *
28      *    robust, strictly quality controlled, supported, and cross          *
29      *    platform software that is more than just the market leader, it     *
30      *    is the industry's de facto standard.                               *
31      *                                                                       *
32      *    Help yourself get started quickly while simultaneously helping     *
33      *    to support the FreeRTOS project by purchasing a FreeRTOS           *
34      *    tutorial book, reference manual, or both:                          *
35      *    http://www.FreeRTOS.org/Documentation                              *
36      *                                                                       *
37     ***************************************************************************
38
39     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading
40     the FAQ page "My application does not run, what could be wrong?".  Have you
41     defined configASSERT()?
42
43     http://www.FreeRTOS.org/support - In return for receiving this top quality
44     embedded software for free we request you assist our global community by
45     participating in the support forum.
46
47     http://www.FreeRTOS.org/training - Investing in training allows your team to
48     be as productive as possible as early as possible.  Now you can receive
49     FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
50     Ltd, and the world's leading authority on the world's leading RTOS.
51
52     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
53     including FreeRTOS+Trace - an indispensable productivity tool, a DOS
54     compatible FAT file system, and our tiny thread aware UDP/IP stack.
55
56     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
57     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
58
59     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
60     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS
61     licenses offer ticketed support, indemnification and commercial middleware.
62
63     http://www.SafeRTOS.com - High Integrity Systems also provide a safety
64     engineered and independently SIL3 certified version for use in safety and
65     mission critical applications that require provable dependability.
66
67     1 tab == 4 spaces!
68 */
69
70 /*
71  *******************************************************************************
72  * NOTE 1: The Win32 port is a simulation (or is that emulation?) only!  Do not
73  * expect to get real time behaviour from the Win32 port or this demo
74  * application.  It is provided as a convenient development and demonstration
75  * test bed only.  This was tested using Windows XP on a dual core laptop.
76  *
77  * Windows will not be running the FreeRTOS simulator threads continuously, so
78  * the timing information in the FreeRTOS+Trace logs have no meaningful units.
79  * See the documentation page for the Windows simulator for an explanation of
80  * the slow timing:
81  * http://www.freertos.org/FreeRTOS-Windows-Simulator-Emulator-for-Visual-Studio-and-Eclipse-MingW.html
82  * - READ THE WEB DOCUMENTATION FOR THIS PORT FOR MORE INFORMATION ON USING IT -
83  *
84  * NOTE 2:  This project provides two demo applications.  A simple blinky style
85  * project, and a more comprehensive test and demo application.  The
86  * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select
87  * between the two.  See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY
88  * in main.c.  This file implements the comprehensive test and demo version.
89  *
90  * NOTE 3:  This file only contains the source code that is specific to the
91  * basic demo.  Generic functions, such FreeRTOS hook functions, are defined in
92  * main.c.
93  *******************************************************************************
94  *
95  * main() creates all the demo application tasks, then starts the scheduler.
96  * The web documentation provides more details of the standard demo application
97  * tasks, which provide no particular functionality but do provide a good
98  * example of how to use the FreeRTOS API.
99  *
100  * In addition to the standard demo tasks, the following tasks and tests are
101  * defined and/or created within this file:
102  *
103  * "Check" task - This only executes every five seconds but has a high priority
104  * to ensure it gets processor time.  Its main function is to check that all the
105  * standard demo tasks are still operational.  While no errors have been
106  * discovered the check task will print out "OK" and the current simulated tick
107  * time.  If an error is discovered in the execution of a task then the check
108  * task will print out an appropriate error message.
109  *
110  */
111
112
113 /* Standard includes. */
114 #include <stdio.h>
115 #include <stdlib.h>
116
117 /* Kernel includes. */
118 #include <FreeRTOS.h>
119 #include "task.h"
120 #include "queue.h"
121 #include "timers.h"
122 #include "semphr.h"
123
124 /* Standard demo includes. */
125 #include "BlockQ.h"
126 #include "integer.h"
127 #include "semtest.h"
128 #include "PollQ.h"
129 #include "GenQTest.h"
130 #include "QPeek.h"
131 #include "recmutex.h"
132 #include "flop.h"
133 #include "TimerDemo.h"
134 #include "countsem.h"
135 #include "death.h"
136 #include "dynamic.h"
137 #include "QueueSet.h"
138 #include "QueueOverwrite.h"
139 #include "EventGroupsDemo.h"
140 #include "IntSemTest.h"
141 #include "TaskNotify.h"
142 #include "QueueSetPolling.h"
143 #include "blocktim.h"
144 #include "AbortDelay.h"
145
146 /* Priorities at which the tasks are created. */
147 #define mainCHECK_TASK_PRIORITY                 ( configMAX_PRIORITIES - 2 )
148 #define mainQUEUE_POLL_PRIORITY                 ( tskIDLE_PRIORITY + 1 )
149 #define mainSEM_TEST_PRIORITY                   ( tskIDLE_PRIORITY + 1 )
150 #define mainBLOCK_Q_PRIORITY                    ( tskIDLE_PRIORITY + 2 )
151 #define mainCREATOR_TASK_PRIORITY               ( tskIDLE_PRIORITY + 3 )
152 #define mainFLASH_TASK_PRIORITY                 ( tskIDLE_PRIORITY + 1 )
153 #define mainINTEGER_TASK_PRIORITY               ( tskIDLE_PRIORITY )
154 #define mainGEN_QUEUE_TASK_PRIORITY             ( tskIDLE_PRIORITY )
155 #define mainFLOP_TASK_PRIORITY                  ( tskIDLE_PRIORITY )
156 #define mainQUEUE_OVERWRITE_PRIORITY    ( tskIDLE_PRIORITY )
157
158 #define mainTIMER_TEST_PERIOD                   ( 50 )
159
160 /* Task function prototypes. */
161 static void prvCheckTask( void *pvParameters );
162
163 /* A task that is created from the idle task to test the functionality of
164 eTaskStateGet(). */
165 static void prvTestTask( void *pvParameters );
166
167 /*
168  * Called from the idle task hook function to demonstrate a few utility
169  * functions that are not demonstrated by any of the standard demo tasks.
170  */
171 static void prvDemonstrateTaskStateAndHandleGetFunctions( void );
172
173 /*
174  * Called from the idle task hook function to demonstrate the use of
175  * xTimerPendFunctionCall() as xTimerPendFunctionCall() is not demonstrated by
176  * any of the standard demo tasks.
177  */
178 static void prvDemonstratePendingFunctionCall( void );
179
180 /*
181  * The function that is pended by prvDemonstratePendingFunctionCall().
182  */
183 static void prvPendedFunction( void *pvParameter1, uint32_t ulParameter2 );
184
185 /*
186  * A task to demonstrate the use of the xQueueSpacesAvailable() function.
187  */
188 static void prvDemoQueueSpaceFunctions( void *pvParameters );
189
190 /*-----------------------------------------------------------*/
191
192 /* The variable into which error messages are latched. */
193 static char *pcStatusMessage = "OK";
194
195 /* This semaphore is created purely to test using the vSemaphoreDelete() and
196 semaphore tracing API functions.  It has no other purpose. */
197 static SemaphoreHandle_t xMutexToDelete = NULL;
198
199 /*-----------------------------------------------------------*/
200
201 int main_full( void )
202 {
203         /* Start the check task as described at the top of this file. */
204         xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
205
206         /* Create the standard demo tasks. */
207         vStartTaskNotifyTask();
208         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
209         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
210         vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
211         vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
212         vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
213         vStartQueuePeekTasks();
214         vStartMathTasks( mainFLOP_TASK_PRIORITY );
215         vStartRecursiveMutexTasks();
216         vStartCountingSemaphoreTasks();
217         vStartDynamicPriorityTasks();
218         vStartQueueSetTasks();
219         vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );
220         xTaskCreate( prvDemoQueueSpaceFunctions, "QSpace", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
221         vStartEventGroupTasks();
222         vStartInterruptSemaphoreTasks();
223         vStartQueueSetPollingTask();
224         vCreateBlockTimeTasks();
225         vCreateAbortDelayTasks();
226
227         #if( configUSE_PREEMPTION != 0  )
228         {
229                 /* Don't expect these tasks to pass when preemption is not used. */
230                 vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
231         }
232         #endif
233
234         /* The suicide tasks must be created last as they need to know how many
235         tasks were running prior to their creation.  This then allows them to
236         ascertain whether or not the correct/expected number of tasks are running at
237         any given time. */
238         vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
239
240         /* Create the semaphore that will be deleted in the idle task hook.  This
241         is done purely to test the use of vSemaphoreDelete(). */
242         xMutexToDelete = xSemaphoreCreateMutex();
243
244         /* Start the scheduler itself. */
245         vTaskStartScheduler();
246
247         /* Should never get here unless there was not enough heap space to create
248         the idle and other system tasks. */
249         return 0;
250 }
251 /*-----------------------------------------------------------*/
252
253 static void prvCheckTask( void *pvParameters )
254 {
255 TickType_t xNextWakeTime;
256 const TickType_t xCycleFrequency = pdMS_TO_TICKS( 2500UL );
257
258         /* Just to remove compiler warning. */
259         ( void ) pvParameters;
260
261         /* Initialise xNextWakeTime - this only needs to be done once. */
262         xNextWakeTime = xTaskGetTickCount();
263
264         for( ;; )
265         {
266                 /* Place this task in the blocked state until it is time to run again. */
267                 vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );
268
269                 /* Check the standard demo tasks are running without error. */
270                 #if( configUSE_PREEMPTION != 0 )
271                 {
272                         /* These tasks are only created when preemption is used. */
273                         if( xAreTimerDemoTasksStillRunning( xCycleFrequency ) != pdTRUE )
274                         {
275                                 pcStatusMessage = "Error: TimerDemo";
276                         }
277                 }
278                 #endif
279
280                 if( xAreTaskNotificationTasksStillRunning() != pdTRUE )
281                 {
282                         pcStatusMessage = "Error:  Notification";
283                 }
284
285                 if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )
286                 {
287                         pcStatusMessage = "Error: IntSem";
288                 }
289                 else if( xAreEventGroupTasksStillRunning() != pdTRUE )
290                 {
291                         pcStatusMessage = "Error: EventGroup";
292                 }
293             else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
294             {
295                         pcStatusMessage = "Error: IntMath";
296             }
297                 else if( xAreGenericQueueTasksStillRunning() != pdTRUE )
298                 {
299                         pcStatusMessage = "Error: GenQueue";
300                 }
301                 else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
302                 {
303                         pcStatusMessage = "Error: QueuePeek";
304                 }
305                 else if( xAreBlockingQueuesStillRunning() != pdTRUE )
306                 {
307                         pcStatusMessage = "Error: BlockQueue";
308                 }
309             else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
310             {
311                         pcStatusMessage = "Error: SemTest";
312             }
313             else if( xArePollingQueuesStillRunning() != pdTRUE )
314             {
315                         pcStatusMessage = "Error: PollQueue";
316             }
317                 else if( xAreMathsTaskStillRunning() != pdPASS )
318                 {
319                         pcStatusMessage = "Error: Flop";
320                 }
321             else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
322             {
323                         pcStatusMessage = "Error: RecMutex";
324                 }
325                 else if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )
326                 {
327                         pcStatusMessage = "Error: CountSem";
328                 }
329                 else if( xIsCreateTaskStillRunning() != pdTRUE )
330                 {
331                         pcStatusMessage = "Error: Death";
332                 }
333                 else if( xAreDynamicPriorityTasksStillRunning() != pdPASS )
334                 {
335                         pcStatusMessage = "Error: Dynamic";
336                 }
337                 else if( xAreQueueSetTasksStillRunning() != pdPASS )
338                 {
339                         pcStatusMessage = "Error: Queue set";
340                 }
341                 else if( xIsQueueOverwriteTaskStillRunning() != pdPASS )
342                 {
343                         pcStatusMessage = "Error: Queue overwrite";
344                 }
345                 else if( xAreQueueSetPollTasksStillRunning() != pdPASS )
346                 {
347                         pcStatusMessage = "Error: Queue set polling";
348                 }
349                 else if( xAreBlockTimeTestTasksStillRunning() != pdPASS )
350                 {
351                         pcStatusMessage = "Error: Block time";
352                 }
353                 else if( xAreAbortDelayTestTasksStillRunning() != pdPASS )
354                 {
355                         pcStatusMessage = "Error: Abort delay";
356                 }
357
358                 /* This is the only task that uses stdout so its ok to call printf()
359                 directly. */
360                 printf( ( char * ) "%s - %u\r\n", pcStatusMessage, ( unsigned int ) xTaskGetTickCount() );
361                 fflush( stdout );
362         }
363 }
364 /*-----------------------------------------------------------*/
365
366 static void prvTestTask( void *pvParameters )
367 {
368 const unsigned long ulMSToSleep = 5;
369
370         /* Just to remove compiler warnings. */
371         ( void ) pvParameters;
372
373         /* This task is just used to test the eTaskStateGet() function.  It
374         does not have anything to do. */
375         for( ;; )
376         {
377                 /* Sleep to reduce CPU load, but don't sleep indefinitely in case there are
378                 tasks waiting to be terminated by the idle task. */
379                 Sleep( ulMSToSleep );
380         }
381 }
382 /*-----------------------------------------------------------*/
383
384 /* Called from vApplicationIdleHook(), which is defined in main.c. */
385 void vFullDemoIdleFunction( void )
386 {
387 const unsigned long ulMSToSleep = 15;
388 void *pvAllocated;
389
390         /* Sleep to reduce CPU load, but don't sleep indefinitely in case there are
391         tasks waiting to be terminated by the idle task. */
392         Sleep( ulMSToSleep );
393
394         /* Demonstrate a few utility functions that are not demonstrated by any of
395         the standard demo tasks. */
396         prvDemonstrateTaskStateAndHandleGetFunctions();
397
398         /* Demonstrate the use of xTimerPendFunctionCall(), which is not
399         demonstrated by any of the standard demo tasks. */
400         prvDemonstratePendingFunctionCall();
401
402         /* If xMutexToDelete has not already been deleted, then delete it now.
403         This is done purely to demonstrate the use of, and test, the
404         vSemaphoreDelete() macro.  Care must be taken not to delete a semaphore
405         that has tasks blocked on it. */
406         if( xMutexToDelete != NULL )
407         {
408                 vSemaphoreDelete( xMutexToDelete );
409                 xMutexToDelete = NULL;
410         }
411
412         /* Exercise heap_5 a bit.  The malloc failed hook will trap failed
413         allocations so there is no need to test here. */
414         pvAllocated = pvPortMalloc( ( rand() % 100 ) + 1 );
415         vPortFree( pvAllocated );
416 }
417 /*-----------------------------------------------------------*/
418
419 /* Called by vApplicationTickHook(), which is defined in main.c. */
420 void vFullDemoTickHookFunction( void )
421 {
422         /* Call the periodic timer test, which tests the timer API functions that
423         can be called from an ISR. */
424         #if( configUSE_PREEMPTION != 0 )
425         {
426                 /* Only created when preemption is used. */
427                 vTimerPeriodicISRTests();
428         }
429         #endif
430
431         /* Call the periodic queue overwrite from ISR demo. */
432         vQueueOverwritePeriodicISRDemo();
433
434         /* Write to a queue that is in use as part of the queue set demo to
435         demonstrate using queue sets from an ISR. */
436         vQueueSetAccessQueueSetFromISR();
437         vQueueSetPollingInterruptAccess();
438
439         /* Exercise event groups from interrupts. */
440         vPeriodicEventGroupsProcessing();
441
442         /* Exercise giving mutexes from an interrupt. */
443         vInterruptSemaphorePeriodicTest();
444
445         /* Exercise using task notifications from an interrupt. */
446         xNotifyTaskFromISR();
447 }
448 /*-----------------------------------------------------------*/
449
450 static void prvPendedFunction( void *pvParameter1, uint32_t ulParameter2 )
451 {
452 static uint32_t ulLastParameter1 = 1000UL, ulLastParameter2 = 0UL;
453 uint32_t ulParameter1;
454
455         ulParameter1 = ( uint32_t ) pvParameter1;
456
457         /* Ensure the parameters are as expected. */
458         configASSERT( ulParameter1 == ( ulLastParameter1 + 1 ) );
459         configASSERT( ulParameter2 == ( ulLastParameter2 + 1 ) );
460
461         /* Remember the parameters for the next time the function is called. */
462         ulLastParameter1 = ulParameter1;
463         ulLastParameter2 = ulParameter2;
464 }
465 /*-----------------------------------------------------------*/
466
467 static void prvDemonstratePendingFunctionCall( void )
468 {
469 static uint32_t ulParameter1 = 1000UL, ulParameter2 = 0UL;
470 const TickType_t xDontBlock = 0; /* This is called from the idle task so must *not* attempt to block. */
471
472         /* prvPendedFunction() just expects the parameters to be incremented by one
473         each time it is called. */
474         ulParameter1++;
475         ulParameter2++;
476
477         /* Pend the function call, sending the parameters. */
478         xTimerPendFunctionCall( prvPendedFunction, ( void * ) ulParameter1, ulParameter2, xDontBlock );
479 }
480 /*-----------------------------------------------------------*/
481
482 static void prvDemonstrateTaskStateAndHandleGetFunctions( void )
483 {
484 TaskHandle_t xIdleTaskHandle, xTimerTaskHandle;
485 char *pcTaskName;
486 static portBASE_TYPE xPerformedOneShotTests = pdFALSE;
487 TaskHandle_t xTestTask;
488
489         /* Demonstrate the use of the xTimerGetTimerDaemonTaskHandle() and
490         xTaskGetIdleTaskHandle() functions.  Also try using the function that sets
491         the task number. */
492         xIdleTaskHandle = xTaskGetIdleTaskHandle();
493         xTimerTaskHandle = xTimerGetTimerDaemonTaskHandle();
494
495         /* This is the idle hook, so the current task handle should equal the
496         returned idle task handle. */
497         if( xTaskGetCurrentTaskHandle() != xIdleTaskHandle )
498         {
499                 pcStatusMessage = "Error:  Returned idle task handle was incorrect";
500         }
501
502         /* Check the timer task handle was returned correctly. */
503         pcTaskName = pcTaskGetName( xTimerTaskHandle );
504         if( strcmp( pcTaskName, "Tmr Svc" ) != 0 )
505         {
506                 pcStatusMessage = "Error:  Returned timer task handle was incorrect";
507         }
508
509         /* This task is running, make sure it's state is returned as running. */
510         if( eTaskStateGet( xIdleTaskHandle ) != eRunning )
511         {
512                 pcStatusMessage = "Error:  Returned idle task state was incorrect";
513         }
514
515         /* If this task is running, then the timer task must be blocked. */
516         if( eTaskStateGet( xTimerTaskHandle ) != eBlocked )
517         {
518                 pcStatusMessage = "Error:  Returned timer task state was incorrect";
519         }
520
521         /* Other tests that should only be performed once follow.  The test task
522         is not created on each iteration because to do so would cause the death
523         task to report an error (too many tasks running). */
524         if( xPerformedOneShotTests == pdFALSE )
525         {
526                 /* Don't run this part of the test again. */
527                 xPerformedOneShotTests = pdTRUE;
528
529                 /* Create a test task to use to test other eTaskStateGet() return values. */
530                 if( xTaskCreate( prvTestTask, "Test", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, &xTestTask ) == pdPASS )
531                 {
532                         /* If this task is running, the test task must be in the ready state. */
533                         if( eTaskStateGet( xTestTask ) != eReady )
534                         {
535                                 pcStatusMessage = "Error: Returned test task state was incorrect 1";
536                         }
537
538                         /* Now suspend the test task and check its state is reported correctly. */
539                         vTaskSuspend( xTestTask );
540                         if( eTaskStateGet( xTestTask ) != eSuspended )
541                         {
542                                 pcStatusMessage = "Error: Returned test task state was incorrect 2";
543                         }
544
545                         /* Now delete the task and check its state is reported correctly. */
546                         vTaskDelete( xTestTask );
547                         if( eTaskStateGet( xTestTask ) != eDeleted )
548                         {
549                                 pcStatusMessage = "Error: Returned test task state was incorrect 3";
550                         }
551                 }
552         }
553 }
554 /*-----------------------------------------------------------*/
555
556 static void prvDemoQueueSpaceFunctions( void *pvParameters )
557 {
558 QueueHandle_t xQueue = NULL;
559 const unsigned portBASE_TYPE uxQueueLength = 10;
560 unsigned portBASE_TYPE uxReturn, x;
561
562         /* Remove compiler warnings. */
563         ( void ) pvParameters;
564
565         /* Create the queue that will be used.  Nothing is actually going to be
566         sent or received so the queue item size is set to 0. */
567         xQueue = xQueueCreate( uxQueueLength, 0 );
568         configASSERT( xQueue );
569
570         for( ;; )
571         {
572                 for( x = 0; x < uxQueueLength; x++ )
573                 {
574                         /* Ask how many messages are available... */
575                         uxReturn = uxQueueMessagesWaiting( xQueue );
576
577                         /* Check the number of messages being reported as being available
578                         is as expected, and force an assert if not. */
579                         if( uxReturn != x )
580                         {
581                                 /* xQueue cannot be NULL so this is deliberately causing an
582                                 assert to be triggered as there is an error. */
583                                 configASSERT( xQueue == NULL );
584                         }
585
586                         /* Ask how many spaces remain in the queue... */
587                         uxReturn = uxQueueSpacesAvailable( xQueue );
588
589                         /* Check the number of spaces being reported as being available
590                         is as expected, and force an assert if not. */
591                         if( uxReturn != ( uxQueueLength - x ) )
592                         {
593                                 /* xQueue cannot be NULL so this is deliberately causing an
594                                 assert to be triggered as there is an error. */
595                                 configASSERT( xQueue == NULL );
596                         }
597
598                         /* Fill one more space in the queue. */
599                         xQueueSendToBack( xQueue, NULL, 0 );
600                 }
601
602                 /* Perform the same check while the queue is full. */
603                 uxReturn = uxQueueMessagesWaiting( xQueue );
604                 if( uxReturn != uxQueueLength )
605                 {
606                         configASSERT( xQueue == NULL );
607                 }
608
609                 uxReturn = uxQueueSpacesAvailable( xQueue );
610
611                 if( uxReturn != 0 )
612                 {
613                         configASSERT( xQueue == NULL );
614                 }
615
616                 /* The queue is full, start again. */
617                 xQueueReset( xQueue );
618
619                 #if( configUSE_PREEMPTION == 0 )
620                         taskYIELD();
621                 #endif
622         }
623 }
624
625