wasm_embedded_spec/
spi.rs

1//! Platform I2C API abstraction (and wrappers).
2//!
3//! Provides a platform I2C trait with wiggle and c wrappers
4
5
6use super::Error;
7/// SPI context abstraction.
8///
9/// This hides runtime implementation details to simplify implementing I2C contexts.
10/// Hopefully one day generation is improved so we don't _need_ this any more
11pub trait Spi {
12    fn init(
13        &mut self,
14        dev: u32,
15        baud: u32,
16        mosi: i32,
17        miso: i32,
18        sck: i32,
19        cs: i32,
20    ) -> Result<i32, Error>;
21
22    fn deinit(&mut self, handle: i32) -> Result<(), Error>;
23
24    fn read<'a>(&mut self, handle: i32, data: &mut [u8]) -> Result<(), Error>;
25
26    fn write<'a>(&mut self, handle: i32, data: &[u8]) -> Result<(), Error>;
27
28    fn transfer<'a>(&mut self, handle: i32, read: &mut [u8], write: &[u8]) -> Result<(), Error>;
29
30    fn transfer_inplace<'a>(&mut self, handle: i32, data: &mut [u8]) -> Result<(), Error>;
31}