riscv support

This commit is contained in:
Sijmen Woutersen 2022-09-25 20:10:11 +02:00
parent 059610a8de
commit 6e1120e17e
4 changed files with 16 additions and 16 deletions

View File

@ -25,6 +25,7 @@ flavors = [
default = []
std = ["embassy-macros/std", "critical-section/std"]
wasm = ["dep:wasm-bindgen", "dep:js-sys", "embassy-macros/wasm"]
riscv = ["embassy-macros/riscv"]
# Enable nightly-only features
nightly = []

View File

@ -54,21 +54,8 @@ impl Executor {
loop {
unsafe {
self.inner.poll();
// we do not care about race conditions between the load and store operations, interrupts
//will only set this value to true.
critical_section::with(|_| {
// if there is work to do, loop back to polling
// TODO can we relax this?
if SIGNAL_WORK_THREAD_MODE.load(Ordering::SeqCst) {
SIGNAL_WORK_THREAD_MODE.store(false, Ordering::SeqCst);
}
// if not, wait for interrupt
else {
core::arch::asm!("wfi");
}
});
// if an interrupt occurred while waiting, it will be serviced here
}
}
}
}

View File

@ -16,6 +16,7 @@ proc-macro = true
[features]
std = []
wasm = []
riscv = []
# Enabling this cause interrupt::take! to require embassy-executor
rtos-trace-interrupt = []

View File

@ -45,7 +45,7 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke
}
};
#[cfg(all(feature = "std", not(feature = "wasm")))]
#[cfg(all(feature = "std", not(feature = "wasm"), not(feature = "riscv")))]
let main = quote! {
fn main() -> ! {
let mut executor = ::embassy_executor::Executor::new();
@ -57,13 +57,24 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke
}
};
#[cfg(all(not(feature = "std"), not(feature = "wasm")))]
#[cfg(all(not(feature = "std"), not(feature = "wasm"), not(feature = "riscv")))]
let main = quote! {
#[cortex_m_rt::entry]
fn main() -> ! {
let mut executor = ::embassy_executor::Executor::new();
let executor = unsafe { __make_static(&mut executor) };
executor.run(|spawner| {
spawner.must_spawn(__embassy_main(spawner));
})
}
};
#[cfg(all(not(feature = "std"), not(feature = "wasm"), feature = "riscv"))]
let main = quote! {
#[riscv_rt::entry]
fn main() -> ! {
let mut executor = ::embassy_executor::Executor::new();
let executor = unsafe { __make_static(&mut executor) };
executor.run(|spawner| {
spawner.must_spawn(__embassy_main(spawner));
})