首页| 论坛| 消息

标题:【提问】令我极其崩溃的问题(急,在线等)
作者:gaoyu
日期:2006-03-10 00:35
内容:

QT中如何嵌入驱动程序:
//driver.h
#ifndefDRIVER_H
#define DRIVER_H
#include
#include
#include
#define _inp(a) inb(a)
#define _outp(a,d) outb(d,a)
int io_access_on( unsigned long );
void io_access_off(unsigned long );
void Start_Receive(void);
extern int ValidPpt;

#define LPT 0x378
#define LPT_FLAG0x379
#define LPT_CONTROL0x37a

#endif

//driver.c
#include "driver.h"
int io_access_on( unsigned long port )
{
if (ioperm(port,3,1))
{
perror ("ioperm()");
return 0;
}
if (ioperm(0x80,1,1))
{
perror ("ioperm()");
return 0;
}
return 1;
}
void io_access_off(unsigned long port)
{
ioperm(port,3,0);
ioperm(0x80,1,0);
}
#else
#define io_access_on(x) (1)
#define io_access_off(x)
#endif
int GetValidPpt(void)
{
// search for valid parallel port
if( io_access_on(LPT) )
{
_outp(LPT, 0x55);
if((int)_inp(LPT) == 0x55) return LPT;
io_access_off(LPT);
}
return 0;
}

int main()
{
io_access_on(LPT);

int b;
int Valid;


Start_Receive();
_outp(LPT_CONTROL,0x02);
b=((_inp(LPT_FLAG)^0x80)>>4)&0x0f;
_outp(LPT_CONTROL,0x00);
..

回复 发表
主题 版块