spi linux驱动
在/sys/bus/spi/drivers目录下,能看到spidev,在/sys/bus/spi/devices目录下,能看到spi1.0(我使用的是spi1在2440芯片下),自己编写了一个测试文件
#include <stdio.h> // printf
#include <fcntl.h> // open
#include <stdlib.h> // exit
#include <unistd.h>
#include <sys/ioctl.h> // ioctl
//*************************Test*********************************
int main(int argc, char *argv[])
{
int fd;
char str = '0';
fd = open("/dev/spidev1.0",O_RDWR);
if(fd<0)
printf("can not open\n");
while(1)
{
write(fd,&str,1);
printf("write successful\n");
}
close(fd);
return 0;
}
我配置SPI1为poll模式时,发现printf("write successful\n");并无执行,就是卡死在write函数上,我并无利用spidev对外连接任何引脚,只是直接把2440的spi1引脚导出来而已,但是打开spidev是成功的。运行上述代码后利用示波器测试了SPICLK1引脚,本身2440设置为主模式,时钟为1M,但是示波器上还是无时钟输出,SPIMOSI1一直为高电平,SPIMOSO1一直为低电平?何解?谢谢了