[Cortex-M0技术交流] 酱油贴!arm9+ linux的基础贴

[复制链接]
2260|2
 楼主| kyzb001 发表于 2012-2-1 10:29 | 显示全部楼层 |阅读模式

  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <fcntl.h>
  4. #include <termios.h>
  5. #include <errno.h>
  6. #include <ctype.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <time.h>
  11. #include <unistd.h>
  12. #include"pthread.h"
  13. #include <sys/ioctl.h>
  14. //#include "serial_test.h"
  15. int main()
  16. {
  17.     int led_on;
  18.     int led_num;
  19.     char arge[3];
  20.     int uart_fd;
  21.     int led_fd;
  22.     int beep_fd;
  23.     beep_fd=open("/dev/PWM-Test",0);
  24.     uart_fd=open("/dev/tq2440_serial0",O_RDWR,0);
  25.     led_fd=open("/dev/GPIO-Control",0);
  26.     if((beep_fd&&uart_fd&&led_fd)<0)
  27.     {
  28.         perror("Open device fail");
  29.         exit(1);
  30.     }
  31.     write(uart_fd,"uart control leds\n",18);
  32.     while(1)
  33.     {
  34.         read(uart_fd,arge,2);
  35.         write(uart_fd,arge,2);
  36.         if(arge[0]>0x31||arge[0]<0x30&&arge[1]>0x33||arge[1]<0x30)
  37.         {
  38.             ioctl(beep_fd,1,10);
  39.             usleep(500000);
  40.             ioctl(beep_fd,0);
  41.         }
  42.         ioctl(led_fd,(arge[0]-48),(arge[1]-48));
  43.    }
  44. // printf("The number is:%d\n",arge[0]);
  45.    close(uart_fd);
  46.    close(led_fd);
  47.    close(beep_fd);
  48. }



串口取数字,点亮LED灯,取值出错蜂鸣器响一下!
hotpower 发表于 2012-2-1 17:36 | 显示全部楼层
晕!菜婆N97打酱油!菜农爱疯饮水思源!原来都是此帖作怪?
 楼主| kyzb001 发表于 2012-2-2 16:35 | 显示全部楼层
2# hotpower

大叔,这你就错怪俺了, 我正在致力于linux的m0 移植。:lol

这就要学linux编程了哇!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:Is this my life

15

主题

624

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部