2009-01-10 03:32:46     spidev Question

Document created by Aaronwu Employee on Aug 9, 2013
Version 1Show Document
  • View in full screen mode

2009-01-10 03:32:46     spidev Question

ivan ucles (GERMANY)

Message: 67741   

 

Hi,

 

I try to vary some paraters of the spi device on the fly with the sentences:

 

 

 

dumpstat(name, fd);

 

ioctl(fd,SPI_IOC_WR_MODE,SPI_MODE_1);

 

ioctl(fd,SPI_IOC_WR_BITS_PER_WORD,16);

 

dumpstat(name, fd);

 

 

 

But dumpstat() prints the same in both calls.

 

What i've done so far is to declare the controller and the resources in cm_bf537.c like:

 

 

 

static struct bfin5xx_spi_chip spidev_chip_info = {

 

.enable_dma = 0,

 

.bits_per_word = 8,

 

};

 

static struct spi_board_info bfin_spi_board_info[] __initdata = {

 

...

 

{

 

.modalias = "spidev",

 

.max_speed_hz = 4,

 

.bus_num = 0,

 

.chip_select = 5,

 

.platform_data = NULL,

 

.controller_data = &spidev_chip_info,

 

.mode = SPI_MODE_0,

 

},

 

...

 

};

 

Could somebody tell me how to vary these and other parameters?

 

Thank u!

QuoteReplyEditDelete

 

 

2009-01-10 03:35:27     Re: spidev Question

Mike Frysinger (UNITED STATES)

Message: 67742   

 

sorry, but what exactly is "dumpstat" ?

 

spidev has a brief primer here with links to all available docs in the kernel tree:

http://docs.blackfin.uclinux.org/doku.php?id=spi

QuoteReplyEditDelete

 

 

2009-01-10 03:52:54     Re: spidev Question

ivan ucles (GERMANY)

Message: 67743   

 

Hi,

 

dumpstat is a function that is provided as an example in the kernel tree documentation.

 

It get the state and print it.

 

Here is the code:

 

static void dumpstat(const char *name, int fd)

 

{

 

__u8 mode, lsb, bits;

 

__u32 speed;

 

if (ioctl(fd, SPI_IOC_RD_MODE, &mode) < 0) {

 

perror("SPI rd_mode");

 

return;

 

}

 

if (ioctl(fd, SPI_IOC_RD_LSB_FIRST, &lsb) < 0) {

 

perror("SPI rd_lsb_fist");

 

return;

 

}

 

if (ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits) < 0) {

 

perror("SPI bits_per_word");

 

return;

 

}

 

if (ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed) < 0) {

 

perror("SPI max_speed_hz");

 

return;

 

}

 

printf("%s: spi mode %d, %d bits %sper word, %d Hz max\n",

 

name, mode, bits, lsb ? "(lsb first) " : "", speed);

 

}

Attachments

    Outcomes