2 FreeRTOS V7.4.0 - Copyright (C) 2013 Real Time Engineers Ltd.
4 FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT
5 http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
7 ***************************************************************************
9 * FreeRTOS tutorial books are available in pdf and paperback. *
10 * Complete, revised, and edited pdf reference manuals are also *
13 * Purchasing FreeRTOS documentation will not only help you, by *
14 * ensuring you get running as quickly as possible and with an *
15 * in-depth knowledge of how to use FreeRTOS, it will also help *
16 * the FreeRTOS project to continue with its mission of providing *
17 * professional grade, cross platform, de facto standard solutions *
18 * for microcontrollers - completely free of charge! *
20 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
22 * Thank you for using FreeRTOS, and thank you for your support! *
24 ***************************************************************************
27 This file is part of the FreeRTOS distribution.
29 FreeRTOS is free software; you can redistribute it and/or modify it under
30 the terms of the GNU General Public License (version 2) as published by the
31 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
33 >>>>>>NOTE<<<<<< The modification to the GPL is included to allow you to
34 distribute a combined work that includes FreeRTOS without being obliged to
35 provide the source code for proprietary components outside of the FreeRTOS
38 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
39 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
40 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
41 details. You should have received a copy of the GNU General Public License
42 and the FreeRTOS license exception along with FreeRTOS; if not itcan be
43 viewed here: http://www.freertos.org/a00114.html and also obtained by
44 writing to Real Time Engineers Ltd., contact details for whom are available
45 on the FreeRTOS WEB site.
49 ***************************************************************************
51 * Having a problem? Start by reading the FAQ "My application does *
52 * not run, what could be wrong?" *
54 * http://www.FreeRTOS.org/FAQHelp.html *
56 ***************************************************************************
59 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
60 license and Real Time Engineers Ltd. contact details.
62 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
63 including FreeRTOS+Trace - an indispensable productivity tool, and our new
64 fully thread aware and reentrant UDP/IP stack.
66 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
67 Integrity Systems, who sell the code with commercial support,
68 indemnification and middleware, under the OpenRTOS brand.
70 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
71 engineered and independently SIL3 certified version for use in safety and
72 mission critical applications that require provable dependability.
75 #ifndef INC_FREERTOS_H
76 #define INC_FREERTOS_H
80 * Include the generic headers required for the FreeRTOS port being used.
84 /* Basic FreeRTOS definitions. */
85 #include "os/projdefs.h"
87 /* Application specific configuration options. */
88 #include "os/FreeRTOSConfig.h"
90 /* configUSE_PORT_OPTIMISED_TASK_SELECTION must be defined before portable.h
91 is included as it is used by the port layer. */
92 #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
93 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
96 /* Definitions specific to the port being used. */
97 #include "os/portable.h"
100 /* Defines the prototype to which the application task hook function must
102 typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * );
109 * Check all the required application specific macros have been defined.
110 * These macros are application specific and (as downloaded) are defined
111 * within FreeRTOSConfig.h.
114 #ifndef configUSE_PREEMPTION
115 #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.
118 #ifndef configUSE_IDLE_HOOK
119 #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.
122 #ifndef configUSE_TICK_HOOK
123 #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.
126 #ifndef configUSE_CO_ROUTINES
127 #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.
130 #ifndef INCLUDE_vTaskPrioritySet
131 #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.
134 #ifndef INCLUDE_uxTaskPriorityGet
135 #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.
138 #ifndef INCLUDE_vTaskDelete
139 #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.
142 #ifndef INCLUDE_vTaskSuspend
143 #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.
146 #ifndef INCLUDE_vTaskDelayUntil
147 #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.
150 #ifndef INCLUDE_vTaskDelay
151 #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.
154 #ifndef configUSE_16_BIT_TICKS
155 #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.
158 #ifndef INCLUDE_xTaskGetIdleTaskHandle
159 #define INCLUDE_xTaskGetIdleTaskHandle 0
162 #ifndef INCLUDE_xTimerGetTimerDaemonTaskHandle
163 #define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
166 #ifndef INCLUDE_xQueueGetMutexHolder
167 #define INCLUDE_xQueueGetMutexHolder 0
170 #ifndef INCLUDE_pcTaskGetTaskName
171 #define INCLUDE_pcTaskGetTaskName 0
174 #ifndef configUSE_APPLICATION_TASK_TAG
175 #define configUSE_APPLICATION_TASK_TAG 0
178 #ifndef INCLUDE_uxTaskGetStackHighWaterMark
179 #define INCLUDE_uxTaskGetStackHighWaterMark 0
182 #ifndef INCLUDE_eTaskStateGet
183 #define INCLUDE_eTaskStateGet 0
186 #ifndef configUSE_RECURSIVE_MUTEXES
187 #define configUSE_RECURSIVE_MUTEXES 0
190 #ifndef configUSE_MUTEXES
191 #define configUSE_MUTEXES 0
194 #ifndef configUSE_TIMERS
195 #define configUSE_TIMERS 0
198 #ifndef configUSE_COUNTING_SEMAPHORES
199 #define configUSE_COUNTING_SEMAPHORES 0
202 #ifndef configUSE_ALTERNATIVE_API
203 #define configUSE_ALTERNATIVE_API 0
206 #ifndef portCRITICAL_NESTING_IN_TCB
207 #define portCRITICAL_NESTING_IN_TCB 0
210 #ifndef configMAX_TASK_NAME_LEN
211 #define configMAX_TASK_NAME_LEN 16
214 #ifndef configIDLE_SHOULD_YIELD
215 #define configIDLE_SHOULD_YIELD 1
218 #if configMAX_TASK_NAME_LEN < 1
219 #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h
222 #ifndef INCLUDE_xTaskResumeFromISR
223 #define INCLUDE_xTaskResumeFromISR 1
227 #define configASSERT( x )
230 #ifndef portALIGNMENT_ASSERT_pxCurrentTCB
231 #define portALIGNMENT_ASSERT_pxCurrentTCB configASSERT
234 /* The timers module relies on xTaskGetSchedulerState(). */
235 #if configUSE_TIMERS == 1
237 #ifndef configTIMER_TASK_PRIORITY
238 #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined.
239 #endif /* configTIMER_TASK_PRIORITY */
241 #ifndef configTIMER_QUEUE_LENGTH
242 #error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined.
243 #endif /* configTIMER_QUEUE_LENGTH */
245 #ifndef configTIMER_TASK_STACK_DEPTH
246 #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined.
247 #endif /* configTIMER_TASK_STACK_DEPTH */
249 #endif /* configUSE_TIMERS */
251 #ifndef INCLUDE_xTaskGetSchedulerState
252 #define INCLUDE_xTaskGetSchedulerState 0
255 #ifndef INCLUDE_xTaskGetCurrentTaskHandle
256 #define INCLUDE_xTaskGetCurrentTaskHandle 0
260 #ifndef portSET_INTERRUPT_MASK_FROM_ISR
261 #define portSET_INTERRUPT_MASK_FROM_ISR() 0
264 #ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR
265 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue
268 #ifndef portCLEAN_UP_TCB
269 #define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB
272 #ifndef portSETUP_TCB
273 #define portSETUP_TCB( pxTCB ) ( void ) pxTCB
276 #ifndef configQUEUE_REGISTRY_SIZE
277 #define configQUEUE_REGISTRY_SIZE 0U
280 #if ( configQUEUE_REGISTRY_SIZE < 1 )
281 #define vQueueAddToRegistry( xQueue, pcName )
282 #define vQueueUnregisterQueue( xQueue )
285 #ifndef portPOINTER_SIZE_TYPE
286 #define portPOINTER_SIZE_TYPE unsigned long
289 /* Remove any unused trace macros. */
291 /* Used to perform any necessary initialisation - for example, open a file
292 into which trace is to be written. */
297 /* Use to close a trace, for example close a file into which trace has been
302 #ifndef traceTASK_SWITCHED_IN
303 /* Called after a task has been selected to run. pxCurrentTCB holds a pointer
304 to the task control block of the selected task. */
305 #define traceTASK_SWITCHED_IN()
308 #ifndef traceTASK_SWITCHED_OUT
309 /* Called before a task has been selected to run. pxCurrentTCB holds a pointer
310 to the task control block of the task being switched out. */
311 #define traceTASK_SWITCHED_OUT()
314 #ifndef traceTASK_PRIORITY_INHERIT
315 /* Called when a task attempts to take a mutex that is already held by a
316 lower priority task. pxTCBOfMutexHolder is a pointer to the TCB of the task
317 that holds the mutex. uxInheritedPriority is the priority the mutex holder
318 will inherit (the priority of the task that is attempting to obtain the
320 #define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority )
323 #ifndef traceTASK_PRIORITY_DISINHERIT
324 /* Called when a task releases a mutex, the holding of which had resulted in
325 the task inheriting the priority of a higher priority task.
326 pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the
327 mutex. uxOriginalPriority is the task's configured (base) priority. */
328 #define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority )
331 #ifndef traceBLOCKING_ON_QUEUE_RECEIVE
332 /* Task is about to block because it cannot read from a
333 queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore
334 upon which the read was attempted. pxCurrentTCB points to the TCB of the
335 task that attempted the read. */
336 #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue )
339 #ifndef traceBLOCKING_ON_QUEUE_SEND
340 /* Task is about to block because it cannot write to a
341 queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore
342 upon which the write was attempted. pxCurrentTCB points to the TCB of the
343 task that attempted the write. */
344 #define traceBLOCKING_ON_QUEUE_SEND( pxQueue )
347 #ifndef configCHECK_FOR_STACK_OVERFLOW
348 #define configCHECK_FOR_STACK_OVERFLOW 0
351 /* The following event macros are embedded in the kernel API calls. */
353 #ifndef traceMOVED_TASK_TO_READY_STATE
354 #define traceMOVED_TASK_TO_READY_STATE( pxTCB )
357 #ifndef traceQUEUE_CREATE
358 #define traceQUEUE_CREATE( pxNewQueue )
361 #ifndef traceQUEUE_CREATE_FAILED
362 #define traceQUEUE_CREATE_FAILED( ucQueueType )
365 #ifndef traceCREATE_MUTEX
366 #define traceCREATE_MUTEX( pxNewQueue )
369 #ifndef traceCREATE_MUTEX_FAILED
370 #define traceCREATE_MUTEX_FAILED()
373 #ifndef traceGIVE_MUTEX_RECURSIVE
374 #define traceGIVE_MUTEX_RECURSIVE( pxMutex )
377 #ifndef traceGIVE_MUTEX_RECURSIVE_FAILED
378 #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex )
381 #ifndef traceTAKE_MUTEX_RECURSIVE
382 #define traceTAKE_MUTEX_RECURSIVE( pxMutex )
385 #ifndef traceTAKE_MUTEX_RECURSIVE_FAILED
386 #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex )
389 #ifndef traceCREATE_COUNTING_SEMAPHORE
390 #define traceCREATE_COUNTING_SEMAPHORE()
393 #ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED
394 #define traceCREATE_COUNTING_SEMAPHORE_FAILED()
397 #ifndef traceQUEUE_SEND
398 #define traceQUEUE_SEND( pxQueue )
401 #ifndef traceQUEUE_SEND_FAILED
402 #define traceQUEUE_SEND_FAILED( pxQueue )
405 #ifndef traceQUEUE_RECEIVE
406 #define traceQUEUE_RECEIVE( pxQueue )
409 #ifndef traceQUEUE_PEEK
410 #define traceQUEUE_PEEK( pxQueue )
413 #ifndef traceQUEUE_RECEIVE_FAILED
414 #define traceQUEUE_RECEIVE_FAILED( pxQueue )
417 #ifndef traceQUEUE_SEND_FROM_ISR
418 #define traceQUEUE_SEND_FROM_ISR( pxQueue )
421 #ifndef traceQUEUE_SEND_FROM_ISR_FAILED
422 #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue )
425 #ifndef traceQUEUE_RECEIVE_FROM_ISR
426 #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue )
429 #ifndef traceQUEUE_RECEIVE_FROM_ISR_FAILED
430 #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue )
433 #ifndef traceQUEUE_DELETE
434 #define traceQUEUE_DELETE( pxQueue )
437 #ifndef traceTASK_CREATE
438 #define traceTASK_CREATE( pxNewTCB )
441 #ifndef traceTASK_CREATE_FAILED
442 #define traceTASK_CREATE_FAILED()
445 #ifndef traceTASK_DELETE
446 #define traceTASK_DELETE( pxTaskToDelete )
449 #ifndef traceTASK_DELAY_UNTIL
450 #define traceTASK_DELAY_UNTIL()
453 #ifndef traceTASK_DELAY
454 #define traceTASK_DELAY()
457 #ifndef traceTASK_PRIORITY_SET
458 #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority )
461 #ifndef traceTASK_SUSPEND
462 #define traceTASK_SUSPEND( pxTaskToSuspend )
465 #ifndef traceTASK_RESUME
466 #define traceTASK_RESUME( pxTaskToResume )
469 #ifndef traceTASK_RESUME_FROM_ISR
470 #define traceTASK_RESUME_FROM_ISR( pxTaskToResume )
473 #ifndef traceTASK_INCREMENT_TICK
474 #define traceTASK_INCREMENT_TICK( xTickCount )
477 #ifndef traceTIMER_CREATE
478 #define traceTIMER_CREATE( pxNewTimer )
481 #ifndef traceTIMER_CREATE_FAILED
482 #define traceTIMER_CREATE_FAILED()
485 #ifndef traceTIMER_COMMAND_SEND
486 #define traceTIMER_COMMAND_SEND( xTimer, xMessageID, xMessageValueValue, xReturn )
489 #ifndef traceTIMER_EXPIRED
490 #define traceTIMER_EXPIRED( pxTimer )
493 #ifndef traceTIMER_COMMAND_RECEIVED
494 #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue )
497 #ifndef configGENERATE_RUN_TIME_STATS
498 #define configGENERATE_RUN_TIME_STATS 0
501 #if ( configGENERATE_RUN_TIME_STATS == 1 )
503 #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
504 #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.
505 #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */
507 #ifndef portGET_RUN_TIME_COUNTER_VALUE
508 #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE
509 #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.
510 #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */
511 #endif /* portGET_RUN_TIME_COUNTER_VALUE */
513 #endif /* configGENERATE_RUN_TIME_STATS */
515 #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
516 #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
519 #ifndef configUSE_MALLOC_FAILED_HOOK
520 #define configUSE_MALLOC_FAILED_HOOK 0
523 #ifndef portPRIVILEGE_BIT
524 #define portPRIVILEGE_BIT ( ( unsigned portBASE_TYPE ) 0x00 )
527 #ifndef portYIELD_WITHIN_API
528 #define portYIELD_WITHIN_API portYIELD
531 #ifndef pvPortMallocAligned
532 #define pvPortMallocAligned( x, puxStackBuffer ) ( ( ( puxStackBuffer ) == NULL ) ? ( pvPortMalloc( ( x ) ) ) : ( puxStackBuffer ) )
535 #ifndef vPortFreeAligned
536 #define vPortFreeAligned( pvBlockToFree ) vPortFree( pvBlockToFree )
539 #ifndef portSUPPRESS_TICKS_AND_SLEEP
540 #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime )
543 #ifndef configPRE_SLEEP_PROCESSING
544 #define configPRE_SLEEP_PROCESSING( x )
547 #ifndef configPOST_SLEEP_PROCESSING
548 #define configPOST_SLEEP_PROCESSING( x )
551 #endif /* INC_FREERTOS_H */