Try using cfg! macro
This commit is contained in:
parent
cd68f85501
commit
251d004708
@ -755,11 +755,12 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn blocking_read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Error> {
|
pub fn blocking_read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Error> {
|
||||||
#[cfg(feature = "time")]
|
if cfg!(feature = "time") {
|
||||||
self.blocking_read_timeout(address, read, self.timeout)
|
self.blocking_read_timeout(address, read, self.timeout)
|
||||||
#[cfg(not(feature = "time"))]
|
} else {
|
||||||
self.blocking_read_timeout(address, read, || Ok(()))
|
self.blocking_read_timeout(address, read, || Ok(()))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "time")]
|
||||||
pub fn blocking_write_timeout(&mut self, address: u8, write: &[u8], timeout: Duration) -> Result<(), Error> {
|
pub fn blocking_write_timeout(&mut self, address: u8, write: &[u8], timeout: Duration) -> Result<(), Error> {
|
||||||
@ -772,11 +773,12 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn blocking_write(&mut self, address: u8, write: &[u8]) -> Result<(), Error> {
|
pub fn blocking_write(&mut self, address: u8, write: &[u8]) -> Result<(), Error> {
|
||||||
#[cfg(feature = "time")]
|
if cfg!(feature = "time") {
|
||||||
self.blocking_write_timeout(address, write, self.timeout)
|
self.blocking_write_timeout(address, write, self.timeout)
|
||||||
#[cfg(not(feature = "time"))]
|
} else {
|
||||||
self.blocking_write_timeout(address, write, || Ok(()))
|
self.blocking_write_timeout(address, write, || Ok(()))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "time")]
|
||||||
pub fn blocking_write_read_timeout(
|
pub fn blocking_write_read_timeout(
|
||||||
@ -807,11 +809,12 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn blocking_write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Error> {
|
pub fn blocking_write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Error> {
|
||||||
#[cfg(feature = "time")]
|
if cfg!(feature = "time") {
|
||||||
self.blocking_write_read_timeout(address, write, read, self.timeout)
|
self.blocking_write_read_timeout(address, write, read, self.timeout)
|
||||||
#[cfg(not(feature = "time"))]
|
} else {
|
||||||
self.blocking_write_read_timeout(address, write, read, || Ok(()))
|
self.blocking_write_read_timeout(address, write, read, || Ok(()))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn blocking_write_vectored_with_timeout(
|
fn blocking_write_vectored_with_timeout(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -913,11 +916,12 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn blocking_write_vectored(&mut self, address: u8, write: &[&[u8]]) -> Result<(), Error> {
|
pub fn blocking_write_vectored(&mut self, address: u8, write: &[&[u8]]) -> Result<(), Error> {
|
||||||
#[cfg(feature = "time")]
|
if cfg!(feature = "time") {
|
||||||
self.blocking_write_vectored_timeout(address, write, self.timeout)
|
self.blocking_write_vectored_timeout(address, write, self.timeout)
|
||||||
#[cfg(not(feature = "time"))]
|
} else {
|
||||||
self.blocking_write_vectored_timeout(address, write, || Ok(()))
|
self.blocking_write_vectored_timeout(address, write, || Ok(()))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Instance, TXDMA, RXDMA> Drop for I2c<'d, T, TXDMA, RXDMA> {
|
impl<'d, T: Instance, TXDMA, RXDMA> Drop for I2c<'d, T, TXDMA, RXDMA> {
|
||||||
|
Loading…
Reference in New Issue
Block a user