Design of I2C touch screen based on ARM processor S3C2440 and Linux system

Publisher:SereneNature7Latest update time:2011-06-16 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

0 Introduction

With the development of computer-related technologies, ARM embedded systems are increasingly widely used and are increasingly integrated into people's lives. Touch screen devices are widely used in this embedded field due to their friendly human-computer interaction, convenient and flexible operation, and fast input speed. The embedded Linux system has the characteristics of open source code, stable kernel, and scalability, which attracts the attention of many commercial companies and free software developers and becomes one of the indispensable operating systems in the field of embedded systems. The touch screen is an input device that is easy to learn and operate, has high reliability, and does not take up extra space. It is the most commonly used input device for portable systems. In particular, the resistive touch screen has a simple structure, low cost, good light transmission effect, and the working environment is completely isolated from the outside world. It is not afraid of dust and moisture. At the same time, it has the characteristics of high resolution, high-speed transmission response, one-time correction, high stability, and no drift, so it is widely used in the field of industrial control.

1 Working principle of resistive touch screen

The touch screen is installed at the front end of the display screen and is mainly composed of two parts: the touch screen detection component and the touch screen controller. According to the working principle and the medium for transmitting information, the touch screen can be divided into resistive, capacitive induction, infrared, and surface acoustic wave. The resistive touch screen has two layers of transparent conductive indium oxide between the surface protection layer and the base layer, and these two conductive layers correspond to the x and y axes respectively, and there are fine transparent insulating particles between them for insulation. When an object is pressed on the touch screen, pressure will be generated, so that the two conductive layers of the touch screen are connected. Once the touch screen detection component detects the user's touch position, the obtained position information will be sent to the touch screen controller TSC2007, and the write signal will be processed, the voltage signal will be converted into a digital signal, and at the same time, it will be sent to the S3C2440 processor in an interrupt mode to calculate the touch point coordinates.

2 Hardware Structure

TSC2007 is a new generation of 4-wire touch screen controller launched by Texas Instruments (TI) in the United States. When it is used in conjunction with a touch screen, once it detects that a pen or finger touches the screen, it can quickly obtain the position signal of the point, thereby achieving the purpose of addressing on the touch screen surface.

TSC2007 is a typical step-by-step approximation A/D converter, whose structure is based on capacitance redistribution and includes a sampling/holding function. The pins of TSC2007 are fully compatible with those of TPSC2003, and it has three functions: on-chip temperature measurement, touch pressure measurement, and preprocessing. The I2C interface of TSC2007 performs data transmission and communication in standard mode, high-speed mode, and ultra-high-speed mode. In order to be compatible with other ARM chips, the design does not use the built-in A/D channel of S3C2440, but adopts the method of external expansion controller TSC2007 to communicate with S3C2440 through I2C bus. Since in the embedded system I2C bus, S3C2440 is the host on the bus, TSC2007 is the slave, and the I2C system has two pins, namely the serial data line SDA and the serial clock line SCL. Therefore, in the design, GPE14 and GPE15 of S3C2440 are used as the SCL and SDA lines of the I2C bus respectively. Its touch screen controller interface circuit is shown in Figure 1. The SDA and SCL lines in the figure are both bidirectional.

3 Touch screen driver

In the Linux system, the device driver is a set of related functions, including device service subroutines and interrupt handlers. The device service subroutines contain all device-related codes. Each device service subroutine only handles one device or closely related devices, accepts abstract commands from device-independent software and executes them. When executing a request, the specific operation is based on the interface provided by the controller to the driver, and uses the interrupt mechanism to call the interrupt service subroutine to cooperate with the device to complete the request. The device driver uses the structure file_operations to connect with the file system. The entry functions of various operations of the device are placed in the structure file_operations, including open(), release(), read() and write() interfaces, which simplifies the writing of the driver. In this way, the application does not have to consider whether the operation is a device or an ordinary file, and can be treated as a file, with a very clear and unified I/O interface. The file_operations structure of the touch screen is defined as follows:


