35#ifndef PROTOCORE_SPI_H
36#define PROTOCORE_SPI_H
43#ifndef PROTOCORE_SPI_HZ
44#define PROTOCORE_SPI_HZ 1000000u
48#ifndef PROTOCORE_SPI_MODE
49#define PROTOCORE_SPI_MODE 0u
53#ifndef PROTOCORE_SPI_HOST
54#define PROTOCORE_SPI_HOST 0u
58#ifndef PROTOCORE_SPI_QUADWP_PIN
59#define PROTOCORE_SPI_QUADWP_PIN (-1)
61#ifndef PROTOCORE_SPI_QUADHD_PIN
62#define PROTOCORE_SPI_QUADHD_PIN (-1)
72 return protocore_platform_spi_begin(host, mosi, miso, sclk, quadwp, quadhd) != 0;
88 const uint8_t *tx, uint8_t *rx,
size_t len)
90 return protocore_platform_spi_txn(host, hz, bit_order, mode, tx, rx, (uint32_t)len) != 0;
95 uint8_t *rx,
size_t len)
129 uint16_t cmd, uint8_t cmd_bits, uint32_t addr, uint8_t addr_bits,
130 uint8_t dummy_bits, uint8_t lanes,
const uint8_t *tx, uint8_t *rx,
133 return protocore_platform_spi_txn_ext(host, hz, bit_order, mode, cmd, cmd_bits, addr, addr_bits, dummy_bits, lanes,
134 tx, rx, (uint32_t)len) != 0;
139 uint8_t dummy_bits, uint8_t lanes,
const uint8_t *tx, uint8_t *rx,
150 protocore_platform_gpio_mode(pin, PROTOCORE_GPIO_OUT);
151 protocore_platform_gpio_write(pin, PROTOCORE_GPIO_HIGH);
157 protocore_platform_gpio_write(pin, PROTOCORE_GPIO_LOW);
163 protocore_platform_gpio_write(pin, PROTOCORE_GPIO_HIGH);
185 const uint8_t *tx, uint8_t *rx,
size_t len)
198 uint8_t *rx,
size_t len)
219 uint16_t cmd, uint8_t cmd_bits, uint32_t addr, uint8_t addr_bits,
220 uint8_t dummy_bits, uint8_t lanes,
const uint8_t *tx, uint8_t *rx,
240 uint8_t dummy_bits, uint8_t lanes,
const uint8_t *tx, uint8_t *rx,
#define PROTOCORE_SPI_MISO_PIN
#define PROTOCORE_SPI_SCLK_PIN
#define PROTOCORE_SPI_MOSI_PIN
Shared SPI bus pins for the peripheral drivers, the same way the I2C pins above are shared....
#define PROTOCORE_INLINE
Linkage for a leaf primitive whose body is cheaper than the call that reaches it.
PROTOCORE_INLINE proto_bool protocore_spi_txn_ext_on(uint8_t host, uint32_t hz, uint8_t bit_order, uint8_t mode, uint16_t cmd, uint8_t cmd_bits, uint32_t addr, uint8_t addr_bits, uint8_t dummy_bits, uint8_t lanes, const uint8_t *tx, uint8_t *rx, size_t len)
PROTOCORE_INLINE proto_bool protocore_spi_txn(const uint8_t *tx, uint8_t *rx, size_t len)
#define PROTOCORE_SPI_MODE
Clock polarity and phase, as SPI mode 0..3. Mode 0 is what these parts use.
PROTOCORE_INLINE proto_bool protocore_spi_txn_at(uint32_t hz, uint8_t bit_order, uint8_t mode, const uint8_t *tx, uint8_t *rx, size_t len)
#define PROTOCORE_SPI_QUADWP_PIN
Third and fourth data lines, for a quad-width bus; -1 leaves the bus single or dual.
PROTOCORE_INLINE proto_bool protocore_spi_read(uint8_t *rx, size_t len)
#define PROTOCORE_SPI_QUADHD_PIN
PROTOCORE_INLINE proto_bool protocore_spi_write(const uint8_t *tx, size_t len)
PROTOCORE_INLINE void protocore_spi_cs_select(uint8_t pin)
#define PROTOCORE_SPI_HZ
Bus clock for the shared peripheral bus; 1 MHz is safe on every part on it.
PROTOCORE_INLINE void protocore_spi_cs_idle(uint8_t pin)
PROTOCORE_INLINE proto_bool protocore_spi_txn_ext(uint16_t cmd, uint8_t cmd_bits, uint32_t addr, uint8_t addr_bits, uint8_t dummy_bits, uint8_t lanes, const uint8_t *tx, uint8_t *rx, size_t len)
PROTOCORE_INLINE proto_bool protocore_spi_txn_on(uint8_t host, uint32_t hz, uint8_t bit_order, uint8_t mode, const uint8_t *tx, uint8_t *rx, size_t len)
PROTOCORE_BEGIN_DECLS PROTOCORE_INLINE proto_bool protocore_spi_begin_on(uint8_t host, int mosi, int miso, int sclk, int quadwp, int quadhd)
#define PROTOCORE_SPI_HOST
Controller the plain verbs drive.
PROTOCORE_INLINE void protocore_spi_cs_release(uint8_t pin)
PROTOCORE_INLINE proto_bool protocore_spi_begin(void)
#define PROTO_FALSE
the false value
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTO_TRUE
the true value, spelled so a caller never writes a bare 1
#define PROTOCORE_END_DECLS