- UID
- 133947
- 性别
- 男
|
四.举例(以2410的触摸屏为例)
1.硬件说明
提供8通道模拟输入,能够将每个模拟输入转化成10位的数字,转换500KSPS with 2.5 MHz A/D converter clock.。
TS使用(nYPON, YMON, nXPON and XMON)和analog pads (AIN[7], AIN[5])
建议采用下面步骤
(1) 使用独立Separate或自动Auto (Sequential) X/Y位置转换模式来获得X/Y位置
(2) 设定TS接口为Waiting Interrupt Mode
(3) 如果中断发生,就会激活上面所选的X/Y位置转换模式
(4) 在得到X/Y值后,再进入中断等待
2.数据结构
struct s3c2410_ts_device { //对应于触摸屏设备
struct s3c2410_ts_general d;
struct s3c2410_ts_calibration cal; /* ts calibration parameters */
struct s3c2410_ts_event buf[MOUSEBUF_SIZE]; //触摸屏事件缓存
struct s3c2410_ts_event cur_data, //当前事件
samples[3],//多次采样事件值
last_data;//上次值
};
struct s3c2410_ts_general {触摸屏一般性信息
unsigned int head, tail; /* Position in the event buffer */
event缓存区中的head和tail,确定当前还需要处理的触摸屏事件
struct fasync_struct *async_queue; /* Asynchronous notification */
wait_queue_head_t waitq; /* Wait queue for reading */
struct semaphore lock; /* Mutex for reading */
unsigned int usage_count; /* Increment on each open */
unsigned int total; /* Total events */
unsigned int processed;
unsigned int dropped;
};
typedef struct s3c2410_ts_event {触摸屏事件,每次触摸就会产生触摸屏事件
unsigned short pressure;
unsigned short x;
unsigned short y;
unsigned short pad;
} TS_EVENT;
struct ts_pen_data {//记录每次触摸的点(笔)信息
enum pen_state state;
unsigned short x[TS_FILTER_LENGTH]; // Unfiltered data points
unsigned short y[TS_FILTER_LENGTH];
unsigned short count; // Number of points recorded in this "DOWN" or "DISCARD" series
unsigned short index; // Location in ring buffer of last stored data value
int last_cal_x; // Last reported X value to the user
int last_cal_y; // Last reported Y value to the user
};
3.基本算法:
采用等待中断模式,则每次点击都会产生一个INT_TC中断,然后开始硬件定时,会不断进入定时采样阶段,将采样值保存到设备对应的s3c2410_ts_device的samples中,并进行校验和坐标转化data_processing,最后结果保存在设备对应的s3c2410_ts_device的cur_data中,并拷贝到buf中
五.添加驱动到内核
1.修改源文件。源文件为linux /driver/char/s3c2410_ts.c。不能#define MODULE,
2. 修改makefile文件。修改 linux/driver/char/Makefile ,在适当位置添加obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o
3. 修改make配置文件。修改 linux/driver/char/ Config.in,在适当位置添加
if [ "$CONFIG_ARCH_S3C2410" = "y" ]; then
tristate 'S3C2410 TOUCH SCREEN SUPPORT ' CONFIG_TOUCHSCREEN_S3C2410
或 bool ''S3C2410 TOUCH SCREEN SUPPORT ' CONFIG_TOUCHSCREEN_S3C2410 y
fi
便于在 make menuconfig 时选择
4. 进行配置。运行make menuconfig(在menuconfig的字符设备选项里你可以看见我们刚刚添加的' S3C2410 TOUCH SCREEN SUPPORT 选项,选中
5. 重新编译内核
|
51 c8051f(f020,f040) msp430 arm(2410,2510) fpga(xc3s4000) dsp(5116 dm642) keilc vc++ matlab linux protel Ten_layerPCB mpegx h.26x Rscode Turbocode ofdm VideoBroadcasting ldpc_code(now!) |
|