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]
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.
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
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Recommended voltage regulator chip and MCU
- Design of an extremely low power digital thermometer using MSP430
- Hey guys, how did you fix this error?
- AD17 PCB space is invalid! What to do?
- Overview of TI's 28335 chip
- Discussion on reverse connection of MOS tube in protection circuit
- Bor application of bluenrg-1
- Download and debug interface issues on product circuit boards
- Multisim op amp output is greater than the power supply problem
- How to choose between DT4215 and 15B for multimeter selection