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

📄 tornadoapi.h

📁 嵌入式操作系统Tornador中函数库的参考
💻 H
字号:
#ifndef _VX_API_
#define _VX_API_

#ifdef WIN32

#include <windows.h>
#include <conio.h>

typedef int (*FUNCPTR)(...) ;
typedef int STATUS ;

#define FOREVER for(;;)
#define KEEP_PROCESS_ALIVE while ( getch()!=27 )

#define OK 0
#ifdef ERROR
	#undef ERROR
#endif
#define ERROR -1

extern STATUS taskDelay
    (
    int ticks /* number of ticks to delay task */
    ) ;

extern STATUS taskDelete
    (
    int tid /* task ID of task to delete */
    ) ;

extern STATUS taskSuspend
    (
    int tid /* task ID of task to suspend */
    ) ;

extern STATUS taskResume
    (
    int tid /* task ID of task to resume */
    ) ;

extern int taskIdSelf() ;

extern int taskSpawn
    (
    char *  name,      /* name of new task (stored at pStackBase) */
    int     priority,  /* priority of new task */
    int     options,   /* task option word */
    int     stackSize, /* size (bytes) of stack needed plus name */
    FUNCPTR entryPt,   /* entry point of new task */
    int     arg1,      /* 1st of 10 req'd task args to pass to func */
    int     arg2,
    int     arg3,
    int     arg4,
    int     arg5,
    int     arg6,
    int     arg7,
    int     arg8,
    int     arg9,
    int     arg10
    ) ;

typedef unsigned int UINT ;
#define NO_WAIT (0)
#define WAIT_FOREVER (-1)
#define MSG_PRI_NORMAL (0) 
#define MSG_PRI_URGENT (1) 
#define MSG_Q_FIFO (0x00)
#define MSG_Q_PRIORITY (0x01) 
#define MAX_QUEUES (1024)

typedef struct _Q_INFO
{
	int maxmsgs ;
	unsigned int maxmsglength ;
	int options ;
	int readpos ;
	int writepos ;
	char * p ;

} Q_INFO, * LPQ_INFO, * MSG_Q_ID ;

extern MSG_Q_ID msgQCreate
    (
    int maxMsgs,      /* max messages that can be queued */
    int maxMsgLength, /* max bytes in a message */
    int options       /* message queue options */
    ) ;

extern STATUS msgQDelete
    (
    MSG_Q_ID msgQId /* message queue to delete */
    ) ;
	
extern STATUS msgQSend
    (
    MSG_Q_ID msgQId,  /* message queue on which to send */
    char *   buffer,  /* message to send */
    UINT     nBytes,  /* length of message */
    int      timeout, /* ticks to wait */
    int      priority /* MSG_PRI_NORMAL or MSG_PRI_URGENT */
    ) ;

extern int msgQReceive
    (
    MSG_Q_ID msgQId,    /* message queue from which to receive */
    char *   buffer,    /* buffer to receive message */
    UINT     maxNBytes, /* length of buffer */
    int      timeout    /* ticks to wait */
    ) ;

extern int msgQNumMsgs
    (
    MSG_Q_ID msgQId /* message queue to examine */
    ) ;

struct _ti
{
	bool used ;
	int life ;
	unsigned int starttime ;
	int interval ;
	void (*funcptr)(int) ;
	int parameter ;
} ;

#define MAX_DOGS (512)
typedef struct _ti * WDOG_ID ;

extern WDOG_ID wdCreate() ;

extern STATUS wdStart
    (
    WDOG_ID wdId,     /* watchdog ID */
    int     delay,    /* delay count, in ticks */
    FUNCPTR pRoutine, /* routine to call on time-out */
    int     parameter /* parameter with which to call routine */
    ) ;

extern STATUS wdDelete
    (
    WDOG_ID wdId /* ID of watchdog to delete */
    ) ;

extern STATUS wdCancel
    (
    WDOG_ID wdId /* ID of watchdog to cancel */
    ) ;

typedef struct _sem_info
{
	bool used ;
	bool taken ;
	int options ; /* Not implement */

} sem_info, * SEM_ID ;

enum SEM_B_STATE { SEM_FULL=1,SEM_EMPTY=0 } ;
#define SEM_Q_PRIORITY (0x1)
#define SEM_Q_FIFO (0x0)
#define MAX_SEMS (1024)

extern SEM_ID semBCreate
    (
    int         options,     /* semaphore options */
    SEM_B_STATE initialState /* initial semaphore state */
    ) ;

extern STATUS semTake
    (
    SEM_ID semId,  /* semaphore ID to take */
    int    timeout /* timeout in ticks */
    ) ;

extern STATUS semGive
    (
    SEM_ID semId /* semaphore ID to give */
    ) ;

extern STATUS semDelete
    (
    SEM_ID semId /* semaphore ID to delete */
    ) ;

#else // undef WIN32

	#define KEEP_PROCESS_ALIVE

	#include <taskLib.h>
	#include <wdLib.h>
	#include <inetLib.h>
	#include <msgQLib.h>
	#include <semLib.h>
	#include <hostLib.h>
	#include <sockLib.h>
	#include <ioLib.h>
	#include <sysLib.h>
	#include <tickLib.h>

#endif // WIN32

#endif // _VX_API_

⌨️ 快捷键说明

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