The main function of this structure is to provide a consistent interface for different devices. For example, in the application, the read function is used for reading operations on different devices, and the write function is used for writing operations. Therefore, the actual work of writing a touch screen driver is not complicated.

3.1 Driver workflow

First, initialize the touch screen controller, then initialize the pulse width modulation timer (PWM TIMER). You can select timer 4 as the clock and define a 10 ms interrupt to provide the touch screen sampling time base, that is, the touch screen samples once every 10 ms. Then map the touch screen interrupt vector and the timer interrupt vector to the response program. The touch screen interrupt handler determines whether the touch screen is pressed. If the touch screen is pressed, the global variable Flag_Trouch is assigned to Touch_Down, otherwise it is assigned to Touch_Up. If the timer interrupt handler determines that Flag_Touch is assigned to Touch_Down, the global variable StartSample is set to control the touch screen sampling. Then the system obtains the sampling value through S3C2440_get_xy() and processes the obtained touch screen data. Next is the calibration of the touch screen, and finally the release of the interrupt and the uninstallation of the registration module. The specific touch screen driver workflow is shown in Figure 2.
[page]

3.2 Device initialization module

The main functions of the device initialization module are: initializing the device, registering the device with the kernel, etc. The specific implementation functions are as follows:

The initialization module uses the request_irq function provided by the kernel to register the interrupt number of the touch pen's press and pop-up, thereby linking the interrupt number with the interrupt service function; using the devfs_register_chrdev function, register a character device with the system; and finally register the timer interrupt to control the data sampling of the touch screen.

3.3 Obtaining the sampling value

First, start the A/D conversion of TSC2007. After waiting for a while, call the S3C2440_get_xy () function. The function of this function is to obtain the position of the touch screen. First, obtain the x coordinate value from one channel of TSC2007, and then obtain the y coordinate value from another channel. Determine whether the returned touch point coordinate value is within the valid range. If it is within the valid range, the sampling flag ts_pressure=1, if it is not within the valid range, its sampling flag ts_pressure=0. In the read function, by calling copy_to_user(buffer, dbuf, length), the kernel space data can be copied to the user space.

3.4 Processing of sampling values

The function Touch_Coordinate Conversion completes the conversion of touch screen sampling values ​​into display coordinates, where TOUCH_MAX_Y and TOUCH_MIN_Y are the maximum and minimum values ​​of the touch screen X coordinate sampling values; the same applies to the X coordinate. If a 320×240 TFT screen is used, the conversion procedure for the Y coordinate is as follows:

3.5 Calibration of the touch screen

In actual applications, the touch screen is usually used as an input device in conjunction with the display screen, and it is necessary to map the coordinates obtained from the touch screen sampling to the display coordinates of the screen. The touch screen design in this article adopts the three-point calibration method. Compared with the two-point calibration, the three-point calibration model takes into account the transformation and rotation, which is closer to the actual situation. In the application, firstly select three independent sampling points that are far apart and not on the same line as the calibration input. Their corresponding touch screen sampling coordinates are P0(x0, y0), P1(x1, y1), P2(x2, y2), and the display coordinates are PD0(xD0, yD0), PD1(xDl, yD1), PD2(xD2, yD2). Two points P and PD on the rectangular coordinate plane, define P as the coordinate point of the touch screen space, PD as the coordinate point of the display screen space, P can be obtained by rotation, scaling and translation. There is a linear relationship between PD and P points: xD=Ax+By+C, yD=Dx+Ey+F. For the same device, A, B, C, D, E, F are constants, called calibration constants, so when calibrating the touch screen, you only need to solve these 6 constants to realize
the conversion from touch screen space to display space.

3.6 Interrupt release and registration module unloading

In the design, s3c2440_ts_cleanup_module0 is called to realize interrupt release and device unloading. They are released in the initialization process respectively. The interrupts of IRQ_TIMER4, IRQ_ADC_DONE, IRQ_TC and the interface function of character device devfs_register_chrdev () applied are as follows:



