2008-01-24 05:39:40 how to use spi framework???
david wang (CHINA)
Message: 50078
hello everyone
my kervel version is linux-2.6.22
when i make menuconfig i choose the following chioce
--- SPI support x x
x x --- SPI Master Controller Drivers x x
x x <*> SPI controller driver for ADI Blackfin5xx x x
x x <*> Bitbanging SPI master x x
x x --- SPI Protocol Masters x x
x x < > SPI EEPROMs from most vendors x x
x x <*> User mode SPI device driver support x x
in my user space when i open("/dev/spi" , O_RDWR);
the messege "can't open device"
my program is :
int main ()
{
int fd;
unsigned char data_write[SAMPLES]={1,2,3,4,5,6,7,8,9,10};
unsigned char data_read[SAMPLES];
fd = open ("/dev/spi", O_RDWR);
if (fd < 0)
{
printf("Error opening dev/spi device \n");
return -1;
}
ioctl(fd, CMD_SPI_SET_BAUDRATE,0x1234);
ioctl(fd, CMD_SPI_OUT_ENABLE, CFG_SPI_OUTENABLE);
ioctl(fd, CMD_SPI_SET_MASTER, CFG_SPI_MASTER);
ioctl(fd, CMD_SPI_SET_LENGTH16, CFG_SPI_WORDSIZE8);
ioctl(fd, CMD_SPI_MISO_ENABLE, CFG_SPI_MISOENABLE);
ioctl(fd, CMD_SPI_SET_POLAR, CFG_SPI_ACTLOW);
ioctl(fd, CMD_SPI_SET_PHASE, CFG_SPI_PHASESTART);
ioctl(fd, CMD_SPI_SET_CSENABLE, CFG_SPI_CHIPSEL1);
ioctl(fd, CMD_SPI_SET_CSLOW, CFG_SPI_CS1VALUE);
ioctl(fd, CMD_SPI_SET_ORDER, CFG_SPI_MSBFIRST);
ioctl(fd, CMD_SPI_SET_TRIGGER_MODE, 0);
write(fd, data_write, SAMPLES);
read(fd, data_read, SAMPLES);
close(fd);
return 0;
}
help me??
thank you very much
QuoteReplyEditDelete
2008-01-24 06:09:19 Re: how to use spi framework???
Mike Frysinger (UNITED STATES)
Message: 50081 /dev/spi is not the right device node
please consult the documentation on the Userspace Device: