-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
174 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
//! Asynchronous W5500 traits. | ||
use super::Sn; | ||
|
||
/// Asynchronous buffer IO extension. | ||
/// | ||
/// This extends [`crate::Registers`]. | ||
/// | ||
/// This only implements async buffer IO functions because async functions often | ||
/// do not make sense for short SPI transactions where the cycles to perform a | ||
/// context switch is greater than the number of cycles to wait for a short SPI | ||
/// transaction to complete. | ||
/// That being said, other asynchronous methods will be added if there is demand. | ||
pub trait Registers: crate::Registers { | ||
/// Future for asynchronous buffer read operations. | ||
type ReadFuture<'a>: core::future::Future<Output = Result<(), Self::Error>> + 'a | ||
where | ||
Self: 'a, | ||
Self::Error: 'a; | ||
|
||
/// Future for asynchronous buffer write operations. | ||
type WriteFuture<'a>: core::future::Future<Output = Result<(), Self::Error>> + 'a | ||
where | ||
Self: 'a, | ||
Self::Error: 'a; | ||
|
||
/// Read from the W5500 asynchronously. | ||
/// | ||
/// See [`crate::Registers::read`] for details. | ||
fn aio_read<'a>(&'a mut self, addr: u16, block: u8, data: &'a mut [u8]) | ||
-> Self::ReadFuture<'a>; | ||
|
||
/// Write to the W5500 asynchronously. | ||
/// | ||
/// See [`crate::Registers::write`] for details. | ||
fn aio_write<'a>(&'a mut self, addr: u16, block: u8, data: &'a [u8]) -> Self::WriteFuture<'a>; | ||
|
||
/// Write to the socket TX buffer asynchronously. | ||
/// | ||
/// See [`crate::Registers::set_sn_tx_buf`] for details. | ||
fn aio_set_sn_tx_buf<'a>( | ||
&'a mut self, | ||
sn: Sn, | ||
ptr: u16, | ||
buf: &'a [u8], | ||
) -> Self::WriteFuture<'a> { | ||
self.aio_write(ptr, sn.tx_block(), buf) | ||
} | ||
|
||
/// Read from the socket TX buffer asynchronously. | ||
/// | ||
/// See [`crate::Registers::sn_tx_buf`] for details. | ||
fn aio_sn_tx_buf<'a>( | ||
&'a mut self, | ||
sn: Sn, | ||
ptr: u16, | ||
buf: &'a mut [u8], | ||
) -> Self::ReadFuture<'a> { | ||
self.aio_read(ptr, sn.tx_block(), buf) | ||
} | ||
|
||
/// Read from the socket RX buffer asynchronously. | ||
/// | ||
/// See [`crate::Registers::sn_rx_buf`] for details. | ||
fn aio_sn_rx_buf<'a>( | ||
&'a mut self, | ||
sn: Sn, | ||
ptr: u16, | ||
buf: &'a mut [u8], | ||
) -> Self::ReadFuture<'a> { | ||
self.aio_read(ptr, sn.rx_block(), buf) | ||
} | ||
|
||
/// Write the socket RX buffer asynchronously. | ||
/// | ||
/// See [`crate::Registers::set_sn_rx_buf`] for details. | ||
fn aio_set_sn_rx_buf<'a>( | ||
&'a mut self, | ||
sn: Sn, | ||
ptr: u16, | ||
buf: &'a [u8], | ||
) -> Self::WriteFuture<'a> { | ||
self.aio_write(ptr, sn.rx_block(), buf) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters