ledtest_app.c
来自「Linux device driver sample code」· C语言 代码 · 共 42 行
C
42 行
#include <stdio.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <sys/fcntl.h>#include "led_drv.h"char str[20]="hello";int main(void){ int device_handle; int ledval; printf("\nLDD test \n"); device_handle = open("/dev/LED", O_RDWR); read(device_handle, &str[0], 5); printf("\nstring %s\n", str); write(device_handle, "Howdy", 5); ledval = 0xFC0; ioctl(device_handle, LEDON_WDATA, ledval); sleep(1); ioctl(device_handle, LEDOFF_WDATA, ledval); ledval = 0x550; ioctl(device_handle, LEDON_WDATA, ledval); sleep(1); ioctl(device_handle, LEDOFF_WDATA, ledval); ledval = 0xAA0; ioctl(device_handle, LEDON_WDATA, ledval); sleep(1); ioctl(device_handle, LEDOFF_WDATA, ledval); close(device_handle);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?