FreeRTOS.h 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063
  1. /*
  2. FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
  3. All rights reserved
  4. VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
  5. This file is part of the FreeRTOS distribution.
  6. FreeRTOS is free software; you can redistribute it and/or modify it under
  7. the terms of the GNU General Public License (version 2) as published by the
  8. Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
  9. ***************************************************************************
  10. >>! NOTE: The modification to the GPL is included to allow you to !<<
  11. >>! distribute a combined work that includes FreeRTOS without being !<<
  12. >>! obliged to provide the source code for proprietary components !<<
  13. >>! outside of the FreeRTOS kernel. !<<
  14. ***************************************************************************
  15. FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
  16. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  17. FOR A PARTICULAR PURPOSE. Full license text is available on the following
  18. link: http://www.freertos.org/a00114.html
  19. ***************************************************************************
  20. * *
  21. * FreeRTOS provides completely free yet professionally developed, *
  22. * robust, strictly quality controlled, supported, and cross *
  23. * platform software that is more than just the market leader, it *
  24. * is the industry's de facto standard. *
  25. * *
  26. * Help yourself get started quickly while simultaneously helping *
  27. * to support the FreeRTOS project by purchasing a FreeRTOS *
  28. * tutorial book, reference manual, or both: *
  29. * http://www.FreeRTOS.org/Documentation *
  30. * *
  31. ***************************************************************************
  32. http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
  33. the FAQ page "My application does not run, what could be wrong?". Have you
  34. defined configASSERT()?
  35. http://www.FreeRTOS.org/support - In return for receiving this top quality
  36. embedded software for free we request you assist our global community by
  37. participating in the support forum.
  38. http://www.FreeRTOS.org/training - Investing in training allows your team to
  39. be as productive as possible as early as possible. Now you can receive
  40. FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
  41. Ltd, and the world's leading authority on the world's leading RTOS.
  42. http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
  43. including FreeRTOS+Trace - an indispensable productivity tool, a DOS
  44. compatible FAT file system, and our tiny thread aware UDP/IP stack.
  45. http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
  46. Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
  47. http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
  48. Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
  49. licenses offer ticketed support, indemnification and commercial middleware.
  50. http://www.SafeRTOS.com - High Integrity Systems also provide a safety
  51. engineered and independently SIL3 certified version for use in safety and
  52. mission critical applications that require provable dependability.
  53. 1 tab == 4 spaces!
  54. */
  55. #ifndef INC_FREERTOS_H
  56. #define INC_FREERTOS_H
  57. /*
  58. * Include the generic headers required for the FreeRTOS port being used.
  59. */
  60. #include <stddef.h>
  61. /*
  62. * If stdint.h cannot be located then:
  63. * + If using GCC ensure the -nostdint options is *not* being used.
  64. * + Ensure the project's include path includes the directory in which your
  65. * compiler stores stdint.h.
  66. * + Set any compiler options necessary for it to support C99, as technically
  67. * stdint.h is only mandatory with C99 (FreeRTOS does not require C99 in any
  68. * other way).
  69. * + The FreeRTOS download includes a simple stdint.h definition that can be
  70. * used in cases where none is provided by the compiler. The files only
  71. * contains the typedefs required to build FreeRTOS. Read the instructions
  72. * in FreeRTOS/source/stdint.readme for more information.
  73. */
  74. #include <stdint.h> /* READ COMMENT ABOVE. */
  75. #ifdef __cplusplus
  76. extern "C" {
  77. #endif
  78. /* Application specific configuration options. */
  79. #include "FreeRTOSConfig.h"
  80. /* Basic FreeRTOS definitions. */
  81. #include "projdefs.h"
  82. /* Definitions specific to the port being used. */
  83. #include "portable.h"
  84. /* Must be defaulted before configUSE_NEWLIB_REENTRANT is used below. */
  85. #ifndef configUSE_NEWLIB_REENTRANT
  86. #define configUSE_NEWLIB_REENTRANT 0
  87. #endif
  88. /* Required if struct _reent is used. */
  89. #if ( configUSE_NEWLIB_REENTRANT == 1 )
  90. #include <reent.h>
  91. #endif
  92. /*
  93. * Check all the required application specific macros have been defined.
  94. * These macros are application specific and (as downloaded) are defined
  95. * within FreeRTOSConfig.h.
  96. */
  97. #ifndef configMINIMAL_STACK_SIZE
  98. #error Missing definition: configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h. configMINIMAL_STACK_SIZE defines the size (in words) of the stack allocated to the idle task. Refer to the demo project provided for your port for a suitable value.
  99. #endif
  100. #ifndef configMAX_PRIORITIES
  101. #error Missing definition: configMAX_PRIORITIES must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details.
  102. #endif
  103. #ifndef configUSE_PREEMPTION
  104. #error Missing definition: configUSE_PREEMPTION must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
  105. #endif
  106. #ifndef configUSE_IDLE_HOOK
  107. #error Missing definition: configUSE_IDLE_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
  108. #endif
  109. #ifndef configUSE_TICK_HOOK
  110. #error Missing definition: configUSE_TICK_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
  111. #endif
  112. #ifndef configUSE_16_BIT_TICKS
  113. #error Missing definition: configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
  114. #endif
  115. #ifndef configMAX_PRIORITIES
  116. #error configMAX_PRIORITIES must be defined to be greater than or equal to 1.
  117. #endif
  118. #ifndef configUSE_CO_ROUTINES
  119. #define configUSE_CO_ROUTINES 0
  120. #endif
  121. #ifndef INCLUDE_vTaskPrioritySet
  122. #define INCLUDE_vTaskPrioritySet 0
  123. #endif
  124. #ifndef INCLUDE_uxTaskPriorityGet
  125. #define INCLUDE_uxTaskPriorityGet 0
  126. #endif
  127. #ifndef INCLUDE_vTaskDelete
  128. #define INCLUDE_vTaskDelete 0
  129. #endif
  130. #ifndef INCLUDE_vTaskSuspend
  131. #define INCLUDE_vTaskSuspend 0
  132. #endif
  133. #ifndef INCLUDE_vTaskDelayUntil
  134. #define INCLUDE_vTaskDelayUntil 0
  135. #endif
  136. #ifndef INCLUDE_vTaskDelay
  137. #define INCLUDE_vTaskDelay 0
  138. #endif
  139. #ifndef INCLUDE_xTaskGetIdleTaskHandle
  140. #define INCLUDE_xTaskGetIdleTaskHandle 0
  141. #endif
  142. #ifndef INCLUDE_xTaskAbortDelay
  143. #define INCLUDE_xTaskAbortDelay 0
  144. #endif
  145. #ifndef INCLUDE_xQueueGetMutexHolder
  146. #define INCLUDE_xQueueGetMutexHolder 0
  147. #endif
  148. #ifndef INCLUDE_xSemaphoreGetMutexHolder
  149. #define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder
  150. #endif
  151. #ifndef INCLUDE_xTaskGetHandle
  152. #define INCLUDE_xTaskGetHandle 0
  153. #endif
  154. #ifndef INCLUDE_uxTaskGetStackHighWaterMark
  155. #define INCLUDE_uxTaskGetStackHighWaterMark 0
  156. #endif
  157. #ifndef INCLUDE_eTaskGetState
  158. #define INCLUDE_eTaskGetState 0
  159. #endif
  160. #ifndef INCLUDE_xTaskResumeFromISR
  161. #define INCLUDE_xTaskResumeFromISR 1
  162. #endif
  163. #ifndef INCLUDE_xTimerPendFunctionCall
  164. #define INCLUDE_xTimerPendFunctionCall 0
  165. #endif
  166. #ifndef INCLUDE_xTaskGetSchedulerState
  167. #define INCLUDE_xTaskGetSchedulerState 0
  168. #endif
  169. #ifndef INCLUDE_xTaskGetCurrentTaskHandle
  170. #define INCLUDE_xTaskGetCurrentTaskHandle 0
  171. #endif
  172. #if configUSE_CO_ROUTINES != 0
  173. #ifndef configMAX_CO_ROUTINE_PRIORITIES
  174. #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1.
  175. #endif
  176. #endif
  177. #ifndef configUSE_DAEMON_TASK_STARTUP_HOOK
  178. #define configUSE_DAEMON_TASK_STARTUP_HOOK 0
  179. #endif
  180. #ifndef configUSE_APPLICATION_TASK_TAG
  181. #define configUSE_APPLICATION_TASK_TAG 0
  182. #endif
  183. #ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS
  184. #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
  185. #endif
  186. #ifndef configUSE_RECURSIVE_MUTEXES
  187. #define configUSE_RECURSIVE_MUTEXES 0
  188. #endif
  189. #ifndef configUSE_MUTEXES
  190. #define configUSE_MUTEXES 0
  191. #endif
  192. #ifndef configUSE_TIMERS
  193. #define configUSE_TIMERS 0
  194. #endif
  195. #ifndef configUSE_COUNTING_SEMAPHORES
  196. #define configUSE_COUNTING_SEMAPHORES 0
  197. #endif
  198. #ifndef configUSE_ALTERNATIVE_API
  199. #define configUSE_ALTERNATIVE_API 0
  200. #endif
  201. #ifndef portCRITICAL_NESTING_IN_TCB
  202. #define portCRITICAL_NESTING_IN_TCB 0
  203. #endif
  204. #ifndef configMAX_TASK_NAME_LEN
  205. #define configMAX_TASK_NAME_LEN 16
  206. #endif
  207. #ifndef configIDLE_SHOULD_YIELD
  208. #define configIDLE_SHOULD_YIELD 1
  209. #endif
  210. #if configMAX_TASK_NAME_LEN < 1
  211. #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h
  212. #endif
  213. #ifndef configASSERT
  214. #define configASSERT( x )
  215. #define configASSERT_DEFINED 0
  216. #else
  217. #define configASSERT_DEFINED 1
  218. #endif
  219. /* The timers module relies on xTaskGetSchedulerState(). */
  220. #if configUSE_TIMERS == 1
  221. #ifndef configTIMER_TASK_PRIORITY
  222. #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined.
  223. #endif /* configTIMER_TASK_PRIORITY */
  224. #ifndef configTIMER_QUEUE_LENGTH
  225. #error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined.
  226. #endif /* configTIMER_QUEUE_LENGTH */
  227. #ifndef configTIMER_TASK_STACK_DEPTH
  228. #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined.
  229. #endif /* configTIMER_TASK_STACK_DEPTH */
  230. #endif /* configUSE_TIMERS */
  231. #ifndef portSET_INTERRUPT_MASK_FROM_ISR
  232. #define portSET_INTERRUPT_MASK_FROM_ISR() 0
  233. #endif
  234. #ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR
  235. #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue
  236. #endif
  237. #ifndef portCLEAN_UP_TCB
  238. #define portCLEAN_UP_TCB( pxTCB ) ( void ) pxTCB
  239. #endif
  240. #ifndef portPRE_TASK_DELETE_HOOK
  241. #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxYieldPending )
  242. #endif
  243. #ifndef portSETUP_TCB
  244. #define portSETUP_TCB( pxTCB ) ( void ) pxTCB
  245. #endif
  246. #ifndef configQUEUE_REGISTRY_SIZE
  247. #define configQUEUE_REGISTRY_SIZE 0U
  248. #endif
  249. #if ( configQUEUE_REGISTRY_SIZE < 1 )
  250. #define vQueueAddToRegistry( xQueue, pcName )
  251. #define vQueueUnregisterQueue( xQueue )
  252. #define pcQueueGetName( xQueue )
  253. #endif
  254. #ifndef portPOINTER_SIZE_TYPE
  255. #define portPOINTER_SIZE_TYPE uint32_t
  256. #endif
  257. /* Remove any unused trace macros. */
  258. #ifndef traceSTART
  259. /* Used to perform any necessary initialisation - for example, open a file
  260. into which trace is to be written. */
  261. #define traceSTART()
  262. #endif
  263. #ifndef traceEND
  264. /* Use to close a trace, for example close a file into which trace has been
  265. written. */
  266. #define traceEND()
  267. #endif
  268. #ifndef traceTASK_SWITCHED_IN
  269. /* Called after a task has been selected to run. pxCurrentTCB holds a pointer
  270. to the task control block of the selected task. */
  271. #define traceTASK_SWITCHED_IN()
  272. #endif
  273. #ifndef traceINCREASE_TICK_COUNT
  274. /* Called before stepping the tick count after waking from tickless idle
  275. sleep. */
  276. #define traceINCREASE_TICK_COUNT( x )
  277. #endif
  278. #ifndef traceLOW_POWER_IDLE_BEGIN
  279. /* Called immediately before entering tickless idle. */
  280. #define traceLOW_POWER_IDLE_BEGIN()
  281. #endif
  282. #ifndef traceLOW_POWER_IDLE_END
  283. /* Called when returning to the Idle task after a tickless idle. */
  284. #define traceLOW_POWER_IDLE_END()
  285. #endif
  286. #ifndef traceTASK_SWITCHED_OUT
  287. /* Called before a task has been selected to run. pxCurrentTCB holds a pointer
  288. to the task control block of the task being switched out. */
  289. #define traceTASK_SWITCHED_OUT()
  290. #endif
  291. #ifndef traceTASK_PRIORITY_INHERIT
  292. /* Called when a task attempts to take a mutex that is already held by a
  293. lower priority task. pxTCBOfMutexHolder is a pointer to the TCB of the task
  294. that holds the mutex. uxInheritedPriority is the priority the mutex holder
  295. will inherit (the priority of the task that is attempting to obtain the
  296. muted. */
  297. #define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority )
  298. #endif
  299. #ifndef traceTASK_PRIORITY_DISINHERIT
  300. /* Called when a task releases a mutex, the holding of which had resulted in
  301. the task inheriting the priority of a higher priority task.
  302. pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the
  303. mutex. uxOriginalPriority is the task's configured (base) priority. */
  304. #define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority )
  305. #endif
  306. #ifndef traceBLOCKING_ON_QUEUE_RECEIVE
  307. /* Task is about to block because it cannot read from a
  308. queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore
  309. upon which the read was attempted. pxCurrentTCB points to the TCB of the
  310. task that attempted the read. */
  311. #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue )
  312. #endif
  313. #ifndef traceBLOCKING_ON_QUEUE_SEND
  314. /* Task is about to block because it cannot write to a
  315. queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore
  316. upon which the write was attempted. pxCurrentTCB points to the TCB of the
  317. task that attempted the write. */
  318. #define traceBLOCKING_ON_QUEUE_SEND( pxQueue )
  319. #endif
  320. #ifndef configCHECK_FOR_STACK_OVERFLOW
  321. #define configCHECK_FOR_STACK_OVERFLOW 0
  322. #endif
  323. /* The following event macros are embedded in the kernel API calls. */
  324. #ifndef traceMOVED_TASK_TO_READY_STATE
  325. #define traceMOVED_TASK_TO_READY_STATE( pxTCB )
  326. #endif
  327. #ifndef tracePOST_MOVED_TASK_TO_READY_STATE
  328. #define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB )
  329. #endif
  330. #ifndef traceQUEUE_CREATE
  331. #define traceQUEUE_CREATE( pxNewQueue )
  332. #endif
  333. #ifndef traceQUEUE_CREATE_FAILED
  334. #define traceQUEUE_CREATE_FAILED( ucQueueType )
  335. #endif
  336. #ifndef traceCREATE_MUTEX
  337. #define traceCREATE_MUTEX( pxNewQueue )
  338. #endif
  339. #ifndef traceCREATE_MUTEX_FAILED
  340. #define traceCREATE_MUTEX_FAILED()
  341. #endif
  342. #ifndef traceGIVE_MUTEX_RECURSIVE
  343. #define traceGIVE_MUTEX_RECURSIVE( pxMutex )
  344. #endif
  345. #ifndef traceGIVE_MUTEX_RECURSIVE_FAILED
  346. #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex )
  347. #endif
  348. #ifndef traceTAKE_MUTEX_RECURSIVE
  349. #define traceTAKE_MUTEX_RECURSIVE( pxMutex )
  350. #endif
  351. #ifndef traceTAKE_MUTEX_RECURSIVE_FAILED
  352. #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex )
  353. #endif
  354. #ifndef traceCREATE_COUNTING_SEMAPHORE
  355. #define traceCREATE_COUNTING_SEMAPHORE()
  356. #endif
  357. #ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED
  358. #define traceCREATE_COUNTING_SEMAPHORE_FAILED()
  359. #endif
  360. #ifndef traceQUEUE_SEND
  361. #define traceQUEUE_SEND( pxQueue )
  362. #endif
  363. #ifndef traceQUEUE_SEND_FAILED
  364. #define traceQUEUE_SEND_FAILED( pxQueue )
  365. #endif
  366. #ifndef traceQUEUE_RECEIVE
  367. #define traceQUEUE_RECEIVE( pxQueue )
  368. #endif
  369. #ifndef traceQUEUE_PEEK
  370. #define traceQUEUE_PEEK( pxQueue )
  371. #endif
  372. #ifndef traceQUEUE_PEEK_FROM_ISR
  373. #define traceQUEUE_PEEK_FROM_ISR( pxQueue )
  374. #endif
  375. #ifndef traceQUEUE_RECEIVE_FAILED
  376. #define traceQUEUE_RECEIVE_FAILED( pxQueue )
  377. #endif
  378. #ifndef traceQUEUE_SEND_FROM_ISR
  379. #define traceQUEUE_SEND_FROM_ISR( pxQueue )
  380. #endif
  381. #ifndef traceQUEUE_SEND_FROM_ISR_FAILED
  382. #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue )
  383. #endif
  384. #ifndef traceQUEUE_RECEIVE_FROM_ISR
  385. #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue )
  386. #endif
  387. #ifndef traceQUEUE_RECEIVE_FROM_ISR_FAILED
  388. #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue )
  389. #endif
  390. #ifndef traceQUEUE_PEEK_FROM_ISR_FAILED
  391. #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue )
  392. #endif
  393. #ifndef traceQUEUE_DELETE
  394. #define traceQUEUE_DELETE( pxQueue )
  395. #endif
  396. #ifndef traceTASK_CREATE
  397. #define traceTASK_CREATE( pxNewTCB )
  398. #endif
  399. #ifndef traceTASK_CREATE_FAILED
  400. #define traceTASK_CREATE_FAILED()
  401. #endif
  402. #ifndef traceTASK_DELETE
  403. #define traceTASK_DELETE( pxTaskToDelete )
  404. #endif
  405. #ifndef traceTASK_DELAY_UNTIL
  406. #define traceTASK_DELAY_UNTIL( x )
  407. #endif
  408. #ifndef traceTASK_DELAY
  409. #define traceTASK_DELAY()
  410. #endif
  411. #ifndef traceTASK_PRIORITY_SET
  412. #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority )
  413. #endif
  414. #ifndef traceTASK_SUSPEND
  415. #define traceTASK_SUSPEND( pxTaskToSuspend )
  416. #endif
  417. #ifndef traceTASK_RESUME
  418. #define traceTASK_RESUME( pxTaskToResume )
  419. #endif
  420. #ifndef traceTASK_RESUME_FROM_ISR
  421. #define traceTASK_RESUME_FROM_ISR( pxTaskToResume )
  422. #endif
  423. #ifndef traceTASK_INCREMENT_TICK
  424. #define traceTASK_INCREMENT_TICK( xTickCount )
  425. #endif
  426. #ifndef traceTIMER_CREATE
  427. #define traceTIMER_CREATE( pxNewTimer )
  428. #endif
  429. #ifndef traceTIMER_CREATE_FAILED
  430. #define traceTIMER_CREATE_FAILED()
  431. #endif
  432. #ifndef traceTIMER_COMMAND_SEND
  433. #define traceTIMER_COMMAND_SEND( xTimer, xMessageID, xMessageValueValue, xReturn )
  434. #endif
  435. #ifndef traceTIMER_EXPIRED
  436. #define traceTIMER_EXPIRED( pxTimer )
  437. #endif
  438. #ifndef traceTIMER_COMMAND_RECEIVED
  439. #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue )
  440. #endif
  441. #ifndef traceMALLOC
  442. #define traceMALLOC( pvAddress, uiSize )
  443. #endif
  444. #ifndef traceFREE
  445. #define traceFREE( pvAddress, uiSize )
  446. #endif
  447. #ifndef traceEVENT_GROUP_CREATE
  448. #define traceEVENT_GROUP_CREATE( xEventGroup )
  449. #endif
  450. #ifndef traceEVENT_GROUP_CREATE_FAILED
  451. #define traceEVENT_GROUP_CREATE_FAILED()
  452. #endif
  453. #ifndef traceEVENT_GROUP_SYNC_BLOCK
  454. #define traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor )
  455. #endif
  456. #ifndef traceEVENT_GROUP_SYNC_END
  457. #define traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred
  458. #endif
  459. #ifndef traceEVENT_GROUP_WAIT_BITS_BLOCK
  460. #define traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor )
  461. #endif
  462. #ifndef traceEVENT_GROUP_WAIT_BITS_END
  463. #define traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) xTimeoutOccurred
  464. #endif
  465. #ifndef traceEVENT_GROUP_CLEAR_BITS
  466. #define traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear )
  467. #endif
  468. #ifndef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR
  469. #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear )
  470. #endif
  471. #ifndef traceEVENT_GROUP_SET_BITS
  472. #define traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet )
  473. #endif
  474. #ifndef traceEVENT_GROUP_SET_BITS_FROM_ISR
  475. #define traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet )
  476. #endif
  477. #ifndef traceEVENT_GROUP_DELETE
  478. #define traceEVENT_GROUP_DELETE( xEventGroup )
  479. #endif
  480. #ifndef tracePEND_FUNC_CALL
  481. #define tracePEND_FUNC_CALL(xFunctionToPend, pvParameter1, ulParameter2, ret)
  482. #endif
  483. #ifndef tracePEND_FUNC_CALL_FROM_ISR
  484. #define tracePEND_FUNC_CALL_FROM_ISR(xFunctionToPend, pvParameter1, ulParameter2, ret)
  485. #endif
  486. #ifndef traceQUEUE_REGISTRY_ADD
  487. #define traceQUEUE_REGISTRY_ADD(xQueue, pcQueueName)
  488. #endif
  489. #ifndef traceTASK_NOTIFY_TAKE_BLOCK
  490. #define traceTASK_NOTIFY_TAKE_BLOCK()
  491. #endif
  492. #ifndef traceTASK_NOTIFY_TAKE
  493. #define traceTASK_NOTIFY_TAKE()
  494. #endif
  495. #ifndef traceTASK_NOTIFY_WAIT_BLOCK
  496. #define traceTASK_NOTIFY_WAIT_BLOCK()
  497. #endif
  498. #ifndef traceTASK_NOTIFY_WAIT
  499. #define traceTASK_NOTIFY_WAIT()
  500. #endif
  501. #ifndef traceTASK_NOTIFY
  502. #define traceTASK_NOTIFY()
  503. #endif
  504. #ifndef traceTASK_NOTIFY_FROM_ISR
  505. #define traceTASK_NOTIFY_FROM_ISR()
  506. #endif
  507. #ifndef traceTASK_NOTIFY_GIVE_FROM_ISR
  508. #define traceTASK_NOTIFY_GIVE_FROM_ISR()
  509. #endif
  510. #ifndef configGENERATE_RUN_TIME_STATS
  511. #define configGENERATE_RUN_TIME_STATS 0
  512. #endif
  513. #if ( configGENERATE_RUN_TIME_STATS == 1 )
  514. #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
  515. #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.
  516. #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */
  517. #ifndef portGET_RUN_TIME_COUNTER_VALUE
  518. #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE
  519. #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.
  520. #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */
  521. #endif /* portGET_RUN_TIME_COUNTER_VALUE */
  522. #endif /* configGENERATE_RUN_TIME_STATS */
  523. #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
  524. #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
  525. #endif
  526. #ifndef configUSE_MALLOC_FAILED_HOOK
  527. #define configUSE_MALLOC_FAILED_HOOK 0
  528. #endif
  529. #ifndef portPRIVILEGE_BIT
  530. #define portPRIVILEGE_BIT ( ( UBaseType_t ) 0x00 )
  531. #endif
  532. #ifndef portYIELD_WITHIN_API
  533. #define portYIELD_WITHIN_API portYIELD
  534. #endif
  535. #ifndef portSUPPRESS_TICKS_AND_SLEEP
  536. #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime )
  537. #endif
  538. #ifndef configEXPECTED_IDLE_TIME_BEFORE_SLEEP
  539. #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2
  540. #endif
  541. #if configEXPECTED_IDLE_TIME_BEFORE_SLEEP < 2
  542. #error configEXPECTED_IDLE_TIME_BEFORE_SLEEP must not be less than 2
  543. #endif
  544. #ifndef configUSE_TICKLESS_IDLE
  545. #define configUSE_TICKLESS_IDLE 0
  546. #endif
  547. #ifndef configPRE_SLEEP_PROCESSING
  548. #define configPRE_SLEEP_PROCESSING( x )
  549. #endif
  550. #ifndef configPOST_SLEEP_PROCESSING
  551. #define configPOST_SLEEP_PROCESSING( x )
  552. #endif
  553. #ifndef configUSE_QUEUE_SETS
  554. #define configUSE_QUEUE_SETS 0
  555. #endif
  556. #ifndef portTASK_USES_FLOATING_POINT
  557. #define portTASK_USES_FLOATING_POINT()
  558. #endif
  559. #ifndef configUSE_TIME_SLICING
  560. #define configUSE_TIME_SLICING 1
  561. #endif
  562. #ifndef configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS
  563. #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0
  564. #endif
  565. #ifndef configUSE_STATS_FORMATTING_FUNCTIONS
  566. #define configUSE_STATS_FORMATTING_FUNCTIONS 0
  567. #endif
  568. #ifndef portASSERT_IF_INTERRUPT_PRIORITY_INVALID
  569. #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID()
  570. #endif
  571. #ifndef configUSE_TRACE_FACILITY
  572. #define configUSE_TRACE_FACILITY 0
  573. #endif
  574. #ifndef mtCOVERAGE_TEST_MARKER
  575. #define mtCOVERAGE_TEST_MARKER()
  576. #endif
  577. #ifndef mtCOVERAGE_TEST_DELAY
  578. #define mtCOVERAGE_TEST_DELAY()
  579. #endif
  580. #ifndef portASSERT_IF_IN_ISR
  581. #define portASSERT_IF_IN_ISR()
  582. #endif
  583. #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
  584. #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
  585. #endif
  586. #ifndef configAPPLICATION_ALLOCATED_HEAP
  587. #define configAPPLICATION_ALLOCATED_HEAP 0
  588. #endif
  589. #ifndef configUSE_TASK_NOTIFICATIONS
  590. #define configUSE_TASK_NOTIFICATIONS 1
  591. #endif
  592. #ifndef portTICK_TYPE_IS_ATOMIC
  593. #define portTICK_TYPE_IS_ATOMIC 0
  594. #endif
  595. #ifndef configSUPPORT_STATIC_ALLOCATION
  596. /* Defaults to 0 for backward compatibility. */
  597. #define configSUPPORT_STATIC_ALLOCATION 0
  598. #endif
  599. #ifndef configSUPPORT_DYNAMIC_ALLOCATION
  600. /* Defaults to 1 for backward compatibility. */
  601. #define configSUPPORT_DYNAMIC_ALLOCATION 1
  602. #endif
  603. /* Sanity check the configuration. */
  604. #if( configUSE_TICKLESS_IDLE != 0 )
  605. #if( INCLUDE_vTaskSuspend != 1 )
  606. #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0
  607. #endif /* INCLUDE_vTaskSuspend */
  608. #endif /* configUSE_TICKLESS_IDLE */
  609. #if( ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) )
  610. #error configSUPPORT_STATIC_ALLOCATION and configSUPPORT_DYNAMIC_ALLOCATION cannot both be 0, but can both be 1.
  611. #endif
  612. #if( ( configUSE_RECURSIVE_MUTEXES == 1 ) && ( configUSE_MUTEXES != 1 ) )
  613. #error configUSE_MUTEXES must be set to 1 to use recursive mutexes
  614. #endif
  615. #if( portTICK_TYPE_IS_ATOMIC == 0 )
  616. /* Either variables of tick type cannot be read atomically, or
  617. portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when
  618. the tick count is returned to the standard critical section macros. */
  619. #define portTICK_TYPE_ENTER_CRITICAL() portENTER_CRITICAL()
  620. #define portTICK_TYPE_EXIT_CRITICAL() portEXIT_CRITICAL()
  621. #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()
  622. #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( ( x ) )
  623. #else
  624. /* The tick type can be read atomically, so critical sections used when the
  625. tick count is returned can be defined away. */
  626. #define portTICK_TYPE_ENTER_CRITICAL()
  627. #define portTICK_TYPE_EXIT_CRITICAL()
  628. #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() 0
  629. #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) ( void ) x
  630. #endif
  631. /* Definitions to allow backward compatibility with FreeRTOS versions prior to
  632. V8 if desired. */
  633. #ifndef configENABLE_BACKWARD_COMPATIBILITY
  634. #define configENABLE_BACKWARD_COMPATIBILITY 1
  635. #endif
  636. #if configENABLE_BACKWARD_COMPATIBILITY == 1
  637. #define eTaskStateGet eTaskGetState
  638. #define portTickType TickType_t
  639. #define xTaskHandle TaskHandle_t
  640. #define xQueueHandle QueueHandle_t
  641. #define xSemaphoreHandle SemaphoreHandle_t
  642. #define xQueueSetHandle QueueSetHandle_t
  643. #define xQueueSetMemberHandle QueueSetMemberHandle_t
  644. #define xTimeOutType TimeOut_t
  645. #define xMemoryRegion MemoryRegion_t
  646. #define xTaskParameters TaskParameters_t
  647. #define xTaskStatusType TaskStatus_t
  648. #define xTimerHandle TimerHandle_t
  649. #define xCoRoutineHandle CoRoutineHandle_t
  650. #define pdTASK_HOOK_CODE TaskHookFunction_t
  651. #define portTICK_RATE_MS portTICK_PERIOD_MS
  652. #define pcTaskGetTaskName pcTaskGetName
  653. #define pcTimerGetTimerName pcTimerGetName
  654. #define pcQueueGetQueueName pcQueueGetName
  655. #define vTaskGetTaskInfo vTaskGetInfo
  656. /* Backward compatibility within the scheduler code only - these definitions
  657. are not really required but are included for completeness. */
  658. #define tmrTIMER_CALLBACK TimerCallbackFunction_t
  659. #define pdTASK_CODE TaskFunction_t
  660. #define xListItem ListItem_t
  661. #define xList List_t
  662. #endif /* configENABLE_BACKWARD_COMPATIBILITY */
  663. #if( configUSE_ALTERNATIVE_API != 0 )
  664. #error The alternative API was deprecated some time ago, and was removed in FreeRTOS V9.0 0
  665. #endif
  666. /* Set configUSE_TASK_FPU_SUPPORT to 0 to omit floating point support even
  667. if floating point hardware is otherwise supported by the FreeRTOS port in use.
  668. This constant is not supported by all FreeRTOS ports that include floating
  669. point support. */
  670. #ifndef configUSE_TASK_FPU_SUPPORT
  671. #define configUSE_TASK_FPU_SUPPORT 1
  672. #endif
  673. /*
  674. * In line with software engineering best practice, FreeRTOS implements a strict
  675. * data hiding policy, so the real structures used by FreeRTOS to maintain the
  676. * state of tasks, queues, semaphores, etc. are not accessible to the application
  677. * code. However, if the application writer wants to statically allocate such
  678. * an object then the size of the object needs to be know. Dummy structures
  679. * that are guaranteed to have the same size and alignment requirements of the
  680. * real objects are used for this purpose. The dummy list and list item
  681. * structures below are used for inclusion in such a dummy structure.
  682. */
  683. struct xSTATIC_LIST_ITEM
  684. {
  685. TickType_t xDummy1;
  686. void *pvDummy2[ 4 ];
  687. };
  688. typedef struct xSTATIC_LIST_ITEM StaticListItem_t;
  689. /* See the comments above the struct xSTATIC_LIST_ITEM definition. */
  690. struct xSTATIC_MINI_LIST_ITEM
  691. {
  692. TickType_t xDummy1;
  693. void *pvDummy2[ 2 ];
  694. };
  695. typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t;
  696. /* See the comments above the struct xSTATIC_LIST_ITEM definition. */
  697. typedef struct xSTATIC_LIST
  698. {
  699. UBaseType_t uxDummy1;
  700. void *pvDummy2;
  701. StaticMiniListItem_t xDummy3;
  702. } StaticList_t;
  703. /*
  704. * In line with software engineering best practice, especially when supplying a
  705. * library that is likely to change in future versions, FreeRTOS implements a
  706. * strict data hiding policy. This means the Task structure used internally by
  707. * FreeRTOS is not accessible to application code. However, if the application
  708. * writer wants to statically allocate the memory required to create a task then
  709. * the size of the task object needs to be know. The StaticTask_t structure
  710. * below is provided for this purpose. Its sizes and alignment requirements are
  711. * guaranteed to match those of the genuine structure, no matter which
  712. * architecture is being used, and no matter how the values in FreeRTOSConfig.h
  713. * are set. Its contents are somewhat obfuscated in the hope users will
  714. * recognise that it would be unwise to make direct use of the structure members.
  715. */
  716. typedef struct xSTATIC_TCB
  717. {
  718. void *pxDummy1;
  719. #if ( portUSING_MPU_WRAPPERS == 1 )
  720. xMPU_SETTINGS xDummy2;
  721. #endif
  722. StaticListItem_t xDummy3[ 2 ];
  723. UBaseType_t uxDummy5;
  724. void *pxDummy6;
  725. uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ];
  726. #if ( portSTACK_GROWTH > 0 )
  727. void *pxDummy8;
  728. #endif
  729. #if ( portCRITICAL_NESTING_IN_TCB == 1 )
  730. UBaseType_t uxDummy9;
  731. #endif
  732. #if ( configUSE_TRACE_FACILITY == 1 )
  733. UBaseType_t uxDummy10[ 2 ];
  734. #endif
  735. #if ( configUSE_MUTEXES == 1 )
  736. UBaseType_t uxDummy12[ 2 ];
  737. #endif
  738. #if ( configUSE_APPLICATION_TASK_TAG == 1 )
  739. void *pxDummy14;
  740. #endif
  741. #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
  742. void *pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];
  743. #endif
  744. #if ( configGENERATE_RUN_TIME_STATS == 1 )
  745. uint32_t ulDummy16;
  746. #endif
  747. #if ( configUSE_NEWLIB_REENTRANT == 1 )
  748. struct _reent xDummy17;
  749. #endif
  750. #if ( configUSE_TASK_NOTIFICATIONS == 1 )
  751. uint32_t ulDummy18;
  752. uint8_t ucDummy19;
  753. #endif
  754. #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
  755. uint8_t uxDummy20;
  756. #endif
  757. } StaticTask_t;
  758. /*
  759. * In line with software engineering best practice, especially when supplying a
  760. * library that is likely to change in future versions, FreeRTOS implements a
  761. * strict data hiding policy. This means the Queue structure used internally by
  762. * FreeRTOS is not accessible to application code. However, if the application
  763. * writer wants to statically allocate the memory required to create a queue
  764. * then the size of the queue object needs to be know. The StaticQueue_t
  765. * structure below is provided for this purpose. Its sizes and alignment
  766. * requirements are guaranteed to match those of the genuine structure, no
  767. * matter which architecture is being used, and no matter how the values in
  768. * FreeRTOSConfig.h are set. Its contents are somewhat obfuscated in the hope
  769. * users will recognise that it would be unwise to make direct use of the
  770. * structure members.
  771. */
  772. typedef struct xSTATIC_QUEUE
  773. {
  774. void *pvDummy1[ 3 ];
  775. union
  776. {
  777. void *pvDummy2;
  778. UBaseType_t uxDummy2;
  779. } u;
  780. StaticList_t xDummy3[ 2 ];
  781. UBaseType_t uxDummy4[ 3 ];
  782. uint8_t ucDummy5[ 2 ];
  783. #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
  784. uint8_t ucDummy6;
  785. #endif
  786. #if ( configUSE_QUEUE_SETS == 1 )
  787. void *pvDummy7;
  788. #endif
  789. #if ( configUSE_TRACE_FACILITY == 1 )
  790. UBaseType_t uxDummy8;
  791. uint8_t ucDummy9;
  792. #endif
  793. } StaticQueue_t;
  794. typedef StaticQueue_t StaticSemaphore_t;
  795. /*
  796. * In line with software engineering best practice, especially when supplying a
  797. * library that is likely to change in future versions, FreeRTOS implements a
  798. * strict data hiding policy. This means the event group structure used
  799. * internally by FreeRTOS is not accessible to application code. However, if
  800. * the application writer wants to statically allocate the memory required to
  801. * create an event group then the size of the event group object needs to be
  802. * know. The StaticEventGroup_t structure below is provided for this purpose.
  803. * Its sizes and alignment requirements are guaranteed to match those of the
  804. * genuine structure, no matter which architecture is being used, and no matter
  805. * how the values in FreeRTOSConfig.h are set. Its contents are somewhat
  806. * obfuscated in the hope users will recognise that it would be unwise to make
  807. * direct use of the structure members.
  808. */
  809. typedef struct xSTATIC_EVENT_GROUP
  810. {
  811. TickType_t xDummy1;
  812. StaticList_t xDummy2;
  813. #if( configUSE_TRACE_FACILITY == 1 )
  814. UBaseType_t uxDummy3;
  815. #endif
  816. #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
  817. uint8_t ucDummy4;
  818. #endif
  819. } StaticEventGroup_t;
  820. /*
  821. * In line with software engineering best practice, especially when supplying a
  822. * library that is likely to change in future versions, FreeRTOS implements a
  823. * strict data hiding policy. This means the software timer structure used
  824. * internally by FreeRTOS is not accessible to application code. However, if
  825. * the application writer wants to statically allocate the memory required to
  826. * create a software timer then the size of the queue object needs to be know.
  827. * The StaticTimer_t structure below is provided for this purpose. Its sizes
  828. * and alignment requirements are guaranteed to match those of the genuine
  829. * structure, no matter which architecture is being used, and no matter how the
  830. * values in FreeRTOSConfig.h are set. Its contents are somewhat obfuscated in
  831. * the hope users will recognise that it would be unwise to make direct use of
  832. * the structure members.
  833. */
  834. typedef struct xSTATIC_TIMER
  835. {
  836. void *pvDummy1;
  837. StaticListItem_t xDummy2;
  838. TickType_t xDummy3;
  839. UBaseType_t uxDummy4;
  840. void *pvDummy5[ 2 ];
  841. #if( configUSE_TRACE_FACILITY == 1 )
  842. UBaseType_t uxDummy6;
  843. #endif
  844. #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
  845. uint8_t ucDummy7;
  846. #endif
  847. } StaticTimer_t;
  848. #ifdef __cplusplus
  849. }
  850. #endif
  851. #endif /* INC_FREERTOS_H */