fix (rp i2c): fix restart/stop flags for i2c master methods
Update the start and stop flags for all read/write/read_write methods to match those in the default blocking implementation of these methods (as well as other RP2040 I2C implementations, and expected I2C behavior). Also adds a write_read_async method that doesnt require using embedded-hal, as this is required to use I2C in an idiomatic fashion (see TI Application Report SLVA704).
This commit is contained in:
parent
233aa1b53a
commit
322f9cb153
1 changed files with 13 additions and 2 deletions
|
@ -295,13 +295,24 @@ impl<'d, T: Instance> I2c<'d, T, Async> {
|
|||
|
||||
pub async fn read_async(&mut self, addr: u16, buffer: &mut [u8]) -> Result<(), Error> {
|
||||
Self::setup(addr)?;
|
||||
self.read_async_internal(buffer, false, true).await
|
||||
self.read_async_internal(buffer, true, true).await
|
||||
}
|
||||
|
||||
pub async fn write_async(&mut self, addr: u16, bytes: impl IntoIterator<Item = u8>) -> Result<(), Error> {
|
||||
Self::setup(addr)?;
|
||||
self.write_async_internal(bytes, true).await
|
||||
}
|
||||
|
||||
pub async fn write_read_async(
|
||||
&mut self,
|
||||
addr: u16,
|
||||
bytes: impl IntoIterator<Item = u8>,
|
||||
buffer: &mut [u8],
|
||||
) -> Result<(), Error> {
|
||||
Self::setup(addr)?;
|
||||
self.write_async_internal(bytes, false).await?;
|
||||
self.read_async_internal(buffer, true, true).await
|
||||
}
|
||||
}
|
||||
|
||||
pub struct InterruptHandler<T: Instance> {
|
||||
|
@ -713,7 +724,7 @@ mod nightly {
|
|||
|
||||
Self::setup(addr)?;
|
||||
self.write_async_internal(write.iter().cloned(), false).await?;
|
||||
self.read_async_internal(read, false, true).await
|
||||
self.read_async_internal(read, true, true).await
|
||||
}
|
||||
|
||||
async fn transaction(&mut self, address: A, operations: &mut [Operation<'_>]) -> Result<(), Self::Error> {
|
||||
|
|
Loading…
Reference in a new issue