diff options
| author | Andres Oliva <[email protected]> | 2023-10-11 23:32:40 +0200 |
|---|---|---|
| committer | Andres Oliva <[email protected]> | 2023-10-11 23:32:40 +0200 |
| commit | 251d004708762210a2279bee66c1e5b2dcdf93cb (patch) | |
| tree | 912989edd8a85a645d86d3dedec16083e6810732 | |
| parent | cd68f85501fabaf22587a900e60c70b6dae43767 (diff) | |
Try using cfg! macro
| -rw-r--r-- | embassy-stm32/src/i2c/v2.rs | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/embassy-stm32/src/i2c/v2.rs b/embassy-stm32/src/i2c/v2.rs index 33c397404..6627d7f67 100644 --- a/embassy-stm32/src/i2c/v2.rs +++ b/embassy-stm32/src/i2c/v2.rs | |||
| @@ -755,10 +755,11 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 755 | } | 755 | } |
| 756 | 756 | ||
| 757 | pub fn blocking_read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Error> { | 757 | pub fn blocking_read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Error> { |
| 758 | #[cfg(feature = "time")] | 758 | if cfg!(feature = "time") { |
| 759 | self.blocking_read_timeout(address, read, self.timeout) | 759 | self.blocking_read_timeout(address, read, self.timeout) |
| 760 | #[cfg(not(feature = "time"))] | 760 | } else { |
| 761 | self.blocking_read_timeout(address, read, || Ok(())) | 761 | self.blocking_read_timeout(address, read, || Ok(())) |
| 762 | } | ||
| 762 | } | 763 | } |
| 763 | 764 | ||
| 764 | #[cfg(feature = "time")] | 765 | #[cfg(feature = "time")] |
| @@ -772,10 +773,11 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 772 | } | 773 | } |
| 773 | 774 | ||
| 774 | pub fn blocking_write(&mut self, address: u8, write: &[u8]) -> Result<(), Error> { | 775 | pub fn blocking_write(&mut self, address: u8, write: &[u8]) -> Result<(), Error> { |
| 775 | #[cfg(feature = "time")] | 776 | if cfg!(feature = "time") { |
| 776 | self.blocking_write_timeout(address, write, self.timeout) | 777 | self.blocking_write_timeout(address, write, self.timeout) |
| 777 | #[cfg(not(feature = "time"))] | 778 | } else { |
| 778 | self.blocking_write_timeout(address, write, || Ok(())) | 779 | self.blocking_write_timeout(address, write, || Ok(())) |
| 780 | } | ||
| 779 | } | 781 | } |
| 780 | 782 | ||
| 781 | #[cfg(feature = "time")] | 783 | #[cfg(feature = "time")] |
| @@ -807,10 +809,11 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 807 | } | 809 | } |
| 808 | 810 | ||
| 809 | pub fn blocking_write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Error> { | 811 | pub fn blocking_write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Error> { |
| 810 | #[cfg(feature = "time")] | 812 | if cfg!(feature = "time") { |
| 811 | self.blocking_write_read_timeout(address, write, read, self.timeout) | 813 | self.blocking_write_read_timeout(address, write, read, self.timeout) |
| 812 | #[cfg(not(feature = "time"))] | 814 | } else { |
| 813 | self.blocking_write_read_timeout(address, write, read, || Ok(())) | 815 | self.blocking_write_read_timeout(address, write, read, || Ok(())) |
| 816 | } | ||
| 814 | } | 817 | } |
| 815 | 818 | ||
| 816 | fn blocking_write_vectored_with_timeout( | 819 | fn blocking_write_vectored_with_timeout( |
| @@ -913,10 +916,11 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 913 | } | 916 | } |
| 914 | 917 | ||
| 915 | pub fn blocking_write_vectored(&mut self, address: u8, write: &[&[u8]]) -> Result<(), Error> { | 918 | pub fn blocking_write_vectored(&mut self, address: u8, write: &[&[u8]]) -> Result<(), Error> { |
| 916 | #[cfg(feature = "time")] | 919 | if cfg!(feature = "time") { |
| 917 | self.blocking_write_vectored_timeout(address, write, self.timeout) | 920 | self.blocking_write_vectored_timeout(address, write, self.timeout) |
| 918 | #[cfg(not(feature = "time"))] | 921 | } else { |
| 919 | self.blocking_write_vectored_timeout(address, write, || Ok(())) | 922 | self.blocking_write_vectored_timeout(address, write, || Ok(())) |
| 923 | } | ||
| 920 | } | 924 | } |
| 921 | } | 925 | } |
| 922 | 926 | ||
