test_iic_led.c

来自「linux驱动开发代码」· C语言 代码 · 共 37 行

C
37
字号
#include <unistd.h>#include <linux/fs.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <stdio.h>#define LED_SLAVE_ADD	0x70int main(){        int fd = open("/dev/led",O_RDWR);	//can read and write	char null_buf[5]={-1,-1,-1,-1,-1};        if (fd == -1)        {                perror("can't open device led_board!");                exit(1);        }	while(1)	{		write(fd,null_buf,5);		sleep(1);	}      close(fd);}

⌨️ 快捷键说明

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