led.c
上传用户:sy_wanhua
上传日期:2013-07-25
资源大小:3048k
文件大小:2k
- /******************************************************************************
- * This is a small application that demonstrates how to make the LEDs on
- * the Quicknet Technologies, Inc. Internet LineJack card go blinky blink.
- *
- * Written by Ed Okerson (eokerson@quicknet.net)
- * Quicknet Technologies, Inc.
- *
- * The ixj driver uses the ioctl IXJCTL_SET_LED to determine which LED to
- * turn on, you pass it a char value and each of the l.s. bits represents
- * an LED. If the bit is 1 the LED will come on, if the bit is 0 the LED
- * will go off.
- ******************************************************************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include <strings.h>
- #include <sys/ioctl.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include "ixjuser.h"
- int ixj;
- void led(char en)
- {
- printf("LED 1 = %dt", en & 0x1?1:0);
- printf("LED 2 = %dt", en & 0x2?1:0);
- printf("LED 3 = %dt", en & 0x4?1:0);
- printf("LED 4 = %dt", en & 0x8?1:0);
- printf("en = %dn", en);
- ioctl(ixj, IXJCTL_SET_LED, en);
- }
- void closeall(void)
- {
- close(ixj);
- }
- int main(int argc, char *argv[])
- {
- char pname[80];
- sprintf(pname, "/dev/ixj%s", argv[1]);
- ixj = open(pname, O_RDWR);
- atexit(closeall);
- sleep(1);
- led(0x1);
- sleep(1);
- led(0x2);
- sleep(1);
- led(0x4);
- sleep(1);
- led(0x8);
- sleep(1);
- led(0x3);
- sleep(1);
- led(0xC);
- sleep(1);
- led(0x5);
- sleep(1);
- led(0xA);
- sleep(1);
- led(0x9);
- sleep(1);
- led(0x6);
- sleep(1);
- led(0x0);
- sleep(1);
- led(0xF);
- sleep(1);
- led(0x0);
- sleep(1);
- led(0xF);
- sleep(1);
- led(0x0);
- sleep(1);
- led(0xF);
- sleep(1);
- led(0x0);
- sleep(1);
- }