2 FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
7 This file is part of the FreeRTOS distribution.
9 FreeRTOS is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License (version 2) as published by the
11 Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
13 ***************************************************************************
14 >>! NOTE: The modification to the GPL is included to allow you to !<<
15 >>! distribute a combined work that includes FreeRTOS without being !<<
16 >>! obliged to provide the source code for proprietary components !<<
17 >>! outside of the FreeRTOS kernel. !<<
18 ***************************************************************************
20 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
21 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22 FOR A PARTICULAR PURPOSE. Full license text is available on the following
23 link: http://www.freertos.org/a00114.html
25 ***************************************************************************
27 * FreeRTOS provides completely free yet professionally developed, *
28 * robust, strictly quality controlled, supported, and cross *
29 * platform software that is more than just the market leader, it *
30 * is the industry's de facto standard. *
32 * Help yourself get started quickly while simultaneously helping *
33 * to support the FreeRTOS project by purchasing a FreeRTOS *
34 * tutorial book, reference manual, or both: *
35 * http://www.FreeRTOS.org/Documentation *
37 ***************************************************************************
39 http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
40 the FAQ page "My application does not run, what could be wrong?". Have you
41 defined configASSERT()?
43 http://www.FreeRTOS.org/support - In return for receiving this top quality
44 embedded software for free we request you assist our global community by
45 participating in the support forum.
47 http://www.FreeRTOS.org/training - Investing in training allows your team to
48 be as productive as possible as early as possible. Now you can receive
49 FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
50 Ltd, and the world's leading authority on the world's leading RTOS.
52 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
53 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
54 compatible FAT file system, and our tiny thread aware UDP/IP stack.
56 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
57 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
59 http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
60 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
61 licenses offer ticketed support, indemnification and commercial middleware.
63 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
64 engineered and independently SIL3 certified version for use in safety and
65 mission critical applications that require provable dependability.
74 #ifndef INC_FREERTOS_H
75 #error "include FreeRTOS.h must appear in source files before include timers.h"
78 /*lint -e537 This headers are only multiply included if the application code
79 happens to also be including task.h. */
87 /*-----------------------------------------------------------
88 * MACROS AND DEFINITIONS
89 *----------------------------------------------------------*/
91 /* IDs for commands that can be sent/received on the timer queue. These are to
92 be used solely through the macros that make up the public software timer API,
93 as defined below. The commands that are sent from interrupts must use the
94 highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task
95 or interrupt version of the queue send function should be used. */
96 #define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 )
97 #define tmrCOMMAND_EXECUTE_CALLBACK ( ( BaseType_t ) -1 )
98 #define tmrCOMMAND_START_DONT_TRACE ( ( BaseType_t ) 0 )
99 #define tmrCOMMAND_START ( ( BaseType_t ) 1 )
100 #define tmrCOMMAND_RESET ( ( BaseType_t ) 2 )
101 #define tmrCOMMAND_STOP ( ( BaseType_t ) 3 )
102 #define tmrCOMMAND_CHANGE_PERIOD ( ( BaseType_t ) 4 )
103 #define tmrCOMMAND_DELETE ( ( BaseType_t ) 5 )
105 #define tmrFIRST_FROM_ISR_COMMAND ( ( BaseType_t ) 6 )
106 #define tmrCOMMAND_START_FROM_ISR ( ( BaseType_t ) 6 )
107 #define tmrCOMMAND_RESET_FROM_ISR ( ( BaseType_t ) 7 )
108 #define tmrCOMMAND_STOP_FROM_ISR ( ( BaseType_t ) 8 )
109 #define tmrCOMMAND_CHANGE_PERIOD_FROM_ISR ( ( BaseType_t ) 9 )
113 * Type by which software timers are referenced. For example, a call to
114 * xTimerCreate() returns an TimerHandle_t variable that can then be used to
115 * reference the subject timer in calls to other software timer API functions
116 * (for example, xTimerStart(), xTimerReset(), etc.).
118 typedef void * TimerHandle_t;
121 * Defines the prototype to which timer callback functions must conform.
123 typedef void (*TimerCallbackFunction_t)( TimerHandle_t xTimer );
126 * Defines the prototype to which functions used with the
127 * xTimerPendFunctionCallFromISR() function must conform.
129 typedef void (*PendedFunction_t)( void *, uint32_t );
132 * TimerHandle_t xTimerCreate( const char * const pcTimerName,
133 * TickType_t xTimerPeriodInTicks,
134 * UBaseType_t uxAutoReload,
136 * TimerCallbackFunction_t pxCallbackFunction );
138 * Creates a new software timer instance, and returns a handle by which the
139 * created software timer can be referenced.
141 * Internally, within the FreeRTOS implementation, software timers use a block
142 * of memory, in which the timer data structure is stored. If a software timer
143 * is created using xTimerCreate() then the required memory is automatically
144 * dynamically allocated inside the xTimerCreate() function. (see
145 * http://www.freertos.org/a00111.html). If a software timer is created using
146 * xTimerCreateStatic() then the application writer must provide the memory that
147 * will get used by the software timer. xTimerCreateStatic() therefore allows a
148 * software timer to be created without using any dynamic memory allocation.
150 * Timers are created in the dormant state. The xTimerStart(), xTimerReset(),
151 * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and
152 * xTimerChangePeriodFromISR() API functions can all be used to transition a
153 * timer into the active state.
155 * @param pcTimerName A text name that is assigned to the timer. This is done
156 * purely to assist debugging. The kernel itself only ever references a timer
157 * by its handle, and never by its name.
159 * @param xTimerPeriodInTicks The timer period. The time is defined in tick
160 * periods so the constant portTICK_PERIOD_MS can be used to convert a time that
161 * has been specified in milliseconds. For example, if the timer must expire
162 * after 100 ticks, then xTimerPeriodInTicks should be set to 100.
163 * Alternatively, if the timer must expire after 500ms, then xPeriod can be set
164 * to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or
167 * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will
168 * expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter.
169 * If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and
170 * enter the dormant state after it expires.
172 * @param pvTimerID An identifier that is assigned to the timer being created.
173 * Typically this would be used in the timer callback function to identify which
174 * timer expired when the same callback function is assigned to more than one
177 * @param pxCallbackFunction The function to call when the timer expires.
178 * Callback functions must have the prototype defined by TimerCallbackFunction_t,
179 * which is "void vCallbackFunction( TimerHandle_t xTimer );".
181 * @return If the timer is successfully created then a handle to the newly
182 * created timer is returned. If the timer cannot be created (because either
183 * there is insufficient FreeRTOS heap remaining to allocate the timer
184 * structures, or the timer period was set to 0) then NULL is returned.
188 * #define NUM_TIMERS 5
190 * // An array to hold handles to the created timers.
191 * TimerHandle_t xTimers[ NUM_TIMERS ];
193 * // An array to hold a count of the number of times each timer expires.
194 * int32_t lExpireCounters[ NUM_TIMERS ] = { 0 };
196 * // Define a callback function that will be used by multiple timer instances.
197 * // The callback function does nothing but count the number of times the
198 * // associated timer expires, and stop the timer once the timer has expired
200 * void vTimerCallback( TimerHandle_t pxTimer )
202 * int32_t lArrayIndex;
203 * const int32_t xMaxExpiryCountBeforeStopping = 10;
205 * // Optionally do something if the pxTimer parameter is NULL.
206 * configASSERT( pxTimer );
208 * // Which timer expired?
209 * lArrayIndex = ( int32_t ) pvTimerGetTimerID( pxTimer );
211 * // Increment the number of times that pxTimer has expired.
212 * lExpireCounters[ lArrayIndex ] += 1;
214 * // If the timer has expired 10 times then stop it from running.
215 * if( lExpireCounters[ lArrayIndex ] == xMaxExpiryCountBeforeStopping )
217 * // Do not use a block time if calling a timer API function from a
218 * // timer callback function, as doing so could cause a deadlock!
219 * xTimerStop( pxTimer, 0 );
227 * // Create then start some timers. Starting the timers before the scheduler
228 * // has been started means the timers will start running immediately that
229 * // the scheduler starts.
230 * for( x = 0; x < NUM_TIMERS; x++ )
232 * xTimers[ x ] = xTimerCreate( "Timer", // Just a text name, not used by the kernel.
233 * ( 100 * x ), // The timer period in ticks.
234 * pdTRUE, // The timers will auto-reload themselves when they expire.
235 * ( void * ) x, // Assign each timer a unique id equal to its array index.
236 * vTimerCallback // Each timer calls the same callback when it expires.
239 * if( xTimers[ x ] == NULL )
241 * // The timer was not created.
245 * // Start the timer. No block time is specified, and even if one was
246 * // it would be ignored because the scheduler has not yet been
248 * if( xTimerStart( xTimers[ x ], 0 ) != pdPASS )
250 * // The timer could not be set into the Active state.
256 * // Create tasks here.
259 * // Starting the scheduler will start the timers running as they have already
260 * // been set into the active state.
261 * vTaskStartScheduler();
263 * // Should not reach here.
268 #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
269 TimerHandle_t xTimerCreate( const char * const pcTimerName,
270 const TickType_t xTimerPeriodInTicks,
271 const UBaseType_t uxAutoReload,
272 void * const pvTimerID,
273 TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
277 * TimerHandle_t xTimerCreateStatic(const char * const pcTimerName,
278 * TickType_t xTimerPeriodInTicks,
279 * UBaseType_t uxAutoReload,
281 * TimerCallbackFunction_t pxCallbackFunction,
282 * StaticTimer_t *pxTimerBuffer );
284 * Creates a new software timer instance, and returns a handle by which the
285 * created software timer can be referenced.
287 * Internally, within the FreeRTOS implementation, software timers use a block
288 * of memory, in which the timer data structure is stored. If a software timer
289 * is created using xTimerCreate() then the required memory is automatically
290 * dynamically allocated inside the xTimerCreate() function. (see
291 * http://www.freertos.org/a00111.html). If a software timer is created using
292 * xTimerCreateStatic() then the application writer must provide the memory that
293 * will get used by the software timer. xTimerCreateStatic() therefore allows a
294 * software timer to be created without using any dynamic memory allocation.
296 * Timers are created in the dormant state. The xTimerStart(), xTimerReset(),
297 * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and
298 * xTimerChangePeriodFromISR() API functions can all be used to transition a
299 * timer into the active state.
301 * @param pcTimerName A text name that is assigned to the timer. This is done
302 * purely to assist debugging. The kernel itself only ever references a timer
303 * by its handle, and never by its name.
305 * @param xTimerPeriodInTicks The timer period. The time is defined in tick
306 * periods so the constant portTICK_PERIOD_MS can be used to convert a time that
307 * has been specified in milliseconds. For example, if the timer must expire
308 * after 100 ticks, then xTimerPeriodInTicks should be set to 100.
309 * Alternatively, if the timer must expire after 500ms, then xPeriod can be set
310 * to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or
313 * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will
314 * expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter.
315 * If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and
316 * enter the dormant state after it expires.
318 * @param pvTimerID An identifier that is assigned to the timer being created.
319 * Typically this would be used in the timer callback function to identify which
320 * timer expired when the same callback function is assigned to more than one
323 * @param pxCallbackFunction The function to call when the timer expires.
324 * Callback functions must have the prototype defined by TimerCallbackFunction_t,
325 * which is "void vCallbackFunction( TimerHandle_t xTimer );".
327 * @param pxTimerBuffer Must point to a variable of type StaticTimer_t, which
328 * will be then be used to hold the software timer's data structures, removing
329 * the need for the memory to be allocated dynamically.
331 * @return If the timer is created then a handle to the created timer is
332 * returned. If pxTimerBuffer was NULL then NULL is returned.
337 * // The buffer used to hold the software timer's data structure.
338 * static StaticTimer_t xTimerBuffer;
340 * // A variable that will be incremented by the software timer's callback
342 * UBaseType_t uxVariableToIncrement = 0;
344 * // A software timer callback function that increments a variable passed to
345 * // it when the software timer was created. After the 5th increment the
346 * // callback function stops the software timer.
347 * static void prvTimerCallback( TimerHandle_t xExpiredTimer )
349 * UBaseType_t *puxVariableToIncrement;
350 * BaseType_t xReturned;
352 * // Obtain the address of the variable to increment from the timer ID.
353 * puxVariableToIncrement = ( UBaseType_t * ) pvTimerGetTimerID( xExpiredTimer );
355 * // Increment the variable to show the timer callback has executed.
356 * ( *puxVariableToIncrement )++;
358 * // If this callback has executed the required number of times, stop the
360 * if( *puxVariableToIncrement == 5 )
362 * // This is called from a timer callback so must not block.
363 * xTimerStop( xExpiredTimer, staticDONT_BLOCK );
370 * // Create the software time. xTimerCreateStatic() has an extra parameter
371 * // than the normal xTimerCreate() API function. The parameter is a pointer
372 * // to the StaticTimer_t structure that will hold the software timer
373 * // structure. If the parameter is passed as NULL then the structure will be
374 * // allocated dynamically, just as if xTimerCreate() had been called.
375 * xTimer = xTimerCreateStatic( "T1", // Text name for the task. Helps debugging only. Not used by FreeRTOS.
376 * xTimerPeriod, // The period of the timer in ticks.
377 * pdTRUE, // This is an auto-reload timer.
378 * ( void * ) &uxVariableToIncrement, // A variable incremented by the software timer's callback function
379 * prvTimerCallback, // The function to execute when the timer expires.
380 * &xTimerBuffer ); // The buffer that will hold the software timer structure.
382 * // The scheduler has not started yet so a block time is not used.
383 * xReturned = xTimerStart( xTimer, 0 );
386 * // Create tasks here.
389 * // Starting the scheduler will start the timers running as they have already
390 * // been set into the active state.
391 * vTaskStartScheduler();
393 * // Should not reach here.
398 #if( configSUPPORT_STATIC_ALLOCATION == 1 )
399 TimerHandle_t xTimerCreateStatic( const char * const pcTimerName,
400 const TickType_t xTimerPeriodInTicks,
401 const UBaseType_t uxAutoReload,
402 void * const pvTimerID,
403 TimerCallbackFunction_t pxCallbackFunction,
404 StaticTimer_t *pxTimerBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
405 #endif /* configSUPPORT_STATIC_ALLOCATION */
408 * void *pvTimerGetTimerID( TimerHandle_t xTimer );
410 * Returns the ID assigned to the timer.
412 * IDs are assigned to timers using the pvTimerID parameter of the call to
413 * xTimerCreated() that was used to create the timer, and by calling the
414 * vTimerSetTimerID() API function.
416 * If the same callback function is assigned to multiple timers then the timer
417 * ID can be used as time specific (timer local) storage.
419 * @param xTimer The timer being queried.
421 * @return The ID assigned to the timer being queried.
425 * See the xTimerCreate() API function example usage scenario.
427 void *pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
430 * void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID );
432 * Sets the ID assigned to the timer.
434 * IDs are assigned to timers using the pvTimerID parameter of the call to
435 * xTimerCreated() that was used to create the timer.
437 * If the same callback function is assigned to multiple timers then the timer
438 * ID can be used as time specific (timer local) storage.
440 * @param xTimer The timer being updated.
442 * @param pvNewID The ID to assign to the timer.
446 * See the xTimerCreate() API function example usage scenario.
448 void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION;
451 * BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer );
453 * Queries a timer to see if it is active or dormant.
455 * A timer will be dormant if:
456 * 1) It has been created but not started, or
457 * 2) It is an expired one-shot timer that has not been restarted.
459 * Timers are created in the dormant state. The xTimerStart(), xTimerReset(),
460 * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and
461 * xTimerChangePeriodFromISR() API functions can all be used to transition a timer into the
464 * @param xTimer The timer being queried.
466 * @return pdFALSE will be returned if the timer is dormant. A value other than
467 * pdFALSE will be returned if the timer is active.
471 * // This function assumes xTimer has already been created.
472 * void vAFunction( TimerHandle_t xTimer )
474 * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )"
476 * // xTimer is active, do something.
480 * // xTimer is not active, do something else.
485 BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
488 * TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
490 * Simply returns the handle of the timer service/daemon task. It it not valid
491 * to call xTimerGetTimerDaemonTaskHandle() before the scheduler has been started.
493 TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
496 * BaseType_t xTimerStart( TimerHandle_t xTimer, TickType_t xTicksToWait );
498 * Timer functionality is provided by a timer service/daemon task. Many of the
499 * public FreeRTOS timer API functions send commands to the timer service task
500 * through a queue called the timer command queue. The timer command queue is
501 * private to the kernel itself and is not directly accessible to application
502 * code. The length of the timer command queue is set by the
503 * configTIMER_QUEUE_LENGTH configuration constant.
505 * xTimerStart() starts a timer that was previously created using the
506 * xTimerCreate() API function. If the timer had already been started and was
507 * already in the active state, then xTimerStart() has equivalent functionality
508 * to the xTimerReset() API function.
510 * Starting a timer ensures the timer is in the active state. If the timer
511 * is not stopped, deleted, or reset in the mean time, the callback function
512 * associated with the timer will get called 'n' ticks after xTimerStart() was
513 * called, where 'n' is the timers defined period.
515 * It is valid to call xTimerStart() before the scheduler has been started, but
516 * when this is done the timer will not actually start until the scheduler is
517 * started, and the timers expiry time will be relative to when the scheduler is
518 * started, not relative to when xTimerStart() was called.
520 * The configUSE_TIMERS configuration constant must be set to 1 for xTimerStart()
523 * @param xTimer The handle of the timer being started/restarted.
525 * @param xTicksToWait Specifies the time, in ticks, that the calling task should
526 * be held in the Blocked state to wait for the start command to be successfully
527 * sent to the timer command queue, should the queue already be full when
528 * xTimerStart() was called. xTicksToWait is ignored if xTimerStart() is called
529 * before the scheduler is started.
531 * @return pdFAIL will be returned if the start command could not be sent to
532 * the timer command queue even after xTicksToWait ticks had passed. pdPASS will
533 * be returned if the command was successfully sent to the timer command queue.
534 * When the command is actually processed will depend on the priority of the
535 * timer service/daemon task relative to other tasks in the system, although the
536 * timers expiry time is relative to when xTimerStart() is actually called. The
537 * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY
538 * configuration constant.
542 * See the xTimerCreate() API function example usage scenario.
545 #define xTimerStart( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) )
548 * BaseType_t xTimerStop( TimerHandle_t xTimer, TickType_t xTicksToWait );
550 * Timer functionality is provided by a timer service/daemon task. Many of the
551 * public FreeRTOS timer API functions send commands to the timer service task
552 * through a queue called the timer command queue. The timer command queue is
553 * private to the kernel itself and is not directly accessible to application
554 * code. The length of the timer command queue is set by the
555 * configTIMER_QUEUE_LENGTH configuration constant.
557 * xTimerStop() stops a timer that was previously started using either of the
558 * The xTimerStart(), xTimerReset(), xTimerStartFromISR(), xTimerResetFromISR(),
559 * xTimerChangePeriod() or xTimerChangePeriodFromISR() API functions.
561 * Stopping a timer ensures the timer is not in the active state.
563 * The configUSE_TIMERS configuration constant must be set to 1 for xTimerStop()
566 * @param xTimer The handle of the timer being stopped.
568 * @param xTicksToWait Specifies the time, in ticks, that the calling task should
569 * be held in the Blocked state to wait for the stop command to be successfully
570 * sent to the timer command queue, should the queue already be full when
571 * xTimerStop() was called. xTicksToWait is ignored if xTimerStop() is called
572 * before the scheduler is started.
574 * @return pdFAIL will be returned if the stop command could not be sent to
575 * the timer command queue even after xTicksToWait ticks had passed. pdPASS will
576 * be returned if the command was successfully sent to the timer command queue.
577 * When the command is actually processed will depend on the priority of the
578 * timer service/daemon task relative to other tasks in the system. The timer
579 * service/daemon task priority is set by the configTIMER_TASK_PRIORITY
580 * configuration constant.
584 * See the xTimerCreate() API function example usage scenario.
587 #define xTimerStop( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xTicksToWait ) )
590 * BaseType_t xTimerChangePeriod( TimerHandle_t xTimer,
591 * TickType_t xNewPeriod,
592 * TickType_t xTicksToWait );
594 * Timer functionality is provided by a timer service/daemon task. Many of the
595 * public FreeRTOS timer API functions send commands to the timer service task
596 * through a queue called the timer command queue. The timer command queue is
597 * private to the kernel itself and is not directly accessible to application
598 * code. The length of the timer command queue is set by the
599 * configTIMER_QUEUE_LENGTH configuration constant.
601 * xTimerChangePeriod() changes the period of a timer that was previously
602 * created using the xTimerCreate() API function.
604 * xTimerChangePeriod() can be called to change the period of an active or
605 * dormant state timer.
607 * The configUSE_TIMERS configuration constant must be set to 1 for
608 * xTimerChangePeriod() to be available.
610 * @param xTimer The handle of the timer that is having its period changed.
612 * @param xNewPeriod The new period for xTimer. Timer periods are specified in
613 * tick periods, so the constant portTICK_PERIOD_MS can be used to convert a time
614 * that has been specified in milliseconds. For example, if the timer must
615 * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively,
616 * if the timer must expire after 500ms, then xNewPeriod can be set to
617 * ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than
620 * @param xTicksToWait Specifies the time, in ticks, that the calling task should
621 * be held in the Blocked state to wait for the change period command to be
622 * successfully sent to the timer command queue, should the queue already be
623 * full when xTimerChangePeriod() was called. xTicksToWait is ignored if
624 * xTimerChangePeriod() is called before the scheduler is started.
626 * @return pdFAIL will be returned if the change period command could not be
627 * sent to the timer command queue even after xTicksToWait ticks had passed.
628 * pdPASS will be returned if the command was successfully sent to the timer
629 * command queue. When the command is actually processed will depend on the
630 * priority of the timer service/daemon task relative to other tasks in the
631 * system. The timer service/daemon task priority is set by the
632 * configTIMER_TASK_PRIORITY configuration constant.
636 * // This function assumes xTimer has already been created. If the timer
637 * // referenced by xTimer is already active when it is called, then the timer
638 * // is deleted. If the timer referenced by xTimer is not active when it is
639 * // called, then the period of the timer is set to 500ms and the timer is
641 * void vAFunction( TimerHandle_t xTimer )
643 * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )"
645 * // xTimer is already active - delete it.
646 * xTimerDelete( xTimer );
650 * // xTimer is not active, change its period to 500ms. This will also
651 * // cause the timer to start. Block for a maximum of 100 ticks if the
652 * // change period command cannot immediately be sent to the timer
654 * if( xTimerChangePeriod( xTimer, 500 / portTICK_PERIOD_MS, 100 ) == pdPASS )
656 * // The command was successfully sent.
660 * // The command could not be sent, even after waiting for 100 ticks
661 * // to pass. Take appropriate action here.
667 #define xTimerChangePeriod( xTimer, xNewPeriod, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xTicksToWait ) )
670 * BaseType_t xTimerDelete( TimerHandle_t xTimer, TickType_t xTicksToWait );
672 * Timer functionality is provided by a timer service/daemon task. Many of the
673 * public FreeRTOS timer API functions send commands to the timer service task
674 * through a queue called the timer command queue. The timer command queue is
675 * private to the kernel itself and is not directly accessible to application
676 * code. The length of the timer command queue is set by the
677 * configTIMER_QUEUE_LENGTH configuration constant.
679 * xTimerDelete() deletes a timer that was previously created using the
680 * xTimerCreate() API function.
682 * The configUSE_TIMERS configuration constant must be set to 1 for
683 * xTimerDelete() to be available.
685 * @param xTimer The handle of the timer being deleted.
687 * @param xTicksToWait Specifies the time, in ticks, that the calling task should
688 * be held in the Blocked state to wait for the delete command to be
689 * successfully sent to the timer command queue, should the queue already be
690 * full when xTimerDelete() was called. xTicksToWait is ignored if xTimerDelete()
691 * is called before the scheduler is started.
693 * @return pdFAIL will be returned if the delete command could not be sent to
694 * the timer command queue even after xTicksToWait ticks had passed. pdPASS will
695 * be returned if the command was successfully sent to the timer command queue.
696 * When the command is actually processed will depend on the priority of the
697 * timer service/daemon task relative to other tasks in the system. The timer
698 * service/daemon task priority is set by the configTIMER_TASK_PRIORITY
699 * configuration constant.
703 * See the xTimerChangePeriod() API function example usage scenario.
705 #define xTimerDelete( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xTicksToWait ) )
708 * BaseType_t xTimerReset( TimerHandle_t xTimer, TickType_t xTicksToWait );
710 * Timer functionality is provided by a timer service/daemon task. Many of the
711 * public FreeRTOS timer API functions send commands to the timer service task
712 * through a queue called the timer command queue. The timer command queue is
713 * private to the kernel itself and is not directly accessible to application
714 * code. The length of the timer command queue is set by the
715 * configTIMER_QUEUE_LENGTH configuration constant.
717 * xTimerReset() re-starts a timer that was previously created using the
718 * xTimerCreate() API function. If the timer had already been started and was
719 * already in the active state, then xTimerReset() will cause the timer to
720 * re-evaluate its expiry time so that it is relative to when xTimerReset() was
721 * called. If the timer was in the dormant state then xTimerReset() has
722 * equivalent functionality to the xTimerStart() API function.
724 * Resetting a timer ensures the timer is in the active state. If the timer
725 * is not stopped, deleted, or reset in the mean time, the callback function
726 * associated with the timer will get called 'n' ticks after xTimerReset() was
727 * called, where 'n' is the timers defined period.
729 * It is valid to call xTimerReset() before the scheduler has been started, but
730 * when this is done the timer will not actually start until the scheduler is
731 * started, and the timers expiry time will be relative to when the scheduler is
732 * started, not relative to when xTimerReset() was called.
734 * The configUSE_TIMERS configuration constant must be set to 1 for xTimerReset()
737 * @param xTimer The handle of the timer being reset/started/restarted.
739 * @param xTicksToWait Specifies the time, in ticks, that the calling task should
740 * be held in the Blocked state to wait for the reset command to be successfully
741 * sent to the timer command queue, should the queue already be full when
742 * xTimerReset() was called. xTicksToWait is ignored if xTimerReset() is called
743 * before the scheduler is started.
745 * @return pdFAIL will be returned if the reset command could not be sent to
746 * the timer command queue even after xTicksToWait ticks had passed. pdPASS will
747 * be returned if the command was successfully sent to the timer command queue.
748 * When the command is actually processed will depend on the priority of the
749 * timer service/daemon task relative to other tasks in the system, although the
750 * timers expiry time is relative to when xTimerStart() is actually called. The
751 * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY
752 * configuration constant.
756 * // When a key is pressed, an LCD back-light is switched on. If 5 seconds pass
757 * // without a key being pressed, then the LCD back-light is switched off. In
758 * // this case, the timer is a one-shot timer.
760 * TimerHandle_t xBacklightTimer = NULL;
762 * // The callback function assigned to the one-shot timer. In this case the
763 * // parameter is not used.
764 * void vBacklightTimerCallback( TimerHandle_t pxTimer )
766 * // The timer expired, therefore 5 seconds must have passed since a key
767 * // was pressed. Switch off the LCD back-light.
768 * vSetBacklightState( BACKLIGHT_OFF );
771 * // The key press event handler.
772 * void vKeyPressEventHandler( char cKey )
774 * // Ensure the LCD back-light is on, then reset the timer that is
775 * // responsible for turning the back-light off after 5 seconds of
776 * // key inactivity. Wait 10 ticks for the command to be successfully sent
777 * // if it cannot be sent immediately.
778 * vSetBacklightState( BACKLIGHT_ON );
779 * if( xTimerReset( xBacklightTimer, 100 ) != pdPASS )
781 * // The reset command was not executed successfully. Take appropriate
785 * // Perform the rest of the key processing here.
792 * // Create then start the one-shot timer that is responsible for turning
793 * // the back-light off if no keys are pressed within a 5 second period.
794 * xBacklightTimer = xTimerCreate( "BacklightTimer", // Just a text name, not used by the kernel.
795 * ( 5000 / portTICK_PERIOD_MS), // The timer period in ticks.
796 * pdFALSE, // The timer is a one-shot timer.
797 * 0, // The id is not used by the callback so can take any value.
798 * vBacklightTimerCallback // The callback function that switches the LCD back-light off.
801 * if( xBacklightTimer == NULL )
803 * // The timer was not created.
807 * // Start the timer. No block time is specified, and even if one was
808 * // it would be ignored because the scheduler has not yet been
810 * if( xTimerStart( xBacklightTimer, 0 ) != pdPASS )
812 * // The timer could not be set into the Active state.
817 * // Create tasks here.
820 * // Starting the scheduler will start the timer running as it has already
821 * // been set into the active state.
822 * vTaskStartScheduler();
824 * // Should not reach here.
829 #define xTimerReset( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) )
832 * BaseType_t xTimerStartFromISR( TimerHandle_t xTimer,
833 * BaseType_t *pxHigherPriorityTaskWoken );
835 * A version of xTimerStart() that can be called from an interrupt service
838 * @param xTimer The handle of the timer being started/restarted.
840 * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most
841 * of its time in the Blocked state, waiting for messages to arrive on the timer
842 * command queue. Calling xTimerStartFromISR() writes a message to the timer
843 * command queue, so has the potential to transition the timer service/daemon
844 * task out of the Blocked state. If calling xTimerStartFromISR() causes the
845 * timer service/daemon task to leave the Blocked state, and the timer service/
846 * daemon task has a priority equal to or greater than the currently executing
847 * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will
848 * get set to pdTRUE internally within the xTimerStartFromISR() function. If
849 * xTimerStartFromISR() sets this value to pdTRUE then a context switch should
850 * be performed before the interrupt exits.
852 * @return pdFAIL will be returned if the start command could not be sent to
853 * the timer command queue. pdPASS will be returned if the command was
854 * successfully sent to the timer command queue. When the command is actually
855 * processed will depend on the priority of the timer service/daemon task
856 * relative to other tasks in the system, although the timers expiry time is
857 * relative to when xTimerStartFromISR() is actually called. The timer
858 * service/daemon task priority is set by the configTIMER_TASK_PRIORITY
859 * configuration constant.
863 * // This scenario assumes xBacklightTimer has already been created. When a
864 * // key is pressed, an LCD back-light is switched on. If 5 seconds pass
865 * // without a key being pressed, then the LCD back-light is switched off. In
866 * // this case, the timer is a one-shot timer, and unlike the example given for
867 * // the xTimerReset() function, the key press event handler is an interrupt
868 * // service routine.
870 * // The callback function assigned to the one-shot timer. In this case the
871 * // parameter is not used.
872 * void vBacklightTimerCallback( TimerHandle_t pxTimer )
874 * // The timer expired, therefore 5 seconds must have passed since a key
875 * // was pressed. Switch off the LCD back-light.
876 * vSetBacklightState( BACKLIGHT_OFF );
879 * // The key press interrupt service routine.
880 * void vKeyPressEventInterruptHandler( void )
882 * BaseType_t xHigherPriorityTaskWoken = pdFALSE;
884 * // Ensure the LCD back-light is on, then restart the timer that is
885 * // responsible for turning the back-light off after 5 seconds of
886 * // key inactivity. This is an interrupt service routine so can only
887 * // call FreeRTOS API functions that end in "FromISR".
888 * vSetBacklightState( BACKLIGHT_ON );
890 * // xTimerStartFromISR() or xTimerResetFromISR() could be called here
891 * // as both cause the timer to re-calculate its expiry time.
892 * // xHigherPriorityTaskWoken was initialised to pdFALSE when it was
893 * // declared (in this function).
894 * if( xTimerStartFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS )
896 * // The start command was not executed successfully. Take appropriate
900 * // Perform the rest of the key processing here.
902 * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch
903 * // should be performed. The syntax required to perform a context switch
904 * // from inside an ISR varies from port to port, and from compiler to
905 * // compiler. Inspect the demos for the port you are using to find the
906 * // actual syntax required.
907 * if( xHigherPriorityTaskWoken != pdFALSE )
909 * // Call the interrupt safe yield function here (actual function
910 * // depends on the FreeRTOS port being used).
915 #define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )
918 * BaseType_t xTimerStopFromISR( TimerHandle_t xTimer,
919 * BaseType_t *pxHigherPriorityTaskWoken );
921 * A version of xTimerStop() that can be called from an interrupt service
924 * @param xTimer The handle of the timer being stopped.
926 * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most
927 * of its time in the Blocked state, waiting for messages to arrive on the timer
928 * command queue. Calling xTimerStopFromISR() writes a message to the timer
929 * command queue, so has the potential to transition the timer service/daemon
930 * task out of the Blocked state. If calling xTimerStopFromISR() causes the
931 * timer service/daemon task to leave the Blocked state, and the timer service/
932 * daemon task has a priority equal to or greater than the currently executing
933 * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will
934 * get set to pdTRUE internally within the xTimerStopFromISR() function. If
935 * xTimerStopFromISR() sets this value to pdTRUE then a context switch should
936 * be performed before the interrupt exits.
938 * @return pdFAIL will be returned if the stop command could not be sent to
939 * the timer command queue. pdPASS will be returned if the command was
940 * successfully sent to the timer command queue. When the command is actually
941 * processed will depend on the priority of the timer service/daemon task
942 * relative to other tasks in the system. The timer service/daemon task
943 * priority is set by the configTIMER_TASK_PRIORITY configuration constant.
947 * // This scenario assumes xTimer has already been created and started. When
948 * // an interrupt occurs, the timer should be simply stopped.
950 * // The interrupt service routine that stops the timer.
951 * void vAnExampleInterruptServiceRoutine( void )
953 * BaseType_t xHigherPriorityTaskWoken = pdFALSE;
955 * // The interrupt has occurred - simply stop the timer.
956 * // xHigherPriorityTaskWoken was set to pdFALSE where it was defined
957 * // (within this function). As this is an interrupt service routine, only
958 * // FreeRTOS API functions that end in "FromISR" can be used.
959 * if( xTimerStopFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS )
961 * // The stop command was not executed successfully. Take appropriate
965 * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch
966 * // should be performed. The syntax required to perform a context switch
967 * // from inside an ISR varies from port to port, and from compiler to
968 * // compiler. Inspect the demos for the port you are using to find the
969 * // actual syntax required.
970 * if( xHigherPriorityTaskWoken != pdFALSE )
972 * // Call the interrupt safe yield function here (actual function
973 * // depends on the FreeRTOS port being used).
978 #define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP_FROM_ISR, 0, ( pxHigherPriorityTaskWoken ), 0U )
981 * BaseType_t xTimerChangePeriodFromISR( TimerHandle_t xTimer,
982 * TickType_t xNewPeriod,
983 * BaseType_t *pxHigherPriorityTaskWoken );
985 * A version of xTimerChangePeriod() that can be called from an interrupt
988 * @param xTimer The handle of the timer that is having its period changed.
990 * @param xNewPeriod The new period for xTimer. Timer periods are specified in
991 * tick periods, so the constant portTICK_PERIOD_MS can be used to convert a time
992 * that has been specified in milliseconds. For example, if the timer must
993 * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively,
994 * if the timer must expire after 500ms, then xNewPeriod can be set to
995 * ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than
998 * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most
999 * of its time in the Blocked state, waiting for messages to arrive on the timer
1000 * command queue. Calling xTimerChangePeriodFromISR() writes a message to the
1001 * timer command queue, so has the potential to transition the timer service/
1002 * daemon task out of the Blocked state. If calling xTimerChangePeriodFromISR()
1003 * causes the timer service/daemon task to leave the Blocked state, and the
1004 * timer service/daemon task has a priority equal to or greater than the
1005 * currently executing task (the task that was interrupted), then
1006 * *pxHigherPriorityTaskWoken will get set to pdTRUE internally within the
1007 * xTimerChangePeriodFromISR() function. If xTimerChangePeriodFromISR() sets
1008 * this value to pdTRUE then a context switch should be performed before the
1011 * @return pdFAIL will be returned if the command to change the timers period
1012 * could not be sent to the timer command queue. pdPASS will be returned if the
1013 * command was successfully sent to the timer command queue. When the command
1014 * is actually processed will depend on the priority of the timer service/daemon
1015 * task relative to other tasks in the system. The timer service/daemon task
1016 * priority is set by the configTIMER_TASK_PRIORITY configuration constant.
1020 * // This scenario assumes xTimer has already been created and started. When
1021 * // an interrupt occurs, the period of xTimer should be changed to 500ms.
1023 * // The interrupt service routine that changes the period of xTimer.
1024 * void vAnExampleInterruptServiceRoutine( void )
1026 * BaseType_t xHigherPriorityTaskWoken = pdFALSE;
1028 * // The interrupt has occurred - change the period of xTimer to 500ms.
1029 * // xHigherPriorityTaskWoken was set to pdFALSE where it was defined
1030 * // (within this function). As this is an interrupt service routine, only
1031 * // FreeRTOS API functions that end in "FromISR" can be used.
1032 * if( xTimerChangePeriodFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS )
1034 * // The command to change the timers period was not executed
1035 * // successfully. Take appropriate action here.
1038 * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch
1039 * // should be performed. The syntax required to perform a context switch
1040 * // from inside an ISR varies from port to port, and from compiler to
1041 * // compiler. Inspect the demos for the port you are using to find the
1042 * // actual syntax required.
1043 * if( xHigherPriorityTaskWoken != pdFALSE )
1045 * // Call the interrupt safe yield function here (actual function
1046 * // depends on the FreeRTOS port being used).
1051 #define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD_FROM_ISR, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U )
1054 * BaseType_t xTimerResetFromISR( TimerHandle_t xTimer,
1055 * BaseType_t *pxHigherPriorityTaskWoken );
1057 * A version of xTimerReset() that can be called from an interrupt service
1060 * @param xTimer The handle of the timer that is to be started, reset, or
1063 * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most
1064 * of its time in the Blocked state, waiting for messages to arrive on the timer
1065 * command queue. Calling xTimerResetFromISR() writes a message to the timer
1066 * command queue, so has the potential to transition the timer service/daemon
1067 * task out of the Blocked state. If calling xTimerResetFromISR() causes the
1068 * timer service/daemon task to leave the Blocked state, and the timer service/
1069 * daemon task has a priority equal to or greater than the currently executing
1070 * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will
1071 * get set to pdTRUE internally within the xTimerResetFromISR() function. If
1072 * xTimerResetFromISR() sets this value to pdTRUE then a context switch should
1073 * be performed before the interrupt exits.
1075 * @return pdFAIL will be returned if the reset command could not be sent to
1076 * the timer command queue. pdPASS will be returned if the command was
1077 * successfully sent to the timer command queue. When the command is actually
1078 * processed will depend on the priority of the timer service/daemon task
1079 * relative to other tasks in the system, although the timers expiry time is
1080 * relative to when xTimerResetFromISR() is actually called. The timer service/daemon
1081 * task priority is set by the configTIMER_TASK_PRIORITY configuration constant.
1085 * // This scenario assumes xBacklightTimer has already been created. When a
1086 * // key is pressed, an LCD back-light is switched on. If 5 seconds pass
1087 * // without a key being pressed, then the LCD back-light is switched off. In
1088 * // this case, the timer is a one-shot timer, and unlike the example given for
1089 * // the xTimerReset() function, the key press event handler is an interrupt
1090 * // service routine.
1092 * // The callback function assigned to the one-shot timer. In this case the
1093 * // parameter is not used.
1094 * void vBacklightTimerCallback( TimerHandle_t pxTimer )
1096 * // The timer expired, therefore 5 seconds must have passed since a key
1097 * // was pressed. Switch off the LCD back-light.
1098 * vSetBacklightState( BACKLIGHT_OFF );
1101 * // The key press interrupt service routine.
1102 * void vKeyPressEventInterruptHandler( void )
1104 * BaseType_t xHigherPriorityTaskWoken = pdFALSE;
1106 * // Ensure the LCD back-light is on, then reset the timer that is
1107 * // responsible for turning the back-light off after 5 seconds of
1108 * // key inactivity. This is an interrupt service routine so can only
1109 * // call FreeRTOS API functions that end in "FromISR".
1110 * vSetBacklightState( BACKLIGHT_ON );
1112 * // xTimerStartFromISR() or xTimerResetFromISR() could be called here
1113 * // as both cause the timer to re-calculate its expiry time.
1114 * // xHigherPriorityTaskWoken was initialised to pdFALSE when it was
1115 * // declared (in this function).
1116 * if( xTimerResetFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS )
1118 * // The reset command was not executed successfully. Take appropriate
1122 * // Perform the rest of the key processing here.
1124 * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch
1125 * // should be performed. The syntax required to perform a context switch
1126 * // from inside an ISR varies from port to port, and from compiler to
1127 * // compiler. Inspect the demos for the port you are using to find the
1128 * // actual syntax required.
1129 * if( xHigherPriorityTaskWoken != pdFALSE )
1131 * // Call the interrupt safe yield function here (actual function
1132 * // depends on the FreeRTOS port being used).
1137 #define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )
1141 * BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend,
1142 * void *pvParameter1,
1143 * uint32_t ulParameter2,
1144 * BaseType_t *pxHigherPriorityTaskWoken );
1147 * Used from application interrupt service routines to defer the execution of a
1148 * function to the RTOS daemon task (the timer service task, hence this function
1149 * is implemented in timers.c and is prefixed with 'Timer').
1151 * Ideally an interrupt service routine (ISR) is kept as short as possible, but
1152 * sometimes an ISR either has a lot of processing to do, or needs to perform
1153 * processing that is not deterministic. In these cases
1154 * xTimerPendFunctionCallFromISR() can be used to defer processing of a function
1155 * to the RTOS daemon task.
1157 * A mechanism is provided that allows the interrupt to return directly to the
1158 * task that will subsequently execute the pended callback function. This
1159 * allows the callback function to execute contiguously in time with the
1160 * interrupt - just as if the callback had executed in the interrupt itself.
1162 * @param xFunctionToPend The function to execute from the timer service/
1163 * daemon task. The function must conform to the PendedFunction_t
1166 * @param pvParameter1 The value of the callback function's first parameter.
1167 * The parameter has a void * type to allow it to be used to pass any type.
1168 * For example, unsigned longs can be cast to a void *, or the void * can be
1169 * used to point to a structure.
1171 * @param ulParameter2 The value of the callback function's second parameter.
1173 * @param pxHigherPriorityTaskWoken As mentioned above, calling this function
1174 * will result in a message being sent to the timer daemon task. If the
1175 * priority of the timer daemon task (which is set using
1176 * configTIMER_TASK_PRIORITY in FreeRTOSConfig.h) is higher than the priority of
1177 * the currently running task (the task the interrupt interrupted) then
1178 * *pxHigherPriorityTaskWoken will be set to pdTRUE within
1179 * xTimerPendFunctionCallFromISR(), indicating that a context switch should be
1180 * requested before the interrupt exits. For that reason
1181 * *pxHigherPriorityTaskWoken must be initialised to pdFALSE. See the
1182 * example code below.
1184 * @return pdPASS is returned if the message was successfully sent to the
1185 * timer daemon task, otherwise pdFALSE is returned.
1190 * // The callback function that will execute in the context of the daemon task.
1191 * // Note callback functions must all use this same prototype.
1192 * void vProcessInterface( void *pvParameter1, uint32_t ulParameter2 )
1194 * BaseType_t xInterfaceToService;
1196 * // The interface that requires servicing is passed in the second
1197 * // parameter. The first parameter is not used in this case.
1198 * xInterfaceToService = ( BaseType_t ) ulParameter2;
1200 * // ...Perform the processing here...
1203 * // An ISR that receives data packets from multiple interfaces
1204 * void vAnISR( void )
1206 * BaseType_t xInterfaceToService, xHigherPriorityTaskWoken;
1208 * // Query the hardware to determine which interface needs processing.
1209 * xInterfaceToService = prvCheckInterfaces();
1211 * // The actual processing is to be deferred to a task. Request the
1212 * // vProcessInterface() callback function is executed, passing in the
1213 * // number of the interface that needs processing. The interface to
1214 * // service is passed in the second parameter. The first parameter is
1215 * // not used in this case.
1216 * xHigherPriorityTaskWoken = pdFALSE;
1217 * xTimerPendFunctionCallFromISR( vProcessInterface, NULL, ( uint32_t ) xInterfaceToService, &xHigherPriorityTaskWoken );
1219 * // If xHigherPriorityTaskWoken is now set to pdTRUE then a context
1220 * // switch should be requested. The macro used is port specific and will
1221 * // be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - refer to
1222 * // the documentation page for the port being used.
1223 * portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
1228 BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
1231 * BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend,
1232 * void *pvParameter1,
1233 * uint32_t ulParameter2,
1234 * TickType_t xTicksToWait );
1237 * Used to defer the execution of a function to the RTOS daemon task (the timer
1238 * service task, hence this function is implemented in timers.c and is prefixed
1241 * @param xFunctionToPend The function to execute from the timer service/
1242 * daemon task. The function must conform to the PendedFunction_t
1245 * @param pvParameter1 The value of the callback function's first parameter.
1246 * The parameter has a void * type to allow it to be used to pass any type.
1247 * For example, unsigned longs can be cast to a void *, or the void * can be
1248 * used to point to a structure.
1250 * @param ulParameter2 The value of the callback function's second parameter.
1252 * @param xTicksToWait Calling this function will result in a message being
1253 * sent to the timer daemon task on a queue. xTicksToWait is the amount of
1254 * time the calling task should remain in the Blocked state (so not using any
1255 * processing time) for space to become available on the timer queue if the
1256 * queue is found to be full.
1258 * @return pdPASS is returned if the message was successfully sent to the
1259 * timer daemon task, otherwise pdFALSE is returned.
1262 BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
1265 * const char * const pcTimerGetName( TimerHandle_t xTimer );
1267 * Returns the name that was assigned to a timer when the timer was created.
1269 * @param xTimer The handle of the timer being queried.
1271 * @return The name assigned to the timer specified by the xTimer parameter.
1273 const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1276 * TickType_t xTimerGetPeriod( TimerHandle_t xTimer );
1278 * Returns the period of a timer.
1280 * @param xTimer The handle of the timer being queried.
1282 * @return The period of the timer in ticks.
1284 TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
1287 * TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer );
1289 * Returns the time in ticks at which the timer will expire. If this is less
1290 * than the current tick count then the expiry time has overflowed from the
1293 * @param xTimer The handle of the timer being queried.
1295 * @return If the timer is running then the time in ticks at which the timer
1296 * will next expire is returned. If the timer is not running then the return
1297 * value is undefined.
1299 TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
1302 * Functions beyond this part are not part of the public API and are intended
1303 * for use by the kernel only.
1305 BaseType_t xTimerCreateTimerTask( void ) PRIVILEGED_FUNCTION;
1306 BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
1311 #endif /* TIMERS_H */