48#define SOFT_SPI_DEV(x) (x)
55#define SOFT_SPI_UNDEF (UINT_MAX)
61#ifndef SOFT_SPI_CS_UNDEF
62#define SOFT_SPI_CS_UNDEF (GPIO_UNDEF)
230 const void *out,
void *in,
size_t len);
261 const void *out,
void *in,
size_t len);
Low-level GPIO peripheral driver interface definitions.
soft_spi_mode_t
Available SPI modes, defining the configuration of clock polarity and clock phase.
int soft_spi_init_cs(soft_spi_t bus, soft_spi_cs_t cs)
Initialize the given chip select pin.
void soft_spi_transfer_regs(soft_spi_t bus, soft_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.
unsigned int soft_spi_t
Default type for SPI devices.
void soft_spi_init(soft_spi_t bus)
Basic initialization of the given SPI bus.
gpio_t soft_spi_cs_t
Chip select pin type overlaps with gpio_t so it can be casted to this.
void soft_spi_init_pins(soft_spi_t bus)
Initialize the used SPI bus pins, i.e.
void soft_spi_release(soft_spi_t bus)
Finish an ongoing SPI transaction by releasing the given SPI bus.
void soft_spi_acquire(soft_spi_t bus, soft_spi_cs_t cs, soft_spi_mode_t mode, soft_spi_clk_t clk)
Start a new SPI transaction.
uint8_t soft_spi_transfer_reg(soft_spi_t bus, soft_spi_cs_t cs, uint8_t reg, uint8_t out)
Transfer one byte to/from a given register address.
uint8_t soft_spi_transfer_byte(soft_spi_t bus, soft_spi_cs_t cs, bool cont, uint8_t out)
Transfer one byte on the given SPI bus Currently only the use of MOSI in master mode is implemented.
void soft_spi_transfer_bytes(soft_spi_t bus, soft_spi_cs_t cs, bool cont, const void *out, void *in, size_t len)
Transfer a number bytes using the given SPI bus.
soft_spi_clk_t
Available SPI clock speeds.
@ SOFT_SPI_MODE_2
CPOL=1, CPHA=0.
@ SOFT_SPI_MODE_3
CPOL=1, CPHA=1.
@ SOFT_SPI_MODE_1
CPOL=0, CPHA=1.
@ SOFT_SPI_MODE_0
CPOL=0, CPHA=0.
@ SOFT_SPI_OK
everything went as planned
@ SOFT_SPI_NOCLK
selected clock value is not supported
@ SOFT_SPI_NOMODE
selected mode is not supported
@ SOFT_SPI_NOCS
invalid chip select line specified
@ SOFT_SPI_NODEV
invalid SPI bus specified
@ SOFT_SPI_CLK_1MHZ
drive the SPI bus with less than 1MHz
@ SOFT_SPI_CLK_100KHZ
drive the SPI bus with less than 100kHz
@ SOFT_SPI_CLK_DEFAULT
drive the SPI bus with maximum speed possible
Mutex for thread synchronization.
Low-level SPI peripheral driver interface definition.
Software SPI port descriptor.
soft_spi_mode_t soft_spi_mode
data and clock polarity
soft_spi_clk_t soft_spi_clk
clock speed