I would appreciate any donations. Wishlist or send e-mail type donations to maekawa AT daemon-systems.org.
SPI(9) Kernel Developer's Manual SPI(9) NAME 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 SYNOPSIS #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); DESCRIPTION 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. FUNCTIONS 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) Sets mode and speed for subsequent communication with a SPI slave. spi_transfer(sh, st) Queue transfer to SPI controller. spi_transfer() returns an errno value when the transfer couldn't be queued. spi_transfer_init(st) Initialize a transfer structure. spi_chunk_init(chunk, cnt, wptr, rptr") Initialize a chunk structure, each chunk corresponds to a possibly bi-directional transfer where the same amount of bytes is shifted in and out. spi_transfer_add(st, chunk) Append a chunk to transfer structure. spi_wait(st) Wait for a transfer to complete. When the transfer has failed for some reason, the field st->st_errno is set to a non-zero value. spi_done(st, err) Called back machine-dependent backend to signal completion of a transfer. 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) Prepares a chunk for receiving data, queues a transfer and waits for it to complete. spi_send(sh, cnt, data) Prepares a chunk for sending data, queues a transfer and waits for it to complete. spi_send_recv(sh, scnt, snd, rcnt, rcv) Prepares two chunks for sending data first and then receiving an answer, queues a transfer and waits for it to complete. This is not a full-duplex operation. SEE ALSO spi(4) HISTORY The spi API first appeared in NetBSD 4.0. NetBSD 8.99.34 February 23, 2019 NetBSD 8.99.34