ucos_ii.h
上传用户:yj_qqy
上传日期:2017-01-28
资源大小:2911k
文件大小:80k
源码类别:

uCOS

开发平台:

C/C++

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