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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
mod blocking {
use super::super::{Error, I2c, Instance};
use embedded_hal::blocking::i2c::{Read, Write, WriteIter, WriteIterRead, WriteRead};
impl<I2C, PINS> WriteRead for I2c<I2C, PINS>
where
I2C: Instance,
{
type Error = Error;
fn write_read(
&mut self,
addr: u8,
bytes: &[u8],
buffer: &mut [u8],
) -> Result<(), Self::Error> {
self.write_read(addr, bytes, buffer)
}
}
impl<I2C, PINS> WriteIterRead for I2c<I2C, PINS>
where
I2C: Instance,
{
type Error = Error;
fn write_iter_read<B>(
&mut self,
addr: u8,
bytes: B,
buffer: &mut [u8],
) -> Result<(), Self::Error>
where
B: IntoIterator<Item = u8>,
{
self.write_iter_read(addr, bytes, buffer)
}
}
impl<I2C, PINS> Write for I2c<I2C, PINS>
where
I2C: Instance,
{
type Error = Error;
fn write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Self::Error> {
self.write(addr, bytes)
}
}
impl<I2C, PINS> WriteIter for I2c<I2C, PINS>
where
I2C: Instance,
{
type Error = Error;
fn write<B>(&mut self, addr: u8, bytes: B) -> Result<(), Self::Error>
where
B: IntoIterator<Item = u8>,
{
self.write_iter(addr, bytes)
}
}
impl<I2C, PINS> Read for I2c<I2C, PINS>
where
I2C: Instance,
{
type Error = Error;
fn read(&mut self, addr: u8, buffer: &mut [u8]) -> Result<(), Self::Error> {
self.read(addr, buffer)
}
}
}