task.h 166 KB

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