Skip to content

Commit

Permalink
Wait at end of ehal 0.2 blocking SPI writes
Browse files Browse the repository at this point in the history
  • Loading branch information
ianrrees committed Aug 21, 2024
1 parent b8de816 commit 3d2ba76
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions hal/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased Changes

- Fix blocking behaviour for `embedded-hal` 0.2 SPI writes
- Fix I2C transaction to be as continuous as possible according to `embedded-hal` specification
- Allow configuring USB clock with `GenericClockController` on atsamd11
- fix samd51j not having i2s support
Expand Down
4 changes: 4 additions & 0 deletions hal/src/sercom/spi/impl_ehal_thumbv6m.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ macro_rules! impl_blocking_spi_write {
}
}
}
// Wait until all data is shifted out
while !self.read_flags().contains(Flags::TXC) {}
Ok(())
}
}
Expand Down Expand Up @@ -666,6 +668,8 @@ macro_rules! impl_blocking_spi_write_iter {
}
}
}
// Wait until all data is shifted out
while !self.read_flags().contains(Flags::TXC) {}
Ok(())
}
}
Expand Down
14 changes: 12 additions & 2 deletions hal/src/sercom/spi/impl_ehal_thumbv7em.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@ macro_rules! impl_blocking_spi_write {
}
}
}
// Wait until all data is shifted out
while !self.read_flags().contains(Flags::TXC) {}
Ok(())
}
}
Expand Down Expand Up @@ -632,7 +634,10 @@ where
panic!("Slice length does not equal SPI transfer length");
}
let sercom = unsafe { self.config.as_ref().sercom() };
write_slice(sercom, buf, false)
write_slice(sercom, buf, false)?;
// Wait until all data is shifted out
while !self.read_flags().contains(Flags::TXC) {}
Ok(())
}
}

Expand Down Expand Up @@ -687,7 +692,10 @@ where
panic!("Slice length does not equal SPI transfer length");
}
let sercom = unsafe { self.config.as_ref().sercom() };
write_slice(sercom, buf, false)
write_slice(sercom, buf, false)?;
// Wait until all data is shifted out
while !self.read_flags().contains(Flags::TXC) {}
Ok(())
}
}

Expand Down Expand Up @@ -779,6 +787,8 @@ macro_rules! impl_blocking_spi_write_iter {
}
}
}
// Wait until all data is shifted out
while !self.read_flags().contains(Flags::TXC) {}
Ok(())
}
}
Expand Down

0 comments on commit 3d2ba76

Please sign in to comment.