Skip to content

Commit 2acbd77

Browse files
committed
Use AtomicBool from core if not using portable-atomic
1 parent cc868a3 commit 2acbd77

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

embedded-hal-bus/src/util.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
#[allow(unused_imports)]
44
use core::cell::UnsafeCell;
55

6+
#[cfg(not(feature = "portable-atomic"))]
7+
use core::sync::atomic::AtomicBool;
8+
#[cfg(feature = "portable-atomic")]
9+
use portable_atomic::AtomicBool;
10+
611
#[cfg(any(feature = "portable-atomic", target_has_atomic = "8"))]
712
/// Cell type used by [`spi::AtomicDevice`](crate::spi::AtomicDevice) and [`i2c::AtomicDevice`](crate::i2c::AtomicDevice).
813
///
914
/// To use `AtomicDevice`, you must wrap the bus with this struct, and then
1015
/// construct multiple `AtomicDevice` instances with references to it.
1116
pub struct AtomicCell<BUS> {
1217
pub(crate) bus: UnsafeCell<BUS>,
13-
pub(crate) busy: portable_atomic::AtomicBool,
18+
pub(crate) busy: AtomicBool,
1419
}
1520
#[cfg(any(feature = "portable-atomic", target_has_atomic = "8"))]
1621
unsafe impl<BUS: Send> Send for AtomicCell<BUS> {}
@@ -23,7 +28,7 @@ impl<BUS> AtomicCell<BUS> {
2328
pub fn new(bus: BUS) -> Self {
2429
Self {
2530
bus: UnsafeCell::new(bus),
26-
busy: portable_atomic::AtomicBool::from(false),
31+
busy: AtomicBool::from(false),
2732
}
2833
}
2934
}

0 commit comments

Comments
 (0)