Hardware Reference
In-Depth Information
If you do not wish to receive data (maybe because it is “don't care” data), you can
null out the receive buffer:
uint8_t tx[32];
struct spi_ioc_transfer tr;
tr.tx_buf = (unsigned long) tx;
tr.rx_buf = 0; /* ignore received data */
Note that to receive data, the master must always transmit data to shift data out of
the slave peripheral. If any byte transmitted will do, you can omit the transmit buffer.
Zero bytes will then be automatically transmitted by the driver to shift the slave data out
onto the MISO line.
It is also permissible to transmit from the buffer you're receiving into:
uint8_t io[32];
struct spi_ioc_transfer tr;
tr.tx_buf = (unsigned long) io; /
Transmit buffer
/
tr.rx_buf = (unsigned long) io; /
is also recv buffer
/
The len structure member indicates the number of bytes for the I/O transfer. Receive
and transmit buffers (when both used) are expected to transfer the same number of bytes.
The member speed_hz defines the clock rate that you wish to use for this I/O, in Hz.
This overrides any value configured in the mode setup, for the duration of the I/O. The
value will be automatically rounded down to a supported clock rate when necessary.
When the value speed_hz is 0, the previously configured clock rate is used
( SPI_IOC_WR_MAX_SPEED_HZ ).
When the delay_usecs member is nonzero, it specifies the number of microseconds
to delay between transfers. It is applied at the end of a transfer, rather than at the start.
When there are multiple I/O transfers in a single ioctl(2) request, this allows time in
between so that the peripheral can process the data.
The bits_per_word member defines how many bits there are in a “word” unit. Often
the unit is 1 byte (8 bits), but it need not be (but note that the Raspbian Linux driver
supports only 8 bits).
An application might use 9 bits to transmit the 8-bit byte and a parity bit, for
example. The bits communicated on the SPI bus are taken from the least significant bits
of the buffer bytes. This is true even when transmitting the most significant bit first.
When the bits_per_word value is 0, the previously configured value from
SPI_IOC_WR_BITS_PER_WORD is used. (See drivers/spi/spi-bcm2708.c in the function
bcm2708_process_transfer() ).
Note
the raspbian wheezy driver requires that bits_per_word is the value 8 or 0 .
 
Search WWH ::




Custom Search