aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/i2c/timeout.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-04-06 22:25:24 +0200
committerDario Nieuwenhuis <[email protected]>2023-04-06 22:41:50 +0200
commitbe37eee13dbd7833e0d74ea57d31d3e5c58cd47f (patch)
tree3e1d5a59409ea06fe34d97fdaf45642683332638 /embassy-stm32/src/i2c/timeout.rs
parentf3ec6080bf9a39d9819195861e7b41e8a2081600 (diff)
Update embedded-hal crates.
Diffstat (limited to 'embassy-stm32/src/i2c/timeout.rs')
-rw-r--r--embassy-stm32/src/i2c/timeout.rs75
1 files changed, 27 insertions, 48 deletions
diff --git a/embassy-stm32/src/i2c/timeout.rs b/embassy-stm32/src/i2c/timeout.rs
index 4fca1ca2b..939e2750e 100644
--- a/embassy-stm32/src/i2c/timeout.rs
+++ b/embassy-stm32/src/i2c/timeout.rs
@@ -28,64 +28,64 @@ impl<'d, T: Instance, TXDMA, RXDMA> TimeoutI2c<'d, T, TXDMA, RXDMA> {
28 } 28 }
29 29
30 /// Blocking read with a custom timeout 30 /// Blocking read with a custom timeout
31 pub fn blocking_read_timeout(&mut self, addr: u8, buffer: &mut [u8], timeout: Duration) -> Result<(), Error> { 31 pub fn blocking_read_timeout(&mut self, addr: u8, read: &mut [u8], timeout: Duration) -> Result<(), Error> {
32 self.i2c.blocking_read_timeout(addr, buffer, timeout_fn(timeout)) 32 self.i2c.blocking_read_timeout(addr, read, timeout_fn(timeout))
33 } 33 }
34 34
35 /// Blocking read with default timeout, provided in [`TimeoutI2c::new()`] 35 /// Blocking read with default timeout, provided in [`TimeoutI2c::new()`]
36 pub fn blocking_read(&mut self, addr: u8, buffer: &mut [u8]) -> Result<(), Error> { 36 pub fn blocking_read(&mut self, addr: u8, read: &mut [u8]) -> Result<(), Error> {
37 self.blocking_read_timeout(addr, buffer, self.timeout) 37 self.blocking_read_timeout(addr, read, self.timeout)
38 } 38 }
39 39
40 /// Blocking write with a custom timeout 40 /// Blocking write with a custom timeout
41 pub fn blocking_write_timeout(&mut self, addr: u8, bytes: &[u8], timeout: Duration) -> Result<(), Error> { 41 pub fn blocking_write_timeout(&mut self, addr: u8, write: &[u8], timeout: Duration) -> Result<(), Error> {
42 self.i2c.blocking_write_timeout(addr, bytes, timeout_fn(timeout)) 42 self.i2c.blocking_write_timeout(addr, write, timeout_fn(timeout))
43 } 43 }
44 44
45 /// Blocking write with default timeout, provided in [`TimeoutI2c::new()`] 45 /// Blocking write with default timeout, provided in [`TimeoutI2c::new()`]
46 pub fn blocking_write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Error> { 46 pub fn blocking_write(&mut self, addr: u8, write: &[u8]) -> Result<(), Error> {
47 self.blocking_write_timeout(addr, bytes, self.timeout) 47 self.blocking_write_timeout(addr, write, self.timeout)
48 } 48 }
49 49
50 /// Blocking write-read with a custom timeout 50 /// Blocking write-read with a custom timeout
51 pub fn blocking_write_read_timeout( 51 pub fn blocking_write_read_timeout(
52 &mut self, 52 &mut self,
53 addr: u8, 53 addr: u8,
54 bytes: &[u8], 54 write: &[u8],
55 buffer: &mut [u8], 55 read: &mut [u8],
56 timeout: Duration, 56 timeout: Duration,
57 ) -> Result<(), Error> { 57 ) -> Result<(), Error> {
58 self.i2c 58 self.i2c
59 .blocking_write_read_timeout(addr, bytes, buffer, timeout_fn(timeout)) 59 .blocking_write_read_timeout(addr, write, read, timeout_fn(timeout))
60 } 60 }
61 61
62 /// Blocking write-read with default timeout, provided in [`TimeoutI2c::new()`] 62 /// Blocking write-read with default timeout, provided in [`TimeoutI2c::new()`]
63 pub fn blocking_write_read(&mut self, addr: u8, bytes: &[u8], buffer: &mut [u8]) -> Result<(), Error> { 63 pub fn blocking_write_read(&mut self, addr: u8, write: &[u8], read: &mut [u8]) -> Result<(), Error> {
64 self.blocking_write_read_timeout(addr, bytes, buffer, self.timeout) 64 self.blocking_write_read_timeout(addr, write, read, self.timeout)
65 } 65 }
66} 66}
67 67
68impl<'d, T: Instance, TXDMA, RXDMA> embedded_hal_02::blocking::i2c::Read for TimeoutI2c<'d, T, TXDMA, RXDMA> { 68impl<'d, T: Instance, TXDMA, RXDMA> embedded_hal_02::blocking::i2c::Read for TimeoutI2c<'d, T, TXDMA, RXDMA> {
69 type Error = Error; 69 type Error = Error;
70 70
71 fn read(&mut self, addr: u8, buffer: &mut [u8]) -> Result<(), Self::Error> { 71 fn read(&mut self, addr: u8, read: &mut [u8]) -> Result<(), Self::Error> {
72 self.blocking_read(addr, buffer) 72 self.blocking_read(addr, read)
73 } 73 }
74} 74}
75 75
76impl<'d, T: Instance, TXDMA, RXDMA> embedded_hal_02::blocking::i2c::Write for TimeoutI2c<'d, T, TXDMA, RXDMA> { 76impl<'d, T: Instance, TXDMA, RXDMA> embedded_hal_02::blocking::i2c::Write for TimeoutI2c<'d, T, TXDMA, RXDMA> {
77 type Error = Error; 77 type Error = Error;
78 78
79 fn write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Self::Error> { 79 fn write(&mut self, addr: u8, write: &[u8]) -> Result<(), Self::Error> {
80 self.blocking_write(addr, bytes) 80 self.blocking_write(addr, write)
81 } 81 }
82} 82}
83 83
84impl<'d, T: Instance, TXDMA, RXDMA> embedded_hal_02::blocking::i2c::WriteRead for TimeoutI2c<'d, T, TXDMA, RXDMA> { 84impl<'d, T: Instance, TXDMA, RXDMA> embedded_hal_02::blocking::i2c::WriteRead for TimeoutI2c<'d, T, TXDMA, RXDMA> {
85 type Error = Error; 85 type Error = Error;
86 86
87 fn write_read(&mut self, addr: u8, bytes: &[u8], buffer: &mut [u8]) -> Result<(), Self::Error> { 87 fn write_read(&mut self, addr: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> {
88 self.blocking_write_read(addr, bytes, buffer) 88 self.blocking_write_read(addr, write, read)
89 } 89 }
90} 90}
91 91
@@ -98,45 +98,24 @@ mod eh1 {
98 } 98 }
99 99
100 impl<'d, T: Instance, TXDMA, RXDMA> embedded_hal_1::i2c::I2c for TimeoutI2c<'d, T, TXDMA, RXDMA> { 100 impl<'d, T: Instance, TXDMA, RXDMA> embedded_hal_1::i2c::I2c for TimeoutI2c<'d, T, TXDMA, RXDMA> {
101 fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> { 101 fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> {
102 self.blocking_read(address, buffer) 102 self.blocking_read(address, read)
103 } 103 }
104 104
105 fn write(&mut self, address: u8, buffer: &[u8]) -> Result<(), Self::Error> { 105 fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> {
106 self.blocking_write(address, buffer) 106 self.blocking_write(address, write)
107 } 107 }
108 108
109 fn write_iter<B>(&mut self, _address: u8, _bytes: B) -> Result<(), Self::Error> 109 fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> {
110 where 110 self.blocking_write_read(address, write, read)
111 B: IntoIterator<Item = u8>,
112 {
113 todo!();
114 } 111 }
115 112
116 fn write_iter_read<B>(&mut self, _address: u8, _bytes: B, _buffer: &mut [u8]) -> Result<(), Self::Error> 113 fn transaction(
117 where
118 B: IntoIterator<Item = u8>,
119 {
120 todo!();
121 }
122
123 fn write_read(&mut self, address: u8, wr_buffer: &[u8], rd_buffer: &mut [u8]) -> Result<(), Self::Error> {
124 self.blocking_write_read(address, wr_buffer, rd_buffer)
125 }
126
127 fn transaction<'a>(
128 &mut self, 114 &mut self,
129 _address: u8, 115 _address: u8,
130 _operations: &mut [embedded_hal_1::i2c::Operation<'a>], 116 _operations: &mut [embedded_hal_1::i2c::Operation<'_>],
131 ) -> Result<(), Self::Error> { 117 ) -> Result<(), Self::Error> {
132 todo!(); 118 todo!();
133 } 119 }
134
135 fn transaction_iter<'a, O>(&mut self, _address: u8, _operations: O) -> Result<(), Self::Error>
136 where
137 O: IntoIterator<Item = embedded_hal_1::i2c::Operation<'a>>,
138 {
139 todo!();
140 }
141 } 120 }
142} 121}