微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > mt2503使用YP当做ADC使用

mt2503使用YP当做ADC使用

时间:10-02 整理:3721RD 点击:
[DESCRIPTION]
HW上提供的ADC不够用,需要开辟其它通道
[SOLUTION]
在不适用触摸的情况下可以使用触摸屏接口YP当ADC。
电路如下:


sample code:
#include "ts_hw.h"
#include "dcl.h"
#include "GPT_sw.h"
#include "kal_general_types.h"
#include "kal_public_api.h"
#include "kal_public_defs.h"
typedef void (*READ_ADC_FROM_TS_TIMER_CB)(void* parameter) ;
// IsPressure == flase --> get 7 times and average ; IsPressure == true --> get 1 times
extern kal_uint16 ts_read_adc(kal_uint16 pos,kal_bool IsPressure);
kal_uint32 read_adc_from_ts_polling_timer_handler;
void read_adc_from_ts_set_timer(kal_uint32 handle, READ_ADC_FROM_TS_TIMER_CB cb, kal_uint32 tick);
void read_adc_from_ts_timer_cb(void *parameter);
void read_adc_from_ts_start_timer(void);
void read_adc_from_ts_init(void);
kal_uint16 read_adc_from_ts(void)
{
return ts_read_adc(TS_CMD_ADDR_X,KAL_TRUE);
}
// following code is start a timer and polling the adc value form ts
void read_adc_from_ts_set_timer(kal_uint32 handle, READ_ADC_FROM_TS_TIMER_CB cb, kal_uint32 tick)
{
SGPT_CTRL_START_T start;
start.pfCallback=(void(*)(void*))cb;
start.vPara=NULL;
start.u2Tick=tick;
DclSGPT_Control(handle,SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
}
void read_adc_from_ts_timer_cb(void *parameter)
{
kal_uint16 ts_adc_value;
ts_adc_value = read_adc_from_ts();
kal_prompt_trace(MOD_DRVKBD,"adc val:%x",ts_adc_value);
// do someting ...
read_adc_from_ts_start_timer();
}
void read_adc_from_ts_start_timer(void)
{
read_adc_from_ts_set_timer(read_adc_from_ts_polling_timer_handler,read_adc_from_ts_timer_cb,1000); //timer:10s
}
void read_adc_from_ts_init(void)
{
read_adc_from_ts_polling_timer_handler=DclSGPT_Open(DCL_GPT_CB,0);
read_adc_from_ts_start_timer();
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top