⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 picoos.h

📁 picoos源码。The RTOS and the TCP/IP stack will be built automatically.
💻 H
📖 第 1 页 / 共 5 页
字号:
#ifndef POSCFG_LOCK_FLAGSTYPE
#error  POSCFG_LOCK_FLAGSTYPE not defined
#endif
#endif
#ifndef POS_SCHED_LOCK
#error  POS_SCHED_LOCK not defined
#endif
#ifndef POS_SCHED_UNLOCK
#error  POS_SCHED_UNLOCK not defined
#endif
#ifndef HZ
#error  HZ not defined
#endif
#ifndef POSCFG_TASKSTACKTYPE
#error  POSCFG_TASKSTACKTYPE not defined
#endif
#ifndef POS_USERTASKDATA
#error  POS_USERTASKDATA not defined
#endif
#ifndef POSCFG_FEATURE_YIELD
#error  POSCFG_FEATURE_YIELD not defined
#endif
#ifndef POSCFG_FEATURE_SLEEP
#error  POSCFG_FEATURE_SLEEP not defined
#endif
#ifndef POSCFG_FEATURE_EXIT
#error  POSCFG_FEATURE_EXIT not defined
#endif
#ifndef POSCFG_FEATURE_GETPRIORITY 
#error  POSCFG_FEATURE_GETPRIORITY  not defined
#endif
#ifndef POSCFG_FEATURE_SETPRIORITY
#error  POSCFG_FEATURE_SETPRIORITY not defined
#endif
#ifndef POSCFG_FEATURE_SEMAPHORES
#error  POSCFG_FEATURE_SEMAPHORES not defined
#endif
#ifndef POSCFG_FEATURE_SEMADESTROY
#error  POSCFG_FEATURE_SEMADESTROY not defined
#endif
#ifndef POSCFG_FEATURE_SEMAWAIT
#error  POSCFG_FEATURE_SEMAWAIT not defined
#endif
#ifndef POSCFG_FEATURE_MUTEXES
#error  POSCFG_FEATURE_MUTEXES not defined
#endif
#ifndef POSCFG_FEATURE_MUTEXDESTROY
#error  POSCFG_FEATURE_MUTEXDESTROY not defined
#endif
#ifndef POSCFG_FEATURE_MUTEXTRYLOCK
#error  POSCFG_FEATURE_MUTEXTRYLOCK not defined
#endif
#ifndef POSCFG_FEATURE_GETTASK
#error  POSCFG_FEATURE_GETTASK not defined
#endif
#ifndef POSCFG_FEATURE_TASKUNUSED
#error  POSCFG_FEATURE_TASKUNUSED not defined
#endif
#ifndef POSCFG_FEATURE_MSGBOXES
#error  POSCFG_FEATURE_MSGBOXES not defined
#endif
#ifndef POSCFG_FEATURE_MSGWAIT
#error  POSCFG_FEATURE_MSGWAIT not defined
#endif
#ifndef POSCFG_FEATURE_INHIBITSCHED
#error  POSCFG_FEATURE_INHIBITSCHED not defined
#endif
#ifndef POSCFG_FEATURE_JIFFIES
#error  POSCFG_FEATURE_JIFFIES not defined
#endif
#ifndef POSCFG_FEATURE_TIMER
#error  POSCFG_FEATURE_TIMER not defined
#endif
#ifndef POSCFG_FEATURE_TIMERDESTROY
#error  POSCFG_FEATURE_TIMERDESTROY not defined
#endif
#ifndef POSCFG_FEATURE_TIMERFIRED
#error  POSCFG_FEATURE_TIMERFIRED not defined
#endif
#ifndef POSCFG_FEATURE_FLAGS
#error  POSCFG_FEATURE_FLAGS not defined
#endif
#ifndef POSCFG_FEATURE_FLAGDESTROY
#error  POSCFG_FEATURE_FLAGDESTROY not defined
#endif
#ifndef POSCFG_FEATURE_FLAGWAIT
#error  POSCFG_FEATURE_FLAGWAIT not defined
#endif
#ifndef POSCFG_FEATURE_SOFTINTS
#error  POSCFG_FEATURE_SOFTINTS not defined
#else
#ifndef POSCFG_FEATURE_SOFTINTDEL
#error  POSCFG_FEATURE_SOFTINTDEL not defined
#endif
#ifndef POSCFG_SOFTINTERRUPTS
#error  POSCFG_SOFTINTERRUPTS not defined
#endif
#ifndef POSCFG_SOFTINTQUEUELEN
#error  POSCFG_SOFTINTQUEUELEN not defined
#endif
#endif
#ifndef POSCFG_FEATURE_IDLETASKHOOK
#error  POSCFG_FEATURE_IDLETASKHOOK not defined
#endif
#ifndef POSCFG_FEATURE_ERRNO
#error  POSCFG_FEATURE_ERRNO not defined
#endif
#ifndef POSCFG_FEATURE_ATOMICVAR
#error  POSCFG_FEATURE_ATOMICVAR not defined
#endif
#ifndef POSCFG_FEATURE_LISTS
#error  POSCFG_FEATURE_LISTS not defined
#else
#ifndef POSCFG_FEATURE_LISTJOIN
#error  POSCFG_FEATURE_LISTJOIN not defined
#endif
#ifndef POSCFG_FEATURE_LISTLEN
#define POSCFG_FEATURE_LISTLEN  1
#endif
#endif
#ifndef POSCFG_FEATURE_DEBUGHELP
#define POSCFG_FEATURE_DEBUGHELP  0
#endif
#ifdef _DBG
#if POSCFG_FEATURE_DEBUGHELP
#define POS_DEBUGHELP
#endif
#endif

/* parameter range checking */
#if (POSCFG_DYNAMIC_MEMORY != 0) && (POSCFG_DYNAMIC_REFILL != 0)
#define SYS_POSTALLOCATE    1
#else
#define SYS_POSTALLOCATE    0
#endif
#if (MVAR_BITS != 8) && (MVAR_BITS != 16) && (MVAR_BITS != 32)
#error MVAR_BITS must be 8, 16 or 32
#endif
#if POSCFG_MAX_PRIO_LEVEL == 0
#error POSCFG_MAX_PRIO_LEVEL must not be zero
#endif
#if (POSCFG_ROUNDROBIN != 0) && (POSCFG_MAX_PRIO_LEVEL > MVAR_BITS)
#error POSCFG_MAX_PRIO_LEVEL must not exceed MVAR_BITS
#endif 
#if (POSCFG_ROUNDROBIN == 0) && (POSCFG_MAX_PRIO_LEVEL > (MVAR_BITS*MVAR_BITS))
#error POSCFG_MAX_PRIO_LEVEL must not exceed (MVAR_BITS * MVAR_BITS)
#endif 
#if (POSCFG_MAX_TASKS < 2) && (SYS_POSTALLOCATE == 0)
#error POSCFG_MAX_TASKS is less than 2
#endif
#if (POSCFG_MAX_TASKS > (POSCFG_TASKS_PER_PRIO * POSCFG_MAX_PRIO_LEVEL))
#error POSCFG_MAX_TASKS is much to big
#endif
#if (POSCFG_MAX_EVENTS < 1) && (SYS_POSTALLOCATE == 0)
#error POSCFG_MAX_EVENTS must be at least 1
#endif
#if POSCFG_TASKS_PER_PRIO > MVAR_BITS
#error POSCFG_TASKS_PER_PRIO can not exceed MVAR_BITS
#endif
#if (POSCFG_TASKS_PER_PRIO < 2) && (POSCFG_ROUNDROBIN != 0)
#error POSCFG_TASKS_PER_PRIO must be at least 2
#endif
#if (POSCFG_TASKS_PER_PRIO != 1) && (POSCFG_ROUNDROBIN == 0)
#error POSCFG_TASKS_PER_PRIO must be 1 when round robin scheduling is disabled
#endif
#if ((POSCFG_TASKS_PER_PRIO % 3) == 0) || ((POSCFG_TASKS_PER_PRIO % 5) == 0)
#error POSCFG_TASKS_PER_PRIO must be 1/2/4/8/16 or 32
#endif
#if (POSCFG_REALTIME_PRIO >= POSCFG_MAX_PRIO_LEVEL) && (POSCFG_ROUNDROBIN != 0)
#error POSCFG_REALTIME_PRIO must be less than POSCFG_MAX_PRIO_LEVEL
#endif
#if POSCFG_FEATURE_MSGBOXES != 0
#if (POSCFG_MAX_MESSAGES < 2) && (SYS_POSTALLOCATE == 0)
#error POSCFG_MAX_MESSAGES must be at least 2
#endif
#if POSCFG_MSG_BUFSIZE < 1
#error POSCFG_MSG_BUFSIZE must be at least 1
#endif
#endif
#if (POSCFG_FEATURE_TIMER != 0)
#if (POSCFG_MAX_TIMER == 0) && (SYS_POSTALLOCATE == 0)
#error POSCFG_MAX_TIMER must be at least 1
#endif
#endif
#if (POSCFG_TASKSTACKTYPE < 0) || (POSCFG_TASKSTACKTYPE > 2)
#error POSCFG_TASKSTACKTYPE must be 0, 1 or 2
#endif
#if POSCFG_ALIGNMENT == 0
#undef POSCFG_ALIGNMENT
#define POSCFG_ALIGNMENT  1
#else
#if ((POSCFG_ALIGNMENT % 3) == 0) || ((POSCFG_ALIGNMENT % 5) == 0)
#error POSCFG_ALIGNMENT must be 1/2/4/8/16/32/64/128/256 etc.
#endif
#endif
#if POSCFG_FEATURE_SOFTINTS != 0
#if POSCFG_SOFTINTERRUPTS == 0
#error POSCFG_SOFTINTERRUPTS must be greater than 0
#endif
#if POSCFG_SOFTINTQUEUELEN < 2
#error POSCFG_SOFTINTQUEUELEN must be at least 2
#endif
#endif


