stm32f1xx_hal/i2c/
hal_02.rs1use super::{BlockingI2c, Error, I2c, Instance};
2use embedded_hal_02::blocking::i2c::{Operation, Read, Transactional, Write, WriteRead};
3
4impl<I2C: Instance> Write for BlockingI2c<I2C> {
5 type Error = Error;
6
7 fn write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Self::Error> {
8 self.write(addr, bytes)
9 }
10}
11
12impl<I2C: Instance> Read for BlockingI2c<I2C> {
13 type Error = Error;
14
15 fn read(&mut self, addr: u8, buffer: &mut [u8]) -> Result<(), Self::Error> {
16 self.read(addr, buffer)
17 }
18}
19
20impl<I2C: Instance> WriteRead for BlockingI2c<I2C> {
21 type Error = Error;
22
23 fn write_read(&mut self, addr: u8, bytes: &[u8], buffer: &mut [u8]) -> Result<(), Self::Error> {
24 self.write_read(addr, bytes, buffer)
25 }
26}
27
28impl<I2C: Instance> Transactional for BlockingI2c<I2C> {
29 type Error = Error;
30
31 fn exec(&mut self, address: u8, operations: &mut [Operation<'_>]) -> Result<(), Self::Error> {
32 self.transaction_slice_hal_02(address, operations)
33 }
34}
35
36impl<I2C: Instance> WriteRead for I2c<I2C> {
37 type Error = Error;
38
39 fn write_read(&mut self, addr: u8, bytes: &[u8], buffer: &mut [u8]) -> Result<(), Self::Error> {
40 self.write_read(addr, bytes, buffer)
41 }
42}
43
44impl<I2C: Instance> Write for I2c<I2C> {
45 type Error = Error;
46
47 fn write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Self::Error> {
48 self.write(addr, bytes)
49 }
50}
51
52impl<I2C: Instance> Read for I2c<I2C> {
53 type Error = Error;
54
55 fn read(&mut self, addr: u8, buffer: &mut [u8]) -> Result<(), Self::Error> {
56 self.read(addr, buffer)
57 }
58}
59
60impl<I2C: Instance> Transactional for I2c<I2C> {
61 type Error = Error;
62
63 fn exec(&mut self, address: u8, operations: &mut [Operation<'_>]) -> Result<(), Self::Error> {
64 self.transaction_slice_hal_02(address, operations)
65 }
66}