Tool/software: Linux
MCU:AM3358 + SDK6.0
I want how can I drive one serial touchscreen . Refered some documents, I changed the data frame of toucgit213.c and write one code which working in userspace.
Just like this :
- #define SERIO_ANY 0xff
- #define SERIO_MD 0x3f
- int main(int argc, char* argv[])
- {
- int dev,ret;
- char comdev[20];
- int ldisc;
- unsigned long type;
- struct termios option;
- int fd = -1;
- if(argc != 2)
- {
- printf("-----------------------------------------\n");
- printf("\nUsage: %s [serial device(1-5)]\n", argv[0]);
- printf("Example: %s 5 n", argv[0]);
- printf("-----------------------------------------\n");
- return 0;
- }
- dev = strtol(argv[1],NULL,10);
- sprintf(comdev,"/dev/ttyAMA%d",dev);
- fd = open(comdev,O_RDWR|O_NONBLOCK|O_NOCTTY);
- if (fd < 0) {
- perror(comdev);
- exit(1);
- }
- tcgetattr(fd, &option);
- option.c_iflag = IGNPAR | IGNBRK;
- option.c_cflag = HUPCL | CS8 | CREAD | CLOCAL | B9600;
- option.c_cc[VMIN] = 1;
- option.c_cc[VTIME] = 0;
- cfsetispeed(&option,B9600);
- cfsetospeed(&option,B9600);
- ret = tcsetattr(fd, TCSANOW, &option);
- if(ret < 0) {
- perror("TCSANOW");
- exit(1);
- }
- ldisc = N_MOUSE;
- ret = ioctl(fd,TIOCSETD,&ldisc);
- if(ret) {
- perror("TIOCSETD");
- }
- type = SERIO_MD | (SERIO_ANY << 8) | (SERIO_ANY << 16);
- ret = ioctl(fd,SPIOCSTYPE, &type);
- if(ret) {
- perror("SPIOCSTYPE");
- }
- read(fd,NULL,0);
- //close(fd);
- return 0;
- }
But the return ioctl(fd, TIOCSETD,&ldisc) and ioctl(fd, SPIOCSTYPE,&type) all is -1.
Please suppport me as soon sa possible! Thankyou!