Design of S3C2440 resistive touch screen driver

Source: Internet
Author: User

Design of S3C2440 resistive touch screen driver

Experiment: When the pen clicks on the touch screen, SecureCRT displays the X and Y coordinates of the contacts;

Objective: To test the resistance touch screen driver;

Development Board: S3C2440

 

/** All Rights Reserved (C) 2015, ZJU ** file name: ts. c * Content Abstract: Touch Screen configuration * Other Instructions: Development Board model: TX2440 * resistance screen * Current version: V1.0 * OPERATOR: Frank * completion date: 2015.12.22 **/# define ADCCON (* (volatile unsigned int *) 0x58000000) // ADC control register # define ADCTSC (* (volatile unsigned int *) 0x58000004) // ADC Touch Screen Control Register # define ADCDLY (* (volatile unsigned int *) 0x58000008) // ADC Start or interval delay register # define ADCDATA0 (* (volatile unsigned int *) 0 X5800000C) // ADC conversion data register # define ADCDATA1 (* (volatile unsigned int *) 0x58000010) // ADC conversion data register/* interrupt register */# define SRCPND (* (volatile unsigned long *) 0x4A000000) # define INTMSK (* (volatile unsigned long *) 0x4A000008) # define INTPND (* (volatile unsigned long *) 0x4A000010) # define effecffset (* (volatile unsigned long *) 0x4A000014) # define SUBSRCPND (* (volatile unsigned l Ong *) 0x4A000018) # define INTSUBMSK (* (volatile unsigned long *) 0x4A00001C) int xdata = 0; int ydata = 0; /*************************************** * **************************** Function Name: ts_Init () * Function Description: Touch Screen work initialization * Other Instructions: Configure ADC for touch screen work mode * creation date: 2015.12.22 *************************************** * ***************************/void Ts_Init (void) {/* 1. Set the adswitch clock */ADCCON = (1 <14) | (49 <6); // The adswitch frequency = PCLK/(Val + 1 ), set to 1 MHz/* 2. Interrupt shielding space */INTMSK = ~ (1 <31); INTSUBMSK = ~ (1 <9);/* 3. Enter the pending interrupt mode */ADCTSC = 0xd3;/*** clear the 7th-bit I (IRQ disable) in the CPSR register ), because in start. S to enable the total interrupt _ asm _ ("mrs r0, cpsr \ n" "bic r0, r0, r0, #0x80 \ n "" msr cpsr_c, r0 \ n "::);} /*************************************** * **************************** Function Name: ts_Handler () * Function Description: Touch Screen Interrupt Processing * Other Description: interrupt processing after the touch screen is pressed * creation date: 2015.12.22 *************************************** * **************************/void Ts_Handler (void) {/* 1. Start Automatic conversion of dynamic XY coordinates */ADCTSC = (1 <2); ADCCON | = (1 <0);/* 2. Wait until the conversion is complete */while (! (ADCCON & (1 <15);/* 3. Obtain coordinates */xdata = ADCDATA0 & 0x3ff; ydata = ADCDATA1 & 0x3ff; /* 4. Clear the press interrupt */SUBSRCPND | = (1 <9); SRCPND = (1 <31); INTPND = (1 <31 ); /* 5. Wait for the disconnection to start */ADCTSC = 0xd3; ADCTSC |=( 1 <8); while (1) {if (SUBSRCPND & (1 <9 )) break;}/* 6. Clear the pop-up interrupt */SUBSRCPND | = (1 <9); SRCPND = (1 <31); INTPND = (1 <31 ); // process the read X and Y coordinates printf ("X is % d, Y is % d \ n", xdata, ydata ); printf ("\ n \ r");/* 7. Wait for the interrupted press again */ADCTSC = 0xd3 ;}

The call program of the touch screen interrupt function in interrupt. c:

 

 

/*************************************** * **************************** Function Name: handle_int () * Function Description: Interrupt Processing Function * Other description: **************************************** * *************************/void handle_int () {/* determine the interrupt source */unsigned long value = * (Interrupt ffset); switch (value) {case 31: Ts_Handler (); // touch screen interrupt break; default: break ;}}

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.