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 self,
mut buffer: Peekable<U>, mut buffer: Peekable<U>,
) -> Result<(), Error> { ) -> Result<(), Error> {
let first = true; let mut first = true;
while let Some(byte) = buffer.next() { while let Some(byte) = buffer.next() {
let last = buffer.peek().is_none(); 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| { self.i2c.ic_data_cmd.write(|w| {
if first { if first {
w.restart().enable(); w.restart().enable();
first = false;
} else { } else {
w.restart().disable(); w.restart().disable();
} }