Skip to content

Commit 3ddc31a

Browse files
committed
Remove features that enable atomic-polyfill flags
1 parent d346553 commit 3ddc31a

File tree

5 files changed

+20
-30
lines changed

5 files changed

+20
-30
lines changed

embedded-hal-bus/Cargo.toml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,17 @@ version = "0.2.0"
1717
[features]
1818
# Enable shared bus implementations using `std::sync::Mutex`, and implement `std::error::Error` for `DeviceError`
1919
std = []
20-
# Enable shared bus implementations that require Atomic CAS operations
21-
atomic-device = []
20+
# Use `portable-atomic` to enable `atomic-device` on devices without native atomic CAS
21+
#
22+
# `portable-atomic` emulates atomic CAS functionality, allowing `embedded-hal-bus` to use `atomic-device` on hardware
23+
# that does not natively support atomic CAS. If you enable this, you must also add `portable-atomic` to your crate with
24+
# a feature flag such as `unsafe-assume-single-core` or `critical-section` to choose how atomic CAS is implemented.
25+
# See https://docs.rs/portable-atomic/1.7.0/portable_atomic/#optional-features for more info.
26+
portable-atomic = []
2227
# Enable `embedded-hal-async` support.
2328
async = ["dep:embedded-hal-async"]
2429
# Derive `defmt::Format` from `defmt` 0.3 for enums and structs. See https://github.com/knurling-rs/defmt for more info
2530
defmt-03 = ["dep:defmt-03", "embedded-hal/defmt-03", "embedded-hal-async?/defmt-03"]
26-
# Enable critical-section feature in portable-atomic.
27-
#
28-
# `portable-atomic` emulates atomic CAS functionality, allowing `embedded-hal-bus` to use `atomic-device` on hardware that does not natively support atomic CAS.
29-
# This feature requires a critical-section implementation, which is most often provided by your arch crate (cortex-m / riscv / msp430 / avr-device / etc) when the `critical-section-single-core` feature is enabled.
30-
# A list of critical-section impls is available [in the critical section docs](https://github.com/rust-embedded/critical-section?tab=readme-ov-file#usage-in-no-std-binaries)
31-
portable-atomic-critical-section = ["atomic-device", "portable-atomic/critical-section"]
32-
# Enable unsafe-assume-single-core feature of portable-atomic.
33-
#
34-
# `portable-atomic` emulates atomic CAS functionality, allowing `embedded-hal-bus` to use `atomic-device` on hardware that does not natively support atomic CAS.
35-
# This feature is only safe on single core systems
36-
portable-atomic-unsafe-assume-single-core = ["atomic-device", "portable-atomic/unsafe-assume-single-core"]
3731

3832
[dependencies]
3933
embedded-hal = { version = "1.0.0", path = "../embedded-hal" }

embedded-hal-bus/README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,13 @@ provides mechanisms to obtain multiple `I2c` instances out of a single `I2c` ins
3131
## Optional Cargo features
3232

3333
- **`async`**: enable `embedded-hal-async` support.
34-
- **`atomic-device`**: enable shared bus implementations that require Atomic CAS operations.
3534
- **`defmt-03`**: Derive `defmt::Format` from `defmt` 0.3 for enums and structs.
36-
- **`portable-atomic-critical-section`**: Enable critical-section feature in portable-atomic.
35+
- **`portable-atomic`**: Use `portable-atomic` to enable `atomic-device` on devices without native atomic CAS
3736

