Module esp_idf_svc::hal::spi

source ·
Expand description

SPI peripheral control

SPI0 is reserved for accessing flash and sram and therefore not usable for other purposes. SPI1 shares its external pins with SPI0 and therefore has severe restrictions in use.

SPI2 & 3 can be used freely.

The CS pin can be controlled by hardware on esp32 variants (contrary to the description of embedded_hal).

Look at the following table to determine which driver best suits your requirements:

SpiDeviceDriver::newSpiDeviceDriver::new (no CS)SpiSoftCsDeviceDriver::newSpiBusDriver::new
Managed CSHardwareNSoftware triggeredN
1 deviceYYYY
1-3 devicesYNYN
4-6 devicesOnly on esp32CXNYN
More than 6NNYN
DMANNNN
Polling transmitYYYY
ISR transmitYYYY
Async support*YYYY
  • True non-blocking async possible only when all devices attached to the SPI bus are used in async mode (i.e. calling methods xxx_async() instead of their blocking xxx() counterparts)

The [Transfer::transfer], [Write::write] and [WriteIter::write_iter] functions lock the APB frequency and therefore the requests are always run at the requested baudrate. The primitive [FullDuplex::read] and [FullDuplex::send] do not lock the APB frequency and therefore may run at a different frequency.

§TODO

  • Quad SPI
  • Slave SPI

Modules§

Structs§

Enums§

Traits§

  • A marker interface implemented by all SPI peripherals except SPI1 which should use a fixed set of pins

Type Aliases§