29
29
//! # impl ErrorType for I2c0 { type Error = ErrorKind; }
30
30
//! impl I2c<SevenBitAddress> for I2c0
31
31
//! {
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> {
33
33
//! // ...
34
34
//! # Ok(())
35
35
//! }
36
- //! fn write(&mut self, addr: u8, bytes : &[u8]) -> Result<(), Self::Error> {
36
+ //! fn write(&mut self, addr: u8, write : &[u8]) -> Result<(), Self::Error> {
37
37
//! // ...
38
38
//! # Ok(())
39
39
//! }
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> {
41
41
//! // ...
42
42
//! # Ok(())
43
43
//! }
49
49
//!
50
50
//! impl I2c<TenBitAddress> for I2c0
51
51
//! {
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> {
53
53
//! // ...
54
54
//! # Ok(())
55
55
//! }
56
- //! fn write(&mut self, addr: u16, bytes : &[u8]) -> Result<(), Self::Error> {
56
+ //! fn write(&mut self, addr: u16, read : &[u8]) -> Result<(), Self::Error> {
57
57
//! // ...
58
58
//! # Ok(())
59
59
//! }
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> {
61
61
//! // ...
62
62
//! # Ok(())
63
63
//! }
@@ -245,7 +245,7 @@ pub enum Operation<'a> {
245
245
246
246
/// Blocking I2C
247
247
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 `
249
249
///
250
250
/// # I2C Events (contract)
251
251
///
@@ -263,7 +263,7 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
263
263
/// - `MAK` = master acknowledge
264
264
/// - `NMAK` = master no acknowledge
265
265
/// - `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 > ;
267
267
268
268
/// Writes bytes to slave with address `address`
269
269
///
@@ -281,9 +281,9 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
281
281
/// - `SAK` = slave acknowledge
282
282
/// - `Bi` = ith byte of data
283
283
/// - `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 > ;
285
285
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
287
287
/// single transaction*
288
288
///
289
289
/// # I2C Events (contract)
@@ -305,12 +305,7 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
305
305
/// - `MAK` = master acknowledge
306
306
/// - `NMAK` = master no acknowledge
307
307
/// - `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 > ;
314
309
315
310
/// Execute the provided operations on the I2C bus.
316
311
///
@@ -333,21 +328,16 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
333
328
}
334
329
335
330
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 )
338
333
}
339
334
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 )
342
337
}
343
338
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)
351
341
}
352
342
353
343
fn transaction (
0 commit comments