Skip to content

Commit

Permalink
Also apply changes to rp235x-hal
Browse files Browse the repository at this point in the history
  • Loading branch information
jannic committed Aug 25, 2024
1 parent 5046f14 commit e7c6d14
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
15 changes: 0 additions & 15 deletions rp235x-hal/src/i2c/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,13 @@ impl<T: Deref<Target = Block>, PINS> I2C<T, PINS, Controller> {
)?;

let lastindex = buffer.len() - 1;
let mut first_byte = true;
for (i, byte) in buffer.iter_mut().enumerate() {
let last_byte = i == lastindex;

// wait until there is space in the FIFO to write the next byte
while self.i2c.ic_status().read().tfnf().bit_is_clear() {}

self.i2c.ic_data_cmd().write(|w| {
if first_byte {
if !first_transaction {
w.restart().enable();
}
first_byte = false;
}

w.stop().bit(do_stop && last_byte);
w.cmd().read()
});
Expand Down Expand Up @@ -270,7 +262,6 @@ impl<T: Deref<Target = Block>, PINS> I2C<T, PINS, Controller> {
)?;

let mut abort_reason = Ok(());
let mut first_byte = true;
'outer: while let Some(byte) = peekable.next() {
if self.tx_fifo_full() {
// wait for more room in the fifo
Expand All @@ -289,12 +280,6 @@ impl<T: Deref<Target = Block>, PINS> I2C<T, PINS, Controller> {
// else enqueue
let last = peekable.peek().is_none();
self.i2c.ic_data_cmd().write(|w| {
if first_byte {
if !first_transaction {
w.restart().enable();
}
first_byte = false;
}
w.stop().bit(do_stop && last);
unsafe { w.dat().bits(byte) }
});
Expand Down
15 changes: 0 additions & 15 deletions rp235x-hal/src/i2c/controller/non_blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ where
)?;

let lastindex = buffer.len() - 1;
let mut first_byte = true;
for (i, byte) in buffer.iter_mut().enumerate() {
let last_byte = i == lastindex;

Expand All @@ -135,13 +134,6 @@ where
.await;

self.i2c.ic_data_cmd().write(|w| {
if first_byte {
if !first_transaction {
w.restart().enable();
}
first_byte = false;
}

w.stop().bit(do_stop && last_byte);
w.cmd().read()
});
Expand Down Expand Up @@ -174,7 +166,6 @@ where
)?;

let mut abort_reason = Ok(());
let mut first_byte = true;
while let Some(byte) = peekable.next() {
if self.tx_fifo_full() {
// wait for more room in the fifo
Expand All @@ -193,12 +184,6 @@ where
// else enqueue
let last = peekable.peek().is_none();
self.i2c.ic_data_cmd().write(|w| {
if first_byte {
if !first_transaction {
w.restart().enable();
}
first_byte = false;
}
w.stop().bit(do_stop && last);
unsafe { w.dat().bits(byte) }
});
Expand Down

0 comments on commit e7c6d14

Please sign in to comment.