PageRenderTime 46ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/src/compiler/ucos-vs2008/UCOS_SIM/src/ucosii/ucos_ii.h

http://ftk.googlecode.com/
C Header | 1404 lines | 848 code | 298 blank | 258 comment | 34 complexity | 94011d4a119ffbe1da59083a2bc9bcec MD5 | raw file
Possible License(s): LGPL-3.0
  1. /*
  2. *********************************************************************************************************
  3. * uC/OS-II
  4. * The Real-Time Kernel
  5. *
  6. * (c) Copyright 1992-2005, Jean J. Labrosse, Weston, FL
  7. * All Rights Reserved
  8. *
  9. * File : uCOS_II.H
  10. * By : Jean J. Labrosse
  11. * Version : V2.80
  12. *********************************************************************************************************
  13. */
  14. #ifndef OS_uCOS_II_H
  15. #define OS_uCOS_II_H
  16. /*
  17. *********************************************************************************************************
  18. * uC/OS-II VERSION NUMBER
  19. *********************************************************************************************************
  20. */
  21. #define OS_VERSION 280u /* Version of uC/OS-II (Vx.yy mult. by 100) */
  22. /*
  23. *********************************************************************************************************
  24. * INCLUDE HEADER FILES
  25. *********************************************************************************************************
  26. */
  27. #include <os_cpu.h>
  28. #include <os_cfg.h>
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /*
  33. *********************************************************************************************************
  34. * MISCELLANEOUS
  35. *********************************************************************************************************
  36. */
  37. #ifdef OS_GLOBALS
  38. #define OS_EXT
  39. #else
  40. #define OS_EXT extern
  41. #endif
  42. #ifndef FALSE
  43. #define FALSE 0u
  44. #endif
  45. #ifndef TRUE
  46. #define TRUE 1u
  47. #endif
  48. #define OS_ASCII_NUL (INT8U)0
  49. #define OS_PRIO_SELF 0xFFu /* Indicate SELF priority */
  50. #if OS_TASK_STAT_EN > 0
  51. #define OS_N_SYS_TASKS 2u /* Number of system tasks */
  52. #else
  53. #define OS_N_SYS_TASKS 1u
  54. #endif
  55. #define OS_STAT_PRIO (OS_LOWEST_PRIO - 1) /* Statistic task priority */
  56. #define OS_IDLE_PRIO (OS_LOWEST_PRIO) /* IDLE task priority */
  57. #if OS_LOWEST_PRIO <= 63
  58. #define OS_EVENT_TBL_SIZE ((OS_LOWEST_PRIO) / 8 + 1) /* Size of event table */
  59. #define OS_RDY_TBL_SIZE ((OS_LOWEST_PRIO) / 8 + 1) /* Size of ready table */
  60. #else
  61. #define OS_EVENT_TBL_SIZE ((OS_LOWEST_PRIO) / 16 + 1) /* Size of event table */
  62. #define OS_RDY_TBL_SIZE ((OS_LOWEST_PRIO) / 16 + 1) /* Size of ready table */
  63. #endif
  64. #define OS_TASK_IDLE_ID 65535u /* I.D. numbers for Idle and Stat tasks */
  65. #define OS_TASK_STAT_ID 65534u
  66. #define OS_EVENT_EN (((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0) || (OS_SEM_EN > 0) || (OS_MUTEX_EN > 0))
  67. /*$PAGE*/
  68. /*
  69. *********************************************************************************************************
  70. * TASK STATUS (Bit definition for OSTCBStat)
  71. *********************************************************************************************************
  72. */
  73. #define OS_STAT_RDY 0x00u /* Ready to run */
  74. #define OS_STAT_SEM 0x01u /* Pending on semaphore */
  75. #define OS_STAT_MBOX 0x02u /* Pending on mailbox */
  76. #define OS_STAT_Q 0x04u /* Pending on queue */
  77. #define OS_STAT_SUSPEND 0x08u /* Task is suspended */
  78. #define OS_STAT_MUTEX 0x10u /* Pending on mutual exclusion semaphore */
  79. #define OS_STAT_FLAG 0x20u /* Pending on event flag group */
  80. #define OS_STAT_PEND_ANY (OS_STAT_SEM | OS_STAT_MBOX | OS_STAT_Q | OS_STAT_MUTEX | OS_STAT_FLAG)
  81. /*
  82. *********************************************************************************************************
  83. * OS_EVENT types
  84. *********************************************************************************************************
  85. */
  86. #define OS_EVENT_TYPE_UNUSED 0u
  87. #define OS_EVENT_TYPE_MBOX 1u
  88. #define OS_EVENT_TYPE_Q 2u
  89. #define OS_EVENT_TYPE_SEM 3u
  90. #define OS_EVENT_TYPE_MUTEX 4u
  91. #define OS_EVENT_TYPE_FLAG 5u
  92. /*
  93. *********************************************************************************************************
  94. * EVENT FLAGS
  95. *********************************************************************************************************
  96. */
  97. #define OS_FLAG_WAIT_CLR_ALL 0u /* Wait for ALL the bits specified to be CLR (i.e. 0) */
  98. #define OS_FLAG_WAIT_CLR_AND 0u
  99. #define OS_FLAG_WAIT_CLR_ANY 1u /* Wait for ANY of the bits specified to be CLR (i.e. 0) */
  100. #define OS_FLAG_WAIT_CLR_OR 1u
  101. #define OS_FLAG_WAIT_SET_ALL 2u /* Wait for ALL the bits specified to be SET (i.e. 1) */
  102. #define OS_FLAG_WAIT_SET_AND 2u
  103. #define OS_FLAG_WAIT_SET_ANY 3u /* Wait for ANY of the bits specified to be SET (i.e. 1) */
  104. #define OS_FLAG_WAIT_SET_OR 3u
  105. #define OS_FLAG_CONSUME 0x80u /* Consume the flags if condition(s) satisfied */
  106. #define OS_FLAG_CLR 0u
  107. #define OS_FLAG_SET 1u
  108. /*
  109. *********************************************************************************************************
  110. * Values for OSTickStepState
  111. *
  112. * Note(s): This feature is used by uC/OS-View.
  113. *********************************************************************************************************
  114. */
  115. #if OS_TICK_STEP_EN > 0
  116. #define OS_TICK_STEP_DIS 0u /* Stepping is disabled, tick runs as mormal */
  117. #define OS_TICK_STEP_WAIT 1u /* Waiting for uC/OS-View to set OSTickStepState to _ONCE */
  118. #define OS_TICK_STEP_ONCE 2u /* Process tick once and wait for next cmd from uC/OS-View */
  119. #endif
  120. /*
  121. *********************************************************************************************************
  122. * Possible values for 'opt' argument of OSSemDel(), OSMboxDel(), OSQDel() and OSMutexDel()
  123. *********************************************************************************************************
  124. */
  125. #define OS_DEL_NO_PEND 0u
  126. #define OS_DEL_ALWAYS 1u
  127. /*
  128. *********************************************************************************************************
  129. * OS???PostOpt() OPTIONS
  130. *
  131. * These #defines are used to establish the options for OSMboxPostOpt() and OSQPostOpt().
  132. *********************************************************************************************************
  133. */
  134. #define OS_POST_OPT_NONE 0x00u /* NO option selected */
  135. #define OS_POST_OPT_BROADCAST 0x01u /* Broadcast message to ALL tasks waiting */
  136. #define OS_POST_OPT_FRONT 0x02u /* Post to highest priority task waiting */
  137. /*
  138. *********************************************************************************************************
  139. * TASK OPTIONS (see OSTaskCreateExt())
  140. *********************************************************************************************************
  141. */
  142. #define OS_TASK_OPT_NONE 0x0000u /* NO option selected */
  143. #define OS_TASK_OPT_STK_CHK 0x0001u /* Enable stack checking for the task */
  144. #define OS_TASK_OPT_STK_CLR 0x0002u /* Clear the stack when the task is create */
  145. #define OS_TASK_OPT_SAVE_FP 0x0004u /* Save the contents of any floating-point registers */
  146. /*
  147. *********************************************************************************************************
  148. * ERROR CODES
  149. *********************************************************************************************************
  150. */
  151. #define OS_NO_ERR 0u
  152. #define OS_ERR_EVENT_TYPE 1u
  153. #define OS_ERR_PEND_ISR 2u
  154. #define OS_ERR_POST_NULL_PTR 3u
  155. #define OS_ERR_PEVENT_NULL 4u
  156. #define OS_ERR_POST_ISR 5u
  157. #define OS_ERR_QUERY_ISR 6u
  158. #define OS_ERR_INVALID_OPT 7u
  159. #define OS_ERR_TASK_WAITING 8u
  160. #define OS_ERR_PDATA_NULL 9u
  161. #define OS_TIMEOUT 10u
  162. #define OS_TASK_NOT_EXIST 11u
  163. #define OS_ERR_EVENT_NAME_TOO_LONG 12u
  164. #define OS_ERR_FLAG_NAME_TOO_LONG 13u
  165. #define OS_ERR_TASK_NAME_TOO_LONG 14u
  166. #define OS_ERR_PNAME_NULL 15u
  167. #define OS_ERR_TASK_CREATE_ISR 16u
  168. #define OS_MBOX_FULL 20u
  169. #define OS_Q_FULL 30u
  170. #define OS_Q_EMPTY 31u
  171. #define OS_PRIO_EXIST 40u
  172. #define OS_PRIO_ERR 41u
  173. #define OS_PRIO_INVALID 42u
  174. #define OS_SEM_OVF 50u
  175. #define OS_TASK_DEL_ERR 60u
  176. #define OS_TASK_DEL_IDLE 61u
  177. #define OS_TASK_DEL_REQ 62u
  178. #define OS_TASK_DEL_ISR 63u
  179. #define OS_NO_MORE_TCB 70u
  180. #define OS_TIME_NOT_DLY 80u
  181. #define OS_TIME_INVALID_MINUTES 81u
  182. #define OS_TIME_INVALID_SECONDS 82u
  183. #define OS_TIME_INVALID_MILLI 83u
  184. #define OS_TIME_ZERO_DLY 84u
  185. #define OS_TASK_SUSPEND_PRIO 90u
  186. #define OS_TASK_SUSPEND_IDLE 91u
  187. #define OS_TASK_RESUME_PRIO 100u
  188. #define OS_TASK_NOT_SUSPENDED 101u
  189. #define OS_MEM_INVALID_PART 110u
  190. #define OS_MEM_INVALID_BLKS 111u
  191. #define OS_MEM_INVALID_SIZE 112u
  192. #define OS_MEM_NO_FREE_BLKS 113u
  193. #define OS_MEM_FULL 114u
  194. #define OS_MEM_INVALID_PBLK 115u
  195. #define OS_MEM_INVALID_PMEM 116u
  196. #define OS_MEM_INVALID_PDATA 117u
  197. #define OS_MEM_INVALID_ADDR 118u
  198. #define OS_MEM_NAME_TOO_LONG 119u
  199. #define OS_ERR_NOT_MUTEX_OWNER 120u
  200. #define OS_TASK_OPT_ERR 130u
  201. #define OS_ERR_DEL_ISR 140u
  202. #define OS_ERR_CREATE_ISR 141u
  203. #define OS_FLAG_INVALID_PGRP 150u
  204. #define OS_FLAG_ERR_WAIT_TYPE 151u
  205. #define OS_FLAG_ERR_NOT_RDY 152u
  206. #define OS_FLAG_INVALID_OPT 153u
  207. #define OS_FLAG_GRP_DEPLETED 154u
  208. #define OS_ERR_PIP_LOWER 160u
  209. /*$PAGE*/
  210. /*
  211. *********************************************************************************************************
  212. * EVENT CONTROL BLOCK
  213. *********************************************************************************************************
  214. */
  215. #if OS_EVENT_EN && (OS_MAX_EVENTS > 0)
  216. typedef struct os_event {
  217. INT8U OSEventType; /* Type of event control block (see OS_EVENT_TYPE_xxxx) */
  218. void *OSEventPtr; /* Pointer to message or queue structure */
  219. INT16U OSEventCnt; /* Semaphore Count (not used if other EVENT type) */
  220. #if OS_LOWEST_PRIO <= 63
  221. INT8U OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
  222. INT8U OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
  223. #else
  224. INT16U OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
  225. INT16U OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
  226. #endif
  227. #if OS_EVENT_NAME_SIZE > 1
  228. INT8U OSEventName[OS_EVENT_NAME_SIZE];
  229. #endif
  230. } OS_EVENT;
  231. #endif
  232. /*
  233. *********************************************************************************************************
  234. * EVENT FLAGS CONTROL BLOCK
  235. *********************************************************************************************************
  236. */
  237. #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
  238. #if OS_FLAGS_NBITS == 8 /* Determine the size of OS_FLAGS (8, 16 or 32 bits) */
  239. typedef INT8U OS_FLAGS;
  240. #endif
  241. #if OS_FLAGS_NBITS == 16
  242. typedef INT16U OS_FLAGS;
  243. #endif
  244. #if OS_FLAGS_NBITS == 32
  245. typedef INT32U OS_FLAGS;
  246. #endif
  247. typedef struct os_flag_grp { /* Event Flag Group */
  248. INT8U OSFlagType; /* Should be set to OS_EVENT_TYPE_FLAG */
  249. void *OSFlagWaitList; /* Pointer to first NODE of task waiting on event flag */
  250. OS_FLAGS OSFlagFlags; /* 8, 16 or 32 bit flags */
  251. #if OS_FLAG_NAME_SIZE > 1
  252. INT8U OSFlagName[OS_FLAG_NAME_SIZE];
  253. #endif
  254. } OS_FLAG_GRP;
  255. typedef struct os_flag_node { /* Event Flag Wait List Node */
  256. void *OSFlagNodeNext; /* Pointer to next NODE in wait list */
  257. void *OSFlagNodePrev; /* Pointer to previous NODE in wait list */
  258. void *OSFlagNodeTCB; /* Pointer to TCB of waiting task */
  259. void *OSFlagNodeFlagGrp; /* Pointer to Event Flag Group */
  260. OS_FLAGS OSFlagNodeFlags; /* Event flag to wait on */
  261. INT8U OSFlagNodeWaitType; /* Type of wait: */
  262. /* OS_FLAG_WAIT_AND */
  263. /* OS_FLAG_WAIT_ALL */
  264. /* OS_FLAG_WAIT_OR */
  265. /* OS_FLAG_WAIT_ANY */
  266. } OS_FLAG_NODE;
  267. #endif
  268. /*$PAGE*/
  269. /*
  270. *********************************************************************************************************
  271. * MESSAGE MAILBOX DATA
  272. *********************************************************************************************************
  273. */
  274. #if OS_MBOX_EN > 0
  275. typedef struct os_mbox_data {
  276. void *OSMsg; /* Pointer to message in mailbox */
  277. #if OS_LOWEST_PRIO <= 63
  278. INT8U OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
  279. INT8U OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
  280. #else
  281. INT16U OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
  282. INT16U OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
  283. #endif
  284. } OS_MBOX_DATA;
  285. #endif
  286. /*
  287. *********************************************************************************************************
  288. * MEMORY PARTITION DATA STRUCTURES
  289. *********************************************************************************************************
  290. */
  291. #if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
  292. typedef struct os_mem { /* MEMORY CONTROL BLOCK */
  293. void *OSMemAddr; /* Pointer to beginning of memory partition */
  294. void *OSMemFreeList; /* Pointer to list of free memory blocks */
  295. INT32U OSMemBlkSize; /* Size (in bytes) of each block of memory */
  296. INT32U OSMemNBlks; /* Total number of blocks in this partition */
  297. INT32U OSMemNFree; /* Number of memory blocks remaining in this partition */
  298. #if OS_MEM_NAME_SIZE > 1
  299. INT8U OSMemName[OS_MEM_NAME_SIZE]; /* Memory partition name */
  300. #endif
  301. } OS_MEM;
  302. typedef struct os_mem_data {
  303. void *OSAddr; /* Pointer to the beginning address of the memory partition */
  304. void *OSFreeList; /* Pointer to the beginning of the free list of memory blocks */
  305. INT32U OSBlkSize; /* Size (in bytes) of each memory block */
  306. INT32U OSNBlks; /* Total number of blocks in the partition */
  307. INT32U OSNFree; /* Number of memory blocks free */
  308. INT32U OSNUsed; /* Number of memory blocks used */
  309. } OS_MEM_DATA;
  310. #endif
  311. /*$PAGE*/
  312. /*
  313. *********************************************************************************************************
  314. * MUTUAL EXCLUSION SEMAPHORE DATA
  315. *********************************************************************************************************
  316. */
  317. #if OS_MUTEX_EN > 0
  318. typedef struct os_mutex_data {
  319. #if OS_LOWEST_PRIO <= 63
  320. INT8U OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
  321. INT8U OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
  322. #else
  323. INT16U OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
  324. INT16U OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
  325. #endif
  326. INT8U OSValue; /* Mutex value (0 = used, 1 = available) */
  327. INT8U OSOwnerPrio; /* Mutex owner's task priority or 0xFF if no owner */
  328. INT8U OSMutexPIP; /* Priority Inheritance Priority or 0xFF if no owner */
  329. } OS_MUTEX_DATA;
  330. #endif
  331. /*
  332. *********************************************************************************************************
  333. * MESSAGE QUEUE DATA
  334. *********************************************************************************************************
  335. */
  336. #if OS_Q_EN > 0
  337. typedef struct os_q { /* QUEUE CONTROL BLOCK */
  338. struct os_q *OSQPtr; /* Link to next queue control block in list of free blocks */
  339. void **OSQStart; /* Pointer to start of queue data */
  340. void **OSQEnd; /* Pointer to end of queue data */
  341. void **OSQIn; /* Pointer to where next message will be inserted in the Q */
  342. void **OSQOut; /* Pointer to where next message will be extracted from the Q */
  343. INT16U OSQSize; /* Size of queue (maximum number of entries) */
  344. INT16U OSQEntries; /* Current number of entries in the queue */
  345. } OS_Q;
  346. typedef struct os_q_data {
  347. void *OSMsg; /* Pointer to next message to be extracted from queue */
  348. INT16U OSNMsgs; /* Number of messages in message queue */
  349. INT16U OSQSize; /* Size of message queue */
  350. #if OS_LOWEST_PRIO <= 63
  351. INT8U OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
  352. INT8U OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
  353. #else
  354. INT16U OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
  355. INT16U OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
  356. #endif
  357. } OS_Q_DATA;
  358. #endif
  359. /*
  360. *********************************************************************************************************
  361. * SEMAPHORE DATA
  362. *********************************************************************************************************
  363. */
  364. #if OS_SEM_EN > 0
  365. typedef struct os_sem_data {
  366. INT16U OSCnt; /* Semaphore count */
  367. #if OS_LOWEST_PRIO <= 63
  368. INT8U OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
  369. INT8U OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
  370. #else
  371. INT16U OSEventTbl[OS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
  372. INT16U OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
  373. #endif
  374. } OS_SEM_DATA;
  375. #endif
  376. /*
  377. *********************************************************************************************************
  378. * TASK STACK DATA
  379. *********************************************************************************************************
  380. */
  381. #if OS_TASK_CREATE_EXT_EN > 0
  382. typedef struct os_stk_data {
  383. INT32U OSFree; /* Number of free bytes on the stack */
  384. INT32U OSUsed; /* Number of bytes used on the stack */
  385. } OS_STK_DATA;
  386. #endif
  387. /*$PAGE*/
  388. /*
  389. *********************************************************************************************************
  390. * TASK CONTROL BLOCK
  391. *********************************************************************************************************
  392. */
  393. typedef struct os_tcb {
  394. OS_STK *OSTCBStkPtr; /* Pointer to current top of stack */
  395. #if OS_TASK_CREATE_EXT_EN > 0
  396. void *OSTCBExtPtr; /* Pointer to user definable data for TCB extension */
  397. OS_STK *OSTCBStkBottom; /* Pointer to bottom of stack */
  398. INT32U OSTCBStkSize; /* Size of task stack (in number of stack elements) */
  399. INT16U OSTCBOpt; /* Task options as passed by OSTaskCreateExt() */
  400. INT16U OSTCBId; /* Task ID (0..65535) */
  401. #endif
  402. struct os_tcb *OSTCBNext; /* Pointer to next TCB in the TCB list */
  403. struct os_tcb *OSTCBPrev; /* Pointer to previous TCB in the TCB list */
  404. #if OS_EVENT_EN
  405. OS_EVENT *OSTCBEventPtr; /* Pointer to event control block */
  406. #endif
  407. #if ((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0)
  408. void *OSTCBMsg; /* Message received from OSMboxPost() or OSQPost() */
  409. #endif
  410. #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
  411. #if OS_TASK_DEL_EN > 0
  412. OS_FLAG_NODE *OSTCBFlagNode; /* Pointer to event flag node */
  413. #endif
  414. OS_FLAGS OSTCBFlagsRdy; /* Event flags that made task ready to run */
  415. #endif
  416. INT16U OSTCBDly; /* Nbr ticks to delay task or, timeout waiting for event */
  417. INT8U OSTCBStat; /* Task status */
  418. BOOLEAN OSTCBPendTO; /* Flag indicating PEND timed out (TRUE == timed out) */
  419. INT8U OSTCBPrio; /* Task priority (0 == highest) */
  420. INT8U OSTCBX; /* Bit position in group corresponding to task priority */
  421. INT8U OSTCBY; /* Index into ready table corresponding to task priority */
  422. #if OS_LOWEST_PRIO <= 63
  423. INT8U OSTCBBitX; /* Bit mask to access bit position in ready table */
  424. INT8U OSTCBBitY; /* Bit mask to access bit position in ready group */
  425. #else
  426. INT16U OSTCBBitX; /* Bit mask to access bit position in ready table */
  427. INT16U OSTCBBitY; /* Bit mask to access bit position in ready group */
  428. #endif
  429. #if OS_TASK_DEL_EN > 0
  430. INT8U OSTCBDelReq; /* Indicates whether a task needs to delete itself */
  431. #endif
  432. #if OS_TASK_PROFILE_EN > 0
  433. INT32U OSTCBCtxSwCtr; /* Number of time the task was switched in */
  434. INT32U OSTCBCyclesTot; /* Total number of clock cycles the task has been running */
  435. INT32U OSTCBCyclesStart; /* Snapshot of cycle counter at start of task resumption */
  436. OS_STK *OSTCBStkBase; /* Pointer to the beginning of the task stack */
  437. INT32U OSTCBStkUsed; /* Number of bytes used from the stack */
  438. #endif
  439. #if OS_TASK_NAME_SIZE > 1
  440. INT8U OSTCBTaskName[OS_TASK_NAME_SIZE];
  441. #endif
  442. } OS_TCB;
  443. /*$PAGE*/
  444. /*
  445. *********************************************************************************************************
  446. * GLOBAL VARIABLES
  447. *********************************************************************************************************
  448. */
  449. OS_EXT INT32U OSCtxSwCtr; /* Counter of number of context switches */
  450. #if OS_EVENT_EN && (OS_MAX_EVENTS > 0)
  451. OS_EXT OS_EVENT *OSEventFreeList; /* Pointer to list of free EVENT control blocks */
  452. OS_EXT OS_EVENT OSEventTbl[OS_MAX_EVENTS];/* Table of EVENT control blocks */
  453. #endif
  454. #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
  455. OS_EXT OS_FLAG_GRP OSFlagTbl[OS_MAX_FLAGS]; /* Table containing event flag groups */
  456. OS_EXT OS_FLAG_GRP *OSFlagFreeList; /* Pointer to free list of event flag groups */
  457. #endif
  458. #if OS_TASK_STAT_EN > 0
  459. OS_EXT INT8S OSCPUUsage; /* Percentage of CPU used */
  460. OS_EXT INT32U OSIdleCtrMax; /* Max. value that idle ctr can take in 1 sec. */
  461. OS_EXT INT32U OSIdleCtrRun; /* Val. reached by idle ctr at run time in 1 sec. */
  462. OS_EXT BOOLEAN OSStatRdy; /* Flag indicating that the statistic task is rdy */
  463. OS_EXT OS_STK OSTaskStatStk[OS_TASK_STAT_STK_SIZE]; /* Statistics task stack */
  464. #endif
  465. OS_EXT INT8U OSIntNesting; /* Interrupt nesting level */
  466. OS_EXT INT8U OSLockNesting; /* Multitasking lock nesting level */
  467. OS_EXT INT8U OSPrioCur; /* Priority of current task */
  468. OS_EXT INT8U OSPrioHighRdy; /* Priority of highest priority task */
  469. #if OS_LOWEST_PRIO <= 63
  470. OS_EXT INT8U OSRdyGrp; /* Ready list group */
  471. OS_EXT INT8U OSRdyTbl[OS_RDY_TBL_SIZE]; /* Table of tasks which are ready to run */
  472. #else
  473. OS_EXT INT16U OSRdyGrp; /* Ready list group */
  474. OS_EXT INT16U OSRdyTbl[OS_RDY_TBL_SIZE]; /* Table of tasks which are ready to run */
  475. #endif
  476. OS_EXT BOOLEAN OSRunning; /* Flag indicating that kernel is running */
  477. OS_EXT INT8U OSTaskCtr; /* Number of tasks created */
  478. OS_EXT volatile INT32U OSIdleCtr; /* Idle counter */
  479. OS_EXT OS_STK OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE]; /* Idle task stack */
  480. OS_EXT OS_TCB *OSTCBCur; /* Pointer to currently running TCB */
  481. OS_EXT OS_TCB *OSTCBFreeList; /* Pointer to list of free TCBs */
  482. OS_EXT OS_TCB *OSTCBHighRdy; /* Pointer to highest priority TCB R-to-R */
  483. OS_EXT OS_TCB *OSTCBList; /* Pointer to doubly linked list of TCBs */
  484. OS_EXT OS_TCB *OSTCBPrioTbl[OS_LOWEST_PRIO + 1];/* Table of pointers to created TCBs */
  485. OS_EXT OS_TCB OSTCBTbl[OS_MAX_TASKS + OS_N_SYS_TASKS]; /* Table of TCBs */
  486. #if OS_TICK_STEP_EN > 0
  487. OS_EXT INT8U OSTickStepState; /* Indicates the state of the tick step feature */
  488. #endif
  489. #if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
  490. OS_EXT OS_MEM *OSMemFreeList; /* Pointer to free list of memory partitions */
  491. OS_EXT OS_MEM OSMemTbl[OS_MAX_MEM_PART];/* Storage for memory partition manager */
  492. #endif
  493. #if (OS_Q_EN > 0) && (OS_MAX_QS > 0)
  494. OS_EXT OS_Q *OSQFreeList; /* Pointer to list of free QUEUE control blocks */
  495. OS_EXT OS_Q OSQTbl[OS_MAX_QS]; /* Table of QUEUE control blocks */
  496. #endif
  497. #if OS_TIME_GET_SET_EN > 0
  498. OS_EXT volatile INT32U OSTime; /* Current value of system time (in ticks) */
  499. #endif
  500. extern INT8U const OSUnMapTbl[256]; /* Priority->Index lookup table */
  501. /*$PAGE*/
  502. /*
  503. *********************************************************************************************************
  504. * FUNCTION PROTOTYPES
  505. * (Target Independent Functions)
  506. *********************************************************************************************************
  507. */
  508. /*
  509. *********************************************************************************************************
  510. * MISCELLANEOUS
  511. *********************************************************************************************************
  512. */
  513. #if OS_EVENT_EN && (OS_EVENT_NAME_SIZE > 1)
  514. INT8U OSEventNameGet(OS_EVENT *pevent, INT8U *pname, INT8U *err);
  515. void OSEventNameSet(OS_EVENT *pevent, INT8U *pname, INT8U *err);
  516. #endif
  517. /*
  518. *********************************************************************************************************
  519. * EVENT FLAGS MANAGEMENT
  520. *********************************************************************************************************
  521. */
  522. #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
  523. #if OS_FLAG_ACCEPT_EN > 0
  524. OS_FLAGS OSFlagAccept(OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U wait_type, INT8U *err);
  525. #endif
  526. OS_FLAG_GRP *OSFlagCreate(OS_FLAGS flags, INT8U *err);
  527. #if OS_FLAG_DEL_EN > 0
  528. OS_FLAG_GRP *OSFlagDel(OS_FLAG_GRP *pgrp, INT8U opt, INT8U *err);
  529. #endif
  530. #if (OS_FLAG_EN > 0) && (OS_FLAG_NAME_SIZE > 1)
  531. INT8U OSFlagNameGet(OS_FLAG_GRP *pgrp, INT8U *pname, INT8U *err);
  532. void OSFlagNameSet(OS_FLAG_GRP *pgrp, INT8U *pname, INT8U *err);
  533. #endif
  534. OS_FLAGS OSFlagPend(OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U wait_type, INT16U timeout, INT8U *err);
  535. OS_FLAGS OSFlagPendGetFlagsRdy(void);
  536. OS_FLAGS OSFlagPost(OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U opt, INT8U *err);
  537. #if OS_FLAG_QUERY_EN > 0
  538. OS_FLAGS OSFlagQuery(OS_FLAG_GRP *pgrp, INT8U *err);
  539. #endif
  540. #endif
  541. /*
  542. *********************************************************************************************************
  543. * MESSAGE MAILBOX MANAGEMENT
  544. *********************************************************************************************************
  545. */
  546. #if OS_MBOX_EN > 0
  547. #if OS_MBOX_ACCEPT_EN > 0
  548. void *OSMboxAccept(OS_EVENT *pevent);
  549. #endif
  550. OS_EVENT *OSMboxCreate(void *msg);
  551. #if OS_MBOX_DEL_EN > 0
  552. OS_EVENT *OSMboxDel(OS_EVENT *pevent, INT8U opt, INT8U *err);
  553. #endif
  554. void *OSMboxPend(OS_EVENT *pevent, INT16U timeout, INT8U *err);
  555. #if OS_MBOX_POST_EN > 0
  556. INT8U OSMboxPost(OS_EVENT *pevent, void *msg);
  557. #endif
  558. #if OS_MBOX_POST_OPT_EN > 0
  559. INT8U OSMboxPostOpt(OS_EVENT *pevent, void *msg, INT8U opt);
  560. #endif
  561. #if OS_MBOX_QUERY_EN > 0
  562. INT8U OSMboxQuery(OS_EVENT *pevent, OS_MBOX_DATA *p_mbox_data);
  563. #endif
  564. #endif
  565. /*
  566. *********************************************************************************************************
  567. * MEMORY MANAGEMENT
  568. *********************************************************************************************************
  569. */
  570. #if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
  571. OS_MEM *OSMemCreate(void *addr, INT32U nblks, INT32U blksize, INT8U *err);
  572. void *OSMemGet(OS_MEM *pmem, INT8U *err);
  573. #if OS_MEM_NAME_SIZE > 1
  574. INT8U OSMemNameGet(OS_MEM *pmem, INT8U *pname, INT8U *err);
  575. void OSMemNameSet(OS_MEM *pmem, INT8U *pname, INT8U *err);
  576. #endif
  577. INT8U OSMemPut(OS_MEM *pmem, void *pblk);
  578. #if OS_MEM_QUERY_EN > 0
  579. INT8U OSMemQuery(OS_MEM *pmem, OS_MEM_DATA *p_mem_data);
  580. #endif
  581. #endif
  582. /*
  583. *********************************************************************************************************
  584. * MUTUAL EXCLUSION SEMAPHORE MANAGEMENT
  585. *********************************************************************************************************
  586. */
  587. #if OS_MUTEX_EN > 0
  588. #if OS_MUTEX_ACCEPT_EN > 0
  589. INT8U OSMutexAccept(OS_EVENT *pevent, INT8U *err);
  590. #endif
  591. OS_EVENT *OSMutexCreate(INT8U prio, INT8U *err);
  592. #if OS_MUTEX_DEL_EN > 0
  593. OS_EVENT *OSMutexDel(OS_EVENT *pevent, INT8U opt, INT8U *err);
  594. #endif
  595. void OSMutexPend(OS_EVENT *pevent, INT16U timeout, INT8U *err);
  596. INT8U OSMutexPost(OS_EVENT *pevent);
  597. #if OS_MUTEX_QUERY_EN > 0
  598. INT8U OSMutexQuery(OS_EVENT *pevent, OS_MUTEX_DATA *p_mutex_data);
  599. #endif
  600. #endif
  601. /*$PAGE*/
  602. /*
  603. *********************************************************************************************************
  604. * MESSAGE QUEUE MANAGEMENT
  605. *********************************************************************************************************
  606. */
  607. #if (OS_Q_EN > 0) && (OS_MAX_QS > 0)
  608. #if OS_Q_ACCEPT_EN > 0
  609. void *OSQAccept(OS_EVENT *pevent, INT8U *err);
  610. #endif
  611. OS_EVENT *OSQCreate(void **start, INT16U size);
  612. #if OS_Q_DEL_EN > 0
  613. OS_EVENT *OSQDel(OS_EVENT *pevent, INT8U opt, INT8U *err);
  614. #endif
  615. #if OS_Q_FLUSH_EN > 0
  616. INT8U OSQFlush(OS_EVENT *pevent);
  617. #endif
  618. void *OSQPend(OS_EVENT *pevent, INT16U timeout, INT8U *err);
  619. #if OS_Q_POST_EN > 0
  620. INT8U OSQPost(OS_EVENT *pevent, void *msg);
  621. #endif
  622. #if OS_Q_POST_FRONT_EN > 0
  623. INT8U OSQPostFront(OS_EVENT *pevent, void *msg);
  624. #endif
  625. #if OS_Q_POST_OPT_EN > 0
  626. INT8U OSQPostOpt(OS_EVENT *pevent, void *msg, INT8U opt);
  627. #endif
  628. #if OS_Q_QUERY_EN > 0
  629. INT8U OSQQuery(OS_EVENT *pevent, OS_Q_DATA *p_q_data);
  630. #endif
  631. #endif
  632. /*$PAGE*/
  633. /*
  634. *********************************************************************************************************
  635. * SEMAPHORE MANAGEMENT
  636. *********************************************************************************************************
  637. */
  638. #if OS_SEM_EN > 0
  639. #if OS_SEM_ACCEPT_EN > 0
  640. INT16U OSSemAccept(OS_EVENT *pevent);
  641. #endif
  642. OS_EVENT *OSSemCreate(INT16U cnt);
  643. #if OS_SEM_DEL_EN > 0
  644. OS_EVENT *OSSemDel(OS_EVENT *pevent, INT8U opt, INT8U *err);
  645. #endif
  646. void OSSemPend(OS_EVENT *pevent, INT16U timeout, INT8U *err);
  647. INT8U OSSemPost(OS_EVENT *pevent);
  648. #if OS_SEM_QUERY_EN > 0
  649. INT8U OSSemQuery(OS_EVENT *pevent, OS_SEM_DATA *p_sem_data);
  650. #endif
  651. #if OS_SEM_SET_EN > 0
  652. void OSSemSet(OS_EVENT *pevent, INT16U cnt, INT8U *err);
  653. #endif
  654. #endif
  655. /*$PAGE*/
  656. /*
  657. *********************************************************************************************************
  658. * TASK MANAGEMENT
  659. *********************************************************************************************************
  660. */
  661. #if OS_TASK_CHANGE_PRIO_EN > 0
  662. INT8U OSTaskChangePrio(INT8U oldprio, INT8U newprio);
  663. #endif
  664. #if OS_TASK_CREATE_EN > 0
  665. INT8U OSTaskCreate(void (*task)(void *p_arg), void *p_arg, OS_STK *ptos, INT8U prio);
  666. #endif
  667. #if OS_TASK_CREATE_EXT_EN > 0
  668. INT8U OSTaskCreateExt(void (*task)(void *p_arg),
  669. void *p_arg,
  670. OS_STK *ptos,
  671. INT8U prio,
  672. INT16U id,
  673. OS_STK *pbos,
  674. INT32U stk_size,
  675. void *pext,
  676. INT16U opt);
  677. #endif
  678. #if OS_TASK_DEL_EN > 0
  679. INT8U OSTaskDel(INT8U prio);
  680. INT8U OSTaskDelReq(INT8U prio);
  681. #endif
  682. #if OS_TASK_NAME_SIZE > 1
  683. INT8U OSTaskNameGet(INT8U prio, INT8U *pname, INT8U *err);
  684. void OSTaskNameSet(INT8U prio, INT8U *pname, INT8U *err);
  685. #endif
  686. #if OS_TASK_SUSPEND_EN > 0
  687. INT8U OSTaskResume(INT8U prio);
  688. INT8U OSTaskSuspend(INT8U prio);
  689. #endif
  690. #if OS_TASK_CREATE_EXT_EN > 0
  691. INT8U OSTaskStkChk(INT8U prio, OS_STK_DATA *p_stk_data);
  692. #endif
  693. #if OS_TASK_QUERY_EN > 0
  694. INT8U OSTaskQuery(INT8U prio, OS_TCB *p_task_data);
  695. #endif
  696. /*$PAGE*/
  697. /*
  698. *********************************************************************************************************
  699. * TIME MANAGEMENT
  700. *********************************************************************************************************
  701. */
  702. void OSTimeDly(INT16U ticks);
  703. #if OS_TIME_DLY_HMSM_EN > 0
  704. INT8U OSTimeDlyHMSM(INT8U hours, INT8U minutes, INT8U seconds, INT16U milli);
  705. #endif
  706. #if OS_TIME_DLY_RESUME_EN > 0
  707. INT8U OSTimeDlyResume(INT8U prio);
  708. #endif
  709. #if OS_TIME_GET_SET_EN > 0
  710. INT32U OSTimeGet(void);
  711. void OSTimeSet(INT32U ticks);
  712. #endif
  713. void OSTimeTick(void);
  714. /*
  715. *********************************************************************************************************
  716. * MISCELLANEOUS
  717. *********************************************************************************************************
  718. */
  719. void OSInit(void);
  720. void OSIntEnter(void);
  721. void OSIntExit(void);
  722. #if OS_SCHED_LOCK_EN > 0
  723. void OSSchedLock(void);
  724. void OSSchedUnlock(void);
  725. #endif
  726. void OSStart(void);
  727. void OSStatInit(void);
  728. INT16U OSVersion(void);
  729. /*$PAGE*/
  730. /*
  731. *********************************************************************************************************
  732. * INTERNAL FUNCTION PROTOTYPES
  733. * (Your application MUST NOT call these functions)
  734. *********************************************************************************************************
  735. */
  736. #if OS_TASK_DEL_EN > 0
  737. void OS_Dummy(void);
  738. #endif
  739. #if OS_EVENT_EN
  740. INT8U OS_EventTaskRdy(OS_EVENT *pevent, void *msg, INT8U msk);
  741. void OS_EventTaskWait(OS_EVENT *pevent);
  742. void OS_EventTO(OS_EVENT *pevent);
  743. void OS_EventWaitListInit(OS_EVENT *pevent);
  744. #endif
  745. #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
  746. void OS_FlagInit(void);
  747. void OS_FlagUnlink(OS_FLAG_NODE *pnode);
  748. #endif
  749. void OS_MemClr(INT8U *pdest, INT16U size);
  750. void OS_MemCopy(INT8U *pdest, INT8U *psrc, INT16U size);
  751. #if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
  752. void OS_MemInit(void);
  753. #endif
  754. #if OS_Q_EN > 0
  755. void OS_QInit(void);
  756. #endif
  757. void OS_Sched(void);
  758. #if (OS_EVENT_NAME_SIZE > 1) || (OS_FLAG_NAME_SIZE > 1) || (OS_MEM_NAME_SIZE > 1) || (OS_TASK_NAME_SIZE > 1)
  759. INT8U OS_StrCopy(INT8U *pdest, INT8U *psrc);
  760. INT8U OS_StrLen(INT8U *psrc);
  761. #endif
  762. void OS_TaskIdle(void *p_arg);
  763. #if OS_TASK_STAT_EN > 0
  764. void OS_TaskStat(void *p_arg);
  765. #endif
  766. #if OS_TASK_CREATE_EXT_EN > 0
  767. void OS_TaskStkClr(OS_STK *pbos, INT32U size, INT16U opt);
  768. #endif
  769. #if (OS_TASK_STAT_STK_CHK_EN > 0) && (OS_TASK_CREATE_EXT_EN > 0)
  770. void OS_TaskStatStkChk(void);
  771. #endif
  772. INT8U OS_TCBInit(INT8U prio, OS_STK *ptos, OS_STK *pbos, INT16U id, INT32U stk_size, void *pext, INT16U opt);
  773. /*$PAGE*/
  774. /*
  775. *********************************************************************************************************
  776. * FUNCTION PROTOTYPES
  777. * (Target Specific Functions)
  778. *********************************************************************************************************
  779. */
  780. #if OS_VERSION >= 270 && OS_DEBUG_EN > 0
  781. void OSDebugInit(void);
  782. #endif
  783. #if OS_VERSION >= 204
  784. void OSInitHookBegin(void);
  785. void OSInitHookEnd(void);
  786. #endif
  787. #ifndef OS_ISR_PROTO_EXT
  788. void OSIntCtxSw(void);
  789. void OSStartHighRdy(void);
  790. #endif
  791. void OSTaskCreateHook(OS_TCB *ptcb);
  792. void OSTaskDelHook(OS_TCB *ptcb);
  793. #if OS_VERSION >= 251
  794. void OSTaskIdleHook(void);
  795. #endif
  796. void OSTaskStatHook(void);
  797. OS_STK *OSTaskStkInit(void (*task)(void *p_arg), void *p_arg, OS_STK *ptos, INT16U opt);
  798. #if OS_TASK_SW_HOOK_EN > 0
  799. void OSTaskSwHook(void);
  800. #endif
  801. #if OS_VERSION >= 204
  802. void OSTCBInitHook(OS_TCB *ptcb);
  803. #endif
  804. #if OS_TIME_TICK_HOOK_EN > 0
  805. void OSTimeTickHook(void);
  806. #endif
  807. /*
  808. *********************************************************************************************************
  809. * FUNCTION PROTOTYPES
  810. * (Compiler Specific ISR prototypes)
  811. *********************************************************************************************************
  812. */
  813. #ifndef OS_ISR_PROTO_EXT
  814. void OSCtxSw(void);
  815. #endif
  816. /*$PAGE*/
  817. /*
  818. *********************************************************************************************************
  819. * LOOK FOR MISSING #define CONSTANTS
  820. *
  821. * This section is used to generate ERROR messages at compile time if certain #define constants are
  822. * MISSING in OS_CFG.H. This allows you to quickly determine the source of the error.
  823. *
  824. * You SHOULD NOT change this section UNLESS you would like to add more comments as to the source of the
  825. * compile time error.
  826. *********************************************************************************************************
  827. */
  828. /*
  829. *********************************************************************************************************
  830. * EVENT FLAGS
  831. *********************************************************************************************************
  832. */
  833. #ifndef OS_FLAG_EN
  834. #error "OS_CFG.H, Missing OS_FLAG_EN: Enable (1) or Disable (0) code generation for Event Flags"
  835. #else
  836. #ifndef OS_MAX_FLAGS
  837. #error "OS_CFG.H, Missing OS_MAX_FLAGS: Max. number of Event Flag Groups in your application"
  838. #else
  839. #if OS_MAX_FLAGS > 65500u
  840. #error "OS_CFG.H, OS_MAX_FLAGS must be <= 65500"
  841. #endif
  842. #endif
  843. #if OS_VERSION >= 280
  844. #ifndef OS_FLAGS_NBITS
  845. #error "OS_CFG.H, Missing OS_FLAGS_NBITS: Determine #bits used for event flags, MUST be either 8, 16 or 32"
  846. #endif
  847. #endif
  848. #ifndef OS_FLAG_WAIT_CLR_EN
  849. #error "OS_CFG.H, Missing OS_FLAG_WAIT_CLR_EN: Include code for Wait on Clear EVENT FLAGS"
  850. #endif
  851. #ifndef OS_FLAG_ACCEPT_EN
  852. #error "OS_CFG.H, Missing OS_FLAG_ACCEPT_EN: Include code for OSFlagAccept()"
  853. #endif
  854. #ifndef OS_FLAG_DEL_EN
  855. #error "OS_CFG.H, Missing OS_FLAG_DEL_EN: Include code for OSFlagDel()"
  856. #endif
  857. #ifndef OS_FLAG_NAME_SIZE
  858. #error "OS_CFG.H, Missing OS_FLAG_NAME_SIZE: Determines the size of flag group names"
  859. #endif
  860. #ifndef OS_FLAG_QUERY_EN
  861. #error "OS_CFG.H, Missing OS_FLAG_QUERY_EN: Include code for OSFlagQuery()"
  862. #endif
  863. #endif
  864. /*
  865. *********************************************************************************************************
  866. * MESSAGE MAILBOXES
  867. *********************************************************************************************************
  868. */
  869. #ifndef OS_MBOX_EN
  870. #error "OS_CFG.H, Missing OS_MBOX_EN: Enable (1) or Disable (0) code generation for MAILBOXES"
  871. #else
  872. #ifndef OS_MBOX_ACCEPT_EN
  873. #error "OS_CFG.H, Missing OS_MBOX_ACCEPT_EN: Include code for OSMboxAccept()"
  874. #endif
  875. #ifndef OS_MBOX_DEL_EN
  876. #error "OS_CFG.H, Missing OS_MBOX_DEL_EN: Include code for OSMboxDel()"
  877. #endif
  878. #ifndef OS_MBOX_POST_EN
  879. #error "OS_CFG.H, Missing OS_MBOX_POST_EN: Include code for OSMboxPost()"
  880. #endif
  881. #ifndef OS_MBOX_POST_OPT_EN
  882. #error "OS_CFG.H, Missing OS_MBOX_POST_OPT_EN: Include code for OSMboxPostOpt()"
  883. #endif
  884. #ifndef OS_MBOX_QUERY_EN
  885. #error "OS_CFG.H, Missing OS_MBOX_QUERY_EN: Include code for OSMboxQuery()"
  886. #endif
  887. #endif
  888. /*
  889. *********************************************************************************************************
  890. * MEMORY MANAGEMENT
  891. *********************************************************************************************************
  892. */
  893. #ifndef OS_MEM_EN
  894. #error "OS_CFG.H, Missing OS_MEM_EN: Enable (1) or Disable (0) code generation for MEMORY MANAGER"
  895. #else
  896. #ifndef OS_MAX_MEM_PART
  897. #error "OS_CFG.H, Missing OS_MAX_MEM_PART: Max. number of memory partitions"
  898. #else
  899. #if OS_MAX_MEM_PART > 65500u
  900. #error "OS_CFG.H, OS_MAX_MEM_PART must be <= 65500"
  901. #endif
  902. #endif
  903. #ifndef OS_MEM_NAME_SIZE
  904. #error "OS_CFG.H, Missing OS_MEM_NAME_SIZE: Determines the size of memory partition names"
  905. #endif
  906. #ifndef OS_MEM_QUERY_EN
  907. #error "OS_CFG.H, Missing OS_MEM_QUERY_EN: Include code for OSMemQuery()"
  908. #endif
  909. #endif
  910. /*
  911. *********************************************************************************************************
  912. * MUTUAL EXCLUSION SEMAPHORES
  913. *********************************************************************************************************
  914. */
  915. #ifndef OS_MUTEX_EN
  916. #error "OS_CFG.H, Missing OS_MUTEX_EN: Enable (1) or Disable (0) code generation for MUTEX"
  917. #else
  918. #ifndef OS_MUTEX_ACCEPT_EN
  919. #error "OS_CFG.H, Missing OS_MUTEX_ACCEPT_EN: Include code for OSMutexAccept()"
  920. #endif
  921. #ifndef OS_MUTEX_DEL_EN
  922. #error "OS_CFG.H, Missing OS_MUTEX_DEL_EN: Include code for OSMutexDel()"
  923. #endif
  924. #ifndef OS_MUTEX_QUERY_EN
  925. #error "OS_CFG.H, Missing OS_MUTEX_QUERY_EN: Include code for OSMutexQuery()"
  926. #endif
  927. #endif
  928. /*
  929. *********************************************************************************************************
  930. * MESSAGE QUEUES
  931. *********************************************************************************************************
  932. */
  933. #ifndef OS_Q_EN
  934. #error "OS_CFG.H, Missing OS_Q_EN: Enable (1) or Disable (0) code generation for QUEUES"
  935. #else
  936. #ifndef OS_MAX_QS
  937. #error "OS_CFG.H, Missing OS_MAX_QS: Max. number of queue control blocks"
  938. #else
  939. #if OS_MAX_QS > 65500u
  940. #error "OS_CFG.H, OS_MAX_QS must be <= 65500"
  941. #endif
  942. #endif
  943. #ifndef OS_Q_ACCEPT_EN
  944. #error "OS_CFG.H, Missing OS_Q_ACCEPT_EN: Include code for OSQAccept()"
  945. #endif
  946. #ifndef OS_Q_DEL_EN
  947. #error "OS_CFG.H, Missing OS_Q_DEL_EN: Include code for OSQDel()"
  948. #endif
  949. #ifndef OS_Q_FLUSH_EN
  950. #error "OS_CFG.H, Missing OS_Q_FLUSH_EN: Include code for OSQFlush()"
  951. #endif
  952. #ifndef OS_Q_POST_EN
  953. #error "OS_CFG.H, Missing OS_Q_POST_EN: Include code for OSQPost()"
  954. #endif
  955. #ifndef OS_Q_POST_FRONT_EN
  956. #error "OS_CFG.H, Missing OS_Q_POST_FRONT_EN: Include code for OSQPostFront()"
  957. #endif
  958. #ifndef OS_Q_POST_OPT_EN
  959. #error "OS_CFG.H, Missing OS_Q_POST_OPT_EN: Include code for OSQPostOpt()"
  960. #endif
  961. #ifndef OS_Q_QUERY_EN
  962. #error "OS_CFG.H, Missing OS_Q_QUERY_EN: Include code for OSQQuery()"
  963. #endif
  964. #endif
  965. /*
  966. *********************************************************************************************************
  967. * SEMAPHORES
  968. *********************************************************************************************************
  969. */
  970. #ifndef OS_SEM_EN
  971. #error "OS_CFG.H, Missing OS_SEM_EN: Enable (1) or Disable (0) code generation for SEMAPHORES"
  972. #else
  973. #ifndef OS_SEM_ACCEPT_EN
  974. #error "OS_CFG.H, Missing OS_SEM_ACCEPT_EN: Include code for OSSemAccept()"
  975. #endif
  976. #ifndef OS_SEM_DEL_EN
  977. #error "OS_CFG.H, Missing OS_SEM_DEL_EN: Include code for OSSemDel()"
  978. #endif
  979. #ifndef OS_SEM_QUERY_EN
  980. #error "OS_CFG.H, Missing OS_SEM_QUERY_EN: Include code for OSSemQuery()"
  981. #endif
  982. #ifndef OS_SEM_SET_EN
  983. #error "OS_CFG.H, Missing OS_SEM_SET_EN: Include code for OSSemSet()"
  984. #endif
  985. #endif
  986. /*
  987. *********************************************************************************************************
  988. * TASK MANAGEMENT
  989. *********************************************************************************************************
  990. */
  991. #ifndef OS_MAX_TASKS
  992. #error "OS_CFG.H, Missing OS_MAX_TASKS: Max. number of tasks in your application"
  993. #else
  994. #if OS_MAX_TASKS < 2
  995. #error "OS_CFG.H, OS_MAX_TASKS must be >= 2"
  996. #endif
  997. #if OS_MAX_TASKS > (OS_LOWEST_PRIO - OS_N_SYS_TASKS + 1)
  998. #error "OS_CFG.H, OS_MAX_TASKS must be <= OS_LOWEST_PRIO - OS_N_SYS_TASKS + 1"
  999. #endif
  1000. #endif
  1001. #if OS_VERSION < 280
  1002. #if OS_LOWEST_PRIO > 63
  1003. #error "OS_CFG.H, OS_LOWEST_PRIO must be <= 63 in V2.7x or lower"
  1004. #endif
  1005. #endif
  1006. #if OS_VERSION >= 280
  1007. #if OS_LOWEST_PRIO > 254
  1008. #error "OS_CFG.H, OS_LOWEST_PRIO must be <= 254 in V2.8x and higher"
  1009. #endif
  1010. #endif
  1011. #ifndef OS_TASK_IDLE_STK_SIZE
  1012. #error "OS_CFG.H, Missing OS_TASK_IDLE_STK_SIZE: Idle task stack size"
  1013. #endif
  1014. #ifndef OS_TASK_STAT_EN
  1015. #error "OS_CFG.H, Missing OS_TASK_STAT_EN: Enable (1) or Disable(0) the statistics task"
  1016. #endif
  1017. #ifndef OS_TASK_STAT_STK_SIZE
  1018. #error "OS_CFG.H, Missing OS_TASK_STAT_STK_SIZE: Statistics task stack size"
  1019. #endif
  1020. #ifndef OS_TASK_STAT_STK_CHK_EN
  1021. #error "OS_CFG.H, Missing OS_TASK_STAT_STK_CHK_EN: Check task stacks from statistics task"
  1022. #endif
  1023. #ifndef OS_TASK_CHANGE_PRIO_EN
  1024. #error "OS_CFG.H, Missing OS_TASK_CHANGE_PRIO_EN: Include code for OSTaskChangePrio()"
  1025. #endif
  1026. #ifndef OS_TASK_CREATE_EN
  1027. #error "OS_CFG.H, Missing OS_TASK_CREATE_EN: Include code for OSTaskCreate()"
  1028. #endif
  1029. #ifndef OS_TASK_CREATE_EXT_EN
  1030. #error "OS_CFG.H, Missing OS_TASK_CREATE_EXT_EN: Include code for OSTaskCreateExt()"
  1031. #endif
  1032. #ifndef OS_TASK_DEL_EN
  1033. #error "OS_CFG.H, Missing OS_TASK_DEL_EN: Include code for OSTaskDel()"
  1034. #endif
  1035. #ifndef OS_TASK_NAME_SIZE
  1036. #error "OS_CFG.H, Missing OS_TASK_NAME_SIZE: Determine the size of task names"
  1037. #endif
  1038. #ifndef OS_TASK_SUSPEND_EN
  1039. #error "OS_CFG.H, Missing OS_TASK_SUSPEND_EN: Include code for OSTaskSuspend() and OSTaskResume()"
  1040. #endif
  1041. #ifndef OS_TASK_QUERY_EN
  1042. #error "OS_CFG.H, Missing OS_TASK_QUERY_EN: Include code for OSTaskQuery()"
  1043. #endif
  1044. /*
  1045. *********************************************************************************************************
  1046. * TIME MANAGEMENT
  1047. *********************************************************************************************************
  1048. */
  1049. #ifndef OS_TICKS_PER_SEC
  1050. #error "OS_CFG.H, Missing OS_TICKS_PER_SEC: Sets the number of ticks in one second"
  1051. #endif
  1052. #ifndef OS_TIME_DLY_HMSM_EN
  1053. #error "OS_CFG.H, Missing OS_TIME_DLY_HMSM_EN: Include code for OSTimeDlyHMSM()"
  1054. #endif
  1055. #ifndef OS_TIME_DLY_RESUME_EN
  1056. #error "OS_CFG.H, Missing OS_TIME_DLY_RESUME_EN: Include code for OSTimeDlyResume()"
  1057. #endif
  1058. #ifndef OS_TIME_GET_SET_EN
  1059. #error "OS_CFG.H, Missing OS_TIME_GET_SET_EN: Include code for OSTimeGet() and OSTimeSet()"
  1060. #endif
  1061. /*
  1062. *********************************************************************************************************
  1063. * MISCELLANEOUS
  1064. *********************************************************************************************************
  1065. */
  1066. #ifndef OS_ARG_CHK_EN
  1067. #error "OS_CFG.H, Missing OS_ARG_CHK_EN: Enable (1) or Disable (0) argument checking"
  1068. #endif
  1069. #ifndef OS_CPU_HOOKS_EN
  1070. #error "OS_CFG.H, Missing OS_CPU_HOOKS_EN: uC/OS-II hooks are found in the processor port files when 1"
  1071. #endif
  1072. #ifndef OS_DEBUG_EN
  1073. #error "OS_CFG.H, Missing OS_DEBUG_EN: Allows you to include variables for debugging or not"
  1074. #endif
  1075. #ifndef OS_LOWEST_PRIO
  1076. #error "OS_CFG.H, Missing OS_LOWEST_PRIO: Defines the lowest priority that can be assigned"
  1077. #endif
  1078. #ifndef OS_MAX_EVENTS
  1079. #error "OS_CFG.H, Missing OS_MAX_EVENTS: Max. number of event control blocks in your application"
  1080. #else
  1081. #if OS_MAX_EVENTS > 65500u
  1082. #error "OS_CFG.H, OS_MAX_EVENTS must be <= 65500"
  1083. #endif
  1084. #endif
  1085. #ifndef OS_SCHED_LOCK_EN
  1086. #error "OS_CFG.H, Missing OS_SCHED_LOCK_EN: Include code for OSSchedLock() and OSSchedUnlock()"
  1087. #endif
  1088. #ifndef OS_TASK_PROFILE_EN
  1089. #error "OS_CFG.H, Missing OS_TASK_PROFILE_EN: Include data structure for run-time task profiling"
  1090. #endif
  1091. #ifndef OS_TASK_SW_HOOK_EN
  1092. #error "OS_CFG.H, Missing OS_TASK_SW_HOOK_EN: Allows you to include the code for OSTaskSwHook() or not"
  1093. #endif
  1094. #ifndef OS_TICK_STEP_EN
  1095. #error "OS_CFG.H, Missing OS_TICK_STEP_EN: Allows to 'step' one tick at a time with uC/OS-View"
  1096. #endif
  1097. #ifndef OS_TIME_TICK_HOOK_EN
  1098. #error "OS_CFG.H, Missing OS_TIME_TICK_HOOK_EN: Allows you to include the code for OSTimeTickHook() or not"
  1099. #endif
  1100. #ifndef OS_VIEW_MODULE
  1101. #error "OS_CFG.H, Missing OS_VIEW_MODULE: (1) means that uC/OS-View is present, (0) means it's absent"
  1102. #endif
  1103. #ifdef __cplusplus
  1104. }
  1105. #endif
  1106. #endif