4 Conclusion

In the touch screen driver development based on S3C2440, considering the compatibility with other ARM chips, the A/D channel of ARM is not used, but the touch screen controller TSC2007 is expanded. The initialization of TSC2007 is mainly to initialize the I2C interface connection between TSC2007 and S3C2440. In the driving process, if the touch pen is pressed, the interrupt handler is entered to read the x and y coordinates. A copy_to_user(buffer, dbuf, length) function is set in the sampling function to send the data continuously measured from the touch screen to the storage area.

Combined with the actual hardware platform, this I2C bus interface touch screen design based on the embedded Linux operating system adopts a method of processing sampling data and an improved calibration method, so that the touch screen driver can better meet actual requirements.

Reference address:Design of I2C touch screen based on ARM processor S3C2440 and Linux system

Previous article:Implementation of multi-mode partition and expert control system for air conditioner energy saving based on ARM7 SoC chip
Next article:Embedded software protection solution based on ARM platform

Recommended ReadingLatest update time:2024-11-16 16:02

S3C2440 development tool realview MDK4.22 library usage
1. Forced linking with the C library If you write a C program, it will be linked to the C library, even if you do not use the C library functions directly. This is because the compiler may implicitly generate calls to C library functions in order to improve the program. Even if your program does not have a main() fu
[Microcontroller]
S3C2440 development tool realview MDK4.22 library usage
10. S3C2440 development resources
10.1 S3C2440 internal resources 1.2V core power supply, 1.8V/2.5V/3.3V memory power supply, 3.3V external I/O power supply, with 16KB instruction cache and 16KB data cache and MMU microprocessor External memory controller (SDRAM control and chip select logic) LCD controller (supports up to 4K color STN and 256K co
[Microcontroller]
10. S3C2440 development resources
How to set the system clock of S3C2440
The clock control logic provides three clocks for the entire chip: FLCK is used for the CPU core; HCLK is used for devices on the AHB bus (such as: CPU core, memory controller, interrupt controller, LCD controller, DMA, etc.); PCLK is used for devices on the APB bus (such as: WATCHDOG, IIS, I2C, PWM timer, MMC interfa
[Microcontroller]
Cross-analysis of I2C driver and test program tracking based on S3c2440
VMware virtual machine + Fedora10, hardware platform TQ2440, kernel 2.6.30.4 The corresponding driver suddenly became clear, and after adding some dev_dbg myself, I also got some reference tips for the things I didn't understand, and recorded them to share with everyone. The test procedure is as follows: /*i2c_test.
[Microcontroller]
S3C2440 bare metal --- touch screen _ calibration principle
The so-called calibration is to find a formula to convert the voltage value into the coordinate value. Our touch screen is covered on the LCD. When we get the voltage value of the output point, we can get the coordinates of the LCD through the proportional formula. But in reality we don't choose the boundary points,
[Microcontroller]
S3C2440 bare metal --- touch screen _ calibration principle
(1) s3c2440——GPIO (water lamp experiment)
1. GPIO running water lamp experiment   1. Experimental purpose   a: Master how to use GPIO   b: Familiar with programming methods under Linux   2. Experimental content   Make LED display by controlling GPIO pin   3. Main procedures:   a: The start.S file is the startup file. The first program to start. The function
[Microcontroller]
(1) s3c2440——GPIO (water lamp experiment)
Difference between NOR flash boot and NAND flash boot on s3c2440
1) Interface difference: NOR FLASH address line and data line are separated, and data comes out when address and control signal are received. NAND Flash address line and data line are together, and need to be controlled by program to output data. In layman's terms, it is not enough to just give address, you need to gi
[Microcontroller]
Design of LED backlight power saving system based on S3C2440
introduction Energy-saving and environmental protection technology is the focus of the world's current attention. In LCD display modules, the power consumption of the backlight can account for more than 50% of the total power consumption. Especially in display products below 10in, such as mobile phones, PDAs, M
[Microcontroller]
Design of LED backlight power saving system based on S3C2440
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号