FreeRTOS Real Time Operating System, Modified from Kenji Arai's initial port. See freertos.org for full documentation.

Fork of FreeRTOS_on_mbed_v1 by Kenji Arai

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FreeRTOS.h Source File

FreeRTOS.h

00001 /*
00002     FreeRTOS V6.0.3 - Copyright (C) 2010 Real Time Engineers Ltd.
00003 
00004     ***************************************************************************
00005     *                                                                         *
00006     * If you are:                                                             *
00007     *                                                                         *
00008     *    + New to FreeRTOS,                                                   *
00009     *    + Wanting to learn FreeRTOS or multitasking in general quickly       *
00010     *    + Looking for basic training,                                        *
00011     *    + Wanting to improve your FreeRTOS skills and productivity           *
00012     *                                                                         *
00013     * then take a look at the FreeRTOS eBook                                  *
00014     *                                                                         *
00015     *        "Using the FreeRTOS Real Time Kernel - a Practical Guide"        *
00016     *                  http://www.FreeRTOS.org/Documentation                  *
00017     *                                                                         *
00018     * A pdf reference manual is also available.  Both are usually delivered   *
00019     * to your inbox within 20 minutes to two hours when purchased between 8am *
00020     * and 8pm GMT (although please allow up to 24 hours in case of            *
00021     * exceptional circumstances).  Thank you for your support!                *
00022     *                                                                         *
00023     ***************************************************************************
00024 
00025     This file is part of the FreeRTOS distribution.
00026 
00027     FreeRTOS is free software; you can redistribute it and/or modify it under
00028     the terms of the GNU General Public License (version 2) as published by the
00029     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
00030     ***NOTE*** The exception to the GPL is included to allow you to distribute
00031     a combined work that includes FreeRTOS without being obliged to provide the
00032     source code for proprietary components outside of the FreeRTOS kernel.
00033     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
00034     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00035     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00036     more details. You should have received a copy of the GNU General Public 
00037     License and the FreeRTOS license exception along with FreeRTOS; if not it 
00038     can be viewed here: http://www.freertos.org/a00114.html and also obtained 
00039     by writing to Richard Barry, contact details for whom are available on the
00040     FreeRTOS WEB site.
00041 
00042     1 tab == 4 spaces!
00043 
00044     http://www.FreeRTOS.org - Documentation, latest information, license and
00045     contact details.
00046 
00047     http://www.SafeRTOS.com - A version that is certified for use in safety
00048     critical systems.
00049 
00050     http://www.OpenRTOS.com - Commercial support, development, porting,
00051     licensing and training services.
00052 */
00053 
00054 #ifndef INC_FREERTOS_H
00055 #define INC_FREERTOS_H
00056 
00057 
00058 /*
00059  * Include the generic headers required for the FreeRTOS port being used.
00060  */
00061 #include <stddef.h>
00062 
00063 /* Basic FreeRTOS definitions. */
00064 #include "projdefs.h"
00065 
00066 /* Application specific configuration options. */
00067 #include "FreeRTOSConfig.h"
00068 
00069 /* Definitions specific to the port being used. */
00070 #include "portable.h"
00071 
00072 
00073 /* Defines the prototype to which the application task hook function must
00074 conform. */
00075 typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * );
00076 
00077 
00078 
00079 
00080 
00081 /*
00082  * Check all the required application specific macros have been defined.
00083  * These macros are application specific and (as downloaded) are defined
00084  * within FreeRTOSConfig.h.
00085  */
00086 
00087 #ifndef configUSE_PREEMPTION
00088     #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.
00089 #endif
00090 
00091 #ifndef configUSE_IDLE_HOOK
00092     #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.
00093 #endif
00094 
00095 #ifndef configUSE_TICK_HOOK
00096     #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.
00097 #endif
00098 
00099 #ifndef configUSE_CO_ROUTINES
00100     #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.
00101 #endif
00102 
00103 #ifndef INCLUDE_vTaskPrioritySet
00104     #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.
00105 #endif
00106 
00107 #ifndef INCLUDE_uxTaskPriorityGet
00108     #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.
00109 #endif
00110 
00111 #ifndef INCLUDE_vTaskDelete        
00112     #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.
00113 #endif
00114 
00115 #ifndef INCLUDE_vTaskCleanUpResources
00116     #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.
00117 #endif
00118 
00119 #ifndef INCLUDE_vTaskSuspend    
00120     #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.
00121 #endif
00122 
00123 #ifndef INCLUDE_vTaskDelayUntil
00124     #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.
00125 #endif
00126 
00127 #ifndef INCLUDE_vTaskDelay
00128     #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.
00129 #endif
00130 
00131 #ifndef configUSE_16_BIT_TICKS
00132     #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.
00133 #endif
00134 
00135 #ifndef configUSE_APPLICATION_TASK_TAG
00136     #define configUSE_APPLICATION_TASK_TAG 0
00137 #endif
00138 
00139 #ifndef INCLUDE_uxTaskGetStackHighWaterMark
00140     #define INCLUDE_uxTaskGetStackHighWaterMark 0
00141 #endif
00142 
00143 #ifndef configUSE_RECURSIVE_MUTEXES
00144     #define configUSE_RECURSIVE_MUTEXES 0
00145 #endif
00146 
00147 #ifndef configUSE_MUTEXES
00148     #define configUSE_MUTEXES 0
00149 #endif
00150 
00151 #ifndef configUSE_COUNTING_SEMAPHORES
00152     #define configUSE_COUNTING_SEMAPHORES 0
00153 #endif
00154 
00155 #ifndef configUSE_ALTERNATIVE_API
00156     #define configUSE_ALTERNATIVE_API 0
00157 #endif
00158 
00159 #ifndef portCRITICAL_NESTING_IN_TCB
00160     #define portCRITICAL_NESTING_IN_TCB 0
00161 #endif
00162 
00163 #ifndef configMAX_TASK_NAME_LEN
00164     #define configMAX_TASK_NAME_LEN 16
00165 #endif
00166 
00167 #ifndef configIDLE_SHOULD_YIELD
00168     #define configIDLE_SHOULD_YIELD        1
00169 #endif
00170 
00171 #if configMAX_TASK_NAME_LEN < 1
00172     #undef configMAX_TASK_NAME_LEN
00173     #define configMAX_TASK_NAME_LEN 1
00174 #endif
00175 
00176 #ifndef INCLUDE_xTaskResumeFromISR
00177     #define INCLUDE_xTaskResumeFromISR 1
00178 #endif
00179 
00180 #ifndef INCLUDE_xTaskGetSchedulerState
00181     #define INCLUDE_xTaskGetSchedulerState 0
00182 #endif
00183 
00184 #if ( configUSE_MUTEXES == 1 )
00185     /* xTaskGetCurrentTaskHandle is used by the priority inheritance mechanism
00186     within the mutex implementation so must be available if mutexes are used. */
00187     #undef INCLUDE_xTaskGetCurrentTaskHandle
00188     #define INCLUDE_xTaskGetCurrentTaskHandle 1
00189 #else
00190     #ifndef INCLUDE_xTaskGetCurrentTaskHandle
00191         #define INCLUDE_xTaskGetCurrentTaskHandle 0
00192     #endif
00193 #endif
00194 
00195 
00196 #ifndef portSET_INTERRUPT_MASK_FROM_ISR
00197     #define portSET_INTERRUPT_MASK_FROM_ISR() 0
00198 #endif
00199 
00200 #ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR
00201     #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue
00202 #endif
00203 
00204 
00205 #ifndef configQUEUE_REGISTRY_SIZE
00206     #define configQUEUE_REGISTRY_SIZE 0
00207 #endif
00208 
00209 #if configQUEUE_REGISTRY_SIZE < 1
00210     #define configQUEUE_REGISTRY_SIZE 0
00211     #define vQueueAddToRegistry( xQueue, pcName )
00212     #define vQueueUnregisterQueue( xQueue )
00213 #endif
00214 
00215 
00216 /* Remove any unused trace macros. */
00217 #ifndef traceSTART
00218     /* Used to perform any necessary initialisation - for example, open a file
00219     into which trace is to be written. */
00220     #define traceSTART()
00221 #endif
00222 
00223 #ifndef traceEND
00224     /* Use to close a trace, for example close a file into which trace has been
00225     written. */
00226     #define traceEND()
00227 #endif
00228 
00229 #ifndef traceTASK_SWITCHED_IN
00230     /* Called after a task has been selected to run.  pxCurrentTCB holds a pointer
00231     to the task control block of the selected task. */
00232     #define traceTASK_SWITCHED_IN()
00233 #endif
00234 
00235 #ifndef traceTASK_SWITCHED_OUT
00236     /* Called before a task has been selected to run.  pxCurrentTCB holds a pointer
00237     to the task control block of the task being switched out. */
00238     #define traceTASK_SWITCHED_OUT()
00239 #endif
00240 
00241 #ifndef traceBLOCKING_ON_QUEUE_RECEIVE
00242     /* Task is about to block because it cannot read from a 
00243     queue/mutex/semaphore.  pxQueue is a pointer to the queue/mutex/semaphore
00244     upon which the read was attempted.  pxCurrentTCB points to the TCB of the 
00245     task that attempted the read. */
00246     #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue )
00247 #endif
00248 
00249 #ifndef traceBLOCKING_ON_QUEUE_SEND
00250     /* Task is about to block because it cannot write to a 
00251     queue/mutex/semaphore.  pxQueue is a pointer to the queue/mutex/semaphore
00252     upon which the write was attempted.  pxCurrentTCB points to the TCB of the 
00253     task that attempted the write. */
00254     #define traceBLOCKING_ON_QUEUE_SEND( pxQueue )
00255 #endif
00256 
00257 #ifndef configCHECK_FOR_STACK_OVERFLOW
00258     #define configCHECK_FOR_STACK_OVERFLOW 0
00259 #endif
00260 
00261 /* The following event macros are embedded in the kernel API calls. */
00262 
00263 #ifndef traceQUEUE_CREATE    
00264     #define traceQUEUE_CREATE( pxNewQueue )
00265 #endif
00266 
00267 #ifndef traceQUEUE_CREATE_FAILED
00268     #define traceQUEUE_CREATE_FAILED()
00269 #endif
00270 
00271 #ifndef traceCREATE_MUTEX
00272     #define traceCREATE_MUTEX( pxNewQueue )
00273 #endif
00274 
00275 #ifndef traceCREATE_MUTEX_FAILED
00276     #define traceCREATE_MUTEX_FAILED()
00277 #endif
00278 
00279 #ifndef traceGIVE_MUTEX_RECURSIVE
00280     #define traceGIVE_MUTEX_RECURSIVE( pxMutex )
00281 #endif
00282 
00283 #ifndef traceGIVE_MUTEX_RECURSIVE_FAILED
00284     #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex )
00285 #endif
00286 
00287 #ifndef traceTAKE_MUTEX_RECURSIVE
00288     #define traceTAKE_MUTEX_RECURSIVE( pxMutex )
00289 #endif
00290 
00291 #ifndef traceCREATE_COUNTING_SEMAPHORE
00292     #define traceCREATE_COUNTING_SEMAPHORE()
00293 #endif
00294 
00295 #ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED
00296     #define traceCREATE_COUNTING_SEMAPHORE_FAILED()
00297 #endif
00298 
00299 #ifndef traceQUEUE_SEND
00300     #define traceQUEUE_SEND( pxQueue )
00301 #endif
00302 
00303 #ifndef traceQUEUE_SEND_FAILED
00304     #define traceQUEUE_SEND_FAILED( pxQueue )
00305 #endif
00306 
00307 #ifndef traceQUEUE_RECEIVE
00308     #define traceQUEUE_RECEIVE( pxQueue )
00309 #endif
00310 
00311 #ifndef traceQUEUE_PEEK
00312     #define traceQUEUE_PEEK( pxQueue )
00313 #endif
00314 
00315 #ifndef traceQUEUE_RECEIVE_FAILED
00316     #define traceQUEUE_RECEIVE_FAILED( pxQueue )
00317 #endif
00318 
00319 #ifndef traceQUEUE_SEND_FROM_ISR
00320     #define traceQUEUE_SEND_FROM_ISR( pxQueue )
00321 #endif
00322 
00323 #ifndef traceQUEUE_SEND_FROM_ISR_FAILED
00324     #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue )
00325 #endif
00326 
00327 #ifndef traceQUEUE_RECEIVE_FROM_ISR
00328     #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue )
00329 #endif
00330 
00331 #ifndef traceQUEUE_RECEIVE_FROM_ISR_FAILED
00332     #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue )
00333 #endif
00334 
00335 #ifndef traceQUEUE_DELETE
00336     #define traceQUEUE_DELETE( pxQueue )
00337 #endif
00338 
00339 #ifndef traceTASK_CREATE
00340     #define traceTASK_CREATE( pxNewTCB )
00341 #endif
00342 
00343 #ifndef traceTASK_CREATE_FAILED
00344     #define traceTASK_CREATE_FAILED( pxNewTCB )
00345 #endif
00346 
00347 #ifndef traceTASK_DELETE
00348     #define traceTASK_DELETE( pxTaskToDelete )
00349 #endif
00350 
00351 #ifndef traceTASK_DELAY_UNTIL
00352     #define traceTASK_DELAY_UNTIL()
00353 #endif
00354 
00355 #ifndef traceTASK_DELAY
00356     #define traceTASK_DELAY()
00357 #endif
00358 
00359 #ifndef traceTASK_PRIORITY_SET
00360     #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority )
00361 #endif
00362 
00363 #ifndef traceTASK_SUSPEND
00364     #define traceTASK_SUSPEND( pxTaskToSuspend )
00365 #endif
00366 
00367 #ifndef traceTASK_RESUME
00368     #define traceTASK_RESUME( pxTaskToResume )
00369 #endif
00370 
00371 #ifndef traceTASK_RESUME_FROM_ISR
00372     #define traceTASK_RESUME_FROM_ISR( pxTaskToResume )
00373 #endif
00374 
00375 #ifndef traceTASK_INCREMENT_TICK
00376     #define traceTASK_INCREMENT_TICK( xTickCount )
00377 #endif
00378 
00379 #ifndef configGENERATE_RUN_TIME_STATS
00380     #define configGENERATE_RUN_TIME_STATS 0
00381 #endif
00382 
00383 #if ( configGENERATE_RUN_TIME_STATS == 1 )
00384 
00385     #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
00386         #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.
00387     #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */
00388 
00389     #ifndef portGET_RUN_TIME_COUNTER_VALUE
00390         #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.
00391     #endif /* portGET_RUN_TIME_COUNTER_VALUE */
00392 
00393 #endif /* configGENERATE_RUN_TIME_STATS */
00394 
00395 #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
00396     #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
00397 #endif
00398 
00399 #ifndef configUSE_MALLOC_FAILED_HOOK
00400     #define configUSE_MALLOC_FAILED_HOOK 0
00401 #endif
00402 
00403 #ifndef portPRIVILEGE_BIT
00404     #define portPRIVILEGE_BIT ( ( unsigned portBASE_TYPE ) 0x00 )
00405 #endif
00406 
00407 #ifndef portYIELD_WITHIN_API
00408     #define portYIELD_WITHIN_API portYIELD
00409 #endif
00410 
00411 #ifndef pvPortMallocAligned
00412     #define pvPortMallocAligned( x, puxStackBuffer ) ( ( puxStackBuffer == NULL ) ? ( pvPortMalloc( x ) ) : ( puxStackBuffer ) )
00413 #endif
00414 
00415 #ifndef vPortFreeAligned
00416     #define vPortFreeAligned( pvBlockToFree ) vPortFree( pvBlockToFree )
00417 #endif
00418 
00419 #endif /* INC_FREERTOS_H */
00420