Add example, fix small bug in respond_and_fill

This commit is contained in:
Caleb Jamison
2023-09-10 02:05:58 -04:00
committed by Dario Nieuwenhuis
parent 2d9f50addc
commit 8201979d71
2 changed files with 130 additions and 0 deletions

View File

@ -287,6 +287,18 @@ impl<'d, T: Instance> I2cSlave<'d, T> {
}
}
/// Respond to a master read, then fill any remaining read bytes with `fill`
pub async fn respond_and_fill(&mut self, buffer: &[u8], fill: u8) -> Result<ReadStatus, Error> {
let resp_stat = self.respond_to_read(buffer).await?;
if resp_stat == ReadStatus::NeedMoreBytes {
self.respond_till_stop(fill).await?;
Ok(ReadStatus::Done)
} else {
Ok(resp_stat)
}
}
#[inline(always)]
fn read_and_clear_abort_reason(&mut self) -> Result<(), Error> {
let p = T::regs();