75#include "periph_cpu.h"
76#include "periph_conf.h"
87#ifndef CONFIG_SPI_DMA_THRESHOLD_BYTES
88#define CONFIG_SPI_DMA_THRESHOLD_BYTES 16
102#define SPI_UNDEF (UINT_FAST8_MAX)
109#define SPI_CS_UNDEF (GPIO_UNDEF)
120#define SPI_HWCS(x) (SPI_CS_UNDEF)
168#ifndef HAVE_SPI_MODE_T
184#ifndef HAVE_SPI_CLK_T
255#if defined(MODULE_PERIPH_SPI_RECONFIGURE) || DOXYGEN
320#if defined(MODULE_PERIPH_SPI_GPIO_MODE) || DOXYGEN
398 const void *out,
void *in,
size_t len);
431 const void *out,
void *in,
size_t len);
Low-level GPIO peripheral driver interface definitions.
libc header for endian conversion
#define ENXIO
No such device or address.
#define EINVAL
Invalid argument.
uint_fast8_t spi_t
Default type for SPI devices.
int spi_init_cs(spi_t bus, spi_cs_t cs)
Initialize the given chip select pin.
gpio_t spi_pin_miso(spi_t dev)
Get the MISO pin of the given SPI bus.
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.
void spi_acquire(spi_t bus, spi_cs_t cs, spi_mode_t mode, spi_clk_t clk)
Start a new SPI transaction.
gpio_t spi_pin_mosi(spi_t dev)
Get the MOSI pin of the given SPI bus.
int spi_init_with_gpio_mode(spi_t bus, const spi_gpio_mode_t *mode)
Initialize MOSI/MISO/SCLK pins with adapted GPIO modes.
gpio_t spi_pin_clk(spi_t dev)
Get the CLK pin of the given SPI bus.
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.
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.
static uint16_t spi_transfer_u16_be(spi_t bus, spi_cs_t cs, bool cont, uint16_t host_number)
Transfer a 16 bit number in big endian byte order.
void spi_release(spi_t bus)
Finish an ongoing SPI transaction by releasing the given SPI bus.
void spi_init_pins(spi_t bus)
Initialize the used SPI bus pins, i.e.
void spi_deinit_pins(spi_t dev)
Change the pins of the given SPI bus back to plain GPIO functionality.
spi_mode_t
Available SPI modes, defining the configuration of clock polarity and clock phase.
void spi_init(spi_t bus)
Basic initialization of the given SPI bus.
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.
spi_clk_t
Available SPI clock speeds.
gpio_t spi_cs_t
Chip select pin type overlaps with gpio_t so it can be casted to this.
@ SPI_OK
everything went as planned
@ SPI_NOCS
invalid chip select line specified
@ SPI_NOCLK
selected clock value is not supported
@ SPI_NODEV
invalid SPI bus specified
@ SPI_NOMODE
selected mode is not supported
@ SPI_MODE_0
CPOL=0, CPHA=0.
@ SPI_MODE_2
CPOL=1, CPHA=0.
@ SPI_MODE_1
CPOL=0, CPHA=1.
@ SPI_MODE_3
CPOL=1, CPHA=1.
@ SPI_CLK_10MHZ
drive the SPI bus with 10MHz
@ SPI_CLK_5MHZ
drive the SPI bus with 5MHz
@ SPI_CLK_400KHZ
drive the SPI bus with 400KHz
@ SPI_CLK_1MHZ
drive the SPI bus with 1MHz
@ SPI_CLK_100KHZ
drive the SPI bus with 100KHz
static ssize_t send(int socket, const void *buffer, size_t length, int flags)
Send a message on a socket.
uint16_t be16toh(uint16_t big_endian_16bits)
big endian to host, 16 bit
uint16_t htobe16(uint16_t host_16bits)
host to big endian, 16 bit
spi_mode_t
Support SPI modes.
gpio_mode_t
Available pin modes.
gpio_mode_t mosi
GPIO mode used for MOSI pin.
gpio_mode_t miso
GPIO mode used for MISO pin.
gpio_mode_t sclk
GPIO mode used for SCLK pin.