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