]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/Common/Minimal/TimerDemo.c
Update version number in preparation for official V8.2.0 release.
[freertos] / FreeRTOS / Demo / Common / Minimal / TimerDemo.c
1 /*\r
2     FreeRTOS V8.2.0 - Copyright (C) 2015 Real Time Engineers Ltd.\r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     This file is part of the FreeRTOS distribution.\r
8 \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
12 \r
13         ***************************************************************************\r
14     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
15     >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
16     >>!   obliged to provide the source code for proprietary components     !<<\r
17     >>!   outside of the FreeRTOS kernel.                                   !<<\r
18         ***************************************************************************\r
19 \r
20     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
21     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
22     FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
23     link: http://www.freertos.org/a00114.html\r
24 \r
25     ***************************************************************************\r
26      *                                                                       *\r
27      *    FreeRTOS provides completely free yet professionally developed,    *\r
28      *    robust, strictly quality controlled, supported, and cross          *\r
29      *    platform software that is more than just the market leader, it     *\r
30      *    is the industry's de facto standard.                               *\r
31      *                                                                       *\r
32      *    Help yourself get started quickly while simultaneously helping     *\r
33      *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
34      *    tutorial book, reference manual, or both:                          *\r
35      *    http://www.FreeRTOS.org/Documentation                              *\r
36      *                                                                       *\r
37     ***************************************************************************\r
38 \r
39     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
40         the FAQ page "My application does not run, what could be wrong?".  Have you\r
41         defined configASSERT()?\r
42 \r
43         http://www.FreeRTOS.org/support - In return for receiving this top quality\r
44         embedded software for free we request you assist our global community by\r
45         participating in the support forum.\r
46 \r
47         http://www.FreeRTOS.org/training - Investing in training allows your team to\r
48         be as productive as possible as early as possible.  Now you can receive\r
49         FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
50         Ltd, and the world's leading authority on the world's leading RTOS.\r
51 \r
52     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
53     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
54     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
55 \r
56     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
57     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
58 \r
59     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
60     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
61     licenses offer ticketed support, indemnification and commercial middleware.\r
62 \r
63     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
64     engineered and independently SIL3 certified version for use in safety and\r
65     mission critical applications that require provable dependability.\r
66 \r
67     1 tab == 4 spaces!\r
68 */\r
69 \r
70 \r
71 /*\r
72  * Tests the behaviour of timers.  Some timers are created before the scheduler\r
73  * is started, and some after.\r
74  */\r
75 \r
76 /* Standard includes. */\r
77 #include <string.h>\r
78 \r
79 /* Scheduler include files. */\r
80 #include "FreeRTOS.h"\r
81 #include "task.h"\r
82 #include "timers.h"\r
83 \r
84 /* Demo program include files. */\r
85 #include "TimerDemo.h"\r
86 \r
87 #if ( configTIMER_TASK_PRIORITY < 1 )\r
88         #error configTIMER_TASK_PRIORITY must be set to at least 1 for this test/demo to function correctly.\r
89 #endif\r
90 \r
91 #define tmrdemoDONT_BLOCK                               ( ( TickType_t ) 0 )\r
92 #define tmrdemoONE_SHOT_TIMER_PERIOD    ( xBasePeriod * ( TickType_t ) 3 )\r
93 #define trmdemoNUM_TIMER_RESETS                 ( ( uint8_t ) 10 )\r
94 \r
95 /*-----------------------------------------------------------*/\r
96 \r
97 /* The callback functions used by the timers.  These each increment a counter\r
98 to indicate which timer has expired.  The auto-reload timers that are used by\r
99 the test task (as opposed to being used from an ISR) all share the same\r
100 prvAutoReloadTimerCallback() callback function, and use the ID of the\r
101 pxExpiredTimer parameter passed into that function to know which counter to\r
102 increment.  The other timers all have their own unique callback function and\r
103 simply increment their counters without using the callback function parameter. */\r
104 static void prvAutoReloadTimerCallback( TimerHandle_t pxExpiredTimer );\r
105 static void prvOneShotTimerCallback( TimerHandle_t pxExpiredTimer );\r
106 static void prvTimerTestTask( void *pvParameters );\r
107 static void prvISRAutoReloadTimerCallback( TimerHandle_t pxExpiredTimer );\r
108 static void prvISROneShotTimerCallback( TimerHandle_t pxExpiredTimer );\r
109 \r
110 /* The test functions used by the timer test task.  These manipulate the auto\r
111 reload and one shot timers in various ways, then delay, then inspect the timers\r
112 to ensure they have behaved as expected. */\r
113 static void prvTest1_CreateTimersWithoutSchedulerRunning( void );\r
114 static void prvTest2_CheckTaskAndTimersInitialState( void );\r
115 static void     prvTest3_CheckAutoReloadExpireRates( void );\r
116 static void prvTest4_CheckAutoReloadTimersCanBeStopped( void );\r
117 static void prvTest5_CheckBasicOneShotTimerBehaviour( void );\r
118 static void prvTest6_CheckAutoReloadResetBehaviour( void );\r
119 static void prvResetStartConditionsForNextIteration( void );\r
120 \r
121 /*-----------------------------------------------------------*/\r
122 \r
123 /* Flag that will be latched to pdFAIL should any unexpected behaviour be\r
124 detected in any of the demo tests. */\r
125 static volatile BaseType_t xTestStatus = pdPASS;\r
126 \r
127 /* Counter that is incremented on each cycle of a test.  This is used to\r
128 detect a stalled task - a test that is no longer running. */\r
129 static volatile uint32_t ulLoopCounter = 0;\r
130 \r
131 /* A set of auto reload timers - each of which use the same callback function.\r
132 The callback function uses the timer ID to index into, and then increment, a\r
133 counter in the ucAutoReloadTimerCounters[] array.  The auto reload timers\r
134 referenced from xAutoReloadTimers[] are used by the prvTimerTestTask task. */\r
135 static TimerHandle_t xAutoReloadTimers[ configTIMER_QUEUE_LENGTH + 1 ] = { 0 };\r
136 static uint8_t ucAutoReloadTimerCounters[ configTIMER_QUEUE_LENGTH + 1 ] = { 0 };\r
137 \r
138 /* The one shot timer is configured to use a callback function that increments\r
139 ucOneShotTimerCounter each time it gets called. */\r
140 static TimerHandle_t xOneShotTimer = NULL;\r
141 static uint8_t ucOneShotTimerCounter = ( uint8_t ) 0;\r
142 \r
143 /* The ISR reload timer is controlled from the tick hook to exercise the timer\r
144 API functions that can be used from an ISR.  It is configured to increment\r
145 ucISRReloadTimerCounter each time its callback function is executed. */\r
146 static TimerHandle_t xISRAutoReloadTimer = NULL;\r
147 static uint8_t ucISRAutoReloadTimerCounter = ( uint8_t ) 0;\r
148 \r
149 /* The ISR one shot timer is controlled from the tick hook to exercise the timer\r
150 API functions that can be used from an ISR.  It is configured to increment\r
151 ucISRReloadTimerCounter each time its callback function is executed. */\r
152 static TimerHandle_t xISROneShotTimer = NULL;\r
153 static uint8_t ucISROneShotTimerCounter = ( uint8_t ) 0;\r
154 \r
155 /* The period of all the timers are a multiple of the base period.  The base\r
156 period is configured by the parameter to vStartTimerDemoTask(). */\r
157 static TickType_t xBasePeriod = 0;\r
158 \r
159 /*-----------------------------------------------------------*/\r
160 \r
161 void vStartTimerDemoTask( TickType_t xBasePeriodIn )\r
162 {\r
163         /* Start with the timer and counter arrays clear - this is only necessary\r
164         where the compiler does not clear them automatically on start up. */\r
165         memset( ucAutoReloadTimerCounters, 0x00, sizeof( ucAutoReloadTimerCounters ) );\r
166         memset( xAutoReloadTimers, 0x00, sizeof( xAutoReloadTimers ) );\r
167 \r
168         /* Store the period from which all the timer periods will be generated from\r
169         (multiples of). */\r
170         xBasePeriod = xBasePeriodIn;\r
171 \r
172         /* Create a set of timers for use by this demo/test. */\r
173         prvTest1_CreateTimersWithoutSchedulerRunning();\r
174 \r
175         /* Create the task that will control and monitor the timers.  This is\r
176         created at a lower priority than the timer service task to ensure, as\r
177         far as it is concerned, commands on timers are actioned immediately\r
178         (sending a command to the timer service task will unblock the timer service\r
179         task, which will then preempt this task). */\r
180         if( xTestStatus != pdFAIL )\r
181         {\r
182                 xTaskCreate( prvTimerTestTask, "Tmr Tst", configMINIMAL_STACK_SIZE, NULL, configTIMER_TASK_PRIORITY - 1, NULL );\r
183         }\r
184 }\r
185 /*-----------------------------------------------------------*/\r
186 \r
187 static void prvTimerTestTask( void *pvParameters )\r
188 {\r
189         ( void ) pvParameters;\r
190 \r
191         /* Create a one-shot timer for use later on in this test. */\r
192         xOneShotTimer = xTimerCreate(   "Oneshot Timer",                                /* Text name to facilitate debugging.  The kernel does not use this itself. */\r
193                                                                         tmrdemoONE_SHOT_TIMER_PERIOD,   /* The period for the timer. */\r
194                                                                         pdFALSE,                                                /* Don't auto-reload - hence a one shot timer. */\r
195                                                                         ( void * ) 0,                                   /* The timer identifier.  In this case this is not used as the timer has its own callback. */\r
196                                                                         prvOneShotTimerCallback );              /* The callback to be called when the timer expires. */\r
197 \r
198         if( xOneShotTimer == NULL )\r
199         {\r
200                 xTestStatus = pdFAIL;\r
201                 configASSERT( xTestStatus );\r
202         }\r
203 \r
204 \r
205         /* Ensure all the timers are in their expected initial state.  This\r
206         depends on the timer service task having a higher priority than this task. */\r
207         prvTest2_CheckTaskAndTimersInitialState();\r
208 \r
209         for( ;; )\r
210         {\r
211                 /* Check the auto reload timers expire at the expected/correct rates. */\r
212                 prvTest3_CheckAutoReloadExpireRates();\r
213 \r
214                 /* Check the auto reload timers can be stopped correctly, and correctly\r
215                 report their state. */\r
216                 prvTest4_CheckAutoReloadTimersCanBeStopped();\r
217 \r
218                 /* Check the one shot timer only calls its callback once after it has been\r
219                 started, and that it reports its state correctly. */\r
220                 prvTest5_CheckBasicOneShotTimerBehaviour();\r
221 \r
222                 /* Check timer reset behaviour. */\r
223                 prvTest6_CheckAutoReloadResetBehaviour();\r
224 \r
225                 /* Start the timers again to restart all the tests over again. */\r
226                 prvResetStartConditionsForNextIteration();\r
227         }\r
228 }\r
229 /*-----------------------------------------------------------*/\r
230 \r
231 /* This is called to check that the created task is still running and has not\r
232 detected any errors. */\r
233 BaseType_t xAreTimerDemoTasksStillRunning( TickType_t xCycleFrequency )\r
234 {\r
235 static uint32_t ulLastLoopCounter = 0UL;\r
236 TickType_t xMaxBlockTimeUsedByTheseTests, xLoopCounterIncrementTimeMax;\r
237 static TickType_t xIterationsWithoutCounterIncrement = ( TickType_t ) 0, xLastCycleFrequency;\r
238 \r
239         if( xLastCycleFrequency != xCycleFrequency )\r
240         {\r
241                 /* The cycle frequency has probably become much faster due to an error\r
242                 elsewhere.  Start counting Iterations again. */\r
243                 xIterationsWithoutCounterIncrement = ( TickType_t ) 0;\r
244                 xLastCycleFrequency = xCycleFrequency;\r
245         }\r
246 \r
247         /* Calculate the maximum number of times that it is permissible for this\r
248         function to be called without ulLoopCounter being incremented.  This is\r
249         necessary because the tests in this file block for extended periods, and the\r
250         block period might be longer than the time between calls to this function. */\r
251         xMaxBlockTimeUsedByTheseTests = ( ( TickType_t ) configTIMER_QUEUE_LENGTH ) * xBasePeriod;\r
252         xLoopCounterIncrementTimeMax = ( xMaxBlockTimeUsedByTheseTests / xCycleFrequency ) + 1;\r
253 \r
254         /* If the demo task is still running then the loop counter is expected to\r
255         have incremented every xLoopCounterIncrementTimeMax calls. */\r
256         if( ulLastLoopCounter == ulLoopCounter )\r
257         {\r
258                 xIterationsWithoutCounterIncrement++;\r
259                 if( xIterationsWithoutCounterIncrement > xLoopCounterIncrementTimeMax )\r
260                 {\r
261                         /* The tests appear to be no longer running (stalled). */\r
262                         xTestStatus = pdFAIL;\r
263                         configASSERT( xTestStatus );\r
264                 }\r
265         }\r
266         else\r
267         {\r
268                 /* ulLoopCounter changed, so the count of times this function was called\r
269                 without a change can be reset to zero. */\r
270                 xIterationsWithoutCounterIncrement = ( TickType_t ) 0;\r
271         }\r
272 \r
273         ulLastLoopCounter = ulLoopCounter;\r
274 \r
275         /* Errors detected in the task itself will have latched xTestStatus\r
276         to pdFAIL. */\r
277 \r
278         return xTestStatus;\r
279 }\r
280 /*-----------------------------------------------------------*/\r
281 \r
282 static void prvTest1_CreateTimersWithoutSchedulerRunning( void )\r
283 {\r
284 TickType_t xTimer;\r
285 \r
286         for( xTimer = 0; xTimer < configTIMER_QUEUE_LENGTH; xTimer++ )\r
287         {\r
288                 /* As the timer queue is not yet full, it should be possible to both create\r
289                 and start a timer.  These timers are being started before the scheduler has\r
290                 been started, so their block times should get set to zero within the timer\r
291                 API itself. */\r
292                 xAutoReloadTimers[ xTimer ] = xTimerCreate( "FR Timer",                                                 /* Text name to facilitate debugging.  The kernel does not use this itself. */\r
293                                                                                                         ( ( xTimer + ( TickType_t ) 1 ) * xBasePeriod ),/* The period for the timer.  The plus 1 ensures a period of zero is not specified. */\r
294                                                                                                         pdTRUE,                                                         /* Auto-reload is set to true. */\r
295                                                                                                         ( void * ) xTimer,                                      /* An identifier for the timer as all the auto reload timers use the same callback. */\r
296                                                                                                         prvAutoReloadTimerCallback );           /* The callback to be called when the timer expires. */\r
297 \r
298                 configASSERT( strcmp( pcTimerGetTimerName( xAutoReloadTimers[ xTimer ] ), "FR Timer" ) == 0 );\r
299 \r
300                 if( xAutoReloadTimers[ xTimer ] == NULL )\r
301                 {\r
302                         xTestStatus = pdFAIL;\r
303                         configASSERT( xTestStatus );\r
304                 }\r
305                 else\r
306                 {\r
307                         /* The scheduler has not yet started, so the block period of\r
308                         portMAX_DELAY should just get set to zero in xTimerStart().  Also,\r
309                         the timer queue is not yet full so xTimerStart() should return\r
310                         pdPASS. */\r
311                         if( xTimerStart( xAutoReloadTimers[ xTimer ], portMAX_DELAY ) != pdPASS )\r
312                         {\r
313                                 xTestStatus = pdFAIL;\r
314                                 configASSERT( xTestStatus );\r
315                         }\r
316                 }\r
317         }\r
318 \r
319         /* The timers queue should now be full, so it should be possible to create\r
320         another timer, but not possible to start it (the timer queue will not get\r
321         drained until the scheduler has been started. */\r
322         xAutoReloadTimers[ configTIMER_QUEUE_LENGTH ] = xTimerCreate( "FR Timer",                                       /* Text name to facilitate debugging.  The kernel does not use this itself. */\r
323                                                                                                         ( configTIMER_QUEUE_LENGTH * xBasePeriod ),     /* The period for the timer. */\r
324                                                                                                         pdTRUE,                                                                         /* Auto-reload is set to true. */\r
325                                                                                                         ( void * ) xTimer,                                                      /* An identifier for the timer as all the auto reload timers use the same callback. */\r
326                                                                                                         prvAutoReloadTimerCallback );                           /* The callback executed when the timer expires. */\r
327 \r
328         if( xAutoReloadTimers[ configTIMER_QUEUE_LENGTH ] == NULL )\r
329         {\r
330                 xTestStatus = pdFAIL;\r
331                 configASSERT( xTestStatus );\r
332         }\r
333         else\r
334         {\r
335                 if( xTimerStart( xAutoReloadTimers[ xTimer ], portMAX_DELAY ) == pdPASS )\r
336                 {\r
337                         /* This time it would not be expected that the timer could be\r
338                         started at this point. */\r
339                         xTestStatus = pdFAIL;\r
340                         configASSERT( xTestStatus );\r
341                 }\r
342         }\r
343 \r
344         /* Create the timers that are used from the tick interrupt to test the timer\r
345         API functions that can be called from an ISR. */\r
346         xISRAutoReloadTimer = xTimerCreate( "ISR AR",                                                   /* The text name given to the timer. */\r
347                                                                                 0xffff,                                                         /* The timer is not given a period yet - this will be done from the tick hook, but a period of 0 is invalid. */\r
348                                                                                 pdTRUE,                                                         /* This is an auto reload timer. */\r
349                                                                                 ( void * ) NULL,                                        /* The identifier is not required. */\r
350                                                                                 prvISRAutoReloadTimerCallback );        /* The callback that is executed when the timer expires. */\r
351 \r
352         xISROneShotTimer = xTimerCreate(        "ISR OS",                                                       /* The text name given to the timer. */\r
353                                                                                 0xffff,                                                         /* The timer is not given a period yet - this will be done from the tick hook, but a period of 0 is invalid. */\r
354                                                                                 pdFALSE,                                                        /* This is a one shot timer. */\r
355                                                                                 ( void * ) NULL,                                        /* The identifier is not required. */\r
356                                                                                 prvISROneShotTimerCallback );           /* The callback that is executed when the timer expires. */\r
357 \r
358         if( ( xISRAutoReloadTimer == NULL ) || ( xISROneShotTimer == NULL ) )\r
359         {\r
360                 xTestStatus = pdFAIL;\r
361                 configASSERT( xTestStatus );\r
362         }\r
363 }\r
364 /*-----------------------------------------------------------*/\r
365 \r
366 static void prvTest2_CheckTaskAndTimersInitialState( void )\r
367 {\r
368 uint8_t ucTimer;\r
369 \r
370         /* Ensure all the timers are in their expected initial state.  This     depends\r
371         on the timer service task having a higher priority than this task.\r
372 \r
373         auto reload timers 0 to ( configTIMER_QUEUE_LENGTH - 1 ) should now be active,\r
374         and auto reload timer configTIMER_QUEUE_LENGTH should not yet be active (it\r
375         could not be started prior to the scheduler being started when it was\r
376         created). */\r
377         for( ucTimer = 0; ucTimer < ( uint8_t ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
378         {\r
379                 if( xTimerIsTimerActive( xAutoReloadTimers[ ucTimer ] ) == pdFALSE )\r
380                 {\r
381                         xTestStatus = pdFAIL;\r
382                         configASSERT( xTestStatus );\r
383                 }\r
384         }\r
385 \r
386         if( xTimerIsTimerActive( xAutoReloadTimers[ configTIMER_QUEUE_LENGTH ] ) != pdFALSE )\r
387         {\r
388                 xTestStatus = pdFAIL;\r
389                 configASSERT( xTestStatus );\r
390         }\r
391 }\r
392 /*-----------------------------------------------------------*/\r
393 \r
394 static void     prvTest3_CheckAutoReloadExpireRates( void )\r
395 {\r
396 uint8_t ucMaxAllowableValue, ucMinAllowableValue, ucTimer;\r
397 TickType_t xBlockPeriod, xTimerPeriod, xExpectedNumber;\r
398 \r
399         /* Check the auto reload timers expire at the expected rates. */\r
400 \r
401 \r
402         /* Delaying for configTIMER_QUEUE_LENGTH * xBasePeriod ticks should allow\r
403         all the auto reload timers to expire at least once. */\r
404         xBlockPeriod = ( ( TickType_t ) configTIMER_QUEUE_LENGTH ) * xBasePeriod;\r
405         vTaskDelay( xBlockPeriod );\r
406 \r
407         /* Check that all the auto reload timers have called their callback\r
408         function the expected number of times. */\r
409         for( ucTimer = 0; ucTimer < ( uint8_t ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
410         {\r
411                 /* The expected number of expiries is equal to the block period divided\r
412                 by the timer period. */\r
413                 xTimerPeriod = ( ( ( TickType_t ) ucTimer + ( TickType_t ) 1 ) * xBasePeriod );\r
414                 xExpectedNumber = xBlockPeriod / xTimerPeriod;\r
415 \r
416                 ucMaxAllowableValue = ( ( uint8_t ) xExpectedNumber ) ;\r
417                 ucMinAllowableValue = ( uint8_t ) ( ( uint8_t ) xExpectedNumber - ( uint8_t ) 1 ); /* Weird casting to try and please all compilers. */\r
418 \r
419                 if( ( ucAutoReloadTimerCounters[ ucTimer ] < ucMinAllowableValue ) ||\r
420                         ( ucAutoReloadTimerCounters[ ucTimer ] > ucMaxAllowableValue )\r
421                         )\r
422                 {\r
423                         xTestStatus = pdFAIL;\r
424                         configASSERT( xTestStatus );\r
425                 }\r
426         }\r
427 \r
428         if( xTestStatus == pdPASS )\r
429         {\r
430                 /* No errors have been reported so increment the loop counter so the\r
431                 check task knows this task is still running. */\r
432                 ulLoopCounter++;\r
433         }\r
434 }\r
435 /*-----------------------------------------------------------*/\r
436 \r
437 static void prvTest4_CheckAutoReloadTimersCanBeStopped( void )\r
438 {\r
439 uint8_t ucTimer;\r
440 \r
441         /* Check the auto reload timers can be stopped correctly, and correctly\r
442         report their state. */\r
443 \r
444         /* Stop all the active timers. */\r
445         for( ucTimer = 0; ucTimer < ( uint8_t ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
446         {\r
447                 /* The timer has not been stopped yet! */\r
448                 if( xTimerIsTimerActive( xAutoReloadTimers[ ucTimer ] ) == pdFALSE )\r
449                 {\r
450                         xTestStatus = pdFAIL;\r
451                         configASSERT( xTestStatus );\r
452                 }\r
453 \r
454                 /* Now stop the timer.  This will appear to happen immediately to\r
455                 this task because this task is running at a priority below the\r
456                 timer service task. */\r
457                 xTimerStop( xAutoReloadTimers[ ucTimer ], tmrdemoDONT_BLOCK );\r
458 \r
459                 /* The timer should now be inactive. */\r
460                 if( xTimerIsTimerActive( xAutoReloadTimers[ ucTimer ] ) != pdFALSE )\r
461                 {\r
462                         xTestStatus = pdFAIL;\r
463                         configASSERT( xTestStatus );\r
464                 }\r
465         }\r
466 \r
467         taskENTER_CRITICAL();\r
468         {\r
469                 /* The timer in array position configTIMER_QUEUE_LENGTH should not\r
470                 be active.  The critical section is used to ensure the timer does\r
471                 not call its callback between the next line running and the array\r
472                 being cleared back to zero, as that would mask an error condition. */\r
473                 if( ucAutoReloadTimerCounters[ configTIMER_QUEUE_LENGTH ] != ( uint8_t ) 0 )\r
474                 {\r
475                         xTestStatus = pdFAIL;\r
476                         configASSERT( xTestStatus );\r
477                 }\r
478 \r
479                 /* Clear the timer callback count. */\r
480                 memset( ( void * ) ucAutoReloadTimerCounters, 0, sizeof( ucAutoReloadTimerCounters ) );\r
481         }\r
482         taskEXIT_CRITICAL();\r
483 \r
484         /* The timers are now all inactive, so this time, after delaying, none\r
485         of the callback counters should have incremented. */\r
486         vTaskDelay( ( ( TickType_t ) configTIMER_QUEUE_LENGTH ) * xBasePeriod );\r
487         for( ucTimer = 0; ucTimer < ( uint8_t ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
488         {\r
489                 if( ucAutoReloadTimerCounters[ ucTimer ] != ( uint8_t ) 0 )\r
490                 {\r
491                         xTestStatus = pdFAIL;\r
492                         configASSERT( xTestStatus );\r
493                 }\r
494         }\r
495 \r
496         if( xTestStatus == pdPASS )\r
497         {\r
498                 /* No errors have been reported so increment the loop counter so\r
499                 the check task knows this task is still running. */\r
500                 ulLoopCounter++;\r
501         }\r
502 }\r
503 /*-----------------------------------------------------------*/\r
504 \r
505 static void prvTest5_CheckBasicOneShotTimerBehaviour( void )\r
506 {\r
507         /* Check the one shot timer only calls its callback once after it has been\r
508         started, and that it reports its state correctly. */\r
509 \r
510         /* The one shot timer should not be active yet. */\r
511         if( xTimerIsTimerActive( xOneShotTimer ) != pdFALSE )\r
512         {\r
513                 xTestStatus = pdFAIL;\r
514                 configASSERT( xTestStatus );\r
515         }\r
516 \r
517         if( ucOneShotTimerCounter != ( uint8_t ) 0 )\r
518         {\r
519                 xTestStatus = pdFAIL;\r
520                 configASSERT( xTestStatus );\r
521         }\r
522 \r
523         /* Start the one shot timer and check that it reports its state correctly. */\r
524         xTimerStart( xOneShotTimer, tmrdemoDONT_BLOCK );\r
525         if( xTimerIsTimerActive( xOneShotTimer ) == pdFALSE )\r
526         {\r
527                 xTestStatus = pdFAIL;\r
528                 configASSERT( xTestStatus );\r
529         }\r
530 \r
531         /* Delay for three times as long as the one shot timer period, then check\r
532         to ensure it has only called its callback once, and is now not in the\r
533         active state. */\r
534         vTaskDelay( tmrdemoONE_SHOT_TIMER_PERIOD * ( TickType_t ) 3 );\r
535 \r
536         if( xTimerIsTimerActive( xOneShotTimer ) != pdFALSE )\r
537         {\r
538                 xTestStatus = pdFAIL;\r
539                 configASSERT( xTestStatus );\r
540         }\r
541 \r
542         if( ucOneShotTimerCounter != ( uint8_t ) 1 )\r
543         {\r
544                 xTestStatus = pdFAIL;\r
545                 configASSERT( xTestStatus );\r
546         }\r
547         else\r
548         {\r
549                 /* Reset the one shot timer callback count. */\r
550                 ucOneShotTimerCounter = ( uint8_t ) 0;\r
551         }\r
552 \r
553         if( xTestStatus == pdPASS )\r
554         {\r
555                 /* No errors have been reported so increment the loop counter so the\r
556                 check task knows this task is still running. */\r
557                 ulLoopCounter++;\r
558         }\r
559 }\r
560 /*-----------------------------------------------------------*/\r
561 \r
562 static void prvTest6_CheckAutoReloadResetBehaviour( void )\r
563 {\r
564 uint8_t ucTimer;\r
565 \r
566         /* Check timer reset behaviour. */\r
567 \r
568         /* Restart the one shot timer and check it reports its status correctly. */\r
569         xTimerStart( xOneShotTimer, tmrdemoDONT_BLOCK );\r
570         if( xTimerIsTimerActive( xOneShotTimer ) == pdFALSE )\r
571         {\r
572                 xTestStatus = pdFAIL;\r
573                 configASSERT( xTestStatus );\r
574         }\r
575 \r
576         /* Restart one of the auto reload timers and check that it reports its\r
577         status correctly. */\r
578         xTimerStart( xAutoReloadTimers[ configTIMER_QUEUE_LENGTH - 1 ], tmrdemoDONT_BLOCK );\r
579         if( xTimerIsTimerActive( xAutoReloadTimers[ configTIMER_QUEUE_LENGTH - 1 ] ) == pdFALSE )\r
580         {\r
581                 xTestStatus = pdFAIL;\r
582                 configASSERT( xTestStatus );\r
583         }\r
584 \r
585         for( ucTimer = 0; ucTimer < trmdemoNUM_TIMER_RESETS; ucTimer++ )\r
586         {\r
587                 /* Delay for half as long as the one shot timer period, then reset it.\r
588                 It should never expire while this is done, so its callback count should\r
589                 never increment. */\r
590                 vTaskDelay( tmrdemoONE_SHOT_TIMER_PERIOD / 2 );\r
591 \r
592                 /* Check both running timers are still active, but have not called their\r
593                 callback functions. */\r
594                 if( xTimerIsTimerActive( xOneShotTimer ) == pdFALSE )\r
595                 {\r
596                         xTestStatus = pdFAIL;\r
597                         configASSERT( xTestStatus );\r
598                 }\r
599 \r
600                 if( ucOneShotTimerCounter != ( uint8_t ) 0 )\r
601                 {\r
602                         xTestStatus = pdFAIL;\r
603                         configASSERT( xTestStatus );\r
604                 }\r
605 \r
606                 if( xTimerIsTimerActive( xAutoReloadTimers[ configTIMER_QUEUE_LENGTH - 1 ] ) == pdFALSE )\r
607                 {\r
608                         xTestStatus = pdFAIL;\r
609                         configASSERT( xTestStatus );\r
610                 }\r
611 \r
612                 if( ucAutoReloadTimerCounters[ configTIMER_QUEUE_LENGTH - 1 ] != ( uint8_t ) 0 )\r
613                 {\r
614                         xTestStatus = pdFAIL;\r
615                         configASSERT( xTestStatus );\r
616                 }\r
617 \r
618                 /* Reset both running timers. */\r
619                 xTimerReset( xOneShotTimer, tmrdemoDONT_BLOCK );\r
620                 xTimerReset( xAutoReloadTimers[ configTIMER_QUEUE_LENGTH - 1 ], tmrdemoDONT_BLOCK );\r
621 \r
622                 if( xTestStatus == pdPASS )\r
623                 {\r
624                         /* No errors have been reported so increment the loop counter so\r
625                         the check task knows this task is still running. */\r
626                         ulLoopCounter++;\r
627                 }\r
628         }\r
629 \r
630         /* Finally delay long enough for both running timers to expire. */\r
631         vTaskDelay( ( ( TickType_t ) configTIMER_QUEUE_LENGTH ) * xBasePeriod );\r
632 \r
633         /* The timers were not reset during the above delay period so should now\r
634         both have called their callback functions. */\r
635         if( ucOneShotTimerCounter != ( uint8_t ) 1 )\r
636         {\r
637                 xTestStatus = pdFAIL;\r
638                 configASSERT( xTestStatus );\r
639         }\r
640 \r
641         if( ucAutoReloadTimerCounters[ configTIMER_QUEUE_LENGTH - 1 ] == 0 )\r
642         {\r
643                 xTestStatus = pdFAIL;\r
644                 configASSERT( xTestStatus );\r
645         }\r
646 \r
647         /* The one shot timer should no longer be active, while the auto reload\r
648         timer should still be active. */\r
649         if( xTimerIsTimerActive( xAutoReloadTimers[ configTIMER_QUEUE_LENGTH - 1 ] ) == pdFALSE )\r
650         {\r
651                 xTestStatus = pdFAIL;\r
652                 configASSERT( xTestStatus );\r
653         }\r
654 \r
655         if( xTimerIsTimerActive( xOneShotTimer ) == pdTRUE )\r
656         {\r
657                 xTestStatus = pdFAIL;\r
658                 configASSERT( xTestStatus );\r
659         }\r
660 \r
661         /* Stop the auto reload timer again. */\r
662         xTimerStop( xAutoReloadTimers[ configTIMER_QUEUE_LENGTH - 1 ], tmrdemoDONT_BLOCK );\r
663 \r
664         if( xTimerIsTimerActive( xAutoReloadTimers[ configTIMER_QUEUE_LENGTH - 1 ] ) != pdFALSE )\r
665         {\r
666                 xTestStatus = pdFAIL;\r
667                 configASSERT( xTestStatus );\r
668         }\r
669 \r
670         /* Clear the timer callback counts, ready for another iteration of these\r
671         tests. */\r
672         ucAutoReloadTimerCounters[ configTIMER_QUEUE_LENGTH - 1 ] = ( uint8_t ) 0;\r
673         ucOneShotTimerCounter = ( uint8_t ) 0;\r
674 \r
675         if( xTestStatus == pdPASS )\r
676         {\r
677                 /* No errors have been reported so increment the loop counter so the check\r
678                 task knows this task is still running. */\r
679                 ulLoopCounter++;\r
680         }\r
681 }\r
682 /*-----------------------------------------------------------*/\r
683 \r
684 static void prvResetStartConditionsForNextIteration( void )\r
685 {\r
686 uint8_t ucTimer;\r
687 \r
688         /* Start the timers again to start all the tests over again. */\r
689 \r
690         /* Start the timers again. */\r
691         for( ucTimer = 0; ucTimer < ( uint8_t ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
692         {\r
693                 /* The timer has not been started yet! */\r
694                 if( xTimerIsTimerActive( xAutoReloadTimers[ ucTimer ] ) != pdFALSE )\r
695                 {\r
696                         xTestStatus = pdFAIL;\r
697                         configASSERT( xTestStatus );\r
698                 }\r
699 \r
700                 /* Now start the timer.  This will appear to happen immediately to\r
701                 this task because this task is running at a priority below the timer\r
702                 service task. */\r
703                 xTimerStart( xAutoReloadTimers[ ucTimer ], tmrdemoDONT_BLOCK );\r
704 \r
705                 /* The timer should now be active. */\r
706                 if( xTimerIsTimerActive( xAutoReloadTimers[ ucTimer ] ) == pdFALSE )\r
707                 {\r
708                         xTestStatus = pdFAIL;\r
709                         configASSERT( xTestStatus );\r
710                 }\r
711         }\r
712 \r
713         if( xTestStatus == pdPASS )\r
714         {\r
715                 /* No errors have been reported so increment the loop counter so the\r
716                 check task knows this task is still running. */\r
717                 ulLoopCounter++;\r
718         }\r
719 }\r
720 /*-----------------------------------------------------------*/\r
721 \r
722 void vTimerPeriodicISRTests( void )\r
723 {\r
724 static TickType_t uxTick = ( TickType_t ) -1;\r
725 \r
726 #if( configTIMER_TASK_PRIORITY != ( configMAX_PRIORITIES - 1 ) )\r
727         /* The timer service task is not the highest priority task, so it cannot\r
728         be assumed that timings will be exact.  Timers should never call their\r
729         callback before their expiry time, but a margin is permissible for calling\r
730         their callback after their expiry time.  If exact timing is required then\r
731         configTIMER_TASK_PRIORITY must be set to ensure the timer service task\r
732         is the highest priority task in the system.\r
733 \r
734         This function is called from the tick hook.  The tick hook is called\r
735         even when the scheduler is suspended.  Therefore it is possible that the\r
736         uxTick count maintained in this function is temporarily ahead of the tick\r
737         count maintained by the kernel.  When this is the case a message posted from\r
738         this function will assume a time stamp in advance of the real time stamp,\r
739         which can result in a timer being processed before this function expects it\r
740         to.  For example, if the kernel's tick count was 100, and uxTick was 102,\r
741         then this function will not expect the timer to have expired until the\r
742         kernel's tick count is (102 + xBasePeriod), whereas in reality the timer\r
743         will expire when the kernel's tick count is (100 + xBasePeriod).  For this\r
744         reason xMargin is used as an allowable margin for premature timer expiries\r
745         as well as late timer expiries. */\r
746         #ifdef _WINDOWS_\r
747                 /* Windows is not real real time. */\r
748                 const TickType_t xMargin = 20;\r
749         #else\r
750                 const TickType_t xMargin = 6;\r
751         #endif /* _WINDOWS_ */\r
752 #else\r
753         #ifdef _WINDOWS_\r
754                 /* Windows is not real real time. */\r
755                 const TickType_t xMargin = 20;\r
756         #else\r
757                 const TickType_t xMargin = 4;\r
758         #endif /* _WINDOWS_ */\r
759 #endif\r
760 \r
761 \r
762         uxTick++;\r
763 \r
764         if( uxTick == 0 )\r
765         {\r
766                 /* The timers will have been created, but not started.  Start them now\r
767                 by setting their period. */\r
768                 ucISRAutoReloadTimerCounter = 0;\r
769                 ucISROneShotTimerCounter = 0;\r
770 \r
771                 /* It is possible that the timer task has not yet made room in the\r
772                 timer queue.  If the timers cannot be started then reset uxTick so\r
773                 another attempt is made later. */\r
774                 uxTick = ( TickType_t ) -1;\r
775 \r
776                 /* Try starting first timer. */\r
777                 if( xTimerChangePeriodFromISR( xISRAutoReloadTimer, xBasePeriod, NULL ) == pdPASS )\r
778                 {\r
779                         /* First timer was started, try starting the second timer. */\r
780                         if( xTimerChangePeriodFromISR( xISROneShotTimer, xBasePeriod, NULL ) == pdPASS )\r
781                         {\r
782                                 /* Both timers were started, so set the uxTick back to its\r
783                                 proper value. */\r
784                                 uxTick = 0;\r
785                         }\r
786                         else\r
787                         {\r
788                                 /* Second timer could not be started, so stop the first one\r
789                                 again. */\r
790                                 xTimerStopFromISR( xISRAutoReloadTimer, NULL );\r
791                         }\r
792                 }\r
793         }\r
794         else if( uxTick == ( xBasePeriod - xMargin ) )\r
795         {\r
796                 /* Neither timer should have expired yet. */\r
797                 if( ( ucISRAutoReloadTimerCounter != 0 ) || ( ucISROneShotTimerCounter != 0 ) )\r
798                 {\r
799                         xTestStatus = pdFAIL;\r
800                         configASSERT( xTestStatus );\r
801                 }\r
802         }\r
803         else if( uxTick == ( xBasePeriod + xMargin ) )\r
804         {\r
805                 /* Both timers should now have expired once.  The auto reload timer will\r
806                 still be active, but the one shot timer should now have stopped. */\r
807                 if( ( ucISRAutoReloadTimerCounter != 1 ) || ( ucISROneShotTimerCounter != 1 ) )\r
808                 {\r
809                         xTestStatus = pdFAIL;\r
810                         configASSERT( xTestStatus );\r
811                 }\r
812         }\r
813         else if( uxTick == ( ( 2 * xBasePeriod ) - xMargin ) )\r
814         {\r
815                 /* The auto reload timer will still be active, but the one shot timer\r
816                 should now have stopped - however, at this time neither of the timers\r
817                 should have expired again since the last test. */\r
818                 if( ( ucISRAutoReloadTimerCounter != 1 ) || ( ucISROneShotTimerCounter != 1 ) )\r
819                 {\r
820                         xTestStatus = pdFAIL;\r
821                         configASSERT( xTestStatus );\r
822                 }\r
823         }\r
824         else if( uxTick == ( ( 2 * xBasePeriod ) + xMargin ) )\r
825         {\r
826                 /* The auto reload timer will still be active, but the one shot timer\r
827                 should now have stopped.  At this time the auto reload timer should have\r
828                 expired again, but the one shot timer count should not have changed. */\r
829                 if( ucISRAutoReloadTimerCounter != 2 )\r
830                 {\r
831                         xTestStatus = pdFAIL;\r
832                         configASSERT( xTestStatus );\r
833                 }\r
834 \r
835                 if( ucISROneShotTimerCounter != 1 )\r
836                 {\r
837                         xTestStatus = pdFAIL;\r
838                         configASSERT( xTestStatus );\r
839                 }\r
840         }\r
841         else if( uxTick == ( ( 2 * xBasePeriod ) + ( xBasePeriod >> ( TickType_t ) 2U ) ) )\r
842         {\r
843                 /* The auto reload timer will still be active, but the one shot timer\r
844                 should now have stopped.  Again though, at this time, neither timer call\r
845                 back should have been called since the last test. */\r
846                 if( ucISRAutoReloadTimerCounter != 2 )\r
847                 {\r
848                         xTestStatus = pdFAIL;\r
849                         configASSERT( xTestStatus );\r
850                 }\r
851 \r
852                 if( ucISROneShotTimerCounter != 1 )\r
853                 {\r
854                         xTestStatus = pdFAIL;\r
855                         configASSERT( xTestStatus );\r
856                 }\r
857         }\r
858         else if( uxTick == ( 3 * xBasePeriod ) )\r
859         {\r
860                 /* Start the one shot timer again. */\r
861                 xTimerStartFromISR( xISROneShotTimer, NULL );\r
862         }\r
863         else if( uxTick == ( ( 3 * xBasePeriod ) + xMargin ) )\r
864         {\r
865                 /* The auto reload timer and one shot timer will be active.  At\r
866                 this time the auto reload timer should have     expired again, but the one\r
867                 shot timer count should not have changed yet. */\r
868                 if( ucISRAutoReloadTimerCounter != 3 )\r
869                 {\r
870                         xTestStatus = pdFAIL;\r
871                         configASSERT( xTestStatus );\r
872                 }\r
873 \r
874                 if( ucISROneShotTimerCounter != 1 )\r
875                 {\r
876                         xTestStatus = pdFAIL;\r
877                         configASSERT( xTestStatus );\r
878                 }\r
879 \r
880                 /* Now stop the auto reload timer.  The one shot timer was started\r
881                 a few ticks ago. */\r
882                 xTimerStopFromISR( xISRAutoReloadTimer, NULL );\r
883         }\r
884         else if( uxTick == ( 4 * ( xBasePeriod - xMargin ) ) )\r
885         {\r
886                 /* The auto reload timer is now stopped, and the one shot timer is\r
887                 active, but at this time neither timer should have expired since the\r
888                 last test. */\r
889                 if( ucISRAutoReloadTimerCounter != 3 )\r
890                 {\r
891                         xTestStatus = pdFAIL;\r
892                         configASSERT( xTestStatus );\r
893                 }\r
894 \r
895                 if( ucISROneShotTimerCounter != 1 )\r
896                 {\r
897                         xTestStatus = pdFAIL;\r
898                         configASSERT( xTestStatus );\r
899                 }\r
900         }\r
901         else if( uxTick == ( ( 4 * xBasePeriod ) + xMargin ) )\r
902         {\r
903                 /* The auto reload timer is now stopped, and the one shot timer is\r
904                 active.  The one shot timer should have expired again, but the auto\r
905                 reload timer should not have executed its callback. */\r
906                 if( ucISRAutoReloadTimerCounter != 3 )\r
907                 {\r
908                         xTestStatus = pdFAIL;\r
909                         configASSERT( xTestStatus );\r
910                 }\r
911 \r
912                 if( ucISROneShotTimerCounter != 2 )\r
913                 {\r
914                         xTestStatus = pdFAIL;\r
915                         configASSERT( xTestStatus );\r
916                 }\r
917         }\r
918         else if( uxTick == ( 8 * xBasePeriod ) )\r
919         {\r
920                 /* The auto reload timer is now stopped, and the one shot timer has\r
921                 already expired and then stopped itself.  Both callback counters should\r
922                 not have incremented since the last test. */\r
923                 if( ucISRAutoReloadTimerCounter != 3 )\r
924                 {\r
925                         xTestStatus = pdFAIL;\r
926                         configASSERT( xTestStatus );\r
927                 }\r
928 \r
929                 if( ucISROneShotTimerCounter != 2 )\r
930                 {\r
931                         xTestStatus = pdFAIL;\r
932                         configASSERT( xTestStatus );\r
933                 }\r
934 \r
935                 /* Now reset the one shot timer. */\r
936                 xTimerResetFromISR( xISROneShotTimer, NULL );\r
937         }\r
938         else if( uxTick == ( ( 9 * xBasePeriod ) - xMargin ) )\r
939         {\r
940                 /* Only the one shot timer should be running, but it should not have\r
941                 expired since the last test.  Check the callback counters have not\r
942                 incremented, then reset the one shot timer again. */\r
943                 if( ucISRAutoReloadTimerCounter != 3 )\r
944                 {\r
945                         xTestStatus = pdFAIL;\r
946                         configASSERT( xTestStatus );\r
947                 }\r
948 \r
949                 if( ucISROneShotTimerCounter != 2 )\r
950                 {\r
951                         xTestStatus = pdFAIL;\r
952                         configASSERT( xTestStatus );\r
953                 }\r
954 \r
955                 xTimerResetFromISR( xISROneShotTimer, NULL );\r
956         }\r
957         else if( uxTick == ( ( 10 * xBasePeriod ) - ( 2 * xMargin ) ) )\r
958         {\r
959                 /* Only the one shot timer should be running, but it should not have\r
960                 expired since the last test.  Check the callback counters have not\r
961                 incremented, then reset the one shot timer again. */\r
962                 if( ucISRAutoReloadTimerCounter != 3 )\r
963                 {\r
964                         xTestStatus = pdFAIL;\r
965                         configASSERT( xTestStatus );\r
966                 }\r
967 \r
968                 if( ucISROneShotTimerCounter != 2 )\r
969                 {\r
970                         xTestStatus = pdFAIL;\r
971                         configASSERT( xTestStatus );\r
972                 }\r
973 \r
974                 xTimerResetFromISR( xISROneShotTimer, NULL );\r
975         }\r
976         else if( uxTick == ( ( 11 * xBasePeriod ) - ( 3 * xMargin ) ) )\r
977         {\r
978                 /* Only the one shot timer should be running, but it should not have\r
979                 expired since the last test.  Check the callback counters have not\r
980                 incremented, then reset the one shot timer once again. */\r
981                 if( ucISRAutoReloadTimerCounter != 3 )\r
982                 {\r
983                         xTestStatus = pdFAIL;\r
984                         configASSERT( xTestStatus );\r
985                 }\r
986 \r
987                 if( ucISROneShotTimerCounter != 2 )\r
988                 {\r
989                         xTestStatus = pdFAIL;\r
990                         configASSERT( xTestStatus );\r
991                 }\r
992 \r
993                 xTimerResetFromISR( xISROneShotTimer, NULL );\r
994         }\r
995         else if( uxTick == ( ( 12 * xBasePeriod ) - ( 2 * xMargin ) ) )\r
996         {\r
997                 /* Only the one shot timer should have been running and this time it\r
998                 should have     expired.  Check its callback count has been incremented.\r
999                 The auto reload timer is still not running so should still have the same\r
1000                 count value.  This time the one shot timer is not reset so should not\r
1001                 restart from its expiry period again. */\r
1002                 if( ucISRAutoReloadTimerCounter != 3 )\r
1003                 {\r
1004                         xTestStatus = pdFAIL;\r
1005                         configASSERT( xTestStatus );\r
1006                 }\r
1007 \r
1008                 if( ucISROneShotTimerCounter != 3 )\r
1009                 {\r
1010                         xTestStatus = pdFAIL;\r
1011                         configASSERT( xTestStatus );\r
1012                 }\r
1013         }\r
1014         else if( uxTick == ( 15 * xBasePeriod ) )\r
1015         {\r
1016                 /* Neither timer should be running now.  Check neither callback count\r
1017                 has incremented, then go back to the start to run these tests all\r
1018                 over again. */\r
1019                 if( ucISRAutoReloadTimerCounter != 3 )\r
1020                 {\r
1021                         xTestStatus = pdFAIL;\r
1022                         configASSERT( xTestStatus );\r
1023                 }\r
1024 \r
1025                 if( ucISROneShotTimerCounter != 3 )\r
1026                 {\r
1027                         xTestStatus = pdFAIL;\r
1028                         configASSERT( xTestStatus );\r
1029                 }\r
1030 \r
1031                 uxTick = ( TickType_t ) -1;\r
1032         }\r
1033 }\r
1034 /*-----------------------------------------------------------*/\r
1035 \r
1036 /*** Timer callback functions are defined below here. ***/\r
1037 \r
1038 static void prvAutoReloadTimerCallback( TimerHandle_t pxExpiredTimer )\r
1039 {\r
1040 uint32_t ulTimerID;\r
1041 \r
1042         ulTimerID = ( uint32_t ) pvTimerGetTimerID( pxExpiredTimer );\r
1043         if( ulTimerID <= ( configTIMER_QUEUE_LENGTH + 1 ) )\r
1044         {\r
1045                 ( ucAutoReloadTimerCounters[ ulTimerID ] )++;\r
1046         }\r
1047         else\r
1048         {\r
1049                 /* The timer ID appears to be unexpected (invalid). */\r
1050                 xTestStatus = pdFAIL;\r
1051                 configASSERT( xTestStatus );\r
1052         }\r
1053 }\r
1054 /*-----------------------------------------------------------*/\r
1055 \r
1056 static void prvOneShotTimerCallback( TimerHandle_t pxExpiredTimer )\r
1057 {\r
1058         /* The parameter is not used in this case as only one timer uses this\r
1059         callback function. */\r
1060         ( void ) pxExpiredTimer;\r
1061 \r
1062         ucOneShotTimerCounter++;\r
1063 }\r
1064 /*-----------------------------------------------------------*/\r
1065 \r
1066 static void prvISRAutoReloadTimerCallback( TimerHandle_t pxExpiredTimer )\r
1067 {\r
1068         /* The parameter is not used in this case as only one timer uses this\r
1069         callback function. */\r
1070         ( void ) pxExpiredTimer;\r
1071 \r
1072         ucISRAutoReloadTimerCounter++;\r
1073 }\r
1074 /*-----------------------------------------------------------*/\r
1075 \r
1076 static void prvISROneShotTimerCallback( TimerHandle_t pxExpiredTimer )\r
1077 {\r
1078         /* The parameter is not used in this case as only one timer uses this\r
1079         callback function. */\r
1080         ( void ) pxExpiredTimer;\r
1081 \r
1082         ucISROneShotTimerCounter++;\r
1083 }\r
1084 /*-----------------------------------------------------------*/\r
1085 \r
1086 \r
1087 \r
1088 \r