Struct atsamd_hal::sercom::spi_future::SpiFuture
source · [−]pub struct SpiFuture<S, B, SS = NoneT, W = fn()>where
S: CheckBufLen,
B: AsRef<[u8]> + AsMut<[u8]> + 'static,
SS: ControlSS,
W: FnOnce() + 'static,{ /* private fields */ }
Expand description
A Future
-like interface for SPI transactions
See the module-level documentation for more details.
Implementations
sourceimpl<S, B, W> SpiFuture<S, B, NoneT, W>where
S: CheckBufLen,
B: AsRef<[u8]> + AsMut<[u8]> + 'static,
W: FnOnce() + 'static,
impl<S, B, W> SpiFuture<S, B, NoneT, W>where
S: CheckBufLen,
B: AsRef<[u8]> + AsMut<[u8]> + 'static,
W: FnOnce() + 'static,
sourceimpl<S, B, SS> SpiFuture<S, B, SS>where
S: CheckBufLen,
B: AsRef<[u8]> + AsMut<[u8]> + 'static,
SS: ControlSS,
impl<S, B, SS> SpiFuture<S, B, SS>where
S: CheckBufLen,
B: AsRef<[u8]> + AsMut<[u8]> + 'static,
SS: ControlSS,
sourcepub fn with_waker<W>(self, waker: W) -> SpiFuture<S, B, SS, W>where
W: FnOnce() + 'static,
pub fn with_waker<W>(self, waker: W) -> SpiFuture<S, B, SS, W>where
W: FnOnce() + 'static,
Add a waker to the SpiFuture
This function changes the waker type, so it must take an owned self
.
sourceimpl<S, B, SS, W> SpiFuture<S, B, SS, W>where
S: CheckBufLen,
B: AsRef<[u8]> + AsMut<[u8]> + 'static,
SS: ControlSS,
W: FnOnce() + 'static,
impl<S, B, SS, W> SpiFuture<S, B, SS, W>where
S: CheckBufLen,
B: AsRef<[u8]> + AsMut<[u8]> + 'static,
SS: ControlSS,
W: FnOnce() + 'static,
sourcepub fn start(&mut self)
pub fn start(&mut self)
Start the SpiFuture
transaction
This will assert the SS pin, if present, and enable the DRE
and RXC
interrupts.
sourcepub fn send(&mut self) -> Result<(), Error>
pub fn send(&mut self) -> Result<(), Error>
Send the next set of bytes from the buffer
This method should be called from the DRE
interrupt handler. Once all
bytes of the transaction have been sent, this function will
automatically disable the DRE
interrupt.
sourcepub fn recv(&mut self) -> Result<(), Error>
pub fn recv(&mut self) -> Result<(), Error>
Received the next set of bytes and write them to the buffer
This method should be called from the RXC
interrupt handler. Once all
bytes of the transaction have been received, this function will
automatically disable the RXC
interrupt, deassert the SS pin (if
present), and call the waker (if present).
sourcepub fn poll(&self) -> Poll<&[u8]>
pub fn poll(&self) -> Poll<&[u8]>
Poll the SpiFuture
This function will return Poll::Pending
until all bytes have been
received. When the transaction is complete, it will return
Poll::Ready
with a reference to the completed buffer.