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

📄 piolib.h

📁 Vxworks的培训教程,大家分享下啊,
💻 H
字号:
#include "daadioLib.h"#include "semLib.h"/****************************************************		PUBLIC*****************************************************/#define PIO_MAX_CHANNELS		8#define PIO_MAX_PORTS			6#define PIO_CHANNELS_PER_PORT	8#define ON						1#define OFF						0#define PIO_INPUT               READ#define PIO_OUTPUT              WRITE/* PIO port numbers */#define PIO_PORT_A					0#define PIO_PORT_B					1#define PIO_PORT_C					2#define PIO_PORT_D					3#define PIO_PORT_E					4#define PIO_PORT_F					5/* PIO Output Port Mask */#define PIO_PORT_A_ENABLE			0x1#define PIO_PORT_B_ENABLE			0x2#define PIO_PORT_C_ENABLE			0x4#define PIO_PORT_D_ENABLE			0x8#define PIO_PORT_E_ENABLE			0x10#define PIO_PORT_F_ENABLE			0x20/* Convenient macros for setting and testing */#define PIO_ON(port, ch)		pioSet((port), (ch), 1)#define PIO_OFF(port, ch)		pioSet((port), (ch), 0)/* PIO modes used by input channels  * * There are 3 components: the type of access we have to the channel  * (polling or interrupts), an action to take when an event occurs * (give a semaphore or put data into a message queue), and a state * which define what an event is (when channel is on, when channel * is off or when channel changes state). *//* input mode types */#define PIO_TYPE_IGNORE				0x0#define PIO_TYPE_POLL				0x1/* input mode actions */#define PIO_ACTION_RELEASE_SEM		0x0/* input mode states */#define PIO_STATE_OFF				0x0#define PIO_STATE_ON				0x1/****************************************************		PRIVATE*****************************************************//* offsets of PIO ports from base */#define PIO_PORT_A_OFFSET			0x21#define PIO_PORT_B_OFFSET			0x20#define PIO_PORT_C_OFFSET			0x23#define PIO_PORT_D_OFFSET			0x22#define PIO_PORT_E_OFFSET			0x25#define PIO_PORT_F_OFFSET			0x24#define PIO_OUTPUT_ENABLE_OFFSET	0x27/* PIO poll task defines */#define PIO_POLL_DELAY			2		/* in clock ticks */#define PIO_POLL_PRIORITY		240/* this could be changed to PIO_PORT_B if we don't want to bother * polling PORT A which could be interrupt driven. */#define PIO_START_POLL_PORT		PIO_PORT_A/* input channel mode structure */typedef union 	{	SEM_ID syncSem;	} PIO_MODE_ID;typedef struct 	{	unsigned type	:1;	/* poll or interrupt */	unsigned action	:1;	/* release semaphore or msg queue */	unsigned state	:1;	/* when on or off */	} PIO_INPUT_MODE;typedef struct	{	PIO_INPUT_MODE mode;	/* what is an event & what to do with it */	PIO_MODE_ID id;	} PIO_CHANNEL;/* per port structure */typedef struct 	{	UINT8 *pPort;	int mode;	PIO_CHANNEL channel[PIO_CHANNELS_PER_PORT];	} PIO_PORT;/* PIO structure */typedef struct	{	PIO_PORT port[PIO_MAX_PORTS];	UINT8 *pOutputEnablePort;	SEM_ID mutexSem;	int pollTaskStarted;	int initialized;	} PIO;

⌨️ 快捷键说明

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