hmc5983/interface/mod.rs
1/*
2Copyright (c) 2020 Todd Stellanova
3LICENSE: BSD3 (see LICENSE file)
4*/
5
6pub mod spi;
7pub use self::spi::SpiInterface;
8
9pub mod i2c;
10pub use self::i2c::I2cInterface;
11
12/// A method of communicating with the device
13pub trait SensorInterface {
14 /// Interface associated error type
15 type InterfaceError;
16
17 /// Read a block from a specific register
18 /// `reg`: The register address to read from
19 /// `recv_buf`: The buffer to receive into
20 fn read_block(
21 &mut self,
22 reg: u8,
23 recv_buf: &mut [u8],
24 ) -> Result<(), Self::InterfaceError>;
25
26 /// Write a value to a register
27 fn write_reg(
28 &mut self,
29 reg: u8,
30 val: u8,
31 ) -> Result<(), Self::InterfaceError>;
32}