wasm_embedded_spec/
i2c.rs

1//! Platform I2C API abstraction (and wrappers).
2//!
3//! Provides a platform I2C trait with wiggle and c wrappers
4
5use super::Error;
6
7/// I2C 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 I2c {
12    fn init(&mut self, dev: u32, _baud: u32, sda: i32, sck: i32) -> Result<i32, Error>;
13
14    fn deinit(&mut self, handle: i32) -> Result<(), Error>;
15
16    fn write(&mut self, handle: i32, addr: u16, data: &[u8]) -> Result<(), Error>;
17
18    fn read(&mut self, handle: i32, addr: u16, buff: &mut [u8]) -> Result<(), Error>;
19
20    fn write_read(
21        &mut self,
22        handle: i32,
23        addr: u16,
24        data: &[u8],
25        buff: &mut [u8],
26    ) -> Result<(), Error>;
27}