ucos_ii.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  1. /***********************************Jieli tech************************************************
  2. File : ucos_ii.h
  3. By : Juntham
  4. date : 2014-07-03 09:09
  5. ********************************************************************************************/
  6. #ifndef OS_uCOS_II_H
  7. #define OS_uCOS_II_H
  8. #include "generic/typedef.h"
  9. #include "os/os_cpu.h"
  10. #include "os/os_cfg.h"
  11. #include "os/os_api.h"
  12. /*
  13. *********************************************************************************************************
  14. * INCLUDE HEADER FILES
  15. *********************************************************************************************************
  16. */
  17. #ifdef __cplusplus
  18. extern "C"
  19. {
  20. #endif
  21. #define OS_VERSION 100u /* Version */
  22. #define OS_STAT_RDY 0x00u /* Ready to run */
  23. #define OS_STAT_SEM 0x01u /* Pending on semaphore */
  24. #define OS_STAT_Q 0x02u /* Pending on queue */
  25. #define OS_STAT_SUSPEND 0x04u /* Task is suspended */
  26. #define OS_STAT_MUTEX 0x08u /* Pending on mutual exclusion semaphore */
  27. #define OS_STAT_TASK_Q 0x10u /* Pending on task Q */
  28. #define OS_STAT_DELAY 0x20u /* Task on delay */
  29. #define OS_STAT_FLAG 0x40u /* Pending on event flag group */
  30. #define OS_STAT_PEND_ANY (OS_STAT_SEM | OS_STAT_Q | OS_STAT_MUTEX | OS_STAT_TASK_Q)
  31. /*
  32. *********************************************************************************************************
  33. * OS_EVENT types
  34. *********************************************************************************************************
  35. */
  36. #define OS_EVENT_TYPE_UNUSED 0u
  37. #define OS_EVENT_TYPE_Q 1u
  38. #define OS_EVENT_TYPE_SEM 2u
  39. #define OS_EVENT_TYPE_MUTEX 3u
  40. #define OS_EVENT_TYPE_FLAG 5u
  41. /*
  42. *********************************************************************************************************
  43. * OS???PostOpt() OPTIONS
  44. *
  45. * These #defines are used to establish the options for OSMboxPostOpt() and OSQPostOpt().
  46. *********************************************************************************************************
  47. */
  48. #define OS_POST_OPT_NONE 0x00u /* NO option selected */
  49. #define OS_POST_OPT_BROADCAST 0x01u /* Broadcast message to ALL tasks waiting */
  50. #define OS_POST_OPT_FRONT 0x02u /* Post to highest priority task waiting */
  51. /*
  52. *********************************************************************************************************
  53. * MISCELLANEOUS
  54. *********************************************************************************************************
  55. */
  56. #ifdef OS_GLOBALS
  57. #define OS_EXT
  58. #else
  59. #define OS_EXT extern
  60. #endif
  61. /*
  62. *********************************************************************************************************
  63. * EVENT CONTROL BLOCK
  64. *********************************************************************************************************
  65. */
  66. #if OS_EVENT_EN
  67. struct event_cnt {
  68. u16 cnt;
  69. };
  70. struct event_mutex {
  71. u8 value;
  72. u8 prio;
  73. u16 OwnerNestingCtr;
  74. };
  75. struct os_tcb;
  76. typedef struct os_event {
  77. u8 OSEventType; /* Type of event control block (see OS_EVENT_TYPE_xxxx) */
  78. #if OS_TIME_SLICE_EN > 0
  79. struct os_tcb *OSTCBList; /* TCB List */
  80. #else
  81. OS_CPU_DATA OSTCBList;
  82. #endif
  83. void *OSEventPtr; /* Pointer to message or queue structure */
  84. union {
  85. struct event_cnt OSEvent;
  86. struct event_mutex OSMutex;
  87. };
  88. } OS_EVENT;
  89. /*
  90. *********************************************************************************************************
  91. * EVENT FLAGS CONTROL BLOCK
  92. *********************************************************************************************************
  93. */
  94. #if (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
  95. /*
  96. *********************************************************************************************************
  97. * EVENT FLAGS
  98. *********************************************************************************************************
  99. */
  100. #define OS_FLAG_WAIT_CLR_ALL 0u /* Wait for ALL the bits specified to be CLR (i.e. 0) */
  101. #define OS_FLAG_WAIT_CLR_AND 0u
  102. #define OS_FLAG_WAIT_CLR_ANY 1u /* Wait for ANY of the bits specified to be CLR (i.e. 0) */
  103. #define OS_FLAG_WAIT_CLR_OR 1u
  104. #define OS_FLAG_WAIT_SET_ALL 2u /* Wait for ALL the bits specified to be SET (i.e. 1) */
  105. #define OS_FLAG_WAIT_SET_AND 2u
  106. #define OS_FLAG_WAIT_SET_ANY 3u /* Wait for ANY of the bits specified to be SET (i.e. 1) */
  107. #define OS_FLAG_WAIT_SET_OR 3u
  108. #define OS_FLAG_CONSUME 0x80u /* Consume the flags if condition(s) satisfied */
  109. #define OS_FLAG_CLR 0u
  110. #define OS_FLAG_SET 1u
  111. #if OS_FLAGS_NBITS == 8 /* Determine the size of OS_FLAGS (8, 16 or 32 bits) */
  112. typedef INT8U OS_FLAGS;
  113. #endif
  114. #if OS_FLAGS_NBITS == 16
  115. typedef INT16U OS_FLAGS;
  116. #endif
  117. #if OS_FLAGS_NBITS == 32
  118. typedef u32 OS_FLAGS;
  119. #endif
  120. typedef struct os_flag_grp { /* Event Flag Group */
  121. u8 OSFlagType; /* Should be set to OS_EVENT_TYPE_FLAG */
  122. void *OSFlagWaitList; /* Pointer to first NODE of task waiting on event flag */
  123. OS_FLAGS OSFlagFlags; /* 8, 16 or 32 bit flags */
  124. #if OS_FLAG_NAME_SIZE > 1
  125. u8 OSFlagName[OS_FLAG_NAME_SIZE];
  126. #endif
  127. } OS_FLAG_GRP;
  128. typedef struct os_flag_node { /* Event Flag Wait List Node */
  129. void *OSFlagNodeNext; /* Pointer to next NODE in wait list */
  130. void *OSFlagNodePrev; /* Pointer to previous NODE in wait list */
  131. void *OSFlagNodeTCB; /* Pointer to TCB of waiting task */
  132. void *OSFlagNodeFlagGrp; /* Pointer to Event Flag Group */
  133. OS_FLAGS OSFlagNodeFlags; /* Event flag to wait on */
  134. u8 OSFlagNodeWaitType; /* Type of wait: */
  135. /* OS_FLAG_WAIT_AND */
  136. /* OS_FLAG_WAIT_ALL */
  137. /* OS_FLAG_WAIT_OR */
  138. /* OS_FLAG_WAIT_ANY */
  139. } OS_FLAG_NODE;
  140. OS_EXT OS_FLAG_GRP OSFlagTbl[OS_MAX_FLAGS]; /* Table containing event flag groups */
  141. OS_EXT OS_FLAG_GRP *OSFlagFreeList; /* Pointer to free list of event flag groups */
  142. OS_FLAG_GRP *OSFlagCreate(OS_FLAGS flags, u8 *err);
  143. OS_FLAG_GRP *OSFlagDel(OS_FLAG_GRP *pgrp, u8 opt, u8 *err);
  144. OS_FLAGS OSFlagPend(OS_FLAG_GRP *pgrp, OS_FLAGS flags, u8 wait_type, u16 timeout, u8 *err);
  145. OS_FLAGS OSFlagPost(OS_FLAG_GRP *pgrp, OS_FLAGS flags, u8 opt, u8 *err);
  146. #endif
  147. /*$PAGE*/
  148. /*
  149. *********************************************************************************************************
  150. * MESSAGE QUEUE DATA
  151. *********************************************************************************************************
  152. */
  153. #if (OS_Q_EN > 0) || (OS_TASKQ_EN > 0)
  154. typedef struct os_q { /* QUEUE CONTROL BLOCK */
  155. QS OSQIn;
  156. QS OSQOut;
  157. QS OSQSize; /* Size of queue (maximum number of entries) */
  158. QS OSQEntries; /* Current number of entries in the queue */
  159. void **OSQStart; /* Pointer to start of queue data */
  160. } OS_Q;
  161. #endif
  162. /*$PAGE*/
  163. /*
  164. *********************************************************************************************************
  165. * TASK CONTROL BLOCK
  166. *********************************************************************************************************
  167. */
  168. typedef struct os_tcb {
  169. OS_STK *OSTCBStkPtr; /* Pointer to current top of stack */
  170. #if OS_CPU_MMU > 0
  171. u8 *frame;
  172. #endif
  173. #if OS_TIME_SLICE_EN > 0
  174. u8 slice_quanta; /* 时间片初始值 */
  175. u8 slice_cnt; /* 时间片模式下的计数值 */
  176. u16 OSTCBDly; /* Nbr ticks to delay task or, timeout waiting for event */
  177. #endif
  178. #if OS_TASKQ_EN > 0
  179. OS_Q task_q;
  180. #endif
  181. #if OS_PARENT_TCB > 0
  182. struct os_tcb *OSTCBParent;
  183. #endif
  184. #if OS_CHILD_TCB > 0
  185. struct os_tcb *OSTCBChildNext;
  186. #endif
  187. #if OS_TIME_SLICE_EN > 0
  188. struct os_tcb *OSTCBEventNext; /* Pointer to next TCB in the event waiting TCB list */
  189. struct os_tcb *OSTCBEventPrev; /* Pointer to previous TCB in the event waiting TCB list */
  190. struct os_tcb *OSTCBSliceNext; /* Pointer to next TCB in the time slice TCB list */
  191. struct os_tcb *OSTCBSlicePrev; /* Pointer to previous TCB in the time slice TCB list */
  192. #endif
  193. #if OS_EVENT_EN
  194. OS_EVENT *OSTCBEventPtr; /* Pointer to event control block */
  195. #endif
  196. #if (OS_Q_EN > 0) || (OS_TASKQ_EN > 0)
  197. void *OSTCBMsg; /* Message received from OSMboxPost() or OSQPost() */
  198. #endif
  199. #if OS_FLAG_EN > 0
  200. OS_FLAG_NODE *OSTCBFlagNode; /* Pointer to event flag node */
  201. OS_FLAGS OSTCBFlagsRdy;
  202. #endif
  203. #if OS_TIME_SLICE_EN == 0
  204. u16 OSTCBDly; /* Nbr ticks to delay task or, timeout waiting for event */
  205. #endif
  206. u8 OSTCBPrio; /* Task priority (0 == highest) */
  207. u8 OSTCBStat; /* Task status */
  208. u8 OSTCBPendTO; /* Flag indicating PEND timed out (TRUE == timed out) */
  209. #if OS_TASK_DEL_EN > 0
  210. u8 OSTCBDelReq; /* Indicates whether a task needs to delete itself */
  211. #endif
  212. u8 OSCoreAffinity; /* core */
  213. u8 fork_thread;
  214. OS_STK *OSTCBStkTos;
  215. int *pid;
  216. OS_STK stk_size;
  217. OS_STK *p_stk_base;
  218. char *name;
  219. u32 timeout;
  220. u32 RunTimeCounterStart;
  221. u32 RunTimeCounterTotal;
  222. } OS_TCB;
  223. typedef struct os_tcb_list {
  224. OS_TCB *ptcb;
  225. #if OS_TIME_SLICE_EN > 0
  226. OS_TCB *idle_ptcb;
  227. #endif
  228. } OS_TCB_LIST;
  229. /*
  230. *********************************************************************************************************
  231. * MUTUAL EXCLUSION SEMAPHORE MANAGEMENT
  232. *********************************************************************************************************
  233. */
  234. #if OS_MUTEX_EN > 0
  235. #if OS_MUTEX_ACCEPT_EN > 0
  236. u8 OSMutexAccept(OS_EVENT *pevent);
  237. #endif
  238. u8 OSMutexCreate(OS_EVENT *pevent);
  239. #if OS_MUTEX_DEL_EN > 0
  240. u8 OSMutexDel(OS_EVENT *pevent, u8 opt);
  241. #endif
  242. u8 OSMutexPend(OS_EVENT *pevent, u16 timeout);
  243. u8 OSMutexPost(OS_EVENT *pevent);
  244. #if OS_MUTEX_QUERY_EN > 0
  245. u8 OSMutexQuery(OS_EVENT *pevent, OS_MUTEX_DATA *p_mutex_data);
  246. #endif
  247. #endif
  248. /*
  249. *********************************************************************************************************
  250. * MESSAGE QUEUE MANAGEMENT
  251. *********************************************************************************************************
  252. */
  253. #if (OS_Q_EN > 0)
  254. #if OS_Q_ACCEPT_EN > 0
  255. u8 OSQAccept(OS_EVENT *pevent, void *msg);
  256. #endif
  257. u8 OSQCreate(OS_EVENT *pevent, /*void **start, */QS size);
  258. #if OS_Q_DEL_EN > 0
  259. u8 OSQDel(OS_EVENT *pevent, u8 opt);
  260. #endif
  261. #if OS_Q_FLUSH_EN > 0
  262. u8 OSQFlush(OS_EVENT *pevent);
  263. #endif
  264. u8 OSQPend(OS_EVENT *pevent, u16 timeout, void *msg);
  265. #if OS_Q_POST_EN > 0
  266. u8 OSQPost(OS_EVENT *pevent, void *msg);
  267. #endif
  268. #if OS_Q_POST_FRONT_EN > 0
  269. u8 OSQPostFront(OS_EVENT *pevent, void *msg);
  270. #endif
  271. #if OS_Q_POST_OPT_EN > 0
  272. u8 OSQPostOpt(OS_EVENT *pevent, void *msg, u8 opt);
  273. #endif
  274. #if OS_Q_QUERY_EN > 0
  275. u16 OSQQuery(OS_EVENT *pevent);
  276. #endif
  277. #endif
  278. /*$PAGE*/
  279. /*
  280. *********************************************************************************************************
  281. * SEMAPHORE MANAGEMENT
  282. *********************************************************************************************************
  283. */
  284. #if OS_SEM_EN > 0
  285. #if OS_SEM_ACCEPT_EN > 0
  286. u16 OSSemAccept(OS_EVENT *pevent);
  287. #endif
  288. u8 OSSemCreate(OS_EVENT *pevent, u16 cnt);
  289. #if OS_SEM_DEL_EN > 0
  290. u8 OSSemDel(OS_EVENT *pevent, u8 opt);
  291. #endif
  292. u8 OSSemPend(OS_EVENT *pevent, u16 timeout);
  293. u8 OSSemPost(OS_EVENT *pevent);
  294. #if OS_SEM_QUERY_EN > 0
  295. u16 OSSemQuery(OS_EVENT *pevent);
  296. #endif
  297. #if OS_SEM_SET_EN > 0
  298. u8 OSSemSet(OS_EVENT *pevent, u16 cnt);
  299. #endif
  300. #endif
  301. /*$PAGE*/
  302. /*
  303. *********************************************************************************************************
  304. * TASK MANAGEMENT
  305. *********************************************************************************************************
  306. */
  307. #if OS_TASK_CHANGE_PRIO_EN > 0
  308. u8 OSTaskChangePrio(char *name, u8 newprio);
  309. #endif
  310. #if OS_TASK_CREATE_EN > 0
  311. u8 OSTaskCreate(void (*task)(void *p_arg), OS_TCB *task_tcb, void *p_arg
  312. #if OS_CPU_MMU == 0
  313. , OS_STK *ptos
  314. #endif
  315. , u8 prio
  316. #if OS_TASKQ_EN > 0
  317. , void **start, QS qsize
  318. #endif
  319. #if OS_TIME_SLICE_EN > 0
  320. , u8 time_quanta
  321. #endif
  322. , s8 *name
  323. );
  324. #endif
  325. u8 OSTaskQAccept(int argc, int *argv);
  326. u8 OSTaskQPend(u16 timeout, int argc, int *argv);
  327. u8 OSTaskQPost(const char *name, int argc, ...);
  328. u8 OSTaskQFlush(const char *name);
  329. u8 OSTaskQPostFront(const char *name, int argc, ...);
  330. u8 OSTaskQQuery(const char *name, u8 *task_q_entries);
  331. #if OS_TASK_DEL_EN > 0
  332. u8 OSTaskDel(const char *name);
  333. u8 OSTaskDelReq(const char *name);
  334. void OSTaskDelRes(const char *name);
  335. #endif
  336. #if OS_TASK_SUSPEND_EN > 0
  337. u8 OSTaskResume(const char *name);
  338. u8 OSTaskSuspend(const char *name);
  339. #endif
  340. #if OS_TASK_QUERY_EN > 0
  341. u8 OSTaskQuery(const char *name, OS_TCB *p_task_data);
  342. #endif
  343. /*$PAGE*/
  344. /*
  345. *********************************************************************************************************
  346. * TIME MANAGEMENT
  347. *********************************************************************************************************
  348. */
  349. void OSTimeDly(u16 ticks);
  350. #if OS_TIME_GET_SET_EN > 0
  351. u32 OSTimeGet(void);
  352. void OSTimeSet(u32 ticks);
  353. #endif
  354. void OSTimeTick(void);
  355. /*
  356. *********************************************************************************************************
  357. * MISCELLANEOUS
  358. *********************************************************************************************************
  359. */
  360. void OSInit(void);
  361. void OSStart();
  362. u16 OSVersion(void);
  363. #endif
  364. /*
  365. *********************************************************************************************************
  366. * GLOBAL VARIABLES
  367. *********************************************************************************************************
  368. */
  369. OS_EXT volatile u8 OSRunning; /* Flag indicating that kernel is running */
  370. OS_EXT volatile OS_CPU_DATA OSRdyTbl;
  371. OS_EXT volatile u32 OSIdleCtr; /* Idle counter */
  372. OS_EXT OS_TCB *OSTCBCur[OS_CPU_CORE]; /* Pointer to currently running TCB */
  373. OS_EXT OS_TCB *OSTCBHighRdy[OS_CPU_CORE]; /* Pointer to highest priority TCB R-to-R */
  374. OS_EXT OS_TCB_LIST OSTCBPrioTbl[OS_MAX_TASKS + 1]; /* Table of pointers to created TCBs */
  375. #if (OS_INT_NESTING == 1)
  376. OS_EXT u8 OSIntNesting;
  377. #elif (OS_INT_NESTING == 2)
  378. extern int is_cpu_int_nesting();
  379. #define OSIntNesting is_cpu_int_nesting()
  380. #endif
  381. #if OS_TIME_GET_SET_EN > 0
  382. OS_EXT volatile u32 OSTime; /* Current value of system time (in ticks) */
  383. #endif
  384. /*
  385. *********************************************************************************************************
  386. * MISCELLANEOUS
  387. *********************************************************************************************************
  388. */
  389. /* void OSInit(void); */
  390. void OSIntEnter(void);
  391. void OSIntExit(void);
  392. #if OS_SCHED_LOCK_EN > 0
  393. void OSSchedLock(void);
  394. void OSSchedUnlock(void);
  395. #endif
  396. u32 OS_HighPrio(OS_CPU_DATA table);
  397. void OS_SchedRoundRobin(OS_TCB *ptcb);
  398. void OS_InsertRdyListHead(OS_TCB *ptcb);
  399. void OS_InsertRdyListTail(OS_TCB *ptcb);
  400. void OS_InsertIdleList(OS_TCB *ptcb);
  401. void OS_RemoveRdyList(OS_TCB *ptcb);
  402. void OS_RemoveIdleList(OS_TCB *ptcb);
  403. void OS_InsertListHead(OS_TCB *ptcb);
  404. void OS_RemoveList(OS_TCB *ptcb);
  405. /* void OSStart(); */
  406. void OSStatInit(void);
  407. /* u16 OSVersion(void); */
  408. /*$PAGE*/
  409. /*
  410. *********************************************************************************************************
  411. * INTERNAL FUNCTION PROTOTYPES
  412. * (Your application MUST NOT call these functions)
  413. *********************************************************************************************************
  414. */
  415. #if OS_TASK_DEL_EN > 0
  416. void OS_Dummy(void);
  417. #endif
  418. #if OS_EVENT_EN
  419. void OS_ExchangePrio(OS_TCB *ptcba, OS_TCB *ptcbb);
  420. #if OS_TIME_SLICE_EN > 0
  421. OS_TCB *OS_EventHighestTask(OS_TCB *ptcb, u8 prio);
  422. void OS_EventTaskRdy(OS_EVENT *pevent, OS_TCB *ptcb, void *msg, u8 msk);
  423. #else
  424. OS_TCB *OS_EventTaskRdy(OS_EVENT *pevent, void *msg, u8 msk);
  425. #endif
  426. void OS_EventTaskWait(OS_EVENT *pevent, OS_TCB *OSTCB);
  427. void OS_EventTO(OS_EVENT *pevent, OS_TCB *OSTCB);
  428. void OS_EventWaitListInit(OS_EVENT *pevent);
  429. #endif
  430. void OS_MemClr(u8 *pdest, u16 size);
  431. void OS_MemCopy(u8 *pdest, u8 *psrc, u16 size);
  432. #if OS_Q_EN > 0
  433. void OS_QInit(void);
  434. #endif
  435. int OS_Sched(void);
  436. void OS_TaskIdle(void *p_arg);
  437. void OSIdleOtherCore(void);
  438. void OSResumOtherCore(void);
  439. void OS_CoreAffinitySet(const char *name, u8 Core);
  440. /*$PAGE*/
  441. /*
  442. *********************************************************************************************************
  443. * FUNCTION PROTOTYPES
  444. * (Target Specific Functions)
  445. *********************************************************************************************************
  446. */
  447. #if OS_VERSION >= 204
  448. void OSInitHookBegin(void);
  449. void OSInitHookEnd(void);
  450. #endif
  451. #ifndef OS_ISR_PROTO_EXT
  452. void OSIntCtxSw(void);
  453. void OSStartHighRdy(void);
  454. #endif
  455. void OSTaskCreateHook(OS_TCB *ptcb);
  456. void OSTaskDelHook(OS_TCB *ptcb);
  457. #if OS_VERSION >= 251
  458. void OSTaskIdleHook(void);
  459. #endif
  460. void OSTaskStatHook(void);
  461. OS_STK *OSTaskStkInit(void(*p_task)(void *pd), void *p_arg, OS_STK *p_stk_base, u16 opt);
  462. #if OS_TASK_SW_HOOK_EN > 0
  463. void OSTaskSwHook(void);
  464. #endif
  465. #if OS_VERSION >= 204
  466. void OSTCBInitHook(OS_TCB *ptcb);
  467. #endif
  468. #if OS_TIME_TICK_HOOK_EN > 0
  469. void OSTimeTickHook(void);
  470. #endif
  471. extern void OS_TASK_DEL_HOOK(OS_TCB *ptcb) ;
  472. /*$PAGE*/
  473. /*
  474. *********************************************************************************************************
  475. * LOOK FOR MISSING #define CONSTANTS
  476. *
  477. * This section is used to generate ERROR messages at compile time if certain #define constants are
  478. * MISSING in OS_CFG.H. This allows you to quickly determine the source of the error.
  479. *
  480. * You SHOULD NOT change this section UNLESS you would like to add more comments as to the source of the
  481. * compile time error.
  482. *********************************************************************************************************
  483. */
  484. /*
  485. *********************************************************************************************************
  486. * MUTUAL EXCLUSION SEMAPHORES
  487. *********************************************************************************************************
  488. */
  489. #ifndef OS_MUTEX_EN
  490. #error "OS_CFG.H, Missing OS_MUTEX_EN: Enable (1) or Disable (0) code generation for MUTEX"
  491. #else
  492. #ifndef OS_MUTEX_ACCEPT_EN
  493. #error "OS_CFG.H, Missing OS_MUTEX_ACCEPT_EN: Include code for OSMutexAccept()"
  494. #endif
  495. #ifndef OS_MUTEX_DEL_EN
  496. #error "OS_CFG.H, Missing OS_MUTEX_DEL_EN: Include code for OSMutexDel()"
  497. #endif
  498. #ifndef OS_MUTEX_QUERY_EN
  499. #error "OS_CFG.H, Missing OS_MUTEX_QUERY_EN: Include code for OSMutexQuery()"
  500. #endif
  501. #endif
  502. /*
  503. *********************************************************************************************************
  504. * SEMAPHORES
  505. *********************************************************************************************************
  506. */
  507. #ifndef OS_SEM_EN
  508. #error "OS_CFG.H, Missing OS_SEM_EN: Enable (1) or Disable (0) code generation for SEMAPHORES"
  509. #else
  510. #ifndef OS_SEM_ACCEPT_EN
  511. #error "OS_CFG.H, Missing OS_SEM_ACCEPT_EN: Include code for OSSemAccept()"
  512. #endif
  513. #ifndef OS_SEM_DEL_EN
  514. #error "OS_CFG.H, Missing OS_SEM_DEL_EN: Include code for OSSemDel()"
  515. #endif
  516. #ifndef OS_SEM_QUERY_EN
  517. #error "OS_CFG.H, Missing OS_SEM_QUERY_EN: Include code for OSSemQuery()"
  518. #endif
  519. #ifndef OS_SEM_SET_EN
  520. #error "OS_CFG.H, Missing OS_SEM_SET_EN: Include code for OSSemSet()"
  521. #endif
  522. #endif
  523. /*
  524. *********************************************************************************************************
  525. * TASK MANAGEMENT
  526. *********************************************************************************************************
  527. */
  528. #ifndef OS_MAX_TASKS
  529. #error "OS_CFG.H, Missing OS_MAX_TASKS: Max. number of tasks in your application"
  530. #else
  531. #if OS_MAX_TASKS < 2
  532. #error "OS_CFG.H, OS_MAX_TASKS must be >= 2"
  533. #endif
  534. /* #if OS_MAX_TASKS > (OS_LOWEST_PRIO - OS_N_SYS_TASKS + 1) */
  535. /* #error "OS_CFG.H, OS_MAX_TASKS must be <= OS_LOWEST_PRIO - OS_N_SYS_TASKS + 1" */
  536. /* #endif */
  537. #endif
  538. #if OS_VERSION < 280
  539. #if OS_LOWEST_PRIO > 63
  540. #error "OS_CFG.H, OS_LOWEST_PRIO must be <= 63 in V2.7x or lower"
  541. #endif
  542. #endif
  543. #if OS_VERSION >= 280
  544. #if OS_LOWEST_PRIO > 254
  545. #error "OS_CFG.H, OS_LOWEST_PRIO must be <= 254 in V2.8x and higher"
  546. #endif
  547. #endif
  548. #ifndef OS_TASK_CHANGE_PRIO_EN
  549. #error "OS_CFG.H, Missing OS_TASK_CHANGE_PRIO_EN: Include code for OSTaskChangePrio()"
  550. #endif
  551. #ifndef OS_TASK_CREATE_EN
  552. #error "OS_CFG.H, Missing OS_TASK_CREATE_EN: Include code for OSTaskCreate()"
  553. #endif
  554. #ifndef OS_TASK_DEL_EN
  555. #error "OS_CFG.H, Missing OS_TASK_DEL_EN: Include code for OSTaskDel()"
  556. #endif
  557. #ifndef OS_TASK_SUSPEND_EN
  558. #error "OS_CFG.H, Missing OS_TASK_SUSPEND_EN: Include code for OSTaskSuspend() and OSTaskResume()"
  559. #endif
  560. #ifndef OS_TASK_QUERY_EN
  561. #error "OS_CFG.H, Missing OS_TASK_QUERY_EN: Include code for OSTaskQuery()"
  562. #endif
  563. /*
  564. *********************************************************************************************************
  565. * TIME MANAGEMENT
  566. *********************************************************************************************************
  567. */
  568. #ifndef OS_TICKS_PER_SEC
  569. #error "OS_CFG.H, Missing OS_TICKS_PER_SEC: Sets the number of ticks in one second"
  570. #endif
  571. #ifndef OS_TIME_DLY_HMSM_EN
  572. #error "OS_CFG.H, Missing OS_TIME_DLY_HMSM_EN: Include code for OSTimeDlyHMSM()"
  573. #endif
  574. #ifndef OS_TIME_DLY_RESUME_EN
  575. #error "OS_CFG.H, Missing OS_TIME_DLY_RESUME_EN: Include code for OSTimeDlyResume()"
  576. #endif
  577. #ifndef OS_TIME_GET_SET_EN
  578. #error "OS_CFG.H, Missing OS_TIME_GET_SET_EN: Include code for OSTimeGet() and OSTimeSet()"
  579. #endif
  580. /*
  581. *********************************************************************************************************
  582. * MISCELLANEOUS
  583. *********************************************************************************************************
  584. */
  585. #ifndef OS_ARG_CHK_EN
  586. #error "OS_CFG.H, Missing OS_ARG_CHK_EN: Enable (1) or Disable (0) argument checking"
  587. #endif
  588. #ifndef OS_CPU_HOOKS_EN
  589. #error "OS_CFG.H, Missing OS_CPU_HOOKS_EN: uC/OS-II hooks are found in the processor port files when 1"
  590. #endif
  591. #ifndef OS_LOWEST_PRIO
  592. #error "OS_CFG.H, Missing OS_LOWEST_PRIO: Defines the lowest priority that can be assigned"
  593. #endif
  594. #ifndef OS_SCHED_LOCK_EN
  595. #error "OS_CFG.H, Missing OS_SCHED_LOCK_EN: Include code for OSSchedLock() and OSSchedUnlock()"
  596. #endif
  597. #ifndef OS_TASK_SW_HOOK_EN
  598. #error "OS_CFG.H, Missing OS_TASK_SW_HOOK_EN: Allows you to include the code for OSTaskSwHook() or not"
  599. #endif
  600. #ifndef OS_TIME_TICK_HOOK_EN
  601. #error "OS_CFG.H, Missing OS_TIME_TICK_HOOK_EN: Allows you to include the code for OSTimeTickHook() or not"
  602. #endif
  603. #ifdef __cplusplus
  604. }
  605. #endif
  606. #endif