步步高vivoy133在哪里调触摸

1077人阅读
触摸屏驱动程序设计
触摸屏工作原理:
四线电阻屏结构上如图,是在玻璃或丙稀酸基板上覆盖两层均匀导电的层,分别作为电极和电极,他们之间由均匀排列的透明格点分来绝缘。电极和电极的正负端由导电线(黑色粗体线)从两端引出,引出
当接触触摸屏表面并施加压力时,上层的导电层和下层的导电层发生接触,形成上面右图的等效电路。
坐标计算:
在加驱动电压,接地。作为引出端测量接触点的电压,由于层均匀导电,触电电压与电压之比等于坐标与屏高度之比。
坐标计算:
在加驱动电压电压,接地。作为引出端测量接触点的电压,由于层均匀导电,触点电压与电压比等于坐标与屏宽度之比。
x=Vy/ V-driv * width
触摸屏工作流程(理解好这几步流程,代码至少能看懂)
设置触摸屏接口为等待中断模式,等待触摸屏被按下。
如果中断()发生,选择坐标转换模式(坐标分别转换模式,坐标自动转换),启动转换。
当转换完后,通过中断()获取坐标,
设置触摸屏接口为等待中断模式,等待触摸笔离开触摸屏。
返回步骤,等待下次触摸笔被按下。
GLOBAL_CLK
#include &stdlib.h&
#include &string.h&
#include &def.h&
#include &option.h&
#include &2440addr.h&
#include &2440lib.h&
#include &2440slib.h&
#include &mmu.h&
#include &profile.h&
#include &memtest.h&
#define ADC_FREQ 2500000
//#define ADC_FREQ
int count = 0;
volatile U32 preS
int xdata,
void Test_Touchpanel(void);
static void __irq AdcTsAuto(void);
static void cal_cpu_bus_clk(void);
void Set_Clk(void);
/*************************************************
Function name: delay
Description
: 延时函数
Autor & date : Daniel
**************************************************/
void delay(int times)
for(i=0;i&i++)
for(j=0;j&400;j++);
/*************************************************
Function name: Main
Description
: 主功能函数
Autor & date : Daniel
**************************************************/
int Main(void)
int Scom=0;
MMU_Init();
Set_Clk();
Uart_Init(0,115200);
Uart_Select(Scom);
// Uart_Printf(&\nHello World!\n&);
Test_Touchpanel();
/*************************************************
Function name: Test_Touchpanel
Description
: 触摸屏初始化
Autor & date : Daniel
**************************************************/
void Test_Touchpanel(void)
rADCDLY=50000;
//Normal conversion mode delay about (1/3.6864M)*ms
/*设置AD转频率*/
preScaler = ADC_FREQ;
Uart_Printf(&ADC conv,freq. = %dHz\n&,preScaler);
preScaler = /ADC_FREQ - 1; //PCLK=50M
rADCCON = (1&&14)|(preScaler&&6); //ADCPRS En,PRSCVL
// rADCCON=(1&&14)+(preScaler&&6);
//ADCPRS En, ADCPRS Value
Uart_Printf(&ADC touch screen test\n&);
/*设置触摸屏为等待中断模式,等待触摸笔被按下*/
rADCTSC=0xd3;
//Wfait,XP_PU,XP_Dis,XM_Dis,YP_Dis,YM_En
/*clear irq*/
//ClearPending(BIT_ADC);
rSRCPND = 0x;
rINTPND = 0x;
ClearSubPending(BIT_SUB_TC);
pISR_ADC = (U32)AdcTsA
/*enable INT_TC irq*/
//EnableIrq(BIT_ADC);
rINTMSK = 0x7//允许中断
EnableSubIrq(BIT_SUB_TC);
/*************************************************
Function name: AdcTsAuto
Description
: 中断服务程序
Autor & date : Daniel
**************************************************/
static void __irq AdcTsAuto(void)
/****************stylus down************************/
/*检测子中断源,判断是否是INT_TC中断,且触摸笔按下*/
if(rSUBSRCPND & (BIT_SUB_TC))//产生中断
if( !(rADCDAT0&0x8000))//按下产生的中断
Uart_Printf(&\nStylus down\n&);
//抬起产生的中断
Uart_Printf(&\nStylus up\n&);
/*pull-up disable,自动连续X,Y坐标转换*/
rADCTSC = (1&&3)|(1&&2);
saveAdcdly=rADCDLY;
rADCDLY=40000;
//Normal conversion mode delay about (1/50M)*ms
/*开始AD转换*/
rADCCON|=0x1;
//start ADC
while(rADCCON & 0x1);
//check if Enable_start is low
while(!(rADCCON & 0x8000));//转换是否结束
//check if EC(End of Conversion) flag is high, This line is necessary~!!
while(!(rSRCPND & 0x));
//check if ADC is finished with interrupt bit
/*获取X,Y坐标*/
xdata=(rADCDAT0&0x3ff);
ydata=(rADCDAT1&0x3ff);
ClearSubPending(BIT_SUB_TC);
//ClearPending(BIT_ADC);
rSRCPND = 0x;
rINTPND = 0x;
EnableSubIrq(BIT_SUB_TC);
//EnableIrq(BIT_ADC);
rINTMSK = 0x7
/****************stylus down************************/
/****************stylus up**************************/
/*设置触摸屏为等待中断模式,等待触摸笔抬起*/
rADCTSC =0xd3;
//Waiting for interrupt
rADCTSC=rADCTSC|(1&&8); // Detect stylus up interrupt signal.
//to check Pen-up state
if(rSUBSRCPND & (BIT_SUB_TC))
//check if ADC is finished with interrupt bit
Uart_Printf(&Stylus Up Interrupt~!\n&);
//if Stylus is up(1) state
/****************stylus up**************************/
Uart_Printf(&count=%03d
XP=%04d, YP=%04d\n&, count++, xdata, ydata);
rADCDLY=saveA
/*设置触摸屏为等待中断模式,等待下次触摸笔按下*/
rADCTSC =0xd3;
//Waiting for interrupt
ClearSubPending(BIT_SUB_TC);
//ClearPending(BIT_ADC);
rSRCPND = 0x;
rINTPND = 0x;
EnableSubIrq(BIT_SUB_TC);
//EnableIrq(BIT_ADC);
rINTMSK = 0x7
/*************************************************
Function name: Set_Clk()
Description
: 设置CPU的时钟频率
Autor & date : Daniel
**************************************************/
void Set_Clk(void)
U32 mpll_val = 0 ;
//don't use 100M!
//boot_params.cpu_clk.val = 3;
switch ( i ) {
mpll_val = (92&&12)|(4&&4)|(1);
mpll_val = (67&&12)|(1&&4)|(1);
mpll_val = (92&&12)|(1&&4)|(1);
mpll_val = (102&&12)|(1&&4)|(1);
mpll_val = (92&&12)|(1&&4)|(1);
//init FCLK=400M, so change MPLL first
ChangeMPllValue((mpll_val&&12)&0xff, (mpll_val&&4)&0x3f, mpll_val&3);
//set the register--rMPLLCON
ChangeClockDivider(key, 12);
//the result of rCLKDIVN [0:1:0:1] 3-0 bit
cal_cpu_bus_clk();
//HCLK=100M
/*************************************************
Function name: cal_cpu_bus_clk
Description
: 设置PCLK\HCLK\FCLK的频率
Autor & date : Daniel
**************************************************/
static void cal_cpu_bus_clk(void)
static U32 cpu_
static U32 UPLL;
val = rMPLLCON;
m = (val&&12)&0
p = (val&&4)&0x3f;
s = val&3;
//(m+8)*FIN*2 不要超出32位数!
FCLK = ((m+8)*(FIN/100)*2)/((p+2)*(1&&s))*100;
//FCLK=400M
val = rCLKDIVN;
m = (val&&1)&3;
p = val&1;
val = rCAMDIVN;
s = val&&8;
switch (m) {
HCLK = FCLK;
HCLK = FCLK&&1;
HCLK = FCLK&&3;
HCLK = FCLK&&2;
HCLK = FCLK/6;
HCLK = FCLK/3;
PCLK = HCLK&&1;
PCLK = HCLK;
if(s&0x10)
cpu_freq = HCLK;
cpu_freq = FCLK;
val = rUPLLCON;
m = (val&&12)&0
p = (val&&4)&0x3f;
s = val&3;
UPLL = ((m+8)*FIN)/((p+2)*(1&&s));
UCLK = (rCLKDIVN&8)?(UPLL&&1):UPLL;
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:213427次
积分:3289
积分:3289
排名:第4006名
原创:116篇
转载:21篇
评论:67条
(2)(7)(3)(3)(1)(4)(5)(6)(2)(1)(4)(5)(5)(15)(36)(31)(7)vivoy13手机触屏校准在哪_百度知道
vivoy13手机触屏校准在哪
我有更好的答案
按默认排序
百度你手机的工程模式,在你手机拨号界面输入
其他类似问题
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁

我要回帖

更多关于 vivoy13刷机教程 的文章

 

随机推荐