26#include "hal/buffer.h"
41#define SPI_EVENT_ERROR (1 << 1)
46#define SPI_EVENT_COMPLETE (1 << 2)
52#define SPI_EVENT_RX_OVERFLOW (1 << 3)
57#define SPI_EVENT_ALL (SPI_EVENT_ERROR | SPI_EVENT_COMPLETE | SPI_EVENT_RX_OVERFLOW)
61#define SPI_EVENT_INTERNAL_TRANSFER_COMPLETE (1 << 30)
63#define SPI_FILL_WORD (0xFFFF)
64#define SPI_FILL_CHAR (0xFF)
78typedef struct spi_s
spi_t;
182#ifdef DEVICE_SPI_COUNT
190SPIName spi_get_peripheral_name(PinName mosi, PinName miso, PinName mclk);
223void spi_init(
spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel);
uint32_t spi_irq_handler_asynch(spi_t *obj)
The asynchronous IRQ handler.
bool spi_master_transfer(spi_t *obj, const void *tx, size_t tx_length, void *rx, size_t rx_length, uint8_t bit_width, uint32_t handler, uint32_t event, DMAUsage hint)
Begin the asynchronous SPI transfer.
uint8_t spi_active(spi_t *obj)
Attempts to determine if the SPI peripheral is already in use.
void spi_abort_asynch(spi_t *obj)
Abort an SPI transfer.
int spi_slave_read(spi_t *obj)
Get a received value out of the SPI receive buffer in slave mode.
int spi_busy(spi_t *obj)
Checks if the specified SPI peripheral is in use.
const PinMap * spi_master_cs_pinmap(void)
Get the pins that support SPI CS.
const PinMap * spi_master_mosi_pinmap(void)
Get the pins that support SPI MOSI.
void spi_slave_write(spi_t *obj, int value)
Write a value to the SPI peripheral in slave mode.
int spi_master_write(spi_t *obj, int value)
Write a byte out in master mode and receive a value.
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, char write_fill)
Write a block out in master mode and receive a value.
const PinMap * spi_master_clk_pinmap(void)
Get the pins that support SPI CLK.
int spi_slave_receive(spi_t *obj)
Check if a value is available to read.
const PinMap * spi_slave_miso_pinmap(void)
Get the pins that support SPI MISO.
const PinMap * spi_slave_cs_pinmap(void)
Get the pins that support SPI CS.
const PinMap * spi_slave_mosi_pinmap(void)
Get the pins that support SPI MOSI.
const PinMap * spi_master_miso_pinmap(void)
Get the pins that support SPI MISO.
uint8_t spi_get_module(spi_t *obj)
Get the module number.
const PinMap * spi_slave_clk_pinmap(void)
Get the pins that support SPI CLK.
void spi_frequency(spi_t *obj, int hz)
Set the SPI baud rate.
void spi_free(spi_t *obj)
Release a SPI object.
void spi_init_direct(spi_t *obj, const spi_pinmap_t *pinmap)
Initialize the SPI peripheral.
void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
Initialize the SPI peripheral.
void spi_format(spi_t *obj, int bits, int mode, int slave)
Configure the SPI format.
void spi_get_capabilities(PinName ssel, bool slave, spi_capabilities_t *cap)
Fills the given spi_capabilities_t structure with the capabilities of the given peripheral.
DMAUsage
Enumeration of possible DMA usage hints.
Generic buffer structure.
Describes the capabilities of a SPI peripherals.
bool tx_rx_buffers_equal_length
If true, rx and tx buffers must have the same length.
uint16_t slave_delay_between_symbols_ns
specifies required number of ns between transmission of successive symbols in slave mode.
uint32_t word_length
Each bit represents the corresponding word length.
bool async_mode
If true, in async mode is supported.
uint8_t clk_modes
specifies supported modes from spi_mode_t.
uint32_t maximum_frequency
Maximum frequency supported must be set by target device and it will be assessed during testing.
bool hw_cs_handle
If true, in SPI master mode Chip Select can be handled by hardware.
bool support_slave_mode
If true, the device can handle SPI slave mode using hardware management on the specified ssel pin.
uint32_t minimum_frequency
Minimum frequency supported must be set by target device and it will be assessed during testing.
Asynch SPI HAL structure.