Go to the documentation of this file.
48 #define SOFT_SPI_DEV(x) (x)
54 #ifndef SOFT_SPI_UNDEF
55 #define SOFT_SPI_UNDEF (UINT_MAX)
61 #ifndef SOFT_SPI_CS_UNDEF
62 #define SOFT_SPI_CS_UNDEF (GPIO_UNDEF)
234 const void *out,
void *in,
size_t len);
265 const void *out,
void *in,
size_t len);
soft_spi_mode_t soft_spi_mode
data and clock polarity
Low-level SPI peripheral driver interface definition.
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_MODE_2
CPOL=1, CPHA=0.
@ SOFT_SPI_OK
everything went as planned
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_init(soft_spi_t bus)
Basic initialization of the given SPI bus.
@ SOFT_SPI_NOMODE
selected mode is not supported
@ SOFT_SPI_CLK_400KHZ
drive the SPI bus with less than 400kHz
@ SOFT_SPI_CLK_100KHZ
drive the SPI bus with less than 100kHz
soft_spi_clk_t
Available SPI clock speeds.
void soft_spi_init_pins(soft_spi_t bus)
Initialize the used SPI bus pins, i.e.
soft_spi_mode_t
Available SPI modes, defining the configuration of clock polarity and clock phase.
gpio_t soft_spi_cs_t
Chip select pin type overlaps with gpio_t so it can be casted to this.
@ SOFT_SPI_MODE_1
CPOL=0, CPHA=1.
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.
Mutex for thread synchronization.
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.
void soft_spi_release(soft_spi_t bus)
Finish an ongoing SPI transaction by releasing the given SPI bus.
Low-level GPIO peripheral driver interface definitions.
int 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.
int soft_spi_init_cs(soft_spi_t bus, soft_spi_cs_t cs)
Initialize the given chip select pin.
@ SOFT_SPI_MODE_0
CPOL=0, CPHA=0.
@ SOFT_SPI_MODE_3
CPOL=1, CPHA=1.
@ SOFT_SPI_CLK_DEFAULT
drive the SPI bus with maximum speed possible
Software SPI port descriptor.
@ SOFT_SPI_NODEV
invalid SPI bus specified
soft_spi_clk_t soft_spi_clk
clock speed
unsigned int soft_spi_t
Default type for SPI devices.
@ SOFT_SPI_NOCS
invalid chip select line specified
@ SOFT_SPI_NOCLK
selected clock value is not supported