QT中如何嵌入驱动程序:
//driver.h
#ifndef DRIVER_H
#define DRIVER_H
#include <asm/io.h>
#include <stdio.h>
#include <unistd.h>
#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_FLAG 0x379
#define LPT_CONTROL 0x37a
#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);
b|=((_inp(LPT_FLAG)^0x80)&0xf0);
printf("the return value is %d\n",b);
printf("the return value is %x\n",b);
Valid=GetValidPpt();
printf("Valid port is #%x\n",Valid);
io_access_off(LPT);
return 0;
}
这个是我实现的对并口实现数据采集的程序(各位对程序到不用看的很懂,都是一些对端口的操作),想嵌入到QT中,使采集到的数据显示在QLineWEdit中,并画出相应的波形.可嵌入到QT时,程序无法识别ioperm(),这个是.c的文件,必须用GCC进行编译,而QT是.CPP文件,需要用G++编译,请问我是不是应该改用QMAKE自动生成的MAKEFILE文件来达到目的啊,应该怎么改讷?
谢谢了!