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
3 changed files
with
21 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//! Blocking API | ||
|
||
pub mod spi; |
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,16 @@ | ||
//! Blocking SPI API | ||
|
||
use Spi; | ||
|
||
/// Transfers bytes to the slave, returns the bytes received from the slave | ||
pub fn transfer<'a, S>(spi: &mut S, bytes: &'a mut [u8]) -> Result<&'a [u8], S::Error> | ||
where | ||
S: Spi<u8>, | ||
{ | ||
for byte in bytes.iter_mut() { | ||
block!(spi.send(*byte))?; | ||
*byte = block!(spi.read())?; | ||
} | ||
|
||
Ok(bytes) | ||
} |
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