-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
2d4a56a
commit 0db24f5
Showing
2 changed files
with
23 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 |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
|
||
pub mod gpio; | ||
pub mod i2c; | ||
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,22 @@ | ||
/// SPI errors that can occur | ||
/// From: https://docs.embassy.dev/embassy-stm32/git/stm32f103c8/spi/enum.Error.html | ||
pub enum SpiError { | ||
Framing, | ||
Crc, | ||
ModeFault, | ||
Overrun, | ||
} | ||
|
||
/// A word is either u8 or u16 | ||
pub enum WordSize { | ||
U8(u8), | ||
U16(u16), | ||
} | ||
|
||
/// SPI trait used to abstract SPI and allow for mocking | ||
pub trait HypedSpi { | ||
/// Read data into `words` from the SPI sensor | ||
fn read(&mut self, words: &mut [WordSize]) -> Result<(), SpiError>; | ||
/// Write data from `words` to the SPI sensor | ||
fn write(&mut self, words: &[WordSize]) -> Result<(), SpiError>; | ||
} |