S3C6410触摸屏中断问题
时间:10-02
整理:3721RD
点击:
void AdcTs_Init(u32 channel, u32 freq)
{
u32 preScaler;
ADCTS->rADCDLY = 50000; //Normal conversion mode delay about (1/3.6864M)*50000=13.56ms
//设置ADC转换频率以及通道
preScaler = g_PCLK/freq -1;
ADCTS->rADCCON = (1<<14)|(preScaler<<6)|(channel<<3);
//设置触摸屏为等待中断模式,查手册等待中断模式为0xd3
ADCTS->rADCTSC = 0xd3;
//中断悬起
AdcTsIntClr();
//写中断函数地址
Outp32(rVIC1VECTADDR+4*(NUM_PENDNUP-32), (unsigned)Isr_ADCTS);
Outp32(rVIC1VECTADDR+4*(NUM_ADC-32), (unsigned)Isr_ADCTS);
//中断使能
Vic1_IntEnable(NUM_PENDNUP);
Vic1_IntEnable(NUM_ADC);
return;
}
*触摸屏中断函数
* */
void __irq Isr_ADCTS(void)
{
u32 saveAdcdly;
//判断是按下中断还是弹起中断,此处只有触摸屏中断,
//故进入中断函数后不进行中断源的判断
if(ADCTS->rADCUPDN & 0x2)
{
Uart_Printf("\nStylus down\n");
ADCTS->rADCUPDN &= ~(1<<1);
}
else
Uart_Printf("\nStylus up\n");
//上拉除能,自动连续X,Y坐标转换,中断信号产生后,设置XY_PST位为无操作模式
ADCTS->rADCTSC = ((1<<2)|(1<<3))&(0x1fc);
saveAdcdly = ADCTS->rADCDLY;
ADCTS->rADCDLY = 40000; //Normal conversion mode delay about (1/50M)*40000=0.8ms
//开始ADC转换并读取
Adc_Read();
//中断悬起
AdcTsIntClr();
//设置触摸屏为等待中断模式,等待触摸笔抬起
ADCTS->rADCTSC = 0xd3;
while(1)
{
if(ADCTS->rADCUPDN & 0x1)
{
Uart_Printf("\nStylus Up\n");
ADCTS->rADCUPDN &= ~(1<<0);
break;
}
}
//串口打印XY坐标信息
Uart_Printf("XP=%04d, YP=%04d\n", xdata, ydata);
//设置触摸屏为等待中断模式,等待下一次的中断
ADCTS->rADCDLY = saveAdcdly;
ADCTS->rADCTSC = 0xd3;
//中断悬起
AdcTsIntClr();
//清除中断服务函数的地址
Outp32(rVIC0ADDR, 0);
Outp32(rVIC1ADDR, 0);
}运行程序后进入不了中断