http://www.360doc.com/content/10/1227/10/3444631_81661308.shtml就是这篇文章的方法,我用测试程序之后发现mini2440接收到的数据为0X00
测试程序
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
int main(int argc, char **argv)
{
int fd;
int count=0;
char buf[]={0x11,0x22,0x33,0x44,0x55};
fd = open("/dev/mini2440_spi", O_RDWR);
if (fd < 0) {
perror("open device spi");
exit(1);
}
count=write(fd,buf,sizeof(buf)/sizeof(buf[0]));
read(fd,buf,1);
printf("read byte is: 0x%02X\n",buf[0]);
close(fd);
return 0;
}