Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ categories = [
license = "MIT OR Apache-2.0"

[dependencies]
cortex-m = { version = "0.6.0", optional = true }
critical-section = { version = "1.1", optional = true }

[dependencies.defmt]
version = "0.3.0"
optional = true

[features]
thumbv6 = ["cortex-m"]
thumbv6 = ["critical-section"]
defmt_0_3 = ["defmt"]

[package.metadata.docs.rs]
Expand Down
8 changes: 4 additions & 4 deletions core/src/bbbuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1108,11 +1108,11 @@ mod atomic {
AtomicBool, AtomicUsize,
Ordering::{self, Acquire, Release},
};
use cortex_m::interrupt::free;
use critical_section::with;

#[inline(always)]
pub fn fetch_add(atomic: &AtomicUsize, val: usize, _order: Ordering) -> usize {
free(|_| {
with(|_| {
let prev = atomic.load(Acquire);
atomic.store(prev.wrapping_add(val), Release);
prev
Expand All @@ -1121,7 +1121,7 @@ mod atomic {

#[inline(always)]
pub fn fetch_sub(atomic: &AtomicUsize, val: usize, _order: Ordering) -> usize {
free(|_| {
with(|_| {
let prev = atomic.load(Acquire);
atomic.store(prev.wrapping_sub(val), Release);
prev
Expand All @@ -1130,7 +1130,7 @@ mod atomic {

#[inline(always)]
pub fn swap(atomic: &AtomicBool, val: bool, _order: Ordering) -> bool {
free(|_| {
with(|_| {
let prev = atomic.load(Acquire);
atomic.store(val, Release);
prev
Expand Down
7 changes: 5 additions & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@
//!
//! This crate contains special support for Cortex-M0(+) targets with the `thumbv6` feature. By
//! enabling the feature, unsupported atomic operations will be replaced with critical sections
//! implemented by disabling interrupts. The critical sections are very short, a few instructions at
//! most, so they should make no difference to most applications.
//! using the `critical_section` crate. The critical sections are very short, a few instructions at
//! most, so they should make no difference to most applications. When using this feature an
//! implementation must be provided for the `critical_section` crate. A single core version that
//! disables interrupts is available on the `cortex_m` crate by enabling the feature
//! `critical-section-single-core` on that crate.

#![cfg_attr(not(feature = "std"), no_std)]
#![deny(missing_docs)]
Expand Down