1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use embedded_hal as hal;

use super::SensorInterface;
use crate::Error;

pub struct I2cInterface<I2C> {
    /// i2c port
    _i2c_port: I2C,
    /// address for i2c communications
    _address: u8,
}

impl<I2C, CommE> I2cInterface<I2C>
where
    I2C: hal::blocking::i2c::Read<Error = CommE>
        + hal::blocking::i2c::Write<Error = CommE>
        + hal::blocking::i2c::WriteRead<Error = CommE>,
{
    pub fn new(i2c: I2C, address: u8) -> Self {
        Self {
            _i2c_port: i2c,
            _address: address,
        }
    }
}

impl<I2C, CommE> SensorInterface for I2cInterface<I2C>
where
    I2C: hal::blocking::i2c::Read<Error = CommE>
        + hal::blocking::i2c::Write<Error = CommE>
        + hal::blocking::i2c::WriteRead<Error = CommE>,
{
    type InterfaceError = Error<CommE, ()>;

    fn register_read(&mut self, _reg: u8) -> Result<u8, Self::InterfaceError> {
        unimplemented!()
    }

    fn register_write(&mut self, _reg: u8, _val: u8) -> Result<(), Self::InterfaceError> {
        unimplemented!()
    }

    fn read_vec3_i16(&mut self, _reg: u8) -> Result<[i16; 3], Self::InterfaceError> {
        unimplemented!()
    }
}