【Linux基礎】GEC2440&linux-2.6.30&ADC&Touchscreeen

本帖最後由 唯C達人 於 2013-9-20 19:38 編輯

選擇支持觸摸屏接口,事件接口及三星S3C2410觸摸屏輸入驅動。
添加代碼
(1)將touchscreen驅動源碼gec2440_ts.c添加到linux-2.6.30源碼目錄drivers/input/touchscreen中。
(2)將ADC驅動源碼gec2440_adc.c及頭文件s3c24xx-adc.h添加到Linux入門培訓linux-2.6.30源碼目錄drivers/char中。
2、修改drivers/input/touchscreen/Makefile文件。
#vim drivers/input/touchscreen/Makefile
添加(放於同格式的前面,下同)
obj-$(CONFIG_TOUCHSCREEN_GEC2440) += gec2440_ts.o
修改drivers/input/touchscreen/Kconfig文件
#vim drivers/input/touchscreen/Kconfig
添加
config TOUCHSCREEN_GEC2440
tristate "GEC2440 touchscreen input driver"
help
Say Y here if you have the s3c2440 touchscreen.
修改drivers/char/Makefile文件
#vim drivers/char/Makefile
添加
obj-$(CONFIG_GEC2440_ADC) += gec2440_adc.o
修改drivers/char/Kconfig文件
#vi drivers/char/Kconfig
添加
config GEC2440_ADC
tristate"GEC2440_ADC"
---help---
Say Y here if you have the s3c2440 ADC.
修改arch/arm/mach-s3c2410/mach-smdk2410.c文件
#vim arch/arm/mach-s3c2410/mach-smdk2410.c
添加
static struct s3c2410_ts_mach_info gec2410_ts_cfg __initdata = {
.delay = 10000,
.presc = 49,
.oversampling_shift = 2,
};
在static void __init smdk2410_map_io(void)函數中添加:
s3c24xx_init_touchscreen(&gec2410_ts_cfg);
C語言教程修改arch/arm/mach-s3c2440/mach-smdk2440.c文件
#vim arch/arm/mach-s3c2440/mach-smdk2440.c
在static struct platform_device *smdk2440_devices[] __initdata
結構體中添加:
&s3c_device_ts,
修改arch/arm/plat-s3c/include/plat/devs.h文件
#vim arch/arm/plat-s3c/include/plat/devs.h
添加:
struct s3c2410_ts_mach_info {
int delay;
int presc;
int oversampling_shift;
};
void __init s3c24xx_init_touchscreen(struct s3c2410_ts_mach_info *hard_s3c2410_ts_info);
extern struct platform_device s3c_device_ts;
修改arch/arm/plat-s3c24xx/devs.c文件
#vim arch/arm/plat-s3c24xx/devs.c
在文件後面添加
/* Touchscreen */
static struct s3c2410_ts_mach_info s3c2410_ts_info;
void __init s3c24xx_init_touchscreen(struct s3c2410_ts_mach_info *hard_s3c2410_ts_info)
{
memcpy(&s3c2410_ts_info,hard_s3c2410_ts_info,sizeof(struct s3c2410_ts_mach_info));
}
EXPORT_SYMBOL(s3c24xx_init_touchscreen);
struct platform_device s3c_device_ts = {
.name = "s3c2410-ts",
.id = -1,
.num_resources = ARRAY_SIZE(s3c_adc_resource),
.resource = s3c_adc_resource,
.dev = {
.platform_data = &s3c2410_ts_info,
}
};
EXPORT_SYMBOL(s3c_device_ts);
編譯配置內核
#make menuconfig
配置菜單添加驅動到內核:
Device Drivers --->
Input device support --->
Touchscreens --->
<*> GEC2440 touchscreen input driver
Character devices --->
<*> GEC2440_ADC
編譯內核生成靜態驅動模塊
#make
在內核啓動中可以看到(需要自己查找)
s3c2410 TouchScreen successfully loaded
input: s3c2410 TouchScreen as /class/input/input0
註冊信息爲:(開發板啓動後,在dnw窗口或者超級終端中輸入下列指令)
#cat /proc/bus/input/devices
信息截圖如圖:

C語言入門 根文件系統中建立相關設備節點:(開發板中執行,若文件已經存則不能建立)
#mkdir /dev/input
#mknod /dev/input/event0 c 13 64
#mknod /dev/input/mouse0 c 13 32
若提示“...Read-only file system”,或者 “mkdir: cannot create directory '/dev/input': File exists”。
解決方法如下:
#chmod 777 /dev/
#mount -o remount rw /
測試觸摸屏
#cat /dev/input/event0
然後點擊觸摸屏,有信息輸出,通常爲亂碼。
本文轉載於C語言入門:http://www.weicedu.com/thread-275839-1-2.html

發佈了1 篇原創文章 · 獲贊 3 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章