📄 app.c~
字号:
#include <sys/ioctl.h>#include <math.h>#include <stdio.h>#include <stdlib.h>#include <linux/fr400cc_vdc.h>#include <sys/stat.h>#include <sys/mman.h>#include <fcntl.h>#include <time.h>#include <unistd.h>#include <sys/types.h>#include <math.h>#define FPGA_SW_IOC_MAGIC 0xdc#define FPGA_SWITCH_READ _IOR(FPGA_SW_IOC_MAGIC,0,int)#define FPGA_LED _IOW(FPGA_SW_IOC_MAGIC,1,int)#define SW5 0x7bff#define SW7 0x77ff#define SW8 0x6fff#define SW9 0x5fff#define SW10 0x3fff #define sw4up 0x7e7f#define sw4press 0x7dff#define sw4down 0x7f9f#define sw6up 0x7ff3#define sw6press 0x7fef#define sw6down 0x7ffcint main(){ int fd,key; fd =open("./keyled",O_RDONLY); if(fd<0) printf("Failure to open the device 'keyled'\n"); while(1) { sleep(2); ioctl(fd,FPGA_SWITCH_READ,&key); switch (key) { case SW5: ioctl(fd,FPGA_LED,0xff);break; case SW7: ioctl(fd,FPGA_LED,0xfe);break; case SW8: ioctl(fd,FPGA_LED,0xfd);break; case SW9: ioctl(fd,FPGA_LED,0xfc);break; case SW10: ioctl(fd,FPGA_LED,0xfb);break; case SW4up: ioctl(fd,FPGA_LED,0xfa);break; case SW4press: ioctl(fd,FPGA_LED,0xf9);break; case SWdown: ioctl(fd,FPGA_LED,0xf8);break; case SWup: ioctl(fd,FPGA_LED,0xf7);break; case SWpress: ioctl(fd,FPGA_LED,0xf6);break; case SWdown: ioctl(fd,FPGA_LED,0xf5);break; default: printf("No key is pressed!\n");break; } } close(fd); return 1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -