s3c2416 Bare Metal Development Series 13 _ Capacitive screen Drive implementation

Source: Internet
Author: User
Tags touch volatile
s3c2416 Bare Metal Development Series 13 Capacitive screen Drive implementation

Chess Boy 1048272975

In the human-computer interaction system, the keyboard, touch screen and other input devices is an indispensable part. For mobile phones, tablets, these consumer electronics, touch screen with its very good user experience has been widely used. The author here is a simple introduction to the application of s3c2416 IIC interface capacitive screen. 1. Touch Screen Overview

At present, there are two kinds of touch screen commonly used in embedded system, one is resistive touch screen and the other is capacitive touch screen. Resistance screen requires a certain amount of pressure to contact the screen, the position of the two conductive layer at the point of contact resistance will change, in the X, y two direction to produce a simulated voltage divider value, the value of this voltage divider through the touch screen controller analog-to-digital conversion, to obtain the coordinates of the touch point position. Therefore, the resistance screen as long as there is pressure contact, there will be a reaction, but also because the resistance screen needs a certain amount of pressure, resulting in resistance screen surface easy to wear, poor sensitivity, to achieve the current mobile phone sliding unlock function is more difficult. Due to its implementation mechanism, the resistive screen can only be single touch, the environmental requirements are not high, can achieve a more precise location of touch.

The capacitive screen leads to the electrode at Four corners of the working face, forming a low voltage alternating electric field within the conductor layer. User Touch screen, due to the human field, the user, the touch screen surface to form a coupling capacitor, for high-frequency current, the charge will flow through this coupling capacitance to the earth, this very small current from the touch screen in the four corners of the electrode flow, and the current flow through the four electrodes is proportional to the distance of the fingers to the four corners, The controller obtains the position of the touch point by accurate calculation of the four current ratios. Therefore, the capacitive screen only reacts to the touch of a charged object, such as toothpicks, nails, gloves, etc. are unable to operate the capacitive screen. Because the capacitive screen is based on the charge, the input reaction can be obtained with the touch of a finger, and the sensitivity is high. But at the same time for the surrounding environment is high, too humid environment (such as the bathroom), water droplets on the touch screen may cause the capacitive screen will not work properly. The capacitance is relatively low precision and cannot touch the fine position by finger. In addition, capacitive screen can support multi-touch, almost become the first choice of mobile phone, tablet touch screen, in order to support multi-touch image amplification, rotation and other functions. 2. Capacitive screen Drive Implementation

I use the capacitive screen driver IC for the Focaltech ft5206, this chip can support the real 5 points, which can detect up to 5 points simultaneously touch, interface support IIC and SPI.

When an effective touch is detected by the driver chip, an interrupt control signal is generated. There are two modes of interrupt signal output, namely query mode and trigger mode. The query mode is suitable for software applications that support only single touch processing, and most operating systems (or graphics systems) do not support multi-touch, except for mobile phones, tablets, Android, iOS, and so on. With this touch, the interrupt signal line pulls low, no touch, the interrupt signal line pull high mode will be very good to apply to these software. Trigger mode is in the touch, the driver chip will generate a certain frequency interrupt signal to report the location of the touch point coordinates, usually this escalation frequency of about 100HZ (driver chip curing), the escalation frequency is too low may cause a drop point. This ensures that multiple points of touch are recognized. At present, the mainstream mobile phones, tablets are this way of working to get multi-touch coordinates position.

The author's capacitive screen module uses the IIC interface, therefore, the s3c2416 capacitive screen drive implementation requires the above section of the IIC driver-based, in the capacitive screen test code to give a 5-point touch Canvas instance, you can use 5 fingers at the same time on the canvas drawing. This section of the touch screen module code testing requires the previous chapter of the boot code, IIC interface module, RGB screen driver module support.

The TP_FT5206.C module is implemented as follows:

#include "S3c2416.h"

#include "IIC.h"

#include "Tp_ft5206.h"

#include "Exception.h"

volatile unsigned char tp_press;

static void Tp_eint8_15_irq ()