38-
`portable-atomic` emulates atomic CAS functionality, allowing `embedded-hal-bus` to use `atomic-device` on hardware that does not natively support atomic CAS.
39-
This feature requires a critical-section implementation, which is most often provided by your arch crate (cortex-m / riscv / msp430 / avr-device / etc) when the `critical-section-single-core` feature is enabled.
40-
A list of critical-section impls is available [in the critical section docs](https://github.com/rust-embedded/critical-section?tab=readme-ov-file#usage-in-no-std-binaries)
41-
- **`portable-atomic-unsafe-assume-single-core`**: Enable unsafe-assume-single-core feature of portable-atomic.
42-
43-
`portable-atomic` emulates atomic CAS functionality, allowing `embedded-hal-bus` to use `atomic-device` on hardware that does not natively support atomic CAS.
44-
This feature is only safe on single core systems
37+
`portable-atomic` emulates atomic CAS functionality, allowing `embedded-hal-bus` to use `atomic-device` on hardware
38+
that does not natively support atomic CAS. If you enable this, you must also add `portable-atomic` to your crate with
39+
a feature flag such as `unsafe-assume-single-core` or `critical-section` to choose how atomic CAS is implemented.
40+
See https://docs.rs/portable-atomic/1.7.0/portable_atomic/#optional-features for more info.
4541
- **`std`**: enable shared bus implementations using `std::sync::Mutex`, and implement
4642
`std::error::Error` for `DeviceError`.
4743

embedded-hal-bus/src/i2c/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod mutex;
88
pub use mutex::*;
99
mod critical_section;
1010
pub use self::critical_section::*;
11-
#[cfg(any(feature = "atomic-device", target_has_atomic = "8"))]
11+
#[cfg(any(feature = "portable-atomic", target_has_atomic = "8"))]
1212
mod atomic;
13-
#[cfg(any(feature = "atomic-device", target_has_atomic = "8"))]
13+
#[cfg(any(feature = "portable-atomic", target_has_atomic = "8"))]
1414
pub use atomic::*;

embedded-hal-bus/src/spi/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ pub use refcell::*;
1111
mod mutex;
1212
#[cfg(feature = "std")]
1313
pub use mutex::*;
14-
#[cfg(any(feature = "atomic-device", target_has_atomic = "8"))]
14+
#[cfg(any(feature = "portable-atomic", target_has_atomic = "8"))]
1515
mod atomic;
1616
mod critical_section;
1717
mod shared;
18-
#[cfg(any(feature = "atomic-device", target_has_atomic = "8"))]
18+
#[cfg(any(feature = "portable-atomic", target_has_atomic = "8"))]
1919
pub use atomic::*;
2020

2121
pub use self::critical_section::*;

embedded-hal-bus/src/util.rs

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

6-
#[cfg(any(feature = "atomic-device", target_has_atomic = "8"))]
6+
#[cfg(any(feature = "portable-atomic", target_has_atomic = "8"))]
77
/// Cell type used by [`spi::AtomicDevice`](crate::spi::AtomicDevice) and [`i2c::AtomicDevice`](crate::i2c::AtomicDevice).
88
///
99
/// To use `AtomicDevice`, you must wrap the bus with this struct, and then
@@ -12,12 +12,12 @@ pub struct AtomicCell<BUS> {
1212
pub(crate) bus: UnsafeCell<BUS>,
1313
pub(crate) busy: portable_atomic::AtomicBool,
1414
}
15-
#[cfg(any(feature = "atomic-device", target_has_atomic = "8"))]
15+
#[cfg(any(feature = "portable-atomic", target_has_atomic = "8"))]
1616
unsafe impl<BUS: Send> Send for AtomicCell<BUS> {}
17-
#[cfg(any(feature = "atomic-device", target_has_atomic = "8"))]
17+
#[cfg(any(feature = "portable-atomic", target_has_atomic = "8"))]
1818
unsafe impl<BUS: Send> Sync for AtomicCell<BUS> {}
1919

20-
#[cfg(any(feature = "atomic-device", target_has_atomic = "8"))]
20+
#[cfg(any(feature = "portable-atomic", target_has_atomic = "8"))]
2121
impl<BUS> AtomicCell<BUS> {
2222
/// Create a new `AtomicCell`
2323
pub fn new(bus: BUS) -> Self {

0 commit comments

Comments
 (0)