| SPI(9) | Kernel Developer's Manual | SPI(9) |
spi_configure,
spi_transfer,
spi_transfer_init,
spi_chunk_init,
spi_transfer_add, spi_wait,
spi_done, spi_send,
spi_recv, spi_send_recv
— Serial Peripheral Interface (SPI) kernel
interface
#include
<dev/spi/spivar.h>
int
spi_configure(struct spi_handle
*sh, int mode, int
speed);
int
spi_transfer(struct spi_handle
*sh, struct spi_transfer *st);
void
spi_transfer_init(struct spi_transfer
*st);
void
spi_chunk_init(struct spi_chunk
*chunk, int cnt, const uint8_t
*wptr, uint8_t *rptr);
void
spi_transfer_add(struct spi_transfer
*st, struct spi_chunk *chunk);
void
spi_wait(struct spi_transfer
*st);
void
spi_done(struct spi_transfer
*st, int err);
int
spi_recv(struct spi_handle *sh,
int cnt, uint8_t *data);
int
spi_send(struct spi_handle *sh,
int cnt, const uint8_t
*data);
int
spi_send_recv(struct spi_handle
*sh, int scnt, const uint8_t
*snd, int rcnt, const uint8_t
*rcv);
SPI is a 4-wire synchronous full-duplex serial bus. It is commonly
used for connecting devices such as EEPROMs, displays, and other types of
integrated circuits. The spi interface provides a
means of communicating with SPI-connected devices.
The following functions comprise the API provided to drivers of SPI-connected devices.
The struct spi_handle corresponding to the device is passed in the driver attachment.
spi_configure(sh,
mode, speed)spi_transfer(sh,
st)spi_transfer()
returns an errno value when the transfer couldn't be queued.spi_transfer_init(st)spi_chunk_init(chunk,
cnt, wptr,
rptr")spi_transfer_add(st,
chunk)spi_wait(st)spi_done(st,
err)For simplicity there are convenience functions that combine common operations. These functions return an errno value when the transfer failed.
spi_recv(sh,
cnt, data)spi_send(sh,
cnt, data)spi_send_recv(sh,
scnt, snd,
rcnt, rcv)The spi API first appeared in
NetBSD 4.0.
| February 23, 2019 | NetBSD 11.0 |