{

if (Reintpend & (1<<12)) {//eint12 Interrupt processing

Reintmask |= (1 << 12); EINT12 Interrupt Disabled

Reintpend |= (1 << 12); Clear Interrupt Flag

tp_press = 1; Indicates that the touch screen has been pressed

}

RSRCPND1 |= (1 << int_eint8_15);//clear pending bit

RINTPND1 |= (1 << int_eint8_15);

}

static void Delay_ms (unsigned int ncount)

{

Delay 1ms, co-delay ncount (R0) MS

__asm__ __volatile__ (

"0:\n\t"

"Ldr R1, =100000\n\t"//ARM clock 400M

"1:\n\t"

"Subs R1, R1, #1 \n\t"//Arm Clock

"Bne 1b\n\t"//jump to the transfer line, 3 arm clock

"Subs%0,%0, #1 \n\t"//Caller make sure Ncount is not 0

"Bne 0b\n\t"

:: "R" (ncount): "R1"

);

}

Continuously writes length byte data to the internal address writeaddr of the capacitive screen, where the data is located in pdata

Inttp_writebytes (unsigned char writeaddr, unsigned char *pdata,

int Length)

{

Call IIc Write, the capacitive screen internal address of a continuous write

Return Iic_writebytes (tp_slaveaddr,writeaddr, PData, Length);

}

Continuously reads the length byte data to the capacitive screen internal address readaddr, the data is saved in the pdata

Inttp_readbytes (unsigned char readaddr, unsigned char *pdata,

int Length)

{

Call the IIc interface to read, the capacitive screen inside an address for continuous reading

Return Iic_readbytes (tp_slaveaddr, Readaddr,pdata, Length);

}

void Tp_reset ()

{

Rgpfdat &= ~ (1 << 5); Pull Low Reset Line

Delay_ms (20);

Rgpfdat |= (1 << 5);

Delay_ms (200);

}

void Tp_init ()

{

RGPGUDP &= ~ (0x3 << 8); GPG4 (EINT12) as capacitive screen interrupt input

RGPGUDP |= (0x2 << 8); Tp_int GPG4 Pull Up

Rgpgcon &= ~ (0x3 << 8);

Rgpgcon |= (0x2 << 8); GPG4 configured as EINT12

RGPFUDP &= ~ (0x3 << 10); GPF5 as Reset control signal

RGPFUDP |= (0x2 << 10); Tp_rst GPF5 Pull Up

Rgpfcon &= ~ (0x3 << 10);

Rgpfcon |= (0x1 << 10); GPF5 configured as output

Tp_reset (); TP Reset

TP External Interrupt Entry function added to the vector table

Irq_register (Int_eint8_15, TP_EINT8_15_IRQ);

REXTINT1 &= ~ (0x7 << 16);

REXTINT1 |= (0x2 << 16); EINT12 Falling Edge Trigger

RINTMOD1 &= ~ (1 << int_eint8_15);//Eint8_15 IRQ

RINTMSK1 &= ~ (1 << int_eint8_15);//Eint8_15 Open Interrupt

Reintmask &= ~ (1 << 12); EINT12 Enable interrupt

}

The contents of the header file of the module are as follows:

#ifndef__TP_FT5206_H__

#define__TP_FT5206_H__

#ifdef__cplusplus

extern "C" {

#endif

7-bit slave address for TP IIC

#define TP_SLAVEADDR 0x38

#define TOUCH1_XH 0x03

#define TOUCH1_XL 0x04

#define TOUCH1_YH 0x05

#define TOUCH1_YL 0x06

#define Id_g_mode 0XA4

extern void Tp_reset (void);

extern void Tp_init (void);

extern int tp_writebytes (unsigned char writeaddr,

unsigned char *pdata, int Length);

extern int tp_readbytes (unsigned char readaddr,

unsigned char *pdata, int Length);

extern volatile unsigned char tp_press;

#ifdef__cplusplus

}

#endif

#endif/*__tp_ft5206_h__*/

Touch the line effect simultaneously with your fingers:

3. Appendix

Touchpanel_gcc.rar, five-point touch line capacitive screen GCC test project

http://pan.baidu.com/s/1i37NU2x

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.