Skip to content

Commit b82272a

Browse files
authored
Removed unnecessary unsafe. In prelude added a cfg feature before blocking::I2cSlave import (#131)
1 parent d5fe192 commit b82272a

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/i2c/nonblocking.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,11 @@ macro_rules! i2c {
268268
self.errors += 1;
269269
self.watchdog = 0;
270270
// Disable I2C processing, resetting all hardware state machines
271-
self.i2c.cr1.modify(|_, w| unsafe {w.pe().clear_bit() } );
271+
self.i2c.cr1.modify(|_, w| w.pe().clear_bit() );
272272
// force enough wait states for the pe clear
273273
let _ = self.i2c.cr1.read();
274274
// Enable the I2C processing again
275-
self.i2c.cr1.modify(|_, w| unsafe {w.pe().set_bit() });
275+
self.i2c.cr1.modify(|_, w| w.pe().set_bit() );
276276
},
277277
_ => {self.watchdog -= 1},
278278
}
@@ -372,16 +372,12 @@ macro_rules! i2c {
372372
return Err( WouldBlock)
373373
} else
374374
if self.index == 0 {
375-
self.i2c.cr2.modify(|_, w| unsafe {
376-
w.stop().set_bit()
377-
});
375+
self.i2c.cr2.modify(|_, w| w.stop().set_bit() );
378376
self.errors += 1;
379377
return Err( Other(Error::Nack))
380378
} else
381379
{
382-
self.i2c.cr2.modify(|_, w| unsafe {
383-
w.stop().set_bit()
384-
});
380+
self.i2c.cr2.modify(|_, w| w.stop().set_bit() );
385381
self.errors += 1;
386382
return Err(Other(Error::IncorrectFrameSize(self.index)))
387383
}

src/prelude.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub use crate::dma::DmaExt as _;
2424
pub use crate::exti::ExtiExt as _;
2525
pub use crate::flash::FlashExt as _;
2626
pub use crate::gpio::GpioExt as _;
27+
#[cfg(feature = "i2c-blocking")]
2728
pub use crate::i2c::blocking::I2cSlave;
2829
pub use crate::i2c::I2cExt as _;
2930
pub use crate::power::PowerExt as _;

0 commit comments

Comments
 (0)