SBC2410Deceives.rar

  • PUDN用户
    了解作者
  • C/C++
    开发工具
  • 3KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 5
    下载次数
  • 2008-11-05 20:24
    上传日期
包含了S3C2410(ARM9)的各种驱动源码
SBC2410Deceives.rar
  • SBC2410驱动源码
  • buttons_test.c
    1.5KB
  • mathtest.c
    151B
  • led.c
    475B
  • led-player.c
    2.3KB
  • pthread_test.c
    932B
  • www.pudn.com.txt
    218B
内容介绍
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/select.h> #include <sys/time.h> static int led_fd; static int type = 1; static void push_leds(void) { static unsigned step; unsigned led_bitmap; int i; switch(type) { case 0: if (step >= 6) { step = 0; } if (step < 3) { led_bitmap = 1 << step; } else { led_bitmap = 1 << (6 - step); } break; case 1: if (step > 255) { step = 0; } led_bitmap = step; break; default: led_bitmap = 0; } step++; for (i = 0; i < 4; i++) { ioctl(led_fd, led_bitmap & 1, i); led_bitmap >>= 1; } } int main(void) { int led_control_pipe; int null_writer_fd; // for read endpoint not blocking when control process exit double period = 0.5; led_fd = open("/dev/leds0", 0); if (led_fd < 0) { perror("open device leds"); exit(1); } unlink("/tmp/led-control"); mkfifo("/tmp/led-control", 0666); led_control_pipe = open("/tmp/led-control", O_RDONLY | O_NONBLOCK); if (led_control_pipe < 0) { perror("open control pipe for read"); exit(1); } null_writer_fd = open("/tmp/led-control", O_WRONLY | O_NONBLOCK); if (null_writer_fd < 0) { perror("open control pipe for write"); exit(1); } for (;;) { fd_set rds; struct timeval step; int ret; FD_ZERO(&rds); FD_SET(led_control_pipe, &rds); step.tv_sec = period; step.tv_usec = (period - step.tv_sec) * 1000000L; ret = select(led_control_pipe + 1, &rds, NULL, NULL, &step); if (ret < 0) { perror("select"); exit(1); } if (ret == 0) { push_leds(); } else if (FD_ISSET(led_control_pipe, &rds)) { static char buffer[200]; for (;;) { char c; int len = strlen(buffer); if (len >= sizeof buffer - 1) { memset(buffer, 0, sizeof buffer); break; } if (read(led_control_pipe, &c, 1) != 1) { break; } if (c == '\r') { continue; } if (c == '\n') { int tmp_type; double tmp_period; if (sscanf(buffer,"%d%lf", &tmp_type, &tmp_period) == 2) { type = tmp_type; period = tmp_period; } fprintf(stderr, "type is %d, period is %lf\n", type, period); memset(buffer, 0, sizeof buffer); break; } buffer[len] = c; } } } close(led_fd); return 0; }
评论
    相关推荐
    • pthread_create.rar
      用c語言,在linux上create 1000個thread去ping某一台主機。
    • pthread_lock.zip
      多线程文件共享 互斥量,单一轮询访问文件,线程加锁
    • pthread_hw.tar.gz
      简单的多线程程序,可以完成两个线程的操作,写操作等 ,很适合初学者入门
    • pthread_ms_dynamic.rar
      this is implemented by pthread(share library) to draw the mandelbrot set.Using the iteration to try to compute the x and y value.and divide work by dynamic mode (different from static)by rows to any ...
    • pthread_test.zip
      pthread basic example
    • pthread_create.rar
      教你如何在linux下如何创建一个线程以及如何在linux下运用这个线程
    • pthread_ms_static.rar
      this is implemented by pthread(share library) to draw the mandelbrot set.Using the iteration to try to compute the x and y value.and divide work by rows to any other threads to complete the total jobs...
    • udf_pthread_name:UDF 从 MySQL 中设置 pthread 名称
      mysql> CREATE FUNCTION pthread_name RETURNS INTEGER SONAME 'udf_pthread_name.so'; 例子 mysql> SELECT set_pthread_name('foobarbaz'); +-------------------------------+ | set_pthread_name('foobarbaz') |...
    • 线程编程——不使用pthread_join(Jack_phread_without_join_test.rar)
      线程编程——不使用pthread_join。 打包文件包含两个文件:c文件源代码、Makefile文件,运行环境在Ubuntu14.04下,使用自带的gcc编译器,同学们只需将文件夹复制到某一目录下之后在终端执行:1.“make”生成“test”...
    • 线程编程——使用pthread_join(Jack_pthread_join_test.rar)
      线程编程——使用pthread_join。 打包文件包含两个文件:c文件源代码、Makefile文件,运行环境在Ubuntu14.04下,使用自带的gcc编译器,同学们只需将文件夹复制到某一目录下之后在终端执行:1.“make”生成“test”可...