This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM3358: aerial touchscreen

Part Number: AM3358


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 :

  1. #define SERIO_ANY   0xff  
  2. #define SERIO_MD    0x3f  
  3.   
  4. int main(int argc, char* argv[])  
  5. {  
  6.     int dev,ret;  
  7.     char comdev[20];  
  8.     int ldisc;  
  9.     unsigned long type;  
  10.     struct termios option;  
  11.     int fd = -1;  
  12.     if(argc != 2)  
  13.     {  
  14.         printf("-----------------------------------------\n");  
  15.         printf("\nUsage: %s [serial device(1-5)]\n", argv[0]);  
  16.         printf("Example: %s 5 n", argv[0]);  
  17.         printf("-----------------------------------------\n");  
  18.         return 0;  
  19.     }  
  20.   
  21.     dev = strtol(argv[1],NULL,10);  
  22.     sprintf(comdev,"/dev/ttyAMA%d",dev);  
  23.     fd = open(comdev,O_RDWR|O_NONBLOCK|O_NOCTTY);  
  24.     if (fd < 0) {  
  25.         perror(comdev);  
  26.         exit(1);  
  27.     }  
  28.       
  29.     tcgetattr(fd, &option);  
  30.     option.c_iflag = IGNPAR | IGNBRK;  
  31.     option.c_cflag = HUPCL | CS8 | CREAD | CLOCAL | B9600;  
  32.     option.c_cc[VMIN] = 1;  
  33.     option.c_cc[VTIME] = 0;  
  34.       
  35.     cfsetispeed(&option,B9600);  
  36.     cfsetospeed(&option,B9600);  
  37.   
  38.     ret = tcsetattr(fd, TCSANOW, &option);  
  39.     if(ret < 0) {  
  40.         perror("TCSANOW");  
  41.         exit(1);  
  42.     }  
  43.   
  44.     ldisc = N_MOUSE;  
  45.     ret = ioctl(fd,TIOCSETD,&ldisc);  
  46.     if(ret) {  
  47.         perror("TIOCSETD");  
  48.     }  
  49.     type = SERIO_MD | (SERIO_ANY << 8) | (SERIO_ANY << 16);  
  50.     ret = ioctl(fd,SPIOCSTYPE, &type);  
  51.     if(ret) {  
  52.         perror("SPIOCSTYPE");  
  53.     }  
  54.     read(fd,NULL,0);  
  55.     //close(fd);  
  56.     return 0;  
  57. }  

But the return ioctl(fd, TIOCSETD,&ldisc) and ioctl(fd, SPIOCSTYPE,&type) all is -1.

Please suppport me as soon sa possible! Thankyou!