Skip to content

Commit

Permalink
Switch atomic-polyfill to portable-atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeaurivage committed Oct 26, 2023
1 parent 78da5ca commit 82d24dc
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
6 changes: 2 additions & 4 deletions hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ features = ["samd21g", "samd21g-rt", "unproven", "usb"]

[dependencies]
aes = "0.7.5"
atomic-polyfill = "0.1.8"
bitfield = "0.13"
bitflags = "1.2.1"
cipher = "0.3"
Expand All @@ -43,6 +42,7 @@ nb = "1.0"
num-traits = {version = "0.2.14", default-features = false}
opaque-debug = "0.3.0"
paste = "1.0.11"
portable-atomic = {version = "1.5.0", optional = true, default-features = false}
rand_core = "0.6"
seq-macro = "0.3"
typenum = "1.12.0"
Expand Down Expand Up @@ -97,9 +97,6 @@ atsame53n = {version = "0.13.0", path = "../pac/atsame53n", optional = true}
atsame54n = {version = "0.13.0", path = "../pac/atsame54n", optional = true}
atsame54p = {version = "0.13.0", path = "../pac/atsame54p", optional = true}




#===============================================================================
# Features
#===============================================================================
Expand Down Expand Up @@ -201,6 +198,7 @@ async = [
"embassy-sync",
"embedded-hal-async",
"futures",
"portable-atomic"
]

#===============================================================================
Expand Down
2 changes: 1 addition & 1 deletion hal/src/async_hal/timer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::{ehal::timer::CountDown, timer_traits::InterruptDrivenTimer, typelevel::Sealed};
use atomic_polyfill::AtomicBool;
use core::{
future::poll_fn,
sync::atomic::Ordering,
Expand All @@ -9,6 +8,7 @@ use cortex_m::interrupt::InterruptNumber;
use cortex_m_interrupt::NvicInterruptRegistration;
use embassy_sync::waitqueue::AtomicWaker;
use fugit::{MicrosDurationU32, MillisDurationU32, NanosDurationU32};
use portable_atomic::AtomicBool;

#[cfg(feature = "thumbv6")]
use crate::thumbv6m::timer;
Expand Down
9 changes: 6 additions & 3 deletions hal/src/dmac/channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ impl<Id: ChId, S: Status> Channel<Id, S> {
}

/// Stop transfer on channel whether or not the transfer has completed
#[inline]
pub(crate) fn stop(&mut self) {
self.regs.chctrla.modify(|_, w| w.enable().clear_bit());
}
Expand All @@ -274,10 +275,12 @@ impl<Id: ChId, S: Status> Channel<Id, S> {
!self.regs.chctrla.read().enable().bit_is_set()
}

/// Returns whether the transfer's success status.
/// Returns the transfer's success status.
#[allow(dead_code)]
#[inline]
pub(crate) fn xfer_success(&mut self) -> super::Result<()> {
let is_ok = self.regs.chintflag.read().terr().bit_is_clear();
is_ok.then_some(()).ok_or(super::Error::TransferError)
let success = self.regs.chintflag.read().terr().bit_is_clear();
success.then_some(()).ok_or(super::Error::TransferError)
}
}

Expand Down
1 change: 1 addition & 0 deletions hal/src/dmac/dma_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ impl DmaController {
with_num_channels!(define_split);
}

#[cfg(feature = "async")]
macro_rules! define_split_future {
($num_channels:literal) => {
seq!(N in 0..$num_channels {
Expand Down
1 change: 1 addition & 0 deletions hal/src/sercom/i2c/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub enum Error {
Dma(crate::dmac::Error),
}

#[cfg(feature = "async")]
impl embedded_hal_async::i2c::Error for Error {
// _ pattern reachable when "dma" feature enabled.
#[allow(unreachable_patterns)]
Expand Down
1 change: 1 addition & 0 deletions hal/src/sercom/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ bitflags! {
}
}

#[allow(dead_code)]
impl Flags {
pub(super) const RX: Self = unsafe { Self::from_bits_unchecked(RX_FLAG_MASK) };
pub(super) const TX: Self = unsafe { Self::from_bits_unchecked(TX_FLAG_MASK) };
Expand Down

0 comments on commit 82d24dc

Please sign in to comment.