Module imxrt_hal::spi [−][src]
SPI support
The module provides an implementation of the embedded_hal::spi::FullDuplex
trait.
All blocking implementations are provided by the default implementations from
embedded_hal
.
Chip selects (CS) for SPI peripherals
The iMXRT SPI peripherals have one or more peripheral-controlled chip selects (CS). Using
the peripheral-controlled CS means that you do not need a GPIO to coordinate SPI operations.
The peripheral-controlled CS is disabled by default. Use the enable_chip_select_N
, where
N
is the CS number, to enable the peripheral-controlled CS. Your hardware must be wired to
accomodate this selection. If you do not want to use the peripheral-controlled CS, you may
select your own GPIO.
Example
use imxrt_hal; use embedded_hal::blocking::spi::Transfer; let mut peripherals = imxrt_hal::Peripherals::take().unwrap(); let (_, _, _, spi4_builder) = peripherals.spi.clock( &mut peripherals.ccm.handle, imxrt_hal::ccm::spi::ClockSelect::Pll2, imxrt_hal::ccm::spi::PrescalarSelect::LPSPI_PODF_5, ); let mut spi4 = spi4_builder.build( peripherals.iomuxc.b0.p02, peripherals.iomuxc.b0.p01, peripherals.iomuxc.b0.p03, ); spi4.enable_chip_select_0(peripherals.iomuxc.b0.p00); spi4.set_clock_speed(imxrt_hal::spi::ClockSpeed(1_000_000)).unwrap(); let mut buffer: [u8; 3] = [1, 2, 3]; spi4.transfer(&mut buffer).unwrap();
Structs
Builder | A SPI builder that can build a SPI peripheral |
BusIdleTimeoutError | Indicates an error when computing the parameters that control the bus idle timeout |
ClockSpeed | SPI Clock speed, in Hz |
ClockSpeedError | Indicates an error when computing the parameters that control the clock speed. |
ModeError | Indicates an error when computing the parameters that control the mode. |
PinLowTimeoutError | Indicates an error when computing the parameters that control the pin low timeout |
SPI | An SPI master |
Unclocked | Unclocked SPI modules |
Enums
Error | An error that occured during a SPI operation |