]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - os/7.4.0/include/os/FreeRTOS.h
Trigger context switch after ADC interrupts
[pes-rpp/rpp-lib.git] / os / 7.4.0 / include / os / FreeRTOS.h
1 /*
2     FreeRTOS V7.4.0 - Copyright (C) 2013 Real Time Engineers Ltd.
3
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.
6
7     ***************************************************************************
8      *                                                                       *
9      *    FreeRTOS tutorial books are available in pdf and paperback.        *
10      *    Complete, revised, and edited pdf reference manuals are also       *
11      *    available.                                                         *
12      *                                                                       *
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!                  *
19      *                                                                       *
20      *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *
21      *                                                                       *
22      *    Thank you for using FreeRTOS, and thank you for your support!      *
23      *                                                                       *
24     ***************************************************************************
25
26
27     This file is part of the FreeRTOS distribution.
28
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.
32
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
36     kernel.
37
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.
46
47     1 tab == 4 spaces!
48
49     ***************************************************************************
50      *                                                                       *
51      *    Having a problem?  Start by reading the FAQ "My application does   *
52      *    not run, what could be wrong?"                                     *
53      *                                                                       *
54      *    http://www.FreeRTOS.org/FAQHelp.html                               *
55      *                                                                       *
56     ***************************************************************************
57
58
59     http://www.FreeRTOS.org - Documentation, books, training, latest versions,
60     license and Real Time Engineers Ltd. contact details.
61
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.
65
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.
69
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.
73 */
74
75 #ifndef INC_FREERTOS_H
76 #define INC_FREERTOS_H
77
78
79 /*
80  * Include the generic headers required for the FreeRTOS port being used.
81  */
82 #include <stddef.h>
83
84 /* Basic FreeRTOS definitions. */
85 #include "os/projdefs.h"
86
87 /* Application specific configuration options. */
88 #include "os/FreeRTOSConfig.h"
89
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
94 #endif
95
96 /* Definitions specific to the port being used. */
97 #include "os/portable.h"
98
99
100 /* Defines the prototype to which the application task hook function must
101 conform. */
102 typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * );
103
104
105
106
107
108 /*
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.
112  */
113
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.
116 #endif
117
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.
120 #endif
121
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.
124 #endif
125
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.
128 #endif
129
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.
132 #endif
133
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.
136 #endif
137
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.
140 #endif
141
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.
144 #endif
145
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.
148 #endif
149
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.
152 #endif
153
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.
156 #endif
157
158 #ifndef INCLUDE_xTaskGetIdleTaskHandle
159     #define INCLUDE_xTaskGetIdleTaskHandle 0
160 #endif
161
162 #ifndef INCLUDE_xTimerGetTimerDaemonTaskHandle
163     #define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
164 #endif
165
166 #ifndef INCLUDE_xQueueGetMutexHolder
167     #define INCLUDE_xQueueGetMutexHolder 0
168 #endif
169
170 #ifndef INCLUDE_pcTaskGetTaskName
171     #define INCLUDE_pcTaskGetTaskName 0
172 #endif
173
174 #ifndef configUSE_APPLICATION_TASK_TAG
175     #define configUSE_APPLICATION_TASK_TAG 0
176 #endif
177
178 #ifndef INCLUDE_uxTaskGetStackHighWaterMark
179     #define INCLUDE_uxTaskGetStackHighWaterMark 0
180 #endif
181
182 #ifndef INCLUDE_eTaskStateGet
183     #define INCLUDE_eTaskStateGet 0
184 #endif
185
186 #ifndef configUSE_RECURSIVE_MUTEXES
187     #define configUSE_RECURSIVE_MUTEXES 0
188 #endif
189
190 #ifndef configUSE_MUTEXES
191     #define configUSE_MUTEXES 0
192 #endif
193
194 #ifndef configUSE_TIMERS
195     #define configUSE_TIMERS 0
196 #endif
197
198 #ifndef configUSE_COUNTING_SEMAPHORES
199     #define configUSE_COUNTING_SEMAPHORES 0
200 #endif
201
202 #ifndef configUSE_ALTERNATIVE_API
203     #define configUSE_ALTERNATIVE_API 0
204 #endif
205
206 #ifndef portCRITICAL_NESTING_IN_TCB
207     #define portCRITICAL_NESTING_IN_TCB 0
208 #endif
209
210 #ifndef configMAX_TASK_NAME_LEN
211     #define configMAX_TASK_NAME_LEN 16
212 #endif
213
214 #ifndef configIDLE_SHOULD_YIELD
215     #define configIDLE_SHOULD_YIELD     1
216 #endif
217
218 #if configMAX_TASK_NAME_LEN < 1
219     #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h
220 #endif
221
222 #ifndef INCLUDE_xTaskResumeFromISR
223     #define INCLUDE_xTaskResumeFromISR 1
224 #endif
225
226 #ifndef configASSERT
227     #define configASSERT( x )
228 #endif
229
230 #ifndef portALIGNMENT_ASSERT_pxCurrentTCB
231     #define portALIGNMENT_ASSERT_pxCurrentTCB configASSERT
232 #endif
233
234 /* The timers module relies on xTaskGetSchedulerState(). */
235 #if configUSE_TIMERS == 1
236
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 */
240
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 */
244
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 */
248
249 #endif /* configUSE_TIMERS */
250
251 #ifndef INCLUDE_xTaskGetSchedulerState
252     #define INCLUDE_xTaskGetSchedulerState 0
253 #endif
254
255 #ifndef INCLUDE_xTaskGetCurrentTaskHandle
256     #define INCLUDE_xTaskGetCurrentTaskHandle 0
257 #endif
258
259
260 #ifndef portSET_INTERRUPT_MASK_FROM_ISR
261     #define portSET_INTERRUPT_MASK_FROM_ISR() 0
262 #endif
263
264 #ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR
265     #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue
266 #endif
267
268 #ifndef portCLEAN_UP_TCB
269     #define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB
270 #endif
271
272 #ifndef portSETUP_TCB
273     #define portSETUP_TCB( pxTCB ) ( void ) pxTCB
274 #endif
275
276 #ifndef configQUEUE_REGISTRY_SIZE
277     #define configQUEUE_REGISTRY_SIZE 0U
278 #endif
279
280 #if ( configQUEUE_REGISTRY_SIZE < 1 )
281     #define vQueueAddToRegistry( xQueue, pcName )
282     #define vQueueUnregisterQueue( xQueue )
283 #endif
284
285 #ifndef portPOINTER_SIZE_TYPE
286     #define portPOINTER_SIZE_TYPE unsigned long
287 #endif
288
289 /* Remove any unused trace macros. */
290 #ifndef traceSTART
291     /* Used to perform any necessary initialisation - for example, open a file
292     into which trace is to be written. */
293     #define traceSTART()
294 #endif
295
296 #ifndef traceEND
297     /* Use to close a trace, for example close a file into which trace has been
298     written. */
299     #define traceEND()
300 #endif
301
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()
306 #endif
307
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()
312 #endif
313
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
319     muted. */
320     #define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority )
321 #endif
322
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 )
329 #endif
330
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 )
337 #endif
338
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 )
345 #endif
346
347 #ifndef configCHECK_FOR_STACK_OVERFLOW
348     #define configCHECK_FOR_STACK_OVERFLOW 0
349 #endif
350
351 /* The following event macros are embedded in the kernel API calls. */
352
353 #ifndef traceMOVED_TASK_TO_READY_STATE
354     #define traceMOVED_TASK_TO_READY_STATE( pxTCB )
355 #endif
356
357 #ifndef traceQUEUE_CREATE
358     #define traceQUEUE_CREATE( pxNewQueue )
359 #endif
360
361 #ifndef traceQUEUE_CREATE_FAILED
362     #define traceQUEUE_CREATE_FAILED( ucQueueType )
363 #endif
364
365 #ifndef traceCREATE_MUTEX
366     #define traceCREATE_MUTEX( pxNewQueue )
367 #endif
368
369 #ifndef traceCREATE_MUTEX_FAILED
370     #define traceCREATE_MUTEX_FAILED()
371 #endif
372
373 #ifndef traceGIVE_MUTEX_RECURSIVE
374     #define traceGIVE_MUTEX_RECURSIVE( pxMutex )
375 #endif
376
377 #ifndef traceGIVE_MUTEX_RECURSIVE_FAILED
378     #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex )
379 #endif
380
381 #ifndef traceTAKE_MUTEX_RECURSIVE
382     #define traceTAKE_MUTEX_RECURSIVE( pxMutex )
383 #endif
384
385 #ifndef traceTAKE_MUTEX_RECURSIVE_FAILED
386     #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex )
387 #endif
388
389 #ifndef traceCREATE_COUNTING_SEMAPHORE
390     #define traceCREATE_COUNTING_SEMAPHORE()
391 #endif
392
393 #ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED
394     #define traceCREATE_COUNTING_SEMAPHORE_FAILED()
395 #endif
396
397 #ifndef traceQUEUE_SEND
398     #define traceQUEUE_SEND( pxQueue )
399 #endif
400
401 #ifndef traceQUEUE_SEND_FAILED
402     #define traceQUEUE_SEND_FAILED( pxQueue )
403 #endif
404
405 #ifndef traceQUEUE_RECEIVE
406     #define traceQUEUE_RECEIVE( pxQueue )
407 #endif
408
409 #ifndef traceQUEUE_PEEK
410     #define traceQUEUE_PEEK( pxQueue )
411 #endif
412
413 #ifndef traceQUEUE_RECEIVE_FAILED
414     #define traceQUEUE_RECEIVE_FAILED( pxQueue )
415 #endif
416
417 #ifndef traceQUEUE_SEND_FROM_ISR
418     #define traceQUEUE_SEND_FROM_ISR( pxQueue )
419 #endif
420
421 #ifndef traceQUEUE_SEND_FROM_ISR_FAILED
422     #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue )
423 #endif
424
425 #ifndef traceQUEUE_RECEIVE_FROM_ISR
426     #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue )
427 #endif
428
429 #ifndef traceQUEUE_RECEIVE_FROM_ISR_FAILED
430     #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue )
431 #endif
432
433 #ifndef traceQUEUE_DELETE
434     #define traceQUEUE_DELETE( pxQueue )
435 #endif
436
437 #ifndef traceTASK_CREATE
438     #define traceTASK_CREATE( pxNewTCB )
439 #endif
440
441 #ifndef traceTASK_CREATE_FAILED
442     #define traceTASK_CREATE_FAILED()
443 #endif
444
445 #ifndef traceTASK_DELETE
446     #define traceTASK_DELETE( pxTaskToDelete )
447 #endif
448
449 #ifndef traceTASK_DELAY_UNTIL
450     #define traceTASK_DELAY_UNTIL()
451 #endif
452
453 #ifndef traceTASK_DELAY
454     #define traceTASK_DELAY()
455 #endif
456
457 #ifndef traceTASK_PRIORITY_SET
458     #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority )
459 #endif
460
461 #ifndef traceTASK_SUSPEND
462     #define traceTASK_SUSPEND( pxTaskToSuspend )
463 #endif
464
465 #ifndef traceTASK_RESUME
466     #define traceTASK_RESUME( pxTaskToResume )
467 #endif
468
469 #ifndef traceTASK_RESUME_FROM_ISR
470     #define traceTASK_RESUME_FROM_ISR( pxTaskToResume )
471 #endif
472
473 #ifndef traceTASK_INCREMENT_TICK
474     #define traceTASK_INCREMENT_TICK( xTickCount )
475 #endif
476
477 #ifndef traceTIMER_CREATE
478     #define traceTIMER_CREATE( pxNewTimer )
479 #endif
480
481 #ifndef traceTIMER_CREATE_FAILED
482     #define traceTIMER_CREATE_FAILED()
483 #endif
484
485 #ifndef traceTIMER_COMMAND_SEND
486     #define traceTIMER_COMMAND_SEND( xTimer, xMessageID, xMessageValueValue, xReturn )
487 #endif
488
489 #ifndef traceTIMER_EXPIRED
490     #define traceTIMER_EXPIRED( pxTimer )
491 #endif
492
493 #ifndef traceTIMER_COMMAND_RECEIVED
494     #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue )
495 #endif
496
497 #ifndef configGENERATE_RUN_TIME_STATS
498     #define configGENERATE_RUN_TIME_STATS 0
499 #endif
500
501 #if ( configGENERATE_RUN_TIME_STATS == 1 )
502
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 */
506
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 */
512
513 #endif /* configGENERATE_RUN_TIME_STATS */
514
515 #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
516     #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
517 #endif
518
519 #ifndef configUSE_MALLOC_FAILED_HOOK
520     #define configUSE_MALLOC_FAILED_HOOK 0
521 #endif
522
523 #ifndef portPRIVILEGE_BIT
524     #define portPRIVILEGE_BIT ( ( unsigned portBASE_TYPE ) 0x00 )
525 #endif
526
527 #ifndef portYIELD_WITHIN_API
528     #define portYIELD_WITHIN_API portYIELD
529 #endif
530
531 #ifndef pvPortMallocAligned
532     #define pvPortMallocAligned( x, puxStackBuffer ) ( ( ( puxStackBuffer ) == NULL ) ? ( pvPortMalloc( ( x ) ) ) : ( puxStackBuffer ) )
533 #endif
534
535 #ifndef vPortFreeAligned
536     #define vPortFreeAligned( pvBlockToFree ) vPortFree( pvBlockToFree )
537 #endif
538
539 #ifndef portSUPPRESS_TICKS_AND_SLEEP
540     #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime )
541 #endif
542
543 #ifndef configPRE_SLEEP_PROCESSING
544     #define configPRE_SLEEP_PROCESSING( x )
545 #endif
546
547 #ifndef configPOST_SLEEP_PROCESSING
548     #define configPOST_SLEEP_PROCESSING( x )
549 #endif
550
551 #endif /* INC_FREERTOS_H */
552