Fix i2c write read (#146)

* i2c write_read: don't continue with read if write aborted

* i2c write_read: use correct length of read buffer
This commit is contained in:
Jan Niehusmann 2021-10-02 09:43:05 +02:00 committed by GitHub
parent 800f71a1b8
commit ad68c9d696
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -383,9 +383,14 @@ macro_rules! hal {
}
}
if abort {
return Err(Error::Abort(abort_reason));
}
let buffer_len = buffer.len();
for (i, byte) in buffer.iter_mut().enumerate() {
let first = i == 0;
let last = i == bytes.len() - 1;
let last = i == buffer_len - 1;
// wait until there is space in the FIFO to write the next byte
while self.tx_fifo_full() {}