embassy-traits: Fix unexpected restart on repeated read.

This commit is contained in:
Wilfried Chauveau 2022-01-11 12:40:57 +00:00 committed by 9names
parent ce7c9f4be3
commit 7840d0f833

View file

@ -7,7 +7,7 @@ impl<T: Deref<Target = Block>, PINS> I2C<T, PINS, Controller> {
&mut self,
mut buffer: Peekable<U>,
) -> Result<(), Error> {
let first = true;
let mut first = true;
while let Some(byte) = buffer.next() {
let last = buffer.peek().is_none();
@ -24,6 +24,7 @@ impl<T: Deref<Target = Block>, PINS> I2C<T, PINS, Controller> {
self.i2c.ic_data_cmd.write(|w| {
if first {
w.restart().enable();
first = false;
} else {
w.restart().disable();
}