task.h 160 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774
  1. /*
  2. * FreeRTOS Kernel V11.1.0
  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. #include "list.h"
  34. /* *INDENT-OFF* */
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /* *INDENT-ON* */
  39. /*-----------------------------------------------------------
  40. * MACROS AND DEFINITIONS
  41. *----------------------------------------------------------*/
  42. /*
  43. * If tskKERNEL_VERSION_NUMBER ends with + it represents the version in development
  44. * after the numbered release.
  45. *
  46. * The tskKERNEL_VERSION_MAJOR, tskKERNEL_VERSION_MINOR, tskKERNEL_VERSION_BUILD
  47. * values will reflect the last released version number.
  48. */
  49. #define tskKERNEL_VERSION_NUMBER "V11.1.0"
  50. #define tskKERNEL_VERSION_MAJOR 11
  51. #define tskKERNEL_VERSION_MINOR 1
  52. #define tskKERNEL_VERSION_BUILD 0
  53. /* MPU region parameters passed in ulParameters
  54. * of MemoryRegion_t struct. */
  55. #define tskMPU_REGION_READ_ONLY ( 1U << 0U )
  56. #define tskMPU_REGION_READ_WRITE ( 1U << 1U )
  57. #define tskMPU_REGION_EXECUTE_NEVER ( 1U << 2U )
  58. #define tskMPU_REGION_NORMAL_MEMORY ( 1U << 3U )
  59. #define tskMPU_REGION_DEVICE_MEMORY ( 1U << 4U )
  60. /* MPU region permissions stored in MPU settings to
  61. * authorize access requests. */
  62. #define tskMPU_READ_PERMISSION ( 1U << 0U )
  63. #define tskMPU_WRITE_PERMISSION ( 1U << 1U )
  64. /* The direct to task notification feature used to have only a single notification
  65. * per task. Now there is an array of notifications per task that is dimensioned by
  66. * configTASK_NOTIFICATION_ARRAY_ENTRIES. For backward compatibility, any use of the
  67. * original direct to task notification defaults to using the first index in the
  68. * array. */
  69. #define tskDEFAULT_INDEX_TO_NOTIFY ( 0 )
  70. /**
  71. * task. h
  72. *
  73. * Type by which tasks are referenced. For example, a call to xTaskCreate
  74. * returns (via a pointer parameter) an TaskHandle_t variable that can then
  75. * be used as a parameter to vTaskDelete to delete the task.
  76. *
  77. * \defgroup TaskHandle_t TaskHandle_t
  78. * \ingroup Tasks
  79. */
  80. struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */
  81. typedef struct tskTaskControlBlock * TaskHandle_t;
  82. typedef const struct tskTaskControlBlock * ConstTaskHandle_t;
  83. /*
  84. * Defines the prototype to which the application task hook function must
  85. * conform.
  86. */
  87. typedef BaseType_t (* TaskHookFunction_t)( void * arg );
  88. /* Task states returned by eTaskGetState. */
  89. typedef enum
  90. {
  91. eRunning = 0, /* A task is querying the state of itself, so must be running. */
  92. eReady, /* The task being queried is in a ready or pending ready list. */
  93. eBlocked, /* The task being queried is in the Blocked state. */
  94. eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */
  95. eDeleted, /* The task being queried has been deleted, but its TCB has not yet been freed. */
  96. eInvalid /* Used as an 'invalid state' value. */
  97. } eTaskState;
  98. /* Actions that can be performed when vTaskNotify() is called. */
  99. typedef enum
  100. {
  101. eNoAction = 0, /* Notify the task without updating its notify value. */
  102. eSetBits, /* Set bits in the task's notification value. */
  103. eIncrement, /* Increment the task's notification value. */
  104. eSetValueWithOverwrite, /* Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */
  105. eSetValueWithoutOverwrite /* Set the task's notification value if the previous value has been read by the task. */
  106. } eNotifyAction;
  107. /*
  108. * Used internally only.
  109. */
  110. typedef struct xTIME_OUT
  111. {
  112. BaseType_t xOverflowCount;
  113. TickType_t xTimeOnEntering;
  114. } TimeOut_t;
  115. /*
  116. * Defines the memory ranges allocated to the task when an MPU is used.
  117. */
  118. typedef struct xMEMORY_REGION
  119. {
  120. void * pvBaseAddress;
  121. uint32_t ulLengthInBytes;
  122. uint32_t ulParameters;
  123. } MemoryRegion_t;
  124. /*
  125. * Parameters required to create an MPU protected task.
  126. */
  127. typedef struct xTASK_PARAMETERS
  128. {
  129. TaskFunction_t pvTaskCode;
  130. const char * pcName;
  131. configSTACK_DEPTH_TYPE usStackDepth;
  132. void * pvParameters;
  133. UBaseType_t uxPriority;
  134. StackType_t * puxStackBuffer;
  135. MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ];
  136. #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
  137. StaticTask_t * const pxTaskBuffer;
  138. #endif
  139. } TaskParameters_t;
  140. /* Used with the uxTaskGetSystemState() function to return the state of each task
  141. * in the system. */
  142. typedef struct xTASK_STATUS
  143. {
  144. TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */
  145. 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! */
  146. UBaseType_t xTaskNumber; /* A number unique to the task. */
  147. eTaskState eCurrentState; /* The state in which the task existed when the structure was populated. */
  148. UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */
  149. 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. */
  150. configRUN_TIME_COUNTER_TYPE ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock. See https://www.FreeRTOS.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */
  151. StackType_t * pxStackBase; /* Points to the lowest address of the task's stack area. */
  152. #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )
  153. StackType_t * pxTopOfStack; /* Points to the top address of the task's stack area. */
  154. StackType_t * pxEndOfStack; /* Points to the end address of the task's stack area. */
  155. #endif
  156. configSTACK_DEPTH_TYPE 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. */
  157. #if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
  158. UBaseType_t uxCoreAffinityMask; /* The core affinity mask for the task */
  159. #endif
  160. } TaskStatus_t;
  161. /* Possible return values for eTaskConfirmSleepModeStatus(). */
  162. typedef enum
  163. {
  164. eAbortSleep = 0, /* A task has been made ready or a context switch pended since portSUPPRESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */
  165. eStandardSleep /* Enter a sleep mode that will not last any longer than the expected idle time. */
  166. #if ( INCLUDE_vTaskSuspend == 1 )
  167. ,
  168. 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. */
  169. #endif /* INCLUDE_vTaskSuspend */
  170. } eSleepModeStatus;
  171. /**
  172. * Defines the priority used by the idle task. This must not be modified.
  173. *
  174. * \ingroup TaskUtils
  175. */
  176. #define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U )
  177. /**
  178. * Defines affinity to all available cores.
  179. *
  180. * \ingroup TaskUtils
  181. */
  182. #define tskNO_AFFINITY ( ( UBaseType_t ) -1 )
  183. /**
  184. * task. h
  185. *
  186. * Macro for forcing a context switch.
  187. *
  188. * \defgroup taskYIELD taskYIELD
  189. * \ingroup SchedulerControl
  190. */
  191. #define taskYIELD() portYIELD()
  192. /**
  193. * task. h
  194. *
  195. * Macro to mark the start of a critical code region. Preemptive context
  196. * switches cannot occur when in a critical region.
  197. *
  198. * NOTE: This may alter the stack (depending on the portable implementation)
  199. * so must be used with care!
  200. *
  201. * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL
  202. * \ingroup SchedulerControl
  203. */
  204. #define taskENTER_CRITICAL() portENTER_CRITICAL()
  205. #if ( configNUMBER_OF_CORES == 1 )
  206. #define taskENTER_CRITICAL_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()
  207. #else
  208. #define taskENTER_CRITICAL_FROM_ISR() portENTER_CRITICAL_FROM_ISR()
  209. #endif
  210. /**
  211. * task. h
  212. *
  213. * Macro to mark the end of a critical code region. Preemptive context
  214. * switches cannot occur when in a critical region.
  215. *
  216. * NOTE: This may alter the stack (depending on the portable implementation)
  217. * so must be used with care!
  218. *
  219. * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL
  220. * \ingroup SchedulerControl
  221. */
  222. #define taskEXIT_CRITICAL() portEXIT_CRITICAL()
  223. #if ( configNUMBER_OF_CORES == 1 )
  224. #define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x )
  225. #else
  226. #define taskEXIT_CRITICAL_FROM_ISR( x ) portEXIT_CRITICAL_FROM_ISR( x )
  227. #endif
  228. /**
  229. * task. h
  230. *
  231. * Macro to disable all maskable interrupts.
  232. *
  233. * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS
  234. * \ingroup SchedulerControl
  235. */
  236. #define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS()
  237. /**
  238. * task. h
  239. *
  240. * Macro to enable microcontroller interrupts.
  241. *
  242. * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS
  243. * \ingroup SchedulerControl
  244. */
  245. #define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS()
  246. /* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is
  247. * 0 to generate more optimal code when configASSERT() is defined as the constant
  248. * is used in assert() statements. */
  249. #define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 )
  250. #define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 )
  251. #define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 )
  252. /* Checks if core ID is valid. */
  253. #define taskVALID_CORE_ID( xCoreID ) ( ( ( ( ( BaseType_t ) 0 <= ( xCoreID ) ) && ( ( xCoreID ) < ( BaseType_t ) configNUMBER_OF_CORES ) ) ) ? ( pdTRUE ) : ( pdFALSE ) )
  254. /*-----------------------------------------------------------
  255. * TASK CREATION API
  256. *----------------------------------------------------------*/
  257. /**
  258. * task. h
  259. * @code{c}
  260. * BaseType_t xTaskCreate(
  261. * TaskFunction_t pxTaskCode,
  262. * const char * const pcName,
  263. * const configSTACK_DEPTH_TYPE uxStackDepth,
  264. * void *pvParameters,
  265. * UBaseType_t uxPriority,
  266. * TaskHandle_t *pxCreatedTask
  267. * );
  268. * @endcode
  269. *
  270. * Create a new task and add it to the list of tasks that are ready to run.
  271. *
  272. * Internally, within the FreeRTOS implementation, tasks use two blocks of
  273. * memory. The first block is used to hold the task's data structures. The
  274. * second block is used by the task as its stack. If a task is created using
  275. * xTaskCreate() then both blocks of memory are automatically dynamically
  276. * allocated inside the xTaskCreate() function. (see
  277. * https://www.FreeRTOS.org/a00111.html). If a task is created using
  278. * xTaskCreateStatic() then the application writer must provide the required
  279. * memory. xTaskCreateStatic() therefore allows a task to be created without
  280. * using any dynamic memory allocation.
  281. *
  282. * See xTaskCreateStatic() for a version that does not use any dynamic memory
  283. * allocation.
  284. *
  285. * xTaskCreate() can only be used to create a task that has unrestricted
  286. * access to the entire microcontroller memory map. Systems that include MPU
  287. * support can alternatively create an MPU constrained task using
  288. * xTaskCreateRestricted().
  289. *
  290. * @param pxTaskCode Pointer to the task entry function. Tasks
  291. * must be implemented to never return (i.e. continuous loop).
  292. *
  293. * @param pcName A descriptive name for the task. This is mainly used to
  294. * facilitate debugging. Max length defined by configMAX_TASK_NAME_LEN - default
  295. * is 16.
  296. *
  297. * @param uxStackDepth The size of the task stack specified as the number of
  298. * variables the stack can hold - not the number of bytes. For example, if
  299. * the stack is 16 bits wide and uxStackDepth is defined as 100, 200 bytes
  300. * will be allocated for stack storage.
  301. *
  302. * @param pvParameters Pointer that will be used as the parameter for the task
  303. * being created.
  304. *
  305. * @param uxPriority The priority at which the task should run. Systems that
  306. * include MPU support can optionally create tasks in a privileged (system)
  307. * mode by setting bit portPRIVILEGE_BIT of the priority parameter. For
  308. * example, to create a privileged task at priority 2 the uxPriority parameter
  309. * should be set to ( 2 | portPRIVILEGE_BIT ).
  310. *
  311. * @param pxCreatedTask Used to pass back a handle by which the created task
  312. * can be referenced.
  313. *
  314. * @return pdPASS if the task was successfully created and added to a ready
  315. * list, otherwise an error code defined in the file projdefs.h
  316. *
  317. * Example usage:
  318. * @code{c}
  319. * // Task to be created.
  320. * void vTaskCode( void * pvParameters )
  321. * {
  322. * for( ;; )
  323. * {
  324. * // Task code goes here.
  325. * }
  326. * }
  327. *
  328. * // Function that creates a task.
  329. * void vOtherFunction( void )
  330. * {
  331. * static uint8_t ucParameterToPass;
  332. * TaskHandle_t xHandle = NULL;
  333. *
  334. * // Create the task, storing the handle. Note that the passed parameter ucParameterToPass
  335. * // must exist for the lifetime of the task, so in this case is declared static. If it was just an
  336. * // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time
  337. * // the new task attempts to access it.
  338. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
  339. * configASSERT( xHandle );
  340. *
  341. * // Use the handle to delete the task.
  342. * if( xHandle != NULL )
  343. * {
  344. * vTaskDelete( xHandle );
  345. * }
  346. * }
  347. * @endcode
  348. * \defgroup xTaskCreate xTaskCreate
  349. * \ingroup Tasks
  350. */
  351. #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  352. BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
  353. const char * const pcName,
  354. const configSTACK_DEPTH_TYPE uxStackDepth,
  355. void * const pvParameters,
  356. UBaseType_t uxPriority,
  357. TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
  358. #endif
  359. #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
  360. BaseType_t xTaskCreateAffinitySet( TaskFunction_t pxTaskCode,
  361. const char * const pcName,
  362. const configSTACK_DEPTH_TYPE uxStackDepth,
  363. void * const pvParameters,
  364. UBaseType_t uxPriority,
  365. UBaseType_t uxCoreAffinityMask,
  366. TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
  367. #endif
  368. /**
  369. * task. h
  370. * @code{c}
  371. * TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
  372. * const char * const pcName,
  373. * const configSTACK_DEPTH_TYPE uxStackDepth,
  374. * void *pvParameters,
  375. * UBaseType_t uxPriority,
  376. * StackType_t *puxStackBuffer,
  377. * StaticTask_t *pxTaskBuffer );
  378. * @endcode
  379. *
  380. * Create a new task and add it to the list of tasks that are ready to run.
  381. *
  382. * Internally, within the FreeRTOS implementation, tasks use two blocks of
  383. * memory. The first block is used to hold the task's data structures. The
  384. * second block is used by the task as its stack. If a task is created using
  385. * xTaskCreate() then both blocks of memory are automatically dynamically
  386. * allocated inside the xTaskCreate() function. (see
  387. * https://www.FreeRTOS.org/a00111.html). If a task is created using
  388. * xTaskCreateStatic() then the application writer must provide the required
  389. * memory. xTaskCreateStatic() therefore allows a task to be created without
  390. * using any dynamic memory allocation.
  391. *
  392. * @param pxTaskCode Pointer to the task entry function. Tasks
  393. * must be implemented to never return (i.e. continuous loop).
  394. *
  395. * @param pcName A descriptive name for the task. This is mainly used to
  396. * facilitate debugging. The maximum length of the string is defined by
  397. * configMAX_TASK_NAME_LEN in FreeRTOSConfig.h.
  398. *
  399. * @param uxStackDepth The size of the task stack specified as the number of
  400. * variables the stack can hold - not the number of bytes. For example, if
  401. * the stack is 32-bits wide and uxStackDepth is defined as 100 then 400 bytes
  402. * will be allocated for stack storage.
  403. *
  404. * @param pvParameters Pointer that will be used as the parameter for the task
  405. * being created.
  406. *
  407. * @param uxPriority The priority at which the task will run.
  408. *
  409. * @param puxStackBuffer Must point to a StackType_t array that has at least
  410. * uxStackDepth indexes - the array will then be used as the task's stack,
  411. * removing the need for the stack to be allocated dynamically.
  412. *
  413. * @param pxTaskBuffer Must point to a variable of type StaticTask_t, which will
  414. * then be used to hold the task's data structures, removing the need for the
  415. * memory to be allocated dynamically.
  416. *
  417. * @return If neither puxStackBuffer nor pxTaskBuffer are NULL, then the task
  418. * will be created and a handle to the created task is returned. If either
  419. * puxStackBuffer or pxTaskBuffer are NULL then the task will not be created and
  420. * NULL is returned.
  421. *
  422. * Example usage:
  423. * @code{c}
  424. *
  425. * // Dimensions of the buffer that the task being created will use as its stack.
  426. * // NOTE: This is the number of words the stack will hold, not the number of
  427. * // bytes. For example, if each stack item is 32-bits, and this is set to 100,
  428. * // then 400 bytes (100 * 32-bits) will be allocated.
  429. #define STACK_SIZE 200
  430. *
  431. * // Structure that will hold the TCB of the task being created.
  432. * StaticTask_t xTaskBuffer;
  433. *
  434. * // Buffer that the task being created will use as its stack. Note this is
  435. * // an array of StackType_t variables. The size of StackType_t is dependent on
  436. * // the RTOS port.
  437. * StackType_t xStack[ STACK_SIZE ];
  438. *
  439. * // Function that implements the task being created.
  440. * void vTaskCode( void * pvParameters )
  441. * {
  442. * // The parameter value is expected to be 1 as 1 is passed in the
  443. * // pvParameters value in the call to xTaskCreateStatic().
  444. * configASSERT( ( uint32_t ) pvParameters == 1U );
  445. *
  446. * for( ;; )
  447. * {
  448. * // Task code goes here.
  449. * }
  450. * }
  451. *
  452. * // Function that creates a task.
  453. * void vOtherFunction( void )
  454. * {
  455. * TaskHandle_t xHandle = NULL;
  456. *
  457. * // Create the task without using any dynamic memory allocation.
  458. * xHandle = xTaskCreateStatic(
  459. * vTaskCode, // Function that implements the task.
  460. * "NAME", // Text name for the task.
  461. * STACK_SIZE, // Stack size in words, not bytes.
  462. * ( void * ) 1, // Parameter passed into the task.
  463. * tskIDLE_PRIORITY,// Priority at which the task is created.
  464. * xStack, // Array to use as the task's stack.
  465. * &xTaskBuffer ); // Variable to hold the task's data structure.
  466. *
  467. * // puxStackBuffer and pxTaskBuffer were not NULL, so the task will have
  468. * // been created, and xHandle will be the task's handle. Use the handle
  469. * // to suspend the task.
  470. * vTaskSuspend( xHandle );
  471. * }
  472. * @endcode
  473. * \defgroup xTaskCreateStatic xTaskCreateStatic
  474. * \ingroup Tasks
  475. */
  476. #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
  477. TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
  478. const char * const pcName,
  479. const configSTACK_DEPTH_TYPE uxStackDepth,
  480. void * const pvParameters,
  481. UBaseType_t uxPriority,
  482. StackType_t * const puxStackBuffer,
  483. StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION;
  484. #endif /* configSUPPORT_STATIC_ALLOCATION */
  485. #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
  486. TaskHandle_t xTaskCreateStaticAffinitySet( TaskFunction_t pxTaskCode,
  487. const char * const pcName,
  488. const configSTACK_DEPTH_TYPE uxStackDepth,
  489. void * const pvParameters,
  490. UBaseType_t uxPriority,
  491. StackType_t * const puxStackBuffer,
  492. StaticTask_t * const pxTaskBuffer,
  493. UBaseType_t uxCoreAffinityMask ) PRIVILEGED_FUNCTION;
  494. #endif
  495. /**
  496. * task. h
  497. * @code{c}
  498. * BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
  499. * @endcode
  500. *
  501. * Only available when configSUPPORT_DYNAMIC_ALLOCATION is set to 1.
  502. *
  503. * xTaskCreateRestricted() should only be used in systems that include an MPU
  504. * implementation.
  505. *
  506. * Create a new task and add it to the list of tasks that are ready to run.
  507. * The function parameters define the memory regions and associated access
  508. * permissions allocated to the task.
  509. *
  510. * See xTaskCreateRestrictedStatic() for a version that does not use any
  511. * dynamic memory allocation.
  512. *
  513. * @param pxTaskDefinition Pointer to a structure that contains a member
  514. * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
  515. * documentation) plus an optional stack buffer and the memory region
  516. * definitions.
  517. *
  518. * @param pxCreatedTask Used to pass back a handle by which the created task
  519. * can be referenced.
  520. *
  521. * @return pdPASS if the task was successfully created and added to a ready
  522. * list, otherwise an error code defined in the file projdefs.h
  523. *
  524. * Example usage:
  525. * @code{c}
  526. * // Create an TaskParameters_t structure that defines the task to be created.
  527. * static const TaskParameters_t xCheckTaskParameters =
  528. * {
  529. * vATask, // pvTaskCode - the function that implements the task.
  530. * "ATask", // pcName - just a text name for the task to assist debugging.
  531. * 100, // uxStackDepth - the stack size DEFINED IN WORDS.
  532. * NULL, // pvParameters - passed into the task function as the function parameters.
  533. * ( 1U | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
  534. * cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
  535. *
  536. * // xRegions - Allocate up to three separate memory regions for access by
  537. * // the task, with appropriate access permissions. Different processors have
  538. * // different memory alignment requirements - refer to the FreeRTOS documentation
  539. * // for full information.
  540. * {
  541. * // Base address Length Parameters
  542. * { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },
  543. * { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },
  544. * { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }
  545. * }
  546. * };
  547. *
  548. * int main( void )
  549. * {
  550. * TaskHandle_t xHandle;
  551. *
  552. * // Create a task from the const structure defined above. The task handle
  553. * // is requested (the second parameter is not NULL) but in this case just for
  554. * // demonstration purposes as its not actually used.
  555. * xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
  556. *
  557. * // Start the scheduler.
  558. * vTaskStartScheduler();
  559. *
  560. * // Will only get here if there was insufficient memory to create the idle
  561. * // and/or timer task.
  562. * for( ;; );
  563. * }
  564. * @endcode
  565. * \defgroup xTaskCreateRestricted xTaskCreateRestricted
  566. * \ingroup Tasks
  567. */
  568. #if ( portUSING_MPU_WRAPPERS == 1 )
  569. BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition,
  570. TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
  571. #endif
  572. #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
  573. BaseType_t xTaskCreateRestrictedAffinitySet( const TaskParameters_t * const pxTaskDefinition,
  574. UBaseType_t uxCoreAffinityMask,
  575. TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
  576. #endif
  577. /**
  578. * task. h
  579. * @code{c}
  580. * BaseType_t xTaskCreateRestrictedStatic( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
  581. * @endcode
  582. *
  583. * Only available when configSUPPORT_STATIC_ALLOCATION is set to 1.
  584. *
  585. * xTaskCreateRestrictedStatic() should only be used in systems that include an
  586. * MPU implementation.
  587. *
  588. * Internally, within the FreeRTOS implementation, tasks use two blocks of
  589. * memory. The first block is used to hold the task's data structures. The
  590. * second block is used by the task as its stack. If a task is created using
  591. * xTaskCreateRestricted() then the stack is provided by the application writer,
  592. * and the memory used to hold the task's data structure is automatically
  593. * dynamically allocated inside the xTaskCreateRestricted() function. If a task
  594. * is created using xTaskCreateRestrictedStatic() then the application writer
  595. * must provide the memory used to hold the task's data structures too.
  596. * xTaskCreateRestrictedStatic() therefore allows a memory protected task to be
  597. * created without using any dynamic memory allocation.
  598. *
  599. * @param pxTaskDefinition Pointer to a structure that contains a member
  600. * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
  601. * documentation) plus an optional stack buffer and the memory region
  602. * definitions. If configSUPPORT_STATIC_ALLOCATION is set to 1 the structure
  603. * contains an additional member, which is used to point to a variable of type
  604. * StaticTask_t - which is then used to hold the task's data structure.
  605. *
  606. * @param pxCreatedTask Used to pass back a handle by which the created task
  607. * can be referenced.
  608. *
  609. * @return pdPASS if the task was successfully created and added to a ready
  610. * list, otherwise an error code defined in the file projdefs.h
  611. *
  612. * Example usage:
  613. * @code{c}
  614. * // Create an TaskParameters_t structure that defines the task to be created.
  615. * // The StaticTask_t variable is only included in the structure when
  616. * // configSUPPORT_STATIC_ALLOCATION is set to 1. The PRIVILEGED_DATA macro can
  617. * // be used to force the variable into the RTOS kernel's privileged data area.
  618. * static PRIVILEGED_DATA StaticTask_t xTaskBuffer;
  619. * static const TaskParameters_t xCheckTaskParameters =
  620. * {
  621. * vATask, // pvTaskCode - the function that implements the task.
  622. * "ATask", // pcName - just a text name for the task to assist debugging.
  623. * 100, // uxStackDepth - the stack size DEFINED IN WORDS.
  624. * NULL, // pvParameters - passed into the task function as the function parameters.
  625. * ( 1U | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
  626. * cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
  627. *
  628. * // xRegions - Allocate up to three separate memory regions for access by
  629. * // the task, with appropriate access permissions. Different processors have
  630. * // different memory alignment requirements - refer to the FreeRTOS documentation
  631. * // for full information.
  632. * {
  633. * // Base address Length Parameters
  634. * { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },
  635. * { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },
  636. * { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }
  637. * }
  638. *
  639. * &xTaskBuffer; // Holds the task's data structure.
  640. * };
  641. *
  642. * int main( void )
  643. * {
  644. * TaskHandle_t xHandle;
  645. *
  646. * // Create a task from the const structure defined above. The task handle
  647. * // is requested (the second parameter is not NULL) but in this case just for
  648. * // demonstration purposes as its not actually used.
  649. * xTaskCreateRestrictedStatic( &xRegTest1Parameters, &xHandle );
  650. *
  651. * // Start the scheduler.
  652. * vTaskStartScheduler();
  653. *
  654. * // Will only get here if there was insufficient memory to create the idle
  655. * // and/or timer task.
  656. * for( ;; );
  657. * }
  658. * @endcode
  659. * \defgroup xTaskCreateRestrictedStatic xTaskCreateRestrictedStatic
  660. * \ingroup Tasks
  661. */
  662. #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
  663. BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition,
  664. TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
  665. #endif
  666. #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
  667. BaseType_t xTaskCreateRestrictedStaticAffinitySet( const TaskParameters_t * const pxTaskDefinition,
  668. UBaseType_t uxCoreAffinityMask,
  669. TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
  670. #endif
  671. /**
  672. * task. h
  673. * @code{c}
  674. * void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions );
  675. * @endcode
  676. *
  677. * Memory regions are assigned to a restricted task when the task is created by
  678. * a call to xTaskCreateRestricted(). These regions can be redefined using
  679. * vTaskAllocateMPURegions().
  680. *
  681. * @param xTaskToModify The handle of the task being updated.
  682. *
  683. * @param[in] pxRegions A pointer to a MemoryRegion_t structure that contains the
  684. * new memory region definitions.
  685. *
  686. * Example usage:
  687. * @code{c}
  688. * // Define an array of MemoryRegion_t structures that configures an MPU region
  689. * // allowing read/write access for 1024 bytes starting at the beginning of the
  690. * // ucOneKByte array. The other two of the maximum 3 definable regions are
  691. * // unused so set to zero.
  692. * static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =
  693. * {
  694. * // Base address Length Parameters
  695. * { ucOneKByte, 1024, portMPU_REGION_READ_WRITE },
  696. * { 0, 0, 0 },
  697. * { 0, 0, 0 }
  698. * };
  699. *
  700. * void vATask( void *pvParameters )
  701. * {
  702. * // This task was created such that it has access to certain regions of
  703. * // memory as defined by the MPU configuration. At some point it is
  704. * // desired that these MPU regions are replaced with that defined in the
  705. * // xAltRegions const struct above. Use a call to vTaskAllocateMPURegions()
  706. * // for this purpose. NULL is used as the task handle to indicate that this
  707. * // function should modify the MPU regions of the calling task.
  708. * vTaskAllocateMPURegions( NULL, xAltRegions );
  709. *
  710. * // Now the task can continue its function, but from this point on can only
  711. * // access its stack and the ucOneKByte array (unless any other statically
  712. * // defined or shared regions have been declared elsewhere).
  713. * }
  714. * @endcode
  715. * \defgroup vTaskAllocateMPURegions vTaskAllocateMPURegions
  716. * \ingroup Tasks
  717. */
  718. #if ( portUSING_MPU_WRAPPERS == 1 )
  719. void vTaskAllocateMPURegions( TaskHandle_t xTaskToModify,
  720. const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION;
  721. #endif
  722. /**
  723. * task. h
  724. * @code{c}
  725. * void vTaskDelete( TaskHandle_t xTaskToDelete );
  726. * @endcode
  727. *
  728. * INCLUDE_vTaskDelete must be defined as 1 for this function to be available.
  729. * See the configuration section for more information.
  730. *
  731. * Remove a task from the RTOS real time kernel's management. The task being
  732. * deleted will be removed from all ready, blocked, suspended and event lists.
  733. *
  734. * NOTE: The idle task is responsible for freeing the kernel allocated
  735. * memory from tasks that have been deleted. It is therefore important that
  736. * the idle task is not starved of microcontroller processing time if your
  737. * application makes any calls to vTaskDelete (). Memory allocated by the
  738. * task code is not automatically freed, and should be freed before the task
  739. * is deleted.
  740. *
  741. * See the demo application file death.c for sample code that utilises
  742. * vTaskDelete ().
  743. *
  744. * @param xTaskToDelete The handle of the task to be deleted. Passing NULL will
  745. * cause the calling task to be deleted.
  746. *
  747. * Example usage:
  748. * @code{c}
  749. * void vOtherFunction( void )
  750. * {
  751. * TaskHandle_t xHandle;
  752. *
  753. * // Create the task, storing the handle.
  754. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  755. *
  756. * // Use the handle to delete the task.
  757. * vTaskDelete( xHandle );
  758. * }
  759. * @endcode
  760. * \defgroup vTaskDelete vTaskDelete
  761. * \ingroup Tasks
  762. */
  763. void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
  764. /*-----------------------------------------------------------
  765. * TASK CONTROL API
  766. *----------------------------------------------------------*/
  767. /**
  768. * task. h
  769. * @code{c}
  770. * void vTaskDelay( const TickType_t xTicksToDelay );
  771. * @endcode
  772. *
  773. * Delay a task for a given number of ticks. The actual time that the
  774. * task remains blocked depends on the tick rate. The constant
  775. * portTICK_PERIOD_MS can be used to calculate real time from the tick
  776. * rate - with the resolution of one tick period.
  777. *
  778. * INCLUDE_vTaskDelay must be defined as 1 for this function to be available.
  779. * See the configuration section for more information.
  780. *
  781. *
  782. * vTaskDelay() specifies a time at which the task wishes to unblock relative to
  783. * the time at which vTaskDelay() is called. For example, specifying a block
  784. * period of 100 ticks will cause the task to unblock 100 ticks after
  785. * vTaskDelay() is called. vTaskDelay() does not therefore provide a good method
  786. * of controlling the frequency of a periodic task as the path taken through the
  787. * code, as well as other task and interrupt activity, will affect the frequency
  788. * at which vTaskDelay() gets called and therefore the time at which the task
  789. * next executes. See xTaskDelayUntil() for an alternative API function designed
  790. * to facilitate fixed frequency execution. It does this by specifying an
  791. * absolute time (rather than a relative time) at which the calling task should
  792. * unblock.
  793. *
  794. * @param xTicksToDelay The amount of time, in tick periods, that
  795. * the calling task should block.
  796. *
  797. * Example usage:
  798. *
  799. * void vTaskFunction( void * pvParameters )
  800. * {
  801. * // Block for 500ms.
  802. * const TickType_t xDelay = 500 / portTICK_PERIOD_MS;
  803. *
  804. * for( ;; )
  805. * {
  806. * // Simply toggle the LED every 500ms, blocking between each toggle.
  807. * vToggleLED();
  808. * vTaskDelay( xDelay );
  809. * }
  810. * }
  811. *
  812. * \defgroup vTaskDelay vTaskDelay
  813. * \ingroup TaskCtrl
  814. */
  815. void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
  816. /**
  817. * task. h
  818. * @code{c}
  819. * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
  820. * @endcode
  821. *
  822. * INCLUDE_xTaskDelayUntil must be defined as 1 for this function to be available.
  823. * See the configuration section for more information.
  824. *
  825. * Delay a task until a specified time. This function can be used by periodic
  826. * tasks to ensure a constant execution frequency.
  827. *
  828. * This function differs from vTaskDelay () in one important aspect: vTaskDelay () will
  829. * cause a task to block for the specified number of ticks from the time vTaskDelay () is
  830. * called. It is therefore difficult to use vTaskDelay () by itself to generate a fixed
  831. * execution frequency as the time between a task starting to execute and that task
  832. * calling vTaskDelay () may not be fixed [the task may take a different path though the
  833. * code between calls, or may get interrupted or preempted a different number of times
  834. * each time it executes].
  835. *
  836. * Whereas vTaskDelay () specifies a wake time relative to the time at which the function
  837. * is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to
  838. * unblock.
  839. *
  840. * The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a
  841. * time specified in milliseconds with a resolution of one tick period.
  842. *
  843. * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the
  844. * task was last unblocked. The variable must be initialised with the current time
  845. * prior to its first use (see the example below). Following this the variable is
  846. * automatically updated within xTaskDelayUntil ().
  847. *
  848. * @param xTimeIncrement The cycle time period. The task will be unblocked at
  849. * time *pxPreviousWakeTime + xTimeIncrement. Calling xTaskDelayUntil with the
  850. * same xTimeIncrement parameter value will cause the task to execute with
  851. * a fixed interface period.
  852. *
  853. * @return Value which can be used to check whether the task was actually delayed.
  854. * Will be pdTRUE if the task way delayed and pdFALSE otherwise. A task will not
  855. * be delayed if the next expected wake time is in the past.
  856. *
  857. * Example usage:
  858. * @code{c}
  859. * // Perform an action every 10 ticks.
  860. * void vTaskFunction( void * pvParameters )
  861. * {
  862. * TickType_t xLastWakeTime;
  863. * const TickType_t xFrequency = 10;
  864. * BaseType_t xWasDelayed;
  865. *
  866. * // Initialise the xLastWakeTime variable with the current time.
  867. * xLastWakeTime = xTaskGetTickCount ();
  868. * for( ;; )
  869. * {
  870. * // Wait for the next cycle.
  871. * xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency );
  872. *
  873. * // Perform action here. xWasDelayed value can be used to determine
  874. * // whether a deadline was missed if the code here took too long.
  875. * }
  876. * }
  877. * @endcode
  878. * \defgroup xTaskDelayUntil xTaskDelayUntil
  879. * \ingroup TaskCtrl
  880. */
  881. BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
  882. const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
  883. /*
  884. * vTaskDelayUntil() is the older version of xTaskDelayUntil() and does not
  885. * return a value.
  886. */
  887. #define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ) \
  888. do { \
  889. ( void ) xTaskDelayUntil( ( pxPreviousWakeTime ), ( xTimeIncrement ) ); \
  890. } while( 0 )
  891. /**
  892. * task. h
  893. * @code{c}
  894. * BaseType_t xTaskAbortDelay( TaskHandle_t xTask );
  895. * @endcode
  896. *
  897. * INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this
  898. * function to be available.
  899. *
  900. * A task will enter the Blocked state when it is waiting for an event. The
  901. * event it is waiting for can be a temporal event (waiting for a time), such
  902. * as when vTaskDelay() is called, or an event on an object, such as when
  903. * xQueueReceive() or ulTaskNotifyTake() is called. If the handle of a task
  904. * that is in the Blocked state is used in a call to xTaskAbortDelay() then the
  905. * task will leave the Blocked state, and return from whichever function call
  906. * placed the task into the Blocked state.
  907. *
  908. * There is no 'FromISR' version of this function as an interrupt would need to
  909. * know which object a task was blocked on in order to know which actions to
  910. * take. For example, if the task was blocked on a queue the interrupt handler
  911. * would then need to know if the queue was locked.
  912. *
  913. * @param xTask The handle of the task to remove from the Blocked state.
  914. *
  915. * @return If the task referenced by xTask was not in the Blocked state then
  916. * pdFAIL is returned. Otherwise pdPASS is returned.
  917. *
  918. * \defgroup xTaskAbortDelay xTaskAbortDelay
  919. * \ingroup TaskCtrl
  920. */
  921. #if ( INCLUDE_xTaskAbortDelay == 1 )
  922. BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  923. #endif
  924. /**
  925. * task. h
  926. * @code{c}
  927. * UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask );
  928. * @endcode
  929. *
  930. * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available.
  931. * See the configuration section for more information.
  932. *
  933. * Obtain the priority of any task.
  934. *
  935. * @param xTask Handle of the task to be queried. Passing a NULL
  936. * handle results in the priority of the calling task being returned.
  937. *
  938. * @return The priority of xTask.
  939. *
  940. * Example usage:
  941. * @code{c}
  942. * void vAFunction( void )
  943. * {
  944. * TaskHandle_t xHandle;
  945. *
  946. * // Create a task, storing the handle.
  947. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  948. *
  949. * // ...
  950. *
  951. * // Use the handle to obtain the priority of the created task.
  952. * // It was created with tskIDLE_PRIORITY, but may have changed
  953. * // it itself.
  954. * if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
  955. * {
  956. * // The task has changed it's priority.
  957. * }
  958. *
  959. * // ...
  960. *
  961. * // Is our priority higher than the created task?
  962. * if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
  963. * {
  964. * // Our priority (obtained using NULL handle) is higher.
  965. * }
  966. * }
  967. * @endcode
  968. * \defgroup uxTaskPriorityGet uxTaskPriorityGet
  969. * \ingroup TaskCtrl
  970. */
  971. UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  972. /**
  973. * task. h
  974. * @code{c}
  975. * UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask );
  976. * @endcode
  977. *
  978. * A version of uxTaskPriorityGet() that can be used from an ISR.
  979. */
  980. UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  981. /**
  982. * task. h
  983. * @code{c}
  984. * UBaseType_t uxTaskBasePriorityGet( const TaskHandle_t xTask );
  985. * @endcode
  986. *
  987. * INCLUDE_uxTaskPriorityGet and configUSE_MUTEXES must be defined as 1 for this
  988. * function to be available. See the configuration section for more information.
  989. *
  990. * Obtain the base priority of any task.
  991. *
  992. * @param xTask Handle of the task to be queried. Passing a NULL
  993. * handle results in the base priority of the calling task being returned.
  994. *
  995. * @return The base priority of xTask.
  996. *
  997. * \defgroup uxTaskPriorityGet uxTaskBasePriorityGet
  998. * \ingroup TaskCtrl
  999. */
  1000. UBaseType_t uxTaskBasePriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  1001. /**
  1002. * task. h
  1003. * @code{c}
  1004. * UBaseType_t uxTaskBasePriorityGetFromISR( const TaskHandle_t xTask );
  1005. * @endcode
  1006. *
  1007. * A version of uxTaskBasePriorityGet() that can be used from an ISR.
  1008. */
  1009. UBaseType_t uxTaskBasePriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  1010. /**
  1011. * task. h
  1012. * @code{c}
  1013. * eTaskState eTaskGetState( TaskHandle_t xTask );
  1014. * @endcode
  1015. *
  1016. * INCLUDE_eTaskGetState must be defined as 1 for this function to be available.
  1017. * See the configuration section for more information.
  1018. *
  1019. * Obtain the state of any task. States are encoded by the eTaskState
  1020. * enumerated type.
  1021. *
  1022. * @param xTask Handle of the task to be queried.
  1023. *
  1024. * @return The state of xTask at the time the function was called. Note the
  1025. * state of the task might change between the function being called, and the
  1026. * functions return value being tested by the calling task.
  1027. */
  1028. #if ( ( INCLUDE_eTaskGetState == 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_xTaskAbortDelay == 1 ) )
  1029. eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  1030. #endif
  1031. /**
  1032. * task. h
  1033. * @code{c}
  1034. * void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState );
  1035. * @endcode
  1036. *
  1037. * configUSE_TRACE_FACILITY must be defined as 1 for this function to be
  1038. * available. See the configuration section for more information.
  1039. *
  1040. * Populates a TaskStatus_t structure with information about a task.
  1041. *
  1042. * @param xTask Handle of the task being queried. If xTask is NULL then
  1043. * information will be returned about the calling task.
  1044. *
  1045. * @param pxTaskStatus A pointer to the TaskStatus_t structure that will be
  1046. * filled with information about the task referenced by the handle passed using
  1047. * the xTask parameter.
  1048. *
  1049. * @param xGetFreeStackSpace The TaskStatus_t structure contains a member to report
  1050. * the stack high water mark of the task being queried. Calculating the stack
  1051. * high water mark takes a relatively long time, and can make the system
  1052. * temporarily unresponsive - so the xGetFreeStackSpace parameter is provided to
  1053. * allow the high water mark checking to be skipped. The high watermark value
  1054. * will only be written to the TaskStatus_t structure if xGetFreeStackSpace is
  1055. * not set to pdFALSE;
  1056. *
  1057. * @param eState The TaskStatus_t structure contains a member to report the
  1058. * state of the task being queried. Obtaining the task state is not as fast as
  1059. * a simple assignment - so the eState parameter is provided to allow the state
  1060. * information to be omitted from the TaskStatus_t structure. To obtain state
  1061. * information then set eState to eInvalid - otherwise the value passed in
  1062. * eState will be reported as the task state in the TaskStatus_t structure.
  1063. *
  1064. * Example usage:
  1065. * @code{c}
  1066. * void vAFunction( void )
  1067. * {
  1068. * TaskHandle_t xHandle;
  1069. * TaskStatus_t xTaskDetails;
  1070. *
  1071. * // Obtain the handle of a task from its name.
  1072. * xHandle = xTaskGetHandle( "Task_Name" );
  1073. *
  1074. * // Check the handle is not NULL.
  1075. * configASSERT( xHandle );
  1076. *
  1077. * // Use the handle to obtain further information about the task.
  1078. * vTaskGetInfo( xHandle,
  1079. * &xTaskDetails,
  1080. * pdTRUE, // Include the high water mark in xTaskDetails.
  1081. * eInvalid ); // Include the task state in xTaskDetails.
  1082. * }
  1083. * @endcode
  1084. * \defgroup vTaskGetInfo vTaskGetInfo
  1085. * \ingroup TaskCtrl
  1086. */
  1087. #if ( configUSE_TRACE_FACILITY == 1 )
  1088. void vTaskGetInfo( TaskHandle_t xTask,
  1089. TaskStatus_t * pxTaskStatus,
  1090. BaseType_t xGetFreeStackSpace,
  1091. eTaskState eState ) PRIVILEGED_FUNCTION;
  1092. #endif
  1093. /**
  1094. * task. h
  1095. * @code{c}
  1096. * void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );
  1097. * @endcode
  1098. *
  1099. * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.
  1100. * See the configuration section for more information.
  1101. *
  1102. * Set the priority of any task.
  1103. *
  1104. * A context switch will occur before the function returns if the priority
  1105. * being set is higher than the currently executing task.
  1106. *
  1107. * @param xTask Handle to the task for which the priority is being set.
  1108. * Passing a NULL handle results in the priority of the calling task being set.
  1109. *
  1110. * @param uxNewPriority The priority to which the task will be set.
  1111. *
  1112. * Example usage:
  1113. * @code{c}
  1114. * void vAFunction( void )
  1115. * {
  1116. * TaskHandle_t xHandle;
  1117. *
  1118. * // Create a task, storing the handle.
  1119. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  1120. *
  1121. * // ...
  1122. *
  1123. * // Use the handle to raise the priority of the created task.
  1124. * vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
  1125. *
  1126. * // ...
  1127. *
  1128. * // Use a NULL handle to raise our priority to the same value.
  1129. * vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
  1130. * }
  1131. * @endcode
  1132. * \defgroup vTaskPrioritySet vTaskPrioritySet
  1133. * \ingroup TaskCtrl
  1134. */
  1135. void vTaskPrioritySet( TaskHandle_t xTask,
  1136. UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
  1137. /**
  1138. * task. h
  1139. * @code{c}
  1140. * void vTaskSuspend( TaskHandle_t xTaskToSuspend );
  1141. * @endcode
  1142. *
  1143. * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
  1144. * See the configuration section for more information.
  1145. *
  1146. * Suspend any task. When suspended a task will never get any microcontroller
  1147. * processing time, no matter what its priority.
  1148. *
  1149. * Calls to vTaskSuspend are not accumulative -
  1150. * i.e. calling vTaskSuspend () twice on the same task still only requires one
  1151. * call to vTaskResume () to ready the suspended task.
  1152. *
  1153. * @param xTaskToSuspend Handle to the task being suspended. Passing a NULL
  1154. * handle will cause the calling task to be suspended.
  1155. *
  1156. * Example usage:
  1157. * @code{c}
  1158. * void vAFunction( void )
  1159. * {
  1160. * TaskHandle_t xHandle;
  1161. *
  1162. * // Create a task, storing the handle.
  1163. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  1164. *
  1165. * // ...
  1166. *
  1167. * // Use the handle to suspend the created task.
  1168. * vTaskSuspend( xHandle );
  1169. *
  1170. * // ...
  1171. *
  1172. * // The created task will not run during this period, unless
  1173. * // another task calls vTaskResume( xHandle ).
  1174. *
  1175. * //...
  1176. *
  1177. *
  1178. * // Suspend ourselves.
  1179. * vTaskSuspend( NULL );
  1180. *
  1181. * // We cannot get here unless another task calls vTaskResume
  1182. * // with our handle as the parameter.
  1183. * }
  1184. * @endcode
  1185. * \defgroup vTaskSuspend vTaskSuspend
  1186. * \ingroup TaskCtrl
  1187. */
  1188. void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION;
  1189. /**
  1190. * task. h
  1191. * @code{c}
  1192. * void vTaskResume( TaskHandle_t xTaskToResume );
  1193. * @endcode
  1194. *
  1195. * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
  1196. * See the configuration section for more information.
  1197. *
  1198. * Resumes a suspended task.
  1199. *
  1200. * A task that has been suspended by one or more calls to vTaskSuspend ()
  1201. * will be made available for running again by a single call to
  1202. * vTaskResume ().
  1203. *
  1204. * @param xTaskToResume Handle to the task being readied.
  1205. *
  1206. * Example usage:
  1207. * @code{c}
  1208. * void vAFunction( void )
  1209. * {
  1210. * TaskHandle_t xHandle;
  1211. *
  1212. * // Create a task, storing the handle.
  1213. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  1214. *
  1215. * // ...
  1216. *
  1217. * // Use the handle to suspend the created task.
  1218. * vTaskSuspend( xHandle );
  1219. *
  1220. * // ...
  1221. *
  1222. * // The created task will not run during this period, unless
  1223. * // another task calls vTaskResume( xHandle ).
  1224. *
  1225. * //...
  1226. *
  1227. *
  1228. * // Resume the suspended task ourselves.
  1229. * vTaskResume( xHandle );
  1230. *
  1231. * // The created task will once again get microcontroller processing
  1232. * // time in accordance with its priority within the system.
  1233. * }
  1234. * @endcode
  1235. * \defgroup vTaskResume vTaskResume
  1236. * \ingroup TaskCtrl
  1237. */
  1238. void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
  1239. /**
  1240. * task. h
  1241. * @code{c}
  1242. * void xTaskResumeFromISR( TaskHandle_t xTaskToResume );
  1243. * @endcode
  1244. *
  1245. * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be
  1246. * available. See the configuration section for more information.
  1247. *
  1248. * An implementation of vTaskResume() that can be called from within an ISR.
  1249. *
  1250. * A task that has been suspended by one or more calls to vTaskSuspend ()
  1251. * will be made available for running again by a single call to
  1252. * xTaskResumeFromISR ().
  1253. *
  1254. * xTaskResumeFromISR() should not be used to synchronise a task with an
  1255. * interrupt if there is a chance that the interrupt could arrive prior to the
  1256. * task being suspended - as this can lead to interrupts being missed. Use of a
  1257. * semaphore as a synchronisation mechanism would avoid this eventuality.
  1258. *
  1259. * @param xTaskToResume Handle to the task being readied.
  1260. *
  1261. * @return pdTRUE if resuming the task should result in a context switch,
  1262. * otherwise pdFALSE. This is used by the ISR to determine if a context switch
  1263. * may be required following the ISR.
  1264. *
  1265. * \defgroup vTaskResumeFromISR vTaskResumeFromISR
  1266. * \ingroup TaskCtrl
  1267. */
  1268. BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
  1269. #if ( configUSE_CORE_AFFINITY == 1 )
  1270. /**
  1271. * @brief Sets the core affinity mask for a task.
  1272. *
  1273. * It sets the cores on which a task can run. configUSE_CORE_AFFINITY must
  1274. * be defined as 1 for this function to be available.
  1275. *
  1276. * @param xTask The handle of the task to set the core affinity mask for.
  1277. * Passing NULL will set the core affinity mask for the calling task.
  1278. *
  1279. * @param uxCoreAffinityMask A bitwise value that indicates the cores on
  1280. * which the task can run. Cores are numbered from 0 to configNUMBER_OF_CORES - 1.
  1281. * For example, to ensure that a task can run on core 0 and core 1, set
  1282. * uxCoreAffinityMask to 0x03.
  1283. *
  1284. * Example usage:
  1285. *
  1286. * // The function that creates task.
  1287. * void vAFunction( void )
  1288. * {
  1289. * TaskHandle_t xHandle;
  1290. * UBaseType_t uxCoreAffinityMask;
  1291. *
  1292. * // Create a task, storing the handle.
  1293. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &( xHandle ) );
  1294. *
  1295. * // Define the core affinity mask such that this task can only run
  1296. * // on core 0 and core 2.
  1297. * uxCoreAffinityMask = ( ( 1 << 0 ) | ( 1 << 2 ) );
  1298. *
  1299. * //Set the core affinity mask for the task.
  1300. * vTaskCoreAffinitySet( xHandle, uxCoreAffinityMask );
  1301. * }
  1302. */
  1303. void vTaskCoreAffinitySet( const TaskHandle_t xTask,
  1304. UBaseType_t uxCoreAffinityMask );
  1305. #endif
  1306. #if ( ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
  1307. /**
  1308. * @brief Gets the core affinity mask for a task.
  1309. *
  1310. * configUSE_CORE_AFFINITY must be defined as 1 for this function to be
  1311. * available.
  1312. *
  1313. * @param xTask The handle of the task to get the core affinity mask for.
  1314. * Passing NULL will get the core affinity mask for the calling task.
  1315. *
  1316. * @return The core affinity mask which is a bitwise value that indicates
  1317. * the cores on which a task can run. Cores are numbered from 0 to
  1318. * configNUMBER_OF_CORES - 1. For example, if a task can run on core 0 and core 1,
  1319. * the core affinity mask is 0x03.
  1320. *
  1321. * Example usage:
  1322. *
  1323. * // Task handle of the networking task - it is populated elsewhere.
  1324. * TaskHandle_t xNetworkingTaskHandle;
  1325. *
  1326. * void vAFunction( void )
  1327. * {
  1328. * TaskHandle_t xHandle;
  1329. * UBaseType_t uxNetworkingCoreAffinityMask;
  1330. *
  1331. * // Create a task, storing the handle.
  1332. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &( xHandle ) );
  1333. *
  1334. * //Get the core affinity mask for the networking task.
  1335. * uxNetworkingCoreAffinityMask = vTaskCoreAffinityGet( xNetworkingTaskHandle );
  1336. *
  1337. * // Here is a hypothetical scenario, just for the example. Assume that we
  1338. * // have 2 cores - Core 0 and core 1. We want to pin the application task to
  1339. * // the core different than the networking task to ensure that the
  1340. * // application task does not interfere with networking.
  1341. * if( ( uxNetworkingCoreAffinityMask & ( 1 << 0 ) ) != 0 )
  1342. * {
  1343. * // The networking task can run on core 0, pin our task to core 1.
  1344. * vTaskCoreAffinitySet( xHandle, ( 1 << 1 ) );
  1345. * }
  1346. * else
  1347. * {
  1348. * // Otherwise, pin our task to core 0.
  1349. * vTaskCoreAffinitySet( xHandle, ( 1 << 0 ) );
  1350. * }
  1351. * }
  1352. */
  1353. UBaseType_t vTaskCoreAffinityGet( ConstTaskHandle_t xTask );
  1354. #endif
  1355. #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
  1356. /**
  1357. * @brief Disables preemption for a task.
  1358. *
  1359. * @param xTask The handle of the task to disable preemption. Passing NULL
  1360. * disables preemption for the calling task.
  1361. *
  1362. * Example usage:
  1363. *
  1364. * void vTaskCode( void *pvParameters )
  1365. * {
  1366. * // Silence warnings about unused parameters.
  1367. * ( void ) pvParameters;
  1368. *
  1369. * for( ;; )
  1370. * {
  1371. * // ... Perform some function here.
  1372. *
  1373. * // Disable preemption for this task.
  1374. * vTaskPreemptionDisable( NULL );
  1375. *
  1376. * // The task will not be preempted when it is executing in this portion ...
  1377. *
  1378. * // ... until the preemption is enabled again.
  1379. * vTaskPreemptionEnable( NULL );
  1380. *
  1381. * // The task can be preempted when it is executing in this portion.
  1382. * }
  1383. * }
  1384. */
  1385. void vTaskPreemptionDisable( const TaskHandle_t xTask );
  1386. #endif
  1387. #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
  1388. /**
  1389. * @brief Enables preemption for a task.
  1390. *
  1391. * @param xTask The handle of the task to enable preemption. Passing NULL
  1392. * enables preemption for the calling task.
  1393. *
  1394. * Example usage:
  1395. *
  1396. * void vTaskCode( void *pvParameters )
  1397. * {
  1398. * // Silence warnings about unused parameters.
  1399. * ( void ) pvParameters;
  1400. *
  1401. * for( ;; )
  1402. * {
  1403. * // ... Perform some function here.
  1404. *
  1405. * // Disable preemption for this task.
  1406. * vTaskPreemptionDisable( NULL );
  1407. *
  1408. * // The task will not be preempted when it is executing in this portion ...
  1409. *
  1410. * // ... until the preemption is enabled again.
  1411. * vTaskPreemptionEnable( NULL );
  1412. *
  1413. * // The task can be preempted when it is executing in this portion.
  1414. * }
  1415. * }
  1416. */
  1417. void vTaskPreemptionEnable( const TaskHandle_t xTask );
  1418. #endif
  1419. /*-----------------------------------------------------------
  1420. * SCHEDULER CONTROL
  1421. *----------------------------------------------------------*/
  1422. /**
  1423. * task. h
  1424. * @code{c}
  1425. * void vTaskStartScheduler( void );
  1426. * @endcode
  1427. *
  1428. * Starts the real time kernel tick processing. After calling the kernel
  1429. * has control over which tasks are executed and when.
  1430. *
  1431. * See the demo application file main.c for an example of creating
  1432. * tasks and starting the kernel.
  1433. *
  1434. * Example usage:
  1435. * @code{c}
  1436. * void vAFunction( void )
  1437. * {
  1438. * // Create at least one task before starting the kernel.
  1439. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
  1440. *
  1441. * // Start the real time kernel with preemption.
  1442. * vTaskStartScheduler ();
  1443. *
  1444. * // Will not get here unless a task calls vTaskEndScheduler ()
  1445. * }
  1446. * @endcode
  1447. *
  1448. * \defgroup vTaskStartScheduler vTaskStartScheduler
  1449. * \ingroup SchedulerControl
  1450. */
  1451. void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;
  1452. /**
  1453. * task. h
  1454. * @code{c}
  1455. * void vTaskEndScheduler( void );
  1456. * @endcode
  1457. *
  1458. * NOTE: At the time of writing only the x86 real mode port, which runs on a PC
  1459. * in place of DOS, implements this function.
  1460. *
  1461. * Stops the real time kernel tick. All created tasks will be automatically
  1462. * deleted and multitasking (either preemptive or cooperative) will
  1463. * stop. Execution then resumes from the point where vTaskStartScheduler ()
  1464. * was called, as if vTaskStartScheduler () had just returned.
  1465. *
  1466. * See the demo application file main. c in the demo/PC directory for an
  1467. * example that uses vTaskEndScheduler ().
  1468. *
  1469. * vTaskEndScheduler () requires an exit function to be defined within the
  1470. * portable layer (see vPortEndScheduler () in port. c for the PC port). This
  1471. * performs hardware specific operations such as stopping the kernel tick.
  1472. *
  1473. * vTaskEndScheduler () will cause all of the resources allocated by the
  1474. * kernel to be freed - but will not free resources allocated by application
  1475. * tasks.
  1476. *
  1477. * Example usage:
  1478. * @code{c}
  1479. * void vTaskCode( void * pvParameters )
  1480. * {
  1481. * for( ;; )
  1482. * {
  1483. * // Task code goes here.
  1484. *
  1485. * // At some point we want to end the real time kernel processing
  1486. * // so call ...
  1487. * vTaskEndScheduler ();
  1488. * }
  1489. * }
  1490. *
  1491. * void vAFunction( void )
  1492. * {
  1493. * // Create at least one task before starting the kernel.
  1494. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
  1495. *
  1496. * // Start the real time kernel with preemption.
  1497. * vTaskStartScheduler ();
  1498. *
  1499. * // Will only get here when the vTaskCode () task has called
  1500. * // vTaskEndScheduler (). When we get here we are back to single task
  1501. * // execution.
  1502. * }
  1503. * @endcode
  1504. *
  1505. * \defgroup vTaskEndScheduler vTaskEndScheduler
  1506. * \ingroup SchedulerControl
  1507. */
  1508. void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;
  1509. /**
  1510. * task. h
  1511. * @code{c}
  1512. * void vTaskSuspendAll( void );
  1513. * @endcode
  1514. *
  1515. * Suspends the scheduler without disabling interrupts. Context switches will
  1516. * not occur while the scheduler is suspended.
  1517. *
  1518. * After calling vTaskSuspendAll () the calling task will continue to execute
  1519. * without risk of being swapped out until a call to xTaskResumeAll () has been
  1520. * made.
  1521. *
  1522. * API functions that have the potential to cause a context switch (for example,
  1523. * xTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler
  1524. * is suspended.
  1525. *
  1526. * Example usage:
  1527. * @code{c}
  1528. * void vTask1( void * pvParameters )
  1529. * {
  1530. * for( ;; )
  1531. * {
  1532. * // Task code goes here.
  1533. *
  1534. * // ...
  1535. *
  1536. * // At some point the task wants to perform a long operation during
  1537. * // which it does not want to get swapped out. It cannot use
  1538. * // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
  1539. * // operation may cause interrupts to be missed - including the
  1540. * // ticks.
  1541. *
  1542. * // Prevent the real time kernel swapping out the task.
  1543. * vTaskSuspendAll ();
  1544. *
  1545. * // Perform the operation here. There is no need to use critical
  1546. * // sections as we have all the microcontroller processing time.
  1547. * // During this time interrupts will still operate and the kernel
  1548. * // tick count will be maintained.
  1549. *
  1550. * // ...
  1551. *
  1552. * // The operation is complete. Restart the kernel.
  1553. * xTaskResumeAll ();
  1554. * }
  1555. * }
  1556. * @endcode
  1557. * \defgroup vTaskSuspendAll vTaskSuspendAll
  1558. * \ingroup SchedulerControl
  1559. */
  1560. void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;
  1561. /**
  1562. * task. h
  1563. * @code{c}
  1564. * BaseType_t xTaskResumeAll( void );
  1565. * @endcode
  1566. *
  1567. * Resumes scheduler activity after it was suspended by a call to
  1568. * vTaskSuspendAll().
  1569. *
  1570. * xTaskResumeAll() only resumes the scheduler. It does not unsuspend tasks
  1571. * that were previously suspended by a call to vTaskSuspend().
  1572. *
  1573. * @return If resuming the scheduler caused a context switch then pdTRUE is
  1574. * returned, otherwise pdFALSE is returned.
  1575. *
  1576. * Example usage:
  1577. * @code{c}
  1578. * void vTask1( void * pvParameters )
  1579. * {
  1580. * for( ;; )
  1581. * {
  1582. * // Task code goes here.
  1583. *
  1584. * // ...
  1585. *
  1586. * // At some point the task wants to perform a long operation during
  1587. * // which it does not want to get swapped out. It cannot use
  1588. * // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
  1589. * // operation may cause interrupts to be missed - including the
  1590. * // ticks.
  1591. *
  1592. * // Prevent the real time kernel swapping out the task.
  1593. * vTaskSuspendAll ();
  1594. *
  1595. * // Perform the operation here. There is no need to use critical
  1596. * // sections as we have all the microcontroller processing time.
  1597. * // During this time interrupts will still operate and the real
  1598. * // time kernel tick count will be maintained.
  1599. *
  1600. * // ...
  1601. *
  1602. * // The operation is complete. Restart the kernel. We want to force
  1603. * // a context switch - but there is no point if resuming the scheduler
  1604. * // caused a context switch already.
  1605. * if( !xTaskResumeAll () )
  1606. * {
  1607. * taskYIELD ();
  1608. * }
  1609. * }
  1610. * }
  1611. * @endcode
  1612. * \defgroup xTaskResumeAll xTaskResumeAll
  1613. * \ingroup SchedulerControl
  1614. */
  1615. BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION;
  1616. /*-----------------------------------------------------------
  1617. * TASK UTILITIES
  1618. *----------------------------------------------------------*/
  1619. /**
  1620. * task. h
  1621. * @code{c}
  1622. * TickType_t xTaskGetTickCount( void );
  1623. * @endcode
  1624. *
  1625. * @return The count of ticks since vTaskStartScheduler was called.
  1626. *
  1627. * \defgroup xTaskGetTickCount xTaskGetTickCount
  1628. * \ingroup TaskUtils
  1629. */
  1630. TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;
  1631. /**
  1632. * task. h
  1633. * @code{c}
  1634. * TickType_t xTaskGetTickCountFromISR( void );
  1635. * @endcode
  1636. *
  1637. * @return The count of ticks since vTaskStartScheduler was called.
  1638. *
  1639. * This is a version of xTaskGetTickCount() that is safe to be called from an
  1640. * ISR - provided that TickType_t is the natural word size of the
  1641. * microcontroller being used or interrupt nesting is either not supported or
  1642. * not being used.
  1643. *
  1644. * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR
  1645. * \ingroup TaskUtils
  1646. */
  1647. TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION;
  1648. /**
  1649. * task. h
  1650. * @code{c}
  1651. * uint16_t uxTaskGetNumberOfTasks( void );
  1652. * @endcode
  1653. *
  1654. * @return The number of tasks that the real time kernel is currently managing.
  1655. * This includes all ready, blocked and suspended tasks. A task that
  1656. * has been deleted but not yet freed by the idle task will also be
  1657. * included in the count.
  1658. *
  1659. * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks
  1660. * \ingroup TaskUtils
  1661. */
  1662. UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;
  1663. /**
  1664. * task. h
  1665. * @code{c}
  1666. * char *pcTaskGetName( TaskHandle_t xTaskToQuery );
  1667. * @endcode
  1668. *
  1669. * @return The text (human readable) name of the task referenced by the handle
  1670. * xTaskToQuery. A task can query its own name by either passing in its own
  1671. * handle, or by setting xTaskToQuery to NULL.
  1672. *
  1673. * \defgroup pcTaskGetName pcTaskGetName
  1674. * \ingroup TaskUtils
  1675. */
  1676. char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION;
  1677. /**
  1678. * task. h
  1679. * @code{c}
  1680. * TaskHandle_t xTaskGetHandle( const char *pcNameToQuery );
  1681. * @endcode
  1682. *
  1683. * NOTE: This function takes a relatively long time to complete and should be
  1684. * used sparingly.
  1685. *
  1686. * @return The handle of the task that has the human readable name pcNameToQuery.
  1687. * NULL is returned if no matching name is found. INCLUDE_xTaskGetHandle
  1688. * must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available.
  1689. *
  1690. * \defgroup pcTaskGetHandle pcTaskGetHandle
  1691. * \ingroup TaskUtils
  1692. */
  1693. #if ( INCLUDE_xTaskGetHandle == 1 )
  1694. TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION;
  1695. #endif
  1696. /**
  1697. * task. h
  1698. * @code{c}
  1699. * BaseType_t xTaskGetStaticBuffers( TaskHandle_t xTask,
  1700. * StackType_t ** ppuxStackBuffer,
  1701. * StaticTask_t ** ppxTaskBuffer );
  1702. * @endcode
  1703. *
  1704. * Retrieve pointers to a statically created task's data structure
  1705. * buffer and stack buffer. These are the same buffers that are supplied
  1706. * at the time of creation.
  1707. *
  1708. * @param xTask The task for which to retrieve the buffers.
  1709. *
  1710. * @param ppuxStackBuffer Used to return a pointer to the task's stack buffer.
  1711. *
  1712. * @param ppxTaskBuffer Used to return a pointer to the task's data structure
  1713. * buffer.
  1714. *
  1715. * @return pdTRUE if buffers were retrieved, pdFALSE otherwise.
  1716. *
  1717. * \defgroup xTaskGetStaticBuffers xTaskGetStaticBuffers
  1718. * \ingroup TaskUtils
  1719. */
  1720. #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
  1721. BaseType_t xTaskGetStaticBuffers( TaskHandle_t xTask,
  1722. StackType_t ** ppuxStackBuffer,
  1723. StaticTask_t ** ppxTaskBuffer ) PRIVILEGED_FUNCTION;
  1724. #endif /* configSUPPORT_STATIC_ALLOCATION */
  1725. /**
  1726. * task.h
  1727. * @code{c}
  1728. * UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );
  1729. * @endcode
  1730. *
  1731. * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for
  1732. * this function to be available.
  1733. *
  1734. * Returns the high water mark of the stack associated with xTask. That is,
  1735. * the minimum free stack space there has been (in words, so on a 32 bit machine
  1736. * a value of 1 means 4 bytes) since the task started. The smaller the returned
  1737. * number the closer the task has come to overflowing its stack.
  1738. *
  1739. * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
  1740. * same except for their return type. Using configSTACK_DEPTH_TYPE allows the
  1741. * user to determine the return type. It gets around the problem of the value
  1742. * overflowing on 8-bit types without breaking backward compatibility for
  1743. * applications that expect an 8-bit return type.
  1744. *
  1745. * @param xTask Handle of the task associated with the stack to be checked.
  1746. * Set xTask to NULL to check the stack of the calling task.
  1747. *
  1748. * @return The smallest amount of free stack space there has been (in words, so
  1749. * actual spaces on the stack rather than bytes) since the task referenced by
  1750. * xTask was created.
  1751. */
  1752. #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
  1753. UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  1754. #endif
  1755. /**
  1756. * task.h
  1757. * @code{c}
  1758. * configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask );
  1759. * @endcode
  1760. *
  1761. * INCLUDE_uxTaskGetStackHighWaterMark2 must be set to 1 in FreeRTOSConfig.h for
  1762. * this function to be available.
  1763. *
  1764. * Returns the high water mark of the stack associated with xTask. That is,
  1765. * the minimum free stack space there has been (in words, so on a 32 bit machine
  1766. * a value of 1 means 4 bytes) since the task started. The smaller the returned
  1767. * number the closer the task has come to overflowing its stack.
  1768. *
  1769. * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
  1770. * same except for their return type. Using configSTACK_DEPTH_TYPE allows the
  1771. * user to determine the return type. It gets around the problem of the value
  1772. * overflowing on 8-bit types without breaking backward compatibility for
  1773. * applications that expect an 8-bit return type.
  1774. *
  1775. * @param xTask Handle of the task associated with the stack to be checked.
  1776. * Set xTask to NULL to check the stack of the calling task.
  1777. *
  1778. * @return The smallest amount of free stack space there has been (in words, so
  1779. * actual spaces on the stack rather than bytes) since the task referenced by
  1780. * xTask was created.
  1781. */
  1782. #if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 )
  1783. configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  1784. #endif
  1785. /* When using trace macros it is sometimes necessary to include task.h before
  1786. * FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,
  1787. * so the following two prototypes will cause a compilation error. This can be
  1788. * fixed by simply guarding against the inclusion of these two prototypes unless
  1789. * they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration
  1790. * constant. */
  1791. #ifdef configUSE_APPLICATION_TASK_TAG
  1792. #if configUSE_APPLICATION_TASK_TAG == 1
  1793. /**
  1794. * task.h
  1795. * @code{c}
  1796. * void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );
  1797. * @endcode
  1798. *
  1799. * Sets pxHookFunction to be the task hook function used by the task xTask.
  1800. * Passing xTask as NULL has the effect of setting the calling tasks hook
  1801. * function.
  1802. */
  1803. void vTaskSetApplicationTaskTag( TaskHandle_t xTask,
  1804. TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION;
  1805. /**
  1806. * task.h
  1807. * @code{c}
  1808. * void xTaskGetApplicationTaskTag( TaskHandle_t xTask );
  1809. * @endcode
  1810. *
  1811. * Returns the pxHookFunction value assigned to the task xTask. Do not
  1812. * call from an interrupt service routine - call
  1813. * xTaskGetApplicationTaskTagFromISR() instead.
  1814. */
  1815. TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  1816. /**
  1817. * task.h
  1818. * @code{c}
  1819. * void xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );
  1820. * @endcode
  1821. *
  1822. * Returns the pxHookFunction value assigned to the task xTask. Can
  1823. * be called from an interrupt service routine.
  1824. */
  1825. TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  1826. #endif /* configUSE_APPLICATION_TASK_TAG ==1 */
  1827. #endif /* ifdef configUSE_APPLICATION_TASK_TAG */
  1828. #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
  1829. /* Each task contains an array of pointers that is dimensioned by the
  1830. * configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. The
  1831. * kernel does not use the pointers itself, so the application writer can use
  1832. * the pointers for any purpose they wish. The following two functions are
  1833. * used to set and query a pointer respectively. */
  1834. void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet,
  1835. BaseType_t xIndex,
  1836. void * pvValue ) PRIVILEGED_FUNCTION;
  1837. void * pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery,
  1838. BaseType_t xIndex ) PRIVILEGED_FUNCTION;
  1839. #endif
  1840. #if ( configCHECK_FOR_STACK_OVERFLOW > 0 )
  1841. /**
  1842. * task.h
  1843. * @code{c}
  1844. * void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName);
  1845. * @endcode
  1846. *
  1847. * The application stack overflow hook is called when a stack overflow is detected for a task.
  1848. *
  1849. * Details on stack overflow detection can be found here: https://www.FreeRTOS.org/Stacks-and-stack-overflow-checking.html
  1850. *
  1851. * @param xTask the task that just exceeded its stack boundaries.
  1852. * @param pcTaskName A character string containing the name of the offending task.
  1853. */
  1854. /* MISRA Ref 8.6.1 [External linkage] */
  1855. /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-86 */
  1856. /* coverity[misra_c_2012_rule_8_6_violation] */
  1857. void vApplicationStackOverflowHook( TaskHandle_t xTask,
  1858. char * pcTaskName );
  1859. #endif
  1860. #if ( configUSE_IDLE_HOOK == 1 )
  1861. /**
  1862. * task.h
  1863. * @code{c}
  1864. * void vApplicationIdleHook( void );
  1865. * @endcode
  1866. *
  1867. * The application idle hook is called by the idle task.
  1868. * This allows the application designer to add background functionality without
  1869. * the overhead of a separate task.
  1870. * NOTE: vApplicationIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES, CALL A FUNCTION THAT MIGHT BLOCK.
  1871. */
  1872. /* MISRA Ref 8.6.1 [External linkage] */
  1873. /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-86 */
  1874. /* coverity[misra_c_2012_rule_8_6_violation] */
  1875. void vApplicationIdleHook( void );
  1876. #endif
  1877. #if ( configUSE_TICK_HOOK != 0 )
  1878. /**
  1879. * task.h
  1880. * @code{c}
  1881. * void vApplicationTickHook( void );
  1882. * @endcode
  1883. *
  1884. * This hook function is called in the system tick handler after any OS work is completed.
  1885. */
  1886. /* MISRA Ref 8.6.1 [External linkage] */
  1887. /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-86 */
  1888. /* coverity[misra_c_2012_rule_8_6_violation] */
  1889. void vApplicationTickHook( void );
  1890. #endif
  1891. #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
  1892. /**
  1893. * task.h
  1894. * @code{c}
  1895. * void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, configSTACK_DEPTH_TYPE * puxIdleTaskStackSize )
  1896. * @endcode
  1897. *
  1898. * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Idle Task TCB. This function is required when
  1899. * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION
  1900. *
  1901. * @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer
  1902. * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task
  1903. * @param puxIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
  1904. */
  1905. void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
  1906. StackType_t ** ppxIdleTaskStackBuffer,
  1907. configSTACK_DEPTH_TYPE * puxIdleTaskStackSize );
  1908. /**
  1909. * task.h
  1910. * @code{c}
  1911. * void vApplicationGetPassiveIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, configSTACK_DEPTH_TYPE * puxIdleTaskStackSize, BaseType_t xCoreID )
  1912. * @endcode
  1913. *
  1914. * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Idle Tasks TCB. This function is required when
  1915. * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION
  1916. *
  1917. * In the FreeRTOS SMP, there are a total of configNUMBER_OF_CORES idle tasks:
  1918. * 1. 1 Active idle task which does all the housekeeping.
  1919. * 2. ( configNUMBER_OF_CORES - 1 ) Passive idle tasks which do nothing.
  1920. * These idle tasks are created to ensure that each core has an idle task to run when
  1921. * no other task is available to run.
  1922. *
  1923. * The function vApplicationGetPassiveIdleTaskMemory is called with passive idle
  1924. * task index 0, 1 ... ( configNUMBER_OF_CORES - 2 ) to get memory for passive idle
  1925. * tasks.
  1926. *
  1927. * @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer
  1928. * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task
  1929. * @param puxIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
  1930. * @param xPassiveIdleTaskIndex The passive idle task index of the idle task buffer
  1931. */
  1932. #if ( configNUMBER_OF_CORES > 1 )
  1933. void vApplicationGetPassiveIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
  1934. StackType_t ** ppxIdleTaskStackBuffer,
  1935. configSTACK_DEPTH_TYPE * puxIdleTaskStackSize,
  1936. BaseType_t xPassiveIdleTaskIndex );
  1937. #endif /* #if ( configNUMBER_OF_CORES > 1 ) */
  1938. #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
  1939. /**
  1940. * task.h
  1941. * @code{c}
  1942. * BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );
  1943. * @endcode
  1944. *
  1945. * Calls the hook function associated with xTask. Passing xTask as NULL has
  1946. * the effect of calling the Running tasks (the calling task) hook function.
  1947. *
  1948. * pvParameter is passed to the hook function for the task to interpret as it
  1949. * wants. The return value is the value returned by the task hook function
  1950. * registered by the user.
  1951. */
  1952. #if ( configUSE_APPLICATION_TASK_TAG == 1 )
  1953. BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask,
  1954. void * pvParameter ) PRIVILEGED_FUNCTION;
  1955. #endif
  1956. /**
  1957. * xTaskGetIdleTaskHandle() is only available if
  1958. * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.
  1959. *
  1960. * In single-core FreeRTOS, this function simply returns the handle of the idle
  1961. * task. It is not valid to call xTaskGetIdleTaskHandle() before the scheduler
  1962. * has been started.
  1963. *
  1964. * In the FreeRTOS SMP, there are a total of configNUMBER_OF_CORES idle tasks:
  1965. * 1. 1 Active idle task which does all the housekeeping.
  1966. * 2. ( configNUMBER_OF_CORES - 1 ) Passive idle tasks which do nothing.
  1967. * These idle tasks are created to ensure that each core has an idle task to run when
  1968. * no other task is available to run. Call xTaskGetIdleTaskHandle() or
  1969. * xTaskGetIdleTaskHandleForCore() with xCoreID set to 0 to get the Active
  1970. * idle task handle. Call xTaskGetIdleTaskHandleForCore() with xCoreID set to
  1971. * 1,2 ... ( configNUMBER_OF_CORES - 1 ) to get the Passive idle task handles.
  1972. */
  1973. #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
  1974. #if ( configNUMBER_OF_CORES == 1 )
  1975. TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
  1976. #endif /* #if ( configNUMBER_OF_CORES == 1 ) */
  1977. TaskHandle_t xTaskGetIdleTaskHandleForCore( BaseType_t xCoreID ) PRIVILEGED_FUNCTION;
  1978. #endif /* #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) */
  1979. /**
  1980. * configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for
  1981. * uxTaskGetSystemState() to be available.
  1982. *
  1983. * uxTaskGetSystemState() populates an TaskStatus_t structure for each task in
  1984. * the system. TaskStatus_t structures contain, among other things, members
  1985. * for the task handle, task name, task priority, task state, and total amount
  1986. * of run time consumed by the task. See the TaskStatus_t structure
  1987. * definition in this file for the full member list.
  1988. *
  1989. * NOTE: This function is intended for debugging use only as its use results in
  1990. * the scheduler remaining suspended for an extended period.
  1991. *
  1992. * @param pxTaskStatusArray A pointer to an array of TaskStatus_t structures.
  1993. * The array must contain at least one TaskStatus_t structure for each task
  1994. * that is under the control of the RTOS. The number of tasks under the control
  1995. * of the RTOS can be determined using the uxTaskGetNumberOfTasks() API function.
  1996. *
  1997. * @param uxArraySize The size of the array pointed to by the pxTaskStatusArray
  1998. * parameter. The size is specified as the number of indexes in the array, or
  1999. * the number of TaskStatus_t structures contained in the array, not by the
  2000. * number of bytes in the array.
  2001. *
  2002. * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in
  2003. * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the
  2004. * total run time (as defined by the run time stats clock, see
  2005. * https://www.FreeRTOS.org/rtos-run-time-stats.html) since the target booted.
  2006. * pulTotalRunTime can be set to NULL to omit the total run time information.
  2007. *
  2008. * @return The number of TaskStatus_t structures that were populated by
  2009. * uxTaskGetSystemState(). This should equal the number returned by the
  2010. * uxTaskGetNumberOfTasks() API function, but will be zero if the value passed
  2011. * in the uxArraySize parameter was too small.
  2012. *
  2013. * Example usage:
  2014. * @code{c}
  2015. * // This example demonstrates how a human readable table of run time stats
  2016. * // information is generated from raw data provided by uxTaskGetSystemState().
  2017. * // The human readable table is written to pcWriteBuffer
  2018. * void vTaskGetRunTimeStats( char *pcWriteBuffer )
  2019. * {
  2020. * TaskStatus_t *pxTaskStatusArray;
  2021. * volatile UBaseType_t uxArraySize, x;
  2022. * configRUN_TIME_COUNTER_TYPE ulTotalRunTime, ulStatsAsPercentage;
  2023. *
  2024. * // Make sure the write buffer does not contain a string.
  2025. * pcWriteBuffer = 0x00;
  2026. *
  2027. * // Take a snapshot of the number of tasks in case it changes while this
  2028. * // function is executing.
  2029. * uxArraySize = uxTaskGetNumberOfTasks();
  2030. *
  2031. * // Allocate a TaskStatus_t structure for each task. An array could be
  2032. * // allocated statically at compile time.
  2033. * pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
  2034. *
  2035. * if( pxTaskStatusArray != NULL )
  2036. * {
  2037. * // Generate raw status information about each task.
  2038. * uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );
  2039. *
  2040. * // For percentage calculations.
  2041. * ulTotalRunTime /= 100U;
  2042. *
  2043. * // Avoid divide by zero errors.
  2044. * if( ulTotalRunTime > 0 )
  2045. * {
  2046. * // For each populated position in the pxTaskStatusArray array,
  2047. * // format the raw data as human readable ASCII data
  2048. * for( x = 0; x < uxArraySize; x++ )
  2049. * {
  2050. * // What percentage of the total run time has the task used?
  2051. * // This will always be rounded down to the nearest integer.
  2052. * // ulTotalRunTimeDiv100 has already been divided by 100.
  2053. * ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;
  2054. *
  2055. * if( ulStatsAsPercentage > 0U )
  2056. * {
  2057. * sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
  2058. * }
  2059. * else
  2060. * {
  2061. * // If the percentage is zero here then the task has
  2062. * // consumed less than 1% of the total run time.
  2063. * sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );
  2064. * }
  2065. *
  2066. * pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );
  2067. * }
  2068. * }
  2069. *
  2070. * // The array is no longer needed, free the memory it consumes.
  2071. * vPortFree( pxTaskStatusArray );
  2072. * }
  2073. * }
  2074. * @endcode
  2075. */
  2076. #if ( configUSE_TRACE_FACILITY == 1 )
  2077. UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray,
  2078. const UBaseType_t uxArraySize,
  2079. configRUN_TIME_COUNTER_TYPE * const pulTotalRunTime ) PRIVILEGED_FUNCTION;
  2080. #endif
  2081. /**
  2082. * task. h
  2083. * @code{c}
  2084. * void vTaskListTasks( char *pcWriteBuffer, size_t uxBufferLength );
  2085. * @endcode
  2086. *
  2087. * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must
  2088. * both be defined as 1 for this function to be available. See the
  2089. * configuration section of the FreeRTOS.org website for more information.
  2090. *
  2091. * NOTE 1: This function will disable interrupts for its duration. It is
  2092. * not intended for normal application runtime use but as a debug aid.
  2093. *
  2094. * Lists all the current tasks, along with their current state and stack
  2095. * usage high water mark.
  2096. *
  2097. * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or
  2098. * suspended ('S').
  2099. *
  2100. * PLEASE NOTE:
  2101. *
  2102. * This function is provided for convenience only, and is used by many of the
  2103. * demo applications. Do not consider it to be part of the scheduler.
  2104. *
  2105. * vTaskListTasks() calls uxTaskGetSystemState(), then formats part of the
  2106. * uxTaskGetSystemState() output into a human readable table that displays task:
  2107. * names, states, priority, stack usage and task number.
  2108. * Stack usage specified as the number of unused StackType_t words stack can hold
  2109. * on top of stack - not the number of bytes.
  2110. *
  2111. * vTaskListTasks() has a dependency on the snprintf() C library function that might
  2112. * bloat the code size, use a lot of stack, and provide different results on
  2113. * different platforms. An alternative, tiny, third party, and limited
  2114. * functionality implementation of snprintf() is provided in many of the
  2115. * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
  2116. * printf-stdarg.c does not provide a full snprintf() implementation!).
  2117. *
  2118. * It is recommended that production systems call uxTaskGetSystemState()
  2119. * directly to get access to raw stats data, rather than indirectly through a
  2120. * call to vTaskListTasks().
  2121. *
  2122. * @param pcWriteBuffer A buffer into which the above mentioned details
  2123. * will be written, in ASCII form. This buffer is assumed to be large
  2124. * enough to contain the generated report. Approximately 40 bytes per
  2125. * task should be sufficient.
  2126. *
  2127. * @param uxBufferLength Length of the pcWriteBuffer.
  2128. *
  2129. * \defgroup vTaskListTasks vTaskListTasks
  2130. * \ingroup TaskUtils
  2131. */
  2132. #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) )
  2133. void vTaskListTasks( char * pcWriteBuffer,
  2134. size_t uxBufferLength ) PRIVILEGED_FUNCTION;
  2135. #endif
  2136. /**
  2137. * task. h
  2138. * @code{c}
  2139. * void vTaskList( char *pcWriteBuffer );
  2140. * @endcode
  2141. *
  2142. * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must
  2143. * both be defined as 1 for this function to be available. See the
  2144. * configuration section of the FreeRTOS.org website for more information.
  2145. *
  2146. * WARN: This function assumes that the pcWriteBuffer is of length
  2147. * configSTATS_BUFFER_MAX_LENGTH. This function is there only for
  2148. * backward compatibility. New applications are recommended to
  2149. * use vTaskListTasks and supply the length of the pcWriteBuffer explicitly.
  2150. *
  2151. * NOTE 1: This function will disable interrupts for its duration. It is
  2152. * not intended for normal application runtime use but as a debug aid.
  2153. *
  2154. * Lists all the current tasks, along with their current state and stack
  2155. * usage high water mark.
  2156. *
  2157. * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or
  2158. * suspended ('S').
  2159. *
  2160. * PLEASE NOTE:
  2161. *
  2162. * This function is provided for convenience only, and is used by many of the
  2163. * demo applications. Do not consider it to be part of the scheduler.
  2164. *
  2165. * vTaskList() calls uxTaskGetSystemState(), then formats part of the
  2166. * uxTaskGetSystemState() output into a human readable table that displays task:
  2167. * names, states, priority, stack usage and task number.
  2168. * Stack usage specified as the number of unused StackType_t words stack can hold
  2169. * on top of stack - not the number of bytes.
  2170. *
  2171. * vTaskList() has a dependency on the snprintf() C library function that might
  2172. * bloat the code size, use a lot of stack, and provide different results on
  2173. * different platforms. An alternative, tiny, third party, and limited
  2174. * functionality implementation of snprintf() is provided in many of the
  2175. * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
  2176. * printf-stdarg.c does not provide a full snprintf() implementation!).
  2177. *
  2178. * It is recommended that production systems call uxTaskGetSystemState()
  2179. * directly to get access to raw stats data, rather than indirectly through a
  2180. * call to vTaskList().
  2181. *
  2182. * @param pcWriteBuffer A buffer into which the above mentioned details
  2183. * will be written, in ASCII form. This buffer is assumed to be large
  2184. * enough to contain the generated report. Approximately 40 bytes per
  2185. * task should be sufficient.
  2186. *
  2187. * \defgroup vTaskList vTaskList
  2188. * \ingroup TaskUtils
  2189. */
  2190. #define vTaskList( pcWriteBuffer ) vTaskListTasks( ( pcWriteBuffer ), configSTATS_BUFFER_MAX_LENGTH )
  2191. /**
  2192. * task. h
  2193. * @code{c}
  2194. * void vTaskGetRunTimeStatistics( char *pcWriteBuffer, size_t uxBufferLength );
  2195. * @endcode
  2196. *
  2197. * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
  2198. * must both be defined as 1 for this function to be available. The application
  2199. * must also then provide definitions for
  2200. * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
  2201. * to configure a peripheral timer/counter and return the timers current count
  2202. * value respectively. The counter should be at least 10 times the frequency of
  2203. * the tick count.
  2204. *
  2205. * NOTE 1: This function will disable interrupts for its duration. It is
  2206. * not intended for normal application runtime use but as a debug aid.
  2207. *
  2208. * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
  2209. * accumulated execution time being stored for each task. The resolution
  2210. * of the accumulated time value depends on the frequency of the timer
  2211. * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
  2212. * Calling vTaskGetRunTimeStatistics() writes the total execution time of each
  2213. * task into a buffer, both as an absolute count value and as a percentage
  2214. * of the total system execution time.
  2215. *
  2216. * NOTE 2:
  2217. *
  2218. * This function is provided for convenience only, and is used by many of the
  2219. * demo applications. Do not consider it to be part of the scheduler.
  2220. *
  2221. * vTaskGetRunTimeStatistics() calls uxTaskGetSystemState(), then formats part of
  2222. * the uxTaskGetSystemState() output into a human readable table that displays the
  2223. * amount of time each task has spent in the Running state in both absolute and
  2224. * percentage terms.
  2225. *
  2226. * vTaskGetRunTimeStatistics() has a dependency on the snprintf() C library function
  2227. * that might bloat the code size, use a lot of stack, and provide different
  2228. * results on different platforms. An alternative, tiny, third party, and
  2229. * limited functionality implementation of snprintf() is provided in many of the
  2230. * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
  2231. * printf-stdarg.c does not provide a full snprintf() implementation!).
  2232. *
  2233. * It is recommended that production systems call uxTaskGetSystemState() directly
  2234. * to get access to raw stats data, rather than indirectly through a call to
  2235. * vTaskGetRunTimeStatistics().
  2236. *
  2237. * @param pcWriteBuffer A buffer into which the execution times will be
  2238. * written, in ASCII form. This buffer is assumed to be large enough to
  2239. * contain the generated report. Approximately 40 bytes per task should
  2240. * be sufficient.
  2241. *
  2242. * @param uxBufferLength Length of the pcWriteBuffer.
  2243. *
  2244. * \defgroup vTaskGetRunTimeStatistics vTaskGetRunTimeStatistics
  2245. * \ingroup TaskUtils
  2246. */
  2247. #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configUSE_TRACE_FACILITY == 1 ) )
  2248. void vTaskGetRunTimeStatistics( char * pcWriteBuffer,
  2249. size_t uxBufferLength ) PRIVILEGED_FUNCTION;
  2250. #endif
  2251. /**
  2252. * task. h
  2253. * @code{c}
  2254. * void vTaskGetRunTimeStats( char *pcWriteBuffer );
  2255. * @endcode
  2256. *
  2257. * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
  2258. * must both be defined as 1 for this function to be available. The application
  2259. * must also then provide definitions for
  2260. * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
  2261. * to configure a peripheral timer/counter and return the timers current count
  2262. * value respectively. The counter should be at least 10 times the frequency of
  2263. * the tick count.
  2264. *
  2265. * WARN: This function assumes that the pcWriteBuffer is of length
  2266. * configSTATS_BUFFER_MAX_LENGTH. This function is there only for
  2267. * backward compatiblity. New applications are recommended to use
  2268. * vTaskGetRunTimeStatistics and supply the length of the pcWriteBuffer
  2269. * explicitly.
  2270. *
  2271. * NOTE 1: This function will disable interrupts for its duration. It is
  2272. * not intended for normal application runtime use but as a debug aid.
  2273. *
  2274. * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
  2275. * accumulated execution time being stored for each task. The resolution
  2276. * of the accumulated time value depends on the frequency of the timer
  2277. * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
  2278. * Calling vTaskGetRunTimeStats() writes the total execution time of each
  2279. * task into a buffer, both as an absolute count value and as a percentage
  2280. * of the total system execution time.
  2281. *
  2282. * NOTE 2:
  2283. *
  2284. * This function is provided for convenience only, and is used by many of the
  2285. * demo applications. Do not consider it to be part of the scheduler.
  2286. *
  2287. * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the
  2288. * uxTaskGetSystemState() output into a human readable table that displays the
  2289. * amount of time each task has spent in the Running state in both absolute and
  2290. * percentage terms.
  2291. *
  2292. * vTaskGetRunTimeStats() has a dependency on the snprintf() C library function
  2293. * that might bloat the code size, use a lot of stack, and provide different
  2294. * results on different platforms. An alternative, tiny, third party, and
  2295. * limited functionality implementation of snprintf() is provided in many of the
  2296. * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
  2297. * printf-stdarg.c does not provide a full snprintf() implementation!).
  2298. *
  2299. * It is recommended that production systems call uxTaskGetSystemState() directly
  2300. * to get access to raw stats data, rather than indirectly through a call to
  2301. * vTaskGetRunTimeStats().
  2302. *
  2303. * @param pcWriteBuffer A buffer into which the execution times will be
  2304. * written, in ASCII form. This buffer is assumed to be large enough to
  2305. * contain the generated report. Approximately 40 bytes per task should
  2306. * be sufficient.
  2307. *
  2308. * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats
  2309. * \ingroup TaskUtils
  2310. */
  2311. #define vTaskGetRunTimeStats( pcWriteBuffer ) vTaskGetRunTimeStatistics( ( pcWriteBuffer ), configSTATS_BUFFER_MAX_LENGTH )
  2312. /**
  2313. * task. h
  2314. * @code{c}
  2315. * configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimeCounter( const TaskHandle_t xTask );
  2316. * configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimePercent( const TaskHandle_t xTask );
  2317. * @endcode
  2318. *
  2319. * configGENERATE_RUN_TIME_STATS must be defined as 1 for these functions to be
  2320. * available. The application must also then provide definitions for
  2321. * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
  2322. * portGET_RUN_TIME_COUNTER_VALUE() to configure a peripheral timer/counter and
  2323. * return the timers current count value respectively. The counter should be
  2324. * at least 10 times the frequency of the tick count.
  2325. *
  2326. * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
  2327. * accumulated execution time being stored for each task. The resolution
  2328. * of the accumulated time value depends on the frequency of the timer
  2329. * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
  2330. * While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total
  2331. * execution time of each task into a buffer, ulTaskGetRunTimeCounter()
  2332. * returns the total execution time of just one task and
  2333. * ulTaskGetRunTimePercent() returns the percentage of the CPU time used by
  2334. * just one task.
  2335. *
  2336. * @return The total run time of the given task or the percentage of the total
  2337. * run time consumed by the given task. This is the amount of time the task
  2338. * has actually been executing. The unit of time is dependent on the frequency
  2339. * configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
  2340. * portGET_RUN_TIME_COUNTER_VALUE() macros.
  2341. *
  2342. * \defgroup ulTaskGetRunTimeCounter ulTaskGetRunTimeCounter
  2343. * \ingroup TaskUtils
  2344. */
  2345. #if ( configGENERATE_RUN_TIME_STATS == 1 )
  2346. configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimeCounter( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  2347. configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimePercent( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  2348. #endif
  2349. /**
  2350. * task. h
  2351. * @code{c}
  2352. * configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimeCounter( void );
  2353. * configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void );
  2354. * @endcode
  2355. *
  2356. * configGENERATE_RUN_TIME_STATS must be defined as 1 for these functions to be
  2357. * available. The application must also then provide definitions for
  2358. * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
  2359. * portGET_RUN_TIME_COUNTER_VALUE() to configure a peripheral timer/counter and
  2360. * return the timers current count value respectively. The counter should be
  2361. * at least 10 times the frequency of the tick count.
  2362. *
  2363. * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
  2364. * accumulated execution time being stored for each task. The resolution
  2365. * of the accumulated time value depends on the frequency of the timer
  2366. * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
  2367. * While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total
  2368. * execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter()
  2369. * returns the total execution time of just the idle task and
  2370. * ulTaskGetIdleRunTimePercent() returns the percentage of the CPU time used by
  2371. * just the idle task.
  2372. *
  2373. * Note the amount of idle time is only a good measure of the slack time in a
  2374. * system if there are no other tasks executing at the idle priority, tickless
  2375. * idle is not used, and configIDLE_SHOULD_YIELD is set to 0.
  2376. *
  2377. * @return The total run time of the idle task or the percentage of the total
  2378. * run time consumed by the idle task. This is the amount of time the
  2379. * idle task has actually been executing. The unit of time is dependent on the
  2380. * frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
  2381. * portGET_RUN_TIME_COUNTER_VALUE() macros.
  2382. *
  2383. * \defgroup ulTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter
  2384. * \ingroup TaskUtils
  2385. */
  2386. #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
  2387. configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION;
  2388. configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void ) PRIVILEGED_FUNCTION;
  2389. #endif
  2390. /**
  2391. * task. h
  2392. * @code{c}
  2393. * BaseType_t xTaskNotifyIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction );
  2394. * BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );
  2395. * @endcode
  2396. *
  2397. * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
  2398. *
  2399. * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
  2400. * functions to be available.
  2401. *
  2402. * Sends a direct to task notification to a task, with an optional value and
  2403. * action.
  2404. *
  2405. * Each task has a private array of "notification values" (or 'notifications'),
  2406. * each of which is a 32-bit unsigned integer (uint32_t). The constant
  2407. * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
  2408. * array, and (for backward compatibility) defaults to 1 if left undefined.
  2409. * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
  2410. *
  2411. * Events can be sent to a task using an intermediary object. Examples of such
  2412. * objects are queues, semaphores, mutexes and event groups. Task notifications
  2413. * are a method of sending an event directly to a task without the need for such
  2414. * an intermediary object.
  2415. *
  2416. * A notification sent to a task can optionally perform an action, such as
  2417. * update, overwrite or increment one of the task's notification values. In
  2418. * that way task notifications can be used to send data to a task, or be used as
  2419. * light weight and fast binary or counting semaphores.
  2420. *
  2421. * A task can use xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() to
  2422. * [optionally] block to wait for a notification to be pending. The task does
  2423. * not consume any CPU time while it is in the Blocked state.
  2424. *
  2425. * A notification sent to a task will remain pending until it is cleared by the
  2426. * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
  2427. * un-indexed equivalents). If the task was already in the Blocked state to
  2428. * wait for a notification when the notification arrives then the task will
  2429. * automatically be removed from the Blocked state (unblocked) and the
  2430. * notification cleared.
  2431. *
  2432. * **NOTE** Each notification within the array operates independently - a task
  2433. * can only block on one notification within the array at a time and will not be
  2434. * unblocked by a notification sent to any other array index.
  2435. *
  2436. * Backward compatibility information:
  2437. * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
  2438. * all task notification API functions operated on that value. Replacing the
  2439. * single notification value with an array of notification values necessitated a
  2440. * new set of API functions that could address specific notifications within the
  2441. * array. xTaskNotify() is the original API function, and remains backward
  2442. * compatible by always operating on the notification value at index 0 in the
  2443. * array. Calling xTaskNotify() is equivalent to calling xTaskNotifyIndexed()
  2444. * with the uxIndexToNotify parameter set to 0.
  2445. *
  2446. * @param xTaskToNotify The handle of the task being notified. The handle to a
  2447. * task can be returned from the xTaskCreate() API function used to create the
  2448. * task, and the handle of the currently running task can be obtained by calling
  2449. * xTaskGetCurrentTaskHandle().
  2450. *
  2451. * @param uxIndexToNotify The index within the target task's array of
  2452. * notification values to which the notification is to be sent. uxIndexToNotify
  2453. * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotify() does
  2454. * not have this parameter and always sends notifications to index 0.
  2455. *
  2456. * @param ulValue Data that can be sent with the notification. How the data is
  2457. * used depends on the value of the eAction parameter.
  2458. *
  2459. * @param eAction Specifies how the notification updates the task's notification
  2460. * value, if at all. Valid values for eAction are as follows:
  2461. *
  2462. * eSetBits -
  2463. * The target notification value is bitwise ORed with ulValue.
  2464. * xTaskNotifyIndexed() always returns pdPASS in this case.
  2465. *
  2466. * eIncrement -
  2467. * The target notification value is incremented. ulValue is not used and
  2468. * xTaskNotifyIndexed() always returns pdPASS in this case.
  2469. *
  2470. * eSetValueWithOverwrite -
  2471. * The target notification value is set to the value of ulValue, even if the
  2472. * task being notified had not yet processed the previous notification at the
  2473. * same array index (the task already had a notification pending at that index).
  2474. * xTaskNotifyIndexed() always returns pdPASS in this case.
  2475. *
  2476. * eSetValueWithoutOverwrite -
  2477. * If the task being notified did not already have a notification pending at the
  2478. * same array index then the target notification value is set to ulValue and
  2479. * xTaskNotifyIndexed() will return pdPASS. If the task being notified already
  2480. * had a notification pending at the same array index then no action is
  2481. * performed and pdFAIL is returned.
  2482. *
  2483. * eNoAction -
  2484. * The task receives a notification at the specified array index without the
  2485. * notification value at that index being updated. ulValue is not used and
  2486. * xTaskNotifyIndexed() always returns pdPASS in this case.
  2487. *
  2488. * pulPreviousNotificationValue -
  2489. * Can be used to pass out the subject task's notification value before any
  2490. * bits are modified by the notify function.
  2491. *
  2492. * @return Dependent on the value of eAction. See the description of the
  2493. * eAction parameter.
  2494. *
  2495. * \defgroup xTaskNotifyIndexed xTaskNotifyIndexed
  2496. * \ingroup TaskNotifications
  2497. */
  2498. BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify,
  2499. UBaseType_t uxIndexToNotify,
  2500. uint32_t ulValue,
  2501. eNotifyAction eAction,
  2502. uint32_t * pulPreviousNotificationValue ) PRIVILEGED_FUNCTION;
  2503. #define xTaskNotify( xTaskToNotify, ulValue, eAction ) \
  2504. xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL )
  2505. #define xTaskNotifyIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction ) \
  2506. xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL )
  2507. /**
  2508. * task. h
  2509. * @code{c}
  2510. * BaseType_t xTaskNotifyAndQueryIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue );
  2511. * BaseType_t xTaskNotifyAndQuery( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue );
  2512. * @endcode
  2513. *
  2514. * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
  2515. *
  2516. * xTaskNotifyAndQueryIndexed() performs the same operation as
  2517. * xTaskNotifyIndexed() with the addition that it also returns the subject
  2518. * task's prior notification value (the notification value at the time the
  2519. * function is called rather than when the function returns) in the additional
  2520. * pulPreviousNotifyValue parameter.
  2521. *
  2522. * xTaskNotifyAndQuery() performs the same operation as xTaskNotify() with the
  2523. * addition that it also returns the subject task's prior notification value
  2524. * (the notification value as it was at the time the function is called, rather
  2525. * than when the function returns) in the additional pulPreviousNotifyValue
  2526. * parameter.
  2527. *
  2528. * \defgroup xTaskNotifyAndQueryIndexed xTaskNotifyAndQueryIndexed
  2529. * \ingroup TaskNotifications
  2530. */
  2531. #define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) \
  2532. xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
  2533. #define xTaskNotifyAndQueryIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotifyValue ) \
  2534. xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
  2535. /**
  2536. * task. h
  2537. * @code{c}
  2538. * BaseType_t xTaskNotifyIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );
  2539. * BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );
  2540. * @endcode
  2541. *
  2542. * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
  2543. *
  2544. * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
  2545. * functions to be available.
  2546. *
  2547. * A version of xTaskNotifyIndexed() that can be used from an interrupt service
  2548. * routine (ISR).
  2549. *
  2550. * Each task has a private array of "notification values" (or 'notifications'),
  2551. * each of which is a 32-bit unsigned integer (uint32_t). The constant
  2552. * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
  2553. * array, and (for backward compatibility) defaults to 1 if left undefined.
  2554. * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
  2555. *
  2556. * Events can be sent to a task using an intermediary object. Examples of such
  2557. * objects are queues, semaphores, mutexes and event groups. Task notifications
  2558. * are a method of sending an event directly to a task without the need for such
  2559. * an intermediary object.
  2560. *
  2561. * A notification sent to a task can optionally perform an action, such as
  2562. * update, overwrite or increment one of the task's notification values. In
  2563. * that way task notifications can be used to send data to a task, or be used as
  2564. * light weight and fast binary or counting semaphores.
  2565. *
  2566. * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a
  2567. * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block
  2568. * to wait for a notification value to have a non-zero value. The task does
  2569. * not consume any CPU time while it is in the Blocked state.
  2570. *
  2571. * A notification sent to a task will remain pending until it is cleared by the
  2572. * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
  2573. * un-indexed equivalents). If the task was already in the Blocked state to
  2574. * wait for a notification when the notification arrives then the task will
  2575. * automatically be removed from the Blocked state (unblocked) and the
  2576. * notification cleared.
  2577. *
  2578. * **NOTE** Each notification within the array operates independently - a task
  2579. * can only block on one notification within the array at a time and will not be
  2580. * unblocked by a notification sent to any other array index.
  2581. *
  2582. * Backward compatibility information:
  2583. * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
  2584. * all task notification API functions operated on that value. Replacing the
  2585. * single notification value with an array of notification values necessitated a
  2586. * new set of API functions that could address specific notifications within the
  2587. * array. xTaskNotifyFromISR() is the original API function, and remains
  2588. * backward compatible by always operating on the notification value at index 0
  2589. * within the array. Calling xTaskNotifyFromISR() is equivalent to calling
  2590. * xTaskNotifyIndexedFromISR() with the uxIndexToNotify parameter set to 0.
  2591. *
  2592. * @param uxIndexToNotify The index within the target task's array of
  2593. * notification values to which the notification is to be sent. uxIndexToNotify
  2594. * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyFromISR()
  2595. * does not have this parameter and always sends notifications to index 0.
  2596. *
  2597. * @param xTaskToNotify The handle of the task being notified. The handle to a
  2598. * task can be returned from the xTaskCreate() API function used to create the
  2599. * task, and the handle of the currently running task can be obtained by calling
  2600. * xTaskGetCurrentTaskHandle().
  2601. *
  2602. * @param ulValue Data that can be sent with the notification. How the data is
  2603. * used depends on the value of the eAction parameter.
  2604. *
  2605. * @param eAction Specifies how the notification updates the task's notification
  2606. * value, if at all. Valid values for eAction are as follows:
  2607. *
  2608. * eSetBits -
  2609. * The task's notification value is bitwise ORed with ulValue. xTaskNotify()
  2610. * always returns pdPASS in this case.
  2611. *
  2612. * eIncrement -
  2613. * The task's notification value is incremented. ulValue is not used and
  2614. * xTaskNotify() always returns pdPASS in this case.
  2615. *
  2616. * eSetValueWithOverwrite -
  2617. * The task's notification value is set to the value of ulValue, even if the
  2618. * task being notified had not yet processed the previous notification (the
  2619. * task already had a notification pending). xTaskNotify() always returns
  2620. * pdPASS in this case.
  2621. *
  2622. * eSetValueWithoutOverwrite -
  2623. * If the task being notified did not already have a notification pending then
  2624. * the task's notification value is set to ulValue and xTaskNotify() will
  2625. * return pdPASS. If the task being notified already had a notification
  2626. * pending then no action is performed and pdFAIL is returned.
  2627. *
  2628. * eNoAction -
  2629. * The task receives a notification without its notification value being
  2630. * updated. ulValue is not used and xTaskNotify() always returns pdPASS in
  2631. * this case.
  2632. *
  2633. * @param pxHigherPriorityTaskWoken xTaskNotifyFromISR() will set
  2634. * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
  2635. * task to which the notification was sent to leave the Blocked state, and the
  2636. * unblocked task has a priority higher than the currently running task. If
  2637. * xTaskNotifyFromISR() sets this value to pdTRUE then a context switch should
  2638. * be requested before the interrupt is exited. How a context switch is
  2639. * requested from an ISR is dependent on the port - see the documentation page
  2640. * for the port in use.
  2641. *
  2642. * @return Dependent on the value of eAction. See the description of the
  2643. * eAction parameter.
  2644. *
  2645. * \defgroup xTaskNotifyIndexedFromISR xTaskNotifyIndexedFromISR
  2646. * \ingroup TaskNotifications
  2647. */
  2648. BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify,
  2649. UBaseType_t uxIndexToNotify,
  2650. uint32_t ulValue,
  2651. eNotifyAction eAction,
  2652. uint32_t * pulPreviousNotificationValue,
  2653. BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
  2654. #define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \
  2655. xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
  2656. #define xTaskNotifyIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \
  2657. xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
  2658. /**
  2659. * task. h
  2660. * @code{c}
  2661. * BaseType_t xTaskNotifyAndQueryIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken );
  2662. * BaseType_t xTaskNotifyAndQueryFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken );
  2663. * @endcode
  2664. *
  2665. * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
  2666. *
  2667. * xTaskNotifyAndQueryIndexedFromISR() performs the same operation as
  2668. * xTaskNotifyIndexedFromISR() with the addition that it also returns the
  2669. * subject task's prior notification value (the notification value at the time
  2670. * the function is called rather than at the time the function returns) in the
  2671. * additional pulPreviousNotifyValue parameter.
  2672. *
  2673. * xTaskNotifyAndQueryFromISR() performs the same operation as
  2674. * xTaskNotifyFromISR() with the addition that it also returns the subject
  2675. * task's prior notification value (the notification value at the time the
  2676. * function is called rather than at the time the function returns) in the
  2677. * additional pulPreviousNotifyValue parameter.
  2678. *
  2679. * \defgroup xTaskNotifyAndQueryIndexedFromISR xTaskNotifyAndQueryIndexedFromISR
  2680. * \ingroup TaskNotifications
  2681. */
  2682. #define xTaskNotifyAndQueryIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \
  2683. xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
  2684. #define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \
  2685. xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
  2686. /**
  2687. * task. h
  2688. * @code{c}
  2689. * BaseType_t xTaskNotifyWaitIndexed( UBaseType_t uxIndexToWaitOn, uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
  2690. *
  2691. * BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
  2692. * @endcode
  2693. *
  2694. * Waits for a direct to task notification to be pending at a given index within
  2695. * an array of direct to task notifications.
  2696. *
  2697. * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
  2698. *
  2699. * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
  2700. * function to be available.
  2701. *
  2702. * Each task has a private array of "notification values" (or 'notifications'),
  2703. * each of which is a 32-bit unsigned integer (uint32_t). The constant
  2704. * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
  2705. * array, and (for backward compatibility) defaults to 1 if left undefined.
  2706. * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
  2707. *
  2708. * Events can be sent to a task using an intermediary object. Examples of such
  2709. * objects are queues, semaphores, mutexes and event groups. Task notifications
  2710. * are a method of sending an event directly to a task without the need for such
  2711. * an intermediary object.
  2712. *
  2713. * A notification sent to a task can optionally perform an action, such as
  2714. * update, overwrite or increment one of the task's notification values. In
  2715. * that way task notifications can be used to send data to a task, or be used as
  2716. * light weight and fast binary or counting semaphores.
  2717. *
  2718. * A notification sent to a task will remain pending until it is cleared by the
  2719. * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
  2720. * un-indexed equivalents). If the task was already in the Blocked state to
  2721. * wait for a notification when the notification arrives then the task will
  2722. * automatically be removed from the Blocked state (unblocked) and the
  2723. * notification cleared.
  2724. *
  2725. * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a
  2726. * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block
  2727. * to wait for a notification value to have a non-zero value. The task does
  2728. * not consume any CPU time while it is in the Blocked state.
  2729. *
  2730. * **NOTE** Each notification within the array operates independently - a task
  2731. * can only block on one notification within the array at a time and will not be
  2732. * unblocked by a notification sent to any other array index.
  2733. *
  2734. * Backward compatibility information:
  2735. * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
  2736. * all task notification API functions operated on that value. Replacing the
  2737. * single notification value with an array of notification values necessitated a
  2738. * new set of API functions that could address specific notifications within the
  2739. * array. xTaskNotifyWait() is the original API function, and remains backward
  2740. * compatible by always operating on the notification value at index 0 in the
  2741. * array. Calling xTaskNotifyWait() is equivalent to calling
  2742. * xTaskNotifyWaitIndexed() with the uxIndexToWaitOn parameter set to 0.
  2743. *
  2744. * @param uxIndexToWaitOn The index within the calling task's array of
  2745. * notification values on which the calling task will wait for a notification to
  2746. * be received. uxIndexToWaitOn must be less than
  2747. * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyWait() does
  2748. * not have this parameter and always waits for notifications on index 0.
  2749. *
  2750. * @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value
  2751. * will be cleared in the calling task's notification value before the task
  2752. * checks to see if any notifications are pending, and optionally blocks if no
  2753. * notifications are pending. Setting ulBitsToClearOnEntry to ULONG_MAX (if
  2754. * limits.h is included) or 0xffffffffU (if limits.h is not included) will have
  2755. * the effect of resetting the task's notification value to 0. Setting
  2756. * ulBitsToClearOnEntry to 0 will leave the task's notification value unchanged.
  2757. *
  2758. * @param ulBitsToClearOnExit If a notification is pending or received before
  2759. * the calling task exits the xTaskNotifyWait() function then the task's
  2760. * notification value (see the xTaskNotify() API function) is passed out using
  2761. * the pulNotificationValue parameter. Then any bits that are set in
  2762. * ulBitsToClearOnExit will be cleared in the task's notification value (note
  2763. * *pulNotificationValue is set before any bits are cleared). Setting
  2764. * ulBitsToClearOnExit to ULONG_MAX (if limits.h is included) or 0xffffffffUL
  2765. * (if limits.h is not included) will have the effect of resetting the task's
  2766. * notification value to 0 before the function exits. Setting
  2767. * ulBitsToClearOnExit to 0 will leave the task's notification value unchanged
  2768. * when the function exits (in which case the value passed out in
  2769. * pulNotificationValue will match the task's notification value).
  2770. *
  2771. * @param pulNotificationValue Used to pass the task's notification value out
  2772. * of the function. Note the value passed out will not be effected by the
  2773. * clearing of any bits caused by ulBitsToClearOnExit being non-zero.
  2774. *
  2775. * @param xTicksToWait The maximum amount of time that the task should wait in
  2776. * the Blocked state for a notification to be received, should a notification
  2777. * not already be pending when xTaskNotifyWait() was called. The task
  2778. * will not consume any processing time while it is in the Blocked state. This
  2779. * is specified in kernel ticks, the macro pdMS_TO_TICKS( value_in_ms ) can be
  2780. * used to convert a time specified in milliseconds to a time specified in
  2781. * ticks.
  2782. *
  2783. * @return If a notification was received (including notifications that were
  2784. * already pending when xTaskNotifyWait was called) then pdPASS is
  2785. * returned. Otherwise pdFAIL is returned.
  2786. *
  2787. * \defgroup xTaskNotifyWaitIndexed xTaskNotifyWaitIndexed
  2788. * \ingroup TaskNotifications
  2789. */
  2790. BaseType_t xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn,
  2791. uint32_t ulBitsToClearOnEntry,
  2792. uint32_t ulBitsToClearOnExit,
  2793. uint32_t * pulNotificationValue,
  2794. TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
  2795. #define xTaskNotifyWait( ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \
  2796. xTaskGenericNotifyWait( tskDEFAULT_INDEX_TO_NOTIFY, ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) )
  2797. #define xTaskNotifyWaitIndexed( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \
  2798. xTaskGenericNotifyWait( ( uxIndexToWaitOn ), ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) )
  2799. /**
  2800. * task. h
  2801. * @code{c}
  2802. * BaseType_t xTaskNotifyGiveIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify );
  2803. * BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );
  2804. * @endcode
  2805. *
  2806. * Sends a direct to task notification to a particular index in the target
  2807. * task's notification array in a manner similar to giving a counting semaphore.
  2808. *
  2809. * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
  2810. *
  2811. * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
  2812. * macros to be available.
  2813. *
  2814. * Each task has a private array of "notification values" (or 'notifications'),
  2815. * each of which is a 32-bit unsigned integer (uint32_t). The constant
  2816. * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
  2817. * array, and (for backward compatibility) defaults to 1 if left undefined.
  2818. * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
  2819. *
  2820. * Events can be sent to a task using an intermediary object. Examples of such
  2821. * objects are queues, semaphores, mutexes and event groups. Task notifications
  2822. * are a method of sending an event directly to a task without the need for such
  2823. * an intermediary object.
  2824. *
  2825. * A notification sent to a task can optionally perform an action, such as
  2826. * update, overwrite or increment one of the task's notification values. In
  2827. * that way task notifications can be used to send data to a task, or be used as
  2828. * light weight and fast binary or counting semaphores.
  2829. *
  2830. * xTaskNotifyGiveIndexed() is a helper macro intended for use when task
  2831. * notifications are used as light weight and faster binary or counting
  2832. * semaphore equivalents. Actual FreeRTOS semaphores are given using the
  2833. * xSemaphoreGive() API function, the equivalent action that instead uses a task
  2834. * notification is xTaskNotifyGiveIndexed().
  2835. *
  2836. * When task notifications are being used as a binary or counting semaphore
  2837. * equivalent then the task being notified should wait for the notification
  2838. * using the ulTaskNotifyTakeIndexed() API function rather than the
  2839. * xTaskNotifyWaitIndexed() API function.
  2840. *
  2841. * **NOTE** Each notification within the array operates independently - a task
  2842. * can only block on one notification within the array at a time and will not be
  2843. * unblocked by a notification sent to any other array index.
  2844. *
  2845. * Backward compatibility information:
  2846. * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
  2847. * all task notification API functions operated on that value. Replacing the
  2848. * single notification value with an array of notification values necessitated a
  2849. * new set of API functions that could address specific notifications within the
  2850. * array. xTaskNotifyGive() is the original API function, and remains backward
  2851. * compatible by always operating on the notification value at index 0 in the
  2852. * array. Calling xTaskNotifyGive() is equivalent to calling
  2853. * xTaskNotifyGiveIndexed() with the uxIndexToNotify parameter set to 0.
  2854. *
  2855. * @param xTaskToNotify The handle of the task being notified. The handle to a
  2856. * task can be returned from the xTaskCreate() API function used to create the
  2857. * task, and the handle of the currently running task can be obtained by calling
  2858. * xTaskGetCurrentTaskHandle().
  2859. *
  2860. * @param uxIndexToNotify The index within the target task's array of
  2861. * notification values to which the notification is to be sent. uxIndexToNotify
  2862. * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyGive()
  2863. * does not have this parameter and always sends notifications to index 0.
  2864. *
  2865. * @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the
  2866. * eAction parameter set to eIncrement - so pdPASS is always returned.
  2867. *
  2868. * \defgroup xTaskNotifyGiveIndexed xTaskNotifyGiveIndexed
  2869. * \ingroup TaskNotifications
  2870. */
  2871. #define xTaskNotifyGive( xTaskToNotify ) \
  2872. xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( 0 ), eIncrement, NULL )
  2873. #define xTaskNotifyGiveIndexed( xTaskToNotify, uxIndexToNotify ) \
  2874. xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( 0 ), eIncrement, NULL )
  2875. /**
  2876. * task. h
  2877. * @code{c}
  2878. * void vTaskNotifyGiveIndexedFromISR( TaskHandle_t xTaskHandle, UBaseType_t uxIndexToNotify, BaseType_t *pxHigherPriorityTaskWoken );
  2879. * void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );
  2880. * @endcode
  2881. *
  2882. * A version of xTaskNotifyGiveIndexed() that can be called from an interrupt
  2883. * service routine (ISR).
  2884. *
  2885. * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
  2886. *
  2887. * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro
  2888. * to be available.
  2889. *
  2890. * Each task has a private array of "notification values" (or 'notifications'),
  2891. * each of which is a 32-bit unsigned integer (uint32_t). The constant
  2892. * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
  2893. * array, and (for backward compatibility) defaults to 1 if left undefined.
  2894. * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
  2895. *
  2896. * Events can be sent to a task using an intermediary object. Examples of such
  2897. * objects are queues, semaphores, mutexes and event groups. Task notifications
  2898. * are a method of sending an event directly to a task without the need for such
  2899. * an intermediary object.
  2900. *
  2901. * A notification sent to a task can optionally perform an action, such as
  2902. * update, overwrite or increment one of the task's notification values. In
  2903. * that way task notifications can be used to send data to a task, or be used as
  2904. * light weight and fast binary or counting semaphores.
  2905. *
  2906. * vTaskNotifyGiveIndexedFromISR() is intended for use when task notifications
  2907. * are used as light weight and faster binary or counting semaphore equivalents.
  2908. * Actual FreeRTOS semaphores are given from an ISR using the
  2909. * xSemaphoreGiveFromISR() API function, the equivalent action that instead uses
  2910. * a task notification is vTaskNotifyGiveIndexedFromISR().
  2911. *
  2912. * When task notifications are being used as a binary or counting semaphore
  2913. * equivalent then the task being notified should wait for the notification
  2914. * using the ulTaskNotifyTakeIndexed() API function rather than the
  2915. * xTaskNotifyWaitIndexed() API function.
  2916. *
  2917. * **NOTE** Each notification within the array operates independently - a task
  2918. * can only block on one notification within the array at a time and will not be
  2919. * unblocked by a notification sent to any other array index.
  2920. *
  2921. * Backward compatibility information:
  2922. * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
  2923. * all task notification API functions operated on that value. Replacing the
  2924. * single notification value with an array of notification values necessitated a
  2925. * new set of API functions that could address specific notifications within the
  2926. * array. xTaskNotifyFromISR() is the original API function, and remains
  2927. * backward compatible by always operating on the notification value at index 0
  2928. * within the array. Calling xTaskNotifyGiveFromISR() is equivalent to calling
  2929. * xTaskNotifyGiveIndexedFromISR() with the uxIndexToNotify parameter set to 0.
  2930. *
  2931. * @param xTaskToNotify The handle of the task being notified. The handle to a
  2932. * task can be returned from the xTaskCreate() API function used to create the
  2933. * task, and the handle of the currently running task can be obtained by calling
  2934. * xTaskGetCurrentTaskHandle().
  2935. *
  2936. * @param uxIndexToNotify The index within the target task's array of
  2937. * notification values to which the notification is to be sent. uxIndexToNotify
  2938. * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
  2939. * xTaskNotifyGiveFromISR() does not have this parameter and always sends
  2940. * notifications to index 0.
  2941. *
  2942. * @param pxHigherPriorityTaskWoken vTaskNotifyGiveFromISR() will set
  2943. * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
  2944. * task to which the notification was sent to leave the Blocked state, and the
  2945. * unblocked task has a priority higher than the currently running task. If
  2946. * vTaskNotifyGiveFromISR() sets this value to pdTRUE then a context switch
  2947. * should be requested before the interrupt is exited. How a context switch is
  2948. * requested from an ISR is dependent on the port - see the documentation page
  2949. * for the port in use.
  2950. *
  2951. * \defgroup vTaskNotifyGiveIndexedFromISR vTaskNotifyGiveIndexedFromISR
  2952. * \ingroup TaskNotifications
  2953. */
  2954. void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify,
  2955. UBaseType_t uxIndexToNotify,
  2956. BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
  2957. #define vTaskNotifyGiveFromISR( xTaskToNotify, pxHigherPriorityTaskWoken ) \
  2958. vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( pxHigherPriorityTaskWoken ) )
  2959. #define vTaskNotifyGiveIndexedFromISR( xTaskToNotify, uxIndexToNotify, pxHigherPriorityTaskWoken ) \
  2960. vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( pxHigherPriorityTaskWoken ) )
  2961. /**
  2962. * task. h
  2963. * @code{c}
  2964. * uint32_t ulTaskNotifyTakeIndexed( UBaseType_t uxIndexToWaitOn, BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
  2965. *
  2966. * uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
  2967. * @endcode
  2968. *
  2969. * Waits for a direct to task notification on a particular index in the calling
  2970. * task's notification array in a manner similar to taking a counting semaphore.
  2971. *
  2972. * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
  2973. *
  2974. * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
  2975. * function to be available.
  2976. *
  2977. * Each task has a private array of "notification values" (or 'notifications'),
  2978. * each of which is a 32-bit unsigned integer (uint32_t). The constant
  2979. * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
  2980. * array, and (for backward compatibility) defaults to 1 if left undefined.
  2981. * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
  2982. *
  2983. * Events can be sent to a task using an intermediary object. Examples of such
  2984. * objects are queues, semaphores, mutexes and event groups. Task notifications
  2985. * are a method of sending an event directly to a task without the need for such
  2986. * an intermediary object.
  2987. *
  2988. * A notification sent to a task can optionally perform an action, such as
  2989. * update, overwrite or increment one of the task's notification values. In
  2990. * that way task notifications can be used to send data to a task, or be used as
  2991. * light weight and fast binary or counting semaphores.
  2992. *
  2993. * ulTaskNotifyTakeIndexed() is intended for use when a task notification is
  2994. * used as a faster and lighter weight binary or counting semaphore alternative.
  2995. * Actual FreeRTOS semaphores are taken using the xSemaphoreTake() API function,
  2996. * the equivalent action that instead uses a task notification is
  2997. * ulTaskNotifyTakeIndexed().
  2998. *
  2999. * When a task is using its notification value as a binary or counting semaphore
  3000. * other tasks should send notifications to it using the xTaskNotifyGiveIndexed()
  3001. * macro, or xTaskNotifyIndex() function with the eAction parameter set to
  3002. * eIncrement.
  3003. *
  3004. * ulTaskNotifyTakeIndexed() can either clear the task's notification value at
  3005. * the array index specified by the uxIndexToWaitOn parameter to zero on exit,
  3006. * in which case the notification value acts like a binary semaphore, or
  3007. * decrement the notification value on exit, in which case the notification
  3008. * value acts like a counting semaphore.
  3009. *
  3010. * A task can use ulTaskNotifyTakeIndexed() to [optionally] block to wait for
  3011. * a notification. The task does not consume any CPU time while it is in the
  3012. * Blocked state.
  3013. *
  3014. * Where as xTaskNotifyWaitIndexed() will return when a notification is pending,
  3015. * ulTaskNotifyTakeIndexed() will return when the task's notification value is
  3016. * not zero.
  3017. *
  3018. * **NOTE** Each notification within the array operates independently - a task
  3019. * can only block on one notification within the array at a time and will not be
  3020. * unblocked by a notification sent to any other array index.
  3021. *
  3022. * Backward compatibility information:
  3023. * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
  3024. * all task notification API functions operated on that value. Replacing the
  3025. * single notification value with an array of notification values necessitated a
  3026. * new set of API functions that could address specific notifications within the
  3027. * array. ulTaskNotifyTake() is the original API function, and remains backward
  3028. * compatible by always operating on the notification value at index 0 in the
  3029. * array. Calling ulTaskNotifyTake() is equivalent to calling
  3030. * ulTaskNotifyTakeIndexed() with the uxIndexToWaitOn parameter set to 0.
  3031. *
  3032. * @param uxIndexToWaitOn The index within the calling task's array of
  3033. * notification values on which the calling task will wait for a notification to
  3034. * be non-zero. uxIndexToWaitOn must be less than
  3035. * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyTake() does
  3036. * not have this parameter and always waits for notifications on index 0.
  3037. *
  3038. * @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's
  3039. * notification value is decremented when the function exits. In this way the
  3040. * notification value acts like a counting semaphore. If xClearCountOnExit is
  3041. * not pdFALSE then the task's notification value is cleared to zero when the
  3042. * function exits. In this way the notification value acts like a binary
  3043. * semaphore.
  3044. *
  3045. * @param xTicksToWait The maximum amount of time that the task should wait in
  3046. * the Blocked state for the task's notification value to be greater than zero,
  3047. * should the count not already be greater than zero when
  3048. * ulTaskNotifyTake() was called. The task will not consume any processing
  3049. * time while it is in the Blocked state. This is specified in kernel ticks,
  3050. * the macro pdMS_TO_TICKS( value_in_ms ) can be used to convert a time
  3051. * specified in milliseconds to a time specified in ticks.
  3052. *
  3053. * @return The task's notification count before it is either cleared to zero or
  3054. * decremented (see the xClearCountOnExit parameter).
  3055. *
  3056. * \defgroup ulTaskNotifyTakeIndexed ulTaskNotifyTakeIndexed
  3057. * \ingroup TaskNotifications
  3058. */
  3059. uint32_t ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn,
  3060. BaseType_t xClearCountOnExit,
  3061. TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
  3062. #define ulTaskNotifyTake( xClearCountOnExit, xTicksToWait ) \
  3063. ulTaskGenericNotifyTake( ( tskDEFAULT_INDEX_TO_NOTIFY ), ( xClearCountOnExit ), ( xTicksToWait ) )
  3064. #define ulTaskNotifyTakeIndexed( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait ) \
  3065. ulTaskGenericNotifyTake( ( uxIndexToWaitOn ), ( xClearCountOnExit ), ( xTicksToWait ) )
  3066. /**
  3067. * task. h
  3068. * @code{c}
  3069. * BaseType_t xTaskNotifyStateClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToCLear );
  3070. *
  3071. * BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
  3072. * @endcode
  3073. *
  3074. * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
  3075. *
  3076. * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
  3077. * functions to be available.
  3078. *
  3079. * Each task has a private array of "notification values" (or 'notifications'),
  3080. * each of which is a 32-bit unsigned integer (uint32_t). The constant
  3081. * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
  3082. * array, and (for backward compatibility) defaults to 1 if left undefined.
  3083. * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
  3084. *
  3085. * If a notification is sent to an index within the array of notifications then
  3086. * the notification at that index is said to be 'pending' until it is read or
  3087. * explicitly cleared by the receiving task. xTaskNotifyStateClearIndexed()
  3088. * is the function that clears a pending notification without reading the
  3089. * notification value. The notification value at the same array index is not
  3090. * altered. Set xTask to NULL to clear the notification state of the calling
  3091. * task.
  3092. *
  3093. * Backward compatibility information:
  3094. * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
  3095. * all task notification API functions operated on that value. Replacing the
  3096. * single notification value with an array of notification values necessitated a
  3097. * new set of API functions that could address specific notifications within the
  3098. * array. xTaskNotifyStateClear() is the original API function, and remains
  3099. * backward compatible by always operating on the notification value at index 0
  3100. * within the array. Calling xTaskNotifyStateClear() is equivalent to calling
  3101. * xTaskNotifyStateClearIndexed() with the uxIndexToNotify parameter set to 0.
  3102. *
  3103. * @param xTask The handle of the RTOS task that will have a notification state
  3104. * cleared. Set xTask to NULL to clear a notification state in the calling
  3105. * task. To obtain a task's handle create the task using xTaskCreate() and
  3106. * make use of the pxCreatedTask parameter, or create the task using
  3107. * xTaskCreateStatic() and store the returned value, or use the task's name in
  3108. * a call to xTaskGetHandle().
  3109. *
  3110. * @param uxIndexToClear The index within the target task's array of
  3111. * notification values to act upon. For example, setting uxIndexToClear to 1
  3112. * will clear the state of the notification at index 1 within the array.
  3113. * uxIndexToClear must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
  3114. * ulTaskNotifyStateClear() does not have this parameter and always acts on the
  3115. * notification at index 0.
  3116. *
  3117. * @return pdTRUE if the task's notification state was set to
  3118. * eNotWaitingNotification, otherwise pdFALSE.
  3119. *
  3120. * \defgroup xTaskNotifyStateClearIndexed xTaskNotifyStateClearIndexed
  3121. * \ingroup TaskNotifications
  3122. */
  3123. BaseType_t xTaskGenericNotifyStateClear( TaskHandle_t xTask,
  3124. UBaseType_t uxIndexToClear ) PRIVILEGED_FUNCTION;
  3125. #define xTaskNotifyStateClear( xTask ) \
  3126. xTaskGenericNotifyStateClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ) )
  3127. #define xTaskNotifyStateClearIndexed( xTask, uxIndexToClear ) \
  3128. xTaskGenericNotifyStateClear( ( xTask ), ( uxIndexToClear ) )
  3129. /**
  3130. * task. h
  3131. * @code{c}
  3132. * uint32_t ulTaskNotifyValueClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear );
  3133. *
  3134. * uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear );
  3135. * @endcode
  3136. *
  3137. * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
  3138. *
  3139. * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
  3140. * functions to be available.
  3141. *
  3142. * Each task has a private array of "notification values" (or 'notifications'),
  3143. * each of which is a 32-bit unsigned integer (uint32_t). The constant
  3144. * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
  3145. * array, and (for backward compatibility) defaults to 1 if left undefined.
  3146. * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
  3147. *
  3148. * ulTaskNotifyValueClearIndexed() clears the bits specified by the
  3149. * ulBitsToClear bit mask in the notification value at array index uxIndexToClear
  3150. * of the task referenced by xTask.
  3151. *
  3152. * Backward compatibility information:
  3153. * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
  3154. * all task notification API functions operated on that value. Replacing the
  3155. * single notification value with an array of notification values necessitated a
  3156. * new set of API functions that could address specific notifications within the
  3157. * array. ulTaskNotifyValueClear() is the original API function, and remains
  3158. * backward compatible by always operating on the notification value at index 0
  3159. * within the array. Calling ulTaskNotifyValueClear() is equivalent to calling
  3160. * ulTaskNotifyValueClearIndexed() with the uxIndexToClear parameter set to 0.
  3161. *
  3162. * @param xTask The handle of the RTOS task that will have bits in one of its
  3163. * notification values cleared. Set xTask to NULL to clear bits in a
  3164. * notification value of the calling task. To obtain a task's handle create the
  3165. * task using xTaskCreate() and make use of the pxCreatedTask parameter, or
  3166. * create the task using xTaskCreateStatic() and store the returned value, or
  3167. * use the task's name in a call to xTaskGetHandle().
  3168. *
  3169. * @param uxIndexToClear The index within the target task's array of
  3170. * notification values in which to clear the bits. uxIndexToClear
  3171. * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
  3172. * ulTaskNotifyValueClear() does not have this parameter and always clears bits
  3173. * in the notification value at index 0.
  3174. *
  3175. * @param ulBitsToClear Bit mask of the bits to clear in the notification value of
  3176. * xTask. Set a bit to 1 to clear the corresponding bits in the task's notification
  3177. * value. Set ulBitsToClear to 0xffffffff (UINT_MAX on 32-bit architectures) to clear
  3178. * the notification value to 0. Set ulBitsToClear to 0 to query the task's
  3179. * notification value without clearing any bits.
  3180. *
  3181. *
  3182. * @return The value of the target task's notification value before the bits
  3183. * specified by ulBitsToClear were cleared.
  3184. * \defgroup ulTaskNotifyValueClear ulTaskNotifyValueClear
  3185. * \ingroup TaskNotifications
  3186. */
  3187. uint32_t ulTaskGenericNotifyValueClear( TaskHandle_t xTask,
  3188. UBaseType_t uxIndexToClear,
  3189. uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
  3190. #define ulTaskNotifyValueClear( xTask, ulBitsToClear ) \
  3191. ulTaskGenericNotifyValueClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulBitsToClear ) )
  3192. #define ulTaskNotifyValueClearIndexed( xTask, uxIndexToClear, ulBitsToClear ) \
  3193. ulTaskGenericNotifyValueClear( ( xTask ), ( uxIndexToClear ), ( ulBitsToClear ) )
  3194. /**
  3195. * task.h
  3196. * @code{c}
  3197. * void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut );
  3198. * @endcode
  3199. *
  3200. * Capture the current time for future use with xTaskCheckForTimeOut().
  3201. *
  3202. * @param pxTimeOut Pointer to a timeout object into which the current time
  3203. * is to be captured. The captured time includes the tick count and the number
  3204. * of times the tick count has overflowed since the system first booted.
  3205. * \defgroup vTaskSetTimeOutState vTaskSetTimeOutState
  3206. * \ingroup TaskCtrl
  3207. */
  3208. void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
  3209. /**
  3210. * task.h
  3211. * @code{c}
  3212. * BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait );
  3213. * @endcode
  3214. *
  3215. * Determines if pxTicksToWait ticks has passed since a time was captured
  3216. * using a call to vTaskSetTimeOutState(). The captured time includes the tick
  3217. * count and the number of times the tick count has overflowed.
  3218. *
  3219. * @param pxTimeOut The time status as captured previously using
  3220. * vTaskSetTimeOutState. If the timeout has not yet occurred, it is updated
  3221. * to reflect the current time status.
  3222. * @param pxTicksToWait The number of ticks to check for timeout i.e. if
  3223. * pxTicksToWait ticks have passed since pxTimeOut was last updated (either by
  3224. * vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred.
  3225. * If the timeout has not occurred, pxTicksToWait is updated to reflect the
  3226. * number of remaining ticks.
  3227. *
  3228. * @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is
  3229. * returned and pxTicksToWait is updated to reflect the number of remaining
  3230. * ticks.
  3231. *
  3232. * @see https://www.FreeRTOS.org/xTaskCheckForTimeOut.html
  3233. *
  3234. * Example Usage:
  3235. * @code{c}
  3236. * // Driver library function used to receive uxWantedBytes from an Rx buffer
  3237. * // that is filled by a UART interrupt. If there are not enough bytes in the
  3238. * // Rx buffer then the task enters the Blocked state until it is notified that
  3239. * // more data has been placed into the buffer. If there is still not enough
  3240. * // data then the task re-enters the Blocked state, and xTaskCheckForTimeOut()
  3241. * // is used to re-calculate the Block time to ensure the total amount of time
  3242. * // spent in the Blocked state does not exceed MAX_TIME_TO_WAIT. This
  3243. * // continues until either the buffer contains at least uxWantedBytes bytes,
  3244. * // or the total amount of time spent in the Blocked state reaches
  3245. * // MAX_TIME_TO_WAIT - at which point the task reads however many bytes are
  3246. * // available up to a maximum of uxWantedBytes.
  3247. *
  3248. * size_t xUART_Receive( uint8_t *pucBuffer, size_t uxWantedBytes )
  3249. * {
  3250. * size_t uxReceived = 0;
  3251. * TickType_t xTicksToWait = MAX_TIME_TO_WAIT;
  3252. * TimeOut_t xTimeOut;
  3253. *
  3254. * // Initialize xTimeOut. This records the time at which this function
  3255. * // was entered.
  3256. * vTaskSetTimeOutState( &xTimeOut );
  3257. *
  3258. * // Loop until the buffer contains the wanted number of bytes, or a
  3259. * // timeout occurs.
  3260. * while( UART_bytes_in_rx_buffer( pxUARTInstance ) < uxWantedBytes )
  3261. * {
  3262. * // The buffer didn't contain enough data so this task is going to
  3263. * // enter the Blocked state. Adjusting xTicksToWait to account for
  3264. * // any time that has been spent in the Blocked state within this
  3265. * // function so far to ensure the total amount of time spent in the
  3266. * // Blocked state does not exceed MAX_TIME_TO_WAIT.
  3267. * if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) != pdFALSE )
  3268. * {
  3269. * //Timed out before the wanted number of bytes were available,
  3270. * // exit the loop.
  3271. * break;
  3272. * }
  3273. *
  3274. * // Wait for a maximum of xTicksToWait ticks to be notified that the
  3275. * // receive interrupt has placed more data into the buffer.
  3276. * ulTaskNotifyTake( pdTRUE, xTicksToWait );
  3277. * }
  3278. *
  3279. * // Attempt to read uxWantedBytes from the receive buffer into pucBuffer.
  3280. * // The actual number of bytes read (which might be less than
  3281. * // uxWantedBytes) is returned.
  3282. * uxReceived = UART_read_from_receive_buffer( pxUARTInstance,
  3283. * pucBuffer,
  3284. * uxWantedBytes );
  3285. *
  3286. * return uxReceived;
  3287. * }
  3288. * @endcode
  3289. * \defgroup xTaskCheckForTimeOut xTaskCheckForTimeOut
  3290. * \ingroup TaskCtrl
  3291. */
  3292. BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut,
  3293. TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;
  3294. /**
  3295. * task.h
  3296. * @code{c}
  3297. * BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp );
  3298. * @endcode
  3299. *
  3300. * This function corrects the tick count value after the application code has held
  3301. * interrupts disabled for an extended period resulting in tick interrupts having
  3302. * been missed.
  3303. *
  3304. * This function is similar to vTaskStepTick(), however, unlike
  3305. * vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a
  3306. * time at which a task should be removed from the blocked state. That means
  3307. * tasks may have to be removed from the blocked state as the tick count is
  3308. * moved.
  3309. *
  3310. * @param xTicksToCatchUp The number of tick interrupts that have been missed due to
  3311. * interrupts being disabled. Its value is not computed automatically, so must be
  3312. * computed by the application writer.
  3313. *
  3314. * @return pdTRUE if moving the tick count forward resulted in a task leaving the
  3315. * blocked state and a context switch being performed. Otherwise pdFALSE.
  3316. *
  3317. * \defgroup xTaskCatchUpTicks xTaskCatchUpTicks
  3318. * \ingroup TaskCtrl
  3319. */
  3320. BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION;
  3321. /**
  3322. * task.h
  3323. * @code{c}
  3324. * void vTaskResetState( void );
  3325. * @endcode
  3326. *
  3327. * This function resets the internal state of the task. It must be called by the
  3328. * application before restarting the scheduler.
  3329. *
  3330. * \defgroup vTaskResetState vTaskResetState
  3331. * \ingroup SchedulerControl
  3332. */
  3333. void vTaskResetState( void ) PRIVILEGED_FUNCTION;
  3334. /*-----------------------------------------------------------
  3335. * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
  3336. *----------------------------------------------------------*/
  3337. #if ( configNUMBER_OF_CORES == 1 )
  3338. #define taskYIELD_WITHIN_API() portYIELD_WITHIN_API()
  3339. #else /* #if ( configNUMBER_OF_CORES == 1 ) */
  3340. #define taskYIELD_WITHIN_API() vTaskYieldWithinAPI()
  3341. #endif /* #if ( configNUMBER_OF_CORES == 1 ) */
  3342. /*
  3343. * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
  3344. * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
  3345. * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
  3346. *
  3347. * Called from the real time kernel tick (either preemptive or cooperative),
  3348. * this increments the tick count and checks if any tasks that are blocked
  3349. * for a finite period required removing from a blocked list and placing on
  3350. * a ready list. If a non-zero value is returned then a context switch is
  3351. * required because either:
  3352. * + A task was removed from a blocked list because its timeout had expired,
  3353. * or
  3354. * + Time slicing is in use and there is a task of equal priority to the
  3355. * currently running task.
  3356. */
  3357. BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;
  3358. /*
  3359. * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
  3360. * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
  3361. *
  3362. * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
  3363. *
  3364. * Removes the calling task from the ready list and places it both
  3365. * on the list of tasks waiting for a particular event, and the
  3366. * list of delayed tasks. The task will be removed from both lists
  3367. * and replaced on the ready list should either the event occur (and
  3368. * there be no higher priority tasks waiting on the same event) or
  3369. * the delay period expires.
  3370. *
  3371. * The 'unordered' version replaces the event list item value with the
  3372. * xItemValue value, and inserts the list item at the end of the list.
  3373. *
  3374. * The 'ordered' version uses the existing event list item value (which is the
  3375. * owning task's priority) to insert the list item into the event list in task
  3376. * priority order.
  3377. *
  3378. * @param pxEventList The list containing tasks that are blocked waiting
  3379. * for the event to occur.
  3380. *
  3381. * @param xItemValue The item value to use for the event list item when the
  3382. * event list is not ordered by task priority.
  3383. *
  3384. * @param xTicksToWait The maximum amount of time that the task should wait
  3385. * for the event to occur. This is specified in kernel ticks, the constant
  3386. * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time
  3387. * period.
  3388. */
  3389. void vTaskPlaceOnEventList( List_t * const pxEventList,
  3390. const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
  3391. void vTaskPlaceOnUnorderedEventList( List_t * pxEventList,
  3392. const TickType_t xItemValue,
  3393. const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
  3394. /*
  3395. * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
  3396. * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
  3397. *
  3398. * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
  3399. *
  3400. * This function performs nearly the same function as vTaskPlaceOnEventList().
  3401. * The difference being that this function does not permit tasks to block
  3402. * indefinitely, whereas vTaskPlaceOnEventList() does.
  3403. *
  3404. */
  3405. void vTaskPlaceOnEventListRestricted( List_t * const pxEventList,
  3406. TickType_t xTicksToWait,
  3407. const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;
  3408. /*
  3409. * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
  3410. * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
  3411. *
  3412. * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
  3413. *
  3414. * Removes a task from both the specified event list and the list of blocked
  3415. * tasks, and places it on a ready queue.
  3416. *
  3417. * xTaskRemoveFromEventList()/vTaskRemoveFromUnorderedEventList() will be called
  3418. * if either an event occurs to unblock a task, or the block timeout period
  3419. * expires.
  3420. *
  3421. * xTaskRemoveFromEventList() is used when the event list is in task priority
  3422. * order. It removes the list item from the head of the event list as that will
  3423. * have the highest priority owning task of all the tasks on the event list.
  3424. * vTaskRemoveFromUnorderedEventList() is used when the event list is not
  3425. * ordered and the event list items hold something other than the owning tasks
  3426. * priority. In this case the event list item value is updated to the value
  3427. * passed in the xItemValue parameter.
  3428. *
  3429. * @return pdTRUE if the task being removed has a higher priority than the task
  3430. * making the call, otherwise pdFALSE.
  3431. */
  3432. BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION;
  3433. void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem,
  3434. const TickType_t xItemValue ) PRIVILEGED_FUNCTION;
  3435. /*
  3436. * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
  3437. * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
  3438. * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
  3439. *
  3440. * Sets the pointer to the current TCB to the TCB of the highest priority task
  3441. * that is ready to run.
  3442. */
  3443. #if ( configNUMBER_OF_CORES == 1 )
  3444. portDONT_DISCARD void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;
  3445. #else
  3446. portDONT_DISCARD void vTaskSwitchContext( BaseType_t xCoreID ) PRIVILEGED_FUNCTION;
  3447. #endif
  3448. /*
  3449. * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY
  3450. * THE EVENT BITS MODULE.
  3451. */
  3452. TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION;
  3453. /*
  3454. * Return the handle of the calling task.
  3455. */
  3456. TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;
  3457. /*
  3458. * Return the handle of the task running on specified core.
  3459. */
  3460. TaskHandle_t xTaskGetCurrentTaskHandleForCore( BaseType_t xCoreID ) PRIVILEGED_FUNCTION;
  3461. /*
  3462. * Shortcut used by the queue implementation to prevent unnecessary call to
  3463. * taskYIELD();
  3464. */
  3465. void vTaskMissedYield( void ) PRIVILEGED_FUNCTION;
  3466. /*
  3467. * Returns the scheduler state as taskSCHEDULER_RUNNING,
  3468. * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.
  3469. */
  3470. BaseType_t xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION;
  3471. /*
  3472. * Raises the priority of the mutex holder to that of the calling task should
  3473. * the mutex holder have a priority less than the calling task.
  3474. */
  3475. BaseType_t xTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
  3476. /*
  3477. * Set the priority of a task back to its proper priority in the case that it
  3478. * inherited a higher priority while it was holding a semaphore.
  3479. */
  3480. BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
  3481. /*
  3482. * If a higher priority task attempting to obtain a mutex caused a lower
  3483. * priority task to inherit the higher priority task's priority - but the higher
  3484. * priority task then timed out without obtaining the mutex, then the lower
  3485. * priority task will disinherit the priority again - but only down as far as
  3486. * the highest priority task that is still waiting for the mutex (if there were
  3487. * more than one task waiting for the mutex).
  3488. */
  3489. void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder,
  3490. UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION;
  3491. /*
  3492. * Get the uxTaskNumber assigned to the task referenced by the xTask parameter.
  3493. */
  3494. #if ( configUSE_TRACE_FACILITY == 1 )
  3495. UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  3496. #endif
  3497. /*
  3498. * Set the uxTaskNumber of the task referenced by the xTask parameter to
  3499. * uxHandle.
  3500. */
  3501. #if ( configUSE_TRACE_FACILITY == 1 )
  3502. void vTaskSetTaskNumber( TaskHandle_t xTask,
  3503. const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION;
  3504. #endif
  3505. /*
  3506. * Only available when configUSE_TICKLESS_IDLE is set to 1.
  3507. * If tickless mode is being used, or a low power mode is implemented, then
  3508. * the tick interrupt will not execute during idle periods. When this is the
  3509. * case, the tick count value maintained by the scheduler needs to be kept up
  3510. * to date with the actual execution time by being skipped forward by a time
  3511. * equal to the idle period.
  3512. */
  3513. #if ( configUSE_TICKLESS_IDLE != 0 )
  3514. void vTaskStepTick( TickType_t xTicksToJump ) PRIVILEGED_FUNCTION;
  3515. #endif
  3516. /*
  3517. * Only available when configUSE_TICKLESS_IDLE is set to 1.
  3518. * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port
  3519. * specific sleep function to determine if it is ok to proceed with the sleep,
  3520. * and if it is ok to proceed, if it is ok to sleep indefinitely.
  3521. *
  3522. * This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only
  3523. * called with the scheduler suspended, not from within a critical section. It
  3524. * is therefore possible for an interrupt to request a context switch between
  3525. * portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being
  3526. * entered. eTaskConfirmSleepModeStatus() should be called from a short
  3527. * critical section between the timer being stopped and the sleep mode being
  3528. * entered to ensure it is ok to proceed into the sleep mode.
  3529. */
  3530. #if ( configUSE_TICKLESS_IDLE != 0 )
  3531. eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;
  3532. #endif
  3533. /*
  3534. * For internal use only. Increment the mutex held count when a mutex is
  3535. * taken and return the handle of the task that has taken the mutex.
  3536. */
  3537. TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;
  3538. /*
  3539. * For internal use only. Same as vTaskSetTimeOutState(), but without a critical
  3540. * section.
  3541. */
  3542. void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
  3543. /*
  3544. * For internal use only. Same as portYIELD_WITHIN_API() in single core FreeRTOS.
  3545. * For SMP this is not defined by the port.
  3546. */
  3547. #if ( configNUMBER_OF_CORES > 1 )
  3548. void vTaskYieldWithinAPI( void );
  3549. #endif
  3550. /*
  3551. * This function is only intended for use when implementing a port of the scheduler
  3552. * and is only available when portCRITICAL_NESTING_IN_TCB is set to 1 or configNUMBER_OF_CORES
  3553. * is greater than 1. This function can be used in the implementation of portENTER_CRITICAL
  3554. * if port wants to maintain critical nesting count in TCB in single core FreeRTOS.
  3555. * It should be used in the implementation of portENTER_CRITICAL if port is running a
  3556. * multiple core FreeRTOS.
  3557. */
  3558. #if ( ( portCRITICAL_NESTING_IN_TCB == 1 ) || ( configNUMBER_OF_CORES > 1 ) )
  3559. void vTaskEnterCritical( void );
  3560. #endif
  3561. /*
  3562. * This function is only intended for use when implementing a port of the scheduler
  3563. * and is only available when portCRITICAL_NESTING_IN_TCB is set to 1 or configNUMBER_OF_CORES
  3564. * is greater than 1. This function can be used in the implementation of portEXIT_CRITICAL
  3565. * if port wants to maintain critical nesting count in TCB in single core FreeRTOS.
  3566. * It should be used in the implementation of portEXIT_CRITICAL if port is running a
  3567. * multiple core FreeRTOS.
  3568. */
  3569. #if ( ( portCRITICAL_NESTING_IN_TCB == 1 ) || ( configNUMBER_OF_CORES > 1 ) )
  3570. void vTaskExitCritical( void );
  3571. #endif
  3572. /*
  3573. * This function is only intended for use when implementing a port of the scheduler
  3574. * and is only available when configNUMBER_OF_CORES is greater than 1. This function
  3575. * should be used in the implementation of portENTER_CRITICAL_FROM_ISR if port is
  3576. * running a multiple core FreeRTOS.
  3577. */
  3578. #if ( configNUMBER_OF_CORES > 1 )
  3579. UBaseType_t vTaskEnterCriticalFromISR( void );
  3580. #endif
  3581. /*
  3582. * This function is only intended for use when implementing a port of the scheduler
  3583. * and is only available when configNUMBER_OF_CORES is greater than 1. This function
  3584. * should be used in the implementation of portEXIT_CRITICAL_FROM_ISR if port is
  3585. * running a multiple core FreeRTOS.
  3586. */
  3587. #if ( configNUMBER_OF_CORES > 1 )
  3588. void vTaskExitCriticalFromISR( UBaseType_t uxSavedInterruptStatus );
  3589. #endif
  3590. #if ( portUSING_MPU_WRAPPERS == 1 )
  3591. /*
  3592. * For internal use only. Get MPU settings associated with a task.
  3593. */
  3594. xMPU_SETTINGS * xTaskGetMPUSettings( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  3595. #endif /* portUSING_MPU_WRAPPERS */
  3596. #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) && ( configENABLE_ACCESS_CONTROL_LIST == 1 ) )
  3597. /*
  3598. * For internal use only. Grant/Revoke a task's access to a kernel object.
  3599. */
  3600. void vGrantAccessToKernelObject( TaskHandle_t xExternalTaskHandle,
  3601. int32_t lExternalKernelObjectHandle ) PRIVILEGED_FUNCTION;
  3602. void vRevokeAccessToKernelObject( TaskHandle_t xExternalTaskHandle,
  3603. int32_t lExternalKernelObjectHandle ) PRIVILEGED_FUNCTION;
  3604. /*
  3605. * For internal use only. Grant/Revoke a task's access to a kernel object.
  3606. */
  3607. void vPortGrantAccessToKernelObject( TaskHandle_t xInternalTaskHandle,
  3608. int32_t lInternalIndexOfKernelObject ) PRIVILEGED_FUNCTION;
  3609. void vPortRevokeAccessToKernelObject( TaskHandle_t xInternalTaskHandle,
  3610. int32_t lInternalIndexOfKernelObject ) PRIVILEGED_FUNCTION;
  3611. #endif /* #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) && ( configENABLE_ACCESS_CONTROL_LIST == 1 ) ) */
  3612. /* *INDENT-OFF* */
  3613. #ifdef __cplusplus
  3614. }
  3615. #endif
  3616. /* *INDENT-ON* */
  3617. #endif /* INC_TASK_H */