SPIs¶
Functions
-
struct metal_spi *
metal_spi_get_device(unsigned int device_num)¶ Get a handle for a SPI device.
- Return
A handle to the SPI device, or NULL if the device does not exist
- Parameters
device_num: The index of the desired SPI device
-
__inline__ void
metal_spi_init(struct metal_spi *spi, int baud_rate)¶ Initialize a SPI device with a certain baud rate.
- Parameters
spi: The handle for the SPI device to initializebaud_rate: The baud rate to set the SPI device to
-
__inline__ int
metal_spi_transfer(struct metal_spi *spi, struct metal_spi_config *config, size_t len, char *tx_buf, char *rx_buf)¶ Perform a SPI transfer.
- Return
0 if the transfer succeeds
- Parameters
spi: The handle for the SPI device to perform the transferconfig: The configuration for the SPI transfer.len: The number of bytes to transfertx_buf: The buffer to send over the SPI bus. Must be len bytes long. If NULL, the SPI will transfer the value 0.rx_buf: The buffer to receive data into. Must be len bytes long. If NULL, the SPI will ignore received bytes.
-
struct
metal_spi_config¶ - #include <spi.h>
The configuration for a SPI transfer.
Public Types
Public Members
-
enum metal_spi_config::[anonymous]
protocol¶ The protocol for the SPI transfer.
-
unsigned int
polarity¶ The polarity of the SPI transfer, equivalent to CPOL.
-
unsigned int
phase¶ The phase of the SPI transfer, equivalent to CPHA.
-
unsigned int
little_endian¶ The endianness of the SPI transfer.
-
unsigned int
cs_active_high¶ The active state of the chip select line.
-
unsigned int
csid¶ The chip select ID to activate for the SPI transfer.
-
unsigned int
cmd_num¶ The spi command frame number (cycles = num * frame_len)
-
unsigned int
addr_num¶ The spi address frame number.
-
unsigned int
dummy_num¶ The spi dummy frame number.
-
enum metal_spi_config::[anonymous]
multi_wire¶ The Dual/Quad spi mode selection.
-
enum metal_spi_config::[anonymous]
-
struct
metal_spi¶ - #include <spi.h>
A handle for a SPI device.