linux c下触摸屏程序,Linux下触摸屏驱动移植

开发板:FL2440

内核:Linux3.0

一、移植

1、修改/arch/arm/mach-s3c2440/mach-smdk2440.c

添加头文件

#include

添加

/*Touch Screen driver info add by huangyidong  */

static struct s3c2410_ts_mach_info smdk2440_ts_cfg __initdata = {

.delay = 10000,

.presc = 49,

.oversampling_shift = 2,

};

修改结构体

static void __init smdk2440_machine_init(void)

{

s3c24xx_fb_set_platdata(&smdk2440_fb_info);

s3c_i2c0_set_platdata(NULL);

s3c24xx_ts_set_platdata(&smdk2440_ts_cfg);

platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices));

smdk_machine_init();

}

添加设备

static struct platform_device *smdk2440_devices[] __initdata = {

&s3c_device_ohci,

&s3c_device_lcd,

&s3c_device_wdt,

&s3c_device_i2c0,

&s3c_device_iis,

&s3c_device_dm9000,

&s3c_device_adc,

&s3c_device_ts,

};

2、修改drivers/input/touchscreen/s3c2410_ts.c

130行左右

input_report_key(ts.input, BTN_TOUCH, 1);

input_report_abs(ts.input, ABS_PRESSURE, 1);//add by huangyidong

input_sync(ts.input);

140多行

input_report_key(ts.input, BTN_TOUCH, 0);

input_report_abs(ts.input, ABS_PRESSURE, 0);//add by huangyidong

input_sync(ts.input);

320行左右

ts.input = input_dev;

ts.input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) | BIT(EV_SYN);//add by huangyidong

ts.input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);

input_set_abs_params(ts.input, ABS_X, 0, 0x3FF, 0, 0);

input_set_abs_params(ts.input, ABS_Y, 0, 0x3FF, 0, 0);

input_set_abs_params(ts.input, ABS_PRESSURE, 0, 1, 0, 0);//add by huangyidong

二、配置make menuconfig

Device Drivers  --->

Input device support  --->

[*]   Touchscreens  --->

  Samsung S3C2410/generic touchscreen input driver

三、编译、烧录

烧录后重启开发板会发现多出来设备event0

0818b9ca8b590ca3270a3433284dd417.png

四、测试

测试程序

#include

#include

static int event0_fd = -1;

struct input_event ev0[64];

static int handle_event0()

{

int button = 0, realx=0, realy=0, i, rd;

rd = read(event0_fd, ev0, sizeof(struct input_event)* 64);

if(rd < sizeof(struct input_event)) return 0;

for(i=0;i

{

if(EV_ABS == ev0[i].type)

{

if(ev0[i].code == 0) {

realx = ev0[i].value;

} else if(ev0[i].code == 1) {

realy = ev0[i].value;

}

}

printf("event(%d):type:%d; code:%3d; value:%3d; realx:%3d; realy:%3d\n",i,ev0[i].type,ev0[i].code,ev0[i].value,realx,realy);

}

return 1;

}

int main(void)

{

int done = 1;

event0_fd = open("/dev/event0",02);

if(event0_fd <0) {

printf("open input device error\n");

return -1;

}

while (done)

{

printf("begin handle_event0...\n");

done = handle_event0();

printf("end handle_event0...\n");

}

if(event0_fd > 0)

{

close(event0_fd);

event0_fd = -1;

}

return 0;

}

运行结果:

按触摸屏产生:

0818b9ca8b590ca3270a3433284dd417.png

linux移植驱动编写最详细教程,Linux 操作系统的安装以及配置............................................................................................3 1 如何安装RedHat9.0 ................................................................................................3 2 在RedHat 中添加新用户.......................................................................................16 3 配置PC 机Linux 的ftp 服务...................................................................................16 4 配置PC 机Linux 的telnet .....................................................................................17 5 建立交叉编译环境...................................................................................................17 6 编译内核..................................................................................................................17 Linux移植.......................................................................................................................19 1 Bootloader 的移植.................................................................................................19 1.1 vivi 的配置与编译..........................................................................................19 1.2 配置和编译vivi .............................................................................................20 1.3 vivi 代码分析..................................................................................................21 1.4 vivi 的运行.....................................................................................................21 1.5 启动代码执行流程图.....................................................................................45 1.6 vivi 的配置文件..............................................................................................45 2 Linux 内核
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值