⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adc.c

📁 S3C2440A + ADS 控制触摸屏 的驱动
💻 C
字号:
#include "adc.h"
#include "key.h"
#include  "2440addr.h"
#include "uart.h"
#include "led.h"

int x_value;
int y_value;

void Adc_Eint(void)
{

		rADCCON = ((1<<14)|(6<<6)|(0x0<<3)|(0x0));
				
		rADCTSC = ((3<<6)|(0<<5)|(1<<4)|(0<<3)|(0<<2)|(3));
		//rADCTSC = ((0<<7)|(1<<6)|(0<<5)|(1<<4)|(0<<3)|(0<<2)|(3));
			
		rADCDLY = 0x00ff; 
		rADCTSC=rADCTSC&~(1<<8); 	
	    pISR_ADC = (int)Adc;

		rSRCPND |= BIT_ADC; //to clear the previous pending states

		rINTPND |= BIT_ADC;	//to clear the previous rINTPND states

		rINTMSK &= ~BIT_ADC;
       

		rSUBSRCPND |= INT_TC;  //interrupt request		
		rINTSUBMSK &= ~INT_TC;

		

}





void __irq Adc(void)
{
   


   rADCTSC |= (1<<2);  //Auto Sequential measurement of X-position, Y-position

   rADCCON |= (1<<0);  //A/D conversion starts and this bit is cleared after the start-up

   while(!(rADCCON &ECFLG));  //checking the ADCCON[15] - end of conversion flag-bit
    
   x_value = (rADCDAT0&0x3ff);  //get rADCDAT0(0~9)bit value
   y_value = (rADCDAT1&0x3ff);  //get rADCDAT1(0~9)bit value
   
   //rSRCPND &= ~(BIT_ADC); 
   rSRCPND |=  (BIT_ADC);
     
   //rINTPND &= ~(BIT_ADC);
   rINTPND |=  (BIT_ADC);

   //rSUBSRCPND &= ~(INT_TC);
   rSUBSRCPND |= (INT_TC);
   
   rADCTSC = ((3<<6)|(0<<5)|(1<<4)|(0<<3)|(0<<2)|(3));
   //rADCTSC = ((0<<7)|(1<<6)|(0<<5)|(1<<4)|(0<<3)|(0<<2)|(3));
   
   rADCTSC |= (1<<8);

  
 
   while(!(rADCUPDN&TSC_UP));
  
   Uart_Printf("the point x_value is %d\n",x_value);
   Uart_Printf("the point y_value is %d\n",y_value);

   //rSUBSRCPND &= ~(INT_TC);
   rSUBSRCPND |= (INT_TC);
  
   //rSRCPND &= ~(BIT_ADC); 
   rSRCPND |=  (BIT_ADC);
     
   //rINTPND &= ~(BIT_ADC);
   rINTPND |=  (BIT_ADC);
   
   rADCCON = ((1<<14)|(6<<6)|(0x0<<3)|(0x0));
   rADCTSC=rADCTSC&~(1<<8); 


   if(x_value<512&&y_value<512)
   	{
        led1_on();
    }

   if(x_value>512&&y_value<512)
   	{
        led2_on();
    }

   if(x_value>512&&y_value>512)
   {
	   led3_on();
   }
   
   if(x_value<512&&y_value>512)
   {
	   led4_on();
   }
   
 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -