task.h 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179
  1. /*
  2. * FreeRTOS Kernel V10.4.6
  3. * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * SPDX-License-Identifier: MIT
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  8. * this software and associated documentation files (the "Software"), to deal in
  9. * the Software without restriction, including without limitation the rights to
  10. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  11. * the Software, and to permit persons to whom the Software is furnished to do so,
  12. * subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in all
  15. * copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  19. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  20. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  21. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * https://www.FreeRTOS.org
  25. * https://github.com/FreeRTOS
  26. *
  27. */
  28. #ifndef INC_TASK_H
  29. #define INC_TASK_H
  30. #ifndef INC_FREERTOS_H
  31. #error "include FreeRTOS.h must appear in source files before include task.h"
  32. #endif
  33. /* *INDENT-OFF* */
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. /* *INDENT-ON* */
  38. /*-----------------------------------------------------------
  39. * MACROS AND DEFINITIONS
  40. *----------------------------------------------------------*/
  41. /*
  42. * If tskKERNEL_VERSION_NUMBER ends with + it represents the version in development
  43. * after the numbered release.
  44. *
  45. * The tskKERNEL_VERSION_MAJOR, tskKERNEL_VERSION_MINOR, tskKERNEL_VERSION_BUILD
  46. * values will reflect the last released version number.
  47. */
  48. #define tskKERNEL_VERSION_NUMBER "V10.4.6"
  49. #define tskKERNEL_VERSION_MAJOR 10
  50. #define tskKERNEL_VERSION_MINOR 4
  51. #define tskKERNEL_VERSION_BUILD 6
  52. /**
  53. * task. h
  54. *
  55. * Type by which tasks are referenced. For example, a call to xTaskCreate
  56. * returns (via a pointer parameter) an TaskHandle_t variable that can then
  57. * be used as a parameter to vTaskDelete to delete the task.
  58. *
  59. * \defgroup TaskHandle_t TaskHandle_t
  60. * \ingroup Tasks
  61. */
  62. struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */
  63. typedef struct tskTaskControlBlock * TaskHandle_t;
  64. /*
  65. * Defines the prototype to which the application task hook function must
  66. * conform.
  67. */
  68. typedef BaseType_t (* TaskHookFunction_t)( void * );
  69. /* Task states returned by eTaskGetState. */
  70. typedef enum
  71. {
  72. eRunning = 0, /* A task is querying the state of itself, so must be running. */
  73. eReady, /* The task being queried is in a ready or pending ready list. */
  74. eBlocked, /* The task being queried is in the Blocked state. */
  75. eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */
  76. eDeleted, /* The task being queried has been deleted, but its TCB has not yet been freed. */
  77. eInvalid /* Used as an 'invalid state' value. */
  78. } eTaskState;
  79. /**
  80. * task. h
  81. *
  82. * Macro for forcing a context switch.
  83. *
  84. * \defgroup taskYIELD taskYIELD
  85. * \ingroup SchedulerControl
  86. */
  87. #define taskYIELD() portYIELD()
  88. /**
  89. * task. h
  90. *
  91. * Macro to mark the start of a critical code region. Preemptive context
  92. * switches cannot occur when in a critical region.
  93. *
  94. * NOTE: This may alter the stack (depending on the portable implementation)
  95. * so must be used with care!
  96. *
  97. * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL
  98. * \ingroup SchedulerControl
  99. */
  100. #define taskENTER_CRITICAL() portENTER_CRITICAL()
  101. #define taskENTER_CRITICAL_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()
  102. /**
  103. * task. h
  104. *
  105. * Macro to mark the end of a critical code region. Preemptive context
  106. * switches cannot occur when in a critical region.
  107. *
  108. * NOTE: This may alter the stack (depending on the portable implementation)
  109. * so must be used with care!
  110. *
  111. * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL
  112. * \ingroup SchedulerControl
  113. */
  114. #define taskEXIT_CRITICAL() portEXIT_CRITICAL()
  115. #define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x )
  116. /**
  117. * task. h
  118. *
  119. * Macro to disable all maskable interrupts.
  120. *
  121. * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS
  122. * \ingroup SchedulerControl
  123. */
  124. #define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS()
  125. /**
  126. * task. h
  127. *
  128. * Macro to enable microcontroller interrupts.
  129. *
  130. * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS
  131. * \ingroup SchedulerControl
  132. */
  133. #define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS()
  134. /*-----------------------------------------------------------
  135. * TASK CREATION API
  136. *----------------------------------------------------------*/
  137. /**
  138. * task. h
  139. * @code{c}
  140. * BaseType_t xTaskCreate(
  141. * TaskFunction_t pxTaskCode,
  142. * const char *pcName,
  143. * configSTACK_DEPTH_TYPE usStackDepth,
  144. * void *pvParameters,
  145. * UBaseType_t uxPriority,
  146. * TaskHandle_t *pxCreatedTask
  147. * );
  148. * @endcode
  149. *
  150. * Create a new task and add it to the list of tasks that are ready to run.
  151. *
  152. * Internally, within the FreeRTOS implementation, tasks use two blocks of
  153. * memory. The first block is used to hold the task's data structures. The
  154. * second block is used by the task as its stack. If a task is created using
  155. * xTaskCreate() then both blocks of memory are automatically dynamically
  156. * allocated inside the xTaskCreate() function. (see
  157. * https://www.FreeRTOS.org/a00111.html). If a task is created using
  158. * xTaskCreateStatic() then the application writer must provide the required
  159. * memory. xTaskCreateStatic() therefore allows a task to be created without
  160. * using any dynamic memory allocation.
  161. *
  162. * See xTaskCreateStatic() for a version that does not use any dynamic memory
  163. * allocation.
  164. *
  165. * xTaskCreate() can only be used to create a task that has unrestricted
  166. * access to the entire microcontroller memory map. Systems that include MPU
  167. * support can alternatively create an MPU constrained task using
  168. * xTaskCreateRestricted().
  169. *
  170. * @param pxTaskCode Pointer to the task entry function. Tasks
  171. * must be implemented to never return (i.e. continuous loop).
  172. *
  173. * @param pcName A descriptive name for the task. This is mainly used to
  174. * facilitate debugging. Max length defined by configMAX_TASK_NAME_LEN - default
  175. * is 16.
  176. *
  177. * @param usStackDepth The size of the task stack specified as the number of
  178. * variables the stack can hold - not the number of bytes. For example, if
  179. * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes
  180. * will be allocated for stack storage.
  181. *
  182. * @param pvParameters Pointer that will be used as the parameter for the task
  183. * being created.
  184. *
  185. * @param uxPriority The priority at which the task should run. Systems that
  186. * include MPU support can optionally create tasks in a privileged (system)
  187. * mode by setting bit portPRIVILEGE_BIT of the priority parameter. For
  188. * example, to create a privileged task at priority 2 the uxPriority parameter
  189. * should be set to ( 2 | portPRIVILEGE_BIT ).
  190. *
  191. * @param pxCreatedTask Used to pass back a handle by which the created task
  192. * can be referenced.
  193. *
  194. * @return pdPASS if the task was successfully created and added to a ready
  195. * list, otherwise an error code defined in the file projdefs.h
  196. *
  197. * Example usage:
  198. * @code{c}
  199. * // Task to be created.
  200. * void vTaskCode( void * pvParameters )
  201. * {
  202. * for( ;; )
  203. * {
  204. * // Task code goes here.
  205. * }
  206. * }
  207. *
  208. * // Function that creates a task.
  209. * void vOtherFunction( void )
  210. * {
  211. * static uint8_t ucParameterToPass;
  212. * TaskHandle_t xHandle = NULL;
  213. *
  214. * // Create the task, storing the handle. Note that the passed parameter ucParameterToPass
  215. * // must exist for the lifetime of the task, so in this case is declared static. If it was just an
  216. * // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time
  217. * // the new task attempts to access it.
  218. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
  219. * configASSERT( xHandle );
  220. *
  221. * // Use the handle to delete the task.
  222. * if( xHandle != NULL )
  223. * {
  224. * vTaskDelete( xHandle );
  225. * }
  226. * }
  227. * @endcode
  228. * \defgroup xTaskCreate xTaskCreate
  229. * \ingroup Tasks
  230. */
  231. #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  232. BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
  233. const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
  234. const configSTACK_DEPTH_TYPE usStackDepth,
  235. void * const pvParameters,
  236. UBaseType_t uxPriority,
  237. TaskHandle_t * const pxCreatedTask );
  238. #endif
  239. /**
  240. * task. h
  241. * @code{c}
  242. * TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
  243. * const char *pcName,
  244. * uint32_t ulStackDepth,
  245. * void *pvParameters,
  246. * UBaseType_t uxPriority,
  247. * StackType_t *puxStackBuffer,
  248. * StaticTask_t *pxTaskBuffer );
  249. * @endcode
  250. *
  251. * Create a new task and add it to the list of tasks that are ready to run.
  252. *
  253. * Internally, within the FreeRTOS implementation, tasks use two blocks of
  254. * memory. The first block is used to hold the task's data structures. The
  255. * second block is used by the task as its stack. If a task is created using
  256. * xTaskCreate() then both blocks of memory are automatically dynamically
  257. * allocated inside the xTaskCreate() function. (see
  258. * https://www.FreeRTOS.org/a00111.html). If a task is created using
  259. * xTaskCreateStatic() then the application writer must provide the required
  260. * memory. xTaskCreateStatic() therefore allows a task to be created without
  261. * using any dynamic memory allocation.
  262. *
  263. * @param pxTaskCode Pointer to the task entry function. Tasks
  264. * must be implemented to never return (i.e. continuous loop).
  265. *
  266. * @param pcName A descriptive name for the task. This is mainly used to
  267. * facilitate debugging. The maximum length of the string is defined by
  268. * configMAX_TASK_NAME_LEN in FreeRTOSConfig.h.
  269. *
  270. * @param ulStackDepth The size of the task stack specified as the number of
  271. * variables the stack can hold - not the number of bytes. For example, if
  272. * the stack is 32-bits wide and ulStackDepth is defined as 100 then 400 bytes
  273. * will be allocated for stack storage.
  274. *
  275. * @param pvParameters Pointer that will be used as the parameter for the task
  276. * being created.
  277. *
  278. * @param uxPriority The priority at which the task will run.
  279. *
  280. * @param puxStackBuffer Must point to a StackType_t array that has at least
  281. * ulStackDepth indexes - the array will then be used as the task's stack,
  282. * removing the need for the stack to be allocated dynamically.
  283. *
  284. * @param pxTaskBuffer Must point to a variable of type StaticTask_t, which will
  285. * then be used to hold the task's data structures, removing the need for the
  286. * memory to be allocated dynamically.
  287. *
  288. * @return If neither puxStackBuffer nor pxTaskBuffer are NULL, then the task
  289. * will be created and a handle to the created task is returned. If either
  290. * puxStackBuffer or pxTaskBuffer are NULL then the task will not be created and
  291. * NULL is returned.
  292. *
  293. * Example usage:
  294. * @code{c}
  295. *
  296. * // Dimensions of the buffer that the task being created will use as its stack.
  297. * // NOTE: This is the number of words the stack will hold, not the number of
  298. * // bytes. For example, if each stack item is 32-bits, and this is set to 100,
  299. * // then 400 bytes (100 * 32-bits) will be allocated.
  300. #define STACK_SIZE 200
  301. *
  302. * // Structure that will hold the TCB of the task being created.
  303. * StaticTask_t xTaskBuffer;
  304. *
  305. * // Buffer that the task being created will use as its stack. Note this is
  306. * // an array of StackType_t variables. The size of StackType_t is dependent on
  307. * // the RTOS port.
  308. * StackType_t xStack[ STACK_SIZE ];
  309. *
  310. * // Function that implements the task being created.
  311. * void vTaskCode( void * pvParameters )
  312. * {
  313. * // The parameter value is expected to be 1 as 1 is passed in the
  314. * // pvParameters value in the call to xTaskCreateStatic().
  315. * configASSERT( ( uint32_t ) pvParameters == 1UL );
  316. *
  317. * for( ;; )
  318. * {
  319. * // Task code goes here.
  320. * }
  321. * }
  322. *
  323. * // Function that creates a task.
  324. * void vOtherFunction( void )
  325. * {
  326. * TaskHandle_t xHandle = NULL;
  327. *
  328. * // Create the task without using any dynamic memory allocation.
  329. * xHandle = xTaskCreateStatic(
  330. * vTaskCode, // Function that implements the task.
  331. * "NAME", // Text name for the task.
  332. * STACK_SIZE, // Stack size in words, not bytes.
  333. * ( void * ) 1, // Parameter passed into the task.
  334. * tskIDLE_PRIORITY,// Priority at which the task is created.
  335. * xStack, // Array to use as the task's stack.
  336. * &xTaskBuffer ); // Variable to hold the task's data structure.
  337. *
  338. * // puxStackBuffer and pxTaskBuffer were not NULL, so the task will have
  339. * // been created, and xHandle will be the task's handle. Use the handle
  340. * // to suspend the task.
  341. * vTaskSuspend( xHandle );
  342. * }
  343. * @endcode
  344. * \defgroup xTaskCreateStatic xTaskCreateStatic
  345. * \ingroup Tasks
  346. */
  347. #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
  348. TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
  349. const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
  350. const uint32_t ulStackDepth,
  351. void * const pvParameters,
  352. UBaseType_t uxPriority,
  353. StackType_t * const puxStackBuffer,
  354. StaticTask_t * const pxTaskBuffer );
  355. #endif /* configSUPPORT_STATIC_ALLOCATION */
  356. /**
  357. * task. h
  358. * @code{c}
  359. * void vTaskDelete( TaskHandle_t xTaskToDelete );
  360. * @endcode
  361. *
  362. * INCLUDE_vTaskDelete must be defined as 1 for this function to be available.
  363. * See the configuration section for more information.
  364. *
  365. * Remove a task from the RTOS real time kernel's management. The task being
  366. * deleted will be removed from all ready, blocked, suspended and event lists.
  367. *
  368. * NOTE: The idle task is responsible for freeing the kernel allocated
  369. * memory from tasks that have been deleted. It is therefore important that
  370. * the idle task is not starved of microcontroller processing time if your
  371. * application makes any calls to vTaskDelete (). Memory allocated by the
  372. * task code is not automatically freed, and should be freed before the task
  373. * is deleted.
  374. *
  375. * See the demo application file death.c for sample code that utilises
  376. * vTaskDelete ().
  377. *
  378. * @param xTaskToDelete The handle of the task to be deleted. Passing NULL will
  379. * cause the calling task to be deleted.
  380. *
  381. * Example usage:
  382. * @code{c}
  383. * void vOtherFunction( void )
  384. * {
  385. * TaskHandle_t xHandle;
  386. *
  387. * // Create the task, storing the handle.
  388. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  389. *
  390. * // Use the handle to delete the task.
  391. * vTaskDelete( xHandle );
  392. * }
  393. * @endcode
  394. * \defgroup vTaskDelete vTaskDelete
  395. * \ingroup Tasks
  396. */
  397. void vTaskDelete( TaskHandle_t xTaskToDelete );
  398. /*-----------------------------------------------------------
  399. * TASK CONTROL API
  400. *----------------------------------------------------------*/
  401. /**
  402. * task. h
  403. * @code{c}
  404. * void vTaskDelay( const TickType_t xTicksToDelay );
  405. * @endcode
  406. *
  407. * Delay a task for a given number of ticks. The actual time that the
  408. * task remains blocked depends on the tick rate. The constant
  409. * portTICK_PERIOD_MS can be used to calculate real time from the tick
  410. * rate - with the resolution of one tick period.
  411. *
  412. * INCLUDE_vTaskDelay must be defined as 1 for this function to be available.
  413. * See the configuration section for more information.
  414. *
  415. *
  416. * vTaskDelay() specifies a time at which the task wishes to unblock relative to
  417. * the time at which vTaskDelay() is called. For example, specifying a block
  418. * period of 100 ticks will cause the task to unblock 100 ticks after
  419. * vTaskDelay() is called. vTaskDelay() does not therefore provide a good method
  420. * of controlling the frequency of a periodic task as the path taken through the
  421. * code, as well as other task and interrupt activity, will affect the frequency
  422. * at which vTaskDelay() gets called and therefore the time at which the task
  423. * next executes. See xTaskDelayUntil() for an alternative API function designed
  424. * to facilitate fixed frequency execution. It does this by specifying an
  425. * absolute time (rather than a relative time) at which the calling task should
  426. * unblock.
  427. *
  428. * @param xTicksToDelay The amount of time, in tick periods, that
  429. * the calling task should block.
  430. *
  431. * Example usage:
  432. *
  433. * void vTaskFunction( void * pvParameters )
  434. * {
  435. * // Block for 500ms.
  436. * const TickType_t xDelay = 500 / portTICK_PERIOD_MS;
  437. *
  438. * for( ;; )
  439. * {
  440. * // Simply toggle the LED every 500ms, blocking between each toggle.
  441. * vToggleLED();
  442. * vTaskDelay( xDelay );
  443. * }
  444. * }
  445. *
  446. * \defgroup vTaskDelay vTaskDelay
  447. * \ingroup TaskCtrl
  448. */
  449. void vTaskDelay( const TickType_t xTicksToDelay );
  450. /**
  451. * task. h
  452. * @code{c}
  453. * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
  454. * @endcode
  455. *
  456. * INCLUDE_xTaskDelayUntil must be defined as 1 for this function to be available.
  457. * See the configuration section for more information.
  458. *
  459. * Delay a task until a specified time. This function can be used by periodic
  460. * tasks to ensure a constant execution frequency.
  461. *
  462. * This function differs from vTaskDelay () in one important aspect: vTaskDelay () will
  463. * cause a task to block for the specified number of ticks from the time vTaskDelay () is
  464. * called. It is therefore difficult to use vTaskDelay () by itself to generate a fixed
  465. * execution frequency as the time between a task starting to execute and that task
  466. * calling vTaskDelay () may not be fixed [the task may take a different path though the
  467. * code between calls, or may get interrupted or preempted a different number of times
  468. * each time it executes].
  469. *
  470. * Whereas vTaskDelay () specifies a wake time relative to the time at which the function
  471. * is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to
  472. * unblock.
  473. *
  474. * The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a
  475. * time specified in milliseconds with a resolution of one tick period.
  476. *
  477. * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the
  478. * task was last unblocked. The variable must be initialised with the current time
  479. * prior to its first use (see the example below). Following this the variable is
  480. * automatically updated within xTaskDelayUntil ().
  481. *
  482. * @param xTimeIncrement The cycle time period. The task will be unblocked at
  483. * time *pxPreviousWakeTime + xTimeIncrement. Calling xTaskDelayUntil with the
  484. * same xTimeIncrement parameter value will cause the task to execute with
  485. * a fixed interface period.
  486. *
  487. * @return Value which can be used to check whether the task was actually delayed.
  488. * Will be pdTRUE if the task way delayed and pdFALSE otherwise. A task will not
  489. * be delayed if the next expected wake time is in the past.
  490. *
  491. * Example usage:
  492. * @code{c}
  493. * // Perform an action every 10 ticks.
  494. * void vTaskFunction( void * pvParameters )
  495. * {
  496. * TickType_t xLastWakeTime;
  497. * const TickType_t xFrequency = 10;
  498. * BaseType_t xWasDelayed;
  499. *
  500. * // Initialise the xLastWakeTime variable with the current time.
  501. * xLastWakeTime = xTaskGetTickCount ();
  502. * for( ;; )
  503. * {
  504. * // Wait for the next cycle.
  505. * xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency );
  506. *
  507. * // Perform action here. xWasDelayed value can be used to determine
  508. * // whether a deadline was missed if the code here took too long.
  509. * }
  510. * }
  511. * @endcode
  512. * \defgroup xTaskDelayUntil xTaskDelayUntil
  513. * \ingroup TaskCtrl
  514. */
  515. BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
  516. const TickType_t xTimeIncrement );
  517. /*
  518. * vTaskDelayUntil() is the older version of xTaskDelayUntil() and does not
  519. * return a value.
  520. */
  521. #define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ) \
  522. { \
  523. ( void ) xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); \
  524. }
  525. /**
  526. * task. h
  527. * @code{c}
  528. * BaseType_t xTaskAbortDelay( TaskHandle_t xTask );
  529. * @endcode
  530. *
  531. * INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this
  532. * function to be available.
  533. *
  534. * A task will enter the Blocked state when it is waiting for an event. The
  535. * event it is waiting for can be a temporal event (waiting for a time), such
  536. * as when vTaskDelay() is called, or an event on an object, such as when
  537. * xQueueReceive() or ulTaskNotifyTake() is called. If the handle of a task
  538. * that is in the Blocked state is used in a call to xTaskAbortDelay() then the
  539. * task will leave the Blocked state, and return from whichever function call
  540. * placed the task into the Blocked state.
  541. *
  542. * There is no 'FromISR' version of this function as an interrupt would need to
  543. * know which object a task was blocked on in order to know which actions to
  544. * take. For example, if the task was blocked on a queue the interrupt handler
  545. * would then need to know if the queue was locked.
  546. *
  547. * @param xTask The handle of the task to remove from the Blocked state.
  548. *
  549. * @return If the task referenced by xTask was not in the Blocked state then
  550. * pdFAIL is returned. Otherwise pdPASS is returned.
  551. *
  552. * \defgroup xTaskAbortDelay xTaskAbortDelay
  553. * \ingroup TaskCtrl
  554. */
  555. BaseType_t xTaskAbortDelay( TaskHandle_t xTask );
  556. /**
  557. * task. h
  558. * @code{c}
  559. * UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask );
  560. * @endcode
  561. *
  562. * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available.
  563. * See the configuration section for more information.
  564. *
  565. * Obtain the priority of any task.
  566. *
  567. * @param xTask Handle of the task to be queried. Passing a NULL
  568. * handle results in the priority of the calling task being returned.
  569. *
  570. * @return The priority of xTask.
  571. *
  572. * Example usage:
  573. * @code{c}
  574. * void vAFunction( void )
  575. * {
  576. * TaskHandle_t xHandle;
  577. *
  578. * // Create a task, storing the handle.
  579. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  580. *
  581. * // ...
  582. *
  583. * // Use the handle to obtain the priority of the created task.
  584. * // It was created with tskIDLE_PRIORITY, but may have changed
  585. * // it itself.
  586. * if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
  587. * {
  588. * // The task has changed it's priority.
  589. * }
  590. *
  591. * // ...
  592. *
  593. * // Is our priority higher than the created task?
  594. * if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
  595. * {
  596. * // Our priority (obtained using NULL handle) is higher.
  597. * }
  598. * }
  599. * @endcode
  600. * \defgroup uxTaskPriorityGet uxTaskPriorityGet
  601. * \ingroup TaskCtrl
  602. */
  603. UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask );
  604. /**
  605. * task. h
  606. * @code{c}
  607. * UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask );
  608. * @endcode
  609. *
  610. * A version of uxTaskPriorityGet() that can be used from an ISR.
  611. */
  612. UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask );
  613. /**
  614. * task. h
  615. * @code{c}
  616. * eTaskState eTaskGetState( TaskHandle_t xTask );
  617. * @endcode
  618. *
  619. * INCLUDE_eTaskGetState must be defined as 1 for this function to be available.
  620. * See the configuration section for more information.
  621. *
  622. * Obtain the state of any task. States are encoded by the eTaskState
  623. * enumerated type.
  624. *
  625. * @param xTask Handle of the task to be queried.
  626. *
  627. * @return The state of xTask at the time the function was called. Note the
  628. * state of the task might change between the function being called, and the
  629. * functions return value being tested by the calling task.
  630. */
  631. eTaskState eTaskGetState( TaskHandle_t xTask );
  632. /**
  633. * task. h
  634. * @code{c}
  635. * void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );
  636. * @endcode
  637. *
  638. * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.
  639. * See the configuration section for more information.
  640. *
  641. * Set the priority of any task.
  642. *
  643. * A context switch will occur before the function returns if the priority
  644. * being set is higher than the currently executing task.
  645. *
  646. * @param xTask Handle to the task for which the priority is being set.
  647. * Passing a NULL handle results in the priority of the calling task being set.
  648. *
  649. * @param uxNewPriority The priority to which the task will be set.
  650. *
  651. * Example usage:
  652. * @code{c}
  653. * void vAFunction( void )
  654. * {
  655. * TaskHandle_t xHandle;
  656. *
  657. * // Create a task, storing the handle.
  658. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  659. *
  660. * // ...
  661. *
  662. * // Use the handle to raise the priority of the created task.
  663. * vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
  664. *
  665. * // ...
  666. *
  667. * // Use a NULL handle to raise our priority to the same value.
  668. * vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
  669. * }
  670. * @endcode
  671. * \defgroup vTaskPrioritySet vTaskPrioritySet
  672. * \ingroup TaskCtrl
  673. */
  674. void vTaskPrioritySet( TaskHandle_t xTask,
  675. UBaseType_t uxNewPriority );
  676. /**
  677. * task. h
  678. * @code{c}
  679. * void vTaskSuspend( TaskHandle_t xTaskToSuspend );
  680. * @endcode
  681. *
  682. * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
  683. * See the configuration section for more information.
  684. *
  685. * Suspend any task. When suspended a task will never get any microcontroller
  686. * processing time, no matter what its priority.
  687. *
  688. * Calls to vTaskSuspend are not accumulative -
  689. * i.e. calling vTaskSuspend () twice on the same task still only requires one
  690. * call to vTaskResume () to ready the suspended task.
  691. *
  692. * RT-Thread only supports suspending the current running thread.
  693. * This function must be called with NULL as the parameter.
  694. *
  695. * @param xTaskToSuspend Handle to the task being suspended. Passing a NULL
  696. * handle will cause the calling task to be suspended.
  697. *
  698. * Example usage:
  699. * @code{c}
  700. * void vAFunction( void )
  701. * {
  702. * TaskHandle_t xHandle;
  703. *
  704. * // Create a task, storing the handle.
  705. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  706. *
  707. * // ...
  708. *
  709. * // Use the handle to suspend the created task.
  710. * vTaskSuspend( xHandle );
  711. *
  712. * // ...
  713. *
  714. * // The created task will not run during this period, unless
  715. * // another task calls vTaskResume( xHandle ).
  716. *
  717. * //...
  718. *
  719. *
  720. * // Suspend ourselves.
  721. * vTaskSuspend( NULL );
  722. *
  723. * // We cannot get here unless another task calls vTaskResume
  724. * // with our handle as the parameter.
  725. * }
  726. * @endcode
  727. * \defgroup vTaskSuspend vTaskSuspend
  728. * \ingroup TaskCtrl
  729. */
  730. void vTaskSuspend( TaskHandle_t xTaskToSuspend );
  731. /**
  732. * task. h
  733. * @code{c}
  734. * void vTaskResume( TaskHandle_t xTaskToResume );
  735. * @endcode
  736. *
  737. * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
  738. * See the configuration section for more information.
  739. *
  740. * Resumes a suspended task.
  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. * vTaskResume ().
  745. *
  746. * @param xTaskToResume Handle to the task being readied.
  747. *
  748. * Example usage:
  749. * @code{c}
  750. * void vAFunction( void )
  751. * {
  752. * TaskHandle_t xHandle;
  753. *
  754. * // Create a task, storing the handle.
  755. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  756. *
  757. * // ...
  758. *
  759. * // Use the handle to suspend the created task.
  760. * vTaskSuspend( xHandle );
  761. *
  762. * // ...
  763. *
  764. * // The created task will not run during this period, unless
  765. * // another task calls vTaskResume( xHandle ).
  766. *
  767. * //...
  768. *
  769. *
  770. * // Resume the suspended task ourselves.
  771. * vTaskResume( xHandle );
  772. *
  773. * // The created task will once again get microcontroller processing
  774. * // time in accordance with its priority within the system.
  775. * }
  776. * @endcode
  777. * \defgroup vTaskResume vTaskResume
  778. * \ingroup TaskCtrl
  779. */
  780. void vTaskResume( TaskHandle_t xTaskToResume );
  781. /**
  782. * task. h
  783. * @code{c}
  784. * void xTaskResumeFromISR( TaskHandle_t xTaskToResume );
  785. * @endcode
  786. *
  787. * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be
  788. * available. See the configuration section for more information.
  789. *
  790. * An implementation of vTaskResume() that can be called from within an ISR.
  791. *
  792. * A task that has been suspended by one or more calls to vTaskSuspend ()
  793. * will be made available for running again by a single call to
  794. * xTaskResumeFromISR ().
  795. *
  796. * xTaskResumeFromISR() should not be used to synchronise a task with an
  797. * interrupt if there is a chance that the interrupt could arrive prior to the
  798. * task being suspended - as this can lead to interrupts being missed. Use of a
  799. * semaphore as a synchronisation mechanism would avoid this eventuality.
  800. *
  801. * @param xTaskToResume Handle to the task being readied.
  802. *
  803. * @return pdTRUE if resuming the task should result in a context switch,
  804. * otherwise pdFALSE. This is used by the ISR to determine if a context switch
  805. * may be required following the ISR.
  806. *
  807. * \defgroup vTaskResumeFromISR vTaskResumeFromISR
  808. * \ingroup TaskCtrl
  809. */
  810. BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume );
  811. /*-----------------------------------------------------------
  812. * SCHEDULER CONTROL
  813. *----------------------------------------------------------*/
  814. /**
  815. * task. h
  816. * @code{c}
  817. * void vTaskSuspendAll( void );
  818. * @endcode
  819. *
  820. * Suspends the scheduler without disabling interrupts. Context switches will
  821. * not occur while the scheduler is suspended.
  822. *
  823. * After calling vTaskSuspendAll () the calling task will continue to execute
  824. * without risk of being swapped out until a call to xTaskResumeAll () has been
  825. * made.
  826. *
  827. * API functions that have the potential to cause a context switch (for example,
  828. * xTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler
  829. * is suspended.
  830. *
  831. * Example usage:
  832. * @code{c}
  833. * void vTask1( void * pvParameters )
  834. * {
  835. * for( ;; )
  836. * {
  837. * // Task code goes here.
  838. *
  839. * // ...
  840. *
  841. * // At some point the task wants to perform a long operation during
  842. * // which it does not want to get swapped out. It cannot use
  843. * // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
  844. * // operation may cause interrupts to be missed - including the
  845. * // ticks.
  846. *
  847. * // Prevent the real time kernel swapping out the task.
  848. * vTaskSuspendAll ();
  849. *
  850. * // Perform the operation here. There is no need to use critical
  851. * // sections as we have all the microcontroller processing time.
  852. * // During this time interrupts will still operate and the kernel
  853. * // tick count will be maintained.
  854. *
  855. * // ...
  856. *
  857. * // The operation is complete. Restart the kernel.
  858. * xTaskResumeAll ();
  859. * }
  860. * }
  861. * @endcode
  862. * \defgroup vTaskSuspendAll vTaskSuspendAll
  863. * \ingroup SchedulerControl
  864. */
  865. void vTaskSuspendAll( void );
  866. /**
  867. * task. h
  868. * @code{c}
  869. * BaseType_t xTaskResumeAll( void );
  870. * @endcode
  871. *
  872. * Resumes scheduler activity after it was suspended by a call to
  873. * vTaskSuspendAll().
  874. *
  875. * xTaskResumeAll() only resumes the scheduler. It does not unsuspend tasks
  876. * that were previously suspended by a call to vTaskSuspend().
  877. *
  878. * @return If resuming the scheduler caused a context switch then pdTRUE is
  879. * returned, otherwise pdFALSE is returned.
  880. *
  881. * Example usage:
  882. * @code{c}
  883. * void vTask1( void * pvParameters )
  884. * {
  885. * for( ;; )
  886. * {
  887. * // Task code goes here.
  888. *
  889. * // ...
  890. *
  891. * // At some point the task wants to perform a long operation during
  892. * // which it does not want to get swapped out. It cannot use
  893. * // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
  894. * // operation may cause interrupts to be missed - including the
  895. * // ticks.
  896. *
  897. * // Prevent the real time kernel swapping out the task.
  898. * vTaskSuspendAll ();
  899. *
  900. * // Perform the operation here. There is no need to use critical
  901. * // sections as we have all the microcontroller processing time.
  902. * // During this time interrupts will still operate and the real
  903. * // time kernel tick count will be maintained.
  904. *
  905. * // ...
  906. *
  907. * // The operation is complete. Restart the kernel. We want to force
  908. * // a context switch - but there is no point if resuming the scheduler
  909. * // caused a context switch already.
  910. * if( !xTaskResumeAll () )
  911. * {
  912. * taskYIELD ();
  913. * }
  914. * }
  915. * }
  916. * @endcode
  917. * \defgroup xTaskResumeAll xTaskResumeAll
  918. * \ingroup SchedulerControl
  919. */
  920. BaseType_t xTaskResumeAll( void );
  921. /*-----------------------------------------------------------
  922. * TASK UTILITIES
  923. *----------------------------------------------------------*/
  924. /**
  925. * task. h
  926. * @code{c}
  927. * TickType_t xTaskGetTickCount( void );
  928. * @endcode
  929. *
  930. * @return The count of ticks since vTaskStartScheduler was called.
  931. *
  932. * \defgroup xTaskGetTickCount xTaskGetTickCount
  933. * \ingroup TaskUtils
  934. */
  935. TickType_t xTaskGetTickCount( void );
  936. /**
  937. * task. h
  938. * @code{c}
  939. * TickType_t xTaskGetTickCountFromISR( void );
  940. * @endcode
  941. *
  942. * @return The count of ticks since vTaskStartScheduler was called.
  943. *
  944. * This is a version of xTaskGetTickCount() that is safe to be called from an
  945. * ISR - provided that TickType_t is the natural word size of the
  946. * microcontroller being used or interrupt nesting is either not supported or
  947. * not being used.
  948. *
  949. * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR
  950. * \ingroup TaskUtils
  951. */
  952. TickType_t xTaskGetTickCountFromISR( void );
  953. /**
  954. * task. h
  955. * @code{c}
  956. * uint16_t uxTaskGetNumberOfTasks( void );
  957. * @endcode
  958. *
  959. * @return The number of tasks that the real time kernel is currently managing.
  960. * This includes all ready, blocked and suspended tasks. A task that
  961. * has been deleted but not yet freed by the idle task will also be
  962. * included in the count.
  963. *
  964. * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks
  965. * \ingroup TaskUtils
  966. */
  967. UBaseType_t uxTaskGetNumberOfTasks( void );
  968. /**
  969. * task. h
  970. * @code{c}
  971. * char *pcTaskGetName( TaskHandle_t xTaskToQuery );
  972. * @endcode
  973. *
  974. * @return The text (human readable) name of the task referenced by the handle
  975. * xTaskToQuery. A task can query its own name by either passing in its own
  976. * handle, or by setting xTaskToQuery to NULL.
  977. *
  978. * \defgroup pcTaskGetName pcTaskGetName
  979. * \ingroup TaskUtils
  980. */
  981. char * pcTaskGetName( TaskHandle_t xTaskToQuery ); /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
  982. /**
  983. * task. h
  984. * @code{c}
  985. * TaskHandle_t xTaskGetHandle( const char *pcNameToQuery );
  986. * @endcode
  987. *
  988. * NOTE: This function takes a relatively long time to complete and should be
  989. * used sparingly.
  990. *
  991. * @return The handle of the task that has the human readable name pcNameToQuery.
  992. * NULL is returned if no matching name is found. INCLUDE_xTaskGetHandle
  993. * must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available.
  994. *
  995. * \defgroup pcTaskGetHandle pcTaskGetHandle
  996. * \ingroup TaskUtils
  997. */
  998. TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ); /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
  999. /**
  1000. * task.h
  1001. * @code{c}
  1002. * UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );
  1003. * @endcode
  1004. *
  1005. * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for
  1006. * this function to be available.
  1007. *
  1008. * Returns the high water mark of the stack associated with xTask. That is,
  1009. * the minimum free stack space there has been (in words, so on a 32 bit machine
  1010. * a value of 1 means 4 bytes) since the task started. The smaller the returned
  1011. * number the closer the task has come to overflowing its stack.
  1012. *
  1013. * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
  1014. * same except for their return type. Using configSTACK_DEPTH_TYPE allows the
  1015. * user to determine the return type. It gets around the problem of the value
  1016. * overflowing on 8-bit types without breaking backward compatibility for
  1017. * applications that expect an 8-bit return type.
  1018. *
  1019. * @param xTask Handle of the task associated with the stack to be checked.
  1020. * Set xTask to NULL to check the stack of the calling task.
  1021. *
  1022. * @return The smallest amount of free stack space there has been (in words, so
  1023. * actual spaces on the stack rather than bytes) since the task referenced by
  1024. * xTask was created.
  1025. */
  1026. UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );
  1027. /**
  1028. * task.h
  1029. * @code{c}
  1030. * configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask );
  1031. * @endcode
  1032. *
  1033. * INCLUDE_uxTaskGetStackHighWaterMark2 must be set to 1 in FreeRTOSConfig.h for
  1034. * this function to be available.
  1035. *
  1036. * Returns the high water mark of the stack associated with xTask. That is,
  1037. * the minimum free stack space there has been (in words, so on a 32 bit machine
  1038. * a value of 1 means 4 bytes) since the task started. The smaller the returned
  1039. * number the closer the task has come to overflowing its stack.
  1040. *
  1041. * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
  1042. * same except for their return type. Using configSTACK_DEPTH_TYPE allows the
  1043. * user to determine the return type. It gets around the problem of the value
  1044. * overflowing on 8-bit types without breaking backward compatibility for
  1045. * applications that expect an 8-bit return type.
  1046. *
  1047. * @param xTask Handle of the task associated with the stack to be checked.
  1048. * Set xTask to NULL to check the stack of the calling task.
  1049. *
  1050. * @return The smallest amount of free stack space there has been (in words, so
  1051. * actual spaces on the stack rather than bytes) since the task referenced by
  1052. * xTask was created.
  1053. */
  1054. configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask );
  1055. /* When using trace macros it is sometimes necessary to include task.h before
  1056. * FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,
  1057. * so the following two prototypes will cause a compilation error. This can be
  1058. * fixed by simply guarding against the inclusion of these two prototypes unless
  1059. * they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration
  1060. * constant. */
  1061. #ifdef configUSE_APPLICATION_TASK_TAG
  1062. #if configUSE_APPLICATION_TASK_TAG == 1
  1063. /**
  1064. * task.h
  1065. * @code{c}
  1066. * void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );
  1067. * @endcode
  1068. *
  1069. * Sets pxHookFunction to be the task hook function used by the task xTask.
  1070. * Passing xTask as NULL has the effect of setting the calling tasks hook
  1071. * function.
  1072. */
  1073. void vTaskSetApplicationTaskTag( TaskHandle_t xTask,
  1074. TaskHookFunction_t pxHookFunction );
  1075. /**
  1076. * task.h
  1077. * @code{c}
  1078. * void xTaskGetApplicationTaskTag( TaskHandle_t xTask );
  1079. * @endcode
  1080. *
  1081. * Returns the pxHookFunction value assigned to the task xTask. Do not
  1082. * call from an interrupt service routine - call
  1083. * xTaskGetApplicationTaskTagFromISR() instead.
  1084. */
  1085. TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask );
  1086. /**
  1087. * task.h
  1088. * @code{c}
  1089. * void xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );
  1090. * @endcode
  1091. *
  1092. * Returns the pxHookFunction value assigned to the task xTask. Can
  1093. * be called from an interrupt service routine.
  1094. */
  1095. TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );
  1096. #endif /* configUSE_APPLICATION_TASK_TAG ==1 */
  1097. #endif /* ifdef configUSE_APPLICATION_TASK_TAG */
  1098. /**
  1099. * task.h
  1100. * @code{c}
  1101. * BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );
  1102. * @endcode
  1103. *
  1104. * Calls the hook function associated with xTask. Passing xTask as NULL has
  1105. * the effect of calling the Running tasks (the calling task) hook function.
  1106. *
  1107. * pvParameter is passed to the hook function for the task to interpret as it
  1108. * wants. The return value is the value returned by the task hook function
  1109. * registered by the user.
  1110. */
  1111. BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask,
  1112. void * pvParameter );
  1113. /**
  1114. * xTaskGetIdleTaskHandle() is only available if
  1115. * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.
  1116. *
  1117. * Simply returns the handle of the idle task. It is not valid to call
  1118. * xTaskGetIdleTaskHandle() before the scheduler has been started.
  1119. */
  1120. TaskHandle_t xTaskGetIdleTaskHandle( void );
  1121. /*
  1122. * Return the handle of the calling task.
  1123. */
  1124. TaskHandle_t xTaskGetCurrentTaskHandle( void );
  1125. /* *INDENT-OFF* */
  1126. #ifdef __cplusplus
  1127. }
  1128. #endif
  1129. /* *INDENT-ON* */
  1130. #endif /* INC_TASK_H */