@web-font-path: "roboto-debian.css";
v2.2.0 (RP2040)
Loading...
Searching...
No Matches
spi.h File Reference
`#include "pico.h"`
`#include "hardware/structs/spi.h"`
`#include "hardware/regs/dreq.h"`
Include dependency graph for spi.h:

Go to the source code of this file.

## Macros

#define | PARAM_ASSERTIONS_ENABLED_HARDWARE_SPI 0
#define | spi0 ((spi_inst_t *)spi0_hw)
#define | spi1 ((spi_inst_t *)spi1_hw)
#define | SPI_NUM(spi)
| Returns the SPI number for a SPI instance.
#define | SPI_INSTANCE(num)
| Returns the SPI instance with the given SPI number.
#define | SPI_DREQ_NUM(spi, is_tx)
| Returns the dreq_num_t used for pacing DMA transfers to or from this SPI instance. If is_tx is true, then it is for transfers to the SPI else for transfers from the SPI.

## Typedefs

typedef struct spi_inst | spi_inst_t
| Opaque type representing an SPI instance.

## Enumerations

enum | spi_cpha_t { SPI_CPHA_0 = 0 , SPI_CPHA_1 = 1 }
| Enumeration of SPI CPHA (clock phase) values.
enum | spi_cpol_t { SPI_CPOL_0 = 0 , SPI_CPOL_1 = 1 }
| Enumeration of SPI CPOL (clock polarity) values.
enum | spi_order_t { SPI_LSB_FIRST = 0 , SPI_MSB_FIRST = 1 }
| Enumeration of SPI bit-order values.

## Functions

uint | spi_init (spi_inst_t *spi, uint baudrate)
| Initialise SPI instances.
void | spi_deinit (spi_inst_t *spi)
| Deinitialise SPI instances.
uint | spi_set_baudrate (spi_inst_t *spi, uint baudrate)
| Set SPI baudrate.
uint | spi_get_baudrate (const spi_inst_t *spi)
| Get SPI baudrate.
static uint | spi_get_index (const spi_inst_t *spi)
| Convert SPI instance to hardware instance number.
static spi_hw_t * | spi_get_hw (spi_inst_t *spi)
static const spi_hw_t * | spi_get_const_hw (const spi_inst_t *spi)
static void | spi_set_format (spi_inst_t *spi, uint data_bits, spi_cpol_t cpol, spi_cpha_t cpha, __unused spi_order_t order)
| Configure SPI.
static void | spi_set_slave (spi_inst_t *spi, bool slave)
| Set SPI master/slave.
static bool | spi_is_writable (const spi_inst_t *spi)
| Check whether a write can be done on SPI device.
static bool | spi_is_readable (const spi_inst_t *spi)
| Check whether a read can be done on SPI device.
static bool | spi_is_busy (const spi_inst_t *spi)
| Check whether SPI is busy.
int | spi_write_read_blocking (spi_inst_t *spi, const uint8_t *src, uint8_t *dst, size_t len)
| Write/Read to/from an SPI device.
int | spi_write_blocking (spi_inst_t *spi, const uint8_t *src, size_t len)
| Write to an SPI device, blocking.
int | spi_read_blocking (spi_inst_t *spi, uint8_t repeated_tx_data, uint8_t *dst, size_t len)
| Read from an SPI device.
int | spi_write16_read16_blocking (spi_inst_t *spi, const uint16_t *src, uint16_t *dst, size_t len)
| Write/Read half words to/from an SPI device.
int | spi_write16_blocking (spi_inst_t *spi, const uint16_t *src, size_t len)
| Write to an SPI device.
int | spi_read16_blocking (spi_inst_t *spi, uint16_t repeated_tx_data, uint16_t *dst, size_t len)
| Read from an SPI device.
static uint | spi_get_dreq (spi_inst_t *spi, bool is_tx)
| Return the DREQ to use for pacing transfers to/from a particular SPI instance.