diff options
| author | Matt Ickstadt <[email protected]> | 2023-07-31 14:17:50 -0500 |
|---|---|---|
| committer | Matt Ickstadt <[email protected]> | 2023-07-31 14:17:50 -0500 |
| commit | 036bc669cd46012e37e09af070ddb8353454719a (patch) | |
| tree | 9e18494d642cc712e311eb126fe90cff8886387b | |
| parent | 26cc0e634d1e0f51e7c4c5bb55fea4f7bec299aa (diff) | |
stm32: only enable async TimeoutI2c on V2 I2C peripheral
| -rw-r--r-- | embassy-stm32/src/i2c/timeout.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/embassy-stm32/src/i2c/timeout.rs b/embassy-stm32/src/i2c/timeout.rs index 830de8e9a..103017cd1 100644 --- a/embassy-stm32/src/i2c/timeout.rs +++ b/embassy-stm32/src/i2c/timeout.rs | |||
| @@ -30,6 +30,7 @@ impl<'a, 'd: 'a, T: Instance, TXDMA, RXDMA> TimeoutI2c<'a, 'd, T, TXDMA, RXDMA> | |||
| 30 | // ========================= | 30 | // ========================= |
| 31 | // Async public API | 31 | // Async public API |
| 32 | 32 | ||
| 33 | #[cfg(i2c_v2)] | ||
| 33 | pub async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Error> | 34 | pub async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Error> |
| 34 | where | 35 | where |
| 35 | TXDMA: crate::i2c::TxDma<T>, | 36 | TXDMA: crate::i2c::TxDma<T>, |
| @@ -37,6 +38,7 @@ impl<'a, 'd: 'a, T: Instance, TXDMA, RXDMA> TimeoutI2c<'a, 'd, T, TXDMA, RXDMA> | |||
| 37 | self.write_timeout(address, write, self.timeout).await | 38 | self.write_timeout(address, write, self.timeout).await |
| 38 | } | 39 | } |
| 39 | 40 | ||
| 41 | #[cfg(i2c_v2)] | ||
| 40 | pub async fn write_timeout(&mut self, address: u8, write: &[u8], timeout: Duration) -> Result<(), Error> | 42 | pub async fn write_timeout(&mut self, address: u8, write: &[u8], timeout: Duration) -> Result<(), Error> |
| 41 | where | 43 | where |
| 42 | TXDMA: crate::i2c::TxDma<T>, | 44 | TXDMA: crate::i2c::TxDma<T>, |
| @@ -44,6 +46,7 @@ impl<'a, 'd: 'a, T: Instance, TXDMA, RXDMA> TimeoutI2c<'a, 'd, T, TXDMA, RXDMA> | |||
| 44 | self.i2c.write_timeout(address, write, timeout_fn(timeout)).await | 46 | self.i2c.write_timeout(address, write, timeout_fn(timeout)).await |
| 45 | } | 47 | } |
| 46 | 48 | ||
| 49 | #[cfg(i2c_v2)] | ||
| 47 | pub async fn write_vectored(&mut self, address: u8, write: &[&[u8]]) -> Result<(), Error> | 50 | pub async fn write_vectored(&mut self, address: u8, write: &[&[u8]]) -> Result<(), Error> |
| 48 | where | 51 | where |
| 49 | TXDMA: crate::i2c::TxDma<T>, | 52 | TXDMA: crate::i2c::TxDma<T>, |
| @@ -51,6 +54,7 @@ impl<'a, 'd: 'a, T: Instance, TXDMA, RXDMA> TimeoutI2c<'a, 'd, T, TXDMA, RXDMA> | |||
| 51 | self.write_vectored_timeout(address, write, self.timeout).await | 54 | self.write_vectored_timeout(address, write, self.timeout).await |
| 52 | } | 55 | } |
| 53 | 56 | ||
| 57 | #[cfg(i2c_v2)] | ||
| 54 | pub async fn write_vectored_timeout(&mut self, address: u8, write: &[&[u8]], timeout: Duration) -> Result<(), Error> | 58 | pub async fn write_vectored_timeout(&mut self, address: u8, write: &[&[u8]], timeout: Duration) -> Result<(), Error> |
| 55 | where | 59 | where |
| 56 | TXDMA: crate::i2c::TxDma<T>, | 60 | TXDMA: crate::i2c::TxDma<T>, |
| @@ -60,6 +64,7 @@ impl<'a, 'd: 'a, T: Instance, TXDMA, RXDMA> TimeoutI2c<'a, 'd, T, TXDMA, RXDMA> | |||
| 60 | .await | 64 | .await |
| 61 | } | 65 | } |
| 62 | 66 | ||
| 67 | #[cfg(i2c_v2)] | ||
| 63 | pub async fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Error> | 68 | pub async fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Error> |
| 64 | where | 69 | where |
| 65 | RXDMA: crate::i2c::RxDma<T>, | 70 | RXDMA: crate::i2c::RxDma<T>, |
| @@ -67,6 +72,7 @@ impl<'a, 'd: 'a, T: Instance, TXDMA, RXDMA> TimeoutI2c<'a, 'd, T, TXDMA, RXDMA> | |||
| 67 | self.read_timeout(address, buffer, self.timeout).await | 72 | self.read_timeout(address, buffer, self.timeout).await |
| 68 | } | 73 | } |
| 69 | 74 | ||
| 75 | #[cfg(i2c_v2)] | ||
| 70 | pub async fn read_timeout(&mut self, address: u8, buffer: &mut [u8], timeout: Duration) -> Result<(), Error> | 76 | pub async fn read_timeout(&mut self, address: u8, buffer: &mut [u8], timeout: Duration) -> Result<(), Error> |
| 71 | where | 77 | where |
| 72 | RXDMA: crate::i2c::RxDma<T>, | 78 | RXDMA: crate::i2c::RxDma<T>, |
| @@ -74,6 +80,7 @@ impl<'a, 'd: 'a, T: Instance, TXDMA, RXDMA> TimeoutI2c<'a, 'd, T, TXDMA, RXDMA> | |||
| 74 | self.i2c.read_timeout(address, buffer, timeout_fn(timeout)).await | 80 | self.i2c.read_timeout(address, buffer, timeout_fn(timeout)).await |
| 75 | } | 81 | } |
| 76 | 82 | ||
| 83 | #[cfg(i2c_v2)] | ||
| 77 | pub async fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Error> | 84 | pub async fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Error> |
| 78 | where | 85 | where |
| 79 | TXDMA: super::TxDma<T>, | 86 | TXDMA: super::TxDma<T>, |
| @@ -82,6 +89,7 @@ impl<'a, 'd: 'a, T: Instance, TXDMA, RXDMA> TimeoutI2c<'a, 'd, T, TXDMA, RXDMA> | |||
| 82 | self.write_read_timeout(address, write, read, self.timeout).await | 89 | self.write_read_timeout(address, write, read, self.timeout).await |
| 83 | } | 90 | } |
| 84 | 91 | ||
| 92 | #[cfg(i2c_v2)] | ||
| 85 | pub async fn write_read_timeout( | 93 | pub async fn write_read_timeout( |
| 86 | &mut self, | 94 | &mut self, |
| 87 | address: u8, | 95 | address: u8, |
