資源簡介
基于android平臺實現串口觸摸屏的功能。在RK3026 ANDROID4.2平臺上測試OK,沒任何BUG。基本功能為:MCU通過串口將觸摸屏的報點信息傳遞給平板電腦,平板電腦實現從串口得到的觸摸信息上傳到應用層。

代碼片段和文件信息
/*
?*?Copyright?(C)?2007?The?Android?Open?Source?Project
?*
?*?Licensed?under?the?Apache?License?Version?2.0?(the?“License“);
?*?you?may?not?use?this?file?except?in?compliance?with?the?License.
?*?You?may?obtain?a?copy?of?the?License?at
?*
?*??????http://www.apache.org/licenses/LICENSE-2.0
?*
?*?Unless?required?by?applicable?law?or?agreed?to?in?writing?software
?*?distributed?under?the?License?is?distributed?on?an?“AS?IS“?BASIS
?*?WITHOUT?WARRANTIES?OR?CONDITIONS?OF?ANY?KIND?either?express?or?implied.
?*?See?the?License?for?the?specific?language?governing?permissions?and
?*?limitations?under?the?License.
?*/
#define?LOG_TAG?“SerioService“
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?“SerioService.h“
#define?SERIO_DEVICE? “/dev/ttyS0“
#define?SERIO_RS232 0x02
#define?SERIO_TOUCHIT213 0x38
#define?SERIO_ANY?0xff
#define?SERIO_PROTO SERIO_TOUCHIT213
#define?SERIO_ID SERIO_ANY
#define?SERIO_EXTRA SERIO_ANY
#define?TIOCSETD_CPP??????0x5423
#define?SPIOCSTYPE 1074032897
#define?N_MOUSE_CPP 2
namespace?android?{
//?---------------------------------------------------------------------------
SerioService::SerioService(bool?shutdown)?:?Thread(false)
{
unsigned?long?ldiscdevt;
?? fd?=?open(SERIO_DEVICE?O_RDWR?|?O_NOCTTY?|?O_NONBLOCK);
if?(fd?0)?{?
fprintf(stderr?“inputattach:?‘%s‘?-?%s\n“?
SERIO_DEVICE?strerror(errno));?
return;??
}??
setline(fd?CS8?B115200);?
ldisc?=?N_MOUSE_CPP;?
if?(ioctl(fd?TIOCSETD_CPP?&ldisc))?{?
fprintf(stderr?“inputattach:?can‘t?set?line?discipline\n“);?
return;?
}??
devt?=?SERIO_PROTO?|?(SERIO_ID?<8)?|?(SERIO_EXTRA?<16);??
if?(ioctl(fd?SPIOCSTYPE?&devt))?{?
fprintf(stderr?“inputattach:?can‘t?set?device?type\n“);?
return;??
}??
read(fd?NULL?0);
}
SerioService::~SerioService()?{
}
void?SerioService::binderDied(const?wp&?who)
{
????//?woah?surfaceflinger?died!
????ALOGD(“SurfaceFlinger?died?exiting...“);
????//?calling?requestExit()?is?not?enough?here?because?the?Surface?code
????//?might?be?blocked?on?a?condition?variable?that?will?never?be?updated.
????kill(?getpid()?SIGKILL?);
????requestExit();
}
void?SerioService::setline(int?fd?int?flags?int?speed)?
{?
struct?termios?t;?
tcgetattr(fd?&t);??
t.c_cflag?=?flags?|?CREAD?|?HUPCL?|?CLOCAL;
t.c_iflag?=?IGNBRK?|?IGNPAR;?
t.c_oflag?=?0;?
t.c_lflag?=?0;??
t.c_cc[VMIN?]?=?1;?
t.c_cc[VTIME]?=?0;?
cfsetispeed(&t?speed);?
cfsetospeed(&t?speed);?
tcsetattr(fd?TCSANOW?&t);??
}??
bool?SerioService::threadLoop()
{
// read(fd?NULL?0);
????return?true;
}
//?---------------------------------
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????20198??2014-08-16?17:17??串口觸摸屏\原碼\device\rockchip\rk30sdk\init.rc
?????文件??????11587??2014-08-22?11:05??串口觸摸屏\原碼\device\rockchip\rk30sdk\init.rk30board.rc
?????文件????????382??2014-08-16?17:17??串口觸摸屏\原碼\fr
?????文件???????3069??2014-08-18?19:57??串口觸摸屏\原碼\fr
?????文件???????1397??2014-08-16?17:17??串口觸摸屏\原碼\fr
?????文件???????1313??2014-08-16?17:17??串口觸摸屏\原碼\fr
?????文件???????6400??2014-08-22?08:54??串口觸摸屏\原碼\kernel\drivers\input\serio\serport.c
?????文件???????8239??2014-08-22?08:54??串口觸摸屏\原碼\kernel\drivers\input\touchscreen\touchit213.c
?????文件??????84151??2014-08-22?08:54??串口觸摸屏\原碼\kernel\drivers\tty\tty_io.c
?????文件??????18013??2015-03-17?11:28??串口觸摸屏\補丁\uart_touch.patch
?????文件????????367??2015-03-17?11:32??串口觸摸屏\說明.txt
?????目錄??????????0??2015-03-17?11:20??串口觸摸屏\原碼\fr
?????目錄??????????0??2015-03-17?11:24??串口觸摸屏\原碼\kernel\drivers\input\serio
?????目錄??????????0??2015-03-17?11:24??串口觸摸屏\原碼\kernel\drivers\input\touchscreen
?????目錄??????????0??2015-03-17?11:22??串口觸摸屏\原碼\device\rockchip\rk30sdk
?????目錄??????????0??2015-03-17?11:20??串口觸摸屏\原碼\fr
?????目錄??????????0??2015-03-17?11:24??串口觸摸屏\原碼\kernel\drivers\input
?????目錄??????????0??2015-03-17?11:25??串口觸摸屏\原碼\kernel\drivers\tty
?????目錄??????????0??2015-03-17?11:22??串口觸摸屏\原碼\device\rockchip
?????目錄??????????0??2015-03-17?11:20??串口觸摸屏\原碼\fr
?????目錄??????????0??2015-03-17?11:25??串口觸摸屏\原碼\kernel\drivers
?????目錄??????????0??2015-03-17?11:22??串口觸摸屏\原碼\device
?????目錄??????????0??2015-03-17?11:20??串口觸摸屏\原碼\fr
?????目錄??????????0??2015-03-17?11:24??串口觸摸屏\原碼\kernel
?????目錄??????????0??2015-03-17?11:26??串口觸摸屏\原碼
?????目錄??????????0??2015-03-17?11:27??串口觸摸屏\補丁
?????目錄??????????0??2015-03-17?11:27??串口觸摸屏
-----------?---------??----------?-----??----
???????????????155116????????????????????27
............此處省略0個文件信息
評論
共有 條評論