/* parameter reconfiguration */
#ifndef POSCFG_TASKCB_USERSPACE
#define POSCFG_TASKCB_USERSPACE     0
#endif
#if POSCFG_FEATURE_SEMAPHORES == 0
#undef POSCFG_FEATURE_SEMADESTROY
#define POSCFG_FEATURE_SEMADESTROY  0
#endif
#if POSCFG_FEATURE_FLAGS == 0
#undef POSCFG_FEATURE_FLAGDESTROY
#define POSCFG_FEATURE_FLAGDESTROY  0
#endif
#if POSCFG_FEATURE_MUTEXES == 0
#undef POSCFG_FEATURE_MUTEXDESTROY
#define POSCFG_FEATURE_MUTEXDESTROY  0
#else
#if (POSCFG_FEATURE_MUTEXDESTROY != 0) && (POSCFG_FEATURE_SEMADESTROY == 0)
#undef POSCFG_FEATURE_SEMADESTROY
#define POSCFG_FEATURE_SEMADESTROY 1
#endif
#endif
#if (POSCFG_FEATURE_MSGBOXES != 0) && (SYS_POSTALLOCATE == 0)
#define SYS_MSGBOXEVENTS  2
#else
#define SYS_MSGBOXEVENTS  0
#endif
#if (POSCFG_FEATURE_MSGBOXES != 0) && (POSCFG_FEATURE_GETTASK == 0)
#undef POSCFG_FEATURE_GETTASK
#define POSCFG_FEATURE_GETTASK 1
#endif
#if (POSCFG_FEATURE_SEMAWAIT != 0) || (POSCFG_FEATURE_MSGWAIT != 0)
#define SYS_TASKDOUBLELINK  1
#else
#define SYS_TASKDOUBLELINK  0
#endif
#define SYS_EVENTS_USED  \
      (POSCFG_FEATURE_MUTEXES | POSCFG_FEATURE_MSGBOXES | \
       POSCFG_FEATURE_FLAGS | POSCFG_FEATURE_LISTS)
