Merge pull request #2039 from jcdickinson/rp-i2c-stop-restart

fix (rp i2c): fix restart/stop flags for i2c master methods
This commit is contained in:
Dario Nieuwenhuis 2023-10-11 00:40:59 +00:00 committed by GitHub
commit 5a19d18b9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -294,13 +294,24 @@ impl<'d, T: Instance> I2c<'d, T, Async> {
pub async fn read_async(&mut self, addr: u16, buffer: &mut [u8]) -> Result<(), Error> { pub async fn read_async(&mut self, addr: u16, buffer: &mut [u8]) -> Result<(), Error> {
Self::setup(addr)?; 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> { pub async fn write_async(&mut self, addr: u16, bytes: impl IntoIterator<Item = u8>) -> Result<(), Error> {
Self::setup(addr)?; Self::setup(addr)?;
self.write_async_internal(bytes, true).await 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> { pub struct InterruptHandler<T: Instance> {
@ -713,7 +724,7 @@ mod nightly {
Self::setup(addr)?; Self::setup(addr)?;
self.write_async_internal(write.iter().cloned(), false).await?; 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> { async fn transaction(&mut self, address: A, operations: &mut [Operation<'_>]) -> Result<(), Self::Error> {