introduction
With the development of computer-related technologies, ARM is a well-known company in the microprocessor industry. It has designed a large number of high-performance, low-cost, low-energy RISC processors, related technologies and software. The technology has the characteristics of high performance, low cost and low energy consumption. It is applicable to many fields, such as embedded control, consumer/educational multimedia, DSP and mobile applications. ARM is a company specializing in the design and development of chips based on RISC technology. As an intellectual property supplier, it does not directly engage in chip production. It relies on the transfer of design licenses to cooperative companies to produce chips with different characteristics. Major semiconductor manufacturers in the world purchase ARM microprocessor cores designed by ARM. 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.
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 of information transmission, the touch screen can be divided into resistive, capacitive, infrared and surface acoustic wave types. When an object is pressed on the touch screen, pressure is 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 is sent to the touch screen controller TSC2007, and the write signal is processed to convert the voltage signal into a digital signal, and at the same time sent to the S3C2440 processor in an interrupt manner 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 used in conjunction with a touch screen, once it detects a pen or finger touching 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. Its structure is based on capacitor redistribution and includes a sampling/holding function. The pins of TSC2007 are fully compatible with those of TPSC2003. 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. Instead, it adopts the method of external expansion controller TSC2007 to communicate with S3C2440 through I2C bus. Therefore, GPE14 and GPE15 of S3C2440 are used as SCL and SDA lines of I2C bus respectively in the design. The 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 Linux system, 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. 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 it is operating a device or an ordinary file. It can be treated as a file and has 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, read operations on different devices all use the read function, and write operations all use the write function. Therefore, the actual work of writing a touch screen driver is not complicated.
3.1 Driving 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.
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 numbers of the touch pen's press and release, thereby linking the interrupt number with the interrupt service function; uses the devfs_register_chrdev function to register a character device with the system; and finally registers the timer interrupt to control the data sampling of the touch screen.
3.3 Obtaining sampling values
First, start the A/D conversion of TSC2007. After waiting for a while, call the S3C2440_get_xy () function, which is used 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 to 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, the 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 sample values
The function Touch_Coordinate Conversion converts the touch screen sampling value into display coordinates, where TOUCH_MAX_Y and TOUCH_MIN_Y are the maximum and minimum values of the touch screen X coordinate sampling value; the same is true for the X coordinate. If a 320×240 TFT screen is used, the Y coordinate conversion procedure is as follows:
3.5 Touch screen calibration
In actual applications, touch screens are usually used as input devices in conjunction with display screens. 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 paper 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, three independent sampling points that are far apart and not on the same line are first selected as calibration inputs. 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 in the rectangular coordinate plane, P is defined as the coordinate point of the touch screen space, and PD is the coordinate point of the display screen space. P can be rotated, scaled and translated to obtain the PD coordinates. 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, and F are constants, called calibration constants. Therefore, when calibrating the touch screen, you only need to solve these 6 constants to achieve the touch screen space calibration.
Conversion to display space.
3.6 Interrupt release and registration module unloading
In the design, s3c2440_ts_cleanup_module0 is called to release the interrupt and uninstall the device, and they are released during the initialization process. The specific interface functions devfs_register_chrdev() for the interrupts of IRQ_TIMER4, IRQ_ADC_DONE, and IRQ_TC and the character device are as follows:
4 Conclusion
In this paper, the touch screen driver development based on S3C2440 is based on the compatibility with other ARM chips. Instead of using the A/D channel of ARM itself, 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 driver 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 the method of processing sampled data and uses an improved calibration method, so that the touch screen driver can better meet the actual requirements. ARM is a well-known company in the microprocessor industry, designing a large number of high-performance, low-cost, low-energy RISC processors, related technologies and software. The technology has the characteristics of high performance, low cost and low energy consumption. It is suitable for a variety of fields, such as embedded control, consumer/educational multimedia, DSP and mobile applications.
Previous article:Realization of real-time network communication and LCD display in ARM11 embedded system
Next article:Realization of Embedded Serial Communication Based on S3C2410 of ADS
Recommended ReadingLatest update time:2024-11-16 20:47
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
- 3.5mm audio interface type description
- Is wireless charging technology for new energy vehicles really not working?
- Introduction to flow principle in automatic monitoring system of oil and gas recovery in oil stations
- Op amp
- R8C uses RD timer and needs to use mov instruction to write trdstr register
- Capacitors and inductors
- If you don’t pay attention to the wiring, you will have to rework it sooner or later
- Purgatory Legend-The Battle between Pre-Simulation and Post-Simulation
- EEWORLD University Hall----labview2016
- Simulation and Calculation in PCB Circuit Design