Skip to content

Commit 0a72e01

Browse files
committed
i2c: rename args to write/read.
1 parent 9c9e337 commit 0a72e01

File tree

2 files changed

+24
-34
lines changed

2 files changed

+24
-34
lines changed

embedded-hal-async/src/i2c.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,21 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
111111
}
112112

113113
impl<A: AddressMode, T: I2c<A>> I2c<A> for &mut T {
114-
async fn read(&mut self, address: A, buffer: &mut [u8]) -> Result<(), Self::Error> {
115-
T::read(self, address, buffer).await
114+
async fn read(&mut self, address: A, read: &mut [u8]) -> Result<(), Self::Error> {
115+
T::read(self, address, read).await
116116
}
117117

118-
async fn write(&mut self, address: A, bytes: &[u8]) -> Result<(), Self::Error> {
119-
T::write(self, address, bytes).await
118+
async fn write(&mut self, address: A, write: &[u8]) -> Result<(), Self::Error> {
119+
T::write(self, address, write).await
120120
}
121121

122122
async fn write_read(
123123
&mut self,
124124
address: A,
125-
bytes: &[u8],
126-
buffer: &mut [u8],
125+
write: &[u8],
126+
read: &mut [u8],
127127
) -> Result<(), Self::Error> {
128-
T::write_read(self, address, bytes, buffer).await
128+
T::write_read(self, address, write, read).await
129129
}
130130

131131
async fn transaction(

embedded-hal/src/i2c.rs

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
//! # impl ErrorType for I2c0 { type Error = ErrorKind; }
3030
//! impl I2c<SevenBitAddress> for I2c0
3131
//! {
32-
//! fn read(&mut self, addr: u8, buffer: &mut [u8]) -> Result<(), Self::Error> {
32+
//! fn read(&mut self, addr: u8, read: &mut [u8]) -> Result<(), Self::Error> {
3333
//! // ...
3434
//! # Ok(())
3535
//! }
36-
//! fn write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Self::Error> {
36+
//! fn write(&mut self, addr: u8, write: &[u8]) -> Result<(), Self::Error> {
3737
//! // ...
3838
//! # Ok(())
3939
//! }
40-
//! fn write_read(&mut self, addr: u8, bytes: &[u8], buffer: &mut [u8]) -> Result<(), Self::Error> {
40+
//! fn write_read(&mut self, addr: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> {
4141
//! // ...
4242
//! # Ok(())
4343
//! }
@@ -49,15 +49,15 @@
4949
//!
5050
//! impl I2c<TenBitAddress> for I2c0
5151
//! {
52-
//! fn read(&mut self, addr: u16, buffer: &mut [u8]) -> Result<(), Self::Error> {
52+
//! fn read(&mut self, addr: u16, write: &mut [u8]) -> Result<(), Self::Error> {
5353
//! // ...
5454
//! # Ok(())
5555
//! }
56-
//! fn write(&mut self, addr: u16, bytes: &[u8]) -> Result<(), Self::Error> {
56+
//! fn write(&mut self, addr: u16, read: &[u8]) -> Result<(), Self::Error> {
5757
//! // ...
5858
//! # Ok(())
5959
//! }
60-
//! fn write_read(&mut self, addr: u16, bytes: &[u8], buffer: &mut [u8]) -> Result<(), Self::Error> {
60+
//! fn write_read(&mut self, addr: u16, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> {
6161
//! // ...
6262
//! # Ok(())
6363
//! }
@@ -245,7 +245,7 @@ pub enum Operation<'a> {
245245

246246
/// Blocking I2C
247247
pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
248-
/// Reads enough bytes from slave with `address` to fill `buffer`
248+
/// Reads enough bytes from slave with `address` to fill `read`
249249
///
250250
/// # I2C Events (contract)
251251
///
@@ -263,7 +263,7 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
263263
/// - `MAK` = master acknowledge
264264
/// - `NMAK` = master no acknowledge
265265
/// - `SP` = stop condition
266-
fn read(&mut self, address: A, buffer: &mut [u8]) -> Result<(), Self::Error>;
266+
fn read(&mut self, address: A, read: &mut [u8]) -> Result<(), Self::Error>;
267267

268268
/// Writes bytes to slave with address `address`
269269
///
@@ -281,9 +281,9 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
281281
/// - `SAK` = slave acknowledge
282282
/// - `Bi` = ith byte of data
283283
/// - `SP` = stop condition
284-
fn write(&mut self, address: A, bytes: &[u8]) -> Result<(), Self::Error>;
284+
fn write(&mut self, address: A, write: &[u8]) -> Result<(), Self::Error>;
285285

286-
/// Writes bytes to slave with address `address` and then reads enough bytes to fill `buffer` *in a
286+
/// Writes bytes to slave with address `address` and then reads enough bytes to fill `read` *in a
287287
/// single transaction*
288288
///
289289
/// # I2C Events (contract)
@@ -305,12 +305,7 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
305305
/// - `MAK` = master acknowledge
306306
/// - `NMAK` = master no acknowledge
307307
/// - `SP` = stop condition
308-
fn write_read(
309-
&mut self,
310-
address: A,
311-
bytes: &[u8],
312-
buffer: &mut [u8],
313-
) -> Result<(), Self::Error>;
308+
fn write_read(&mut self, address: A, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error>;
314309

315310
/// Execute the provided operations on the I2C bus.
316311
///
@@ -333,21 +328,16 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
333328
}
334329

335330
impl<A: AddressMode, T: I2c<A>> I2c<A> for &mut T {
336-
fn read(&mut self, address: A, buffer: &mut [u8]) -> Result<(), Self::Error> {
337-
T::read(self, address, buffer)
331+
fn read(&mut self, address: A, read: &mut [u8]) -> Result<(), Self::Error> {
332+
T::read(self, address, read)
338333
}
339334

340-
fn write(&mut self, address: A, bytes: &[u8]) -> Result<(), Self::Error> {
341-
T::write(self, address, bytes)
335+
fn write(&mut self, address: A, write: &[u8]) -> Result<(), Self::Error> {
336+
T::write(self, address, write)
342337
}
343338

344-
fn write_read(
345-
&mut self,
346-
address: A,
347-
bytes: &[u8],
348-
buffer: &mut [u8],
349-
) -> Result<(), Self::Error> {
350-
T::write_read(self, address, bytes, buffer)
339+
fn write_read(&mut self, address: A, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> {
340+
T::write_read(self, address, write, read)
351341
}
352342

353343
fn transaction(

0 commit comments

Comments
 (0)