1 | /*
|
---|
2 | * FreeRTOS Kernel V10.3.1
|
---|
3 | * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
---|
6 | * this software and associated documentation files (the "Software"), to deal in
|
---|
7 | * the Software without restriction, including without limitation the rights to
|
---|
8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
---|
9 | * the Software, and to permit persons to whom the Software is furnished to do so,
|
---|
10 | * subject to the following conditions:
|
---|
11 | *
|
---|
12 | * The above copyright notice and this permission notice shall be included in all
|
---|
13 | * copies or substantial portions of the Software.
|
---|
14 | *
|
---|
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
---|
17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
---|
18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
---|
19 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
21 | *
|
---|
22 | * http://www.FreeRTOS.org
|
---|
23 | * http://aws.amazon.com/freertos
|
---|
24 | *
|
---|
25 | * 1 tab == 4 spaces!
|
---|
26 | */
|
---|
27 |
|
---|
28 |
|
---|
29 | #ifndef TIMERS_H
|
---|
30 | #define TIMERS_H
|
---|
31 |
|
---|
32 | #ifndef INC_FREERTOS_H
|
---|
33 | #error "include FreeRTOS.h must appear in source files before include timers.h"
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | /*lint -save -e537 This headers are only multiply included if the application code
|
---|
37 | happens to also be including task.h. */
|
---|
38 | #include "task.h"
|
---|
39 | /*lint -restore */
|
---|
40 |
|
---|
41 | #ifdef __cplusplus
|
---|
42 | extern "C" {
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | /*-----------------------------------------------------------
|
---|
46 | * MACROS AND DEFINITIONS
|
---|
47 | *----------------------------------------------------------*/
|
---|
48 |
|
---|
49 | /* IDs for commands that can be sent/received on the timer queue. These are to
|
---|
50 | be used solely through the macros that make up the public software timer API,
|
---|
51 | as defined below. The commands that are sent from interrupts must use the
|
---|
52 | highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task
|
---|
53 | or interrupt version of the queue send function should be used. */
|
---|
54 | #define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 )
|
---|
55 | #define tmrCOMMAND_EXECUTE_CALLBACK ( ( BaseType_t ) -1 )
|
---|
56 | #define tmrCOMMAND_START_DONT_TRACE ( ( BaseType_t ) 0 )
|
---|
57 | #define tmrCOMMAND_START ( ( BaseType_t ) 1 )
|
---|
58 | #define tmrCOMMAND_RESET ( ( BaseType_t ) 2 )
|
---|
59 | #define tmrCOMMAND_STOP ( ( BaseType_t ) 3 )
|
---|
60 | #define tmrCOMMAND_CHANGE_PERIOD ( ( BaseType_t ) 4 )
|
---|
61 | #define tmrCOMMAND_DELETE ( ( BaseType_t ) 5 )
|
---|
62 |
|
---|
63 | #define tmrFIRST_FROM_ISR_COMMAND ( ( BaseType_t ) 6 )
|
---|
64 | #define tmrCOMMAND_START_FROM_ISR ( ( BaseType_t ) 6 )
|
---|
65 | #define tmrCOMMAND_RESET_FROM_ISR ( ( BaseType_t ) 7 )
|
---|
66 | #define tmrCOMMAND_STOP_FROM_ISR ( ( BaseType_t ) 8 )
|
---|
67 | #define tmrCOMMAND_CHANGE_PERIOD_FROM_ISR ( ( BaseType_t ) 9 )
|
---|
68 |
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * Type by which software timers are referenced. For example, a call to
|
---|
72 | * xTimerCreate() returns an TimerHandle_t variable that can then be used to
|
---|
73 | * reference the subject timer in calls to other software timer API functions
|
---|
74 | * (for example, xTimerStart(), xTimerReset(), etc.).
|
---|
75 | */
|
---|
76 | struct tmrTimerControl; /* The old naming convention is used to prevent breaking kernel aware debuggers. */
|
---|
77 | typedef struct tmrTimerControl * TimerHandle_t;
|
---|
78 |
|
---|
79 | /*
|
---|
80 | * Defines the prototype to which timer callback functions must conform.
|
---|
81 | */
|
---|
82 | typedef void (*TimerCallbackFunction_t)( TimerHandle_t xTimer );
|
---|
83 |
|
---|
84 | /*
|
---|
85 | * Defines the prototype to which functions used with the
|
---|
86 | * xTimerPendFunctionCallFromISR() function must conform.
|
---|
87 | */
|
---|
88 | typedef void (*PendedFunction_t)( void *, uint32_t );
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * TimerHandle_t xTimerCreate( const char * const pcTimerName,
|
---|
92 | * TickType_t xTimerPeriodInTicks,
|
---|
93 | * UBaseType_t uxAutoReload,
|
---|
94 | * void * pvTimerID,
|
---|
95 | * TimerCallbackFunction_t pxCallbackFunction );
|
---|
96 | *
|
---|
97 | * Creates a new software timer instance, and returns a handle by which the
|
---|
98 | * created software timer can be referenced.
|
---|
99 | *
|
---|
100 | * Internally, within the FreeRTOS implementation, software timers use a block
|
---|
101 | * of memory, in which the timer data structure is stored. If a software timer
|
---|
102 | * is created using xTimerCreate() then the required memory is automatically
|
---|
103 | * dynamically allocated inside the xTimerCreate() function. (see
|
---|
104 | * http://www.freertos.org/a00111.html). If a software timer is created using
|
---|
105 | * xTimerCreateStatic() then the application writer must provide the memory that
|
---|
106 | * will get used by the software timer. xTimerCreateStatic() therefore allows a
|
---|
107 | * software timer to be created without using any dynamic memory allocation.
|
---|
108 | *
|
---|
109 | * Timers are created in the dormant state. The xTimerStart(), xTimerReset(),
|
---|
110 | * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and
|
---|
111 | * xTimerChangePeriodFromISR() API functions can all be used to transition a
|
---|
112 | * timer into the active state.
|
---|
113 | *
|
---|
114 | * @param pcTimerName A text name that is assigned to the timer. This is done
|
---|
115 | * purely to assist debugging. The kernel itself only ever references a timer
|
---|
116 | * by its handle, and never by its name.
|
---|
117 | *
|
---|
118 | * @param xTimerPeriodInTicks The timer period. The time is defined in tick
|
---|
119 | * periods so the constant portTICK_PERIOD_MS can be used to convert a time that
|
---|
120 | * has been specified in milliseconds. For example, if the timer must expire
|
---|
121 | * after 100 ticks, then xTimerPeriodInTicks should be set to 100.
|
---|
122 | * Alternatively, if the timer must expire after 500ms, then xPeriod can be set
|
---|
123 | * to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or
|
---|
124 | * equal to 1000. Time timer period must be greater than 0.
|
---|
125 | *
|
---|
126 | * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will
|
---|
127 | * expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter.
|
---|
128 | * If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and
|
---|
129 | * enter the dormant state after it expires.
|
---|
130 | *
|
---|
131 | * @param pvTimerID An identifier that is assigned to the timer being created.
|
---|
132 | * Typically this would be used in the timer callback function to identify which
|
---|
133 | * timer expired when the same callback function is assigned to more than one
|
---|
134 | * timer.
|
---|
135 | *
|
---|
136 | * @param pxCallbackFunction The function to call when the timer expires.
|
---|
137 | * Callback functions must have the prototype defined by TimerCallbackFunction_t,
|
---|
138 | * which is "void vCallbackFunction( TimerHandle_t xTimer );".
|
---|
139 | *
|
---|
140 | * @return If the timer is successfully created then a handle to the newly
|
---|
141 | * created timer is returned. If the timer cannot be created because there is
|
---|
142 | * insufficient FreeRTOS heap remaining to allocate the timer
|
---|
143 | * structures then NULL is returned.
|
---|
144 | *
|
---|
145 | * Example usage:
|
---|
146 | * @verbatim
|
---|
147 | * #define NUM_TIMERS 5
|
---|
148 | *
|
---|
149 | * // An array to hold handles to the created timers.
|
---|
150 | * TimerHandle_t xTimers[ NUM_TIMERS ];
|
---|
151 | *
|
---|
152 | * // An array to hold a count of the number of times each timer expires.
|
---|
153 | * int32_t lExpireCounters[ NUM_TIMERS ] = { 0 };
|
---|
154 | *
|
---|
155 | * // Define a callback function that will be used by multiple timer instances.
|
---|
156 | * // The callback function does nothing but count the number of times the
|
---|
157 | * // associated timer expires, and stop the timer once the timer has expired
|
---|
158 | * // 10 times.
|
---|
159 | * void vTimerCallback( TimerHandle_t pxTimer )
|
---|
160 | * {
|
---|
161 | * int32_t lArrayIndex;
|
---|
162 | * const int32_t xMaxExpiryCountBeforeStopping = 10;
|
---|
163 | *
|
---|
164 | * // Optionally do something if the pxTimer parameter is NULL.
|
---|
165 | * configASSERT( pxTimer );
|
---|
166 | *
|
---|
167 | * // Which timer expired?
|
---|
168 | * lArrayIndex = ( int32_t ) pvTimerGetTimerID( pxTimer );
|
---|
169 | *
|
---|
170 | * // Increment the number of times that pxTimer has expired.
|
---|
171 | * lExpireCounters[ lArrayIndex ] += 1;
|
---|
172 | *
|
---|
173 | * // If the timer has expired 10 times then stop it from running.
|
---|
174 | * if( lExpireCounters[ lArrayIndex ] == xMaxExpiryCountBeforeStopping )
|
---|
175 | * {
|
---|
176 | * // Do not use a block time if calling a timer API function from a
|
---|
177 | * // timer callback function, as doing so could cause a deadlock!
|
---|
178 | * xTimerStop( pxTimer, 0 );
|
---|
179 | * }
|
---|
180 | * }
|
---|
181 | *
|
---|
182 | * void main( void )
|
---|
183 | * {
|
---|
184 | * int32_t x;
|
---|
185 | *
|
---|
186 | * // Create then start some timers. Starting the timers before the scheduler
|
---|
187 | * // has been started means the timers will start running immediately that
|
---|
188 | * // the scheduler starts.
|
---|
189 | * for( x = 0; x < NUM_TIMERS; x++ )
|
---|
190 | * {
|
---|
191 | * xTimers[ x ] = xTimerCreate( "Timer", // Just a text name, not used by the kernel.
|
---|
192 | * ( 100 * x ), // The timer period in ticks.
|
---|
193 | * pdTRUE, // The timers will auto-reload themselves when they expire.
|
---|
194 | * ( void * ) x, // Assign each timer a unique id equal to its array index.
|
---|
195 | * vTimerCallback // Each timer calls the same callback when it expires.
|
---|
196 | * );
|
---|
197 | *
|
---|
198 | * if( xTimers[ x ] == NULL )
|
---|
199 | * {
|
---|
200 | * // The timer was not created.
|
---|
201 | * }
|
---|
202 | * else
|
---|
203 | * {
|
---|
204 | * // Start the timer. No block time is specified, and even if one was
|
---|
205 | * // it would be ignored because the scheduler has not yet been
|
---|
206 | * // started.
|
---|
207 | * if( xTimerStart( xTimers[ x ], 0 ) != pdPASS )
|
---|
208 | * {
|
---|
209 | * // The timer could not be set into the Active state.
|
---|
210 | * }
|
---|
211 | * }
|
---|
212 | * }
|
---|
213 | *
|
---|
214 | * // ...
|
---|
215 | * // Create tasks here.
|
---|
216 | * // ...
|
---|
217 | *
|
---|
218 | * // Starting the scheduler will start the timers running as they have already
|
---|
219 | * // been set into the active state.
|
---|
220 | * vTaskStartScheduler();
|
---|
221 | *
|
---|
222 | * // Should not reach here.
|
---|
223 | * for( ;; );
|
---|
224 | * }
|
---|
225 | * @endverbatim
|
---|
226 | */
|
---|
227 | #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
|
---|
228 | TimerHandle_t xTimerCreate( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
---|
229 | const TickType_t xTimerPeriodInTicks,
|
---|
230 | const UBaseType_t uxAutoReload,
|
---|
231 | void * const pvTimerID,
|
---|
232 | TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION;
|
---|
233 | #endif
|
---|
234 |
|
---|
235 | /**
|
---|
236 | * TimerHandle_t xTimerCreateStatic(const char * const pcTimerName,
|
---|
237 | * TickType_t xTimerPeriodInTicks,
|
---|
238 | * UBaseType_t uxAutoReload,
|
---|
239 | * void * pvTimerID,
|
---|
240 | * TimerCallbackFunction_t pxCallbackFunction,
|
---|
241 | * StaticTimer_t *pxTimerBuffer );
|
---|
242 | *
|
---|
243 | * Creates a new software timer instance, and returns a handle by which the
|
---|
244 | * created software timer can be referenced.
|
---|
245 | *
|
---|
246 | * Internally, within the FreeRTOS implementation, software timers use a block
|
---|
247 | * of memory, in which the timer data structure is stored. If a software timer
|
---|
248 | * is created using xTimerCreate() then the required memory is automatically
|
---|
249 | * dynamically allocated inside the xTimerCreate() function. (see
|
---|
250 | * http://www.freertos.org/a00111.html). If a software timer is created using
|
---|
251 | * xTimerCreateStatic() then the application writer must provide the memory that
|
---|
252 | * will get used by the software timer. xTimerCreateStatic() therefore allows a
|
---|
253 | * software timer to be created without using any dynamic memory allocation.
|
---|
254 | *
|
---|
255 | * Timers are created in the dormant state. The xTimerStart(), xTimerReset(),
|
---|
256 | * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and
|
---|
257 | * xTimerChangePeriodFromISR() API functions can all be used to transition a
|
---|
258 | * timer into the active state.
|
---|
259 | *
|
---|
260 | * @param pcTimerName A text name that is assigned to the timer. This is done
|
---|
261 | * purely to assist debugging. The kernel itself only ever references a timer
|
---|
262 | * by its handle, and never by its name.
|
---|
263 | *
|
---|
264 | * @param xTimerPeriodInTicks The timer period. The time is defined in tick
|
---|
265 | * periods so the constant portTICK_PERIOD_MS can be used to convert a time that
|
---|
266 | * has been specified in milliseconds. For example, if the timer must expire
|
---|
267 | * after 100 ticks, then xTimerPeriodInTicks should be set to 100.
|
---|
268 | * Alternatively, if the timer must expire after 500ms, then xPeriod can be set
|
---|
269 | * to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or
|
---|
270 | * equal to 1000. The timer period must be greater than 0.
|
---|
271 | *
|
---|
272 | * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will
|
---|
273 | * expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter.
|
---|
274 | * If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and
|
---|
275 | * enter the dormant state after it expires.
|
---|
276 | *
|
---|
277 | * @param pvTimerID An identifier that is assigned to the timer being created.
|
---|
278 | * Typically this would be used in the timer callback function to identify which
|
---|
279 | * timer expired when the same callback function is assigned to more than one
|
---|
280 | * timer.
|
---|
281 | *
|
---|
282 | * @param pxCallbackFunction The function to call when the timer expires.
|
---|
283 | * Callback functions must have the prototype defined by TimerCallbackFunction_t,
|
---|
284 | * which is "void vCallbackFunction( TimerHandle_t xTimer );".
|
---|
285 | *
|
---|
286 | * @param pxTimerBuffer Must point to a variable of type StaticTimer_t, which
|
---|
287 | * will be then be used to hold the software timer's data structures, removing
|
---|
288 | * the need for the memory to be allocated dynamically.
|
---|
289 | *
|
---|
290 | * @return If the timer is created then a handle to the created timer is
|
---|
291 | * returned. If pxTimerBuffer was NULL then NULL is returned.
|
---|
292 | *
|
---|
293 | * Example usage:
|
---|
294 | * @verbatim
|
---|
295 | *
|
---|
296 | * // The buffer used to hold the software timer's data structure.
|
---|
297 | * static StaticTimer_t xTimerBuffer;
|
---|
298 | *
|
---|
299 | * // A variable that will be incremented by the software timer's callback
|
---|
300 | * // function.
|
---|
301 | * UBaseType_t uxVariableToIncrement = 0;
|
---|
302 | *
|
---|
303 | * // A software timer callback function that increments a variable passed to
|
---|
304 | * // it when the software timer was created. After the 5th increment the
|
---|
305 | * // callback function stops the software timer.
|
---|
306 | * static void prvTimerCallback( TimerHandle_t xExpiredTimer )
|
---|
307 | * {
|
---|
308 | * UBaseType_t *puxVariableToIncrement;
|
---|
309 | * BaseType_t xReturned;
|
---|
310 | *
|
---|
311 | * // Obtain the address of the variable to increment from the timer ID.
|
---|
312 | * puxVariableToIncrement = ( UBaseType_t * ) pvTimerGetTimerID( xExpiredTimer );
|
---|
313 | *
|
---|
314 | * // Increment the variable to show the timer callback has executed.
|
---|
315 | * ( *puxVariableToIncrement )++;
|
---|
316 | *
|
---|
317 | * // If this callback has executed the required number of times, stop the
|
---|
318 | * // timer.
|
---|
319 | * if( *puxVariableToIncrement == 5 )
|
---|
320 | * {
|
---|
321 | * // This is called from a timer callback so must not block.
|
---|
322 | * xTimerStop( xExpiredTimer, staticDONT_BLOCK );
|
---|
323 | * }
|
---|
324 | * }
|
---|
325 | *
|
---|
326 | *
|
---|
327 | * void main( void )
|
---|
328 | * {
|
---|
329 | * // Create the software time. xTimerCreateStatic() has an extra parameter
|
---|
330 | * // than the normal xTimerCreate() API function. The parameter is a pointer
|
---|
331 | * // to the StaticTimer_t structure that will hold the software timer
|
---|
332 | * // structure. If the parameter is passed as NULL then the structure will be
|
---|
333 | * // allocated dynamically, just as if xTimerCreate() had been called.
|
---|
334 | * xTimer = xTimerCreateStatic( "T1", // Text name for the task. Helps debugging only. Not used by FreeRTOS.
|
---|
335 | * xTimerPeriod, // The period of the timer in ticks.
|
---|
336 | * pdTRUE, // This is an auto-reload timer.
|
---|
337 | * ( void * ) &uxVariableToIncrement, // A variable incremented by the software timer's callback function
|
---|
338 | * prvTimerCallback, // The function to execute when the timer expires.
|
---|
339 | * &xTimerBuffer ); // The buffer that will hold the software timer structure.
|
---|
340 | *
|
---|
341 | * // The scheduler has not started yet so a block time is not used.
|
---|
342 | * xReturned = xTimerStart( xTimer, 0 );
|
---|
343 | *
|
---|
344 | * // ...
|
---|
345 | * // Create tasks here.
|
---|
346 | * // ...
|
---|
347 | *
|
---|
348 | * // Starting the scheduler will start the timers running as they have already
|
---|
349 | * // been set into the active state.
|
---|
350 | * vTaskStartScheduler();
|
---|
351 | *
|
---|
352 | * // Should not reach here.
|
---|
353 | * for( ;; );
|
---|
354 | * }
|
---|
355 | * @endverbatim
|
---|
356 | */
|
---|
357 | #if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
---|
358 | TimerHandle_t xTimerCreateStatic( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
---|
359 | const TickType_t xTimerPeriodInTicks,
|
---|
360 | const UBaseType_t uxAutoReload,
|
---|
361 | void * const pvTimerID,
|
---|
362 | TimerCallbackFunction_t pxCallbackFunction,
|
---|
363 | StaticTimer_t *pxTimerBuffer ) PRIVILEGED_FUNCTION;
|
---|
364 | #endif /* configSUPPORT_STATIC_ALLOCATION */
|
---|
365 |
|
---|
366 | /**
|
---|
367 | * void *pvTimerGetTimerID( TimerHandle_t xTimer );
|
---|
368 | *
|
---|
369 | * Returns the ID assigned to the timer.
|
---|
370 | *
|
---|
371 | * IDs are assigned to timers using the pvTimerID parameter of the call to
|
---|
372 | * xTimerCreated() that was used to create the timer, and by calling the
|
---|
373 | * vTimerSetTimerID() API function.
|
---|
374 | *
|
---|
375 | * If the same callback function is assigned to multiple timers then the timer
|
---|
376 | * ID can be used as time specific (timer local) storage.
|
---|
377 | *
|
---|
378 | * @param xTimer The timer being queried.
|
---|
379 | *
|
---|
380 | * @return The ID assigned to the timer being queried.
|
---|
381 | *
|
---|
382 | * Example usage:
|
---|
383 | *
|
---|
384 | * See the xTimerCreate() API function example usage scenario.
|
---|
385 | */
|
---|
386 | void *pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
---|
387 |
|
---|
388 | /**
|
---|
389 | * void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID );
|
---|
390 | *
|
---|
391 | * Sets the ID assigned to the timer.
|
---|
392 | *
|
---|
393 | * IDs are assigned to timers using the pvTimerID parameter of the call to
|
---|
394 | * xTimerCreated() that was used to create the timer.
|
---|
395 | *
|
---|
396 | * If the same callback function is assigned to multiple timers then the timer
|
---|
397 | * ID can be used as time specific (timer local) storage.
|
---|
398 | *
|
---|
399 | * @param xTimer The timer being updated.
|
---|
400 | *
|
---|
401 | * @param pvNewID The ID to assign to the timer.
|
---|
402 | *
|
---|
403 | * Example usage:
|
---|
404 | *
|
---|
405 | * See the xTimerCreate() API function example usage scenario.
|
---|
406 | */
|
---|
407 | void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION;
|
---|
408 |
|
---|
409 | /**
|
---|
410 | * BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer );
|
---|
411 | *
|
---|
412 | * Queries a timer to see if it is active or dormant.
|
---|
413 | *
|
---|
414 | * A timer will be dormant if:
|
---|
415 | * 1) It has been created but not started, or
|
---|
416 | * 2) It is an expired one-shot timer that has not been restarted.
|
---|
417 | *
|
---|
418 | * Timers are created in the dormant state. The xTimerStart(), xTimerReset(),
|
---|
419 | * xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and
|
---|
420 | * xTimerChangePeriodFromISR() API functions can all be used to transition a timer into the
|
---|
421 | * active state.
|
---|
422 | *
|
---|
423 | * @param xTimer The timer being queried.
|
---|
424 | *
|
---|
425 | * @return pdFALSE will be returned if the timer is dormant. A value other than
|
---|
426 | * pdFALSE will be returned if the timer is active.
|
---|
427 | *
|
---|
428 | * Example usage:
|
---|
429 | * @verbatim
|
---|
430 | * // This function assumes xTimer has already been created.
|
---|
431 | * void vAFunction( TimerHandle_t xTimer )
|
---|
432 | * {
|
---|
433 | * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )"
|
---|
434 | * {
|
---|
435 | * // xTimer is active, do something.
|
---|
436 | * }
|
---|
437 | * else
|
---|
438 | * {
|
---|
439 | * // xTimer is not active, do something else.
|
---|
440 | * }
|
---|
441 | * }
|
---|
442 | * @endverbatim
|
---|
443 | */
|
---|
444 | BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
---|
445 |
|
---|
446 | /**
|
---|
447 | * TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );
|
---|
448 | *
|
---|
449 | * Simply returns the handle of the timer service/daemon task. It it not valid
|
---|
450 | * to call xTimerGetTimerDaemonTaskHandle() before the scheduler has been started.
|
---|
451 | */
|
---|
452 | TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
|
---|
453 |
|
---|
454 | /**
|
---|
455 | * BaseType_t xTimerStart( TimerHandle_t xTimer, TickType_t xTicksToWait );
|
---|
456 | *
|
---|
457 | * Timer functionality is provided by a timer service/daemon task. Many of the
|
---|
458 | * public FreeRTOS timer API functions send commands to the timer service task
|
---|
459 | * through a queue called the timer command queue. The timer command queue is
|
---|
460 | * private to the kernel itself and is not directly accessible to application
|
---|
461 | * code. The length of the timer command queue is set by the
|
---|
462 | * configTIMER_QUEUE_LENGTH configuration constant.
|
---|
463 | *
|
---|
464 | * xTimerStart() starts a timer that was previously created using the
|
---|
465 | * xTimerCreate() API function. If the timer had already been started and was
|
---|
466 | * already in the active state, then xTimerStart() has equivalent functionality
|
---|
467 | * to the xTimerReset() API function.
|
---|
468 | *
|
---|
469 | * Starting a timer ensures the timer is in the active state. If the timer
|
---|
470 | * is not stopped, deleted, or reset in the mean time, the callback function
|
---|
471 | * associated with the timer will get called 'n' ticks after xTimerStart() was
|
---|
472 | * called, where 'n' is the timers defined period.
|
---|
473 | *
|
---|
474 | * It is valid to call xTimerStart() before the scheduler has been started, but
|
---|
475 | * when this is done the timer will not actually start until the scheduler is
|
---|
476 | * started, and the timers expiry time will be relative to when the scheduler is
|
---|
477 | * started, not relative to when xTimerStart() was called.
|
---|
478 | *
|
---|
479 | * The configUSE_TIMERS configuration constant must be set to 1 for xTimerStart()
|
---|
480 | * to be available.
|
---|
481 | *
|
---|
482 | * @param xTimer The handle of the timer being started/restarted.
|
---|
483 | *
|
---|
484 | * @param xTicksToWait Specifies the time, in ticks, that the calling task should
|
---|
485 | * be held in the Blocked state to wait for the start command to be successfully
|
---|
486 | * sent to the timer command queue, should the queue already be full when
|
---|
487 | * xTimerStart() was called. xTicksToWait is ignored if xTimerStart() is called
|
---|
488 | * before the scheduler is started.
|
---|
489 | *
|
---|
490 | * @return pdFAIL will be returned if the start command could not be sent to
|
---|
491 | * the timer command queue even after xTicksToWait ticks had passed. pdPASS will
|
---|
492 | * be returned if the command was successfully sent to the timer command queue.
|
---|
493 | * When the command is actually processed will depend on the priority of the
|
---|
494 | * timer service/daemon task relative to other tasks in the system, although the
|
---|
495 | * timers expiry time is relative to when xTimerStart() is actually called. The
|
---|
496 | * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY
|
---|
497 | * configuration constant.
|
---|
498 | *
|
---|
499 | * Example usage:
|
---|
500 | *
|
---|
501 | * See the xTimerCreate() API function example usage scenario.
|
---|
502 | *
|
---|
503 | */
|
---|
504 | #define xTimerStart( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) )
|
---|
505 |
|
---|
506 | /**
|
---|
507 | * BaseType_t xTimerStop( TimerHandle_t xTimer, TickType_t xTicksToWait );
|
---|
508 | *
|
---|
509 | * Timer functionality is provided by a timer service/daemon task. Many of the
|
---|
510 | * public FreeRTOS timer API functions send commands to the timer service task
|
---|
511 | * through a queue called the timer command queue. The timer command queue is
|
---|
512 | * private to the kernel itself and is not directly accessible to application
|
---|
513 | * code. The length of the timer command queue is set by the
|
---|
514 | * configTIMER_QUEUE_LENGTH configuration constant.
|
---|
515 | *
|
---|
516 | * xTimerStop() stops a timer that was previously started using either of the
|
---|
517 | * The xTimerStart(), xTimerReset(), xTimerStartFromISR(), xTimerResetFromISR(),
|
---|
518 | * xTimerChangePeriod() or xTimerChangePeriodFromISR() API functions.
|
---|
519 | *
|
---|
520 | * Stopping a timer ensures the timer is not in the active state.
|
---|
521 | *
|
---|
522 | * The configUSE_TIMERS configuration constant must be set to 1 for xTimerStop()
|
---|
523 | * to be available.
|
---|
524 | *
|
---|
525 | * @param xTimer The handle of the timer being stopped.
|
---|
526 | *
|
---|
527 | * @param xTicksToWait Specifies the time, in ticks, that the calling task should
|
---|
528 | * be held in the Blocked state to wait for the stop command to be successfully
|
---|
529 | * sent to the timer command queue, should the queue already be full when
|
---|
530 | * xTimerStop() was called. xTicksToWait is ignored if xTimerStop() is called
|
---|
531 | * before the scheduler is started.
|
---|
532 | *
|
---|
533 | * @return pdFAIL will be returned if the stop command could not be sent to
|
---|
534 | * the timer command queue even after xTicksToWait ticks had passed. pdPASS will
|
---|
535 | * be returned if the command was successfully sent to the timer command queue.
|
---|
536 | * When the command is actually processed will depend on the priority of the
|
---|
537 | * timer service/daemon task relative to other tasks in the system. The timer
|
---|
538 | * service/daemon task priority is set by the configTIMER_TASK_PRIORITY
|
---|
539 | * configuration constant.
|
---|
540 | *
|
---|
541 | * Example usage:
|
---|
542 | *
|
---|
543 | * See the xTimerCreate() API function example usage scenario.
|
---|
544 | *
|
---|
545 | */
|
---|
546 | #define xTimerStop( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xTicksToWait ) )
|
---|
547 |
|
---|
548 | /**
|
---|
549 | * BaseType_t xTimerChangePeriod( TimerHandle_t xTimer,
|
---|
550 | * TickType_t xNewPeriod,
|
---|
551 | * TickType_t xTicksToWait );
|
---|
552 | *
|
---|
553 | * Timer functionality is provided by a timer service/daemon task. Many of the
|
---|
554 | * public FreeRTOS timer API functions send commands to the timer service task
|
---|
555 | * through a queue called the timer command queue. The timer command queue is
|
---|
556 | * private to the kernel itself and is not directly accessible to application
|
---|
557 | * code. The length of the timer command queue is set by the
|
---|
558 | * configTIMER_QUEUE_LENGTH configuration constant.
|
---|
559 | *
|
---|
560 | * xTimerChangePeriod() changes the period of a timer that was previously
|
---|
561 | * created using the xTimerCreate() API function.
|
---|
562 | *
|
---|
563 | * xTimerChangePeriod() can be called to change the period of an active or
|
---|
564 | * dormant state timer.
|
---|
565 | *
|
---|
566 | * The configUSE_TIMERS configuration constant must be set to 1 for
|
---|
567 | * xTimerChangePeriod() to be available.
|
---|
568 | *
|
---|
569 | * @param xTimer The handle of the timer that is having its period changed.
|
---|
570 | *
|
---|
571 | * @param xNewPeriod The new period for xTimer. Timer periods are specified in
|
---|
572 | * tick periods, so the constant portTICK_PERIOD_MS can be used to convert a time
|
---|
573 | * that has been specified in milliseconds. For example, if the timer must
|
---|
574 | * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively,
|
---|
575 | * if the timer must expire after 500ms, then xNewPeriod can be set to
|
---|
576 | * ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than
|
---|
577 | * or equal to 1000.
|
---|
578 | *
|
---|
579 | * @param xTicksToWait Specifies the time, in ticks, that the calling task should
|
---|
580 | * be held in the Blocked state to wait for the change period command to be
|
---|
581 | * successfully sent to the timer command queue, should the queue already be
|
---|
582 | * full when xTimerChangePeriod() was called. xTicksToWait is ignored if
|
---|
583 | * xTimerChangePeriod() is called before the scheduler is started.
|
---|
584 | *
|
---|
585 | * @return pdFAIL will be returned if the change period command could not be
|
---|
586 | * sent to the timer command queue even after xTicksToWait ticks had passed.
|
---|
587 | * pdPASS will be returned if the command was successfully sent to the timer
|
---|
588 | * command queue. When the command is actually processed will depend on the
|
---|
589 | * priority of the timer service/daemon task relative to other tasks in the
|
---|
590 | * system. The timer service/daemon task priority is set by the
|
---|
591 | * configTIMER_TASK_PRIORITY configuration constant.
|
---|
592 | *
|
---|
593 | * Example usage:
|
---|
594 | * @verbatim
|
---|
595 | * // This function assumes xTimer has already been created. If the timer
|
---|
596 | * // referenced by xTimer is already active when it is called, then the timer
|
---|
597 | * // is deleted. If the timer referenced by xTimer is not active when it is
|
---|
598 | * // called, then the period of the timer is set to 500ms and the timer is
|
---|
599 | * // started.
|
---|
600 | * void vAFunction( TimerHandle_t xTimer )
|
---|
601 | * {
|
---|
602 | * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )"
|
---|
603 | * {
|
---|
604 | * // xTimer is already active - delete it.
|
---|
605 | * xTimerDelete( xTimer );
|
---|
606 | * }
|
---|
607 | * else
|
---|
608 | * {
|
---|
609 | * // xTimer is not active, change its period to 500ms. This will also
|
---|
610 | * // cause the timer to start. Block for a maximum of 100 ticks if the
|
---|
611 | * // change period command cannot immediately be sent to the timer
|
---|
612 | * // command queue.
|
---|
613 | * if( xTimerChangePeriod( xTimer, 500 / portTICK_PERIOD_MS, 100 ) == pdPASS )
|
---|
614 | * {
|
---|
615 | * // The command was successfully sent.
|
---|
616 | * }
|
---|
617 | * else
|
---|
618 | * {
|
---|
619 | * // The command could not be sent, even after waiting for 100 ticks
|
---|
620 | * // to pass. Take appropriate action here.
|
---|
621 | * }
|
---|
622 | * }
|
---|
623 | * }
|
---|
624 | * @endverbatim
|
---|
625 | */
|
---|
626 | #define xTimerChangePeriod( xTimer, xNewPeriod, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xTicksToWait ) )
|
---|
627 |
|
---|
628 | /**
|
---|
629 | * BaseType_t xTimerDelete( TimerHandle_t xTimer, TickType_t xTicksToWait );
|
---|
630 | *
|
---|
631 | * Timer functionality is provided by a timer service/daemon task. Many of the
|
---|
632 | * public FreeRTOS timer API functions send commands to the timer service task
|
---|
633 | * through a queue called the timer command queue. The timer command queue is
|
---|
634 | * private to the kernel itself and is not directly accessible to application
|
---|
635 | * code. The length of the timer command queue is set by the
|
---|
636 | * configTIMER_QUEUE_LENGTH configuration constant.
|
---|
637 | *
|
---|
638 | * xTimerDelete() deletes a timer that was previously created using the
|
---|
639 | * xTimerCreate() API function.
|
---|
640 | *
|
---|
641 | * The configUSE_TIMERS configuration constant must be set to 1 for
|
---|
642 | * xTimerDelete() to be available.
|
---|
643 | *
|
---|
644 | * @param xTimer The handle of the timer being deleted.
|
---|
645 | *
|
---|
646 | * @param xTicksToWait Specifies the time, in ticks, that the calling task should
|
---|
647 | * be held in the Blocked state to wait for the delete command to be
|
---|
648 | * successfully sent to the timer command queue, should the queue already be
|
---|
649 | * full when xTimerDelete() was called. xTicksToWait is ignored if xTimerDelete()
|
---|
650 | * is called before the scheduler is started.
|
---|
651 | *
|
---|
652 | * @return pdFAIL will be returned if the delete command could not be sent to
|
---|
653 | * the timer command queue even after xTicksToWait ticks had passed. pdPASS will
|
---|
654 | * be returned if the command was successfully sent to the timer command queue.
|
---|
655 | * When the command is actually processed will depend on the priority of the
|
---|
656 | * timer service/daemon task relative to other tasks in the system. The timer
|
---|
657 | * service/daemon task priority is set by the configTIMER_TASK_PRIORITY
|
---|
658 | * configuration constant.
|
---|
659 | *
|
---|
660 | * Example usage:
|
---|
661 | *
|
---|
662 | * See the xTimerChangePeriod() API function example usage scenario.
|
---|
663 | */
|
---|
664 | #define xTimerDelete( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xTicksToWait ) )
|
---|
665 |
|
---|
666 | /**
|
---|
667 | * BaseType_t xTimerReset( TimerHandle_t xTimer, TickType_t xTicksToWait );
|
---|
668 | *
|
---|
669 | * Timer functionality is provided by a timer service/daemon task. Many of the
|
---|
670 | * public FreeRTOS timer API functions send commands to the timer service task
|
---|
671 | * through a queue called the timer command queue. The timer command queue is
|
---|
672 | * private to the kernel itself and is not directly accessible to application
|
---|
673 | * code. The length of the timer command queue is set by the
|
---|
674 | * configTIMER_QUEUE_LENGTH configuration constant.
|
---|
675 | *
|
---|
676 | * xTimerReset() re-starts a timer that was previously created using the
|
---|
677 | * xTimerCreate() API function. If the timer had already been started and was
|
---|
678 | * already in the active state, then xTimerReset() will cause the timer to
|
---|
679 | * re-evaluate its expiry time so that it is relative to when xTimerReset() was
|
---|
680 | * called. If the timer was in the dormant state then xTimerReset() has
|
---|
681 | * equivalent functionality to the xTimerStart() API function.
|
---|
682 | *
|
---|
683 | * Resetting a timer ensures the timer is in the active state. If the timer
|
---|
684 | * is not stopped, deleted, or reset in the mean time, the callback function
|
---|
685 | * associated with the timer will get called 'n' ticks after xTimerReset() was
|
---|
686 | * called, where 'n' is the timers defined period.
|
---|
687 | *
|
---|
688 | * It is valid to call xTimerReset() before the scheduler has been started, but
|
---|
689 | * when this is done the timer will not actually start until the scheduler is
|
---|
690 | * started, and the timers expiry time will be relative to when the scheduler is
|
---|
691 | * started, not relative to when xTimerReset() was called.
|
---|
692 | *
|
---|
693 | * The configUSE_TIMERS configuration constant must be set to 1 for xTimerReset()
|
---|
694 | * to be available.
|
---|
695 | *
|
---|
696 | * @param xTimer The handle of the timer being reset/started/restarted.
|
---|
697 | *
|
---|
698 | * @param xTicksToWait Specifies the time, in ticks, that the calling task should
|
---|
699 | * be held in the Blocked state to wait for the reset command to be successfully
|
---|
700 | * sent to the timer command queue, should the queue already be full when
|
---|
701 | * xTimerReset() was called. xTicksToWait is ignored if xTimerReset() is called
|
---|
702 | * before the scheduler is started.
|
---|
703 | *
|
---|
704 | * @return pdFAIL will be returned if the reset command could not be sent to
|
---|
705 | * the timer command queue even after xTicksToWait ticks had passed. pdPASS will
|
---|
706 | * be returned if the command was successfully sent to the timer command queue.
|
---|
707 | * When the command is actually processed will depend on the priority of the
|
---|
708 | * timer service/daemon task relative to other tasks in the system, although the
|
---|
709 | * timers expiry time is relative to when xTimerStart() is actually called. The
|
---|
710 | * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY
|
---|
711 | * configuration constant.
|
---|
712 | *
|
---|
713 | * Example usage:
|
---|
714 | * @verbatim
|
---|
715 | * // When a key is pressed, an LCD back-light is switched on. If 5 seconds pass
|
---|
716 | * // without a key being pressed, then the LCD back-light is switched off. In
|
---|
717 | * // this case, the timer is a one-shot timer.
|
---|
718 | *
|
---|
719 | * TimerHandle_t xBacklightTimer = NULL;
|
---|
720 | *
|
---|
721 | * // The callback function assigned to the one-shot timer. In this case the
|
---|
722 | * // parameter is not used.
|
---|
723 | * void vBacklightTimerCallback( TimerHandle_t pxTimer )
|
---|
724 | * {
|
---|
725 | * // The timer expired, therefore 5 seconds must have passed since a key
|
---|
726 | * // was pressed. Switch off the LCD back-light.
|
---|
727 | * vSetBacklightState( BACKLIGHT_OFF );
|
---|
728 | * }
|
---|
729 | *
|
---|
730 | * // The key press event handler.
|
---|
731 | * void vKeyPressEventHandler( char cKey )
|
---|
732 | * {
|
---|
733 | * // Ensure the LCD back-light is on, then reset the timer that is
|
---|
734 | * // responsible for turning the back-light off after 5 seconds of
|
---|
735 | * // key inactivity. Wait 10 ticks for the command to be successfully sent
|
---|
736 | * // if it cannot be sent immediately.
|
---|
737 | * vSetBacklightState( BACKLIGHT_ON );
|
---|
738 | * if( xTimerReset( xBacklightTimer, 100 ) != pdPASS )
|
---|
739 | * {
|
---|
740 | * // The reset command was not executed successfully. Take appropriate
|
---|
741 | * // action here.
|
---|
742 | * }
|
---|
743 | *
|
---|
744 | * // Perform the rest of the key processing here.
|
---|
745 | * }
|
---|
746 | *
|
---|
747 | * void main( void )
|
---|
748 | * {
|
---|
749 | * int32_t x;
|
---|
750 | *
|
---|
751 | * // Create then start the one-shot timer that is responsible for turning
|
---|
752 | * // the back-light off if no keys are pressed within a 5 second period.
|
---|
753 | * xBacklightTimer = xTimerCreate( "BacklightTimer", // Just a text name, not used by the kernel.
|
---|
754 | * ( 5000 / portTICK_PERIOD_MS), // The timer period in ticks.
|
---|
755 | * pdFALSE, // The timer is a one-shot timer.
|
---|
756 | * 0, // The id is not used by the callback so can take any value.
|
---|
757 | * vBacklightTimerCallback // The callback function that switches the LCD back-light off.
|
---|
758 | * );
|
---|
759 | *
|
---|
760 | * if( xBacklightTimer == NULL )
|
---|
761 | * {
|
---|
762 | * // The timer was not created.
|
---|
763 | * }
|
---|
764 | * else
|
---|
765 | * {
|
---|
766 | * // Start the timer. No block time is specified, and even if one was
|
---|
767 | * // it would be ignored because the scheduler has not yet been
|
---|
768 | * // started.
|
---|
769 | * if( xTimerStart( xBacklightTimer, 0 ) != pdPASS )
|
---|
770 | * {
|
---|
771 | * // The timer could not be set into the Active state.
|
---|
772 | * }
|
---|
773 | * }
|
---|
774 | *
|
---|
775 | * // ...
|
---|
776 | * // Create tasks here.
|
---|
777 | * // ...
|
---|
778 | *
|
---|
779 | * // Starting the scheduler will start the timer running as it has already
|
---|
780 | * // been set into the active state.
|
---|
781 | * vTaskStartScheduler();
|
---|
782 | *
|
---|
783 | * // Should not reach here.
|
---|
784 | * for( ;; );
|
---|
785 | * }
|
---|
786 | * @endverbatim
|
---|
787 | */
|
---|
788 | #define xTimerReset( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) )
|
---|
789 |
|
---|
790 | /**
|
---|
791 | * BaseType_t xTimerStartFromISR( TimerHandle_t xTimer,
|
---|
792 | * BaseType_t *pxHigherPriorityTaskWoken );
|
---|
793 | *
|
---|
794 | * A version of xTimerStart() that can be called from an interrupt service
|
---|
795 | * routine.
|
---|
796 | *
|
---|
797 | * @param xTimer The handle of the timer being started/restarted.
|
---|
798 | *
|
---|
799 | * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most
|
---|
800 | * of its time in the Blocked state, waiting for messages to arrive on the timer
|
---|
801 | * command queue. Calling xTimerStartFromISR() writes a message to the timer
|
---|
802 | * command queue, so has the potential to transition the timer service/daemon
|
---|
803 | * task out of the Blocked state. If calling xTimerStartFromISR() causes the
|
---|
804 | * timer service/daemon task to leave the Blocked state, and the timer service/
|
---|
805 | * daemon task has a priority equal to or greater than the currently executing
|
---|
806 | * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will
|
---|
807 | * get set to pdTRUE internally within the xTimerStartFromISR() function. If
|
---|
808 | * xTimerStartFromISR() sets this value to pdTRUE then a context switch should
|
---|
809 | * be performed before the interrupt exits.
|
---|
810 | *
|
---|
811 | * @return pdFAIL will be returned if the start command could not be sent to
|
---|
812 | * the timer command queue. pdPASS will be returned if the command was
|
---|
813 | * successfully sent to the timer command queue. When the command is actually
|
---|
814 | * processed will depend on the priority of the timer service/daemon task
|
---|
815 | * relative to other tasks in the system, although the timers expiry time is
|
---|
816 | * relative to when xTimerStartFromISR() is actually called. The timer
|
---|
817 | * service/daemon task priority is set by the configTIMER_TASK_PRIORITY
|
---|
818 | * configuration constant.
|
---|
819 | *
|
---|
820 | * Example usage:
|
---|
821 | * @verbatim
|
---|
822 | * // This scenario assumes xBacklightTimer has already been created. When a
|
---|
823 | * // key is pressed, an LCD back-light is switched on. If 5 seconds pass
|
---|
824 | * // without a key being pressed, then the LCD back-light is switched off. In
|
---|
825 | * // this case, the timer is a one-shot timer, and unlike the example given for
|
---|
826 | * // the xTimerReset() function, the key press event handler is an interrupt
|
---|
827 | * // service routine.
|
---|
828 | *
|
---|
829 | * // The callback function assigned to the one-shot timer. In this case the
|
---|
830 | * // parameter is not used.
|
---|
831 | * void vBacklightTimerCallback( TimerHandle_t pxTimer )
|
---|
832 | * {
|
---|
833 | * // The timer expired, therefore 5 seconds must have passed since a key
|
---|
834 | * // was pressed. Switch off the LCD back-light.
|
---|
835 | * vSetBacklightState( BACKLIGHT_OFF );
|
---|
836 | * }
|
---|
837 | *
|
---|
838 | * // The key press interrupt service routine.
|
---|
839 | * void vKeyPressEventInterruptHandler( void )
|
---|
840 | * {
|
---|
841 | * BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
---|
842 | *
|
---|
843 | * // Ensure the LCD back-light is on, then restart the timer that is
|
---|
844 | * // responsible for turning the back-light off after 5 seconds of
|
---|
845 | * // key inactivity. This is an interrupt service routine so can only
|
---|
846 | * // call FreeRTOS API functions that end in "FromISR".
|
---|
847 | * vSetBacklightState( BACKLIGHT_ON );
|
---|
848 | *
|
---|
849 | * // xTimerStartFromISR() or xTimerResetFromISR() could be called here
|
---|
850 | * // as both cause the timer to re-calculate its expiry time.
|
---|
851 | * // xHigherPriorityTaskWoken was initialised to pdFALSE when it was
|
---|
852 | * // declared (in this function).
|
---|
853 | * if( xTimerStartFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS )
|
---|
854 | * {
|
---|
855 | * // The start command was not executed successfully. Take appropriate
|
---|
856 | * // action here.
|
---|
857 | * }
|
---|
858 | *
|
---|
859 | * // Perform the rest of the key processing here.
|
---|
860 | *
|
---|
861 | * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch
|
---|
862 | * // should be performed. The syntax required to perform a context switch
|
---|
863 | * // from inside an ISR varies from port to port, and from compiler to
|
---|
864 | * // compiler. Inspect the demos for the port you are using to find the
|
---|
865 | * // actual syntax required.
|
---|
866 | * if( xHigherPriorityTaskWoken != pdFALSE )
|
---|
867 | * {
|
---|
868 | * // Call the interrupt safe yield function here (actual function
|
---|
869 | * // depends on the FreeRTOS port being used).
|
---|
870 | * }
|
---|
871 | * }
|
---|
872 | * @endverbatim
|
---|
873 | */
|
---|
874 | #define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )
|
---|
875 |
|
---|
876 | /**
|
---|
877 | * BaseType_t xTimerStopFromISR( TimerHandle_t xTimer,
|
---|
878 | * BaseType_t *pxHigherPriorityTaskWoken );
|
---|
879 | *
|
---|
880 | * A version of xTimerStop() that can be called from an interrupt service
|
---|
881 | * routine.
|
---|
882 | *
|
---|
883 | * @param xTimer The handle of the timer being stopped.
|
---|
884 | *
|
---|
885 | * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most
|
---|
886 | * of its time in the Blocked state, waiting for messages to arrive on the timer
|
---|
887 | * command queue. Calling xTimerStopFromISR() writes a message to the timer
|
---|
888 | * command queue, so has the potential to transition the timer service/daemon
|
---|
889 | * task out of the Blocked state. If calling xTimerStopFromISR() causes the
|
---|
890 | * timer service/daemon task to leave the Blocked state, and the timer service/
|
---|
891 | * daemon task has a priority equal to or greater than the currently executing
|
---|
892 | * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will
|
---|
893 | * get set to pdTRUE internally within the xTimerStopFromISR() function. If
|
---|
894 | * xTimerStopFromISR() sets this value to pdTRUE then a context switch should
|
---|
895 | * be performed before the interrupt exits.
|
---|
896 | *
|
---|
897 | * @return pdFAIL will be returned if the stop command could not be sent to
|
---|
898 | * the timer command queue. pdPASS will be returned if the command was
|
---|
899 | * successfully sent to the timer command queue. When the command is actually
|
---|
900 | * processed will depend on the priority of the timer service/daemon task
|
---|
901 | * relative to other tasks in the system. The timer service/daemon task
|
---|
902 | * priority is set by the configTIMER_TASK_PRIORITY configuration constant.
|
---|
903 | *
|
---|
904 | * Example usage:
|
---|
905 | * @verbatim
|
---|
906 | * // This scenario assumes xTimer has already been created and started. When
|
---|
907 | * // an interrupt occurs, the timer should be simply stopped.
|
---|
908 | *
|
---|
909 | * // The interrupt service routine that stops the timer.
|
---|
910 | * void vAnExampleInterruptServiceRoutine( void )
|
---|
911 | * {
|
---|
912 | * BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
---|
913 | *
|
---|
914 | * // The interrupt has occurred - simply stop the timer.
|
---|
915 | * // xHigherPriorityTaskWoken was set to pdFALSE where it was defined
|
---|
916 | * // (within this function). As this is an interrupt service routine, only
|
---|
917 | * // FreeRTOS API functions that end in "FromISR" can be used.
|
---|
918 | * if( xTimerStopFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS )
|
---|
919 | * {
|
---|
920 | * // The stop command was not executed successfully. Take appropriate
|
---|
921 | * // action here.
|
---|
922 | * }
|
---|
923 | *
|
---|
924 | * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch
|
---|
925 | * // should be performed. The syntax required to perform a context switch
|
---|
926 | * // from inside an ISR varies from port to port, and from compiler to
|
---|
927 | * // compiler. Inspect the demos for the port you are using to find the
|
---|
928 | * // actual syntax required.
|
---|
929 | * if( xHigherPriorityTaskWoken != pdFALSE )
|
---|
930 | * {
|
---|
931 | * // Call the interrupt safe yield function here (actual function
|
---|
932 | * // depends on the FreeRTOS port being used).
|
---|
933 | * }
|
---|
934 | * }
|
---|
935 | * @endverbatim
|
---|
936 | */
|
---|
937 | #define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP_FROM_ISR, 0, ( pxHigherPriorityTaskWoken ), 0U )
|
---|
938 |
|
---|
939 | /**
|
---|
940 | * BaseType_t xTimerChangePeriodFromISR( TimerHandle_t xTimer,
|
---|
941 | * TickType_t xNewPeriod,
|
---|
942 | * BaseType_t *pxHigherPriorityTaskWoken );
|
---|
943 | *
|
---|
944 | * A version of xTimerChangePeriod() that can be called from an interrupt
|
---|
945 | * service routine.
|
---|
946 | *
|
---|
947 | * @param xTimer The handle of the timer that is having its period changed.
|
---|
948 | *
|
---|
949 | * @param xNewPeriod The new period for xTimer. Timer periods are specified in
|
---|
950 | * tick periods, so the constant portTICK_PERIOD_MS can be used to convert a time
|
---|
951 | * that has been specified in milliseconds. For example, if the timer must
|
---|
952 | * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively,
|
---|
953 | * if the timer must expire after 500ms, then xNewPeriod can be set to
|
---|
954 | * ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than
|
---|
955 | * or equal to 1000.
|
---|
956 | *
|
---|
957 | * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most
|
---|
958 | * of its time in the Blocked state, waiting for messages to arrive on the timer
|
---|
959 | * command queue. Calling xTimerChangePeriodFromISR() writes a message to the
|
---|
960 | * timer command queue, so has the potential to transition the timer service/
|
---|
961 | * daemon task out of the Blocked state. If calling xTimerChangePeriodFromISR()
|
---|
962 | * causes the timer service/daemon task to leave the Blocked state, and the
|
---|
963 | * timer service/daemon task has a priority equal to or greater than the
|
---|
964 | * currently executing task (the task that was interrupted), then
|
---|
965 | * *pxHigherPriorityTaskWoken will get set to pdTRUE internally within the
|
---|
966 | * xTimerChangePeriodFromISR() function. If xTimerChangePeriodFromISR() sets
|
---|
967 | * this value to pdTRUE then a context switch should be performed before the
|
---|
968 | * interrupt exits.
|
---|
969 | *
|
---|
970 | * @return pdFAIL will be returned if the command to change the timers period
|
---|
971 | * could not be sent to the timer command queue. pdPASS will be returned if the
|
---|
972 | * command was successfully sent to the timer command queue. When the command
|
---|
973 | * is actually processed will depend on the priority of the timer service/daemon
|
---|
974 | * task relative to other tasks in the system. The timer service/daemon task
|
---|
975 | * priority is set by the configTIMER_TASK_PRIORITY configuration constant.
|
---|
976 | *
|
---|
977 | * Example usage:
|
---|
978 | * @verbatim
|
---|
979 | * // This scenario assumes xTimer has already been created and started. When
|
---|
980 | * // an interrupt occurs, the period of xTimer should be changed to 500ms.
|
---|
981 | *
|
---|
982 | * // The interrupt service routine that changes the period of xTimer.
|
---|
983 | * void vAnExampleInterruptServiceRoutine( void )
|
---|
984 | * {
|
---|
985 | * BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
---|
986 | *
|
---|
987 | * // The interrupt has occurred - change the period of xTimer to 500ms.
|
---|
988 | * // xHigherPriorityTaskWoken was set to pdFALSE where it was defined
|
---|
989 | * // (within this function). As this is an interrupt service routine, only
|
---|
990 | * // FreeRTOS API functions that end in "FromISR" can be used.
|
---|
991 | * if( xTimerChangePeriodFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS )
|
---|
992 | * {
|
---|
993 | * // The command to change the timers period was not executed
|
---|
994 | * // successfully. Take appropriate action here.
|
---|
995 | * }
|
---|
996 | *
|
---|
997 | * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch
|
---|
998 | * // should be performed. The syntax required to perform a context switch
|
---|
999 | * // from inside an ISR varies from port to port, and from compiler to
|
---|
1000 | * // compiler. Inspect the demos for the port you are using to find the
|
---|
1001 | * // actual syntax required.
|
---|
1002 | * if( xHigherPriorityTaskWoken != pdFALSE )
|
---|
1003 | * {
|
---|
1004 | * // Call the interrupt safe yield function here (actual function
|
---|
1005 | * // depends on the FreeRTOS port being used).
|
---|
1006 | * }
|
---|
1007 | * }
|
---|
1008 | * @endverbatim
|
---|
1009 | */
|
---|
1010 | #define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD_FROM_ISR, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U )
|
---|
1011 |
|
---|
1012 | /**
|
---|
1013 | * BaseType_t xTimerResetFromISR( TimerHandle_t xTimer,
|
---|
1014 | * BaseType_t *pxHigherPriorityTaskWoken );
|
---|
1015 | *
|
---|
1016 | * A version of xTimerReset() that can be called from an interrupt service
|
---|
1017 | * routine.
|
---|
1018 | *
|
---|
1019 | * @param xTimer The handle of the timer that is to be started, reset, or
|
---|
1020 | * restarted.
|
---|
1021 | *
|
---|
1022 | * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most
|
---|
1023 | * of its time in the Blocked state, waiting for messages to arrive on the timer
|
---|
1024 | * command queue. Calling xTimerResetFromISR() writes a message to the timer
|
---|
1025 | * command queue, so has the potential to transition the timer service/daemon
|
---|
1026 | * task out of the Blocked state. If calling xTimerResetFromISR() causes the
|
---|
1027 | * timer service/daemon task to leave the Blocked state, and the timer service/
|
---|
1028 | * daemon task has a priority equal to or greater than the currently executing
|
---|
1029 | * task (the task that was interrupted), then *pxHigherPriorityTaskWoken will
|
---|
1030 | * get set to pdTRUE internally within the xTimerResetFromISR() function. If
|
---|
1031 | * xTimerResetFromISR() sets this value to pdTRUE then a context switch should
|
---|
1032 | * be performed before the interrupt exits.
|
---|
1033 | *
|
---|
1034 | * @return pdFAIL will be returned if the reset command could not be sent to
|
---|
1035 | * the timer command queue. pdPASS will be returned if the command was
|
---|
1036 | * successfully sent to the timer command queue. When the command is actually
|
---|
1037 | * processed will depend on the priority of the timer service/daemon task
|
---|
1038 | * relative to other tasks in the system, although the timers expiry time is
|
---|
1039 | * relative to when xTimerResetFromISR() is actually called. The timer service/daemon
|
---|
1040 | * task priority is set by the configTIMER_TASK_PRIORITY configuration constant.
|
---|
1041 | *
|
---|
1042 | * Example usage:
|
---|
1043 | * @verbatim
|
---|
1044 | * // This scenario assumes xBacklightTimer has already been created. When a
|
---|
1045 | * // key is pressed, an LCD back-light is switched on. If 5 seconds pass
|
---|
1046 | * // without a key being pressed, then the LCD back-light is switched off. In
|
---|
1047 | * // this case, the timer is a one-shot timer, and unlike the example given for
|
---|
1048 | * // the xTimerReset() function, the key press event handler is an interrupt
|
---|
1049 | * // service routine.
|
---|
1050 | *
|
---|
1051 | * // The callback function assigned to the one-shot timer. In this case the
|
---|
1052 | * // parameter is not used.
|
---|
1053 | * void vBacklightTimerCallback( TimerHandle_t pxTimer )
|
---|
1054 | * {
|
---|
1055 | * // The timer expired, therefore 5 seconds must have passed since a key
|
---|
1056 | * // was pressed. Switch off the LCD back-light.
|
---|
1057 | * vSetBacklightState( BACKLIGHT_OFF );
|
---|
1058 | * }
|
---|
1059 | *
|
---|
1060 | * // The key press interrupt service routine.
|
---|
1061 | * void vKeyPressEventInterruptHandler( void )
|
---|
1062 | * {
|
---|
1063 | * BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
---|
1064 | *
|
---|
1065 | * // Ensure the LCD back-light is on, then reset the timer that is
|
---|
1066 | * // responsible for turning the back-light off after 5 seconds of
|
---|
1067 | * // key inactivity. This is an interrupt service routine so can only
|
---|
1068 | * // call FreeRTOS API functions that end in "FromISR".
|
---|
1069 | * vSetBacklightState( BACKLIGHT_ON );
|
---|
1070 | *
|
---|
1071 | * // xTimerStartFromISR() or xTimerResetFromISR() could be called here
|
---|
1072 | * // as both cause the timer to re-calculate its expiry time.
|
---|
1073 | * // xHigherPriorityTaskWoken was initialised to pdFALSE when it was
|
---|
1074 | * // declared (in this function).
|
---|
1075 | * if( xTimerResetFromISR( xBacklightTimer, &xHigherPriorityTaskWoken ) != pdPASS )
|
---|
1076 | * {
|
---|
1077 | * // The reset command was not executed successfully. Take appropriate
|
---|
1078 | * // action here.
|
---|
1079 | * }
|
---|
1080 | *
|
---|
1081 | * // Perform the rest of the key processing here.
|
---|
1082 | *
|
---|
1083 | * // If xHigherPriorityTaskWoken equals pdTRUE, then a context switch
|
---|
1084 | * // should be performed. The syntax required to perform a context switch
|
---|
1085 | * // from inside an ISR varies from port to port, and from compiler to
|
---|
1086 | * // compiler. Inspect the demos for the port you are using to find the
|
---|
1087 | * // actual syntax required.
|
---|
1088 | * if( xHigherPriorityTaskWoken != pdFALSE )
|
---|
1089 | * {
|
---|
1090 | * // Call the interrupt safe yield function here (actual function
|
---|
1091 | * // depends on the FreeRTOS port being used).
|
---|
1092 | * }
|
---|
1093 | * }
|
---|
1094 | * @endverbatim
|
---|
1095 | */
|
---|
1096 | #define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )
|
---|
1097 |
|
---|
1098 |
|
---|
1099 | /**
|
---|
1100 | * BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend,
|
---|
1101 | * void *pvParameter1,
|
---|
1102 | * uint32_t ulParameter2,
|
---|
1103 | * BaseType_t *pxHigherPriorityTaskWoken );
|
---|
1104 | *
|
---|
1105 | *
|
---|
1106 | * Used from application interrupt service routines to defer the execution of a
|
---|
1107 | * function to the RTOS daemon task (the timer service task, hence this function
|
---|
1108 | * is implemented in timers.c and is prefixed with 'Timer').
|
---|
1109 | *
|
---|
1110 | * Ideally an interrupt service routine (ISR) is kept as short as possible, but
|
---|
1111 | * sometimes an ISR either has a lot of processing to do, or needs to perform
|
---|
1112 | * processing that is not deterministic. In these cases
|
---|
1113 | * xTimerPendFunctionCallFromISR() can be used to defer processing of a function
|
---|
1114 | * to the RTOS daemon task.
|
---|
1115 | *
|
---|
1116 | * A mechanism is provided that allows the interrupt to return directly to the
|
---|
1117 | * task that will subsequently execute the pended callback function. This
|
---|
1118 | * allows the callback function to execute contiguously in time with the
|
---|
1119 | * interrupt - just as if the callback had executed in the interrupt itself.
|
---|
1120 | *
|
---|
1121 | * @param xFunctionToPend The function to execute from the timer service/
|
---|
1122 | * daemon task. The function must conform to the PendedFunction_t
|
---|
1123 | * prototype.
|
---|
1124 | *
|
---|
1125 | * @param pvParameter1 The value of the callback function's first parameter.
|
---|
1126 | * The parameter has a void * type to allow it to be used to pass any type.
|
---|
1127 | * For example, unsigned longs can be cast to a void *, or the void * can be
|
---|
1128 | * used to point to a structure.
|
---|
1129 | *
|
---|
1130 | * @param ulParameter2 The value of the callback function's second parameter.
|
---|
1131 | *
|
---|
1132 | * @param pxHigherPriorityTaskWoken As mentioned above, calling this function
|
---|
1133 | * will result in a message being sent to the timer daemon task. If the
|
---|
1134 | * priority of the timer daemon task (which is set using
|
---|
1135 | * configTIMER_TASK_PRIORITY in FreeRTOSConfig.h) is higher than the priority of
|
---|
1136 | * the currently running task (the task the interrupt interrupted) then
|
---|
1137 | * *pxHigherPriorityTaskWoken will be set to pdTRUE within
|
---|
1138 | * xTimerPendFunctionCallFromISR(), indicating that a context switch should be
|
---|
1139 | * requested before the interrupt exits. For that reason
|
---|
1140 | * *pxHigherPriorityTaskWoken must be initialised to pdFALSE. See the
|
---|
1141 | * example code below.
|
---|
1142 | *
|
---|
1143 | * @return pdPASS is returned if the message was successfully sent to the
|
---|
1144 | * timer daemon task, otherwise pdFALSE is returned.
|
---|
1145 | *
|
---|
1146 | * Example usage:
|
---|
1147 | * @verbatim
|
---|
1148 | *
|
---|
1149 | * // The callback function that will execute in the context of the daemon task.
|
---|
1150 | * // Note callback functions must all use this same prototype.
|
---|
1151 | * void vProcessInterface( void *pvParameter1, uint32_t ulParameter2 )
|
---|
1152 | * {
|
---|
1153 | * BaseType_t xInterfaceToService;
|
---|
1154 | *
|
---|
1155 | * // The interface that requires servicing is passed in the second
|
---|
1156 | * // parameter. The first parameter is not used in this case.
|
---|
1157 | * xInterfaceToService = ( BaseType_t ) ulParameter2;
|
---|
1158 | *
|
---|
1159 | * // ...Perform the processing here...
|
---|
1160 | * }
|
---|
1161 | *
|
---|
1162 | * // An ISR that receives data packets from multiple interfaces
|
---|
1163 | * void vAnISR( void )
|
---|
1164 | * {
|
---|
1165 | * BaseType_t xInterfaceToService, xHigherPriorityTaskWoken;
|
---|
1166 | *
|
---|
1167 | * // Query the hardware to determine which interface needs processing.
|
---|
1168 | * xInterfaceToService = prvCheckInterfaces();
|
---|
1169 | *
|
---|
1170 | * // The actual processing is to be deferred to a task. Request the
|
---|
1171 | * // vProcessInterface() callback function is executed, passing in the
|
---|
1172 | * // number of the interface that needs processing. The interface to
|
---|
1173 | * // service is passed in the second parameter. The first parameter is
|
---|
1174 | * // not used in this case.
|
---|
1175 | * xHigherPriorityTaskWoken = pdFALSE;
|
---|
1176 | * xTimerPendFunctionCallFromISR( vProcessInterface, NULL, ( uint32_t ) xInterfaceToService, &xHigherPriorityTaskWoken );
|
---|
1177 | *
|
---|
1178 | * // If xHigherPriorityTaskWoken is now set to pdTRUE then a context
|
---|
1179 | * // switch should be requested. The macro used is port specific and will
|
---|
1180 | * // be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - refer to
|
---|
1181 | * // the documentation page for the port being used.
|
---|
1182 | * portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
---|
1183 | *
|
---|
1184 | * }
|
---|
1185 | * @endverbatim
|
---|
1186 | */
|
---|
1187 | BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
|
---|
1188 |
|
---|
1189 | /**
|
---|
1190 | * BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend,
|
---|
1191 | * void *pvParameter1,
|
---|
1192 | * uint32_t ulParameter2,
|
---|
1193 | * TickType_t xTicksToWait );
|
---|
1194 | *
|
---|
1195 | *
|
---|
1196 | * Used to defer the execution of a function to the RTOS daemon task (the timer
|
---|
1197 | * service task, hence this function is implemented in timers.c and is prefixed
|
---|
1198 | * with 'Timer').
|
---|
1199 | *
|
---|
1200 | * @param xFunctionToPend The function to execute from the timer service/
|
---|
1201 | * daemon task. The function must conform to the PendedFunction_t
|
---|
1202 | * prototype.
|
---|
1203 | *
|
---|
1204 | * @param pvParameter1 The value of the callback function's first parameter.
|
---|
1205 | * The parameter has a void * type to allow it to be used to pass any type.
|
---|
1206 | * For example, unsigned longs can be cast to a void *, or the void * can be
|
---|
1207 | * used to point to a structure.
|
---|
1208 | *
|
---|
1209 | * @param ulParameter2 The value of the callback function's second parameter.
|
---|
1210 | *
|
---|
1211 | * @param xTicksToWait Calling this function will result in a message being
|
---|
1212 | * sent to the timer daemon task on a queue. xTicksToWait is the amount of
|
---|
1213 | * time the calling task should remain in the Blocked state (so not using any
|
---|
1214 | * processing time) for space to become available on the timer queue if the
|
---|
1215 | * queue is found to be full.
|
---|
1216 | *
|
---|
1217 | * @return pdPASS is returned if the message was successfully sent to the
|
---|
1218 | * timer daemon task, otherwise pdFALSE is returned.
|
---|
1219 | *
|
---|
1220 | */
|
---|
1221 | BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
|
---|
1222 |
|
---|
1223 | /**
|
---|
1224 | * const char * const pcTimerGetName( TimerHandle_t xTimer );
|
---|
1225 | *
|
---|
1226 | * Returns the name that was assigned to a timer when the timer was created.
|
---|
1227 | *
|
---|
1228 | * @param xTimer The handle of the timer being queried.
|
---|
1229 | *
|
---|
1230 | * @return The name assigned to the timer specified by the xTimer parameter.
|
---|
1231 | */
|
---|
1232 | const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
---|
1233 |
|
---|
1234 | /**
|
---|
1235 | * void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload );
|
---|
1236 | *
|
---|
1237 | * Updates a timer to be either an auto-reload timer, in which case the timer
|
---|
1238 | * automatically resets itself each time it expires, or a one-shot timer, in
|
---|
1239 | * which case the timer will only expire once unless it is manually restarted.
|
---|
1240 | *
|
---|
1241 | * @param xTimer The handle of the timer being updated.
|
---|
1242 | *
|
---|
1243 | * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will
|
---|
1244 | * expire repeatedly with a frequency set by the timer's period (see the
|
---|
1245 | * xTimerPeriodInTicks parameter of the xTimerCreate() API function). If
|
---|
1246 | * uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and
|
---|
1247 | * enter the dormant state after it expires.
|
---|
1248 | */
|
---|
1249 | void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION;
|
---|
1250 |
|
---|
1251 | /**
|
---|
1252 | * UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer );
|
---|
1253 | *
|
---|
1254 | * Queries a timer to determine if it is an auto-reload timer, in which case the timer
|
---|
1255 | * automatically resets itself each time it expires, or a one-shot timer, in
|
---|
1256 | * which case the timer will only expire once unless it is manually restarted.
|
---|
1257 | *
|
---|
1258 | * @param xTimer The handle of the timer being queried.
|
---|
1259 | *
|
---|
1260 | * @return If the timer is an auto-reload timer then pdTRUE is returned, otherwise
|
---|
1261 | * pdFALSE is returned.
|
---|
1262 | */
|
---|
1263 | UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
---|
1264 |
|
---|
1265 | /**
|
---|
1266 | * TickType_t xTimerGetPeriod( TimerHandle_t xTimer );
|
---|
1267 | *
|
---|
1268 | * Returns the period of a timer.
|
---|
1269 | *
|
---|
1270 | * @param xTimer The handle of the timer being queried.
|
---|
1271 | *
|
---|
1272 | * @return The period of the timer in ticks.
|
---|
1273 | */
|
---|
1274 | TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
---|
1275 |
|
---|
1276 | /**
|
---|
1277 | * TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer );
|
---|
1278 | *
|
---|
1279 | * Returns the time in ticks at which the timer will expire. If this is less
|
---|
1280 | * than the current tick count then the expiry time has overflowed from the
|
---|
1281 | * current time.
|
---|
1282 | *
|
---|
1283 | * @param xTimer The handle of the timer being queried.
|
---|
1284 | *
|
---|
1285 | * @return If the timer is running then the time in ticks at which the timer
|
---|
1286 | * will next expire is returned. If the timer is not running then the return
|
---|
1287 | * value is undefined.
|
---|
1288 | */
|
---|
1289 | TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
---|
1290 |
|
---|
1291 | /*
|
---|
1292 | * Functions beyond this part are not part of the public API and are intended
|
---|
1293 | * for use by the kernel only.
|
---|
1294 | */
|
---|
1295 | BaseType_t xTimerCreateTimerTask( void ) PRIVILEGED_FUNCTION;
|
---|
1296 | BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
|
---|
1297 |
|
---|
1298 | #if( configUSE_TRACE_FACILITY == 1 )
|
---|
1299 | void vTimerSetTimerNumber( TimerHandle_t xTimer, UBaseType_t uxTimerNumber ) PRIVILEGED_FUNCTION;
|
---|
1300 | UBaseType_t uxTimerGetTimerNumber( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
|
---|
1301 | #endif
|
---|
1302 |
|
---|
1303 | #ifdef __cplusplus
|
---|
1304 | }
|
---|
1305 | #endif
|
---|
1306 | #endif /* TIMERS_H */
|
---|
1307 |
|
---|
1308 |
|
---|
1309 |
|
---|