Merge pull request #1666 from alexferro/possible-1664-fix

Embassy-rp I2C: Fix 1664 (async transaction failure)
This commit is contained in:
Dario Nieuwenhuis 2023-07-18 11:24:52 +00:00 committed by GitHub
commit a1cc3f2c60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -716,6 +716,9 @@ mod nightly {
async fn transaction(&mut self, address: A, operations: &mut [Operation<'_>]) -> Result<(), Self::Error> { async fn transaction(&mut self, address: A, operations: &mut [Operation<'_>]) -> Result<(), Self::Error> {
let addr: u16 = address.into(); let addr: u16 = address.into();
if operations.len() > 0 {
Self::setup(addr)?;
}
let mut iterator = operations.iter_mut(); let mut iterator = operations.iter_mut();
while let Some(op) = iterator.next() { while let Some(op) = iterator.next() {
@ -723,11 +726,9 @@ mod nightly {
match op { match op {
Operation::Read(buffer) => { Operation::Read(buffer) => {
Self::setup(addr)?;
self.read_async_internal(buffer, false, last).await?; self.read_async_internal(buffer, false, last).await?;
} }
Operation::Write(buffer) => { Operation::Write(buffer) => {
Self::setup(addr)?;
self.write_async_internal(buffer.into_iter().cloned(), last).await?; self.write_async_internal(buffer.into_iter().cloned(), last).await?;
} }
} }