Go to the documentation of this file.
74 #include "periph_cpu.h"
75 #include "periph_conf.h"
86 #define SPI_DEV(x) (x)
93 #define SPI_UNDEF (UINT_MAX)
100 #define SPI_CS_UNDEF (GPIO_UNDEF)
111 #define SPI_HWCS(x) (SPI_CS_UNDEF)
125 #ifndef HAVE_SPI_CS_T
156 #ifndef HAVE_SPI_MODE_T
172 #ifndef HAVE_SPI_CLK_T
243 #if defined(MODULE_PERIPH_SPI_RECONFIGURE) || DOXYGEN
308 #if defined(MODULE_PERIPH_SPI_GPIO_MODE) || DOXYGEN
389 const void *out,
void *in,
size_t len);
422 const void *out,
void *in,
size_t len);
@ SPI_CLK_400KHZ
drive the SPI bus with 400KHz
void spi_transfer_bytes(spi_t bus, spi_cs_t cs, bool cont, const void *out, void *in, size_t len)
Transfer a number bytes using the given SPI bus.
gpio_t spi_pin_mosi(spi_t dev)
Get the MOSI pin of the given SPI bus.
@ SPI_MODE_3
CPOL=1, CPHA=1.
@ SPI_CLK_5MHZ
drive the SPI bus with 5MHz
@ SPI_CLK_10MHZ
drive the SPI bus with 10MHz
@ SPI_MODE_0
CPOL=0, CPHA=0.
@ SPI_NODEV
invalid SPI bus specified
@ SPI_CLK_1MHZ
drive the SPI bus with 1MHz
@ SPI_NOCS
invalid chip select line specified
gpio_mode_t miso
GPIO mode used for MISO pin.
spi_mode_t
Available SPI modes, defining the configuration of clock polarity and clock phase.
void spi_release(spi_t bus)
Finish an ongoing SPI transaction by releasing the given SPI bus.
gpio_t spi_cs_t
Chip select pin type overlaps with gpio_t so it can be casted to this.
@ SPI_NOMODE
selected mode is not supported
gpio_t spi_pin_clk(spi_t dev)
Get the CLK pin of the given SPI bus.
spi_clk_t
Available SPI clock speeds.
int spi_acquire(spi_t bus, spi_cs_t cs, spi_mode_t mode, spi_clk_t clk)
Start a new SPI transaction.
gpio_mode_t mosi
GPIO mode used for MOSI pin.
int spi_init_with_gpio_mode(spi_t bus, spi_gpio_mode_t mode)
Initialize MOSI/MISO/SCLK pins with adapted GPIO modes.
void spi_transfer_regs(spi_t bus, spi_cs_t cs, uint8_t reg, const void *out, void *in, size_t len)
Transfer a number of bytes to/from a given register address.
@ SPI_CLK_100KHZ
drive the SPI bus with 100KHz
void spi_init(spi_t bus)
Basic initialization of the given SPI bus.
gpio_t spi_pin_miso(spi_t dev)
Get the MISO pin of the given SPI bus.
int spi_init_cs(spi_t bus, spi_cs_t cs)
Initialize the given chip select pin.
uint8_t spi_transfer_reg(spi_t bus, spi_cs_t cs, uint8_t reg, uint8_t out)
Transfer one byte to/from a given register address.
Low-level GPIO peripheral driver interface definitions.
void spi_init_pins(spi_t bus)
Initialize the used SPI bus pins, i.e.
gpio_mode_t
Available pin modes.
@ SPI_OK
everything went as planned
gpio_mode_t sclk
GPIO mode used for SCLK pin.
uint8_t spi_transfer_byte(spi_t bus, spi_cs_t cs, bool cont, uint8_t out)
Transfer one byte on the given SPI bus.
void spi_deinit_pins(spi_t dev)
Change the pins of the given SPI bus back to plain GPIO functionality.
@ SPI_MODE_1
CPOL=0, CPHA=1.
unsigned int spi_t
Default type for SPI devices.
@ SPI_MODE_2
CPOL=1, CPHA=0.
@ SPI_NOCLK
selected clock value is not supported