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

uCOS

开发平台:

C/C++

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