ucos_ii.h 76 KB

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