微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > MTK75平台TP中断处理分析

MTK75平台TP中断处理分析

时间:10-02 整理:3721RD 点击:
以GT811为例:
1,首先开启一个线程来专门处理中断之后过来的数据。
thread = kthread_run(touch_event_handler, 0, TPD_DEVICE);
touch_event_handler就是专门处理数据的线程函数。
2,当中断触发会跑到中断处理函数。
static void tpd_eint_interrupt_handler(void)
{
    //TPD_DMESG( "TPD interrupt!\n" );
    TPD_DEBUG_PRINT_INT;
    tpd_flag=1;
    wake_up_interruptible(&waiter);
}
中断处理函数中对于大量数据,一般都不自己处理(所以就会分为中断上下部),而是分给专用的线程来处里。
3,在touch_event_handler的线程函数中,当有中断到来会如下处理:
wait_event_interruptible(waiter, tpd_flag != 0);
如果tpd_flag = 0,且没有中断,处理数据的线程就会阻塞,如果tpd_flag=1,且有wake_up_interruptible(&waiter);
线程就会继续下去取数据和解析数据。

在touch_event_handler函数中如下代码:
static int touch_event_handler(void *unused)
{
    struct sched_param param = { .sched_priority = RTPM_PRIO_TPD };
    u8  point_data[34];
    u8  check_sum = 0;
    u8  point_index = 0;
    u8  point_tmp = 0;
    u8  touch_num = 0;
   
    sched_setscheduler(current, SCHED_RR, &param);
    do
    {
        set_current_state(TASK_INTERRUPTIBLE);
        while ( tpd_halt )
        {
            tpd_flag = 0;
            msleep(20);
        }
        wait_event_interruptible(waiter, tpd_flag != 0);
        tpd_flag = 0;
        TPD_DEBUG_SET_TIME;
        set_current_state(TASK_RUNNING);
//==========================================================================================================        
               i2c_read_bytes( i2c_client, TPD_TOUCH_INFO_REG_BASE, point_data, 34);
                    if(point_data[0]&0x20)
                    {
                        if(point_data[1]==0xF0)
                        {
                            i2c_write_bytes( client, TPD_CONFIG_REG_BASE, cfg_data, CONFIG_LEN );
                            continue;
                        }
                    }
   
                    point_index = point_data[0]&0x1f;
                    point_tmp = point_index;
                   
                    for(position=0; (position<GTP_MAX_TOUCH)&&point_tmp; position++)
                    {
                        if(point_tmp&0x01)
                        {
                            track_id[touch_num++] = position;
                        }
                        point_tmp >>= 1;
                    }
                   
                    point_num = position;
    } while ( !kthread_should_stop() );
    return 0;
}

以上述函数中的touch_num这个变量为例,在函数开始touch_num = 0;当有触摸中断触发时touch_num会增加根据你触摸的点数,当你不断的有中断上来时touch_num不再跑touch_num = 0赋值操作而是接着上次的touch_num递增知道溢出。为什么会这样呢?还请大家指教一下啊

哥们有没有驱动的串口工具分享一个。 我在搞75,想抓tp的报点数据,用的串口工具是securecrt,我down函数里面加了log,就是打印不到,摸着触摸屏是有反应的。

用adb 的 getevent -lt 即可

static int tpd_detect (struct i2c_client *client, struct i2c_board_info *info){
    strcpy(info->type, TPD_DEVICE);
    return 0;
}
兄弟,在TP驱动中,我一直不太明白这个函数的作用,能给解释一下吗?

进来学习了

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

网站地图

Top