36 #include "mcu_periph/spi_arch.h"
39 #ifndef SPI_BLOCKING_TIMEOUT
40 #define SPI_BLOCKING_TIMEOUT 1.f
168 #ifndef SPI_TRANSACTION_QUEUE_LEN
169 #define SPI_TRANSACTION_QUEUE_LEN 8
241 extern void spi3_init(
void);
246 extern void spi3_arch_init(
void);
253 extern void spi4_init(
void);
258 extern void spi4_arch_init(
void);
333 extern void spi0_slave_init(
void);
338 extern void spi0_slave_arch_init(
void);
345 extern void spi1_slave_init(
void);
350 extern void spi1_slave_arch_init(
void);
357 extern void spi2_slave_init(
void);
362 extern void spi2_slave_arch_init(
void);
369 extern void spi3_slave_init(
void);
374 extern void spi3_slave_arch_init(
void);
SPIClockPolarity
SPI CPOL (clock polarity) options.
enum SPIClockPolarity cpol
clock polarity control
bool spi_slave_register(struct spi_periph *p, struct spi_transaction *t)
Register a spi transaction in slave mode (only one transaction can be registered).
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
#define SPI_BLOCKING_TIMEOUT
uint16_t output_length
number of data words to write
SPIDataSizeSelect
SPI data word size of transfer.
struct spi_periph spi2
receive transferred over DMA
slave is selected before transaction but not unselected
void spi1_arch_init(void)
Architecture dependent SPI1 initialization.
slave is not selected but unselected after transaction
SPITransactionStatus
SPI transaction status.
SPI transaction structure.
slave is not selected nor unselected
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit a spi transaction.
void(* SPICallback)(struct spi_transaction *trans)
SPI Callback function.
void spi_slave_hs_init(void)
enum SPIBitOrder bitorder
MSB/LSB order.
SPIClockPhase
SPI CPHA (clock phase) options.
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
static float get_sys_time_float(void)
Get the time in seconds since startup.
volatile uint8_t suspend
control for stop/resume of the fifo
static bool spi_blocking_transceive(struct spi_periph *p, struct spi_transaction *t)
Perform a spi transaction (blocking).
enum SPISlaveSelect select
slave selection behavior
void spi_init(struct spi_periph *p)
Initialize a spi peripheral.
SPIStatus
SPI peripheral status.
enum SPIClockPhase cpha
clock phase control
bool spi_lock(struct spi_periph *p, uint8_t slave)
Lock the SPI fifo.
SPI peripheral structure.
void spi_slave_init(struct spi_periph *p)
Initialize a spi peripheral in slave mode.
void spi_slave_unselect(uint8_t slave)
Unselect a slave.
Architecture independent timing functions.
SPICallback after_cb
NULL or function called after the transaction.
void spi2_arch_init(void)
Architecture dependent SPI2 initialization.
volatile uint8_t tx_idx_buf
bool spi_slave_wait(struct spi_periph *p)
Initialized and wait for the next transaction.
uint16_t input_length
number of data words to read
enum SPIStatus status
internal state of the peripheral
SPIClockDiv
Peripheral clock divider.
bool spi_resume(struct spi_periph *p, uint8_t slave)
Resume the SPI fifo.
slave is selected before transaction and unselected after
uint8_t trans_extract_idx
enum SPIDataSizeSelect dss
data transfer word size
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
volatile uint8_t * input_buf
pointer to receive buffer for DMA
Highspeed SPI Slave Interface.
SPICallback before_cb
NULL or function called before the transaction.
volatile uint8_t rx_idx_buf
#define SPI_TRANSACTION_QUEUE_LEN
SPI transaction queue length.
void spi_init_slaves(void)
Initialize all used slaves and unselect them.
void spi_slave_select(uint8_t slave)
Select a slave.
void spi0_arch_init(void)
Architecture dependent SPI0 initialization.
struct spi_transaction * trans[SPI_TRANSACTION_QUEUE_LEN]
circular buffer holding transactions
struct spi_periph spi1
receive transferred over DMA
SPISlaveSelect
SPI slave selection behavior options.
enum SPITransactionStatus status