25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 

1988 satır
79 KiB

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