天嵌 ARM开发社区

 找回密码
 注册
12
返回列表 发新帖
楼主: jamesjoo

在UCOSII中整合TEST2440中触摸屏模块的问题

[复制链接]
chenenzhi 发表于 2010-5-15 12:16:13 | 显示全部楼层
已经知道是原因了,查看http://hi.baidu.com/chenenzhi/bl ... 77dad5f3d385f1.html
亚瑟王 发表于 2010-5-18 11:59:01 | 显示全部楼层
好帖子啊。
Andornotlee 发表于 2011-3-25 15:06:57 | 显示全部楼层
我的也要死机,好像是要什么保存寄存内容,不然程序就回不到ucos了,但我对汇编语言不懂
pofeng110 发表于 2011-4-30 18:47:44 | 显示全部楼层
/*****************************************
  NAME: Touchpanel.c
  DESC: ADC & Touch screen test
*****************************************/
#include "config.h"


#define REQCNT 30

#define LOOP 1
#define ADCPRS 0x27
int TX=0;//触摸坐标x
int TY=0;//触摸坐标y

int isDown;
volatile int touch_over = 0;

int count=0;
U32 Pt[6];
U16 diffx, diffy;
U16 errx1, erry1,errx2, erry2;

extern OS_EVENT *TouchMbox;

static void TSIrqISR(void);


int calibration(void)
{

//        Lcd_ClearScr( (0x1f<<11) | (0x3f<<5) | (0x1f)  )  ;//白屏
    /* 获取左上角基准点 */
//    DrawLine(   0,  19,  39, 19, 0);
//    DrawLine(  19,   0,  19, 39, 0);//十字叉

    touch_over = 0;
    while(!touch_over);//if not touch over,wait
//    DrawLine(   0,  19,  39, 19, 0xffff);
//    DrawLine(  19,   0,  19, 39, 0xffff);//清十字叉
    if( (TX<855) && (TX>810) && (TY<170) && (TY>115) )
    {
        errx1 = TY;
            erry1 = TX;//基准点坐标
    }
    else
    {
        return(0);
    }

    /* 获取右下角基准点 */
//   DrawLine( 279, 219, 319, 219, 0);
//   DrawLine( 299, 199, 299, 239, 0);

    touch_over = 0;
    while(!touch_over);//if not touch over,wait
//    DrawLine( 279, 219, 319, 219, 0xffff);
//    DrawLine( 299, 199, 299, 239, 0xffff);//清十字叉
    if( (TX<200) && (TX>145) && (TY<916) && (TY>869) )
    {
        errx2 = TY;
            erry2 = TX;//基准点坐标
    }
    else
    {
        return(0);
    }
    diffx = errx2 - errx1;
    diffy = erry1 - erry2;
    return (1);       
}



void SetTSInterrupt(void)
{
    rADCDLY = (50000);
    rADCCON = (1<<14)|(ADCPRS<<6)|(7<<3)|(0<<2)|(0<<1)|(0);
      rADCTSC = (0<<8)|(1<<7)|(1<<6)|(0<<5)|(1<<4)|(0<<3)|(0<<2)|(3);
    pISR_ADC = (U32)TSIrqISR; //
    rINTMSK &= ~(BIT_ADC);
    rINTSUBMSK &= ~(BIT_SUB_TC);
OSPrintf("\nTouch Initing.. !\n");     
}


static void TSIrqISR(void)
{
    int i;
   
    rINTSUBMSK |= (BIT_SUB_ADC|BIT_SUB_TC);
        if(rADCDAT0 & 0x8000)
    {//抬起
                isDown = 0;
                rADCTSC &= 0xff;    // Set stylus down interrupt
                TX = -1;
                TY = -1; //抬起触笔时,TX,TY要值成不大于0的数
    }
    else //按下
    {          isDown = 1;
        rADCTSC=(0<<8)|(0<<7)|(0<<6)|(1<<5)|(1<<4)|(1<<3)|(0<<2)|(1);
        for(i=0;i<LOOP;i++);            //delay to set up the next channel
        for(i=0;i<5;i++)                           //5 times
        {
                        rADCCON|=0x1;               // Start X-position conversion
                        while(rADCCON & 0x1);       // Check if Enable_start is low
                        while(!(0x8000&rADCCON));   // Check ECFLG
                        Pt[i]=(0x3ff&rADCDAT0);
                }
                Pt[5]=(Pt[0]+Pt[1]+Pt[2]+Pt[3]+Pt[4])/5;//多次采样取平均值
                TX = Pt[5];
                rADCTSC=(0<<8)|(0<<7)|(1<<6)|(1<<5)|(0<<4)|(1<<3)|(0<<2)|(2);
                for(i=0;i<LOOP;i++);            //delay to set up the next channel
                for(i=0;i<5;i++)                           //5 times
                {
                        rADCCON|=0x1;               // Start Y-position conversion
                        while(rADCCON & 0x1);       // Check if Enable_start is low
                        while(!(0x8000&rADCCON));   // Check ECFLG
                        Pt[i]=(0x3ff&rADCDAT1);
        }
                Pt[5]=(Pt[0]+Pt[1]+Pt[2]+Pt[3]+Pt[4])/5;// 多次采样取平均值

                TY = Pt[5];
                rADCTSC=(1<<8)|(1<<7)|(1<<6)|(0<<5)|(1<<4)|(0<<3)|(0<<2)|(3);
        }
    //cprintf("%d,%d\n",TX,TY);
       //OSMboxPost(TouchMbox, 0);//向处理触摸进程发消息
        if(rSUBSRCPND & (BIT_SUB_TC))        //check if ADC is finished with interrupt bit
        {
                touch_over = 1;//gshx_2010_7_11
        }
      
    rSUBSRCPND |= BIT_SUB_TC;
    rINTSUBMSK &= ~(BIT_SUB_TC);         // Unmask sub interrupt (TC)     
    ClearPending(BIT_ADC);      
}
pofeng110 发表于 2011-4-30 18:49:34 | 显示全部楼层
我的添加触摸屏中断也是死掉,上面那个是网上看到的,现在没有死机了。
w285868925 发表于 2011-11-14 10:35:02 | 显示全部楼层
我的刚调好  交流qq285868925
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号-2 )

GMT+8, 2024-10-6 22:22 , Processed in 1.035196 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表