Category:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
0
1
2
3
4
5
6
7
8
9
Position:IcFull.com » IC Electronic information » Category: I

IC Electronic information

I2C-based embedded design of multi-touch screen driver

In Electronic Infomation Category: I | on April 20,2011

Abstract: Using a Samsung S3C6410X processor, embedded Linux drivers management system implemented on Cypress 7958, Snaptics TM1444 and LT6204CS datasheet and other I2C bus protocol based on multi-touch screen-driven design. Practice has proved that the core of the Linux-based Qtopia platform and LT6204CS price and embedded operating systems Andriod smooth, distinctive and LT6204CS suppliers and with high accuracy.

Introduction

With the development and promotion of embedded devices, the touch screen as the new input device has been everywhere, cell phone, PDA, MID, and ATM machines and other equipment have been used in a touch screen. In the continuous development of the technology, touch screen, also from the beginning of the 4-wire resistive touch screen, a single point to todays variety of multi-capacitive touch screen. Through the cypress 7958 as the representative of the I2C bus interface capacitive multi-touch screen studies, designed for the Linux operating system, multi-touch screen drivers, and does not run the operating system under the premise of the SCM on the touch screen driver, and achieved good results.

1 research platform to introduce

1.1 ARM11 processor S3C6410X

S3C6410X is based on the nuclear ARM1176JZFS for handheld, mobile terminal equipment, such as general-purpose processor. S3C6410X is a low-power, cost-effective, high-performance general-purpose processing used in mobile phones and RSIC processor. 2.5G and 3G communication services to provide optimized hardware performance with 64/32-bit internal bus architecture, the integration of AXI, AHB, APB bus. There are a lot of powerful hardware acceleration, including motion video processing, audio processing, 2D acceleration, display processing and scaling.

1.2 capacitive multi-touch screen

Capacitive touch screen on the touch screen 4 side electrodes are coated with long, narrow, conductive body in the formation of a low voltage AC field. The touch screen, because the body electric, fingers and the conductor layer to form a capacitive coupling, 4 side electrode current will flow to the contact issue, but the current strength is proportional to the distance from finger to the electrode, is located after the touch screen controller compute the current ratio and strength, accurately calculate the touch point. Double-glass capacitive touch screen can not only protect the conductors and sensors, to more effectively prevent external environmental factors impact on the touch screen, even if the screen stained with filth, dust or grease, capacitive touch screen is still able to accurately calculate the touch location. And the relative ratio of resistive touch screen, capacitive touch screen is to support multi-touch human-computer interaction, common resistive touch screen can only touch a single point.

1.3 ARM tool chain

This paper, the microcontroller uses ARM core arm none linux gnueabi 4.3.2 cross compiler chain to realize the support of the ARM binary file compiled for a successful compile ARMLinux 2.6.28 kernel.

1.4 transplant conditions

For content described in this article, all supported processors running Linux operating systems (including embedded processors) can run, and all support the I2C bus protocol of the MCU can not use the premise of the operating system will be touch screen a common input device for use.

2 research process

Figure 1 shows this in Linux platform for embedded software and hardware structure of the drive system.


Figure 1 driver software and hardware structure system

2.1 I2C devices in the platform part of the statement

CYPRESS 7958 multi-touch screen I2C address is 0x20, on the platform before use equipment at the I2C device declarations, so that it can find a Linux driver I2C address of the corresponding operation. I2C device must first declare the structure, the code is as follows:

Static struct i2c_board_info i2c_devs1 [] __initdata = {

{I2C_BOARD_INFO ("cypress 7958", 0x20),}, / * cypress 7958 touch pannel controller * /

};

Then static void __init smdk6410_machine_init (void) function is declared in the I2C device:

I2c_register_board_info (1, i2c_devs1, ARRAY_SIZE (i2c_devs1 ));

2.2 Cypress 7958 driver part of the design

2.2.1 registration and cancellation of modules

I2C driver structure is established, cypress_7958_driver, the code is as follows:

Static struct i2c_driver cypress_7958_driver = {

. Probe = cypress_7958_probe,

. Remove = cypress_7958_remove,

. Id_table = cypress_7958_id,

. Driver = {

. Name = CYPRESS_7958_NAME,

},

};

Initialization function and then create _INIT _EXIT cancellation device function: static int __devinit cypress_7958_ts_init (void), static void __exit cypress_7958_exit (void), and i2c_del_driver function through i2c_add_driver I2C device registration and cancellation.

2.2.2 touch screen driver entry function of the design

