task.h 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037
  1. /*
  2. FreeRTOS V8.2.3 - Copyright (C) 2015 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_TASK_H
  56. #define INC_TASK_H
  57. #ifndef INC_FREERTOS_H
  58. #error "include FreeRTOS.h must appear in source files before include task.h"
  59. #endif
  60. #include "list.h"
  61. #ifdef __cplusplus
  62. extern "C" {
  63. #endif
  64. /*-----------------------------------------------------------
  65. * MACROS AND DEFINITIONS
  66. *----------------------------------------------------------*/
  67. #define tskKERNEL_VERSION_NUMBER "V8.2.3"
  68. #define tskKERNEL_VERSION_MAJOR 8
  69. #define tskKERNEL_VERSION_MINOR 2
  70. #define tskKERNEL_VERSION_BUILD 3
  71. /**
  72. * task. h
  73. *
  74. * Type by which tasks are referenced. For example, a call to xTaskCreate
  75. * returns (via a pointer parameter) an TaskHandle_t variable that can then
  76. * be used as a parameter to vTaskDelete to delete the task.
  77. *
  78. * \defgroup TaskHandle_t TaskHandle_t
  79. * \ingroup Tasks
  80. */
  81. typedef void * TaskHandle_t;
  82. /*
  83. * Defines the prototype to which the application task hook function must
  84. * conform.
  85. */
  86. typedef BaseType_t (*TaskHookFunction_t)( void * );
  87. /* Task states returned by eTaskGetState. */
  88. typedef enum
  89. {
  90. eRunning = 0, /* A task is querying the state of itself, so must be running. */
  91. eReady, /* The task being queried is in a read or pending ready list. */
  92. eBlocked, /* The task being queried is in the Blocked state. */
  93. eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */
  94. eDeleted /* The task being queried has been deleted, but its TCB has not yet been freed. */
  95. } eTaskState;
  96. /* Actions that can be performed when vTaskNotify() is called. */
  97. typedef enum
  98. {
  99. eNoAction = 0, /* Notify the task without updating its notify value. */
  100. eSetBits, /* Set bits in the task's notification value. */
  101. eIncrement, /* Increment the task's notification value. */
  102. eSetValueWithOverwrite, /* Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */
  103. eSetValueWithoutOverwrite /* Set the task's notification value if the previous value has been read by the task. */
  104. } eNotifyAction;
  105. /*
  106. * Used internally only.
  107. */
  108. typedef struct xTIME_OUT
  109. {
  110. BaseType_t xOverflowCount;
  111. TickType_t xTimeOnEntering;
  112. } TimeOut_t;
  113. /*
  114. * Defines the memory ranges allocated to the task when an MPU is used.
  115. */
  116. typedef struct xMEMORY_REGION
  117. {
  118. void *pvBaseAddress;
  119. uint32_t ulLengthInBytes;
  120. uint32_t ulParameters;
  121. } MemoryRegion_t;
  122. /*
  123. * Parameters required to create an MPU protected task.
  124. */
  125. typedef struct xTASK_PARAMETERS
  126. {
  127. TaskFunction_t pvTaskCode;
  128. const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
  129. uint16_t usStackDepth;
  130. void *pvParameters;
  131. UBaseType_t uxPriority;
  132. StackType_t *puxStackBuffer;
  133. MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ];
  134. } TaskParameters_t;
  135. /* Used with the uxTaskGetSystemState() function to return the state of each task
  136. in the system. */
  137. typedef struct xTASK_STATUS
  138. {
  139. TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */
  140. const char *pcTaskName; /* A pointer to the task's name. This value will be invalid if the task was deleted since the structure was populated! */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
  141. UBaseType_t xTaskNumber; /* A number unique to the task. */
  142. eTaskState eCurrentState; /* The state in which the task existed when the structure was populated. */
  143. UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */
  144. UBaseType_t uxBasePriority; /* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */
  145. uint32_t ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock. See http://www.freertos.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */
  146. uint16_t usStackHighWaterMark; /* The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */
  147. } TaskStatus_t;
  148. /* Possible return values for eTaskConfirmSleepModeStatus(). */
  149. typedef enum
  150. {
  151. eAbortSleep = 0, /* A task has been made ready or a context switch pended since portSUPPORESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */
  152. eStandardSleep, /* Enter a sleep mode that will not last any longer than the expected idle time. */
  153. eNoTasksWaitingTimeout /* No tasks are waiting for a timeout so it is safe to enter a sleep mode that can only be exited by an external interrupt. */
  154. } eSleepModeStatus;
  155. /**
  156. * Defines the priority used by the idle task. This must not be modified.
  157. *
  158. * \ingroup TaskUtils
  159. */
  160. #define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U )
  161. /**
  162. * task. h
  163. *
  164. * Macro for forcing a context switch.
  165. *
  166. * \defgroup taskYIELD taskYIELD
  167. * \ingroup SchedulerControl
  168. */
  169. #define taskYIELD() portYIELD()
  170. /**
  171. * task. h
  172. *
  173. * Macro to mark the start of a critical code region. Preemptive context
  174. * switches cannot occur when in a critical region.
  175. *
  176. * NOTE: This may alter the stack (depending on the portable implementation)
  177. * so must be used with care!
  178. *
  179. * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL
  180. * \ingroup SchedulerControl
  181. */
  182. #define taskENTER_CRITICAL() portENTER_CRITICAL()
  183. #define taskENTER_CRITICAL_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()
  184. /**
  185. * task. h
  186. *
  187. * Macro to mark the end of a critical code region. Preemptive context
  188. * switches cannot occur when in a critical region.
  189. *
  190. * NOTE: This may alter the stack (depending on the portable implementation)
  191. * so must be used with care!
  192. *
  193. * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL
  194. * \ingroup SchedulerControl
  195. */
  196. #define taskEXIT_CRITICAL() portEXIT_CRITICAL()
  197. #define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x )
  198. /**
  199. * task. h
  200. *
  201. * Macro to disable all maskable interrupts.
  202. *
  203. * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS
  204. * \ingroup SchedulerControl
  205. */
  206. #define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS()
  207. /**
  208. * task. h
  209. *
  210. * Macro to enable microcontroller interrupts.
  211. *
  212. * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS
  213. * \ingroup SchedulerControl
  214. */
  215. #define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS()
  216. /* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is
  217. 0 to generate more optimal code when configASSERT() is defined as the constant
  218. is used in assert() statements. */
  219. #define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 )
  220. #define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 )
  221. #define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 )
  222. /*-----------------------------------------------------------
  223. * TASK CREATION API
  224. *----------------------------------------------------------*/
  225. /**
  226. * task. h
  227. *<pre>
  228. BaseType_t xTaskCreate(
  229. TaskFunction_t pvTaskCode,
  230. const char * const pcName,
  231. uint16_t usStackDepth,
  232. void *pvParameters,
  233. UBaseType_t uxPriority,
  234. TaskHandle_t *pvCreatedTask
  235. );</pre>
  236. *
  237. * Create a new task and add it to the list of tasks that are ready to run.
  238. *
  239. * xTaskCreate() can only be used to create a task that has unrestricted
  240. * access to the entire microcontroller memory map. Systems that include MPU
  241. * support can alternatively create an MPU constrained task using
  242. * xTaskCreateRestricted().
  243. *
  244. * @param pvTaskCode Pointer to the task entry function. Tasks
  245. * must be implemented to never return (i.e. continuous loop).
  246. *
  247. * @param pcName A descriptive name for the task. This is mainly used to
  248. * facilitate debugging. Max length defined by configMAX_TASK_NAME_LEN - default
  249. * is 16.
  250. *
  251. * @param usStackDepth The size of the task stack specified as the number of
  252. * variables the stack can hold - not the number of bytes. For example, if
  253. * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes
  254. * will be allocated for stack storage.
  255. *
  256. * @param pvParameters Pointer that will be used as the parameter for the task
  257. * being created.
  258. *
  259. * @param uxPriority The priority at which the task should run. Systems that
  260. * include MPU support can optionally create tasks in a privileged (system)
  261. * mode by setting bit portPRIVILEGE_BIT of the priority parameter. For
  262. * example, to create a privileged task at priority 2 the uxPriority parameter
  263. * should be set to ( 2 | portPRIVILEGE_BIT ).
  264. *
  265. * @param pvCreatedTask Used to pass back a handle by which the created task
  266. * can be referenced.
  267. *
  268. * @return pdPASS if the task was successfully created and added to a ready
  269. * list, otherwise an error code defined in the file projdefs.h
  270. *
  271. * Example usage:
  272. <pre>
  273. // Task to be created.
  274. void vTaskCode( void * pvParameters )
  275. {
  276. for( ;; )
  277. {
  278. // Task code goes here.
  279. }
  280. }
  281. // Function that creates a task.
  282. void vOtherFunction( void )
  283. {
  284. static uint8_t ucParameterToPass;
  285. TaskHandle_t xHandle = NULL;
  286. // Create the task, storing the handle. Note that the passed parameter ucParameterToPass
  287. // must exist for the lifetime of the task, so in this case is declared static. If it was just an
  288. // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time
  289. // the new task attempts to access it.
  290. xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
  291. configASSERT( xHandle );
  292. // Use the handle to delete the task.
  293. if( xHandle != NULL )
  294. {
  295. vTaskDelete( xHandle );
  296. }
  297. }
  298. </pre>
  299. * \defgroup xTaskCreate xTaskCreate
  300. * \ingroup Tasks
  301. */
  302. #define xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask ) xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), ( NULL ), ( NULL ) )
  303. /**
  304. * task. h
  305. *<pre>
  306. BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );</pre>
  307. *
  308. * xTaskCreateRestricted() should only be used in systems that include an MPU
  309. * implementation.
  310. *
  311. * Create a new task and add it to the list of tasks that are ready to run.
  312. * The function parameters define the memory regions and associated access
  313. * permissions allocated to the task.
  314. *
  315. * @param pxTaskDefinition Pointer to a structure that contains a member
  316. * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
  317. * documentation) plus an optional stack buffer and the memory region
  318. * definitions.
  319. *
  320. * @param pxCreatedTask Used to pass back a handle by which the created task
  321. * can be referenced.
  322. *
  323. * @return pdPASS if the task was successfully created and added to a ready
  324. * list, otherwise an error code defined in the file projdefs.h
  325. *
  326. * Example usage:
  327. <pre>
  328. // Create an TaskParameters_t structure that defines the task to be created.
  329. static const TaskParameters_t xCheckTaskParameters =
  330. {
  331. vATask, // pvTaskCode - the function that implements the task.
  332. "ATask", // pcName - just a text name for the task to assist debugging.
  333. 100, // usStackDepth - the stack size DEFINED IN WORDS.
  334. NULL, // pvParameters - passed into the task function as the function parameters.
  335. ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
  336. cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
  337. // xRegions - Allocate up to three separate memory regions for access by
  338. // the task, with appropriate access permissions. Different processors have
  339. // different memory alignment requirements - refer to the FreeRTOS documentation
  340. // for full information.
  341. {
  342. // Base address Length Parameters
  343. { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },
  344. { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },
  345. { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }
  346. }
  347. };
  348. int main( void )
  349. {
  350. TaskHandle_t xHandle;
  351. // Create a task from the const structure defined above. The task handle
  352. // is requested (the second parameter is not NULL) but in this case just for
  353. // demonstration purposes as its not actually used.
  354. xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
  355. // Start the scheduler.
  356. vTaskStartScheduler();
  357. // Will only get here if there was insufficient memory to create the idle
  358. // and/or timer task.
  359. for( ;; );
  360. }
  361. </pre>
  362. * \defgroup xTaskCreateRestricted xTaskCreateRestricted
  363. * \ingroup Tasks
  364. */
  365. #define xTaskCreateRestricted( x, pxCreatedTask ) xTaskGenericCreate( ((x)->pvTaskCode), ((x)->pcName), ((x)->usStackDepth), ((x)->pvParameters), ((x)->uxPriority), (pxCreatedTask), ((x)->puxStackBuffer), ((x)->xRegions) )
  366. /**
  367. * task. h
  368. *<pre>
  369. void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions );</pre>
  370. *
  371. * Memory regions are assigned to a restricted task when the task is created by
  372. * a call to xTaskCreateRestricted(). These regions can be redefined using
  373. * vTaskAllocateMPURegions().
  374. *
  375. * @param xTask The handle of the task being updated.
  376. *
  377. * @param xRegions A pointer to an MemoryRegion_t structure that contains the
  378. * new memory region definitions.
  379. *
  380. * Example usage:
  381. <pre>
  382. // Define an array of MemoryRegion_t structures that configures an MPU region
  383. // allowing read/write access for 1024 bytes starting at the beginning of the
  384. // ucOneKByte array. The other two of the maximum 3 definable regions are
  385. // unused so set to zero.
  386. static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =
  387. {
  388. // Base address Length Parameters
  389. { ucOneKByte, 1024, portMPU_REGION_READ_WRITE },
  390. { 0, 0, 0 },
  391. { 0, 0, 0 }
  392. };
  393. void vATask( void *pvParameters )
  394. {
  395. // This task was created such that it has access to certain regions of
  396. // memory as defined by the MPU configuration. At some point it is
  397. // desired that these MPU regions are replaced with that defined in the
  398. // xAltRegions const struct above. Use a call to vTaskAllocateMPURegions()
  399. // for this purpose. NULL is used as the task handle to indicate that this
  400. // function should modify the MPU regions of the calling task.
  401. vTaskAllocateMPURegions( NULL, xAltRegions );
  402. // Now the task can continue its function, but from this point on can only
  403. // access its stack and the ucOneKByte array (unless any other statically
  404. // defined or shared regions have been declared elsewhere).
  405. }
  406. </pre>
  407. * \defgroup xTaskCreateRestricted xTaskCreateRestricted
  408. * \ingroup Tasks
  409. */
  410. void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION;
  411. /**
  412. * task. h
  413. * <pre>void vTaskDelete( TaskHandle_t xTask );</pre>
  414. *
  415. * INCLUDE_vTaskDelete must be defined as 1 for this function to be available.
  416. * See the configuration section for more information.
  417. *
  418. * Remove a task from the RTOS real time kernel's management. The task being
  419. * deleted will be removed from all ready, blocked, suspended and event lists.
  420. *
  421. * NOTE: The idle task is responsible for freeing the kernel allocated
  422. * memory from tasks that have been deleted. It is therefore important that
  423. * the idle task is not starved of microcontroller processing time if your
  424. * application makes any calls to vTaskDelete (). Memory allocated by the
  425. * task code is not automatically freed, and should be freed before the task
  426. * is deleted.
  427. *
  428. * See the demo application file death.c for sample code that utilises
  429. * vTaskDelete ().
  430. *
  431. * @param xTask The handle of the task to be deleted. Passing NULL will
  432. * cause the calling task to be deleted.
  433. *
  434. * Example usage:
  435. <pre>
  436. void vOtherFunction( void )
  437. {
  438. TaskHandle_t xHandle;
  439. // Create the task, storing the handle.
  440. xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  441. // Use the handle to delete the task.
  442. vTaskDelete( xHandle );
  443. }
  444. </pre>
  445. * \defgroup vTaskDelete vTaskDelete
  446. * \ingroup Tasks
  447. */
  448. void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
  449. /*-----------------------------------------------------------
  450. * TASK CONTROL API
  451. *----------------------------------------------------------*/
  452. /**
  453. * task. h
  454. * <pre>void vTaskDelay( const TickType_t xTicksToDelay );</pre>
  455. *
  456. * Delay a task for a given number of ticks. The actual time that the
  457. * task remains blocked depends on the tick rate. The constant
  458. * portTICK_PERIOD_MS can be used to calculate real time from the tick
  459. * rate - with the resolution of one tick period.
  460. *
  461. * INCLUDE_vTaskDelay must be defined as 1 for this function to be available.
  462. * See the configuration section for more information.
  463. *
  464. *
  465. * vTaskDelay() specifies a time at which the task wishes to unblock relative to
  466. * the time at which vTaskDelay() is called. For example, specifying a block
  467. * period of 100 ticks will cause the task to unblock 100 ticks after
  468. * vTaskDelay() is called. vTaskDelay() does not therefore provide a good method
  469. * of controlling the frequency of a periodic task as the path taken through the
  470. * code, as well as other task and interrupt activity, will effect the frequency
  471. * at which vTaskDelay() gets called and therefore the time at which the task
  472. * next executes. See vTaskDelayUntil() for an alternative API function designed
  473. * to facilitate fixed frequency execution. It does this by specifying an
  474. * absolute time (rather than a relative time) at which the calling task should
  475. * unblock.
  476. *
  477. * @param xTicksToDelay The amount of time, in tick periods, that
  478. * the calling task should block.
  479. *
  480. * Example usage:
  481. void vTaskFunction( void * pvParameters )
  482. {
  483. // Block for 500ms.
  484. const TickType_t xDelay = 500 / portTICK_PERIOD_MS;
  485. for( ;; )
  486. {
  487. // Simply toggle the LED every 500ms, blocking between each toggle.
  488. vToggleLED();
  489. vTaskDelay( xDelay );
  490. }
  491. }
  492. * \defgroup vTaskDelay vTaskDelay
  493. * \ingroup TaskCtrl
  494. */
  495. void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
  496. /**
  497. * task. h
  498. * <pre>void vTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );</pre>
  499. *
  500. * INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available.
  501. * See the configuration section for more information.
  502. *
  503. * Delay a task until a specified time. This function can be used by periodic
  504. * tasks to ensure a constant execution frequency.
  505. *
  506. * This function differs from vTaskDelay () in one important aspect: vTaskDelay () will
  507. * cause a task to block for the specified number of ticks from the time vTaskDelay () is
  508. * called. It is therefore difficult to use vTaskDelay () by itself to generate a fixed
  509. * execution frequency as the time between a task starting to execute and that task
  510. * calling vTaskDelay () may not be fixed [the task may take a different path though the
  511. * code between calls, or may get interrupted or preempted a different number of times
  512. * each time it executes].
  513. *
  514. * Whereas vTaskDelay () specifies a wake time relative to the time at which the function
  515. * is called, vTaskDelayUntil () specifies the absolute (exact) time at which it wishes to
  516. * unblock.
  517. *
  518. * The constant portTICK_PERIOD_MS can be used to calculate real time from the tick
  519. * rate - with the resolution of one tick period.
  520. *
  521. * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the
  522. * task was last unblocked. The variable must be initialised with the current time
  523. * prior to its first use (see the example below). Following this the variable is
  524. * automatically updated within vTaskDelayUntil ().
  525. *
  526. * @param xTimeIncrement The cycle time period. The task will be unblocked at
  527. * time *pxPreviousWakeTime + xTimeIncrement. Calling vTaskDelayUntil with the
  528. * same xTimeIncrement parameter value will cause the task to execute with
  529. * a fixed interface period.
  530. *
  531. * Example usage:
  532. <pre>
  533. // Perform an action every 10 ticks.
  534. void vTaskFunction( void * pvParameters )
  535. {
  536. TickType_t xLastWakeTime;
  537. const TickType_t xFrequency = 10;
  538. // Initialise the xLastWakeTime variable with the current time.
  539. xLastWakeTime = xTaskGetTickCount ();
  540. for( ;; )
  541. {
  542. // Wait for the next cycle.
  543. vTaskDelayUntil( &xLastWakeTime, xFrequency );
  544. // Perform action here.
  545. }
  546. }
  547. </pre>
  548. * \defgroup vTaskDelayUntil vTaskDelayUntil
  549. * \ingroup TaskCtrl
  550. */
  551. void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
  552. /**
  553. * task. h
  554. * <pre>UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask );</pre>
  555. *
  556. * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available.
  557. * See the configuration section for more information.
  558. *
  559. * Obtain the priority of any task.
  560. *
  561. * @param xTask Handle of the task to be queried. Passing a NULL
  562. * handle results in the priority of the calling task being returned.
  563. *
  564. * @return The priority of xTask.
  565. *
  566. * Example usage:
  567. <pre>
  568. void vAFunction( void )
  569. {
  570. TaskHandle_t xHandle;
  571. // Create a task, storing the handle.
  572. xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  573. // ...
  574. // Use the handle to obtain the priority of the created task.
  575. // It was created with tskIDLE_PRIORITY, but may have changed
  576. // it itself.
  577. if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
  578. {
  579. // The task has changed it's priority.
  580. }
  581. // ...
  582. // Is our priority higher than the created task?
  583. if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
  584. {
  585. // Our priority (obtained using NULL handle) is higher.
  586. }
  587. }
  588. </pre>
  589. * \defgroup uxTaskPriorityGet uxTaskPriorityGet
  590. * \ingroup TaskCtrl
  591. */
  592. UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  593. /**
  594. * task. h
  595. * <pre>UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask );</pre>
  596. *
  597. * A version of uxTaskPriorityGet() that can be used from an ISR.
  598. */
  599. UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  600. /**
  601. * task. h
  602. * <pre>eTaskState eTaskGetState( TaskHandle_t xTask );</pre>
  603. *
  604. * INCLUDE_eTaskGetState must be defined as 1 for this function to be available.
  605. * See the configuration section for more information.
  606. *
  607. * Obtain the state of any task. States are encoded by the eTaskState
  608. * enumerated type.
  609. *
  610. * @param xTask Handle of the task to be queried.
  611. *
  612. * @return The state of xTask at the time the function was called. Note the
  613. * state of the task might change between the function being called, and the
  614. * functions return value being tested by the calling task.
  615. */
  616. eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  617. /**
  618. * task. h
  619. * <pre>void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );</pre>
  620. *
  621. * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.
  622. * See the configuration section for more information.
  623. *
  624. * Set the priority of any task.
  625. *
  626. * A context switch will occur before the function returns if the priority
  627. * being set is higher than the currently executing task.
  628. *
  629. * @param xTask Handle to the task for which the priority is being set.
  630. * Passing a NULL handle results in the priority of the calling task being set.
  631. *
  632. * @param uxNewPriority The priority to which the task will be set.
  633. *
  634. * Example usage:
  635. <pre>
  636. void vAFunction( void )
  637. {
  638. TaskHandle_t xHandle;
  639. // Create a task, storing the handle.
  640. xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  641. // ...
  642. // Use the handle to raise the priority of the created task.
  643. vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
  644. // ...
  645. // Use a NULL handle to raise our priority to the same value.
  646. vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
  647. }
  648. </pre>
  649. * \defgroup vTaskPrioritySet vTaskPrioritySet
  650. * \ingroup TaskCtrl
  651. */
  652. void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
  653. /**
  654. * task. h
  655. * <pre>void vTaskSuspend( TaskHandle_t xTaskToSuspend );</pre>
  656. *
  657. * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
  658. * See the configuration section for more information.
  659. *
  660. * Suspend any task. When suspended a task will never get any microcontroller
  661. * processing time, no matter what its priority.
  662. *
  663. * Calls to vTaskSuspend are not accumulative -
  664. * i.e. calling vTaskSuspend () twice on the same task still only requires one
  665. * call to vTaskResume () to ready the suspended task.
  666. *
  667. * @param xTaskToSuspend Handle to the task being suspended. Passing a NULL
  668. * handle will cause the calling task to be suspended.
  669. *
  670. * Example usage:
  671. <pre>
  672. void vAFunction( void )
  673. {
  674. TaskHandle_t xHandle;
  675. // Create a task, storing the handle.
  676. xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  677. // ...
  678. // Use the handle to suspend the created task.
  679. vTaskSuspend( xHandle );
  680. // ...
  681. // The created task will not run during this period, unless
  682. // another task calls vTaskResume( xHandle ).
  683. //...
  684. // Suspend ourselves.
  685. vTaskSuspend( NULL );
  686. // We cannot get here unless another task calls vTaskResume
  687. // with our handle as the parameter.
  688. }
  689. </pre>
  690. * \defgroup vTaskSuspend vTaskSuspend
  691. * \ingroup TaskCtrl
  692. */
  693. void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION;
  694. /**
  695. * task. h
  696. * <pre>void vTaskResume( TaskHandle_t xTaskToResume );</pre>
  697. *
  698. * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
  699. * See the configuration section for more information.
  700. *
  701. * Resumes a suspended task.
  702. *
  703. * A task that has been suspended by one or more calls to vTaskSuspend ()
  704. * will be made available for running again by a single call to
  705. * vTaskResume ().
  706. *
  707. * @param xTaskToResume Handle to the task being readied.
  708. *
  709. * Example usage:
  710. <pre>
  711. void vAFunction( void )
  712. {
  713. TaskHandle_t xHandle;
  714. // Create a task, storing the handle.
  715. xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  716. // ...
  717. // Use the handle to suspend the created task.
  718. vTaskSuspend( xHandle );
  719. // ...
  720. // The created task will not run during this period, unless
  721. // another task calls vTaskResume( xHandle ).
  722. //...
  723. // Resume the suspended task ourselves.
  724. vTaskResume( xHandle );
  725. // The created task will once again get microcontroller processing
  726. // time in accordance with its priority within the system.
  727. }
  728. </pre>
  729. * \defgroup vTaskResume vTaskResume
  730. * \ingroup TaskCtrl
  731. */
  732. void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
  733. /**
  734. * task. h
  735. * <pre>void xTaskResumeFromISR( TaskHandle_t xTaskToResume );</pre>
  736. *
  737. * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be
  738. * available. See the configuration section for more information.
  739. *
  740. * An implementation of vTaskResume() that can be called from within an ISR.
  741. *
  742. * A task that has been suspended by one or more calls to vTaskSuspend ()
  743. * will be made available for running again by a single call to
  744. * xTaskResumeFromISR ().
  745. *
  746. * xTaskResumeFromISR() should not be used to synchronise a task with an
  747. * interrupt if there is a chance that the interrupt could arrive prior to the
  748. * task being suspended - as this can lead to interrupts being missed. Use of a
  749. * semaphore as a synchronisation mechanism would avoid this eventuality.
  750. *
  751. * @param xTaskToResume Handle to the task being readied.
  752. *
  753. * @return pdTRUE if resuming the task should result in a context switch,
  754. * otherwise pdFALSE. This is used by the ISR to determine if a context switch
  755. * may be required following the ISR.
  756. *
  757. * \defgroup vTaskResumeFromISR vTaskResumeFromISR
  758. * \ingroup TaskCtrl
  759. */
  760. BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
  761. /*-----------------------------------------------------------
  762. * SCHEDULER CONTROL
  763. *----------------------------------------------------------*/
  764. /**
  765. * task. h
  766. * <pre>void vTaskStartScheduler( void );</pre>
  767. *
  768. * Starts the real time kernel tick processing. After calling the kernel
  769. * has control over which tasks are executed and when.
  770. *
  771. * See the demo application file main.c for an example of creating
  772. * tasks and starting the kernel.
  773. *
  774. * Example usage:
  775. <pre>
  776. void vAFunction( void )
  777. {
  778. // Create at least one task before starting the kernel.
  779. xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
  780. // Start the real time kernel with preemption.
  781. vTaskStartScheduler ();
  782. // Will not get here unless a task calls vTaskEndScheduler ()
  783. }
  784. </pre>
  785. *
  786. * \defgroup vTaskStartScheduler vTaskStartScheduler
  787. * \ingroup SchedulerControl
  788. */
  789. void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;
  790. /**
  791. * task. h
  792. * <pre>void vTaskEndScheduler( void );</pre>
  793. *
  794. * NOTE: At the time of writing only the x86 real mode port, which runs on a PC
  795. * in place of DOS, implements this function.
  796. *
  797. * Stops the real time kernel tick. All created tasks will be automatically
  798. * deleted and multitasking (either preemptive or cooperative) will
  799. * stop. Execution then resumes from the point where vTaskStartScheduler ()
  800. * was called, as if vTaskStartScheduler () had just returned.
  801. *
  802. * See the demo application file main. c in the demo/PC directory for an
  803. * example that uses vTaskEndScheduler ().
  804. *
  805. * vTaskEndScheduler () requires an exit function to be defined within the
  806. * portable layer (see vPortEndScheduler () in port. c for the PC port). This
  807. * performs hardware specific operations such as stopping the kernel tick.
  808. *
  809. * vTaskEndScheduler () will cause all of the resources allocated by the
  810. * kernel to be freed - but will not free resources allocated by application
  811. * tasks.
  812. *
  813. * Example usage:
  814. <pre>
  815. void vTaskCode( void * pvParameters )
  816. {
  817. for( ;; )
  818. {
  819. // Task code goes here.
  820. // At some point we want to end the real time kernel processing
  821. // so call ...
  822. vTaskEndScheduler ();
  823. }
  824. }
  825. void vAFunction( void )
  826. {
  827. // Create at least one task before starting the kernel.
  828. xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
  829. // Start the real time kernel with preemption.
  830. vTaskStartScheduler ();
  831. // Will only get here when the vTaskCode () task has called
  832. // vTaskEndScheduler (). When we get here we are back to single task
  833. // execution.
  834. }
  835. </pre>
  836. *
  837. * \defgroup vTaskEndScheduler vTaskEndScheduler
  838. * \ingroup SchedulerControl
  839. */
  840. void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;
  841. /**
  842. * task. h
  843. * <pre>void vTaskSuspendAll( void );</pre>
  844. *
  845. * Suspends the scheduler without disabling interrupts. Context switches will
  846. * not occur while the scheduler is suspended.
  847. *
  848. * After calling vTaskSuspendAll () the calling task will continue to execute
  849. * without risk of being swapped out until a call to xTaskResumeAll () has been
  850. * made.
  851. *
  852. * API functions that have the potential to cause a context switch (for example,
  853. * vTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler
  854. * is suspended.
  855. *
  856. * Example usage:
  857. <pre>
  858. void vTask1( void * pvParameters )
  859. {
  860. for( ;; )
  861. {
  862. // Task code goes here.
  863. // ...
  864. // At some point the task wants to perform a long operation during
  865. // which it does not want to get swapped out. It cannot use
  866. // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
  867. // operation may cause interrupts to be missed - including the
  868. // ticks.
  869. // Prevent the real time kernel swapping out the task.
  870. vTaskSuspendAll ();
  871. // Perform the operation here. There is no need to use critical
  872. // sections as we have all the microcontroller processing time.
  873. // During this time interrupts will still operate and the kernel
  874. // tick count will be maintained.
  875. // ...
  876. // The operation is complete. Restart the kernel.
  877. xTaskResumeAll ();
  878. }
  879. }
  880. </pre>
  881. * \defgroup vTaskSuspendAll vTaskSuspendAll
  882. * \ingroup SchedulerControl
  883. */
  884. void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;
  885. /**
  886. * task. h
  887. * <pre>BaseType_t xTaskResumeAll( void );</pre>
  888. *
  889. * Resumes scheduler activity after it was suspended by a call to
  890. * vTaskSuspendAll().
  891. *
  892. * xTaskResumeAll() only resumes the scheduler. It does not unsuspend tasks
  893. * that were previously suspended by a call to vTaskSuspend().
  894. *
  895. * @return If resuming the scheduler caused a context switch then pdTRUE is
  896. * returned, otherwise pdFALSE is returned.
  897. *
  898. * Example usage:
  899. <pre>
  900. void vTask1( void * pvParameters )
  901. {
  902. for( ;; )
  903. {
  904. // Task code goes here.
  905. // ...
  906. // At some point the task wants to perform a long operation during
  907. // which it does not want to get swapped out. It cannot use
  908. // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
  909. // operation may cause interrupts to be missed - including the
  910. // ticks.
  911. // Prevent the real time kernel swapping out the task.
  912. vTaskSuspendAll ();
  913. // Perform the operation here. There is no need to use critical
  914. // sections as we have all the microcontroller processing time.
  915. // During this time interrupts will still operate and the real
  916. // time kernel tick count will be maintained.
  917. // ...
  918. // The operation is complete. Restart the kernel. We want to force
  919. // a context switch - but there is no point if resuming the scheduler
  920. // caused a context switch already.
  921. if( !xTaskResumeAll () )
  922. {
  923. taskYIELD ();
  924. }
  925. }
  926. }
  927. </pre>
  928. * \defgroup xTaskResumeAll xTaskResumeAll
  929. * \ingroup SchedulerControl
  930. */
  931. BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION;
  932. /*-----------------------------------------------------------
  933. * TASK UTILITIES
  934. *----------------------------------------------------------*/
  935. /**
  936. * task. h
  937. * <PRE>TickType_t xTaskGetTickCount( void );</PRE>
  938. *
  939. * @return The count of ticks since vTaskStartScheduler was called.
  940. *
  941. * \defgroup xTaskGetTickCount xTaskGetTickCount
  942. * \ingroup TaskUtils
  943. */
  944. TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;
  945. /**
  946. * task. h
  947. * <PRE>TickType_t xTaskGetTickCountFromISR( void );</PRE>
  948. *
  949. * @return The count of ticks since vTaskStartScheduler was called.
  950. *
  951. * This is a version of xTaskGetTickCount() that is safe to be called from an
  952. * ISR - provided that TickType_t is the natural word size of the
  953. * microcontroller being used or interrupt nesting is either not supported or
  954. * not being used.
  955. *
  956. * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR
  957. * \ingroup TaskUtils
  958. */
  959. TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION;
  960. /**
  961. * task. h
  962. * <PRE>uint16_t uxTaskGetNumberOfTasks( void );</PRE>
  963. *
  964. * @return The number of tasks that the real time kernel is currently managing.
  965. * This includes all ready, blocked and suspended tasks. A task that
  966. * has been deleted but not yet freed by the idle task will also be
  967. * included in the count.
  968. *
  969. * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks
  970. * \ingroup TaskUtils
  971. */
  972. UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;
  973. /**
  974. * task. h
  975. * <PRE>char *pcTaskGetTaskName( TaskHandle_t xTaskToQuery );</PRE>
  976. *
  977. * @return The text (human readable) name of the task referenced by the handle
  978. * xTaskToQuery. A task can query its own name by either passing in its own
  979. * handle, or by setting xTaskToQuery to NULL. INCLUDE_pcTaskGetTaskName must be
  980. * set to 1 in FreeRTOSConfig.h for pcTaskGetTaskName() to be available.
  981. *
  982. * \defgroup pcTaskGetTaskName pcTaskGetTaskName
  983. * \ingroup TaskUtils
  984. */
  985. char *pcTaskGetTaskName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
  986. /**
  987. * task.h
  988. * <PRE>UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );</PRE>
  989. *
  990. * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for
  991. * this function to be available.
  992. *
  993. * Returns the high water mark of the stack associated with xTask. That is,
  994. * the minimum free stack space there has been (in words, so on a 32 bit machine
  995. * a value of 1 means 4 bytes) since the task started. The smaller the returned
  996. * number the closer the task has come to overflowing its stack.
  997. *
  998. * @param xTask Handle of the task associated with the stack to be checked.
  999. * Set xTask to NULL to check the stack of the calling task.
  1000. *
  1001. * @return The smallest amount of free stack space there has been (in words, so
  1002. * actual spaces on the stack rather than bytes) since the task referenced by
  1003. * xTask was created.
  1004. */
  1005. UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  1006. /* When using trace macros it is sometimes necessary to include task.h before
  1007. FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,
  1008. so the following two prototypes will cause a compilation error. This can be
  1009. fixed by simply guarding against the inclusion of these two prototypes unless
  1010. they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration
  1011. constant. */
  1012. #ifdef configUSE_APPLICATION_TASK_TAG
  1013. #if configUSE_APPLICATION_TASK_TAG == 1
  1014. /**
  1015. * task.h
  1016. * <pre>void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );</pre>
  1017. *
  1018. * Sets pxHookFunction to be the task hook function used by the task xTask.
  1019. * Passing xTask as NULL has the effect of setting the calling tasks hook
  1020. * function.
  1021. */
  1022. void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION;
  1023. /**
  1024. * task.h
  1025. * <pre>void xTaskGetApplicationTaskTag( TaskHandle_t xTask );</pre>
  1026. *
  1027. * Returns the pxHookFunction value assigned to the task xTask.
  1028. */
  1029. TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  1030. #endif /* configUSE_APPLICATION_TASK_TAG ==1 */
  1031. #endif /* ifdef configUSE_APPLICATION_TASK_TAG */
  1032. #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
  1033. /* Each task contains an array of pointers that is dimensioned by the
  1034. configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. The
  1035. kernel does not use the pointers itself, so the application writer can use
  1036. the pointers for any purpose they wish. The following two functions are
  1037. used to set and query a pointer respectively. */
  1038. void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ) PRIVILEGED_FUNCTION;
  1039. void *pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) PRIVILEGED_FUNCTION;
  1040. #endif
  1041. /**
  1042. * task.h
  1043. * <pre>BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );</pre>
  1044. *
  1045. * Calls the hook function associated with xTask. Passing xTask as NULL has
  1046. * the effect of calling the Running tasks (the calling task) hook function.
  1047. *
  1048. * pvParameter is passed to the hook function for the task to interpret as it
  1049. * wants. The return value is the value returned by the task hook function
  1050. * registered by the user.
  1051. */
  1052. BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) PRIVILEGED_FUNCTION;
  1053. /**
  1054. * xTaskGetIdleTaskHandle() is only available if
  1055. * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.
  1056. *
  1057. * Simply returns the handle of the idle task. It is not valid to call
  1058. * xTaskGetIdleTaskHandle() before the scheduler has been started.
  1059. */
  1060. TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
  1061. /**
  1062. * configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for
  1063. * uxTaskGetSystemState() to be available.
  1064. *
  1065. * uxTaskGetSystemState() populates an TaskStatus_t structure for each task in
  1066. * the system. TaskStatus_t structures contain, among other things, members
  1067. * for the task handle, task name, task priority, task state, and total amount
  1068. * of run time consumed by the task. See the TaskStatus_t structure
  1069. * definition in this file for the full member list.
  1070. *
  1071. * NOTE: This function is intended for debugging use only as its use results in
  1072. * the scheduler remaining suspended for an extended period.
  1073. *
  1074. * @param pxTaskStatusArray A pointer to an array of TaskStatus_t structures.
  1075. * The array must contain at least one TaskStatus_t structure for each task
  1076. * that is under the control of the RTOS. The number of tasks under the control
  1077. * of the RTOS can be determined using the uxTaskGetNumberOfTasks() API function.
  1078. *
  1079. * @param uxArraySize The size of the array pointed to by the pxTaskStatusArray
  1080. * parameter. The size is specified as the number of indexes in the array, or
  1081. * the number of TaskStatus_t structures contained in the array, not by the
  1082. * number of bytes in the array.
  1083. *
  1084. * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in
  1085. * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the
  1086. * total run time (as defined by the run time stats clock, see
  1087. * http://www.freertos.org/rtos-run-time-stats.html) since the target booted.
  1088. * pulTotalRunTime can be set to NULL to omit the total run time information.
  1089. *
  1090. * @return The number of TaskStatus_t structures that were populated by
  1091. * uxTaskGetSystemState(). This should equal the number returned by the
  1092. * uxTaskGetNumberOfTasks() API function, but will be zero if the value passed
  1093. * in the uxArraySize parameter was too small.
  1094. *
  1095. * Example usage:
  1096. <pre>
  1097. // This example demonstrates how a human readable table of run time stats
  1098. // information is generated from raw data provided by uxTaskGetSystemState().
  1099. // The human readable table is written to pcWriteBuffer
  1100. void vTaskGetRunTimeStats( char *pcWriteBuffer )
  1101. {
  1102. TaskStatus_t *pxTaskStatusArray;
  1103. volatile UBaseType_t uxArraySize, x;
  1104. uint32_t ulTotalRunTime, ulStatsAsPercentage;
  1105. // Make sure the write buffer does not contain a string.
  1106. *pcWriteBuffer = 0x00;
  1107. // Take a snapshot of the number of tasks in case it changes while this
  1108. // function is executing.
  1109. uxArraySize = uxTaskGetNumberOfTasks();
  1110. // Allocate a TaskStatus_t structure for each task. An array could be
  1111. // allocated statically at compile time.
  1112. pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
  1113. if( pxTaskStatusArray != NULL )
  1114. {
  1115. // Generate raw status information about each task.
  1116. uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );
  1117. // For percentage calculations.
  1118. ulTotalRunTime /= 100UL;
  1119. // Avoid divide by zero errors.
  1120. if( ulTotalRunTime > 0 )
  1121. {
  1122. // For each populated position in the pxTaskStatusArray array,
  1123. // format the raw data as human readable ASCII data
  1124. for( x = 0; x < uxArraySize; x++ )
  1125. {
  1126. // What percentage of the total run time has the task used?
  1127. // This will always be rounded down to the nearest integer.
  1128. // ulTotalRunTimeDiv100 has already been divided by 100.
  1129. ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;
  1130. if( ulStatsAsPercentage > 0UL )
  1131. {
  1132. sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
  1133. }
  1134. else
  1135. {
  1136. // If the percentage is zero here then the task has
  1137. // consumed less than 1% of the total run time.
  1138. sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );
  1139. }
  1140. pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );
  1141. }
  1142. }
  1143. // The array is no longer needed, free the memory it consumes.
  1144. vPortFree( pxTaskStatusArray );
  1145. }
  1146. }
  1147. </pre>
  1148. */
  1149. UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION;
  1150. /**
  1151. * task. h
  1152. * <PRE>void vTaskList( char *pcWriteBuffer );</PRE>
  1153. *
  1154. * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must
  1155. * both be defined as 1 for this function to be available. See the
  1156. * configuration section of the FreeRTOS.org website for more information.
  1157. *
  1158. * NOTE 1: This function will disable interrupts for its duration. It is
  1159. * not intended for normal application runtime use but as a debug aid.
  1160. *
  1161. * Lists all the current tasks, along with their current state and stack
  1162. * usage high water mark.
  1163. *
  1164. * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or
  1165. * suspended ('S').
  1166. *
  1167. * PLEASE NOTE:
  1168. *
  1169. * This function is provided for convenience only, and is used by many of the
  1170. * demo applications. Do not consider it to be part of the scheduler.
  1171. *
  1172. * vTaskList() calls uxTaskGetSystemState(), then formats part of the
  1173. * uxTaskGetSystemState() output into a human readable table that displays task
  1174. * names, states and stack usage.
  1175. *
  1176. * vTaskList() has a dependency on the sprintf() C library function that might
  1177. * bloat the code size, use a lot of stack, and provide different results on
  1178. * different platforms. An alternative, tiny, third party, and limited
  1179. * functionality implementation of sprintf() is provided in many of the
  1180. * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
  1181. * printf-stdarg.c does not provide a full snprintf() implementation!).
  1182. *
  1183. * It is recommended that production systems call uxTaskGetSystemState()
  1184. * directly to get access to raw stats data, rather than indirectly through a
  1185. * call to vTaskList().
  1186. *
  1187. * @param pcWriteBuffer A buffer into which the above mentioned details
  1188. * will be written, in ASCII form. This buffer is assumed to be large
  1189. * enough to contain the generated report. Approximately 40 bytes per
  1190. * task should be sufficient.
  1191. *
  1192. * \defgroup vTaskList vTaskList
  1193. * \ingroup TaskUtils
  1194. */
  1195. void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
  1196. /**
  1197. * task. h
  1198. * <PRE>void vTaskGetRunTimeStats( char *pcWriteBuffer );</PRE>
  1199. *
  1200. * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
  1201. * must both be defined as 1 for this function to be available. The application
  1202. * must also then provide definitions for
  1203. * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
  1204. * to configure a peripheral timer/counter and return the timers current count
  1205. * value respectively. The counter should be at least 10 times the frequency of
  1206. * the tick count.
  1207. *
  1208. * NOTE 1: This function will disable interrupts for its duration. It is
  1209. * not intended for normal application runtime use but as a debug aid.
  1210. *
  1211. * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
  1212. * accumulated execution time being stored for each task. The resolution
  1213. * of the accumulated time value depends on the frequency of the timer
  1214. * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
  1215. * Calling vTaskGetRunTimeStats() writes the total execution time of each
  1216. * task into a buffer, both as an absolute count value and as a percentage
  1217. * of the total system execution time.
  1218. *
  1219. * NOTE 2:
  1220. *
  1221. * This function is provided for convenience only, and is used by many of the
  1222. * demo applications. Do not consider it to be part of the scheduler.
  1223. *
  1224. * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the
  1225. * uxTaskGetSystemState() output into a human readable table that displays the
  1226. * amount of time each task has spent in the Running state in both absolute and
  1227. * percentage terms.
  1228. *
  1229. * vTaskGetRunTimeStats() has a dependency on the sprintf() C library function
  1230. * that might bloat the code size, use a lot of stack, and provide different
  1231. * results on different platforms. An alternative, tiny, third party, and
  1232. * limited functionality implementation of sprintf() is provided in many of the
  1233. * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
  1234. * printf-stdarg.c does not provide a full snprintf() implementation!).
  1235. *
  1236. * It is recommended that production systems call uxTaskGetSystemState() directly
  1237. * to get access to raw stats data, rather than indirectly through a call to
  1238. * vTaskGetRunTimeStats().
  1239. *
  1240. * @param pcWriteBuffer A buffer into which the execution times will be
  1241. * written, in ASCII form. This buffer is assumed to be large enough to
  1242. * contain the generated report. Approximately 40 bytes per task should
  1243. * be sufficient.
  1244. *
  1245. * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats
  1246. * \ingroup TaskUtils
  1247. */
  1248. void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
  1249. /**
  1250. * task. h
  1251. * <PRE>BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );</PRE>
  1252. *
  1253. * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
  1254. * function to be available.
  1255. *
  1256. * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
  1257. * "notification value", which is a 32-bit unsigned integer (uint32_t).
  1258. *
  1259. * Events can be sent to a task using an intermediary object. Examples of such
  1260. * objects are queues, semaphores, mutexes and event groups. Task notifications
  1261. * are a method of sending an event directly to a task without the need for such
  1262. * an intermediary object.
  1263. *
  1264. * A notification sent to a task can optionally perform an action, such as
  1265. * update, overwrite or increment the task's notification value. In that way
  1266. * task notifications can be used to send data to a task, or be used as light
  1267. * weight and fast binary or counting semaphores.
  1268. *
  1269. * A notification sent to a task will remain pending until it is cleared by the
  1270. * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was
  1271. * already in the Blocked state to wait for a notification when the notification
  1272. * arrives then the task will automatically be removed from the Blocked state
  1273. * (unblocked) and the notification cleared.
  1274. *
  1275. * A task can use xTaskNotifyWait() to [optionally] block to wait for a
  1276. * notification to be pending, or ulTaskNotifyTake() to [optionally] block
  1277. * to wait for its notification value to have a non-zero value. The task does
  1278. * not consume any CPU time while it is in the Blocked state.
  1279. *
  1280. * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.
  1281. *
  1282. * @param xTaskToNotify The handle of the task being notified. The handle to a
  1283. * task can be returned from the xTaskCreate() API function used to create the
  1284. * task, and the handle of the currently running task can be obtained by calling
  1285. * xTaskGetCurrentTaskHandle().
  1286. *
  1287. * @param ulValue Data that can be sent with the notification. How the data is
  1288. * used depends on the value of the eAction parameter.
  1289. *
  1290. * @param eAction Specifies how the notification updates the task's notification
  1291. * value, if at all. Valid values for eAction are as follows:
  1292. *
  1293. * eSetBits -
  1294. * The task's notification value is bitwise ORed with ulValue. xTaskNofify()
  1295. * always returns pdPASS in this case.
  1296. *
  1297. * eIncrement -
  1298. * The task's notification value is incremented. ulValue is not used and
  1299. * xTaskNotify() always returns pdPASS in this case.
  1300. *
  1301. * eSetValueWithOverwrite -
  1302. * The task's notification value is set to the value of ulValue, even if the
  1303. * task being notified had not yet processed the previous notification (the
  1304. * task already had a notification pending). xTaskNotify() always returns
  1305. * pdPASS in this case.
  1306. *
  1307. * eSetValueWithoutOverwrite -
  1308. * If the task being notified did not already have a notification pending then
  1309. * the task's notification value is set to ulValue and xTaskNotify() will
  1310. * return pdPASS. If the task being notified already had a notification
  1311. * pending then no action is performed and pdFAIL is returned.
  1312. *
  1313. * eNoAction -
  1314. * The task receives a notification without its notification value being
  1315. * updated. ulValue is not used and xTaskNotify() always returns pdPASS in
  1316. * this case.
  1317. *
  1318. * pulPreviousNotificationValue -
  1319. * Can be used to pass out the subject task's notification value before any
  1320. * bits are modified by the notify function.
  1321. *
  1322. * @return Dependent on the value of eAction. See the description of the
  1323. * eAction parameter.
  1324. *
  1325. * \defgroup xTaskNotify xTaskNotify
  1326. * \ingroup TaskNotifications
  1327. */
  1328. BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) PRIVILEGED_FUNCTION;
  1329. #define xTaskNotify( xTaskToNotify, ulValue, eAction ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL )
  1330. #define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
  1331. /**
  1332. * task. h
  1333. * <PRE>BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );</PRE>
  1334. *
  1335. * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
  1336. * function to be available.
  1337. *
  1338. * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
  1339. * "notification value", which is a 32-bit unsigned integer (uint32_t).
  1340. *
  1341. * A version of xTaskNotify() that can be used from an interrupt service routine
  1342. * (ISR).
  1343. *
  1344. * Events can be sent to a task using an intermediary object. Examples of such
  1345. * objects are queues, semaphores, mutexes and event groups. Task notifications
  1346. * are a method of sending an event directly to a task without the need for such
  1347. * an intermediary object.
  1348. *
  1349. * A notification sent to a task can optionally perform an action, such as
  1350. * update, overwrite or increment the task's notification value. In that way
  1351. * task notifications can be used to send data to a task, or be used as light
  1352. * weight and fast binary or counting semaphores.
  1353. *
  1354. * A notification sent to a task will remain pending until it is cleared by the
  1355. * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was
  1356. * already in the Blocked state to wait for a notification when the notification
  1357. * arrives then the task will automatically be removed from the Blocked state
  1358. * (unblocked) and the notification cleared.
  1359. *
  1360. * A task can use xTaskNotifyWait() to [optionally] block to wait for a
  1361. * notification to be pending, or ulTaskNotifyTake() to [optionally] block
  1362. * to wait for its notification value to have a non-zero value. The task does
  1363. * not consume any CPU time while it is in the Blocked state.
  1364. *
  1365. * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.
  1366. *
  1367. * @param xTaskToNotify The handle of the task being notified. The handle to a
  1368. * task can be returned from the xTaskCreate() API function used to create the
  1369. * task, and the handle of the currently running task can be obtained by calling
  1370. * xTaskGetCurrentTaskHandle().
  1371. *
  1372. * @param ulValue Data that can be sent with the notification. How the data is
  1373. * used depends on the value of the eAction parameter.
  1374. *
  1375. * @param eAction Specifies how the notification updates the task's notification
  1376. * value, if at all. Valid values for eAction are as follows:
  1377. *
  1378. * eSetBits -
  1379. * The task's notification value is bitwise ORed with ulValue. xTaskNofify()
  1380. * always returns pdPASS in this case.
  1381. *
  1382. * eIncrement -
  1383. * The task's notification value is incremented. ulValue is not used and
  1384. * xTaskNotify() always returns pdPASS in this case.
  1385. *
  1386. * eSetValueWithOverwrite -
  1387. * The task's notification value is set to the value of ulValue, even if the
  1388. * task being notified had not yet processed the previous notification (the
  1389. * task already had a notification pending). xTaskNotify() always returns
  1390. * pdPASS in this case.
  1391. *
  1392. * eSetValueWithoutOverwrite -
  1393. * If the task being notified did not already have a notification pending then
  1394. * the task's notification value is set to ulValue and xTaskNotify() will
  1395. * return pdPASS. If the task being notified already had a notification
  1396. * pending then no action is performed and pdFAIL is returned.
  1397. *
  1398. * eNoAction -
  1399. * The task receives a notification without its notification value being
  1400. * updated. ulValue is not used and xTaskNotify() always returns pdPASS in
  1401. * this case.
  1402. *
  1403. * @param pxHigherPriorityTaskWoken xTaskNotifyFromISR() will set
  1404. * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
  1405. * task to which the notification was sent to leave the Blocked state, and the
  1406. * unblocked task has a priority higher than the currently running task. If
  1407. * xTaskNotifyFromISR() sets this value to pdTRUE then a context switch should
  1408. * be requested before the interrupt is exited. How a context switch is
  1409. * requested from an ISR is dependent on the port - see the documentation page
  1410. * for the port in use.
  1411. *
  1412. * @return Dependent on the value of eAction. See the description of the
  1413. * eAction parameter.
  1414. *
  1415. * \defgroup xTaskNotify xTaskNotify
  1416. * \ingroup TaskNotifications
  1417. */
  1418. BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
  1419. #define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
  1420. #define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
  1421. /**
  1422. * task. h
  1423. * <PRE>BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );</pre>
  1424. *
  1425. * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
  1426. * function to be available.
  1427. *
  1428. * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
  1429. * "notification value", which is a 32-bit unsigned integer (uint32_t).
  1430. *
  1431. * Events can be sent to a task using an intermediary object. Examples of such
  1432. * objects are queues, semaphores, mutexes and event groups. Task notifications
  1433. * are a method of sending an event directly to a task without the need for such
  1434. * an intermediary object.
  1435. *
  1436. * A notification sent to a task can optionally perform an action, such as
  1437. * update, overwrite or increment the task's notification value. In that way
  1438. * task notifications can be used to send data to a task, or be used as light
  1439. * weight and fast binary or counting semaphores.
  1440. *
  1441. * A notification sent to a task will remain pending until it is cleared by the
  1442. * task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was
  1443. * already in the Blocked state to wait for a notification when the notification
  1444. * arrives then the task will automatically be removed from the Blocked state
  1445. * (unblocked) and the notification cleared.
  1446. *
  1447. * A task can use xTaskNotifyWait() to [optionally] block to wait for a
  1448. * notification to be pending, or ulTaskNotifyTake() to [optionally] block
  1449. * to wait for its notification value to have a non-zero value. The task does
  1450. * not consume any CPU time while it is in the Blocked state.
  1451. *
  1452. * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.
  1453. *
  1454. * @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value
  1455. * will be cleared in the calling task's notification value before the task
  1456. * checks to see if any notifications are pending, and optionally blocks if no
  1457. * notifications are pending. Setting ulBitsToClearOnEntry to ULONG_MAX (if
  1458. * limits.h is included) or 0xffffffffUL (if limits.h is not included) will have
  1459. * the effect of resetting the task's notification value to 0. Setting
  1460. * ulBitsToClearOnEntry to 0 will leave the task's notification value unchanged.
  1461. *
  1462. * @param ulBitsToClearOnExit If a notification is pending or received before
  1463. * the calling task exits the xTaskNotifyWait() function then the task's
  1464. * notification value (see the xTaskNotify() API function) is passed out using
  1465. * the pulNotificationValue parameter. Then any bits that are set in
  1466. * ulBitsToClearOnExit will be cleared in the task's notification value (note
  1467. * *pulNotificationValue is set before any bits are cleared). Setting
  1468. * ulBitsToClearOnExit to ULONG_MAX (if limits.h is included) or 0xffffffffUL
  1469. * (if limits.h is not included) will have the effect of resetting the task's
  1470. * notification value to 0 before the function exits. Setting
  1471. * ulBitsToClearOnExit to 0 will leave the task's notification value unchanged
  1472. * when the function exits (in which case the value passed out in
  1473. * pulNotificationValue will match the task's notification value).
  1474. *
  1475. * @param pulNotificationValue Used to pass the task's notification value out
  1476. * of the function. Note the value passed out will not be effected by the
  1477. * clearing of any bits caused by ulBitsToClearOnExit being non-zero.
  1478. *
  1479. * @param xTicksToWait The maximum amount of time that the task should wait in
  1480. * the Blocked state for a notification to be received, should a notification
  1481. * not already be pending when xTaskNotifyWait() was called. The task
  1482. * will not consume any processing time while it is in the Blocked state. This
  1483. * is specified in kernel ticks, the macro pdMS_TO_TICSK( value_in_ms ) can be
  1484. * used to convert a time specified in milliseconds to a time specified in
  1485. * ticks.
  1486. *
  1487. * @return If a notification was received (including notifications that were
  1488. * already pending when xTaskNotifyWait was called) then pdPASS is
  1489. * returned. Otherwise pdFAIL is returned.
  1490. *
  1491. * \defgroup xTaskNotifyWait xTaskNotifyWait
  1492. * \ingroup TaskNotifications
  1493. */
  1494. BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
  1495. /**
  1496. * task. h
  1497. * <PRE>BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );</PRE>
  1498. *
  1499. * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro
  1500. * to be available.
  1501. *
  1502. * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
  1503. * "notification value", which is a 32-bit unsigned integer (uint32_t).
  1504. *
  1505. * Events can be sent to a task using an intermediary object. Examples of such
  1506. * objects are queues, semaphores, mutexes and event groups. Task notifications
  1507. * are a method of sending an event directly to a task without the need for such
  1508. * an intermediary object.
  1509. *
  1510. * A notification sent to a task can optionally perform an action, such as
  1511. * update, overwrite or increment the task's notification value. In that way
  1512. * task notifications can be used to send data to a task, or be used as light
  1513. * weight and fast binary or counting semaphores.
  1514. *
  1515. * xTaskNotifyGive() is a helper macro intended for use when task notifications
  1516. * are used as light weight and faster binary or counting semaphore equivalents.
  1517. * Actual FreeRTOS semaphores are given using the xSemaphoreGive() API function,
  1518. * the equivalent action that instead uses a task notification is
  1519. * xTaskNotifyGive().
  1520. *
  1521. * When task notifications are being used as a binary or counting semaphore
  1522. * equivalent then the task being notified should wait for the notification
  1523. * using the ulTaskNotificationTake() API function rather than the
  1524. * xTaskNotifyWait() API function.
  1525. *
  1526. * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
  1527. *
  1528. * @param xTaskToNotify The handle of the task being notified. The handle to a
  1529. * task can be returned from the xTaskCreate() API function used to create the
  1530. * task, and the handle of the currently running task can be obtained by calling
  1531. * xTaskGetCurrentTaskHandle().
  1532. *
  1533. * @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the
  1534. * eAction parameter set to eIncrement - so pdPASS is always returned.
  1535. *
  1536. * \defgroup xTaskNotifyGive xTaskNotifyGive
  1537. * \ingroup TaskNotifications
  1538. */
  1539. #define xTaskNotifyGive( xTaskToNotify ) xTaskGenericNotify( ( xTaskToNotify ), ( 0 ), eIncrement, NULL )
  1540. /**
  1541. * task. h
  1542. * <PRE>void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );
  1543. *
  1544. * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro
  1545. * to be available.
  1546. *
  1547. * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
  1548. * "notification value", which is a 32-bit unsigned integer (uint32_t).
  1549. *
  1550. * A version of xTaskNotifyGive() that can be called from an interrupt service
  1551. * routine (ISR).
  1552. *
  1553. * Events can be sent to a task using an intermediary object. Examples of such
  1554. * objects are queues, semaphores, mutexes and event groups. Task notifications
  1555. * are a method of sending an event directly to a task without the need for such
  1556. * an intermediary object.
  1557. *
  1558. * A notification sent to a task can optionally perform an action, such as
  1559. * update, overwrite or increment the task's notification value. In that way
  1560. * task notifications can be used to send data to a task, or be used as light
  1561. * weight and fast binary or counting semaphores.
  1562. *
  1563. * vTaskNotifyGiveFromISR() is intended for use when task notifications are
  1564. * used as light weight and faster binary or counting semaphore equivalents.
  1565. * Actual FreeRTOS semaphores are given from an ISR using the
  1566. * xSemaphoreGiveFromISR() API function, the equivalent action that instead uses
  1567. * a task notification is vTaskNotifyGiveFromISR().
  1568. *
  1569. * When task notifications are being used as a binary or counting semaphore
  1570. * equivalent then the task being notified should wait for the notification
  1571. * using the ulTaskNotificationTake() API function rather than the
  1572. * xTaskNotifyWait() API function.
  1573. *
  1574. * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
  1575. *
  1576. * @param xTaskToNotify The handle of the task being notified. The handle to a
  1577. * task can be returned from the xTaskCreate() API function used to create the
  1578. * task, and the handle of the currently running task can be obtained by calling
  1579. * xTaskGetCurrentTaskHandle().
  1580. *
  1581. * @param pxHigherPriorityTaskWoken vTaskNotifyGiveFromISR() will set
  1582. * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
  1583. * task to which the notification was sent to leave the Blocked state, and the
  1584. * unblocked task has a priority higher than the currently running task. If
  1585. * vTaskNotifyGiveFromISR() sets this value to pdTRUE then a context switch
  1586. * should be requested before the interrupt is exited. How a context switch is
  1587. * requested from an ISR is dependent on the port - see the documentation page
  1588. * for the port in use.
  1589. *
  1590. * \defgroup xTaskNotifyWait xTaskNotifyWait
  1591. * \ingroup TaskNotifications
  1592. */
  1593. void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
  1594. /**
  1595. * task. h
  1596. * <PRE>uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );</pre>
  1597. *
  1598. * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
  1599. * function to be available.
  1600. *
  1601. * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
  1602. * "notification value", which is a 32-bit unsigned integer (uint32_t).
  1603. *
  1604. * Events can be sent to a task using an intermediary object. Examples of such
  1605. * objects are queues, semaphores, mutexes and event groups. Task notifications
  1606. * are a method of sending an event directly to a task without the need for such
  1607. * an intermediary object.
  1608. *
  1609. * A notification sent to a task can optionally perform an action, such as
  1610. * update, overwrite or increment the task's notification value. In that way
  1611. * task notifications can be used to send data to a task, or be used as light
  1612. * weight and fast binary or counting semaphores.
  1613. *
  1614. * ulTaskNotifyTake() is intended for use when a task notification is used as a
  1615. * faster and lighter weight binary or counting semaphore alternative. Actual
  1616. * FreeRTOS semaphores are taken using the xSemaphoreTake() API function, the
  1617. * equivalent action that instead uses a task notification is
  1618. * ulTaskNotifyTake().
  1619. *
  1620. * When a task is using its notification value as a binary or counting semaphore
  1621. * other tasks should send notifications to it using the xTaskNotifyGive()
  1622. * macro, or xTaskNotify() function with the eAction parameter set to
  1623. * eIncrement.
  1624. *
  1625. * ulTaskNotifyTake() can either clear the task's notification value to
  1626. * zero on exit, in which case the notification value acts like a binary
  1627. * semaphore, or decrement the task's notification value on exit, in which case
  1628. * the notification value acts like a counting semaphore.
  1629. *
  1630. * A task can use ulTaskNotifyTake() to [optionally] block to wait for a
  1631. * the task's notification value to be non-zero. The task does not consume any
  1632. * CPU time while it is in the Blocked state.
  1633. *
  1634. * Where as xTaskNotifyWait() will return when a notification is pending,
  1635. * ulTaskNotifyTake() will return when the task's notification value is
  1636. * not zero.
  1637. *
  1638. * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.
  1639. *
  1640. * @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's
  1641. * notification value is decremented when the function exits. In this way the
  1642. * notification value acts like a counting semaphore. If xClearCountOnExit is
  1643. * not pdFALSE then the task's notification value is cleared to zero when the
  1644. * function exits. In this way the notification value acts like a binary
  1645. * semaphore.
  1646. *
  1647. * @param xTicksToWait The maximum amount of time that the task should wait in
  1648. * the Blocked state for the task's notification value to be greater than zero,
  1649. * should the count not already be greater than zero when
  1650. * ulTaskNotifyTake() was called. The task will not consume any processing
  1651. * time while it is in the Blocked state. This is specified in kernel ticks,
  1652. * the macro pdMS_TO_TICSK( value_in_ms ) can be used to convert a time
  1653. * specified in milliseconds to a time specified in ticks.
  1654. *
  1655. * @return The task's notification count before it is either cleared to zero or
  1656. * decremented (see the xClearCountOnExit parameter).
  1657. *
  1658. * \defgroup ulTaskNotifyTake ulTaskNotifyTake
  1659. * \ingroup TaskNotifications
  1660. */
  1661. uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
  1662. /**
  1663. * task. h
  1664. * <PRE>BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );</pre>
  1665. *
  1666. * If the notification state of the task referenced by the handle xTask is
  1667. * eNotified, then set the task's notification state to eNotWaitingNotification.
  1668. * The task's notification value is not altered. Set xTask to NULL to clear the
  1669. * notification state of the calling task.
  1670. *
  1671. * @return pdTRUE if the task's notification state was set to
  1672. * eNotWaitingNotification, otherwise pdFALSE.
  1673. * \defgroup xTaskNotifyStateClear xTaskNotifyStateClear
  1674. * \ingroup TaskNotifications
  1675. */
  1676. BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
  1677. /*-----------------------------------------------------------
  1678. * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
  1679. *----------------------------------------------------------*/
  1680. /*
  1681. * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
  1682. * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
  1683. * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
  1684. *
  1685. * Called from the real time kernel tick (either preemptive or cooperative),
  1686. * this increments the tick count and checks if any tasks that are blocked
  1687. * for a finite period required removing from a blocked list and placing on
  1688. * a ready list. If a non-zero value is returned then a context switch is
  1689. * required because either:
  1690. * + A task was removed from a blocked list because its timeout had expired,
  1691. * or
  1692. * + Time slicing is in use and there is a task of equal priority to the
  1693. * currently running task.
  1694. */
  1695. BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;
  1696. /*
  1697. * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
  1698. * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
  1699. *
  1700. * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
  1701. *
  1702. * Removes the calling task from the ready list and places it both
  1703. * on the list of tasks waiting for a particular event, and the
  1704. * list of delayed tasks. The task will be removed from both lists
  1705. * and replaced on the ready list should either the event occur (and
  1706. * there be no higher priority tasks waiting on the same event) or
  1707. * the delay period expires.
  1708. *
  1709. * The 'unordered' version replaces the event list item value with the
  1710. * xItemValue value, and inserts the list item at the end of the list.
  1711. *
  1712. * The 'ordered' version uses the existing event list item value (which is the
  1713. * owning tasks priority) to insert the list item into the event list is task
  1714. * priority order.
  1715. *
  1716. * @param pxEventList The list containing tasks that are blocked waiting
  1717. * for the event to occur.
  1718. *
  1719. * @param xItemValue The item value to use for the event list item when the
  1720. * event list is not ordered by task priority.
  1721. *
  1722. * @param xTicksToWait The maximum amount of time that the task should wait
  1723. * for the event to occur. This is specified in kernel ticks,the constant
  1724. * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time
  1725. * period.
  1726. */
  1727. void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
  1728. void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
  1729. /*
  1730. * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
  1731. * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
  1732. *
  1733. * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
  1734. *
  1735. * This function performs nearly the same function as vTaskPlaceOnEventList().
  1736. * The difference being that this function does not permit tasks to block
  1737. * indefinitely, whereas vTaskPlaceOnEventList() does.
  1738. *
  1739. */
  1740. void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;
  1741. /*
  1742. * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
  1743. * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
  1744. *
  1745. * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
  1746. *
  1747. * Removes a task from both the specified event list and the list of blocked
  1748. * tasks, and places it on a ready queue.
  1749. *
  1750. * xTaskRemoveFromEventList()/xTaskRemoveFromUnorderedEventList() will be called
  1751. * if either an event occurs to unblock a task, or the block timeout period
  1752. * expires.
  1753. *
  1754. * xTaskRemoveFromEventList() is used when the event list is in task priority
  1755. * order. It removes the list item from the head of the event list as that will
  1756. * have the highest priority owning task of all the tasks on the event list.
  1757. * xTaskRemoveFromUnorderedEventList() is used when the event list is not
  1758. * ordered and the event list items hold something other than the owning tasks
  1759. * priority. In this case the event list item value is updated to the value
  1760. * passed in the xItemValue parameter.
  1761. *
  1762. * @return pdTRUE if the task being removed has a higher priority than the task
  1763. * making the call, otherwise pdFALSE.
  1764. */
  1765. BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION;
  1766. BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) PRIVILEGED_FUNCTION;
  1767. /*
  1768. * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
  1769. * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
  1770. * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
  1771. *
  1772. * Sets the pointer to the current TCB to the TCB of the highest priority task
  1773. * that is ready to run.
  1774. */
  1775. void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;
  1776. /*
  1777. * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY
  1778. * THE EVENT BITS MODULE.
  1779. */
  1780. TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION;
  1781. /*
  1782. * Return the handle of the calling task.
  1783. */
  1784. TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;
  1785. /*
  1786. * Capture the current time status for future reference.
  1787. */
  1788. void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
  1789. /*
  1790. * Compare the time status now with that previously captured to see if the
  1791. * timeout has expired.
  1792. */
  1793. BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;
  1794. /*
  1795. * Shortcut used by the queue implementation to prevent unnecessary call to
  1796. * taskYIELD();
  1797. */
  1798. void vTaskMissedYield( void ) PRIVILEGED_FUNCTION;
  1799. /*
  1800. * Returns the scheduler state as taskSCHEDULER_RUNNING,
  1801. * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.
  1802. */
  1803. BaseType_t xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION;
  1804. /*
  1805. * Raises the priority of the mutex holder to that of the calling task should
  1806. * the mutex holder have a priority less than the calling task.
  1807. */
  1808. void vTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
  1809. /*
  1810. * Set the priority of a task back to its proper priority in the case that it
  1811. * inherited a higher priority while it was holding a semaphore.
  1812. */
  1813. BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
  1814. /*
  1815. * Generic version of the task creation function which is in turn called by the
  1816. * xTaskCreate() and xTaskCreateRestricted() macros.
  1817. */
  1818. BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask, StackType_t * const puxStackBuffer, const MemoryRegion_t * const xRegions ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
  1819. /*
  1820. * Get the uxTCBNumber assigned to the task referenced by the xTask parameter.
  1821. */
  1822. UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  1823. /*
  1824. * Set the uxTaskNumber of the task referenced by the xTask parameter to
  1825. * uxHandle.
  1826. */
  1827. void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION;
  1828. /*
  1829. * Only available when configUSE_TICKLESS_IDLE is set to 1.
  1830. * If tickless mode is being used, or a low power mode is implemented, then
  1831. * the tick interrupt will not execute during idle periods. When this is the
  1832. * case, the tick count value maintained by the scheduler needs to be kept up
  1833. * to date with the actual execution time by being skipped forward by a time
  1834. * equal to the idle period.
  1835. */
  1836. void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION;
  1837. /*
  1838. * Only avilable when configUSE_TICKLESS_IDLE is set to 1.
  1839. * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port
  1840. * specific sleep function to determine if it is ok to proceed with the sleep,
  1841. * and if it is ok to proceed, if it is ok to sleep indefinitely.
  1842. *
  1843. * This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only
  1844. * called with the scheduler suspended, not from within a critical section. It
  1845. * is therefore possible for an interrupt to request a context switch between
  1846. * portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being
  1847. * entered. eTaskConfirmSleepModeStatus() should be called from a short
  1848. * critical section between the timer being stopped and the sleep mode being
  1849. * entered to ensure it is ok to proceed into the sleep mode.
  1850. */
  1851. eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;
  1852. /*
  1853. * For internal use only. Increment the mutex held count when a mutex is
  1854. * taken and return the handle of the task that has taken the mutex.
  1855. */
  1856. void *pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;
  1857. #ifdef __cplusplus
  1858. }
  1859. #endif
  1860. #endif /* INC_TASK_H */