pub fn init_spi_master(
spi2: SPI2<'static>,
sck: impl PeripheralOutput<'static>,
mosi: impl PeripheralOutput<'static>,
miso: impl PeripheralInput<'static>,
frequency: HertzU32,
) -> Result<SpiBusInner, SpiInitError>Expand description
Initialises the ESP32-S3 SPI2 master bus at the requested frequency.
This is called once during crate::Lilka::init. The SPI2 peripheral is
hardwired to three specific GPIOs on the Lilka PCB:
| Signal | GPIO |
|---|---|
| SCK (clock) | GPIO18 |
| MOSI (data out) | GPIO17 |
| MISO (data in) | GPIO8 |
In async builds the returned bus is automatically converted to async mode
via Spi::into_async().
§Parameters
spi2— Ownership of theSPI2peripheral token.sck/mosi/miso— GPIO peripheral tokens (consumed permanently).frequency— Desired bus clock frequency. The hardware rounds to the nearest achievable value. Use values ≤ 80 MHz; the ST7789 display supports up to ~80 MHz but SD cards max out at 25 MHz in standard speed mode.
§Returns
Ok(SpiBusInner) on success, or Err(SpiInitError::BusInitFailed).
§Example
use lilkaoxide::{init_spi_master, LilkaSpiBus};
use fugit::RateExtU32;
let spi: LilkaSpiBus = init_spi_master(
peripherals.SPI2,
peripherals.GPIO18,
peripherals.GPIO17,
peripherals.GPIO8,
60.MHz(),
).expect("SPI init failed");