adc_test.c
来自「linux下ad7888使用spi口驱动程序代码」· C语言 代码 · 共 38 行
C
38 行
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
int main(){
int fd, size;
char s[] = "1234";
char buf[10];
//buf = (char *)malloc(sizeof(s));
//memset( buf, 0, sizeof(s));
//while ( 1 ){
fd = open( "/dev/adc", O_WRONLY );
if ( fd < 0 ){
printf( "open file fail\n" );
return -1;
}
//while ( 1 ){
write( fd, s, sizeof( s ) );
//}
close( fd );
fd = open( "/dev/adc", O_RDONLY );
//while ( 1 ){
size = read( fd, buf, sizeof(s) );
//}
close( fd );
//free( buf );
//printf( "buf = %s\n", buf );
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?