You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: embedded-hal-bus/src/i2c/atomic.rs
+15-15Lines changed: 15 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
-
use core::cell::UnsafeCell;
2
1
use embedded_hal::i2c::{Error,ErrorKind,ErrorType,I2c};
3
2
3
+
usecrate::util::AtomicCell;
4
+
4
5
/// `UnsafeCell`-based shared bus [`I2c`] implementation.
5
6
///
6
7
/// Sharing is implemented with a `UnsafeCell`. This means it has low overhead, similar to [`crate::i2c::RefCellDevice`] instances, but they are `Send`.
@@ -18,7 +19,7 @@ use embedded_hal::i2c::{Error, ErrorKind, ErrorType, I2c};
18
19
///
19
20
/// ```
20
21
/// use embedded_hal_bus::i2c;
21
-
/// use core::cell::UnsafeCell;
22
+
/// use embedded_hal_bus::util::AtomicCell;
22
23
/// # use embedded_hal::i2c::{self as hali2c, SevenBitAddress, TenBitAddress, I2c, Operation, ErrorKind};
23
24
/// # pub struct Sensor<I2C> {
24
25
/// # i2c: I2C,
@@ -56,19 +57,18 @@ use embedded_hal::i2c::{Error, ErrorKind, ErrorType, I2c};
56
57
/// # let hal = Hal;
57
58
///
58
59
/// let i2c = hal.i2c();
59
-
/// let i2c_unsafe_cell = UnsafeCell::new(i2c);
60
+
/// let i2c_cell = AtomicCell::new(i2c);
60
61
/// let mut temperature_sensor = TemperatureSensor::new(
61
-
/// i2c::AtomicDevice::new(&i2c_unsafe_cell),
62
+
/// i2c::AtomicDevice::new(&i2c_cell),
62
63
/// 0x20,
63
64
/// );
64
65
/// let mut pressure_sensor = PressureSensor::new(
0 commit comments