S5PV210(TQ210)學(xué)習(xí)筆記——觸摸屏驅(qū)動編寫
一 觸控芯片分析
首先,卸下觸摸屏的四個螺絲并翻過觸摸屏來觀察,可以在在觸摸屏排線上看到觸控芯片,仔細觀察芯片型號(如果看不清可以用放大鏡配合手電筒觀看),我們可以看到,TQ210的觸摸屏控制芯片是GT811,然后我找到了GT811的芯片手冊(這些資料都上傳到了我的CSDN資源里,請您支持一下),有了手冊,編寫驅(qū)動就不難了。
本文引用地址:http://m.butianyuan.cn/article/201611/322810.htmGT811引出了6根腳,分別是VCC、GND、I2CSDA、I2CSCL、INT和RESET,雖然INT腳不是必須的,但是開發(fā)高效省資源的觸屏驅(qū)動程序往往都采用中斷方式,下面是GT811的引腳圖:
我用萬能表實際測量了一下觸控模塊的各個引腳,實際線序是GND、SDA、SDL、INT、RESET和VDD。GT811的初始化順序如下:
- (1)初始化INT腳為懸浮輸入態(tài)并初始化RESET腳為輸出態(tài),并輸出低電平
- (2)延時1ms
- (3)初始化RESET腳為懸浮輸入態(tài),并使能上拉
- (4)寫入GT811寄存器配置表
- (5)根據(jù)需要配置INT腳
二 I2C驅(qū)動編寫
I2C驅(qū)動也是基于總線結(jié)構(gòu)的,不過分為兩種,一種是Legacy方式,另一種是New Style方式,其中,Legacy方式在新內(nèi)核中已經(jīng)不支持了,不過韋東山老師的視頻中還是分析的Legacy方式,New Style方式你可以自己用Source Insight追蹤分析一下,我這里就不多說了,具體的可以參考下面的代碼。
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- conststaticunsignedshortnormal_address[]={0x5d,I2C_CLIENT_END};
- staticunsignedgt811_rst;
- staticunsignedgt811_int;
- staticstructinput_dev*ts_input;
- staticstructworkqueue_struct*wq;
- staticstructwork_structwork;
- staticstructi2c_client*this_client=NULL;
- staticunsignedintstatus=0;
- staticinti2c_read_bytes(structi2c_client*client,uint8_t*buf,intlen)
- {
- structi2c_msgmsgs[2];
- intret=-1;
- msgs[0].flags=!I2C_M_RD;
- msgs[0].addr=client->addr;
- msgs[0].len=2;
- msgs[0].buf=&buf[0];
- msgs[1].flags=I2C_M_RD;
- msgs[1].addr=client->addr;
- msgs[1].len=len-2;
- msgs[1].buf=&buf[2];
- ret=i2c_transfer(client->adapter,msgs,2);
- returnret;
- }
- staticinti2c_write_bytes(structi2c_client*client,uint8_t*data,intlen)
- {
- structi2c_msgmsg;
- intret=-1;
- msg.flags=!I2C_M_RD;
- msg.addr=client->addr;
- msg.len=len;
- msg.buf=data;
- ret=i2c_transfer(client->adapter,&msg,1);
- returnret;
- }
- staticconststructi2c_device_idts_id[]={
- {"tq210-ts",0},
- {}
- };
- staticintts_init_panel(structi2c_client*client){
- shortret=-1;
- uint8_tconfig_info[]={
- 0x06,0xA2,
- 0x12,0x10,0x0E,0x0C,0x0A,0x08,0x06,0x04,0x02,0x00,0xE2,0x53,0xD2,0x53,0xC2,0x53,
- 0xB2,0x53,0xA2,0x53,0x92,0x53,0x82,0x53,0x72,0x53,0x62,0x53,0x52,0x53,0x42,0x53,
- 0x32,0x53,0x22,0x53,0x12,0x53,0x02,0x53,0xF2,0x53,0x0F,0x13,0x40,0x40,0x40,0x10,
- 0x10,0x10,0x0F,0x0F,0x0A,0x35,0x25,0x0C,0x03,0x00,0x05,0x20,0x03,0xE0,0x01,0x00,
- 0x00,0x34,0x2C,0x36,0x2E,0x00,0x00,0x03,0x19,0x03,0x08,0x00,0x00,0x00,0x00,0x00,
- 0x14,0x10,0xEC,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0D,0x40,
- 0x30,0x3C,0x28,0x00,0x00,0x00,0x00,0xC0,0x12,0x01
- };
關(guān)鍵詞:
S5PV210觸摸屏驅(qū)動編
評論