Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

1983 lignes
79 KiB

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