#define SYS_FEATURE_EVENTS  (POSCFG_FEATURE_SEMAPHORES | SYS_EVENTS_USED)
#define SYS_FEATURE_EVENTFREE  (POSCFG_FEATURE_SEMADESTROY | \
          POSCFG_FEATURE_MUTEXDESTROY | POSCFG_FEATURE_FLAGDESTROY | \
          POSCFG_FEATURE_LISTS)
#if (POSCFG_FEATURE_MSGBOXES != 0) && (POSCFG_FEATURE_EXIT != 0)
#undef  SYS_FEATURE_EVENTFREE
#define SYS_FEATURE_EVENTFREE  1
#endif
#ifndef POSCFG_FEATURE_LARGEJIFFIES
#if MVAR_BITS < 16
#define POSCFG_FEATURE_LARGEJIFFIES  1
#else
#define POSCFG_FEATURE_LARGEJIFFIES  0
#endif
#endif
#endif /* DOX!=0 */



/*---------------------------------------------------------------------------
 *  SOME DEFINITIONS AND MACROS
 *-------------------------------------------------------------------------*/

#ifdef _POSCORE_C
#define POSEXTERN
#define POSFROMEXT  extern
#else
#define POSEXTERN   extern
#define POSFROMEXT
#endif

#if POSCFG_ROUNDROBIN == 0
#define SYS_TASKTABSIZE_X  MVAR_BITS
#define SYS_TASKTABSIZE_Y  ((POSCFG_MAX_PRIO_LEVEL+MVAR_BITS-1)/MVAR_BITS)
#else
#define SYS_TASKTABSIZE_X  POSCFG_TASKS_PER_PRIO
#define SYS_TASKTABSIZE_Y  POSCFG_MAX_PRIO_LEVEL
#endif

#define SYS_TASKSTATE (POSCFG_FEATURE_TASKUNUSED | POSCFG_FEATURE_MSGBOXES)

#if POSCFG_LOCK_USEFLAGS != 0
#define POS_LOCKFLAGS   POSCFG_LOCK_FLAGSTYPE flags
#else
#define POS_LOCKFLAGS   do { } while(0)
#endif

#define POSTASKSTATE_UNUSED      0
#define POSTASKSTATE_ZOMBIE      1
#define POSTASKSTATE_ACTIVE      2

#define INFINITE   ((UINT_t)~0)



/*---------------------------------------------------------------------------
 *  ERROR CODES
 *-------------------------------------------------------------------------*/

/** @defgroup errcodes Error Codes
 * @ingroup userapip
 * Most pico]OS functions return a signed integer value describing the
 * execution status of the function. Generally, a negative value denotes
 * an error, zero means success (no error), and a positive value may
 * be returned as result of a successful operation.
 * To check if an operation was successful, you need only to test if the
 * returned value is positiv ( status >= 0 ).  For example, if you would
 * like to test if a function failed because the system ran out of memory,
 * you may test the status against the (negativ) value @c -E_NOMEM.
 * @{
 */

/** @brief  No Error (the operation was successful) */
#define E_OK        0

/** @brief  The operation failed. */
#define E_FAIL      1

/** @brief  The System ran out of memory. */
#define E_NOMEM     2

/** @brief  The given argument is wrong or inacceptable. */
#define E_ARG       3

/** @brief  The operation is forbidden at the current operation stage. */
#define E_FORB      4

/** @brief  For query operations: End of query (no more elements) */
#define E_NOMORE    5

/** @brief  The query operation was not successfull */
#define E_NOTFOUND  6

/** @} */



/*---------------------------------------------------------------------------
 *  MACROS
 *-------------------------------------------------------------------------*/

/** Convert milliseconds into HZ timer ticks.
 * This macro is used to convert milliseconds into the timer tick
 * rate (see ::HZ define).
 * Example:  Use  ::posTaskSleep(MS(1000))  to sleep 1000 ms.
 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -