You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

1897 line
76 KiB

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