Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion capsules/extra/src/bus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,21 @@ impl<'a, I: I2CDevice> Bus<'a> for I2CMasterBus<'a, I> {
}
}
}),

BusWidth::Bits16LE => self
.addr_buffer
.take()
.map_or(Err(ErrorCode::NOMEM), |buffer| {
buffer[0] = 0x00;
buffer[1] = addr as u8;
self.status.set(BusStatus::SetAddress);
match self.i2c.write(buffer, 2) {
Ok(()) => Ok(()),
Err((error, buffer)) => {
self.addr_buffer.replace(buffer);
Err(error.into())
}
}
}),
_ => Err(ErrorCode::NOSUPPORT),
}
}
Expand All @@ -315,6 +329,7 @@ impl<'a, I: I2CDevice> Bus<'a> for I2CMasterBus<'a, I> {
// endianess does not matter as the buffer is sent as is
let bytes = data_width.width_in_bytes();
self.len.set(len * bytes);

if len * bytes < 255 && buffer.len() >= len * bytes {
debug!("write len {}", len);
self.len.set(len);
Expand Down