Declared by the I2C on the section structure that, in the device to be checked when entering static int synaptics_ts_probe (struct i2c_client * client, const struct i2c_device_id * id) function, this function requires the initial touch-screen mode initialization of the touch screen as an input device driver in the Linux platform device registered at the same time initialization caused when the touch event is triggered interrupt operation.

(1) Cypress 7958 model initialization As a multi-touch screen

, Cypress 7958, many related to the configuration register, this article will not repeat them, the initialization part is working only on the screen in normal mode to check the address by reading the register 0x28, If the value is 0x07, then the screen working properly, or returns an error value.

Ret = i2c_smbus_read_byte_data (ts > client, 0x28);

If (ret! = 0x07) {

Printk (KERN_ERR, "Cypress Detect Errorn ");

Return ret;

}

(2) input devices registered

Create struct input_dev structure, through the input_allocate_device () function creates the device name, then input device functions set_bit function declaration. Because it is multi-touch screen, can produce EV_SYN, EV_KEY, BTN_TOUCH, BTN_2 (multi-touch), EV_ABS other functions, so the statement of the:

Set_bit (EV_SYN, ts > input_dev > evbit);

Set_bit (EV_KEY, ts > input_dev > evbit);

Set_bit (BTN_TOUCH, ts > input_dev > keybit);

Set_bit (BTN_2, ts > input_dev > keybit);

Set_bit (EV_ABS, ts > input_dev > evbit);

And then complete the specific configuration of the event:

Input_set_abs_params (ts > input_dev, ABS_X, 0, max_y, 0, 0);

Input_set_abs_params (ts > input_dev, ABS_Y, 0, max_x, 0, 0);

Input_set_abs_params (ts > input_dev, ABS_PRESSURE, 0, 255, 0, 0);

Input_set_abs_params (ts > input_dev, ABS_TOOL_WIDTH, 0, 15, 0, 0);

Input_set_abs_params (ts > input_dev, ABS_HAT0X, 0, max_y, 0, 0);

Input_set_abs_params (ts > input_dev, ABS_HAT0Y, 0, max_x, 0, 0);

Input_set_abs_params (ts > input_dev, ABS_MT_POSITION_X, 0, max_y, 0, 0);

Input_set_abs_params (ts > input_dev, ABS_MT_POSITION_Y, 0, max_x, 0, 0);

Input_set_abs_params (ts > input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);

Input_set_abs_params (ts > input_dev, ABS_MT_WIDTH_MAJOR, 0, 15, 0, 0);

Finally input_register_device (ts > input_dev) function to complete the registration of the device name.

(3) generate an interrupt function event-driven initialization

Cypress 7958 touch screen touch event occurs at the IRQ pin will produce a low level signal, this pin is connected to the GPN (15) pin, and create a GPIO interrupt function:

S3c_gpio_cfgpin (S3C64XX_GPN (15), S3C_GPIO_SFN (2 ));

Client > irq = gpio_to_irq (S3C64XX_GPN (15 ));

Irqflags = IRQF_TRIGGER_LOW;

Then ret = request_irq (client > irq, cypress_7958_irq_handler, irqflags, client > name, ts) to interrupt the function application. Create cypress_7958_irq_handler function:

Static irqreturn_t cypress_7958_irq_handler (int irq, void * dev_id) {

Struct synaptics_ts_data * ts = dev_id;

/ / Int ret = gpio_get_value (S3C64XX_GPN (15 ));

/ / Printk ("% s: ret =% dn", __func__, ret);

Disable_irq_nosync (ts > client > irq);

Queue_work (cypress_7958_wq, & ts > work);

Return IRQ_HANDLED;

}

Event is triggered when the driver after the drive through queue_work function into the work area cypress_7958_wq, to ??drive the level of information reported on the application layer.

2.2.3 touch screen function work area design

Touch screen function work area and access to information required to complete the event-driven application layer information layer on the reporting function, through INIT_WORK (& ts > work, cypress_7958_work_func) function work area to complete the driver initialization function declaration, the driver After the incident in work areas interrupt function cypress_7958_work_func.

(1) touch-screen access to event information

Cypress 7958 event trigger information stored in the register, only need to register their information by i2c_smbus_read_byte_data function to read event information to complete its acquisition, also done by i2c_transfer bulk of its register information read: < / P>

Buf [0] = i2c_smbus_read_byte_data (ts > client, 0x12);

Buf [1] = i2c_smbus_read_byte_data (ts > client, 0x13);

Buf [2] = i2c_smbus_read_byte_data (ts > client, 0x14);

Buf [3] = i2c_smbus_read_byte_data (ts > client, 0x15);

Buf [4] = i2c_smbus_read_byte_data (ts > client, 0x16);

Buf [5] = i2c_smbus_read_byte_data (ts > client, 0x17);

Buf [6] = i2c_smbus_read_byte_data (ts > client, 0x18);

Buf [7] = i2c_smbus_read_byte_data (ts > client, 0x19);

Buf [8] = i2c_smbus_read_byte_data (ts > client, 0x1a);

Buf [9] = i2c_smbus_read_byte_data (ts > client, 0x1b);

Buf [10] = i2c_smbus_read_byte_data (ts > client, 0x1c);

Buf [11] = i2c_smbus_read_byte_data (ts > client, 0x1d);

Buf [12] = i2c_smbus_read_byte_data (ts > client, 0x1e);

Buf [13] = i2c_smbus_read_byte_data (ts > client, 0x1f);

(2) touch screen event information reported to the

By buf array analysis, specific information for current events and family functions by input_report event information reported to the application layer:

If (fingermark == 2) {

Input_report_key (ts > input_dev, ABS_MT_TRACKING_ID, 0);

Input_report_abs (ts > input_dev, ABS_MT_TOUCH_MAJOR, f1z);

Input_report_abs (ts > input_dev, ABS_MT_POSITION_X, f1x);

Input_report_abs (ts > input_dev, ABS_MT_POSITION_Y, f1y);

Input_mt_sync (ts > input_dev);

Input_report_key (ts > input_dev, ABS_MT_TRACKING_ID, 1);

Input_report_abs (ts > input_dev, ABS_MT_TOUCH_MAJOR, f2z);

Input_report_abs (ts > input_dev, ABS_MT_POSITION_X, f2x);

Input_report_abs (ts > input_dev, ABS_MT_POSITION_Y, f2y);

Input_mt_sync (ts > input_dev)

Input_sync (ts > input_dev);

}

Else if (fingermark == 1) {

Input_report_key (ts > input_dev, ABS_MT_TRACKING_ID, 0);

Input_report_abs (ts > input_dev, ABS_MT_TOUCH_MAJOR, f1z);

Input_report_abs (ts > input_dev, ABS_MT_POSITION_X, f1x);

Input_report_abs (ts > input_dev, ABS_MT_POSITION_Y, f1y);

Input_mt_sync (ts > input_dev);

Input_sync (ts > input_dev);

}

Else {

Input_report_abs (ts > input_dev, ABS_MT_TOUCH_MAJOR, 0);

Input_mt_sync (ts > input_dev);

Input_sync (ts > input_dev);

}

2.3 Cypress 7958 driver in the kernel porting Makefile and KCONFIG

done by rewriting the kernel in Cypress 7985 transplant, to help achieve the GCC tool chain compiled kernel.

2.3.1 Kconfig changes

In / driver / input / touchscreen / Kconfig add the following statement:

Config TOUCHSCREEN_CYPRESS

Tristate "CYPRESS 7958 touchscreens"

Help

Say Y here if you have a CYPRESS 7958 touchscreen connected to your system.

If unsure, say N.

Compile options to achieve the file to MAKE MENUCONFIG in. The touch screen is the system basic input-driven device driver itself is called the I / O interrupt, can not implement the module compiled, can be completely compiled into the kernel. Found in subsequent research using the clock interrupt to its modular compiled into the kernel, but because of UCLINUX time slice interrupt the operation, it abandoned.

2.3.2 Makefile modifications

Then / driver / input / touchscreen / Makefile to add the corresponding compiled information:

Obj $ (CONFIG_TOUCHSCREEN_CYPRESS) + = touchscreen_cypress.o

Will eventually compile options / MAKEFILE the ARCH option is set to S3C6410, in the make menuconfig command after the options and choose the option TOUCHSREEN_CYPRESS compiled into the kernel.

Conclusion

Way the design I2C multi-touch screen driven by embedded Linux multi-touch input method will be applied to the system, embedded applications, enriched single keyboard input and single-point input mode, reducing the system size improve the reliability of the system. Makes the simple input of embedded systems, embedded systems also enhance the communication ability between people, simplifying the tedious debugging. By Samsung S3C6410 ARM11 processors to speed up the experimental procedure. Practice has proved that the design-driven multi-touch screen speed and stability to meet the commissioning requirements. The design just make simple changes to the underlying driver, can be directly applied to all the microcontroller can run Linux and other embedded systems.

LT6204CS datasheetLT6204CS suppliersLT6204CS Price

All right reserved:icfull.com © 2010-2016 Certificate