【正文】
t too concerned with power usage. If the touch input response is much slower than this, there 西安文理學(xué)院 本科畢業(yè)設(shè)計(jì)(論文) 第 28 頁 will be a noticeable and annoying lag between touch input by the user and visual response on the display. The 20Hz update rate might not sound too challenging, but providing updates at 20Hz actually requires sampling at approximately 200Hz, depending on how many readings we are going to take before deciding we have a stable input. We need to oversample in order to debounce and average the touch input position values. Resistive touch screens, especially the inexpensive variety, are notoriously noisy and bouncy. The driver needs to sample the input for each axis s。ll describe these interrupts and how they39。ll find sections of the code have been ifdef39。re using an RTOS and all of your tasks are often blocked waiting for an external event of some sort, the processor is sitting in an idletask loop, doing nothing constructive. Maybe a better design in this situation is to have your idle task poll for input from your touch screen. It39。s not interruptdriven. I bring this up only because it seems polling has bee a dirty word to embedded systems programmers. I once asked a client if he was polling or using interrupts to service an input device. The response was this is an embedded system, we don39。s always the best or correct design, and don39。s fun to use interrupts. Don39。ll walk you through each step in detail. Hardware configuration The first thing the touch drivers need to do is configure the hardware. For these integrated controllers, this means writing to memorymapped registers to configure the controllers to a known state. This is done in a function named TouchConfigureHardware() in each driver. In order to configure the hardware, we already have some decisions to make. Should the driver be interrupt driven? What type of conversion rate is required to get responsive and accurate touch position information? Let39。 4. Calibrate the touch screen。 2. Determine if the screen is touched。s MC9328MX1 processor. These can be ordered directly from Freescale distributors. The evaluation kit includes a QVGA (240x320) color LCD and touch screen. The second board is based on the Sharp LH79524 ARM processor. The Sharp reference boards can be ordered from LogicPD Corporation (), along with integrated display and touch kits. Several interchangeable display kits are available at resolutions ranging from QVGA to 800x600 pixel resolution. Rather than listing the code for each driver within this article, I39。t matter in which order you take these readings. To convert the voltage produced by a resistive touch screen into a number we need an analogtodigital converter (ADC). Until quite recently this ADC was nearly always external to the main CPU. An example of such an ADC controller is the Burr Brown NS7843 or NS7846. This device is a 12bit analogtodigital converter with builtin logic to control a touch screen by powering alternate planes and converting from the other. You could acplish the plane power switching using generalpurpose I/O lines and such, but this device offloads much of the work and also provides means for generating a touch or pendown interrupt. More recently several CPU manufacturers have started to bring the analogtodigital conversion block and specialized touchscreen control circuitry inside the main CPU. This makes perfect sense when a CPU is intended for consumer devices, telematics, or other markets where LCD displays and touch screens are prevalent. 西安文理學(xué)院 本科畢業(yè)設(shè)計(jì)(論文) 第 26 頁 The reference boards For this article we39。re posed of two resistive sheets separated by a very thin insulator usually in the form of plastic microdots. When you touch the screen, you deform the two resistive sheets just enough to make electrical contact between them. Your software can figure out where the sheets are shorted together, and hence the touch location, by examining the voltage produced across the voltage dividers. 西安文理學(xué)院 本科畢業(yè)設(shè)計(jì)(論文) 第 25 頁 There are several types of resistive touch screens with names like fourwire, fivewire, and eightwire. The additional wires improve accuracy and reduce temperature drift, but the basic operation doesn39。ll find integrated with many evaluation boards and development kits. Resistive touch screens are popular mainly because they39。ll focus on resistive touch screens. Resistive touch screens are very popular, and they39。ll show you how to write a software driver that will configure, calibrate, and continuously respond to touchscreen input using either of these microprocessors. The result will be working code that you39。 module_exit(gt2440ts_exit)。 iounmap(base_addr)。 adc_clock = NULL。 if (adc_clock) { clk_disable(adc_clock)。 free_irq(IRQ_TC,dev)。 } static void __exit gt2440ts_exit(void) { disable_irq(IRQ_ADC)。 input_register_device(dev)。 return EIO。 西安文理學(xué)院 本科畢業(yè)設(shè)計(jì)(論文) 第 23 頁 } if (request_irq(IRQ_TC, stylus_updown, IRQF_SAMPLE_RANDOM, gt2440ts_name, dev)) { printk(KERN_ERR : Could not allocate ts IRQ_ADC !\n)。 iounmap(base_addr)。 dev = 0xBEEF dev = S3C2410TSVERSION。 dev = BUS_RS232。 input_set_abs_params(dev, ABS_PRESSURE, 0, 1, 0, 0)。 input_set_abs_params(dev, ABS_X, 0, 0x3FF, 0, 0)。 devevbit[0] = BIT(EV_SYN) | BIT(EV_KEY) | BIT(EV_ABS)。 return ENOMEM。 input_dev = input_allocate_device()。 iowrite32(0x4fff, base_addr+S3C2410_ADCDLY)。 } gt2440_ts_connect()。 if (base_addr == NULL) { printk(KERN_ERR Failed to remap register blo