]> begriffs open source - freertos/blob - Source/include/FreeRTOS.h
Added run time stats functions.
[freertos] / Source / include / FreeRTOS.h
1 /*\r
2         FreeRTOS.org V5.2.0 - Copyright (C) 2003-2009 Richard Barry.\r
3 \r
4         This file is part of the FreeRTOS.org distribution.\r
5 \r
6         FreeRTOS.org is free software; you can redistribute it and/or modify it \r
7         under the terms of the GNU General Public License (version 2) as published\r
8         by the Free Software Foundation and modified by the FreeRTOS exception.\r
9 \r
10         FreeRTOS.org is distributed in the hope that it will be useful, but WITHOUT\r
11         ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or \r
12         FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for \r
13         more details.\r
14 \r
15         You should have received a copy of the GNU General Public License along \r
16         with FreeRTOS.org; if not, write to the Free Software Foundation, Inc., 59 \r
17         Temple Place, Suite 330, Boston, MA  02111-1307  USA.\r
18 \r
19         A special exception to the GPL is included to allow you to distribute a \r
20         combined work that includes FreeRTOS.org without being obliged to provide\r
21         the source code for any proprietary components.  See the licensing section\r
22         of http://www.FreeRTOS.org for full details.\r
23 \r
24 \r
25         ***************************************************************************\r
26         *                                                                         *\r
27         * Get the FreeRTOS eBook!  See http://www.FreeRTOS.org/Documentation      *\r
28         *                                                                         *\r
29         * This is a concise, step by step, 'hands on' guide that describes both   *\r
30         * general multitasking concepts and FreeRTOS specifics. It presents and   *\r
31         * explains numerous examples that are written using the FreeRTOS API.     *\r
32         * Full source code for all the examples is provided in an accompanying    *\r
33         * .zip file.                                                              *\r
34         *                                                                         *\r
35         ***************************************************************************\r
36 \r
37         1 tab == 4 spaces!\r
38 \r
39         Please ensure to read the configuration and relevant port sections of the\r
40         online documentation.\r
41 \r
42         http://www.FreeRTOS.org - Documentation, latest information, license and\r
43         contact details.\r
44 \r
45         http://www.SafeRTOS.com - A version that is certified for use in safety\r
46         critical systems.\r
47 \r
48         http://www.OpenRTOS.com - Commercial support, development, porting,\r
49         licensing and training services.\r
50 */\r
51 \r
52 #ifndef INC_FREERTOS_H\r
53 #define INC_FREERTOS_H\r
54 \r
55 \r
56 /*\r
57  * Include the generic headers required for the FreeRTOS port being used.\r
58  */\r
59 #include <stddef.h>\r
60 \r
61 /* Basic FreeRTOS definitions. */\r
62 #include "projdefs.h"\r
63 \r
64 /* Application specific configuration options. */\r
65 #include "FreeRTOSConfig.h"\r
66 \r
67 /* Definitions specific to the port being used. */\r
68 #include "portable.h"\r
69 \r
70 \r
71 /* Defines the prototype to which the application task hook function must\r
72 conform. */\r
73 typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * );\r
74 \r
75 \r
76 \r
77 \r
78 \r
79 /*\r
80  * Check all the required application specific macros have been defined.\r
81  * These macros are application specific and (as downloaded) are defined\r
82  * within FreeRTOSConfig.h.\r
83  */\r
84 \r
85 #ifndef configUSE_PREEMPTION\r
86         #error Missing definition:  configUSE_PREEMPTION should be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
87 #endif\r
88 \r
89 #ifndef configUSE_IDLE_HOOK\r
90         #error Missing definition:  configUSE_IDLE_HOOK should be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
91 #endif\r
92 \r
93 #ifndef configUSE_TICK_HOOK\r
94         #error Missing definition:  configUSE_TICK_HOOK should be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
95 #endif\r
96 \r
97 #ifndef configUSE_CO_ROUTINES\r
98         #error  Missing definition:  configUSE_CO_ROUTINES should be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
99 #endif\r
100 \r
101 #ifndef INCLUDE_vTaskPrioritySet\r
102         #error Missing definition:  INCLUDE_vTaskPrioritySet should be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
103 #endif\r
104 \r
105 #ifndef INCLUDE_uxTaskPriorityGet\r
106         #error Missing definition:  INCLUDE_uxTaskPriorityGet should be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
107 #endif\r
108 \r
109 #ifndef INCLUDE_vTaskDelete             \r
110         #error Missing definition:  INCLUDE_vTaskDelete          should be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
111 #endif\r
112 \r
113 #ifndef INCLUDE_vTaskCleanUpResources\r
114         #error Missing definition:  INCLUDE_vTaskCleanUpResources should be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
115 #endif\r
116 \r
117 #ifndef INCLUDE_vTaskSuspend    \r
118         #error Missing definition:  INCLUDE_vTaskSuspend         should be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
119 #endif\r
120 \r
121 #ifndef INCLUDE_vTaskDelayUntil\r
122         #error Missing definition:  INCLUDE_vTaskDelayUntil should be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
123 #endif\r
124 \r
125 #ifndef INCLUDE_vTaskDelay\r
126         #error Missing definition:  INCLUDE_vTaskDelay should be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
127 #endif\r
128 \r
129 #ifndef configUSE_16_BIT_TICKS\r
130         #error Missing definition:  configUSE_16_BIT_TICKS should be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
131 #endif\r
132 \r
133 #ifndef configUSE_APPLICATION_TASK_TAG\r
134         #define configUSE_APPLICATION_TASK_TAG 0\r
135 #endif\r
136 \r
137 #ifndef INCLUDE_uxTaskGetStackHighWaterMark\r
138         #define INCLUDE_uxTaskGetStackHighWaterMark 0\r
139 #endif\r
140 \r
141 #ifndef configUSE_RECURSIVE_MUTEXES\r
142         #define configUSE_RECURSIVE_MUTEXES 0\r
143 #endif\r
144 \r
145 #ifndef configUSE_MUTEXES\r
146         #define configUSE_MUTEXES 0\r
147 #endif\r
148 \r
149 #ifndef configUSE_COUNTING_SEMAPHORES\r
150         #define configUSE_COUNTING_SEMAPHORES 0\r
151 #endif\r
152 \r
153 #ifndef configUSE_ALTERNATIVE_API\r
154         #define configUSE_ALTERNATIVE_API 0\r
155 #endif\r
156 \r
157 #ifndef portCRITICAL_NESTING_IN_TCB\r
158         #define portCRITICAL_NESTING_IN_TCB 0\r
159 #endif\r
160 \r
161 #ifndef configMAX_TASK_NAME_LEN\r
162         #define configMAX_TASK_NAME_LEN 16\r
163 #endif\r
164 \r
165 #ifndef configIDLE_SHOULD_YIELD\r
166         #define configIDLE_SHOULD_YIELD         1\r
167 #endif\r
168 \r
169 #if configMAX_TASK_NAME_LEN < 1\r
170         #undef configMAX_TASK_NAME_LEN\r
171         #define configMAX_TASK_NAME_LEN 1\r
172 #endif\r
173 \r
174 #ifndef INCLUDE_xTaskResumeFromISR\r
175         #define INCLUDE_xTaskResumeFromISR 1\r
176 #endif\r
177 \r
178 #ifndef INCLUDE_xTaskGetSchedulerState\r
179         #define INCLUDE_xTaskGetSchedulerState 0\r
180 #endif\r
181 \r
182 #if ( configUSE_MUTEXES == 1 )\r
183         /* xTaskGetCurrentTaskHandle is used by the priority inheritance mechanism\r
184         within the mutex implementation so must be available if mutexes are used. */\r
185         #undef INCLUDE_xTaskGetCurrentTaskHandle\r
186         #define INCLUDE_xTaskGetCurrentTaskHandle 1\r
187 #else\r
188         #ifndef INCLUDE_xTaskGetCurrentTaskHandle\r
189                 #define INCLUDE_xTaskGetCurrentTaskHandle 0\r
190         #endif\r
191 #endif\r
192 \r
193 \r
194 #ifndef portSET_INTERRUPT_MASK_FROM_ISR\r
195         #define portSET_INTERRUPT_MASK_FROM_ISR() 0\r
196 #endif\r
197 \r
198 #ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR\r
199         #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue\r
200 #endif\r
201 \r
202 \r
203 #ifndef configQUEUE_REGISTRY_SIZE\r
204         #define configQUEUE_REGISTRY_SIZE 0\r
205 #endif\r
206 \r
207 #if configQUEUE_REGISTRY_SIZE < 1\r
208         #define configQUEUE_REGISTRY_SIZE 0\r
209         #define vQueueAddToRegistry( xQueue, pcName )\r
210         #define vQueueUnregisterQueue( xQueue )\r
211 #endif\r
212 \r
213 \r
214 /* Remove any unused trace macros. */\r
215 #ifndef traceSTART\r
216         /* Used to perform any necessary initialisation - for example, open a file\r
217         into which trace is to be written. */\r
218         #define traceSTART()\r
219 #endif\r
220 \r
221 #ifndef traceEND\r
222         /* Use to close a trace, for example close a file into which trace has been\r
223         written. */\r
224         #define traceEND()\r
225 #endif\r
226 \r
227 #ifndef traceTASK_SWITCHED_IN\r
228         /* Called after a task has been selected to run.  pxCurrentTCB holds a pointer\r
229         to the task control block of the selected task. */\r
230         #define traceTASK_SWITCHED_IN()\r
231 #endif\r
232 \r
233 #ifndef traceTASK_SWITCHED_OUT\r
234         /* Called before a task has been selected to run.  pxCurrentTCB holds a pointer\r
235         to the task control block of the task being switched out. */\r
236         #define traceTASK_SWITCHED_OUT()\r
237 #endif\r
238 \r
239 #ifndef traceBLOCKING_ON_QUEUE_RECEIVE\r
240         /* Task is about to block because it cannot read from a \r
241         queue/mutex/semaphore.  pxQueue is a pointer to the queue/mutex/semaphore\r
242         upon which the read was attempted.  pxCurrentTCB points to the TCB of the \r
243         task that attempted the read. */\r
244         #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue )\r
245 #endif\r
246 \r
247 #ifndef traceBLOCKING_ON_QUEUE_SEND\r
248         /* Task is about to block because it cannot write to a \r
249         queue/mutex/semaphore.  pxQueue is a pointer to the queue/mutex/semaphore\r
250         upon which the write was attempted.  pxCurrentTCB points to the TCB of the \r
251         task that attempted the write. */\r
252         #define traceBLOCKING_ON_QUEUE_SEND( pxQueue )\r
253 #endif\r
254 \r
255 #ifndef configCHECK_FOR_STACK_OVERFLOW\r
256         #define configCHECK_FOR_STACK_OVERFLOW 0\r
257 #endif\r
258 \r
259 /* The following event macros are embedded in the kernel API calls. */\r
260 \r
261 #ifndef traceQUEUE_CREATE       \r
262         #define traceQUEUE_CREATE( pxNewQueue )\r
263 #endif\r
264 \r
265 #ifndef traceQUEUE_CREATE_FAILED\r
266         #define traceQUEUE_CREATE_FAILED()\r
267 #endif\r
268 \r
269 #ifndef traceCREATE_MUTEX\r
270         #define traceCREATE_MUTEX( pxNewQueue )\r
271 #endif\r
272 \r
273 #ifndef traceCREATE_MUTEX_FAILED\r
274         #define traceCREATE_MUTEX_FAILED()\r
275 #endif\r
276 \r
277 #ifndef traceGIVE_MUTEX_RECURSIVE\r
278         #define traceGIVE_MUTEX_RECURSIVE( pxMutex )\r
279 #endif\r
280 \r
281 #ifndef traceGIVE_MUTEX_RECURSIVE_FAILED\r
282         #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex )\r
283 #endif\r
284 \r
285 #ifndef traceTAKE_MUTEX_RECURSIVE\r
286         #define traceTAKE_MUTEX_RECURSIVE( pxMutex )\r
287 #endif\r
288 \r
289 #ifndef traceCREATE_COUNTING_SEMAPHORE\r
290         #define traceCREATE_COUNTING_SEMAPHORE()\r
291 #endif\r
292 \r
293 #ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED\r
294         #define traceCREATE_COUNTING_SEMAPHORE_FAILED()\r
295 #endif\r
296 \r
297 #ifndef traceQUEUE_SEND\r
298         #define traceQUEUE_SEND( pxQueue )\r
299 #endif\r
300 \r
301 #ifndef traceQUEUE_SEND_FAILED\r
302         #define traceQUEUE_SEND_FAILED( pxQueue )\r
303 #endif\r
304 \r
305 #ifndef traceQUEUE_RECEIVE\r
306         #define traceQUEUE_RECEIVE( pxQueue )\r
307 #endif\r
308 \r
309 #ifndef traceQUEUE_PEEK\r
310         #define traceQUEUE_PEEK( pxQueue )\r
311 #endif\r
312 \r
313 #ifndef traceQUEUE_RECEIVE_FAILED\r
314         #define traceQUEUE_RECEIVE_FAILED( pxQueue )\r
315 #endif\r
316 \r
317 #ifndef traceQUEUE_SEND_FROM_ISR\r
318         #define traceQUEUE_SEND_FROM_ISR( pxQueue )\r
319 #endif\r
320 \r
321 #ifndef traceQUEUE_SEND_FROM_ISR_FAILED\r
322         #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue )\r
323 #endif\r
324 \r
325 #ifndef traceQUEUE_RECEIVE_FROM_ISR\r
326         #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue )\r
327 #endif\r
328 \r
329 #ifndef traceQUEUE_RECEIVE_FROM_ISR_FAILED\r
330         #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue )\r
331 #endif\r
332 \r
333 #ifndef traceQUEUE_DELETE\r
334         #define traceQUEUE_DELETE( pxQueue )\r
335 #endif\r
336 \r
337 #ifndef traceTASK_CREATE\r
338         #define traceTASK_CREATE( pxNewTCB )\r
339 #endif\r
340 \r
341 #ifndef traceTASK_CREATE_FAILED\r
342         #define traceTASK_CREATE_FAILED( pxNewTCB )\r
343 #endif\r
344 \r
345 #ifndef traceTASK_DELETE\r
346         #define traceTASK_DELETE( pxTaskToDelete )\r
347 #endif\r
348 \r
349 #ifndef traceTASK_DELAY_UNTIL\r
350         #define traceTASK_DELAY_UNTIL()\r
351 #endif\r
352 \r
353 #ifndef traceTASK_DELAY\r
354         #define traceTASK_DELAY()\r
355 #endif\r
356 \r
357 #ifndef traceTASK_PRIORITY_SET\r
358         #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority )\r
359 #endif\r
360 \r
361 #ifndef traceTASK_SUSPEND\r
362         #define traceTASK_SUSPEND( pxTaskToSuspend )\r
363 #endif\r
364 \r
365 #ifndef traceTASK_RESUME\r
366         #define traceTASK_RESUME( pxTaskToResume )\r
367 #endif\r
368 \r
369 #ifndef traceTASK_RESUME_FROM_ISR\r
370         #define traceTASK_RESUME_FROM_ISR( pxTaskToResume )\r
371 #endif\r
372 \r
373 #ifndef traceTASK_INCREMENT_TICK\r
374         #define traceTASK_INCREMENT_TICK( xTickCount )\r
375 #endif\r
376 \r
377 #ifndef configGENERATE_RUN_TIME_STATS\r
378         #define configGENERATE_RUN_TIME_STATS 0\r
379 #endif\r
380 \r
381 #if ( configGENERATE_RUN_TIME_STATS == 1 )\r
382 \r
383         #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS\r
384                 #error If configGENERATE_RUN_TIME_STATS is defined then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS must also be defined.  portCONFIGURE_TIMER_FOR_RUN_TIME_STATS should call a port layer function to setup a peripheral timer/counter that can then be used as the run time counter time base.\r
385         #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */\r
386 \r
387         #ifndef portGET_RUN_TIME_COUNTER_VALUE\r
388                 #error If configGENERATE_RUN_TIME_STATS is defined then portGET_RUN_TIME_COUNTER_VALUE must also be defined.  portGET_RUN_TIME_COUNTER_VALUE should evaluate to the counter value of the timer/counter peripheral used as the run time counter time base.\r
389         #endif /* portGET_RUN_TIME_COUNTER_VALUE */\r
390 \r
391 #endif /* configGENERATE_RUN_TIME_STATS */\r
392 \r
393 #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS\r
394         #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()\r
395 #endif\r
396 \r
397 #endif /* INC_FREERTOS_H */\r
398 \r