2 FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.
\r
4 ***************************************************************************
\r
8 * + New to FreeRTOS, *
\r
9 * + Wanting to learn FreeRTOS or multitasking in general quickly *
\r
10 * + Looking for basic training, *
\r
11 * + Wanting to improve your FreeRTOS skills and productivity *
\r
13 * then take a look at the FreeRTOS books - available as PDF or paperback *
\r
15 * "Using the FreeRTOS Real Time Kernel - a Practical Guide" *
\r
16 * http://www.FreeRTOS.org/Documentation *
\r
18 * A pdf reference manual is also available. Both are usually delivered *
\r
19 * to your inbox within 20 minutes to two hours when purchased between 8am *
\r
20 * and 8pm GMT (although please allow up to 24 hours in case of *
\r
21 * exceptional circumstances). Thank you for your support! *
\r
23 ***************************************************************************
\r
25 This file is part of the FreeRTOS distribution.
\r
27 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
28 the terms of the GNU General Public License (version 2) as published by the
\r
29 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
30 ***NOTE*** The exception to the GPL is included to allow you to distribute
\r
31 a combined work that includes FreeRTOS without being obliged to provide the
\r
32 source code for proprietary components outside of the FreeRTOS kernel.
\r
33 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
\r
34 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
35 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
36 more details. You should have received a copy of the GNU General Public
\r
37 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
38 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
39 by writing to Richard Barry, contact details for whom are available on the
\r
44 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
47 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
50 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
51 licensing and training services.
\r
54 #ifndef INC_FREERTOS_H
\r
55 #define INC_FREERTOS_H
\r
59 * Include the generic headers required for the FreeRTOS port being used.
\r
63 /* Basic FreeRTOS definitions. */
\r
64 #include "projdefs.h"
\r
66 /* Application specific configuration options. */
\r
67 #include "FreeRTOSConfig.h"
\r
69 /* Definitions specific to the port being used. */
\r
70 #include "portable.h"
\r
73 /* Defines the prototype to which the application task hook function must
\r
75 typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * );
\r
82 * Check all the required application specific macros have been defined.
\r
83 * These macros are application specific and (as downloaded) are defined
\r
84 * within FreeRTOSConfig.h.
\r
87 #ifndef configUSE_PREEMPTION
\r
88 #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
91 #ifndef configUSE_IDLE_HOOK
\r
92 #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
95 #ifndef configUSE_TICK_HOOK
\r
96 #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
99 #ifndef configUSE_CO_ROUTINES
\r
100 #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
103 #ifndef INCLUDE_vTaskPrioritySet
\r
104 #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
107 #ifndef INCLUDE_uxTaskPriorityGet
\r
108 #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
111 #ifndef INCLUDE_vTaskDelete
\r
112 #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
115 #ifndef INCLUDE_vTaskCleanUpResources
\r
116 #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
119 #ifndef INCLUDE_vTaskSuspend
\r
120 #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
123 #ifndef INCLUDE_vTaskDelayUntil
\r
124 #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
127 #ifndef INCLUDE_vTaskDelay
\r
128 #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
131 #ifndef configUSE_16_BIT_TICKS
\r
132 #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
135 #ifndef configUSE_APPLICATION_TASK_TAG
\r
136 #define configUSE_APPLICATION_TASK_TAG 0
\r
139 #ifndef INCLUDE_uxTaskGetStackHighWaterMark
\r
140 #define INCLUDE_uxTaskGetStackHighWaterMark 0
\r
143 #ifndef configUSE_RECURSIVE_MUTEXES
\r
144 #define configUSE_RECURSIVE_MUTEXES 0
\r
147 #ifndef configUSE_MUTEXES
\r
148 #define configUSE_MUTEXES 0
\r
151 #ifndef configUSE_COUNTING_SEMAPHORES
\r
152 #define configUSE_COUNTING_SEMAPHORES 0
\r
155 #ifndef configUSE_ALTERNATIVE_API
\r
156 #define configUSE_ALTERNATIVE_API 0
\r
159 #ifndef portCRITICAL_NESTING_IN_TCB
\r
160 #define portCRITICAL_NESTING_IN_TCB 0
\r
163 #ifndef configMAX_TASK_NAME_LEN
\r
164 #define configMAX_TASK_NAME_LEN 16
\r
167 #ifndef configIDLE_SHOULD_YIELD
\r
168 #define configIDLE_SHOULD_YIELD 1
\r
171 #if configMAX_TASK_NAME_LEN < 1
\r
172 #undef configMAX_TASK_NAME_LEN
\r
173 #define configMAX_TASK_NAME_LEN 1
\r
176 #ifndef INCLUDE_xTaskResumeFromISR
\r
177 #define INCLUDE_xTaskResumeFromISR 1
\r
180 #ifndef INCLUDE_xTaskGetSchedulerState
\r
181 #define INCLUDE_xTaskGetSchedulerState 0
\r
184 #if ( configUSE_MUTEXES == 1 )
\r
185 /* xTaskGetCurrentTaskHandle is used by the priority inheritance mechanism
\r
186 within the mutex implementation so must be available if mutexes are used. */
\r
187 #undef INCLUDE_xTaskGetCurrentTaskHandle
\r
188 #define INCLUDE_xTaskGetCurrentTaskHandle 1
\r
190 #ifndef INCLUDE_xTaskGetCurrentTaskHandle
\r
191 #define INCLUDE_xTaskGetCurrentTaskHandle 0
\r
196 #ifndef portSET_INTERRUPT_MASK_FROM_ISR
\r
197 #define portSET_INTERRUPT_MASK_FROM_ISR() 0
\r
200 #ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR
\r
201 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue
\r
205 #ifndef configQUEUE_REGISTRY_SIZE
\r
206 #define configQUEUE_REGISTRY_SIZE 0
\r
209 #if configQUEUE_REGISTRY_SIZE < 1
\r
210 #define configQUEUE_REGISTRY_SIZE 0
\r
211 #define vQueueAddToRegistry( xQueue, pcName )
\r
212 #define vQueueUnregisterQueue( xQueue )
\r
216 /* Remove any unused trace macros. */
\r
218 /* Used to perform any necessary initialisation - for example, open a file
\r
219 into which trace is to be written. */
\r
220 #define traceSTART()
\r
224 /* Use to close a trace, for example close a file into which trace has been
\r
229 #ifndef traceTASK_SWITCHED_IN
\r
230 /* Called after a task has been selected to run. pxCurrentTCB holds a pointer
\r
231 to the task control block of the selected task. */
\r
232 #define traceTASK_SWITCHED_IN()
\r
235 #ifndef traceTASK_SWITCHED_OUT
\r
236 /* Called before a task has been selected to run. pxCurrentTCB holds a pointer
\r
237 to the task control block of the task being switched out. */
\r
238 #define traceTASK_SWITCHED_OUT()
\r
241 #ifndef traceBLOCKING_ON_QUEUE_RECEIVE
\r
242 /* Task is about to block because it cannot read from a
\r
243 queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore
\r
244 upon which the read was attempted. pxCurrentTCB points to the TCB of the
\r
245 task that attempted the read. */
\r
246 #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue )
\r
249 #ifndef traceBLOCKING_ON_QUEUE_SEND
\r
250 /* Task is about to block because it cannot write to a
\r
251 queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore
\r
252 upon which the write was attempted. pxCurrentTCB points to the TCB of the
\r
253 task that attempted the write. */
\r
254 #define traceBLOCKING_ON_QUEUE_SEND( pxQueue )
\r
257 #ifndef configCHECK_FOR_STACK_OVERFLOW
\r
258 #define configCHECK_FOR_STACK_OVERFLOW 0
\r
261 /* The following event macros are embedded in the kernel API calls. */
\r
263 #ifndef traceQUEUE_CREATE
\r
264 #define traceQUEUE_CREATE( pxNewQueue )
\r
267 #ifndef traceQUEUE_CREATE_FAILED
\r
268 #define traceQUEUE_CREATE_FAILED()
\r
271 #ifndef traceCREATE_MUTEX
\r
272 #define traceCREATE_MUTEX( pxNewQueue )
\r
275 #ifndef traceCREATE_MUTEX_FAILED
\r
276 #define traceCREATE_MUTEX_FAILED()
\r
279 #ifndef traceGIVE_MUTEX_RECURSIVE
\r
280 #define traceGIVE_MUTEX_RECURSIVE( pxMutex )
\r
283 #ifndef traceGIVE_MUTEX_RECURSIVE_FAILED
\r
284 #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex )
\r
287 #ifndef traceTAKE_MUTEX_RECURSIVE
\r
288 #define traceTAKE_MUTEX_RECURSIVE( pxMutex )
\r
291 #ifndef traceTAKE_MUTEX_RECURSIVE_FAILED
\r
292 #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex )
\r
295 #ifndef traceCREATE_COUNTING_SEMAPHORE
\r
296 #define traceCREATE_COUNTING_SEMAPHORE()
\r
299 #ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED
\r
300 #define traceCREATE_COUNTING_SEMAPHORE_FAILED()
\r
303 #ifndef traceQUEUE_SEND
\r
304 #define traceQUEUE_SEND( pxQueue )
\r
307 #ifndef traceQUEUE_SEND_FAILED
\r
308 #define traceQUEUE_SEND_FAILED( pxQueue )
\r
311 #ifndef traceQUEUE_RECEIVE
\r
312 #define traceQUEUE_RECEIVE( pxQueue )
\r
315 #ifndef traceQUEUE_PEEK
\r
316 #define traceQUEUE_PEEK( pxQueue )
\r
319 #ifndef traceQUEUE_RECEIVE_FAILED
\r
320 #define traceQUEUE_RECEIVE_FAILED( pxQueue )
\r
323 #ifndef traceQUEUE_SEND_FROM_ISR
\r
324 #define traceQUEUE_SEND_FROM_ISR( pxQueue )
\r
327 #ifndef traceQUEUE_SEND_FROM_ISR_FAILED
\r
328 #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue )
\r
331 #ifndef traceQUEUE_RECEIVE_FROM_ISR
\r
332 #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue )
\r
335 #ifndef traceQUEUE_RECEIVE_FROM_ISR_FAILED
\r
336 #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue )
\r
339 #ifndef traceQUEUE_DELETE
\r
340 #define traceQUEUE_DELETE( pxQueue )
\r
343 #ifndef traceTASK_CREATE
\r
344 #define traceTASK_CREATE( pxNewTCB )
\r
347 #ifndef traceTASK_CREATE_FAILED
\r
348 #define traceTASK_CREATE_FAILED()
\r
351 #ifndef traceTASK_DELETE
\r
352 #define traceTASK_DELETE( pxTaskToDelete )
\r
355 #ifndef traceTASK_DELAY_UNTIL
\r
356 #define traceTASK_DELAY_UNTIL()
\r
359 #ifndef traceTASK_DELAY
\r
360 #define traceTASK_DELAY()
\r
363 #ifndef traceTASK_PRIORITY_SET
\r
364 #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority )
\r
367 #ifndef traceTASK_SUSPEND
\r
368 #define traceTASK_SUSPEND( pxTaskToSuspend )
\r
371 #ifndef traceTASK_RESUME
\r
372 #define traceTASK_RESUME( pxTaskToResume )
\r
375 #ifndef traceTASK_RESUME_FROM_ISR
\r
376 #define traceTASK_RESUME_FROM_ISR( pxTaskToResume )
\r
379 #ifndef traceTASK_INCREMENT_TICK
\r
380 #define traceTASK_INCREMENT_TICK( xTickCount )
\r
383 #ifndef configGENERATE_RUN_TIME_STATS
\r
384 #define configGENERATE_RUN_TIME_STATS 0
\r
387 #if ( configGENERATE_RUN_TIME_STATS == 1 )
\r
389 #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
\r
390 #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
391 #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */
\r
393 #ifndef portGET_RUN_TIME_COUNTER_VALUE
\r
394 #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE
\r
395 #error If configGENERATE_RUN_TIME_STATS is defined then either portGET_RUN_TIME_COUNTER_VALUE or portALT_GET_RUN_TIME_COUNTER_VALUE must also be defined. See the examples provided and the FreeRTOS web site for more information.
\r
396 #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */
\r
397 #endif /* portGET_RUN_TIME_COUNTER_VALUE */
\r
399 #endif /* configGENERATE_RUN_TIME_STATS */
\r
401 #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
\r
402 #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
\r
405 #ifndef configUSE_MALLOC_FAILED_HOOK
\r
406 #define configUSE_MALLOC_FAILED_HOOK 0
\r
409 #ifndef portPRIVILEGE_BIT
\r
410 #define portPRIVILEGE_BIT ( ( unsigned portBASE_TYPE ) 0x00 )
\r
413 #ifndef portYIELD_WITHIN_API
\r
414 #define portYIELD_WITHIN_API portYIELD
\r
417 #ifndef pvPortMallocAligned
\r
418 #define pvPortMallocAligned( x, puxStackBuffer ) ( ( puxStackBuffer == NULL ) ? ( pvPortMalloc( x ) ) : ( puxStackBuffer ) )
\r
421 #ifndef vPortFreeAligned
\r
422 #define vPortFreeAligned( pvBlockToFree ) vPortFree( pvBlockToFree )
\r
425 #endif /* INC_FREERTOS_H */
\r