Struct esp32c2_hal::Spi
source · pub struct Spi<'d, T, M> { /* private fields */ }
Implementations§
source§impl<'d, T> Spi<'d, T, FullDuplexMode>where
T: Instance,
impl<'d, T> Spi<'d, T, FullDuplexMode>where T: Instance,
sourcepub fn new<SCK, MOSI, MISO, CS>(
spi: impl Peripheral<P = T> + 'd,
sck: impl Peripheral<P = SCK> + 'd,
mosi: impl Peripheral<P = MOSI> + 'd,
miso: impl Peripheral<P = MISO> + 'd,
cs: impl Peripheral<P = CS> + 'd,
frequency: Rate<u32, 1, 1>,
mode: SpiMode,
peripheral_clock_control: &mut PeripheralClockControl,
clocks: &Clocks<'_>
) -> Spi<'d, T, FullDuplexMode>where
SCK: OutputPin,
MOSI: OutputPin,
MISO: InputPin,
CS: OutputPin,
pub fn new<SCK, MOSI, MISO, CS>( spi: impl Peripheral<P = T> + 'd, sck: impl Peripheral<P = SCK> + 'd, mosi: impl Peripheral<P = MOSI> + 'd, miso: impl Peripheral<P = MISO> + 'd, cs: impl Peripheral<P = CS> + 'd, frequency: Rate<u32, 1, 1>, mode: SpiMode, peripheral_clock_control: &mut PeripheralClockControl, clocks: &Clocks<'_> ) -> Spi<'d, T, FullDuplexMode>where SCK: OutputPin, MOSI: OutputPin, MISO: InputPin, CS: OutputPin,
Constructs an SPI instance in 8bit dataframe mode.
sourcepub fn new_no_cs<SCK, MOSI, MISO>(
spi: impl Peripheral<P = T> + 'd,
sck: impl Peripheral<P = SCK> + 'd,
mosi: impl Peripheral<P = MOSI> + 'd,
miso: impl Peripheral<P = MISO> + 'd,
frequency: Rate<u32, 1, 1>,
mode: SpiMode,
peripheral_clock_control: &mut PeripheralClockControl,
clocks: &Clocks<'_>
) -> Spi<'d, T, FullDuplexMode>where
SCK: OutputPin,
MOSI: OutputPin,
MISO: InputPin,
pub fn new_no_cs<SCK, MOSI, MISO>( spi: impl Peripheral<P = T> + 'd, sck: impl Peripheral<P = SCK> + 'd, mosi: impl Peripheral<P = MOSI> + 'd, miso: impl Peripheral<P = MISO> + 'd, frequency: Rate<u32, 1, 1>, mode: SpiMode, peripheral_clock_control: &mut PeripheralClockControl, clocks: &Clocks<'_> ) -> Spi<'d, T, FullDuplexMode>where SCK: OutputPin, MOSI: OutputPin, MISO: InputPin,
Constructs an SPI instance in 8bit dataframe mode without CS pin.
sourcepub fn new_no_cs_no_miso<SCK, MOSI>(
spi: impl Peripheral<P = T> + 'd,
sck: impl Peripheral<P = SCK> + 'd,
mosi: impl Peripheral<P = MOSI> + 'd,
frequency: Rate<u32, 1, 1>,
mode: SpiMode,
peripheral_clock_control: &mut PeripheralClockControl,
clocks: &Clocks<'_>
) -> Spi<'d, T, FullDuplexMode>where
SCK: OutputPin,
MOSI: OutputPin,
pub fn new_no_cs_no_miso<SCK, MOSI>( spi: impl Peripheral<P = T> + 'd, sck: impl Peripheral<P = SCK> + 'd, mosi: impl Peripheral<P = MOSI> + 'd, frequency: Rate<u32, 1, 1>, mode: SpiMode, peripheral_clock_control: &mut PeripheralClockControl, clocks: &Clocks<'_> ) -> Spi<'d, T, FullDuplexMode>where SCK: OutputPin, MOSI: OutputPin,
Constructs an SPI instance in 8bit dataframe mode without CS and MISO pin.
sourcepub fn new_mosi_only<MOSI>(
spi: impl Peripheral<P = T> + 'd,
mosi: impl Peripheral<P = MOSI> + 'd,
frequency: Rate<u32, 1, 1>,
mode: SpiMode,
peripheral_clock_control: &mut PeripheralClockControl,
clocks: &Clocks<'_>
) -> Spi<'d, T, FullDuplexMode>where
MOSI: OutputPin,
pub fn new_mosi_only<MOSI>( spi: impl Peripheral<P = T> + 'd, mosi: impl Peripheral<P = MOSI> + 'd, frequency: Rate<u32, 1, 1>, mode: SpiMode, peripheral_clock_control: &mut PeripheralClockControl, clocks: &Clocks<'_> ) -> Spi<'d, T, FullDuplexMode>where MOSI: OutputPin,
Constructs an SPI instance in 8bit dataframe mode with only MOSI connected. This might be useful for (ab)using SPI to implement other protocols by bitbanging (WS2812B, onewire, generating arbitrary waveforms…)
pub fn change_bus_frequency( &mut self, frequency: Rate<u32, 1, 1>, clocks: &Clocks<'_> )
source§impl<'d, T> Spi<'d, T, HalfDuplexMode>where
T: ExtendedInstance,
impl<'d, T> Spi<'d, T, HalfDuplexMode>where T: ExtendedInstance,
sourcepub fn new_half_duplex<SCK, MOSI, MISO, SIO2, SIO3, CS>(
spi: impl Peripheral<P = T> + 'd,
sck: Option<impl Peripheral<P = SCK> + 'd>,
mosi: Option<impl Peripheral<P = MOSI> + 'd>,
miso: Option<impl Peripheral<P = MISO> + 'd>,
sio2: Option<impl Peripheral<P = SIO2> + 'd>,
sio3: Option<impl Peripheral<P = SIO3> + 'd>,
cs: Option<impl Peripheral<P = CS> + 'd>,
frequency: Rate<u32, 1, 1>,
mode: SpiMode,
peripheral_clock_control: &mut PeripheralClockControl,
clocks: &Clocks<'_>
) -> Spi<'d, T, HalfDuplexMode>where
SCK: OutputPin,
MOSI: OutputPin + InputPin,
MISO: OutputPin + InputPin,
SIO2: OutputPin + InputPin,
SIO3: OutputPin + InputPin,
CS: OutputPin,
pub fn new_half_duplex<SCK, MOSI, MISO, SIO2, SIO3, CS>( spi: impl Peripheral<P = T> + 'd, sck: Option<impl Peripheral<P = SCK> + 'd>, mosi: Option<impl Peripheral<P = MOSI> + 'd>, miso: Option<impl Peripheral<P = MISO> + 'd>, sio2: Option<impl Peripheral<P = SIO2> + 'd>, sio3: Option<impl Peripheral<P = SIO3> + 'd>, cs: Option<impl Peripheral<P = CS> + 'd>, frequency: Rate<u32, 1, 1>, mode: SpiMode, peripheral_clock_control: &mut PeripheralClockControl, clocks: &Clocks<'_> ) -> Spi<'d, T, HalfDuplexMode>where SCK: OutputPin, MOSI: OutputPin + InputPin, MISO: OutputPin + InputPin, SIO2: OutputPin + InputPin, SIO3: OutputPin + InputPin, CS: OutputPin,
Constructs an SPI instance in half-duplex mode.
All pins are optional. Pass crate::gpio::NO_PIN if you don’t need the given pin.
pub fn change_bus_frequency( &mut self, frequency: Rate<u32, 1, 1>, clocks: &Clocks<'_> )
Trait Implementations§
source§impl<T, M> FullDuplex<u8> for Spi<'_, T, M>where
T: Instance,
M: IsFullDuplex,
impl<T, M> FullDuplex<u8> for Spi<'_, T, M>where T: Instance, M: IsFullDuplex,
source§impl<T, M> HalfDuplexReadWrite for Spi<'_, T, M>where
T: Instance,
M: IsHalfDuplex,
impl<T, M> HalfDuplexReadWrite for Spi<'_, T, M>where T: Instance, M: IsHalfDuplex,
source§impl<'d, T, RX, TX, P, M> WithDmaSpi2<'d, T, RX, TX, P, M> for Spi<'d, T, M>where
T: Instance + Spi2Instance,
TX: Tx,
RX: Rx,
P: SpiPeripheral + Spi2Peripheral,
M: DuplexMode,
impl<'d, T, RX, TX, P, M> WithDmaSpi2<'d, T, RX, TX, P, M> for Spi<'d, T, M>where T: Instance + Spi2Instance, TX: Tx, RX: Rx, P: SpiPeripheral + Spi2Peripheral, M: DuplexMode,
Auto Trait Implementations§
impl<'d, T, M> RefUnwindSafe for Spi<'d, T, M>where M: RefUnwindSafe, T: RefUnwindSafe,
impl<'d, T, M> Send for Spi<'d, T, M>where M: Send, T: Send,
impl<'d, T, M> Sync for Spi<'d, T, M>where M: Sync, T: Sync,
impl<'d, T, M> Unpin for Spi<'d, T, M>where M: Unpin, T: Unpin,
impl<'d, T, M> !UnwindSafe for Spi<'d, T, M>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more