embedded_interfaces/
i2c.rs1#[maybe_async_cfg::maybe(
2 idents(hal(sync = "embedded_hal", async = "embedded_hal_async")),
3 sync(feature = "sync"),
4 async(feature = "async")
5)]
6pub struct I2cBoundBus<I, A>
8where
9 I: hal::i2c::I2c<A> + hal::i2c::ErrorType,
10 A: hal::i2c::AddressMode + Copy,
11{
12 pub interface: I,
14 pub address: A,
16}
17
18#[maybe_async_cfg::maybe(
19 idents(hal(sync = "embedded_hal", async = "embedded_hal_async"), Codec, I2cBoundBus),
20 sync(feature = "sync"),
21 async(feature = "async")
22)]
23pub struct I2cDevice<I, A>
25where
26 I: hal::i2c::I2c<A> + hal::i2c::ErrorType,
27 A: hal::i2c::AddressMode + Copy,
28{
29 pub bound_bus: I2cBoundBus<I, A>,
31}
32
33#[maybe_async_cfg::maybe(
34 idents(hal(sync = "embedded_hal", async = "embedded_hal_async"), Codec, I2cBoundBus),
35 sync(feature = "sync"),
36 async(feature = "async")
37)]
38impl<I, A> I2cDevice<I, A>
39where
40 I: hal::i2c::I2c<A> + hal::i2c::ErrorType,
41 A: hal::i2c::AddressMode + Copy,
42{
43 pub fn new(interface: I, address: A) -> Self {
45 Self {
46 bound_bus: I2cBoundBus { interface, address },
47 }
48 }
49}