thumbv6m support with emulated atomics
This commit is contained in:
@ -18,8 +18,9 @@ defmt = { version = "0.2.0", optional = true }
|
||||
log = { version = "0.4.11", optional = true }
|
||||
|
||||
cortex-m = "0.7.1"
|
||||
futures = { version = "0.3.5", default-features = false }
|
||||
futures = { version = "0.3.5", default-features = false, features = [ "cfg-target-has-atomic", "unstable" ] }
|
||||
pin-project = { version = "1.0.2", default-features = false }
|
||||
embassy-macros = { version = "0.1.0", path = "../embassy-macros"}
|
||||
embassy-traits = { version = "0.1.0", path = "../embassy-traits"}
|
||||
atomic-polyfill = { version = "0.1.0" }
|
||||
|
||||
|
29
embassy/build.rs
Normal file
29
embassy/build.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
let target = env::var("TARGET").unwrap();
|
||||
|
||||
if target.starts_with("thumbv6m-") {
|
||||
println!("cargo:rustc-cfg=cortex_m");
|
||||
println!("cargo:rustc-cfg=armv6m");
|
||||
} else if target.starts_with("thumbv7m-") {
|
||||
println!("cargo:rustc-cfg=cortex_m");
|
||||
println!("cargo:rustc-cfg=armv7m");
|
||||
} else if target.starts_with("thumbv7em-") {
|
||||
println!("cargo:rustc-cfg=cortex_m");
|
||||
println!("cargo:rustc-cfg=armv7m");
|
||||
println!("cargo:rustc-cfg=armv7em"); // (not currently used)
|
||||
} else if target.starts_with("thumbv8m.base") {
|
||||
println!("cargo:rustc-cfg=cortex_m");
|
||||
println!("cargo:rustc-cfg=armv8m");
|
||||
println!("cargo:rustc-cfg=armv8m_base");
|
||||
} else if target.starts_with("thumbv8m.main") {
|
||||
println!("cargo:rustc-cfg=cortex_m");
|
||||
println!("cargo:rustc-cfg=armv8m");
|
||||
println!("cargo:rustc-cfg=armv8m_main");
|
||||
}
|
||||
|
||||
if target.ends_with("-eabihf") {
|
||||
println!("cargo:rustc-cfg=has_fpu");
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ use core::future::Future;
|
||||
use core::marker::PhantomData;
|
||||
use core::pin::Pin;
|
||||
use core::ptr::NonNull;
|
||||
use core::sync::atomic::Ordering;
|
||||
use core::task::{Context, Poll};
|
||||
use core::{mem, ptr};
|
||||
|
||||
@ -16,6 +15,7 @@ mod util;
|
||||
mod waker;
|
||||
|
||||
use self::util::UninitCell;
|
||||
use crate::atomic::Ordering;
|
||||
use crate::fmt::panic;
|
||||
use crate::interrupt::{Interrupt, InterruptExt};
|
||||
use crate::time::Alarm;
|
||||
|
@ -3,13 +3,13 @@ use core::cmp::min;
|
||||
use core::marker::PhantomData;
|
||||
use core::ptr;
|
||||
use core::ptr::NonNull;
|
||||
use core::sync::atomic::{AtomicU32, Ordering};
|
||||
use core::task::Waker;
|
||||
|
||||
use super::run_queue::{RunQueue, RunQueueItem};
|
||||
use super::timer_queue::{TimerQueue, TimerQueueItem};
|
||||
use super::util::UninitCell;
|
||||
use super::waker;
|
||||
use crate::atomic::{AtomicU32, Ordering};
|
||||
use crate::time::{Alarm, Instant};
|
||||
|
||||
/// Task is spawned (has a future)
|
||||
|
@ -1,8 +1,8 @@
|
||||
use core::ptr;
|
||||
use core::ptr::NonNull;
|
||||
use core::sync::atomic::{AtomicPtr, Ordering};
|
||||
|
||||
use super::raw::Task;
|
||||
use crate::atomic::{AtomicPtr, Ordering};
|
||||
|
||||
pub(crate) struct RunQueueItem {
|
||||
next: AtomicPtr<Task>,
|
||||
|
@ -2,9 +2,9 @@ use core::cell::Cell;
|
||||
use core::cmp::min;
|
||||
use core::ptr;
|
||||
use core::ptr::NonNull;
|
||||
use core::sync::atomic::Ordering;
|
||||
|
||||
use super::raw::{Task, STATE_TIMER_QUEUED};
|
||||
use crate::atomic::{AtomicPtr, Ordering};
|
||||
use crate::time::Instant;
|
||||
|
||||
pub(crate) struct TimerQueueItem {
|
||||
|
@ -1,7 +1,8 @@
|
||||
use core::ptr;
|
||||
use core::sync::atomic::{AtomicPtr, Ordering};
|
||||
use cortex_m::peripheral::NVIC;
|
||||
|
||||
use crate::atomic::{AtomicBool, AtomicPtr, Ordering};
|
||||
|
||||
pub use embassy_macros::interrupt_declare as declare;
|
||||
pub use embassy_macros::interrupt_take as take;
|
||||
|
||||
@ -45,6 +46,7 @@ pub trait InterruptExt: Interrupt {
|
||||
fn set_handler_context(&self, ctx: *mut ());
|
||||
fn enable(&self);
|
||||
fn disable(&self);
|
||||
#[cfg(not(armv6m))]
|
||||
fn is_active(&self) -> bool;
|
||||
fn is_enabled(&self) -> bool;
|
||||
fn is_pending(&self) -> bool;
|
||||
@ -83,6 +85,7 @@ impl<T: Interrupt + ?Sized> InterruptExt for T {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(not(armv6m))]
|
||||
fn is_active(&self) -> bool {
|
||||
NVIC::is_active(NrWrap(self.number()))
|
||||
}
|
||||
|
@ -16,3 +16,4 @@ pub mod time;
|
||||
pub mod util;
|
||||
|
||||
pub use embassy_traits as traits;
|
||||
pub use atomic_polyfill as atomic;
|
||||
|
@ -1,6 +1,7 @@
|
||||
use core::cell::UnsafeCell;
|
||||
use core::mem::MaybeUninit;
|
||||
use core::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use crate::atomic::{AtomicBool, Ordering};
|
||||
|
||||
pub struct Forever<T> {
|
||||
used: AtomicBool,
|
||||
|
Reference in New Issue
Block a user