⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 turnled.c

📁 Six objects here: The document you re reading & its Chinese version Set of "HWDesign" includes
💻 C
字号:
#include <stdio.h>    /* Hey! C U again!! */#include "usb-mn-ioctls.h"#include <fcntl.h>#include <sys/ioctl.h>#include <asm/types.h>int main(int argc,char *argv[]) {  int fd;  __u16 LEDnum;          if (argc!=3) {    printf("turnLED usage: turnLED <LEDcmd> <LEDnum>\n");    printf("\tLEDcmd:0->turn off; LEDcmd:1->turn on\n");    printf("\tLEDnum:0->1st LED; LEDnum:1->2nd LED; LEDnum:A->both of them\n");    return -1;  }  /* argv[1] stands for command, now: 0(->turn off LED) or 1(->turn on LED)   * argv[2] stands for arg, now: 0(->1st LED) or 1(->2nd LED) or A(->both)   */    fd=open("/dev/MiniNurse",O_WRONLY);  if (fd<0) {    printf("CanNOT open Device.\n");    exit(-1);  }    switch (*argv[2]) {    case '0':      LEDnum = 0x04;      break;    case '1':      LEDnum = 0x08;      break;    case 'A':      LEDnum = 0x0C;      break;  default:    printf("arg:%c to this cmd is error!\n",*argv[2]);    exit(-1);  }        switch (*argv[1]) {    case '1':      ioctl(fd,MN_LEDon,LEDnum);      break;    case '0':      ioctl(fd,MN_LEDoff,LEDnum);      break;  default:    printf("cmd:%c is not support!\n",*argv[1]);    exit(-1);  }  close(fd);  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -