atsamd_hal::sercom::spi

Struct Spi

Source
pub struct Spi<C, A, RxDma = NoneT, TxDma = NoneT>
where C: ValidConfig, A: Capability,
{ /* private fields */ }
Expand description

An enabled SPI peripheral that can perform transactions

See the impl_ehal documentation for details on the implementations of the embedded HAL traits, which vary based on Size and Capability.

Implementations§

Source§

impl<C, A, S> Spi<C, A>
where C: ValidConfig<Sercom = S>, A: Capability, S: Sercom,

Source

pub fn into_future<I>(self, _interrupts: I) -> SpiFuture<C, A>

Turn an Spi into a SpiFuture.

In cases where the underlying Spi is Duplex, reading words need to be accompanied with sending a no-op word. By default it is set to 0x00, but you can configure it by using the nop_word method.

Source§

impl<C, A, RxDma, TxDma> Spi<C, A, RxDma, TxDma>
where C: ValidConfig, A: Capability,

Source

pub fn reconfigure(&mut self, update: impl FnOnce(&mut SpecificConfig<C>))

Update the SPI configuration.

Calling this method will temporarily disable the SERCOM peripheral, as some registers are enable-protected. This may interrupt any ongoing transactions.

Source

pub fn enable_interrupts(&mut self, flags: Flags)

Enable interrupts for the specified flags

Source

pub fn disable_interrupts(&mut self, flags: Flags)

Disable interrupts for the specified flags

Source

pub fn read_flags(&self) -> Flags

Read the interrupt flags

Source

pub fn clear_flags(&mut self, flags: Flags)

Clear the corresponding interrupt flags

Only the ERROR, SSL and TXC flags can be cleared.

Note: The implementation of of serial::Write::flush waits on and clears the TXC flag. Manually clearing this flag could cause it to hang indefinitely.

Source

pub fn read_status(&self) -> Status

Read the error status flags

Source

pub fn clear_status(&mut self, status: Status)

Clear the corresponding error status flags

Source

pub fn read_flags_errors(&self) -> Result<Flags, Error>

Try to read the interrupt flags, but first check the error status flags.

Source

pub unsafe fn read_data(&mut self) -> DataWidth

Read from the DATA register

§Safety

Reading from the data register directly is unsafe, because it will clear the RXC flag, which could break assumptions made elsewhere in this module.

Source

pub unsafe fn write_data(&mut self, data: DataWidth)

Write to the DATA register

§Safety

Writing to the data register directly is unsafe, because it will clear the DRE flag, which could break assumptions made elsewhere in this module.

Source

pub fn disable(self) -> C

Disable the SPI peripheral and return the Config struct

Source§

impl<C, D> Spi<C, D>

Source

pub fn with_dma_channels<R, T>(self, rx: R, tx: T) -> Spi<C, D, R, T>
where R: AnyChannel<Status = Ready>, T: AnyChannel<Status = Ready>,

Attach RX and TX DMA channels to this Spi. Its SpiBus implementation will use DMA to carry out its transactions. In Master mode, since even read SPI transaction necessarily involve a write, Rx-only must take two DMA channels, just the same as if it were Duplex.

Source§

impl<C, D, RxDma, TxDma, S> Spi<C, D, RxDma, TxDma>
where C: ValidConfig, D: Capability, RxDma: AnyChannel<Status = S>, TxDma: AnyChannel<Status = S>, S: ReadyChannel,

Source

pub fn take_dma_channels(self) -> (Spi<C, D, NoneT, NoneT>, RxDma, TxDma)

Reclaim the DMA channels. Any subsequent SPI transaction will not use DMA.

Source§

impl<C> Spi<C, Duplex>
where C: ValidConfig<OpMode = Slave>,

Source

pub fn with_dma_channels_slave<R, T>(self, rx: R, tx: T) -> Spi<C, Duplex, R, T>
where R: AnyChannel<Status = Ready>, T: AnyChannel<Status = Ready>,

Attach a DMA channel to this Spi. Its SpiBus implementation will use DMA to carry out its transactions. In Slave mode, a Duplex Spi needs two DMA channels.

Source§

impl<C> Spi<C, Rx>
where C: ValidConfig<OpMode = Slave>,

Source

pub fn with_rx_channel<R>(self, rx: R) -> Spi<C, Rx, R, NoneT>
where R: AnyChannel<Status = Ready>,

Attach a DMA channel to this Spi. Its SpiBus implementation will use DMA to carry out its transactions. In Slave mode, a Rx Spi only needs a single DMA channel.

Source§

impl<C, D, R, T, S> Spi<C, D, R, T>
where C: ValidConfig, D: Receive, R: AnyChannel<Status = S>, S: ReadyChannel,

Source

pub fn take_rx_channel(self) -> (Spi<C, D, NoneT, T>, R)

Reclaim the Rx DMA channel. Any subsequent SPI transaction will not use DMA.

Source§

impl<C> Spi<C, Tx>
where C: ValidConfig,

Source

pub fn with_tx_channel<T>(self, tx: T) -> Spi<C, Tx, NoneT, T>
where T: AnyChannel<Status = Ready>,

Attach a DMA channel to this Spi. Its SpiBus implementation will use DMA to carry out its transactions. For Tx Spis, only a single DMA channel is necessary.

Source§

impl<C, D, R, T, S> Spi<C, D, R, T>
where C: ValidConfig, D: Capability, T: AnyChannel<Status = S>, S: ReadyChannel,

Source

pub fn take_tx_channel(self) -> (Spi<C, D, R, NoneT>, T)

Reclaim the DMA channel. Any subsequent SPI transaction will not use DMA.

Source§

impl<C: ValidConfig, R, T> Spi<C, Tx, R, T>

Source

pub fn into_panic_on_write(self) -> PanicOnWrite<Self>

Turn a Tx Spi into a PanicOnWrite

Source§

impl<C: ValidConfig, R, T> Spi<C, Tx, R, T>

Source

pub fn into_panic_on_read(self) -> PanicOnRead<Self>

Turn a Rx Spi into a PanicOnRead

Source§

impl<C, A> Spi<C, A>
where C: ValidConfig, A: Transmit, Self: Buffer<Beat = C::Word>,

Source

pub fn send_with_dma<Ch, B>( self, buf: B, channel: Ch, ) -> Transfer<Channel<Ch::Id, Busy>, BufferPair<B, Self>>
where Ch: AnyChannel<Status = Ready>, B: Buffer<Beat = C::Word> + 'static,

👎Deprecated since 0.19.0: Use Spi::with_dma_channels instead. You will have access to DMA-enabled embedded-hal implementations.

Transform an Spi into a DMA Transfer) and start a send transaction.

Source§

impl<C, A> Spi<C, A>
where C: ValidConfig, A: Receive, Self: Buffer<Beat = C::Word>,

Source

pub fn receive_with_dma<Ch, B>( self, buf: B, channel: Ch, ) -> Transfer<Channel<Ch::Id, Busy>, BufferPair<Self, B>>
where Ch: AnyChannel<Status = Ready>, B: Buffer<Beat = C::Word> + 'static,

👎Deprecated since 0.19.0: Use Spi::with_dma_channels instead. You will have access to DMA-enabled embedded-hal implementations.

Transform an Spi into a DMA Transfer) and start a receive transaction.

Trait Implementations§

Source§

impl<C, A> AnySpi for Spi<C, A>
where C: ValidConfig, A: Capability,

Source§

impl<C, A> AsMut<Spi<C, A>> for Spi<C, A>
where C: ValidConfig, A: Capability,

Source§

fn as_mut(&mut self) -> &mut Self

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<C, A, R, T> AsMut<Spi<C, A, R, T>> for SpiFuture<C, A, R, T>
where C: ValidConfig, A: Capability,

Source§

fn as_mut(&mut self) -> &mut Spi<C, A, R, T>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<C: ValidConfig, R, T> AsMut<Spi<C, Rx, R, T>> for PanicOnWrite<Spi<C, Rx, R, T>>

Source§

fn as_mut(&mut self) -> &mut Spi<C, Rx, R, T>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<C: ValidConfig, R, T> AsMut<Spi<C, Tx, R, T>> for PanicOnRead<Spi<C, Tx, R, T>>

Source§

fn as_mut(&mut self) -> &mut Spi<C, Tx, R, T>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<C, A> AsRef<Config<<C as AnyConfig>::Pads, <C as AnyConfig>::OpMode, <C as AnyConfig>::Size>> for Spi<C, A>
where C: ValidConfig, A: Capability,

Get a shared reference to the underlying Config struct

This can be used to call the various get_* functions on Config

Source§

fn as_ref(&self) -> &SpecificConfig<C>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<C, A> AsRef<Spi<C, A>> for Spi<C, A>
where C: ValidConfig, A: Capability,

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<C, A, R, T> AsRef<Spi<C, A, R, T>> for SpiFuture<C, A, R, T>
where C: ValidConfig, A: Capability,

Source§

fn as_ref(&self) -> &Spi<C, A, R, T>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<C: ValidConfig, R, T> AsRef<Spi<C, Rx, R, T>> for PanicOnWrite<Spi<C, Rx, R, T>>

Source§

fn as_ref(&self) -> &Spi<C, Rx, R, T>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<C: ValidConfig, R, T> AsRef<Spi<C, Tx, R, T>> for PanicOnRead<Spi<C, Tx, R, T>>

Source§

fn as_ref(&self) -> &Spi<C, Tx, R, T>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<C, A> Buffer for Spi<C, A>
where C: ValidConfig, C::OpMode: MasterMode, C::Size: AtomicSize<Word = C::Word>, C::Word: Beat, A: Capability,

Source§

type Beat = <C as AnyConfig>::Word

DMAC beat size
Source§

fn dma_ptr(&mut self) -> *mut Self::Beat

Pointer to the buffer. If the buffer is incrementing, the address should point to one past the last beat transfer in the block.
Source§

fn incrementing(&self) -> bool

Return whether the buffer pointer should be incrementing or not
Source§

fn buffer_len(&self) -> usize

Buffer length in beats
Source§

impl<C, D, R, T> ErrorType for Spi<C, D, R, T>
where C: ValidConfig, D: Capability,

Source§

type Error = Error

Error type.
Source§

impl<C, D, R, T> ErrorType for Spi<C, D, R, T>
where C: ValidConfig, D: Capability,

Source§

type Error = Error

Error type of all the IO operations on this type.
Source§

impl<C, D, R, T> ErrorType for Spi<C, D, R, T>
where C: ValidConfig, D: Capability,

Source§

type Error = Error

Error type
Source§

impl<C: ValidConfig, R, T> From<PanicOnRead<Spi<C, Tx, R, T>>> for Spi<C, Tx, R, T>

Source§

fn from(value: PanicOnRead<Spi<C, Tx, R, T>>) -> Self

Converts to this type from the input type.
Source§

impl<C: ValidConfig, R, T> From<PanicOnWrite<Spi<C, Rx, R, T>>> for Spi<C, Rx, R, T>

Source§

fn from(value: PanicOnWrite<Spi<C, Rx, R, T>>) -> Self

Converts to this type from the input type.
Source§

impl<C> FullDuplex<<C as AnyConfig>::Word> for Spi<C, Duplex>

Implement [spi::FullDuplex] for Spi structs with AtomicSize

spi::FullDuplex is only implemented when the Spi struct has Duplex Capability. The Word size used in the implementation depends on the corresponding CharSize.

Source§

fn read(&mut self) -> Result<C::Word, Error>

Reads the word stored in the shift register Read more
Source§

fn write(&mut self, word: C::Word) -> Result<(), Self::Error>

Writes a word to the slave
Source§

impl<P, M, C> Read<<C as CharSize>::Word> for Spi<Config<P, M, C>, Rx>

Implement Read for Rx Spi structs in a MasterMode

Read is only implemented for Spi structs with Rx Capability. In a MasterMode, Read has to initiate transactions, so it keeps track of the transaction state. If a transaction is in progress, it will wait on RXC. If not, it will wait on DRE, and then send 0.

Source§

fn read(&mut self) -> Result<C::Word, Error>

Reads a single word from the serial interface
Source§

impl<P, C> Read<<C as CharSize>::Word> for Spi<Config<P, Slave, C>, Rx>

Implement Read for Rx Spi structs in Slave OpMode

Read is only implemented for Spi structs with Rx Capability. In Slave OpMode, Read does not have to initiate transactions, so it does not have to store any internal state. It only has to wait on RXC.

Source§

fn read(&mut self) -> Result<C::Word, Error>

Wait for an RXC flag, then read the word

Source§

impl<P, M> Read for Spi<Config<P, M, EightBit>, Rx>

Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>

Read the exact number of bytes required to fill buf. Read more
Source§

impl<P, M, Z, D, R, T, S> Read for Spi<Config<P, M, Z>, D, R, T>
where P: ValidPads, M: MasterMode, Z: Size<Word = u8> + 'static, Config<P, M, Z>: ValidConfig<Sercom = S>, D: Receive, S: Sercom, R: AnyChannel<Status = Ready>, T: AnyChannel<Status = Ready>,

embedded_io::Read implementation for Receive Spis in MasterMode, using DMA transfers.

Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>

Read the exact number of bytes required to fill buf. Read more
Source§

impl<P> Read for Spi<Config<P, Slave, EightBit>, Rx>

Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>

Read the exact number of bytes required to fill buf. Read more
Source§

impl<P, Z, D, R, T, S> Read for Spi<Config<P, Slave, Z>, D, R, T>
where P: ValidPads, Z: Size<Word = u8> + 'static, Config<P, Slave, Z>: ValidConfig<Sercom = S>, D: Receive, S: Sercom, R: AnyChannel<Status = Ready>,

embedded_io::Read implementation for Receive Spis in Slave mode, using DMA transfers.

Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>

Read the exact number of bytes required to fill buf. Read more
Source§

impl<P, M, C> SpiBus<<C as CharSize>::Word> for Spi<Config<P, M, C>, Duplex>
where Config<P, M, C>: ValidConfig, P: ValidPads, M: MasterMode, C: Size + 'static, C::Word: PrimInt + AsPrimitive<DataWidth> + Copy, DataWidth: AsPrimitive<C::Word>,

SpiBus implementation for Spi, using word-by-word transfers.

Source§

fn read(&mut self, words: &mut [Word<C>]) -> Result<(), Self::Error>

Read words from the slave. Read more
Source§

fn write(&mut self, words: &[Word<C>]) -> Result<(), Self::Error>

Write words to the slave, ignoring all the incoming words. Read more
Source§

fn transfer( &mut self, read: &mut [Word<C>], write: &[Word<C>], ) -> Result<(), Self::Error>

Write and read simultaneously. write is written to the slave on MOSI and words received on MISO are stored in read. Read more
Source§

fn transfer_in_place( &mut self, words: &mut [Word<C>], ) -> Result<(), Self::Error>

Write and read simultaneously. The contents of words are written to the slave, and the received words are stored into the same words buffer, overwriting it. Read more
Source§

fn flush(&mut self) -> Result<(), Error>

Wait until all operations have completed and the bus is idle. Read more
Source§

impl<P, M, S, C, R, T> SpiBus<<C as CharSize>::Word> for Spi<Config<P, M, C>, Duplex, R, T>
where Config<P, M, C>: ValidConfig<Sercom = S>, S: Sercom, P: ValidPads, M: MasterMode, C: Size + 'static, C::Word: PrimInt + AsPrimitive<DataWidth> + Beat, DataWidth: AsPrimitive<C::Word>, R: AnyChannel<Status = Ready>, T: AnyChannel<Status = Ready>,

SpiBus implementation for Spi, using DMA transfers.

Source§

fn read(&mut self, words: &mut [C::Word]) -> Result<(), Self::Error>

Read words from the slave. Read more
Source§

fn write(&mut self, words: &[C::Word]) -> Result<(), Self::Error>

Write words to the slave, ignoring all the incoming words. Read more
Source§

fn transfer( &mut self, read: &mut [C::Word], write: &[C::Word], ) -> Result<(), Self::Error>

Write and read simultaneously. write is written to the slave on MOSI and words received on MISO are stored in read. Read more
Source§

fn transfer_in_place( &mut self, words: &mut [C::Word], ) -> Result<(), Self::Error>

Write and read simultaneously. The contents of words are written to the slave, and the received words are stored into the same words buffer, overwriting it. Read more
Source§

fn flush(&mut self) -> Result<(), Error>

Wait until all operations have completed and the bus is idle. Read more
Source§

impl<P, M, C> Write<<C as CharSize>::Word> for Spi<Config<P, M, C>, Tx>

Implement Write for Tx Spi structs

Write is only implemented for Spi structs with Tx Capability. Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

Source§

fn write(&mut self, word: C::Word) -> Result<(), Error>

Writes a single word to the serial interface.
Source§

fn flush(&mut self) -> Result<(), Error>

Ensures that none of the previously written words are still buffered.
Source§

impl<P, M> Write for Spi<Config<P, M, EightBit>, Tx>
where Config<P, M, EightBit>: ValidConfig, P: ValidPads, M: OpMode,

Source§

fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>

Write a buffer into this writer, returning how many bytes were written. Read more
Source§

fn flush(&mut self) -> Result<(), Self::Error>

Flush this output stream, blocking until all intermediately buffered contents reach their destination.
Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error>

Write an entire buffer into this writer. Read more
Source§

fn write_fmt( &mut self, fmt: Arguments<'_>, ) -> Result<(), WriteFmtError<Self::Error>>

Write a formatted string into this writer, returning any error encountered. Read more
Source§

impl<P, M, Z, D, R, T, S> Write for Spi<Config<P, M, Z>, D, R, T>
where P: ValidPads, M: OpMode, Z: Size<Word = u8> + 'static, Config<P, M, Z>: ValidConfig<Sercom = S>, D: Transmit, S: Sercom, T: AnyChannel<Status = Ready>,

embedded_io::Write implementation for Transmit Spis in either Slave or MasterMode, using DMA transfers.

Source§

fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>

Write a buffer into this writer, returning how many bytes were written. Read more
Source§

fn flush(&mut self) -> Result<(), Self::Error>

Flush this output stream, blocking until all intermediately buffered contents reach their destination.
Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error>

Write an entire buffer into this writer. Read more
Source§

fn write_fmt( &mut self, fmt: Arguments<'_>, ) -> Result<(), WriteFmtError<Self::Error>>

Write a formatted string into this writer, returning any error encountered. Read more
Source§

impl<P, M> WriteIter<<EightBit as CharSize>::Word> for Spi<Config<P, M, EightBit>, Duplex>
where Config<P, M, EightBit>: ValidConfig, P: ValidPads, M: OpMode,

Implement WriteIter for Spi structs with Duplex Capability

The transfer accepts a slice of primitive integers, depending on the CharSize (u8 or u16).

Source§

type Error = Error

Error type
Source§

fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error>
where WI: IntoIterator<Item = Word<EightBit>>,

Sends words to the slave, ignoring all the incoming words
Source§

impl<P, M> WriteIter<<EightBit as CharSize>::Word> for Spi<Config<P, M, EightBit>, Tx>
where Config<P, M, EightBit>: ValidConfig, P: ValidPads, M: OpMode,

Implement WriteIter for Spi structs with Tx Capability

The transfer accepts a slice of primitive integers, depending on the CharSize (u8 or u16).

Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

Source§

type Error = Error

Error type
Source§

fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error>
where WI: IntoIterator<Item = Word<EightBit>>,

Sends words to the slave, ignoring all the incoming words
Source§

impl<P, M> WriteIter<<NineBit as CharSize>::Word> for Spi<Config<P, M, NineBit>, Duplex>
where Config<P, M, NineBit>: ValidConfig, P: ValidPads, M: OpMode,

Implement WriteIter for Spi structs with Duplex Capability

The transfer accepts a slice of primitive integers, depending on the CharSize (u8 or u16).

Source§

type Error = Error

Error type
Source§

fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error>
where WI: IntoIterator<Item = Word<NineBit>>,

Sends words to the slave, ignoring all the incoming words
Source§

impl<P, M> WriteIter<<NineBit as CharSize>::Word> for Spi<Config<P, M, NineBit>, Tx>
where Config<P, M, NineBit>: ValidConfig, P: ValidPads, M: OpMode,

Implement WriteIter for Spi structs with Tx Capability

The transfer accepts a slice of primitive integers, depending on the CharSize (u8 or u16).

Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

Source§

type Error = Error

Error type
Source§

fn write_iter<WI>(&mut self, words: WI) -> Result<(), Error>
where WI: IntoIterator<Item = Word<NineBit>>,

Sends words to the slave, ignoring all the incoming words
Source§

impl<P, M, A> Transfer<<EightBit as CharSize>::Word> for Spi<Config<P, M, EightBit>, A>
where Config<P, M, EightBit>: ValidConfig, P: ValidPads, M: OpMode, A: Receive,

Implement Transfer for Spi structs that can Receive

The transfer accepts a slice of primitive integers, depending on the CharSize (u8 or u16).

Source§

type Error = Error

Error type
Source§

fn transfer<'w>( &mut self, words: &'w mut [Word<EightBit>], ) -> Result<&'w [Word<EightBit>], Error>

Sends words to the slave. Returns the words received from the slave
Source§

impl<P, M, A> Transfer<<NineBit as CharSize>::Word> for Spi<Config<P, M, NineBit>, A>
where Config<P, M, NineBit>: ValidConfig, P: ValidPads, M: OpMode, A: Receive,

Implement Transfer for Spi structs that can Receive

The transfer accepts a slice of primitive integers, depending on the CharSize (u8 or u16).

Source§

type Error = Error

Error type
Source§

fn transfer<'w>( &mut self, words: &'w mut [Word<NineBit>], ) -> Result<&'w [Word<NineBit>], Error>

Sends words to the slave. Returns the words received from the slave
Source§

impl<P, M> Write<<EightBit as CharSize>::Word> for Spi<Config<P, M, EightBit>, Duplex>
where Config<P, M, EightBit>: ValidConfig, P: ValidPads, M: OpMode,

Implement Write for Spi structs with Duplex Capability

The transfer accepts a slice of primitive integers, depending on the CharSize (u8 or u16).

Source§

type Error = Error

Error type
Source§

fn write(&mut self, words: &[Word<EightBit>]) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
Source§

impl<P, M> Write<<EightBit as CharSize>::Word> for Spi<Config<P, M, EightBit>, Tx>
where Config<P, M, EightBit>: ValidConfig, P: ValidPads, M: OpMode,

Implement Write for Spi structs with Tx Capability

The transfer accepts a slice of primitive integers, depending on the CharSize (u8 or u16).

Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

Source§

type Error = Error

Error type
Source§

fn write(&mut self, words: &[Word<EightBit>]) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
Source§

impl<P, M> Write<<NineBit as CharSize>::Word> for Spi<Config<P, M, NineBit>, Duplex>
where Config<P, M, NineBit>: ValidConfig, P: ValidPads, M: OpMode,

Implement Write for Spi structs with Duplex Capability

The transfer accepts a slice of primitive integers, depending on the CharSize (u8 or u16).

Source§

type Error = Error

Error type
Source§

fn write(&mut self, words: &[Word<NineBit>]) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
Source§

impl<P, M> Write<<NineBit as CharSize>::Word> for Spi<Config<P, M, NineBit>, Tx>
where Config<P, M, NineBit>: ValidConfig, P: ValidPads, M: OpMode,

Implement Write for Spi structs with Tx Capability

The transfer accepts a slice of primitive integers, depending on the CharSize (u8 or u16).

Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

Source§

type Error = Error

Error type
Source§

fn write(&mut self, words: &[Word<NineBit>]) -> Result<(), Error>

Sends words to the slave, ignoring all the incoming words
Source§

impl<P, M, C> Read<<C as CharSize>::Word> for Spi<Config<P, M, C>, Rx>

Implement serial::Read for Rx Spi structs in a MasterMode

Read is only implemented for Spi structs with Rx Capability. In a MasterMode, Read has to initiate transactions, so it keeps track of the transaction state. If a transaction is in progress, it will wait on RXC. If not, it will wait on DRE, and then send 0.

Source§

type Error = Error

Read error
Source§

fn read(&mut self) -> Result<C::Word, Error>

Reads a single word from the serial interface
Source§

impl<P, C> Read<<C as CharSize>::Word> for Spi<Config<P, Slave, C>, Rx>

Implement serial::Read for Rx Spi structs in Slave OpMode

serial::Read is only implemented for Spi structs with Rx Capability. In Slave OpMode, Read does not have to initiate transactions, so it does not have to store any internal state. It only has to wait on RXC.

Source§

fn read(&mut self) -> Result<C::Word, Error>

Wait for an RXC flag, then read the word

Source§

type Error = Error

Read error
Source§

impl<P, M, C> Write<<C as CharSize>::Word> for Spi<Config<P, M, C>, Tx>

