主题 : 请教高手们SPI的问题 复制链接 | 浏览器收藏 | 打印
我最虚心
级别: 新手上路
UID: 44872
精华: 0
发帖: 20
金钱: 100 两
威望: 20 点
综合积分: 40 分
注册时间: 2011-04-29
最后登录: 2014-03-08
楼主  发表于: 2011-09-14 22:39

 请教高手们SPI的问题

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;  

}