Skip to content

Commit

Permalink
small cleanup and add a few internal docs
Browse files Browse the repository at this point in the history
  • Loading branch information
liebman committed Aug 30, 2024
1 parent 864c12a commit dd1b2be
Showing 1 changed file with 50 additions and 10 deletions.
60 changes: 50 additions & 10 deletions esp-hal/src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ where
address,
bytes,
last_op != Op::Write,
op_iter.peek().is_none(),
next_op == Op::None,
cmd_iterator,
)?;
last_op = Op::Write;
Expand All @@ -318,7 +318,7 @@ where
address,
buffer,
last_op != Op::Read,
op_iter.peek().is_none(),
next_op == Op::None,
next_op == Op::Read,
cmd_iterator,
)?;
Expand Down Expand Up @@ -770,6 +770,14 @@ mod asynch {
Ok(())
}

/// Executes an async I2C write operation.
/// - `addr` is the address of the slave device.
/// - `bytes` is the data two be sent.
/// - `start` indicates whether the operation should start by a START
/// condition and sending the address.
/// - `stop` indicates whether the operation should end with a STOP
/// condition.
/// - `cmd_iterator` is an iterator over the command registers.
async fn write_operation<'a, I>(
&self,
address: u8,
Expand Down Expand Up @@ -802,6 +810,16 @@ mod asynch {
Ok(())
}

/// Executes an async I2C read operation.
/// - `addr` is the address of the slave device.
/// - `buffer` is the buffer to store the read data.
/// - `start` indicates whether the operation should start by a START
/// condition and sending the address.
/// - `stop` indicates whether the operation should end with a STOP
/// condition.
/// - `will_continue` indicates whether there is another read operation
/// following this one and we should not nack the last byte.
/// - `cmd_iterator` is an iterator over the command registers.
async fn read_operation<'a, I>(
&self,
address: u8,
Expand Down Expand Up @@ -960,7 +978,7 @@ mod asynch {
address,
bytes,
last_op != Op::Write,
op_iter.peek().is_none(),
next_op == Op::None,
cmd_iterator,
)
.await?;
Expand All @@ -974,7 +992,7 @@ mod asynch {
address,
buffer,
last_op != Op::Read,
op_iter.peek().is_none(),
next_op == Op::None,
next_op == Op::Read,
cmd_iterator,
)
Expand Down Expand Up @@ -1493,6 +1511,11 @@ pub trait Instance: crate::private::Sealed {
}

/// Configures the I2C peripheral for a write operation.
/// - `addr` is the address of the slave device.
/// - `bytes` is the data two be sent.
/// - `start` indicates whether the operation should start by a START
/// condition and sending the address.
/// - `cmd_iterator` is an iterator over the command registers.
fn setup_write<'a, I>(
&self,
addr: u8,
Expand Down Expand Up @@ -1533,12 +1556,13 @@ pub trait Instance: crate::private::Sealed {
}

/// Configures the I2C peripheral for a read operation.
/// `addr` is the address of the slave device.
/// `buffer` is the buffer to store the read data.
/// `start` indicates whether the operation should start by writing the
/// address `will_continue` indicates whether there is another read
/// operation following this one and we should not nack the last byte.
/// The `cmd_iterator` parameter is an iterator over the command registers.
/// - `addr` is the address of the slave device.
/// - `buffer` is the buffer to store the read data.
/// - `start` indicates whether the operation should start by a START
/// condition and sending the address.
/// - `will_continue` indicates whether there is another read operation
/// following this one and we should not nack the last byte.
/// - `cmd_iterator` is an iterator over the command registers.
fn setup_read<'a, I>(
&self,
addr: u8,
Expand Down Expand Up @@ -1945,6 +1969,13 @@ pub trait Instance: crate::private::Sealed {
}

/// Executes an I2C write operation.
/// - `addr` is the address of the slave device.
/// - `bytes` is the data two be sent.
/// - `start` indicates whether the operation should start by a START
/// condition and sending the address.
/// - `stop` indicates whether the operation should end with a STOP
/// condition.
/// - `cmd_iterator` is an iterator over the command registers.
fn write_operation<'a, I>(
&self,
address: u8,
Expand Down Expand Up @@ -1978,6 +2009,15 @@ pub trait Instance: crate::private::Sealed {
}

/// Executes an I2C read operation.
/// - `addr` is the address of the slave device.
/// - `buffer` is the buffer to store the read data.
/// - `start` indicates whether the operation should start by a START
/// condition and sending the address.
/// - `stop` indicates whether the operation should end with a STOP
/// condition.
/// - `will_continue` indicates whether there is another read operation
/// following this one and we should not nack the last byte.
/// - `cmd_iterator` is an iterator over the command registers.
fn read_operation<'a, I>(
&self,
address: u8,
Expand Down

0 comments on commit dd1b2be

Please sign in to comment.