Implement serial::Write for Tx Spi structs

serial::Write is only implemented for Spi structs with Tx Capability. Because the Capability is Tx, this implementation never reads the DATA register and ignores all buffer overflow errors.

Source§

type Error = Error

Write error
Source§

fn write(&mut self, word: C::Word) -> Result<(), Error>

Writes a single word to the serial interface
Source§

fn flush(&mut self) -> Result<(), Error>

Ensures that none of the previously written words are still buffered
Source§

impl<C> FullDuplex<<C as AnyConfig>::Word> for Spi<C, Duplex>

Implement [spi::FullDuplex] for Spi structs with AtomicSize

spi::FullDuplex is only implemented when the Spi struct has Duplex Capability. The Word size used in the implementation depends on the corresponding CharSize.

Source§

type Error = Error

An enumeration of SPI errors
Source§

fn read(&mut self) -> Result<C::Word, Error>

Reads the word stored in the shift register Read more
Source§

fn send(&mut self, word: C::Word) -> Result<(), Error>

Sends a word to the slave
Source§

impl<C> Default<<C as AnyConfig>::Word> for Spi<C, Tx>
where C: ValidConfig, Spi<C, Tx>: Write<C::Word>,

Auto Trait Implementations§

§

impl<C, A, RxDma, TxDma> Freeze for Spi<C, A, RxDma, TxDma>
where C: Freeze, A: Freeze, RxDma: Freeze, TxDma: Freeze,

§

impl<C, A, RxDma, TxDma> RefUnwindSafe for Spi<C, A, RxDma, TxDma>

§

impl<C, A, RxDma, TxDma> Send for Spi<C, A, RxDma, TxDma>
where C: Send, A: Send, RxDma: Send, TxDma: Send,

§

impl<C, A, RxDma, TxDma> Sync for Spi<C, A, RxDma, TxDma>
where C: Sync, A: Sync, RxDma: Sync, TxDma: Sync,

§

impl<C, A, RxDma, TxDma> Unpin for Spi<C, A, RxDma, TxDma>
where C: Unpin, A: Unpin, RxDma: Unpin, TxDma: Unpin,

§

impl<C, A, RxDma, TxDma> UnwindSafe for Spi<C, A, RxDma, TxDma>
where C: UnwindSafe, A: UnwindSafe, RxDma: UnwindSafe, TxDma: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<S> CheckBufLen for S
where S: AnySpi,

Source§

const LEN: usize = _

👎Deprecated since 0.19.0: spi_future is deprecated and will be removed in a later version of atsamd_hal. Consider using the async APIs available in the spi module as a replacement.
Spi transaction length
Source§

fn len(&self) -> usize

👎Deprecated since 0.19.0: spi_future is deprecated and will be removed in a later version of atsamd_hal. Consider using the async APIs available in the spi module as a replacement.
Return the Spi transaction length Read more
Source§

const STEP: usize = _

👎Deprecated since 0.19.0: spi_future is deprecated and will be removed in a later version of atsamd_hal. Consider using the async APIs available in the spi module as a replacement.
Step size through the SpiFuture buffer Read more
Source§

fn step(&self) -> usize

👎Deprecated since 0.19.0: spi_future is deprecated and will be removed in a later version of atsamd_hal. Consider using the async APIs available in the spi module as a replacement.
Return the step size through the SpiFuture buffer Read more
Source§

fn check_buf_len(&self, buf: &impl AsRef<[u8]>)

👎Deprecated since 0.19.0: spi_future is deprecated and will be removed in a later version of atsamd_hal. Consider using the async APIs available in the spi module as a replacement.
Check that the buffer has a valid length Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Is for T
where T: Sealed + AsRef<T> + AsMut<T>,

Source§

type Type = T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, Word> Write<Word> for S
where S: Default<Word>, Word: Clone,

Source§

type Error = <S as Write<Word>>::Error

The type of error that can occur when writing
Source§

fn bwrite_all( &mut self, buffer: &[Word], ) -> Result<(), <S as Write<Word>>::Error>

Writes a slice, blocking until everything has been written Read more
Source§

fn bflush(&mut self) -> Result<(), <S as Write<Word>>::Error>

Block until the serial interface has sent all buffered words