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
244 extern void spi3_init(
void);
249 extern void spi3_arch_init(
void);
256 extern void spi4_init(
void);
261 extern void spi4_arch_init(
void);
268 extern void spi6_init(
void);
273 extern void spi6_arch_init(
void);
348 extern void spi0_slave_init(
void);
353 extern void spi0_slave_arch_init(
void);
360 extern void spi1_slave_init(
void);
365 extern void spi1_slave_arch_init(
void);
372 extern void spi2_slave_init(
void);
377 extern void spi2_slave_arch_init(
void);
384 extern void spi3_slave_init(
void);
389 extern void spi3_slave_arch_init(
void);
420 #include "mcu_periph/spi_slave_hs_arch.h"
421 extern void spi_slave_hs_init(
void);
enum SPIClockPolarity cpol
clock polarity control
enum SPIClockPhase cpha
clock phase control
enum SPISlaveSelect select
slave selection behavior
SPICallback before_cb
NULL or function called before the transaction.
enum SPIStatus status
internal state of the peripheral
SPICallback after_cb
NULL or function called after the transaction.
struct spi_transaction * trans[SPI_TRANSACTION_QUEUE_LEN]
circular buffer holding transactions
enum SPIDataSizeSelect dss
data transfer word size
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
uint16_t input_length
number of data words to read
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
volatile uint8_t * input_buf
pointer to receive buffer for DMA
volatile uint8_t tx_idx_buf
volatile uint8_t suspend
control for stop/resume of the fifo
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
uint8_t trans_extract_idx
enum SPIBitOrder bitorder
MSB/LSB order.
uint16_t output_length
number of data words to write
enum SPITransactionStatus status
volatile uint8_t rx_idx_buf
SPIClockPhase
SPI CPHA (clock phase) options.
SPIStatus
SPI peripheral status.
SPITransactionStatus
SPI transaction status.
SPIClockPolarity
SPI CPOL (clock polarity) options.
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit a spi transaction.
bool spi_slave_wait(struct spi_periph *p)
Initialized and wait for the next transaction.
static bool spi_blocking_transceive(struct spi_periph *p, struct spi_transaction *t)
Perform a spi transaction (blocking).
void spi_init(struct spi_periph *p)
Initialize a spi peripheral.
void spi_slave_init(struct spi_periph *p)
Initialize a spi peripheral in slave mode.
bool spi_lock(struct spi_periph *p, uint8_t slave)
Lock the SPI fifo.
SPISlaveSelect
SPI slave selection behavior options.
void(* SPICallback)(struct spi_transaction *trans)
SPI Callback function.
#define SPI_TRANSACTION_QUEUE_LEN
SPI transaction queue length.
void spi_slave_unselect(uint8_t slave)
Unselect a slave.
SPIClockDiv
Peripheral clock divider.
void spi1_arch_init(void)
Architecture dependent SPI1 initialization.
SPIDataSizeSelect
SPI data word size of transfer.
void spi0_arch_init(void)
Architecture dependent SPI0 initialization.
struct spi_periph spi2
receive transferred over DMA
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).
void spi_slave_select(uint8_t slave)
Select a slave.
void spi2_arch_init(void)
Architecture dependent SPI2 initialization.
struct spi_periph spi1
receive transferred over DMA
bool spi_resume(struct spi_periph *p, uint8_t slave)
Resume the SPI fifo.
void spi_init_slaves(void)
Initialize all used slaves and unselect them.
@ SPICpolIdleLow
CPOL = 0.
@ SPICpolIdleHigh
CPOL = 1.
@ SPISelect
slave is selected before transaction but not unselected
@ SPINoSelect
slave is not selected nor unselected
@ SPISelectUnselect
slave is selected before transaction and unselected after
@ SPIUnselect
slave is not selected but unselected after transaction
SPI peripheral structure.
SPI transaction structure.
#define SPI_BLOCKING_TIMEOUT
Architecture independent timing functions.
static float get_sys_time_float(void)
Get the time in seconds since startup.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.