ucos_ii.h 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970
  1. /*
  2. *********************************************************************************************************
  3. * uC/OS-II
  4. * The Real-Time Kernel
  5. *
  6. * (c) Copyright 1992-2013, Micrium, Weston, FL
  7. * All Rights Reserved
  8. *
  9. * File : uCOS_II.H
  10. * By : Jean J. Labrosse
  11. * Version : V2.92.11
  12. *
  13. * LICENSING TERMS:
  14. * ---------------
  15. * uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research.
  16. * If you plan on using uC/OS-II in a commercial product you need to contact Micrium to properly license
  17. * its use in your product. We provide ALL the source code for your convenience and to help you experience
  18. * uC/OS-II. The fact that the source is provided does NOT mean that you can use it without paying a
  19. * licensing fee.
  20. *********************************************************************************************************
  21. */
  22. #ifndef OS_uCOS_II_H
  23. #define OS_uCOS_II_H
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. /*
  29. *********************************************************************************************************
  30. * uC/OS-II VERSION NUMBER
  31. *********************************************************************************************************
  32. */
  33. #define OS_VERSION 29211u /* Version of uC/OS-II (Vx.yy mult. by 10000) */
  34. /*
  35. *********************************************************************************************************
  36. * INCLUDE HEADER FILES
  37. *********************************************************************************************************
  38. */
  39. // #include <app_cfg.h>
  40. #include <os_cfg.h>
  41. #include <os_cpu.h>
  42. /*
  43. *********************************************************************************************************
  44. * MISCELLANEOUS
  45. *********************************************************************************************************
  46. */
  47. #ifdef OS_GLOBALS
  48. #define OS_EXT
  49. #else
  50. #define OS_EXT extern
  51. #endif
  52. #ifndef OS_FALSE
  53. #define OS_FALSE 0u
  54. #endif
  55. #ifndef OS_TRUE
  56. #define OS_TRUE 1u
  57. #endif
  58. #define OS_ASCII_NUL (INT8U)0
  59. #define OS_PRIO_SELF 0xFFu /* Indicate SELF priority */
  60. #define OS_PRIO_MUTEX_CEIL_DIS 0xFFu /* Disable mutex priority ceiling promotion */
  61. #if OS_TASK_STAT_EN > 0u
  62. #define OS_N_SYS_TASKS 2u /* Number of system tasks */
  63. #else
  64. #define OS_N_SYS_TASKS 1u
  65. #endif
  66. #define OS_TASK_STAT_PRIO (OS_LOWEST_PRIO - 1u) /* Statistic task priority */
  67. #define OS_TASK_IDLE_PRIO (OS_LOWEST_PRIO) /* IDLE task priority */
  68. #if OS_LOWEST_PRIO <= 63u
  69. #define OS_EVENT_TBL_SIZE ((OS_LOWEST_PRIO) / 8u + 1u) /* Size of event table */
  70. #define OS_RDY_TBL_SIZE ((OS_LOWEST_PRIO) / 8u + 1u) /* Size of ready table */
  71. #else
  72. #define OS_EVENT_TBL_SIZE ((OS_LOWEST_PRIO) / 16u + 1u) /* Size of event table */
  73. #define OS_RDY_TBL_SIZE ((OS_LOWEST_PRIO) / 16u + 1u) /* Size of ready table */
  74. #endif
  75. #define OS_TASK_IDLE_ID 65535u /* ID numbers for Idle, Stat and Timer tasks */
  76. #define OS_TASK_STAT_ID 65534u
  77. #define OS_TASK_TMR_ID 65533u
  78. #define OS_EVENT_EN (((OS_Q_EN > 0u) && (OS_MAX_QS > 0u)) || (OS_MBOX_EN > 0u) || (OS_SEM_EN > 0u) || (OS_MUTEX_EN > 0u))
  79. #define OS_TCB_RESERVED ((OS_TCB *)1)
  80. /*$PAGE*/
  81. /*
  82. *********************************************************************************************************
  83. * TASK STATUS (Bit definition for OSTCBStat)
  84. *********************************************************************************************************
  85. */
  86. #define OS_STAT_RDY 0x00u /* Ready to run */
  87. #define OS_STAT_SEM 0x01u /* Pending on semaphore */
  88. #define OS_STAT_MBOX 0x02u /* Pending on mailbox */
  89. #define OS_STAT_Q 0x04u /* Pending on queue */
  90. #define OS_STAT_SUSPEND 0x08u /* Task is suspended */
  91. #define OS_STAT_MUTEX 0x10u /* Pending on mutual exclusion semaphore */
  92. #define OS_STAT_FLAG 0x20u /* Pending on event flag group */
  93. #define OS_STAT_MULTI 0x80u /* Pending on multiple events */
  94. #define OS_STAT_PEND_ANY (OS_STAT_SEM | OS_STAT_MBOX | OS_STAT_Q | OS_STAT_MUTEX | OS_STAT_FLAG)
  95. /*
  96. *********************************************************************************************************
  97. * TASK PEND STATUS (Status codes for OSTCBStatPend)
  98. *********************************************************************************************************
  99. */
  100. #define OS_STAT_PEND_OK 0u /* Pending status OK, not pending, or pending complete */
  101. #define OS_STAT_PEND_TO 1u /* Pending timed out */
  102. #define OS_STAT_PEND_ABORT 2u /* Pending aborted */
  103. /*
  104. *********************************************************************************************************
  105. * OS_EVENT types
  106. *********************************************************************************************************
  107. */
  108. #define OS_EVENT_TYPE_UNUSED 0u
  109. #define OS_EVENT_TYPE_MBOX 1u
  110. #define OS_EVENT_TYPE_Q 2u
  111. #define OS_EVENT_TYPE_SEM 3u
  112. #define OS_EVENT_TYPE_MUTEX 4u
  113. #define OS_EVENT_TYPE_FLAG 5u
  114. #define OS_TMR_TYPE 100u /* Used to identify Timers ... */
  115. /* ... (Must be different value than OS_EVENT_TYPE_xxx) */
  116. /*
  117. *********************************************************************************************************
  118. * EVENT FLAGS
  119. *********************************************************************************************************
  120. */
  121. #define OS_FLAG_WAIT_CLR_ALL 0u /* Wait for ALL the bits specified to be CLR (i.e. 0) */
  122. #define OS_FLAG_WAIT_CLR_AND 0u
  123. #define OS_FLAG_WAIT_CLR_ANY 1u /* Wait for ANY of the bits specified to be CLR (i.e. 0) */
  124. #define OS_FLAG_WAIT_CLR_OR 1u
  125. #define OS_FLAG_WAIT_SET_ALL 2u /* Wait for ALL the bits specified to be SET (i.e. 1) */
  126. #define OS_FLAG_WAIT_SET_AND 2u
  127. #define OS_FLAG_WAIT_SET_ANY 3u /* Wait for ANY of the bits specified to be SET (i.e. 1) */
  128. #define OS_FLAG_WAIT_SET_OR 3u
  129. #define OS_FLAG_CONSUME 0x80u /* Consume the flags if condition(s) satisfied */
  130. #define OS_FLAG_CLR 0u
  131. #define OS_FLAG_SET 1u
  132. /*
  133. *********************************************************************************************************
  134. * Values for OSTickStepState
  135. *
  136. * Note(s): This feature is used by uC/OS-View.
  137. *********************************************************************************************************
  138. */
  139. #if OS_TICK_STEP_EN > 0u
  140. #define OS_TICK_STEP_DIS 0u /* Stepping is disabled, tick runs as normal */
  141. #define OS_TICK_STEP_WAIT 1u /* Waiting for uC/OS-View to set OSTickStepState to _ONCE */
  142. #define OS_TICK_STEP_ONCE 2u /* Process tick once and wait for next cmd from uC/OS-View */
  143. #endif
  144. /*
  145. *********************************************************************************************************
  146. * Possible values for 'opt' argument of OSSemDel(), OSMboxDel(), OSQDel() and OSMutexDel()
  147. *********************************************************************************************************
  148. */
  149. #define OS_DEL_NO_PEND 0u
  150. #define OS_DEL_ALWAYS 1u
  151. /*
  152. *********************************************************************************************************
  153. * OS???Pend() OPTIONS
  154. *
  155. * These #defines are used to establish the options for OS???PendAbort().
  156. *********************************************************************************************************
  157. */
  158. #define OS_PEND_OPT_NONE 0u /* NO option selected */
  159. #define OS_PEND_OPT_BROADCAST 1u /* Broadcast action to ALL tasks waiting */
  160. /*
  161. *********************************************************************************************************
  162. * OS???PostOpt() OPTIONS
  163. *
  164. * These #defines are used to establish the options for OSMboxPostOpt() and OSQPostOpt().
  165. *********************************************************************************************************
  166. */
  167. #define OS_POST_OPT_NONE 0x00u /* NO option selected */
  168. #define OS_POST_OPT_BROADCAST 0x01u /* Broadcast message to ALL tasks waiting */
  169. #define OS_POST_OPT_FRONT 0x02u /* Post to highest priority task waiting */
  170. #define OS_POST_OPT_NO_SCHED 0x04u /* Do not call the scheduler if this option is selected */
  171. /*
  172. *********************************************************************************************************
  173. * TASK OPTIONS (see OSTaskCreateExt())
  174. *********************************************************************************************************
  175. */
  176. #define OS_TASK_OPT_NONE 0x0000u /* NO option selected */
  177. #define OS_TASK_OPT_STK_CHK 0x0001u /* Enable stack checking for the task */
  178. #define OS_TASK_OPT_STK_CLR 0x0002u /* Clear the stack when the task is create */
  179. #define OS_TASK_OPT_SAVE_FP 0x0004u /* Save the contents of any floating-point registers */
  180. #define OS_TASK_OPT_NO_TLS 0x0008u /* Specify that task doesn't needs TLS */
  181. /*
  182. *********************************************************************************************************
  183. * TIMER OPTIONS (see OSTmrStart() and OSTmrStop())
  184. *********************************************************************************************************
  185. */
  186. #define OS_TMR_OPT_NONE 0u /* No option selected */
  187. #define OS_TMR_OPT_ONE_SHOT 1u /* Timer will not automatically restart when it expires */
  188. #define OS_TMR_OPT_PERIODIC 2u /* Timer will automatically restart when it expires */
  189. #define OS_TMR_OPT_CALLBACK 3u /* OSTmrStop() option to call 'callback' w/ timer arg. */
  190. #define OS_TMR_OPT_CALLBACK_ARG 4u /* OSTmrStop() option to call 'callback' w/ new arg. */
  191. /*
  192. *********************************************************************************************************
  193. * TIMER STATES
  194. *********************************************************************************************************
  195. */
  196. #define OS_TMR_STATE_UNUSED 0u
  197. #define OS_TMR_STATE_STOPPED 1u
  198. #define OS_TMR_STATE_COMPLETED 2u
  199. #define OS_TMR_STATE_RUNNING 3u
  200. /*
  201. *********************************************************************************************************
  202. * ERROR CODES
  203. *********************************************************************************************************
  204. */
  205. #define OS_ERR_NONE 0u
  206. #define OS_ERR_EVENT_TYPE 1u
  207. #define OS_ERR_PEND_ISR 2u
  208. #define OS_ERR_POST_NULL_PTR 3u
  209. #define OS_ERR_PEVENT_NULL 4u
  210. #define OS_ERR_POST_ISR 5u
  211. #define OS_ERR_QUERY_ISR 6u
  212. #define OS_ERR_INVALID_OPT 7u
  213. #define OS_ERR_ID_INVALID 8u
  214. #define OS_ERR_PDATA_NULL 9u
  215. #define OS_ERR_TIMEOUT 10u
  216. #define OS_ERR_EVENT_NAME_TOO_LONG 11u
  217. #define OS_ERR_PNAME_NULL 12u
  218. #define OS_ERR_PEND_LOCKED 13u
  219. #define OS_ERR_PEND_ABORT 14u
  220. #define OS_ERR_DEL_ISR 15u
  221. #define OS_ERR_CREATE_ISR 16u
  222. #define OS_ERR_NAME_GET_ISR 17u
  223. #define OS_ERR_NAME_SET_ISR 18u
  224. #define OS_ERR_ILLEGAL_CREATE_RUN_TIME 19u
  225. #define OS_ERR_MBOX_FULL 20u
  226. #define OS_ERR_Q_FULL 30u
  227. #define OS_ERR_Q_EMPTY 31u
  228. #define OS_ERR_PRIO_EXIST 40u
  229. #define OS_ERR_PRIO 41u
  230. #define OS_ERR_PRIO_INVALID 42u
  231. #define OS_ERR_SCHED_LOCKED 50u
  232. #define OS_ERR_SEM_OVF 51u
  233. #define OS_ERR_TASK_CREATE_ISR 60u
  234. #define OS_ERR_TASK_DEL 61u
  235. #define OS_ERR_TASK_DEL_IDLE 62u
  236. #define OS_ERR_TASK_DEL_REQ 63u
  237. #define OS_ERR_TASK_DEL_ISR 64u
  238. #define OS_ERR_TASK_NAME_TOO_LONG 65u
  239. #define OS_ERR_TASK_NO_MORE_TCB 66u
  240. #define OS_ERR_TASK_NOT_EXIST 67u
  241. #define OS_ERR_TASK_NOT_SUSPENDED 68u
  242. #define OS_ERR_TASK_OPT 69u
  243. #define OS_ERR_TASK_RESUME_PRIO 70u
  244. #define OS_ERR_TASK_SUSPEND_IDLE 71u
  245. #define OS_ERR_TASK_SUSPEND_PRIO 72u
  246. #define OS_ERR_TASK_WAITING 73u
  247. #define OS_ERR_TIME_NOT_DLY 80u
  248. #define OS_ERR_TIME_INVALID_MINUTES 81u
  249. #define OS_ERR_TIME_INVALID_SECONDS 82u
  250. #define OS_ERR_TIME_INVALID_MS 83u
  251. #define OS_ERR_TIME_ZERO_DLY 84u
  252. #define OS_ERR_TIME_DLY_ISR 85u
  253. #define OS_ERR_MEM_INVALID_PART 90u
  254. #define OS_ERR_MEM_INVALID_BLKS 91u
  255. #define OS_ERR_MEM_INVALID_SIZE 92u
  256. #define OS_ERR_MEM_NO_FREE_BLKS 93u
  257. #define OS_ERR_MEM_FULL 94u
  258. #define OS_ERR_MEM_INVALID_PBLK 95u
  259. #define OS_ERR_MEM_INVALID_PMEM 96u
  260. #define OS_ERR_MEM_INVALID_PDATA 97u
  261. #define OS_ERR_MEM_INVALID_ADDR 98u
  262. #define OS_ERR_MEM_NAME_TOO_LONG 99u
  263. #define OS_ERR_NOT_MUTEX_OWNER 100u
  264. #define OS_ERR_FLAG_INVALID_PGRP 110u
  265. #define OS_ERR_FLAG_WAIT_TYPE 111u
  266. #define OS_ERR_FLAG_NOT_RDY 112u
  267. #define OS_ERR_FLAG_INVALID_OPT 113u
  268. #define OS_ERR_FLAG_GRP_DEPLETED 114u
  269. #define OS_ERR_FLAG_NAME_TOO_LONG 115u
  270. #define OS_ERR_PCP_LOWER 120u
  271. #define OS_ERR_TMR_INVALID_DLY 130u
  272. #define OS_ERR_TMR_INVALID_PERIOD 131u
  273. #define OS_ERR_TMR_INVALID_OPT 132u
  274. #define OS_ERR_TMR_INVALID_NAME 133u
  275. #define OS_ERR_TMR_NON_AVAIL 134u
  276. #define OS_ERR_TMR_INACTIVE 135u
  277. #define OS_ERR_TMR_INVALID_DEST 136u
  278. #define OS_ERR_TMR_INVALID_TYPE 137u
  279. #define OS_ERR_TMR_INVALID 138u
  280. #define OS_ERR_TMR_ISR 139u
  281. #define OS_ERR_TMR_NAME_TOO_LONG 140u
  282. #define OS_ERR_TMR_INVALID_STATE 141u
  283. #define OS_ERR_TMR_STOPPED 142u
  284. #define OS_ERR_TMR_NO_CALLBACK 143u
  285. #define OS_ERR_NO_MORE_ID_AVAIL 150u
  286. #define OS_ERR_TLS_NO_MORE_AVAIL 160u
  287. #define OS_ERR_TLS_ID_INVALID 161u
  288. #define OS_ERR_TLS_NOT_EN 162u
  289. #define OS_ERR_TLS_DESTRUCT_ASSIGNED 163u
  290. #define OS_ERR_OS_NOT_RUNNING 164u
  291. /*$PAGE*/
  292. /*
  293. *********************************************************************************************************
  294. * THREAD LOCAL STORAGE (TLS)
  295. *********************************************************************************************************
  296. */
  297. #if OS_TASK_CREATE_EXT_EN > 0u
  298. #if defined(OS_TLS_TBL_SIZE) && (OS_TLS_TBL_SIZE > 0u)
  299. typedef void *OS_TLS;
  300. typedef INT8U OS_TLS_ID;
  301. #endif
  302. #endif
  303. /*
  304. *********************************************************************************************************
  305. * EVENT CONTROL BLOCK
  306. *********************************************************************************************************
  307. */
  308. #if OS_LOWEST_PRIO <= 63u
  309. typedef INT8U OS_PRIO;
  310. #else
  311. typedef INT16U OS_PRIO;
  312. #endif
  313. #if (OS_EVENT_EN) && (OS_MAX_EVENTS > 0u)
  314. typedef struct os_event
  315. {
  316. INT8U OSEventType; /* Type of event control block (see OS_EVENT_TYPE_xxxx) */
  317. void *OSEventPtr; /* Pointer to message or queue structure */
  318. INT16U OSEventCnt; /* Semaphore Count (not used if other EVENT type) */
  319. OS_PRIO OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
  320. OS_PRIO OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
  321. #if OS_EVENT_NAME_EN > 0u
  322. INT8U *OSEventName;
  323. #endif
  324. } OS_EVENT;
  325. #endif
  326. /*
  327. *********************************************************************************************************
  328. * EVENT FLAGS CONTROL BLOCK
  329. *********************************************************************************************************
  330. */
  331. #if (OS_FLAG_EN > 0u) && (OS_MAX_FLAGS > 0u)
  332. #if OS_FLAGS_NBITS == 8u /* Determine the size of OS_FLAGS (8, 16 or 32 bits) */
  333. typedef INT8U OS_FLAGS;
  334. #endif
  335. #if OS_FLAGS_NBITS == 16u
  336. typedef INT16U OS_FLAGS;
  337. #endif
  338. #if OS_FLAGS_NBITS == 32u
  339. typedef INT32U OS_FLAGS;
  340. #endif
  341. typedef struct os_flag_grp
  342. { /* Event Flag Group */
  343. INT8U OSFlagType; /* Should be set to OS_EVENT_TYPE_FLAG */
  344. void *OSFlagWaitList; /* Pointer to first NODE of task waiting on event flag */
  345. OS_FLAGS OSFlagFlags; /* 8, 16 or 32 bit flags */
  346. #if OS_FLAG_NAME_EN > 0u
  347. INT8U *OSFlagName;
  348. #endif
  349. } OS_FLAG_GRP;
  350. typedef struct os_flag_node
  351. { /* Event Flag Wait List Node */
  352. void *OSFlagNodeNext; /* Pointer to next NODE in wait list */
  353. void *OSFlagNodePrev; /* Pointer to previous NODE in wait list */
  354. void *OSFlagNodeTCB; /* Pointer to TCB of waiting task */
  355. void *OSFlagNodeFlagGrp; /* Pointer to Event Flag Group */
  356. OS_FLAGS OSFlagNodeFlags; /* Event flag to wait on */
  357. INT8U OSFlagNodeWaitType; /* Type of wait: */
  358. /* OS_FLAG_WAIT_AND */
  359. /* OS_FLAG_WAIT_ALL */
  360. /* OS_FLAG_WAIT_OR */
  361. /* OS_FLAG_WAIT_ANY */
  362. } OS_FLAG_NODE;
  363. #endif
  364. /*$PAGE*/
  365. /*
  366. *********************************************************************************************************
  367. * MESSAGE MAILBOX DATA
  368. *********************************************************************************************************
  369. */
  370. #if OS_MBOX_EN > 0u
  371. typedef struct os_mbox_data
  372. {
  373. void *OSMsg; /* Pointer to message in mailbox */
  374. OS_PRIO OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
  375. OS_PRIO OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
  376. } OS_MBOX_DATA;
  377. #endif
  378. /*
  379. *********************************************************************************************************
  380. * MEMORY PARTITION DATA STRUCTURES
  381. *********************************************************************************************************
  382. */
  383. #if (OS_MEM_EN > 0u) && (OS_MAX_MEM_PART > 0u)
  384. typedef struct os_mem
  385. { /* MEMORY CONTROL BLOCK */
  386. void *OSMemAddr; /* Pointer to beginning of memory partition */
  387. void *OSMemFreeList; /* Pointer to list of free memory blocks */
  388. INT32U OSMemBlkSize; /* Size (in bytes) of each block of memory */
  389. INT32U OSMemNBlks; /* Total number of blocks in this partition */
  390. INT32U OSMemNFree; /* Number of memory blocks remaining in this partition */
  391. #if OS_MEM_NAME_EN > 0u
  392. INT8U *OSMemName; /* Memory partition name */
  393. #endif
  394. } OS_MEM;
  395. typedef struct os_mem_data
  396. {
  397. void *OSAddr; /* Ptr to the beginning address of the memory partition */
  398. void *OSFreeList; /* Ptr to the beginning of the free list of memory blocks */
  399. INT32U OSBlkSize; /* Size (in bytes) of each memory block */
  400. INT32U OSNBlks; /* Total number of blocks in the partition */
  401. INT32U OSNFree; /* Number of memory blocks free */
  402. INT32U OSNUsed; /* Number of memory blocks used */
  403. } OS_MEM_DATA;
  404. #endif
  405. /*$PAGE*/
  406. /*
  407. *********************************************************************************************************
  408. * MUTUAL EXCLUSION SEMAPHORE DATA
  409. *********************************************************************************************************
  410. */
  411. #if OS_MUTEX_EN > 0u
  412. typedef struct os_mutex_data
  413. {
  414. OS_PRIO OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
  415. OS_PRIO OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
  416. BOOLEAN OSValue; /* Mutex value (OS_FALSE = used, OS_TRUE = available) */
  417. INT8U OSOwnerPrio; /* Mutex owner's task priority or 0xFF if no owner */
  418. INT8U OSMutexPCP; /* Priority Ceiling Priority or 0xFF if PCP disabled */
  419. } OS_MUTEX_DATA;
  420. #endif
  421. /*
  422. *********************************************************************************************************
  423. * MESSAGE QUEUE DATA
  424. *********************************************************************************************************
  425. */
  426. #if OS_Q_EN > 0u
  427. typedef struct os_q
  428. { /* QUEUE CONTROL BLOCK */
  429. struct os_q *OSQPtr; /* Link to next queue control block in list of free blocks */
  430. void **OSQStart; /* Ptr to start of queue data */
  431. void **OSQEnd; /* Ptr to end of queue data */
  432. void **OSQIn; /* Ptr to where next message will be inserted in the Q */
  433. void **OSQOut; /* Ptr to where next message will be extracted from the Q */
  434. INT16U OSQSize; /* Size of queue (maximum number of entries) */
  435. INT16U OSQEntries; /* Current number of entries in the queue */
  436. } OS_Q;
  437. typedef struct os_q_data
  438. {
  439. void *OSMsg; /* Pointer to next message to be extracted from queue */
  440. INT16U OSNMsgs; /* Number of messages in message queue */
  441. INT16U OSQSize; /* Size of message queue */
  442. OS_PRIO OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
  443. OS_PRIO OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
  444. } OS_Q_DATA;
  445. #endif
  446. /*
  447. *********************************************************************************************************
  448. * SEMAPHORE DATA
  449. *********************************************************************************************************
  450. */
  451. #if OS_SEM_EN > 0u
  452. typedef struct os_sem_data
  453. {
  454. INT16U OSCnt; /* Semaphore count */
  455. OS_PRIO OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
  456. OS_PRIO OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
  457. } OS_SEM_DATA;
  458. #endif
  459. /*
  460. *********************************************************************************************************
  461. * TASK STACK DATA
  462. *********************************************************************************************************
  463. */
  464. #if OS_TASK_CREATE_EXT_EN > 0u
  465. typedef struct os_stk_data
  466. {
  467. INT32U OSFree; /* Number of free entries on the stack */
  468. INT32U OSUsed; /* Number of entries used on the stack */
  469. } OS_STK_DATA;
  470. #endif
  471. /*$PAGE*/
  472. /*
  473. *********************************************************************************************************
  474. * TASK CONTROL BLOCK
  475. *********************************************************************************************************
  476. */
  477. typedef struct os_tcb
  478. {
  479. OS_STK *OSTCBStkPtr; /* Pointer to current top of stack */
  480. #if OS_TASK_CREATE_EXT_EN > 0u
  481. void *OSTCBExtPtr; /* Pointer to user definable data for TCB extension */
  482. OS_STK *OSTCBStkBottom; /* Pointer to bottom of stack */
  483. INT32U OSTCBStkSize; /* Size of task stack (in number of stack elements) */
  484. INT16U OSTCBOpt; /* Task options as passed by OSTaskCreateExt() */
  485. INT16U OSTCBId; /* Task ID (0..65535) */
  486. #endif
  487. struct os_tcb *OSTCBNext; /* Pointer to next TCB in the TCB list */
  488. struct os_tcb *OSTCBPrev; /* Pointer to previous TCB in the TCB list */
  489. #if OS_TASK_CREATE_EXT_EN > 0u
  490. #if defined(OS_TLS_TBL_SIZE) && (OS_TLS_TBL_SIZE > 0u)
  491. OS_TLS OSTCBTLSTbl[OS_TLS_TBL_SIZE];
  492. #endif
  493. #endif
  494. #if (OS_EVENT_EN)
  495. OS_EVENT *OSTCBEventPtr; /* Pointer to event control block */
  496. #endif
  497. #if (OS_EVENT_EN) && (OS_EVENT_MULTI_EN > 0u)
  498. OS_EVENT **OSTCBEventMultiPtr; /* Pointer to multiple event control blocks */
  499. #endif
  500. #if ((OS_Q_EN > 0u) && (OS_MAX_QS > 0u)) || (OS_MBOX_EN > 0u)
  501. void *OSTCBMsg; /* Message received from OSMboxPost() or OSQPost() */
  502. #endif
  503. #if (OS_FLAG_EN > 0u) && (OS_MAX_FLAGS > 0u)
  504. #if OS_TASK_DEL_EN > 0u
  505. OS_FLAG_NODE *OSTCBFlagNode; /* Pointer to event flag node */
  506. #endif
  507. OS_FLAGS OSTCBFlagsRdy; /* Event flags that made task ready to run */
  508. #endif
  509. INT32U OSTCBDly; /* Nbr ticks to delay task or, timeout waiting for event */
  510. INT8U OSTCBStat; /* Task status */
  511. INT8U OSTCBStatPend; /* Task PEND status */
  512. INT8U OSTCBPrio; /* Task priority (0 == highest) */
  513. INT8U OSTCBX; /* Bit position in group corresponding to task priority */
  514. INT8U OSTCBY; /* Index into ready table corresponding to task priority */
  515. OS_PRIO OSTCBBitX; /* Bit mask to access bit position in ready table */
  516. OS_PRIO OSTCBBitY; /* Bit mask to access bit position in ready group */
  517. #if OS_TASK_DEL_EN > 0u
  518. INT8U OSTCBDelReq; /* Indicates whether a task needs to delete itself */
  519. #endif
  520. #if OS_TASK_PROFILE_EN > 0u
  521. INT32U OSTCBCtxSwCtr; /* Number of time the task was switched in */
  522. INT32U OSTCBCyclesTot; /* Total number of clock cycles the task has been running */
  523. INT32U OSTCBCyclesStart; /* Snapshot of cycle counter at start of task resumption */
  524. OS_STK *OSTCBStkBase; /* Pointer to the beginning of the task stack */
  525. INT32U OSTCBStkUsed; /* Number of bytes used from the stack */
  526. #endif
  527. #if OS_TASK_NAME_EN > 0u
  528. INT8U *OSTCBTaskName;
  529. #endif
  530. #if OS_TASK_REG_TBL_SIZE > 0u
  531. INT32U OSTCBRegTbl[OS_TASK_REG_TBL_SIZE];
  532. #endif
  533. } OS_TCB;
  534. /*$PAGE*/
  535. /*
  536. *********************************************************************************************************
  537. * TIMER DATA TYPES
  538. *********************************************************************************************************
  539. */
  540. #if OS_TMR_EN > 0u
  541. typedef void (*OS_TMR_CALLBACK)(void *ptmr, void *parg);
  542. typedef struct os_tmr
  543. {
  544. INT8U OSTmrType; /* Should be set to OS_TMR_TYPE */
  545. OS_TMR_CALLBACK OSTmrCallback; /* Function to call when timer expires */
  546. void *OSTmrCallbackArg; /* Argument to pass to function when timer expires */
  547. void *OSTmrNext; /* Double link list pointers */
  548. void *OSTmrPrev;
  549. INT32U OSTmrMatch; /* Timer expires when OSTmrTime == OSTmrMatch */
  550. INT32U OSTmrDly; /* Delay time before periodic update starts */
  551. INT32U OSTmrPeriod; /* Period to repeat timer */
  552. #if OS_TMR_CFG_NAME_EN > 0u
  553. INT8U *OSTmrName; /* Name to give the timer */
  554. #endif
  555. INT8U OSTmrOpt; /* Options (see OS_TMR_OPT_xxx) */
  556. INT8U OSTmrState; /* Indicates the state of the timer: */
  557. /* OS_TMR_STATE_UNUSED */
  558. /* OS_TMR_STATE_RUNNING */
  559. /* OS_TMR_STATE_STOPPED */
  560. } OS_TMR;
  561. typedef struct os_tmr_wheel
  562. {
  563. OS_TMR *OSTmrFirst; /* Pointer to first timer in linked list */
  564. INT16U OSTmrEntries;
  565. } OS_TMR_WHEEL;
  566. #endif
  567. /*$PAGE*/
  568. /*
  569. *********************************************************************************************************
  570. * THREAD LOCAL STORAGE (TLS)
  571. *********************************************************************************************************
  572. */
  573. #if OS_TASK_CREATE_EXT_EN > 0u
  574. #if defined(OS_TLS_TBL_SIZE) && (OS_TLS_TBL_SIZE > 0u)
  575. typedef void (*OS_TLS_DESTRUCT_PTR)(OS_TCB *ptcb,
  576. OS_TLS_ID id,
  577. OS_TLS value);
  578. #endif
  579. #endif
  580. /*
  581. *********************************************************************************************************
  582. * GLOBAL VARIABLES
  583. *********************************************************************************************************
  584. */
  585. OS_EXT INT32U OSCtxSwCtr; /* Counter of number of context switches */
  586. #if (OS_EVENT_EN) && (OS_MAX_EVENTS > 0u)
  587. OS_EXT OS_EVENT *OSEventFreeList; /* Pointer to list of free EVENT control blocks */
  588. OS_EXT OS_EVENT OSEventTbl[OS_MAX_EVENTS]; /* Table of EVENT control blocks */
  589. #endif
  590. #if (OS_FLAG_EN > 0u) && (OS_MAX_FLAGS > 0u)
  591. OS_EXT OS_FLAG_GRP OSFlagTbl[OS_MAX_FLAGS]; /* Table containing event flag groups */
  592. OS_EXT OS_FLAG_GRP *OSFlagFreeList; /* Pointer to free list of event flag groups */
  593. #endif
  594. #if OS_TASK_STAT_EN > 0u
  595. OS_EXT INT8U OSCPUUsage; /* Percentage of CPU used */
  596. OS_EXT INT32U OSIdleCtrMax; /* Max. value that idle ctr can take in 1 sec. */
  597. OS_EXT INT32U OSIdleCtrRun; /* Val. reached by idle ctr at run time in 1 sec. */
  598. OS_EXT BOOLEAN OSStatRdy; /* Flag indicating that the statistic task is rdy */
  599. OS_EXT OS_STK OSTaskStatStk[OS_TASK_STAT_STK_SIZE]; /* Statistics task stack */
  600. #endif
  601. OS_EXT INT8U OSIntNesting; /* Interrupt nesting level */
  602. OS_EXT INT8U OSLockNesting; /* Multitasking lock nesting level */
  603. OS_EXT INT8U OSPrioCur; /* Priority of current task */
  604. OS_EXT INT8U OSPrioHighRdy; /* Priority of highest priority task */
  605. OS_EXT OS_PRIO OSRdyGrp; /* Ready list group */
  606. OS_EXT OS_PRIO OSRdyTbl[OS_RDY_TBL_SIZE]; /* Table of tasks which are ready to run */
  607. OS_EXT BOOLEAN OSRunning; /* Flag indicating that kernel is running */
  608. OS_EXT INT8U OSTaskCtr; /* Number of tasks created */
  609. OS_EXT volatile INT32U OSIdleCtr; /* Idle counter */
  610. #ifdef OS_SAFETY_CRITICAL_IEC61508
  611. OS_EXT BOOLEAN OSSafetyCriticalStartFlag;
  612. #endif
  613. OS_EXT OS_STK OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE]; /* Idle task stack */
  614. OS_EXT OS_TCB *OSTCBCur; /* Pointer to currently running TCB */
  615. OS_EXT OS_TCB *OSTCBFreeList; /* Pointer to list of free TCBs */
  616. OS_EXT OS_TCB *OSTCBHighRdy; /* Pointer to highest priority TCB R-to-R */
  617. OS_EXT OS_TCB *OSTCBList; /* Pointer to doubly linked list of TCBs */
  618. OS_EXT OS_TCB *OSTCBPrioTbl[OS_LOWEST_PRIO + 1u]; /* Table of pointers to created TCBs */
  619. OS_EXT OS_TCB OSTCBTbl[OS_MAX_TASKS + OS_N_SYS_TASKS]; /* Table of TCBs */
  620. #if OS_TICK_STEP_EN > 0u
  621. OS_EXT INT8U OSTickStepState; /* Indicates the state of the tick step feature */
  622. #endif
  623. #if (OS_MEM_EN > 0u) && (OS_MAX_MEM_PART > 0u)
  624. OS_EXT OS_MEM *OSMemFreeList; /* Pointer to free list of memory partitions */
  625. OS_EXT OS_MEM OSMemTbl[OS_MAX_MEM_PART]; /* Storage for memory partition manager */
  626. #endif
  627. #if (OS_Q_EN > 0u) && (OS_MAX_QS > 0u)
  628. OS_EXT OS_Q *OSQFreeList; /* Pointer to list of free QUEUE control blocks */
  629. OS_EXT OS_Q OSQTbl[OS_MAX_QS]; /* Table of QUEUE control blocks */
  630. #endif
  631. #if OS_TASK_REG_TBL_SIZE > 0u
  632. OS_EXT INT8U OSTaskRegNextAvailID; /* Next available Task register ID */
  633. #endif
  634. #if OS_TIME_GET_SET_EN > 0u
  635. OS_EXT volatile INT32U OSTime; /* Current value of system time (in ticks) */
  636. #endif
  637. #if OS_TMR_EN > 0u
  638. OS_EXT INT16U OSTmrFree; /* Number of free entries in the timer pool */
  639. OS_EXT INT16U OSTmrUsed; /* Number of timers used */
  640. OS_EXT INT32U OSTmrTime; /* Current timer time */
  641. OS_EXT OS_EVENT *OSTmrSem; /* Sem. used to gain exclusive access to timers */
  642. OS_EXT OS_EVENT *OSTmrSemSignal; /* Sem. used to signal the update of timers */
  643. OS_EXT OS_TMR OSTmrTbl[OS_TMR_CFG_MAX]; /* Table containing pool of timers */
  644. OS_EXT OS_TMR *OSTmrFreeList; /* Pointer to free list of timers */
  645. OS_EXT OS_STK OSTmrTaskStk[OS_TASK_TMR_STK_SIZE];
  646. OS_EXT OS_TMR_WHEEL OSTmrWheelTbl[OS_TMR_CFG_WHEEL_SIZE];
  647. #endif
  648. extern INT8U const OSUnMapTbl[256]; /* Priority->Index lookup table */
  649. /*$PAGE*/
  650. /*
  651. *********************************************************************************************************
  652. * FUNCTION PROTOTYPES
  653. * (Target Independent Functions)
  654. *********************************************************************************************************
  655. */
  656. /*
  657. *********************************************************************************************************
  658. * MISCELLANEOUS
  659. *********************************************************************************************************
  660. */
  661. #if (OS_EVENT_EN)
  662. #if (OS_EVENT_NAME_EN > 0u)
  663. INT8U OSEventNameGet(OS_EVENT *pevent,
  664. INT8U **pname,
  665. INT8U *perr);
  666. void OSEventNameSet(OS_EVENT *pevent,
  667. INT8U *pname,
  668. INT8U *perr);
  669. #endif
  670. #if (OS_EVENT_MULTI_EN > 0u)
  671. INT16U OSEventPendMulti(OS_EVENT **pevents_pend,
  672. OS_EVENT **pevents_rdy,
  673. void **pmsgs_rdy,
  674. INT32U timeout,
  675. INT8U *perr);
  676. #endif
  677. #endif
  678. /*
  679. *********************************************************************************************************
  680. * TASK LOCAL STORAGE (TLS) SUPPORT
  681. *********************************************************************************************************
  682. */
  683. #if OS_TASK_CREATE_EXT_EN > 0u
  684. #if defined(OS_TLS_TBL_SIZE) && (OS_TLS_TBL_SIZE > 0u)
  685. OS_TLS_ID OS_TLS_GetID(INT8U *perr);
  686. OS_TLS OS_TLS_GetValue(OS_TCB *ptcb,
  687. OS_TLS_ID id,
  688. INT8U *perr);
  689. void OS_TLS_Init(INT8U *perr);
  690. void OS_TLS_SetValue(OS_TCB *ptcb,
  691. OS_TLS_ID id,
  692. OS_TLS value,
  693. INT8U *perr);
  694. void OS_TLS_SetDestruct(OS_TLS_ID id,
  695. OS_TLS_DESTRUCT_PTR pdestruct,
  696. INT8U *perr);
  697. void OS_TLS_TaskCreate(OS_TCB *ptcb);
  698. void OS_TLS_TaskDel(OS_TCB *ptcb);
  699. void OS_TLS_TaskSw(void);
  700. #endif
  701. #endif
  702. /*$PAGE*/
  703. /*
  704. *********************************************************************************************************
  705. * EVENT FLAGS MANAGEMENT
  706. *********************************************************************************************************
  707. */
  708. #if (OS_FLAG_EN > 0u) && (OS_MAX_FLAGS > 0u)
  709. #if OS_FLAG_ACCEPT_EN > 0u
  710. OS_FLAGS OSFlagAccept(OS_FLAG_GRP *pgrp,
  711. OS_FLAGS flags,
  712. INT8U wait_type,
  713. INT8U *perr);
  714. #endif
  715. OS_FLAG_GRP *OSFlagCreate(OS_FLAGS flags,
  716. INT8U *perr);
  717. #if OS_FLAG_DEL_EN > 0u
  718. OS_FLAG_GRP *OSFlagDel(OS_FLAG_GRP *pgrp,
  719. INT8U opt,
  720. INT8U *perr);
  721. #endif
  722. #if (OS_FLAG_EN > 0u) && (OS_FLAG_NAME_EN > 0u)
  723. INT8U OSFlagNameGet(OS_FLAG_GRP *pgrp,
  724. INT8U **pname,
  725. INT8U *perr);
  726. void OSFlagNameSet(OS_FLAG_GRP *pgrp,
  727. INT8U *pname,
  728. INT8U *perr);
  729. #endif
  730. OS_FLAGS OSFlagPend(OS_FLAG_GRP *pgrp,
  731. OS_FLAGS flags,
  732. INT8U wait_type,
  733. INT32U timeout,
  734. INT8U *perr);
  735. OS_FLAGS OSFlagPendGetFlagsRdy(void);
  736. OS_FLAGS OSFlagPost(OS_FLAG_GRP *pgrp,
  737. OS_FLAGS flags,
  738. INT8U opt,
  739. INT8U *perr);
  740. #if OS_FLAG_QUERY_EN > 0u
  741. OS_FLAGS OSFlagQuery(OS_FLAG_GRP *pgrp,
  742. INT8U *perr);
  743. #endif
  744. #endif
  745. /*
  746. *********************************************************************************************************
  747. * MESSAGE MAILBOX MANAGEMENT
  748. *********************************************************************************************************
  749. */
  750. #if OS_MBOX_EN > 0u
  751. #if OS_MBOX_ACCEPT_EN > 0u
  752. void *OSMboxAccept(OS_EVENT *pevent);
  753. #endif
  754. OS_EVENT *OSMboxCreate(void *pmsg);
  755. #if OS_MBOX_DEL_EN > 0u
  756. OS_EVENT *OSMboxDel(OS_EVENT *pevent,
  757. INT8U opt,
  758. INT8U *perr);
  759. #endif
  760. void *OSMboxPend(OS_EVENT *pevent,
  761. INT32U timeout,
  762. INT8U *perr);
  763. #if OS_MBOX_PEND_ABORT_EN > 0u
  764. INT8U OSMboxPendAbort(OS_EVENT *pevent,
  765. INT8U opt,
  766. INT8U *perr);
  767. #endif
  768. #if OS_MBOX_POST_EN > 0u
  769. INT8U OSMboxPost(OS_EVENT *pevent,
  770. void *pmsg);
  771. #endif
  772. #if OS_MBOX_POST_OPT_EN > 0u
  773. INT8U OSMboxPostOpt(OS_EVENT *pevent,
  774. void *pmsg,
  775. INT8U opt);
  776. #endif
  777. #if OS_MBOX_QUERY_EN > 0u
  778. INT8U OSMboxQuery(OS_EVENT *pevent,
  779. OS_MBOX_DATA *p_mbox_data);
  780. #endif
  781. #endif
  782. /*
  783. *********************************************************************************************************
  784. * MEMORY MANAGEMENT
  785. *********************************************************************************************************
  786. */
  787. #if (OS_MEM_EN > 0u) && (OS_MAX_MEM_PART > 0u)
  788. OS_MEM *OSMemCreate(void *addr,
  789. INT32U nblks,
  790. INT32U blksize,
  791. INT8U *perr);
  792. void *OSMemGet(OS_MEM *pmem,
  793. INT8U *perr);
  794. #if OS_MEM_NAME_EN > 0u
  795. INT8U OSMemNameGet(OS_MEM *pmem,
  796. INT8U **pname,
  797. INT8U *perr);
  798. void OSMemNameSet(OS_MEM *pmem,
  799. INT8U *pname,
  800. INT8U *perr);
  801. #endif
  802. INT8U OSMemPut(OS_MEM *pmem,
  803. void *pblk);
  804. #if OS_MEM_QUERY_EN > 0u
  805. INT8U OSMemQuery(OS_MEM *pmem,
  806. OS_MEM_DATA *p_mem_data);
  807. #endif
  808. #endif
  809. /*
  810. *********************************************************************************************************
  811. * MUTUAL EXCLUSION SEMAPHORE MANAGEMENT
  812. *********************************************************************************************************
  813. */
  814. #if OS_MUTEX_EN > 0u
  815. #if OS_MUTEX_ACCEPT_EN > 0u
  816. BOOLEAN OSMutexAccept(OS_EVENT *pevent,
  817. INT8U *perr);
  818. #endif
  819. OS_EVENT *OSMutexCreate(INT8U prio,
  820. INT8U *perr);
  821. #if OS_MUTEX_DEL_EN > 0u
  822. OS_EVENT *OSMutexDel(OS_EVENT *pevent,
  823. INT8U opt,
  824. INT8U *perr);
  825. #endif
  826. void OSMutexPend(OS_EVENT *pevent,
  827. INT32U timeout,
  828. INT8U *perr);
  829. INT8U OSMutexPost(OS_EVENT *pevent);
  830. #if OS_MUTEX_QUERY_EN > 0u
  831. INT8U OSMutexQuery(OS_EVENT *pevent,
  832. OS_MUTEX_DATA *p_mutex_data);
  833. #endif
  834. #endif
  835. /*$PAGE*/
  836. /*
  837. *********************************************************************************************************
  838. * MESSAGE QUEUE MANAGEMENT
  839. *********************************************************************************************************
  840. */
  841. #if (OS_Q_EN > 0u) && (OS_MAX_QS > 0u)
  842. #if OS_Q_ACCEPT_EN > 0u
  843. void *OSQAccept(OS_EVENT *pevent,
  844. INT8U *perr);
  845. #endif
  846. OS_EVENT *OSQCreate(void **start,
  847. INT16U size);
  848. #if OS_Q_DEL_EN > 0u
  849. OS_EVENT *OSQDel(OS_EVENT *pevent,
  850. INT8U opt,
  851. INT8U *perr);
  852. #endif
  853. #if OS_Q_FLUSH_EN > 0u
  854. INT8U OSQFlush(OS_EVENT *pevent);
  855. #endif
  856. void *OSQPend(OS_EVENT *pevent,
  857. INT32U timeout,
  858. INT8U *perr);
  859. #if OS_Q_PEND_ABORT_EN > 0u
  860. INT8U OSQPendAbort(OS_EVENT *pevent,
  861. INT8U opt,
  862. INT8U *perr);
  863. #endif
  864. #if OS_Q_POST_EN > 0u
  865. INT8U OSQPost(OS_EVENT *pevent,
  866. void *pmsg);
  867. #endif
  868. #if OS_Q_POST_FRONT_EN > 0u
  869. INT8U OSQPostFront(OS_EVENT *pevent,
  870. void *pmsg);
  871. #endif
  872. #if OS_Q_POST_OPT_EN > 0u
  873. INT8U OSQPostOpt(OS_EVENT *pevent,
  874. void *pmsg,
  875. INT8U opt);
  876. #endif
  877. #if OS_Q_QUERY_EN > 0u
  878. INT8U OSQQuery(OS_EVENT *pevent,
  879. OS_Q_DATA *p_q_data);
  880. #endif
  881. #endif
  882. /*$PAGE*/
  883. /*
  884. *********************************************************************************************************
  885. * SEMAPHORE MANAGEMENT
  886. *********************************************************************************************************
  887. */
  888. #if OS_SEM_EN > 0u
  889. #if OS_SEM_ACCEPT_EN > 0u
  890. INT16U OSSemAccept(OS_EVENT *pevent);
  891. #endif
  892. OS_EVENT *OSSemCreate(INT16U cnt);
  893. #if OS_SEM_DEL_EN > 0u
  894. OS_EVENT *OSSemDel(OS_EVENT *pevent,
  895. INT8U opt,
  896. INT8U *perr);
  897. #endif
  898. void OSSemPend(OS_EVENT *pevent,
  899. INT32U timeout,
  900. INT8U *perr);
  901. #if OS_SEM_PEND_ABORT_EN > 0u
  902. INT8U OSSemPendAbort(OS_EVENT *pevent,
  903. INT8U opt,
  904. INT8U *perr);
  905. #endif
  906. INT8U OSSemPost(OS_EVENT *pevent);
  907. #if OS_SEM_QUERY_EN > 0u
  908. INT8U OSSemQuery(OS_EVENT *pevent,
  909. OS_SEM_DATA *p_sem_data);
  910. #endif
  911. #if OS_SEM_SET_EN > 0u
  912. void OSSemSet(OS_EVENT *pevent,
  913. INT16U cnt,
  914. INT8U *perr);
  915. #endif
  916. #endif
  917. /*$PAGE*/
  918. /*
  919. *********************************************************************************************************
  920. * TASK MANAGEMENT
  921. *********************************************************************************************************
  922. */
  923. #if OS_TASK_CHANGE_PRIO_EN > 0u
  924. INT8U OSTaskChangePrio(INT8U oldprio,
  925. INT8U newprio);
  926. #endif
  927. #if OS_TASK_CREATE_EN > 0u
  928. INT8U OSTaskCreate(void (*task)(void *p_arg),
  929. void *p_arg,
  930. OS_STK *ptos,
  931. INT8U prio);
  932. #endif
  933. #if OS_TASK_CREATE_EXT_EN > 0u
  934. INT8U OSTaskCreateExt(void (*task)(void *p_arg),
  935. void *p_arg,
  936. OS_STK *ptos,
  937. INT8U prio,
  938. INT16U id,
  939. OS_STK *pbos,
  940. INT32U stk_size,
  941. void *pext,
  942. INT16U opt);
  943. #endif
  944. #if OS_TASK_DEL_EN > 0u
  945. INT8U OSTaskDel(INT8U prio);
  946. INT8U OSTaskDelReq(INT8U prio);
  947. #endif
  948. #if OS_TASK_NAME_EN > 0u
  949. INT8U OSTaskNameGet(INT8U prio,
  950. INT8U **pname,
  951. INT8U *perr);
  952. void OSTaskNameSet(INT8U prio,
  953. INT8U *pname,
  954. INT8U *perr);
  955. #endif
  956. #if OS_TASK_SUSPEND_EN > 0u
  957. INT8U OSTaskResume(INT8U prio);
  958. INT8U OSTaskSuspend(INT8U prio);
  959. #endif
  960. #if (OS_TASK_STAT_STK_CHK_EN > 0u) && (OS_TASK_CREATE_EXT_EN > 0u)
  961. INT8U OSTaskStkChk(INT8U prio,
  962. OS_STK_DATA *p_stk_data);
  963. #endif
  964. #if OS_TASK_QUERY_EN > 0u
  965. INT8U OSTaskQuery(INT8U prio,
  966. OS_TCB *p_task_data);
  967. #endif
  968. #if OS_TASK_REG_TBL_SIZE > 0u
  969. INT32U OSTaskRegGet(INT8U prio,
  970. INT8U id,
  971. INT8U *perr);
  972. INT8U OSTaskRegGetID(INT8U *perr);
  973. void OSTaskRegSet(INT8U prio,
  974. INT8U id,
  975. INT32U value,
  976. INT8U *perr);
  977. #endif
  978. /*$PAGE*/
  979. /*
  980. *********************************************************************************************************
  981. * TIME MANAGEMENT
  982. *********************************************************************************************************
  983. */
  984. void OSTimeDly(INT32U ticks);
  985. #if OS_TIME_DLY_HMSM_EN > 0u
  986. INT8U OSTimeDlyHMSM(INT8U hours,
  987. INT8U minutes,
  988. INT8U seconds,
  989. INT16U ms);
  990. #endif
  991. #if OS_TIME_DLY_RESUME_EN > 0u
  992. INT8U OSTimeDlyResume(INT8U prio);
  993. #endif
  994. #if OS_TIME_GET_SET_EN > 0u
  995. INT32U OSTimeGet(void);
  996. void OSTimeSet(INT32U ticks);
  997. #endif
  998. void OSTimeTick(void);
  999. /*
  1000. *********************************************************************************************************
  1001. * TIMER MANAGEMENT
  1002. *********************************************************************************************************
  1003. */
  1004. #if OS_TMR_EN > 0u
  1005. OS_TMR *OSTmrCreate(INT32U dly,
  1006. INT32U period,
  1007. INT8U opt,
  1008. OS_TMR_CALLBACK callback,
  1009. void *callback_arg,
  1010. INT8U *pname,
  1011. INT8U *perr);
  1012. BOOLEAN OSTmrDel(OS_TMR *ptmr,
  1013. INT8U *perr);
  1014. #if OS_TMR_CFG_NAME_EN > 0u
  1015. INT8U OSTmrNameGet(OS_TMR *ptmr,
  1016. INT8U **pdest,
  1017. INT8U *perr);
  1018. #endif
  1019. INT32U OSTmrRemainGet(OS_TMR *ptmr,
  1020. INT8U *perr);
  1021. INT8U OSTmrStateGet(OS_TMR *ptmr,
  1022. INT8U *perr);
  1023. BOOLEAN OSTmrStart(OS_TMR *ptmr,
  1024. INT8U *perr);
  1025. BOOLEAN OSTmrStop(OS_TMR *ptmr,
  1026. INT8U opt,
  1027. void *callback_arg,
  1028. INT8U *perr);
  1029. INT8U OSTmrSignal(void);
  1030. #endif
  1031. /*
  1032. *********************************************************************************************************
  1033. * MISCELLANEOUS
  1034. *********************************************************************************************************
  1035. */
  1036. void OSInit(void);
  1037. void OSIntEnter(void);
  1038. void OSIntExit(void);
  1039. #ifdef OS_SAFETY_CRITICAL_IEC61508
  1040. void OSSafetyCriticalStart(void);
  1041. #endif
  1042. #if OS_SCHED_LOCK_EN > 0u
  1043. void OSSchedLock(void);
  1044. void OSSchedUnlock(void);
  1045. #endif
  1046. void OSStart(void);
  1047. void OSStatInit(void);
  1048. INT16U OSVersion(void);
  1049. /*$PAGE*/
  1050. /*
  1051. *********************************************************************************************************
  1052. * INTERNAL FUNCTION PROTOTYPES
  1053. * (Your application MUST NOT call these functions)
  1054. *********************************************************************************************************
  1055. */
  1056. #if OS_TASK_DEL_EN > 0u
  1057. void OS_Dummy(void);
  1058. #endif
  1059. #if (OS_EVENT_EN)
  1060. INT8U OS_EventTaskRdy(OS_EVENT *pevent,
  1061. void *pmsg,
  1062. INT8U msk,
  1063. INT8U pend_stat);
  1064. void OS_EventTaskWait(OS_EVENT *pevent);
  1065. void OS_EventTaskRemove(OS_TCB *ptcb,
  1066. OS_EVENT *pevent);
  1067. #if (OS_EVENT_MULTI_EN > 0u)
  1068. void OS_EventTaskWaitMulti(OS_EVENT **pevents_wait);
  1069. void OS_EventTaskRemoveMulti(OS_TCB *ptcb,
  1070. OS_EVENT **pevents_multi);
  1071. #endif
  1072. void OS_EventWaitListInit(OS_EVENT *pevent);
  1073. #endif
  1074. #if (OS_FLAG_EN > 0u) && (OS_MAX_FLAGS > 0u)
  1075. void OS_FlagInit(void);
  1076. void OS_FlagUnlink(OS_FLAG_NODE *pnode);
  1077. #endif
  1078. void OS_MemClr(INT8U *pdest,
  1079. INT16U size);
  1080. void OS_MemCopy(INT8U *pdest,
  1081. INT8U *psrc,
  1082. INT16U size);
  1083. #if (OS_MEM_EN > 0u) && (OS_MAX_MEM_PART > 0u)
  1084. void OS_MemInit(void);
  1085. #endif
  1086. #if OS_Q_EN > 0u
  1087. void OS_QInit(void);
  1088. #endif
  1089. void OS_Sched(void);
  1090. #if (OS_EVENT_NAME_EN > 0u) || (OS_FLAG_NAME_EN > 0u) || (OS_MEM_NAME_EN > 0u) || (OS_TASK_NAME_EN > 0u)
  1091. INT8U OS_StrLen(INT8U *psrc);
  1092. #endif
  1093. void OS_TaskIdle(void *p_arg);
  1094. void OS_TaskReturn(void);
  1095. #if OS_TASK_STAT_EN > 0u
  1096. void OS_TaskStat(void *p_arg);
  1097. #endif
  1098. #if (OS_TASK_STAT_STK_CHK_EN > 0u) && (OS_TASK_CREATE_EXT_EN > 0u)
  1099. void OS_TaskStkClr(OS_STK *pbos,
  1100. INT32U size,
  1101. INT16U opt);
  1102. #endif
  1103. #if (OS_TASK_STAT_STK_CHK_EN > 0u) && (OS_TASK_CREATE_EXT_EN > 0u)
  1104. void OS_TaskStatStkChk(void);
  1105. #endif
  1106. INT8U OS_TCBInit(INT8U prio,
  1107. OS_STK *ptos,
  1108. OS_STK *pbos,
  1109. INT16U id,
  1110. INT32U stk_size,
  1111. void *pext,
  1112. INT16U opt);
  1113. #if OS_TMR_EN > 0u
  1114. void OSTmr_Init(void);
  1115. #endif
  1116. /*$PAGE*/
  1117. /*
  1118. *********************************************************************************************************
  1119. * FUNCTION PROTOTYPES
  1120. * (Target Specific Functions)
  1121. *********************************************************************************************************
  1122. */
  1123. #if OS_DEBUG_EN > 0u
  1124. void OSDebugInit(void);
  1125. #endif
  1126. void OSInitHookBegin(void);
  1127. void OSInitHookEnd(void);
  1128. void OSTaskCreateHook(OS_TCB *ptcb);
  1129. void OSTaskDelHook(OS_TCB *ptcb);
  1130. void OSTaskIdleHook(void);
  1131. void OSTaskReturnHook(OS_TCB *ptcb);
  1132. void OSTaskStatHook(void);
  1133. OS_STK *OSTaskStkInit(void (*task)(void *p_arg),
  1134. void *p_arg,
  1135. OS_STK *ptos,
  1136. INT16U opt);
  1137. #if OS_TASK_SW_HOOK_EN > 0u
  1138. void OSTaskSwHook(void);
  1139. #endif
  1140. void OSTCBInitHook(OS_TCB *ptcb);
  1141. #if OS_TIME_TICK_HOOK_EN > 0u
  1142. void OSTimeTickHook(void);
  1143. #endif
  1144. /*$PAGE*/
  1145. /*
  1146. *********************************************************************************************************
  1147. * FUNCTION PROTOTYPES
  1148. * (Application Specific Functions)
  1149. *********************************************************************************************************
  1150. */
  1151. #if OS_APP_HOOKS_EN > 0u
  1152. void App_TaskCreateHook(OS_TCB *ptcb);
  1153. void App_TaskDelHook(OS_TCB *ptcb);
  1154. void App_TaskIdleHook(void);
  1155. void App_TaskReturnHook(OS_TCB *ptcb);
  1156. void App_TaskStatHook(void);
  1157. #if OS_TASK_SW_HOOK_EN > 0u
  1158. void App_TaskSwHook(void);
  1159. #endif
  1160. void App_TCBInitHook(OS_TCB *ptcb);
  1161. #if OS_TIME_TICK_HOOK_EN > 0u
  1162. void App_TimeTickHook(void);
  1163. #endif
  1164. #endif
  1165. /*
  1166. *********************************************************************************************************
  1167. * FUNCTION PROTOTYPES
  1168. *
  1169. * IMPORTANT: These prototypes MUST be placed in OS_CPU.H
  1170. *********************************************************************************************************
  1171. */
  1172. #if 0
  1173. void OSStartHighRdy (void);
  1174. void OSIntCtxSw (void);
  1175. void OSCtxSw (void);
  1176. #endif
  1177. /*$PAGE*/
  1178. /*
  1179. *********************************************************************************************************
  1180. * LOOK FOR MISSING #define CONSTANTS
  1181. *
  1182. * This section is used to generate ERROR messages at compile time if certain #define constants are
  1183. * MISSING in OS_CFG.H. This allows you to quickly determine the source of the error.
  1184. *
  1185. * You SHOULD NOT change this section UNLESS you would like to add more comments as to the source of the
  1186. * compile time error.
  1187. *********************************************************************************************************
  1188. */
  1189. /*
  1190. *********************************************************************************************************
  1191. * EVENT FLAGS
  1192. *********************************************************************************************************
  1193. */
  1194. #ifndef OS_FLAG_EN
  1195. #error "OS_CFG.H, Missing OS_FLAG_EN: Enable (1) or Disable (0) code generation for Event Flags"
  1196. #else
  1197. #ifndef OS_MAX_FLAGS
  1198. #error "OS_CFG.H, Missing OS_MAX_FLAGS: Max. number of Event Flag Groups in your application"
  1199. #else
  1200. #if OS_MAX_FLAGS > 65500u
  1201. #error "OS_CFG.H, OS_MAX_FLAGS must be <= 65500"
  1202. #endif
  1203. #endif
  1204. #ifndef OS_FLAGS_NBITS
  1205. #error "OS_CFG.H, Missing OS_FLAGS_NBITS: Determine #bits used for event flags, MUST be either 8, 16 or 32"
  1206. #endif
  1207. #ifndef OS_FLAG_WAIT_CLR_EN
  1208. #error "OS_CFG.H, Missing OS_FLAG_WAIT_CLR_EN: Include code for Wait on Clear EVENT FLAGS"
  1209. #endif
  1210. #ifndef OS_FLAG_ACCEPT_EN
  1211. #error "OS_CFG.H, Missing OS_FLAG_ACCEPT_EN: Include code for OSFlagAccept()"
  1212. #endif
  1213. #ifndef OS_FLAG_DEL_EN
  1214. #error "OS_CFG.H, Missing OS_FLAG_DEL_EN: Include code for OSFlagDel()"
  1215. #endif
  1216. #ifndef OS_FLAG_NAME_EN
  1217. #error "OS_CFG.H, Missing OS_FLAG_NAME_EN: Enable flag group names"
  1218. #endif
  1219. #ifndef OS_FLAG_QUERY_EN
  1220. #error "OS_CFG.H, Missing OS_FLAG_QUERY_EN: Include code for OSFlagQuery()"
  1221. #endif
  1222. #endif
  1223. /*
  1224. *********************************************************************************************************
  1225. * MESSAGE MAILBOXES
  1226. *********************************************************************************************************
  1227. */
  1228. #ifndef OS_MBOX_EN
  1229. #error "OS_CFG.H, Missing OS_MBOX_EN: Enable (1) or Disable (0) code generation for MAILBOXES"
  1230. #else
  1231. #ifndef OS_MBOX_ACCEPT_EN
  1232. #error "OS_CFG.H, Missing OS_MBOX_ACCEPT_EN: Include code for OSMboxAccept()"
  1233. #endif
  1234. #ifndef OS_MBOX_DEL_EN
  1235. #error "OS_CFG.H, Missing OS_MBOX_DEL_EN: Include code for OSMboxDel()"
  1236. #endif
  1237. #ifndef OS_MBOX_PEND_ABORT_EN
  1238. #error "OS_CFG.H, Missing OS_MBOX_PEND_ABORT_EN: Include code for OSMboxPendAbort()"
  1239. #endif
  1240. #ifndef OS_MBOX_POST_EN
  1241. #error "OS_CFG.H, Missing OS_MBOX_POST_EN: Include code for OSMboxPost()"
  1242. #endif
  1243. #ifndef OS_MBOX_POST_OPT_EN
  1244. #error "OS_CFG.H, Missing OS_MBOX_POST_OPT_EN: Include code for OSMboxPostOpt()"
  1245. #endif
  1246. #ifndef OS_MBOX_QUERY_EN
  1247. #error "OS_CFG.H, Missing OS_MBOX_QUERY_EN: Include code for OSMboxQuery()"
  1248. #endif
  1249. #endif
  1250. /*
  1251. *********************************************************************************************************
  1252. * MEMORY MANAGEMENT
  1253. *********************************************************************************************************
  1254. */
  1255. #ifndef OS_MEM_EN
  1256. #error "OS_CFG.H, Missing OS_MEM_EN: Enable (1) or Disable (0) code generation for MEMORY MANAGER"
  1257. #else
  1258. #ifndef OS_MAX_MEM_PART
  1259. #error "OS_CFG.H, Missing OS_MAX_MEM_PART: Max. number of memory partitions"
  1260. #else
  1261. #if OS_MAX_MEM_PART > 65500u
  1262. #error "OS_CFG.H, OS_MAX_MEM_PART must be <= 65500"
  1263. #endif
  1264. #endif
  1265. #ifndef OS_MEM_NAME_EN
  1266. #error "OS_CFG.H, Missing OS_MEM_NAME_EN: Enable memory partition names"
  1267. #endif
  1268. #ifndef OS_MEM_QUERY_EN
  1269. #error "OS_CFG.H, Missing OS_MEM_QUERY_EN: Include code for OSMemQuery()"
  1270. #endif
  1271. #endif
  1272. /*
  1273. *********************************************************************************************************
  1274. * MUTUAL EXCLUSION SEMAPHORES
  1275. *********************************************************************************************************
  1276. */
  1277. #ifndef OS_MUTEX_EN
  1278. #error "OS_CFG.H, Missing OS_MUTEX_EN: Enable (1) or Disable (0) code generation for MUTEX"
  1279. #else
  1280. #ifndef OS_MUTEX_ACCEPT_EN
  1281. #error "OS_CFG.H, Missing OS_MUTEX_ACCEPT_EN: Include code for OSMutexAccept()"
  1282. #endif
  1283. #ifndef OS_MUTEX_DEL_EN
  1284. #error "OS_CFG.H, Missing OS_MUTEX_DEL_EN: Include code for OSMutexDel()"
  1285. #endif
  1286. #ifndef OS_MUTEX_QUERY_EN
  1287. #error "OS_CFG.H, Missing OS_MUTEX_QUERY_EN: Include code for OSMutexQuery()"
  1288. #endif
  1289. #endif
  1290. /*
  1291. *********************************************************************************************************
  1292. * MESSAGE QUEUES
  1293. *********************************************************************************************************
  1294. */
  1295. #ifndef OS_Q_EN
  1296. #error "OS_CFG.H, Missing OS_Q_EN: Enable (1) or Disable (0) code generation for QUEUES"
  1297. #else
  1298. #ifndef OS_MAX_QS
  1299. #error "OS_CFG.H, Missing OS_MAX_QS: Max. number of queue control blocks"
  1300. #else
  1301. #if OS_MAX_QS > 65500u
  1302. #error "OS_CFG.H, OS_MAX_QS must be <= 65500"
  1303. #endif
  1304. #endif
  1305. #ifndef OS_Q_ACCEPT_EN
  1306. #error "OS_CFG.H, Missing OS_Q_ACCEPT_EN: Include code for OSQAccept()"
  1307. #endif
  1308. #ifndef OS_Q_DEL_EN
  1309. #error "OS_CFG.H, Missing OS_Q_DEL_EN: Include code for OSQDel()"
  1310. #endif
  1311. #ifndef OS_Q_FLUSH_EN
  1312. #error "OS_CFG.H, Missing OS_Q_FLUSH_EN: Include code for OSQFlush()"
  1313. #endif
  1314. #ifndef OS_Q_PEND_ABORT_EN
  1315. #error "OS_CFG.H, Missing OS_Q_PEND_ABORT_EN: Include code for OSQPendAbort()"
  1316. #endif
  1317. #ifndef OS_Q_POST_EN
  1318. #error "OS_CFG.H, Missing OS_Q_POST_EN: Include code for OSQPost()"
  1319. #endif
  1320. #ifndef OS_Q_POST_FRONT_EN
  1321. #error "OS_CFG.H, Missing OS_Q_POST_FRONT_EN: Include code for OSQPostFront()"
  1322. #endif
  1323. #ifndef OS_Q_POST_OPT_EN
  1324. #error "OS_CFG.H, Missing OS_Q_POST_OPT_EN: Include code for OSQPostOpt()"
  1325. #endif
  1326. #ifndef OS_Q_QUERY_EN
  1327. #error "OS_CFG.H, Missing OS_Q_QUERY_EN: Include code for OSQQuery()"
  1328. #endif
  1329. #endif
  1330. /*
  1331. *********************************************************************************************************
  1332. * SEMAPHORES
  1333. *********************************************************************************************************
  1334. */
  1335. #ifndef OS_SEM_EN
  1336. #error "OS_CFG.H, Missing OS_SEM_EN: Enable (1) or Disable (0) code generation for SEMAPHORES"
  1337. #else
  1338. #ifndef OS_SEM_ACCEPT_EN
  1339. #error "OS_CFG.H, Missing OS_SEM_ACCEPT_EN: Include code for OSSemAccept()"
  1340. #endif
  1341. #ifndef OS_SEM_DEL_EN
  1342. #error "OS_CFG.H, Missing OS_SEM_DEL_EN: Include code for OSSemDel()"
  1343. #endif
  1344. #ifndef OS_SEM_PEND_ABORT_EN
  1345. #error "OS_CFG.H, Missing OS_SEM_PEND_ABORT_EN: Include code for OSSemPendAbort()"
  1346. #endif
  1347. #ifndef OS_SEM_QUERY_EN
  1348. #error "OS_CFG.H, Missing OS_SEM_QUERY_EN: Include code for OSSemQuery()"
  1349. #endif
  1350. #ifndef OS_SEM_SET_EN
  1351. #error "OS_CFG.H, Missing OS_SEM_SET_EN: Include code for OSSemSet()"
  1352. #endif
  1353. #endif
  1354. /*
  1355. *********************************************************************************************************
  1356. * TASK MANAGEMENT
  1357. *********************************************************************************************************
  1358. */
  1359. #ifndef OS_MAX_TASKS
  1360. #error "OS_CFG.H, Missing OS_MAX_TASKS: Max. number of tasks in your application"
  1361. #else
  1362. #if OS_MAX_TASKS < 2u
  1363. #error "OS_CFG.H, OS_MAX_TASKS must be >= 2"
  1364. #endif
  1365. #if OS_MAX_TASKS > ((OS_LOWEST_PRIO - OS_N_SYS_TASKS) + 1u)
  1366. #error "OS_CFG.H, OS_MAX_TASKS must be <= OS_LOWEST_PRIO - OS_N_SYS_TASKS + 1"
  1367. #endif
  1368. #endif
  1369. #if OS_LOWEST_PRIO > 254u
  1370. #error "OS_CFG.H, OS_LOWEST_PRIO must be <= 254 in V2.8x and higher"
  1371. #endif
  1372. #ifndef OS_TASK_IDLE_STK_SIZE
  1373. #error "OS_CFG.H, Missing OS_TASK_IDLE_STK_SIZE: Idle task stack size"
  1374. #endif
  1375. #ifndef OS_TASK_STAT_EN
  1376. #error "OS_CFG.H, Missing OS_TASK_STAT_EN: Enable (1) or Disable(0) the statistics task"
  1377. #endif
  1378. #ifndef OS_TASK_STAT_STK_SIZE
  1379. #error "OS_CFG.H, Missing OS_TASK_STAT_STK_SIZE: Statistics task stack size"
  1380. #endif
  1381. #ifndef OS_TASK_STAT_STK_CHK_EN
  1382. #error "OS_CFG.H, Missing OS_TASK_STAT_STK_CHK_EN: Check task stacks from statistics task"
  1383. #endif
  1384. #ifndef OS_TASK_CHANGE_PRIO_EN
  1385. #error "OS_CFG.H, Missing OS_TASK_CHANGE_PRIO_EN: Include code for OSTaskChangePrio()"
  1386. #endif
  1387. #ifndef OS_TASK_CREATE_EN
  1388. #error "OS_CFG.H, Missing OS_TASK_CREATE_EN: Include code for OSTaskCreate()"
  1389. #endif
  1390. #ifndef OS_TASK_CREATE_EXT_EN
  1391. #error "OS_CFG.H, Missing OS_TASK_CREATE_EXT_EN: Include code for OSTaskCreateExt()"
  1392. #else
  1393. #if (OS_TASK_CREATE_EXT_EN == 0u) && (OS_TASK_CREATE_EN == 0u)
  1394. #error "OS_CFG.H, OS_TASK_CREATE_EXT_EN or OS_TASK_CREATE_EN must be Enable (1)"
  1395. #endif
  1396. #endif
  1397. #ifndef OS_TASK_DEL_EN
  1398. #error "OS_CFG.H, Missing OS_TASK_DEL_EN: Include code for OSTaskDel()"
  1399. #endif
  1400. #ifndef OS_TASK_NAME_EN
  1401. #error "OS_CFG.H, Missing OS_TASK_NAME_EN: Enable task names"
  1402. #endif
  1403. #ifndef OS_TASK_SUSPEND_EN
  1404. #error "OS_CFG.H, Missing OS_TASK_SUSPEND_EN: Include code for OSTaskSuspend() and OSTaskResume()"
  1405. #endif
  1406. #ifndef OS_TASK_QUERY_EN
  1407. #error "OS_CFG.H, Missing OS_TASK_QUERY_EN: Include code for OSTaskQuery()"
  1408. #endif
  1409. #ifndef OS_TASK_REG_TBL_SIZE
  1410. #error "OS_CFG.H, Missing OS_TASK_REG_TBL_SIZE: Include code for task specific registers"
  1411. #else
  1412. #if OS_TASK_REG_TBL_SIZE > 255u
  1413. #error "OS_CFG.H, OS_TASK_REG_TBL_SIZE must be <= 255"
  1414. #endif
  1415. #endif
  1416. /*
  1417. *********************************************************************************************************
  1418. * TIME MANAGEMENT
  1419. *********************************************************************************************************
  1420. */
  1421. #ifndef OS_TICKS_PER_SEC
  1422. #error "OS_CFG.H, Missing OS_TICKS_PER_SEC: Sets the number of ticks in one second"
  1423. #endif
  1424. #ifndef OS_TIME_DLY_HMSM_EN
  1425. #error "OS_CFG.H, Missing OS_TIME_DLY_HMSM_EN: Include code for OSTimeDlyHMSM()"
  1426. #endif
  1427. #ifndef OS_TIME_DLY_RESUME_EN
  1428. #error "OS_CFG.H, Missing OS_TIME_DLY_RESUME_EN: Include code for OSTimeDlyResume()"
  1429. #endif
  1430. #ifndef OS_TIME_GET_SET_EN
  1431. #error "OS_CFG.H, Missing OS_TIME_GET_SET_EN: Include code for OSTimeGet() and OSTimeSet()"
  1432. #endif
  1433. /*
  1434. *********************************************************************************************************
  1435. * TIMER MANAGEMENT
  1436. *********************************************************************************************************
  1437. */
  1438. #ifndef OS_TMR_EN
  1439. #error "OS_CFG.H, Missing OS_TMR_EN: When (1) enables code generation for Timer Management"
  1440. #elif OS_TMR_EN > 0u
  1441. #if OS_SEM_EN == 0u
  1442. #error "OS_CFG.H, Semaphore management is required (set OS_SEM_EN to 1) when enabling Timer Management."
  1443. #error " Timer management require TWO semaphores."
  1444. #endif
  1445. #ifndef OS_TMR_CFG_MAX
  1446. #error "OS_CFG.H, Missing OS_TMR_CFG_MAX: Determines the total number of timers in an application (2 .. 65500)"
  1447. #else
  1448. #if OS_TMR_CFG_MAX < 2u
  1449. #error "OS_CFG.H, OS_TMR_CFG_MAX should be between 2 and 65500"
  1450. #endif
  1451. #if OS_TMR_CFG_MAX > 65500u
  1452. #error "OS_CFG.H, OS_TMR_CFG_MAX should be between 2 and 65500"
  1453. #endif
  1454. #endif
  1455. #ifndef OS_TMR_CFG_WHEEL_SIZE
  1456. #error "OS_CFG.H, Missing OS_TMR_CFG_WHEEL_SIZE: Sets the size of the timer wheel (1 .. 1023)"
  1457. #else
  1458. #if OS_TMR_CFG_WHEEL_SIZE < 2u
  1459. #error "OS_CFG.H, OS_TMR_CFG_WHEEL_SIZE should be between 2 and 1024"
  1460. #endif
  1461. #if OS_TMR_CFG_WHEEL_SIZE > 1024u
  1462. #error "OS_CFG.H, OS_TMR_CFG_WHEEL_SIZE should be between 2 and 1024"
  1463. #endif
  1464. #endif
  1465. #ifndef OS_TMR_CFG_NAME_EN
  1466. #error "OS_CFG.H, Missing OS_TMR_CFG_NAME_EN: Enable Timer names"
  1467. #endif
  1468. #ifndef OS_TMR_CFG_TICKS_PER_SEC
  1469. #error "OS_CFG.H, Missing OS_TMR_CFG_TICKS_PER_SEC: Determines the rate at which the timer management task will run (Hz)"
  1470. #endif
  1471. #ifndef OS_TASK_TMR_STK_SIZE
  1472. #error "OS_CFG.H, Missing OS_TASK_TMR_STK_SIZE: Determines the size of the Timer Task's stack"
  1473. #endif
  1474. #endif
  1475. /*
  1476. *********************************************************************************************************
  1477. * MISCELLANEOUS
  1478. *********************************************************************************************************
  1479. */
  1480. #ifndef OS_ARG_CHK_EN
  1481. #error "OS_CFG.H, Missing OS_ARG_CHK_EN: Enable (1) or Disable (0) argument checking"
  1482. #endif
  1483. #ifndef OS_CPU_HOOKS_EN
  1484. #error "OS_CFG.H, Missing OS_CPU_HOOKS_EN: uC/OS-II hooks are found in the processor port files when 1"
  1485. #endif
  1486. #ifndef OS_APP_HOOKS_EN
  1487. #error "OS_CFG.H, Missing OS_APP_HOOKS_EN: Application-defined hooks are called from the uC/OS-II hooks"
  1488. #endif
  1489. #ifndef OS_DEBUG_EN
  1490. #error "OS_CFG.H, Missing OS_DEBUG_EN: Allows you to include variables for debugging or not"
  1491. #endif
  1492. #ifndef OS_LOWEST_PRIO
  1493. #error "OS_CFG.H, Missing OS_LOWEST_PRIO: Defines the lowest priority that can be assigned"
  1494. #endif
  1495. #ifndef OS_MAX_EVENTS
  1496. #error "OS_CFG.H, Missing OS_MAX_EVENTS: Max. number of event control blocks in your application"
  1497. #else
  1498. #if OS_MAX_EVENTS > 65500u
  1499. #error "OS_CFG.H, OS_MAX_EVENTS must be <= 65500"
  1500. #endif
  1501. #endif
  1502. #ifndef OS_SCHED_LOCK_EN
  1503. #error "OS_CFG.H, Missing OS_SCHED_LOCK_EN: Include code for OSSchedLock() and OSSchedUnlock()"
  1504. #endif
  1505. #ifndef OS_EVENT_MULTI_EN
  1506. #error "OS_CFG.H, Missing OS_EVENT_MULTI_EN: Include code for OSEventPendMulti()"
  1507. #endif
  1508. #ifndef OS_TASK_PROFILE_EN
  1509. #error "OS_CFG.H, Missing OS_TASK_PROFILE_EN: Include data structure for run-time task profiling"
  1510. #endif
  1511. #ifndef OS_TASK_SW_HOOK_EN
  1512. #error "OS_CFG.H, Missing OS_TASK_SW_HOOK_EN: Allows you to include the code for OSTaskSwHook() or not"
  1513. #endif
  1514. #ifndef OS_TICK_STEP_EN
  1515. #error "OS_CFG.H, Missing OS_TICK_STEP_EN: Allows to 'step' one tick at a time with uC/OS-View"
  1516. #endif
  1517. #ifndef OS_TIME_TICK_HOOK_EN
  1518. #error "OS_CFG.H, Missing OS_TIME_TICK_HOOK_EN: Allows you to include the code for OSTimeTickHook() or not"
  1519. #endif
  1520. /*
  1521. *********************************************************************************************************
  1522. * SAFETY CRITICAL USE
  1523. *********************************************************************************************************
  1524. */
  1525. #ifdef SAFETY_CRITICAL_RELEASE
  1526. #if OS_ARG_CHK_EN < 1u
  1527. #error "OS_CFG.H, OS_ARG_CHK_EN must be enabled for safety-critical release code"
  1528. #endif
  1529. #if OS_APP_HOOKS_EN > 0u
  1530. #error "OS_CFG.H, OS_APP_HOOKS_EN must be disabled for safety-critical release code"
  1531. #endif
  1532. #if OS_DEBUG_EN > 0u
  1533. #error "OS_CFG.H, OS_DEBUG_EN must be disabled for safety-critical release code"
  1534. #endif
  1535. #ifdef CANTATA
  1536. #error "OS_CFG.H, CANTATA must be disabled for safety-critical release code"
  1537. #endif
  1538. #ifdef OS_SCHED_LOCK_EN
  1539. #error "OS_CFG.H, OS_SCHED_LOCK_EN must be disabled for safety-critical release code"
  1540. #endif
  1541. #ifdef VSC_VALIDATION_MODE
  1542. #error "OS_CFG.H, VSC_VALIDATION_MODE must be disabled for safety-critical release code"
  1543. #endif
  1544. #if OS_TASK_STAT_EN > 0u
  1545. #error "OS_CFG.H, OS_TASK_STAT_EN must be disabled for safety-critical release code"
  1546. #endif
  1547. #if OS_TICK_STEP_EN > 0u
  1548. #error "OS_CFG.H, OS_TICK_STEP_EN must be disabled for safety-critical release code"
  1549. #endif
  1550. #if OS_FLAG_EN > 0u
  1551. #if OS_FLAG_DEL_EN > 0
  1552. #error "OS_CFG.H, OS_FLAG_DEL_EN must be disabled for safety-critical release code"
  1553. #endif
  1554. #endif
  1555. #if OS_MBOX_EN > 0u
  1556. #if OS_MBOX_DEL_EN > 0u
  1557. #error "OS_CFG.H, OS_MBOX_DEL_EN must be disabled for safety-critical release code"
  1558. #endif
  1559. #endif
  1560. #if OS_MUTEX_EN > 0u
  1561. #if OS_MUTEX_DEL_EN > 0u
  1562. #error "OS_CFG.H, OS_MUTEX_DEL_EN must be disabled for safety-critical release code"
  1563. #endif
  1564. #endif
  1565. #if OS_Q_EN > 0u
  1566. #if OS_Q_DEL_EN > 0u
  1567. #error "OS_CFG.H, OS_Q_DEL_EN must be disabled for safety-critical release code"
  1568. #endif
  1569. #endif
  1570. #if OS_SEM_EN > 0u
  1571. #if OS_SEM_DEL_EN > 0u
  1572. #error "OS_CFG.H, OS_SEM_DEL_EN must be disabled for safety-critical release code"
  1573. #endif
  1574. #endif
  1575. #if OS_TASK_DEL_EN > 0u
  1576. #error "OS_CFG.H, OS_TASK_DEL_EN must be disabled for safety-critical release code"
  1577. #endif
  1578. #if OS_CRITICAL_METHOD != 3u
  1579. #error "OS_CPU.H, OS_CRITICAL_METHOD must be type 3 for safety-critical release code"
  1580. #endif
  1581. #endif /* ------------------------ SAFETY_CRITICAL_RELEASE ------------------------ */
  1582. #ifdef __cplusplus
  1583. }
  1584. #endif
  1585. #endif