资源简介
本人利用外部中断方式,模拟PS2协议写的鼠标驱动,各种平台都可以移植,本人已移植过4个不同平台。现在此份驱动是在凌阳芯片 ecos系统上的。欢迎大家交流。看有否其他更好方式(如spi ur等方式)
代码片段和文件信息
//==================有经验交流的(zfq01081401@163.com)====================
//=========================================================================
// File: drv_mouse.c
// Author: zfq
// Date: 08.11.05
//=========================================================================
#include
#include
#include
#define printf diag_printf
//=========================================================================
#define BUFNUMMAX 4
#define MOUSEMSGMAX 4
//for MouseSystemFlag
#define MOUSEInitFlag0 0x01
#define MOUSEInitFlag1 0x02
#define MOUSEInitFlag2 0x04
#define MOUSEInitFlag3 0x08
#define MOUSEInitFlag4 0x10
#define MOUSEInitFlag5 0x20
#define MOUSEInitFlag6 0x40
#define MOUSEInitFlag7 0x80
#define MOUSEInitFlag8 0x100
#define MOUSEInitFlag9 0x200
#define MOUSEInitFlag10 0x400
#define MOUSEInitFlag11 0x800
#define MOUSEInitFlag12 0x1000
#define MOUSEInitFlag13 0x2000
#define MOUSEInitFlag14 0x4000
#define MOUSEStepFlag 0x8000
//=====================================================
//for DataFlag
#define LeftBtn 0x01
#define RightBtn 0x02
#define MiddleBtn 0x04
#define XSignBit 0x10
#define YSignBit 0x20
#define XOverFlow 0x40
#define YOverFlow 0x80
//for MouseIrqFlag
#define ReceiveFlag 0x01
#define SendFlag 0x02
#define SendOver 0x04
#define ReceiveOver 0x08
//#define MOUSECHECKTIMER 0 //检测数据是否正确timer号
int mouseInitisrflag;
//------------------mouse 1------------------------
int mousetimenum;
int mousecheckflag;
int MouseSystemFlag;
int MouseIrqFlag;
int MouseDataReg;
int MouseBitCount;
int MouseWriteCount;
int MouseDataBufNum;
int MouseReceiveBuffer[BUFNUMMAX];
int MouseReceiveBufferOK[100];
int MouseMsgNum;
int MouseRestartFlag;
int MouseErrDataFlag;
int Mousejishu;
int Mousetype;
int MouseNum;
int MouseRCount;
int MouseCount;
int MouseInitFirstFlag;
//-------------------mouse 2-------------------
int mousetimenum2;
int mousecheckflag2;
int MouseSystemFlag2;
int MouseIrqFlag2;
int MouseDataReg2;
int MouseBitCount2;
int MouseWriteCount2;
int MouseDataBufNum2;
int MouseReceiveBuffer2[BUFNUMMAX];
int MouseReceiveBufferOK2[100];
int MouseMsgNum2;
int MouseRestartFlag2;
int MouseErrDataFlag2;
int Mousejishu2;
int Mousetype2;
int MouseNum2;
int MouseRCount2;
int MouseCount2;
int MouseInitFirstFlag2;
//-----------------------------------------
int OfnSendMessageFlag = 0;
const int BitTab[]={0x00010x00020x00040x00080x00100x00200x00400x0080
0x01000x02000x04000x08000x10000x20000x40000x8000};
typedef struct
{
int x0;
int y0;
int INTx;
int INTy;
}MOUSE;
MOUSE MouseData;
extern int MouseLCDX;
extern int MouseLCDY;
extern int MouseDispFlag;
void MouseSendMessageExt(int *PacketRegint xint y);
void SetMouseXY(int *PacketRegint X int Y)
{
MouseData.INTx += X;
MouseData.INTy += Y;
if(Mo
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 27297 2010-08-27 15:45 mouse\drv_mouse.c
文件 10126 2010-08-27 15:39 mouse\drv_mouse.h
目录 0 2010-08-27 15:39 mouse
----------- --------- ---------- ----- ----
37423 3
评论
共有 条评论