2 FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.
\r
4 ***************************************************************************
\r
8 * + New to FreeRTOS, *
\r
9 * + Wanting to learn FreeRTOS or multitasking in general quickly *
\r
10 * + Looking for basic training, *
\r
11 * + Wanting to improve your FreeRTOS skills and productivity *
\r
13 * then take a look at the FreeRTOS books - available as PDF or paperback *
\r
15 * "Using the FreeRTOS Real Time Kernel - a Practical Guide" *
\r
16 * http://www.FreeRTOS.org/Documentation *
\r
18 * A pdf reference manual is also available. Both are usually delivered *
\r
19 * to your inbox within 20 minutes to two hours when purchased between 8am *
\r
20 * and 8pm GMT (although please allow up to 24 hours in case of *
\r
21 * exceptional circumstances). Thank you for your support! *
\r
23 ***************************************************************************
\r
25 This file is part of the FreeRTOS distribution.
\r
27 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
28 the terms of the GNU General Public License (version 2) as published by the
\r
29 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
30 ***NOTE*** The exception to the GPL is included to allow you to distribute
\r
31 a combined work that includes FreeRTOS without being obliged to provide the
\r
32 source code for proprietary components outside of the FreeRTOS kernel.
\r
33 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
\r
34 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
35 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
36 more details. You should have received a copy of the GNU General Public
\r
37 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
38 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
39 by writing to Richard Barry, contact details for whom are available on the
\r
44 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
47 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
50 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
51 licensing and training services.
\r
54 /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
\r
55 all the API functions to use the MPU wrappers. That should only be done when
\r
56 task.h is included from an application file. */
\r
57 #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
\r
59 #include "FreeRTOS.h"
\r
64 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
\r
66 /* This entire source file will be skipped if the application is not configured
\r
67 to include software timer functionality. This #if is closed at the very bottom
\r
68 of this file. If you want to include software timer functionality then ensure
\r
69 configUSE_TIMERS is set to 1 in FreeRTOSConfig.h. */
\r
70 #if ( configUSE_TIMERS == 1 )
\r
72 /* Misc definitions. */
\r
73 #define tmrNO_DELAY ( portTickType ) 0U
\r
75 /* The definition of the timers themselves. */
\r
76 typedef struct tmrTimerControl
\r
78 const signed char *pcTimerName; /*<< Text name. This is not used by the kernel, it is included simply to make debugging easier. */
\r
79 xListItem xTimerListItem; /*<< Standard linked list item as used by all kernel features for event management. */
\r
80 portTickType xTimerPeriodInTicks;/*<< How quickly and often the timer expires. */
\r
81 unsigned portBASE_TYPE uxAutoReload; /*<< Set to pdTRUE if the timer should be automatically restarted once expired. Set to pdFALSE if the timer is, in effect, a one shot timer. */
\r
82 void *pvTimerID; /*<< An ID to identify the timer. This allows the timer to be identified when the same callback is used for multiple timers. */
\r
83 tmrTIMER_CALLBACK pxCallbackFunction; /*<< The function that will be called when the timer expires. */
\r
86 /* The definition of messages that can be sent and received on the timer
\r
88 typedef struct tmrTimerQueueMessage
\r
90 portBASE_TYPE xMessageID; /*<< The command being sent to the timer service task. */
\r
91 portTickType xMessageValue; /*<< An optional value used by a subset of commands, for example, when changing the period of a timer. */
\r
92 xTIMER * pxTimer; /*<< The timer to which the command will be applied. */
\r
96 /* The list in which active timers are stored. Timers are referenced in expire
\r
97 time order, with the nearest expiry time at the front of the list. Only the
\r
98 timer service task is allowed to access xActiveTimerList. */
\r
99 PRIVILEGED_DATA static xList xActiveTimerList1;
\r
100 PRIVILEGED_DATA static xList xActiveTimerList2;
\r
101 PRIVILEGED_DATA static xList *pxCurrentTimerList;
\r
102 PRIVILEGED_DATA static xList *pxOverflowTimerList;
\r
104 /* A queue that is used to send commands to the timer service task. */
\r
105 PRIVILEGED_DATA static xQueueHandle xTimerQueue = NULL;
\r
107 /*-----------------------------------------------------------*/
\r
110 * Initialise the infrastructure used by the timer service task if it has not
\r
111 * been initialised already.
\r
113 static void prvCheckForValidListAndQueue( void ) PRIVILEGED_FUNCTION;
\r
116 * The timer service task (daemon). Timer functionality is controlled by this
\r
117 * task. Other tasks communicate with the timer service task using the
\r
118 * xTimerQueue queue.
\r
120 static void prvTimerTask( void *pvParameters ) PRIVILEGED_FUNCTION;
\r
123 * Called by the timer service task to interpret and process a command it
\r
124 * received on the timer queue.
\r
126 static void prvProcessReceivedCommands( void ) PRIVILEGED_FUNCTION;
\r
129 * Insert the timer into either xActiveTimerList1, or xActiveTimerList2,
\r
130 * depending on if the expire time causes a timer counter overflow.
\r
132 static portBASE_TYPE prvInsertTimerInActiveList( xTIMER *pxTimer, portTickType xNextExpiryTime, portTickType xTimeNow, portTickType xCommandTime ) PRIVILEGED_FUNCTION;
\r
135 * An active timer has reached its expire time. Reload the timer if it is an
\r
136 * auto reload timer, then call its callback.
\r
138 static void prvProcessExpiredTimer( portTickType xNextExpireTime, portTickType xTimeNow ) PRIVILEGED_FUNCTION;
\r
141 * The tick count has overflowed. Switch the timer lists after ensuring the
\r
142 * current timer list does not still reference some timers.
\r
144 static void prvSwitchTimerLists( portTickType xLastTime ) PRIVILEGED_FUNCTION;
\r
147 * Obtain the current tick count, setting *pxTimerListsWereSwitched to pdTRUE
\r
148 * if a tick count overflow occurred since prvSampleTimeNow() was last called.
\r
150 static portTickType prvSampleTimeNow( portBASE_TYPE *pxTimerListsWereSwitched ) PRIVILEGED_FUNCTION;
\r
153 * If the timer list contains any active timers then return the expire time of
\r
154 * the timer that will expire first and set *pxListWasEmpty to false. If the
\r
155 * timer list does not contain any timers then return 0 and set *pxListWasEmpty
\r
158 static portTickType prvGetNextExpireTime( portBASE_TYPE *pxListWasEmpty ) PRIVILEGED_FUNCTION;
\r
161 * If a timer has expired, process it. Otherwise, block the timer service task
\r
162 * until either a timer does expire or a command is received.
\r
164 static void prvProcessTimerOrBlockTask( portTickType xNextExpireTime, portBASE_TYPE xListWasEmpty ) PRIVILEGED_FUNCTION;
\r
166 /*-----------------------------------------------------------*/
\r
168 portBASE_TYPE xTimerCreateTimerTask( void )
\r
170 portBASE_TYPE xReturn = pdFAIL;
\r
172 /* This function is called when the scheduler is started if
\r
173 configUSE_TIMERS is set to 1. Check that the infrastructure used by the
\r
174 timer service task has been created/initialised. If timers have already
\r
175 been created then the initialisation will already have been performed. */
\r
176 prvCheckForValidListAndQueue();
\r
178 if( xTimerQueue != NULL )
\r
180 xReturn = xTaskCreate( prvTimerTask, ( const signed char * ) "Tmr Svc", configTIMER_TASK_STACK_DEPTH, NULL, configTIMER_TASK_PRIORITY, NULL);
\r
185 /*-----------------------------------------------------------*/
\r
187 xTimerHandle xTimerCreate( const signed char *pcTimerName, portTickType xTimerPeriodInTicks, unsigned portBASE_TYPE uxAutoReload, void *pvTimerID, tmrTIMER_CALLBACK pxCallbackFunction )
\r
189 xTIMER *pxNewTimer;
\r
191 /* Allocate the timer structure. */
\r
192 if( xTimerPeriodInTicks == ( portTickType ) 0U )
\r
195 configASSERT( ( xTimerPeriodInTicks > 0 ) );
\r
199 pxNewTimer = ( xTIMER * ) pvPortMalloc( sizeof( xTIMER ) );
\r
200 if( pxNewTimer != NULL )
\r
202 /* Ensure the infrastructure used by the timer service task has been
\r
203 created/initialised. */
\r
204 prvCheckForValidListAndQueue();
\r
206 configASSERT( ( xTimerPeriodInTicks > 0 ) );
\r
208 /* Initialise the timer structure members using the function parameters. */
\r
209 pxNewTimer->pcTimerName = pcTimerName;
\r
210 pxNewTimer->xTimerPeriodInTicks = xTimerPeriodInTicks;
\r
211 pxNewTimer->uxAutoReload = uxAutoReload;
\r
212 pxNewTimer->pvTimerID = pvTimerID;
\r
213 pxNewTimer->pxCallbackFunction = pxCallbackFunction;
\r
214 vListInitialiseItem( &( pxNewTimer->xTimerListItem ) );
\r
218 return ( xTimerHandle ) pxNewTimer;
\r
220 /*-----------------------------------------------------------*/
\r
222 portBASE_TYPE xTimerGenericCommand( xTimerHandle xTimer, portBASE_TYPE xCommandID, portTickType xOptionalValue, portBASE_TYPE *pxHigherPriorityTaskWoken, portTickType xBlockTime )
\r
224 portBASE_TYPE xReturn = pdFAIL;
\r
225 xTIMER_MESSAGE xMessage;
\r
227 /* Send a message to the timer service task to perform a particular action
\r
228 on a particular timer definition. */
\r
229 if( xTimerQueue != NULL )
\r
231 /* Send a command to the timer service task to start the xTimer timer. */
\r
232 xMessage.xMessageID = xCommandID;
\r
233 xMessage.xMessageValue = xOptionalValue;
\r
234 xMessage.pxTimer = ( xTIMER * ) xTimer;
\r
236 if( pxHigherPriorityTaskWoken == NULL )
\r
238 if( xTaskGetSchedulerState() == taskSCHEDULER_RUNNING )
\r
240 xReturn = xQueueSendToBack( xTimerQueue, &xMessage, xBlockTime );
\r
244 xReturn = xQueueSendToBack( xTimerQueue, &xMessage, tmrNO_DELAY );
\r
249 xReturn = xQueueSendToBackFromISR( xTimerQueue, &xMessage, pxHigherPriorityTaskWoken );
\r
255 /*-----------------------------------------------------------*/
\r
257 static void prvProcessExpiredTimer( portTickType xNextExpireTime, portTickType xTimeNow )
\r
260 portBASE_TYPE xResult;
\r
262 /* Remove the timer from the list of active timers. A check has already
\r
263 been performed to ensure the list is not empty. */
\r
264 pxTimer = ( xTIMER * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList );
\r
265 vListRemove( &( pxTimer->xTimerListItem ) );
\r
267 /* If the timer is an auto reload timer then calculate the next
\r
268 expiry time and re-insert the timer in the list of active timers. */
\r
269 if( pxTimer->uxAutoReload == pdTRUE )
\r
271 /* This is the only time a timer is inserted into a list using
\r
272 a time relative to anything other than the current time. It
\r
273 will therefore be inserted into the correct list relative to
\r
274 the time this task thinks it is now, even if a command to
\r
275 switch lists due to a tick count overflow is already waiting in
\r
276 the timer queue. */
\r
277 if( prvInsertTimerInActiveList( pxTimer, ( xNextExpireTime + pxTimer->xTimerPeriodInTicks ), xTimeNow, xNextExpireTime ) == pdTRUE )
\r
279 /* The timer expired before it was added to the active timer
\r
280 list. Reload it now. */
\r
281 xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xNextExpireTime, NULL, tmrNO_DELAY );
\r
282 configASSERT( xResult );
\r
287 /* Call the timer callback. */
\r
288 pxTimer->pxCallbackFunction( ( xTimerHandle ) pxTimer );
\r
290 /*-----------------------------------------------------------*/
\r
292 static void prvTimerTask( void *pvParameters )
\r
294 portTickType xNextExpireTime;
\r
295 portBASE_TYPE xListWasEmpty;
\r
297 /* Just to avoid compiler warnings. */
\r
298 ( void ) pvParameters;
\r
302 /* Query the timers list to see if it contains any timers, and if so,
\r
303 obtain the time at which the next timer will expire. */
\r
304 xNextExpireTime = prvGetNextExpireTime( &xListWasEmpty );
\r
306 /* If a timer has expired, process it. Otherwise, block this task
\r
307 until either a timer does expire, or a command is received. */
\r
308 prvProcessTimerOrBlockTask( xNextExpireTime, xListWasEmpty );
\r
310 /* Empty the command queue. */
\r
311 prvProcessReceivedCommands();
\r
314 /*-----------------------------------------------------------*/
\r
316 static void prvProcessTimerOrBlockTask( portTickType xNextExpireTime, portBASE_TYPE xListWasEmpty )
\r
318 portTickType xTimeNow;
\r
319 portBASE_TYPE xTimerListsWereSwitched;
\r
323 /* Obtain the time now to make an assessment as to whether the timer
\r
324 has expired or not. If obtaining the time causes the lists to switch
\r
325 then don't process this timer as any timers that remained in the list
\r
326 when the lists were switched will have been processed within the
\r
327 prvSampelTimeNow() function. */
\r
328 xTimeNow = prvSampleTimeNow( &xTimerListsWereSwitched );
\r
329 if( xTimerListsWereSwitched == pdFALSE )
\r
331 /* The tick count has not overflowed, has the timer expired? */
\r
332 if( ( xListWasEmpty == pdFALSE ) && ( xNextExpireTime <= xTimeNow ) )
\r
335 prvProcessExpiredTimer( xNextExpireTime, xTimeNow );
\r
339 /* The tick count has not overflowed, and the next expire
\r
340 time has not been reached yet. This task should therefore
\r
341 block to wait for the next expire time or a command to be
\r
342 received - whichever comes first. The following line cannot
\r
343 be reached unless xNextExpireTime > xTimeNow, except in the
\r
344 case when the current timer list is empty. */
\r
345 vQueueWaitForMessageRestricted( xTimerQueue, ( xNextExpireTime - xTimeNow ) );
\r
347 if( xTaskResumeAll() == pdFALSE )
\r
349 /* Yield to wait for either a command to arrive, or the block time
\r
350 to expire. If a command arrived between the critical section being
\r
351 exited and this yield then the yield will not cause the task
\r
353 portYIELD_WITHIN_API();
\r
363 /*-----------------------------------------------------------*/
\r
365 static portTickType prvGetNextExpireTime( portBASE_TYPE *pxListWasEmpty )
\r
367 portTickType xNextExpireTime;
\r
369 /* Timers are listed in expiry time order, with the head of the list
\r
370 referencing the task that will expire first. Obtain the time at which
\r
371 the timer with the nearest expiry time will expire. If there are no
\r
372 active timers then just set the next expire time to 0. That will cause
\r
373 this task to unblock when the tick count overflows, at which point the
\r
374 timer lists will be switched and the next expiry time can be
\r
376 *pxListWasEmpty = listLIST_IS_EMPTY( pxCurrentTimerList );
\r
377 if( *pxListWasEmpty == pdFALSE )
\r
379 xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList );
\r
383 /* Ensure the task unblocks when the tick count rolls over. */
\r
384 xNextExpireTime = ( portTickType ) 0U;
\r
387 return xNextExpireTime;
\r
389 /*-----------------------------------------------------------*/
\r
391 static portTickType prvSampleTimeNow( portBASE_TYPE *pxTimerListsWereSwitched )
\r
393 portTickType xTimeNow;
\r
394 static portTickType xLastTime = ( portTickType ) 0U;
\r
396 xTimeNow = xTaskGetTickCount();
\r
398 if( xTimeNow < xLastTime )
\r
400 prvSwitchTimerLists( xLastTime );
\r
401 *pxTimerListsWereSwitched = pdTRUE;
\r
405 *pxTimerListsWereSwitched = pdFALSE;
\r
408 xLastTime = xTimeNow;
\r
412 /*-----------------------------------------------------------*/
\r
414 static portBASE_TYPE prvInsertTimerInActiveList( xTIMER *pxTimer, portTickType xNextExpiryTime, portTickType xTimeNow, portTickType xCommandTime )
\r
416 portBASE_TYPE xProcessTimerNow = pdFALSE;
\r
418 listSET_LIST_ITEM_VALUE( &( pxTimer->xTimerListItem ), xNextExpiryTime );
\r
419 listSET_LIST_ITEM_OWNER( &( pxTimer->xTimerListItem ), pxTimer );
\r
421 if( xNextExpiryTime <= xTimeNow )
\r
423 /* Has the expiry time elapsed between the command to start/reset a
\r
424 timer was issued, and the time the command was processed? */
\r
425 if( ( ( portTickType ) ( xTimeNow - xCommandTime ) ) >= pxTimer->xTimerPeriodInTicks )
\r
427 /* The time between a command being issued and the command being
\r
428 processed actually exceeds the timers period. */
\r
429 xProcessTimerNow = pdTRUE;
\r
433 vListInsert( pxOverflowTimerList, &( pxTimer->xTimerListItem ) );
\r
438 if( ( xTimeNow < xCommandTime ) && ( xNextExpiryTime >= xCommandTime ) )
\r
440 /* If, since the command was issued, the tick count has overflowed
\r
441 but the expiry time has not, then the timer must have already passed
\r
442 its expiry time and should be processed immediately. */
\r
443 xProcessTimerNow = pdTRUE;
\r
447 vListInsert( pxCurrentTimerList, &( pxTimer->xTimerListItem ) );
\r
451 return xProcessTimerNow;
\r
453 /*-----------------------------------------------------------*/
\r
455 static void prvProcessReceivedCommands( void )
\r
457 xTIMER_MESSAGE xMessage;
\r
459 portBASE_TYPE xTimerListsWereSwitched, xResult;
\r
460 portTickType xTimeNow;
\r
462 /* In this case the xTimerListsWereSwitched parameter is not used, but it
\r
463 must be present in the function call. */
\r
464 xTimeNow = prvSampleTimeNow( &xTimerListsWereSwitched );
\r
466 while( xQueueReceive( xTimerQueue, &xMessage, tmrNO_DELAY ) != pdFAIL )
\r
468 pxTimer = xMessage.pxTimer;
\r
470 /* Is the timer already in a list of active timers? When the command
\r
471 is trmCOMMAND_PROCESS_TIMER_OVERFLOW, the timer will be NULL as the
\r
472 command is to the task rather than to an individual timer. */
\r
473 if( pxTimer != NULL )
\r
475 if( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) == pdFALSE )
\r
477 /* The timer is in a list, remove it. */
\r
478 vListRemove( &( pxTimer->xTimerListItem ) );
\r
482 switch( xMessage.xMessageID )
\r
484 case tmrCOMMAND_START :
\r
485 /* Start or restart a timer. */
\r
486 if( prvInsertTimerInActiveList( pxTimer, xMessage.xMessageValue + pxTimer->xTimerPeriodInTicks, xTimeNow, xMessage.xMessageValue ) == pdTRUE )
\r
488 /* The timer expired before it was added to the active timer
\r
489 list. Process it now. */
\r
490 pxTimer->pxCallbackFunction( ( xTimerHandle ) pxTimer );
\r
492 if( pxTimer->uxAutoReload == pdTRUE )
\r
494 xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xMessage.xMessageValue + pxTimer->xTimerPeriodInTicks, NULL, tmrNO_DELAY );
\r
495 configASSERT( xResult );
\r
501 case tmrCOMMAND_STOP :
\r
502 /* The timer has already been removed from the active list.
\r
503 There is nothing to do here. */
\r
506 case tmrCOMMAND_CHANGE_PERIOD :
\r
507 pxTimer->xTimerPeriodInTicks = xMessage.xMessageValue;
\r
508 configASSERT( ( pxTimer->xTimerPeriodInTicks > 0 ) );
\r
509 prvInsertTimerInActiveList( pxTimer, ( xTimeNow + pxTimer->xTimerPeriodInTicks ), xTimeNow, xTimeNow );
\r
512 case tmrCOMMAND_DELETE :
\r
513 /* The timer has already been removed from the active list,
\r
514 just free up the memory. */
\r
515 vPortFree( pxTimer );
\r
519 /* Don't expect to get here. */
\r
524 /*-----------------------------------------------------------*/
\r
526 static void prvSwitchTimerLists( portTickType xLastTime )
\r
528 portTickType xNextExpireTime, xReloadTime;
\r
531 portBASE_TYPE xResult;
\r
533 /* Remove compiler warnings if configASSERT() is not defined. */
\r
534 ( void ) xLastTime;
\r
536 /* The tick count has overflowed. The timer lists must be switched.
\r
537 If there are any timers still referenced from the current timer list
\r
538 then they must have expired and should be processed before the lists
\r
540 while( listLIST_IS_EMPTY( pxCurrentTimerList ) == pdFALSE )
\r
542 xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList );
\r
544 /* Remove the timer from the list. */
\r
545 pxTimer = ( xTIMER * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList );
\r
546 vListRemove( &( pxTimer->xTimerListItem ) );
\r
548 /* Execute its callback, then send a command to restart the timer if
\r
549 it is an auto-reload timer. It cannot be restarted here as the lists
\r
550 have not yet been switched. */
\r
551 pxTimer->pxCallbackFunction( ( xTimerHandle ) pxTimer );
\r
553 if( pxTimer->uxAutoReload == pdTRUE )
\r
555 /* Calculate the reload value, and if the reload value results in
\r
556 the timer going into the same timer list then it has already expired
\r
557 and the timer should be re-inserted into the current list so it is
\r
558 processed again within this loop. Otherwise a command should be sent
\r
559 to restart the timer to ensure it is only inserted into a list after
\r
560 the lists have been swapped. */
\r
561 xReloadTime = ( xNextExpireTime + pxTimer->xTimerPeriodInTicks );
\r
562 if( xReloadTime > xNextExpireTime )
\r
564 listSET_LIST_ITEM_VALUE( &( pxTimer->xTimerListItem ), xReloadTime );
\r
565 listSET_LIST_ITEM_OWNER( &( pxTimer->xTimerListItem ), pxTimer );
\r
566 vListInsert( pxCurrentTimerList, &( pxTimer->xTimerListItem ) );
\r
570 xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xNextExpireTime, NULL, tmrNO_DELAY );
\r
571 configASSERT( xResult );
\r
577 pxTemp = pxCurrentTimerList;
\r
578 pxCurrentTimerList = pxOverflowTimerList;
\r
579 pxOverflowTimerList = pxTemp;
\r
581 /*-----------------------------------------------------------*/
\r
583 static void prvCheckForValidListAndQueue( void )
\r
585 /* Check that the list from which active timers are referenced, and the
\r
586 queue used to communicate with the timer service, have been
\r
588 taskENTER_CRITICAL();
\r
590 if( xTimerQueue == NULL )
\r
592 vListInitialise( &xActiveTimerList1 );
\r
593 vListInitialise( &xActiveTimerList2 );
\r
594 pxCurrentTimerList = &xActiveTimerList1;
\r
595 pxOverflowTimerList = &xActiveTimerList2;
\r
596 xTimerQueue = xQueueCreate( configTIMER_QUEUE_LENGTH, sizeof( xTIMER_MESSAGE ) );
\r
599 taskEXIT_CRITICAL();
\r
601 /*-----------------------------------------------------------*/
\r
603 portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer )
\r
605 portBASE_TYPE xTimerIsInActiveList;
\r
606 xTIMER *pxTimer = ( xTIMER * ) xTimer;
\r
608 /* Is the timer in the list of active timers? */
\r
609 taskENTER_CRITICAL();
\r
611 /* Checking to see if it is in the NULL list in effect checks to see if
\r
612 it is referenced from either the current or the overflow timer lists in
\r
613 one go, but the logic has to be reversed, hence the '!'. */
\r
614 xTimerIsInActiveList = !( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) );
\r
616 taskEXIT_CRITICAL();
\r
618 return xTimerIsInActiveList;
\r
620 /*-----------------------------------------------------------*/
\r
622 void *pvTimerGetTimerID( xTimerHandle xTimer )
\r
624 xTIMER *pxTimer = ( xTIMER * ) xTimer;
\r
626 return pxTimer->pvTimerID;
\r
628 /*-----------------------------------------------------------*/
\r
630 /* This entire source file will be skipped if the application is not configured
\r
631 to include software timer functionality. If you want to include software timer
\r
632 functionality then ensure configUSE_TIMERS is set to 1 in FreeRTOSConfig.h. */
\r
633 #endif /* configUSE_TIMERS == 1 */
\r