diff --git a/embassy-macros/src/lib.rs b/embassy-macros/src/lib.rs index 26b49b2e..145714f2 100644 --- a/embassy-macros/src/lib.rs +++ b/embassy-macros/src/lib.rs @@ -256,7 +256,7 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream { let chip_setup = chip::generate(macro_args); let result = quote! { - #[embassy::executor::task] + #[embassy::task] async fn __embassy_main(#args) { #task_fn_body } diff --git a/embassy-nrf-examples/src/bin/executor_fairness_test.rs b/embassy-nrf-examples/src/bin/executor_fairness_test.rs index e82e5475..3ea74316 100644 --- a/embassy-nrf-examples/src/bin/executor_fairness_test.rs +++ b/embassy-nrf-examples/src/bin/executor_fairness_test.rs @@ -11,11 +11,11 @@ use example_common::*; use core::task::Poll; use defmt::panic; -use embassy::executor::{task, Spawner}; +use embassy::executor::Spawner; use embassy::time::{Duration, Instant, Timer}; use embassy_nrf::interrupt; -#[task] +#[embassy::task] async fn run1() { loop { info!("DING DONG"); @@ -23,14 +23,14 @@ async fn run1() { } } -#[task] +#[embassy::task] async fn run2() { loop { Timer::at(Instant::from_ticks(0)).await; } } -#[task] +#[embassy::task] async fn run3() { futures::future::poll_fn(|cx| { cx.waker().wake_by_ref(); diff --git a/embassy-nrf-examples/src/bin/multiprio.rs b/embassy-nrf-examples/src/bin/multiprio.rs index aa2824f6..c6228a1e 100644 --- a/embassy-nrf-examples/src/bin/multiprio.rs +++ b/embassy-nrf-examples/src/bin/multiprio.rs @@ -66,13 +66,13 @@ use example_common::*; use cortex_m_rt::entry; use defmt::panic; -use embassy::executor::{task, Executor, InterruptExecutor}; +use embassy::executor::{Executor, InterruptExecutor}; use embassy::interrupt::InterruptExt; use embassy::time::{Duration, Instant, Timer}; use embassy::util::Forever; use embassy_nrf::{interrupt, peripherals, rtc}; -#[task] +#[embassy::task] async fn run_high() { loop { info!(" [high] tick!"); @@ -80,7 +80,7 @@ async fn run_high() { } } -#[task] +#[embassy::task] async fn run_med() { loop { let start = Instant::now(); @@ -97,7 +97,7 @@ async fn run_med() { } } -#[task] +#[embassy::task] async fn run_low() { loop { let start = Instant::now(); diff --git a/embassy-nrf-examples/src/bin/timer.rs b/embassy-nrf-examples/src/bin/timer.rs index 6116aa60..a2b717bc 100644 --- a/embassy-nrf-examples/src/bin/timer.rs +++ b/embassy-nrf-examples/src/bin/timer.rs @@ -10,10 +10,10 @@ mod example_common; use example_common::*; use defmt::panic; -use embassy::executor::{task, Spawner}; +use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; -#[task] +#[embassy::task] async fn run1() { loop { info!("BIG INFREQUENT TICK"); @@ -21,7 +21,7 @@ async fn run1() { } } -#[task] +#[embassy::task] async fn run2() { loop { info!("tick"); diff --git a/embassy-std-examples/src/bin/serial.rs b/embassy-std-examples/src/bin/serial.rs index 6d628fe1..79f10c41 100644 --- a/embassy-std-examples/src/bin/serial.rs +++ b/embassy-std-examples/src/bin/serial.rs @@ -6,7 +6,6 @@ mod serial_port; use async_io::Async; -use embassy::executor::task; use embassy::io::AsyncBufReadExt; use embassy::util::Forever; use embassy_std::Executor; @@ -15,7 +14,7 @@ use nix::sys::termios; use self::serial_port::SerialPort; -#[task] +#[embassy::task] async fn run() { // Open the serial port. let baudrate = termios::BaudRate::B115200; diff --git a/embassy-std-examples/src/bin/tick.rs b/embassy-std-examples/src/bin/tick.rs index 96eef067..47713f7b 100644 --- a/embassy-std-examples/src/bin/tick.rs +++ b/embassy-std-examples/src/bin/tick.rs @@ -2,13 +2,12 @@ #![feature(impl_trait_in_bindings)] #![feature(type_alias_impl_trait)] -use embassy::executor::task; use embassy::time::{Duration, Timer}; use embassy::util::Forever; use embassy_std::Executor; use log::*; -#[task] +#[embassy::task] async fn run() { loop { info!("tick"); diff --git a/embassy-stm32f4-examples/src/bin/can.rs b/embassy-stm32f4-examples/src/bin/can.rs index 5ffde247..c34c0a2a 100644 --- a/embassy-stm32f4-examples/src/bin/can.rs +++ b/embassy-stm32f4-examples/src/bin/can.rs @@ -11,13 +11,13 @@ use example_common::{panic, *}; use bxcan::filter::Mask32; use cortex_m_rt::entry; -use embassy::executor::{task, Executor}; +use embassy::executor::Executor; use embassy::util::Forever; use embassy_stm32f4::{can, interrupt}; use stm32f4xx_hal::prelude::*; use stm32f4xx_hal::{can::Can, stm32}; -#[task] +#[embassy::task] async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) { let gpioa = dp.GPIOA.split(); diff --git a/embassy-stm32f4-examples/src/bin/exti.rs b/embassy-stm32f4-examples/src/bin/exti.rs index 9b2535b1..9879de40 100644 --- a/embassy-stm32f4-examples/src/bin/exti.rs +++ b/embassy-stm32f4-examples/src/bin/exti.rs @@ -10,7 +10,7 @@ mod example_common; use example_common::{panic, *}; use cortex_m_rt::entry; -use embassy::executor::{task, Executor}; +use embassy::executor::Executor; use embassy::traits::gpio::*; use embassy::util::Forever; use embassy_stm32f4::exti::ExtiPin; @@ -19,7 +19,7 @@ use futures::pin_mut; use stm32f4xx_hal::prelude::*; use stm32f4xx_hal::stm32; -#[task] +#[embassy::task] async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) { let gpioa = dp.GPIOA.split(); diff --git a/embassy-stm32f4-examples/src/bin/rtc_async.rs b/embassy-stm32f4-examples/src/bin/rtc_async.rs index 1927d01b..f2757294 100644 --- a/embassy-stm32f4-examples/src/bin/rtc_async.rs +++ b/embassy-stm32f4-examples/src/bin/rtc_async.rs @@ -11,12 +11,11 @@ use example_common::*; use defmt::panic; use embassy; use embassy::executor::Spawner; -use embassy::task; use embassy::time::{Duration, Timer}; use embassy_stm32f4; use embassy_stm32f4::hal; -#[task] +#[embassy::task] async fn run1() { loop { info!("BIG INFREQUENT TICK"); @@ -24,7 +23,7 @@ async fn run1() { } } -#[task] +#[embassy::task] async fn run2() { loop { info!("tick"); diff --git a/embassy-stm32f4-examples/src/bin/serial.rs b/embassy-stm32f4-examples/src/bin/serial.rs index c8e7f288..925fd68f 100644 --- a/embassy-stm32f4-examples/src/bin/serial.rs +++ b/embassy-stm32f4-examples/src/bin/serial.rs @@ -11,7 +11,7 @@ use example_common::{panic, *}; use cortex_m::singleton; use cortex_m_rt::entry; -use embassy::executor::{task, Executor}; +use embassy::executor::Executor; use embassy::traits::uart::{Read, Write}; use embassy::util::Forever; use embassy_stm32f4::interrupt; @@ -22,7 +22,7 @@ use stm32f4xx_hal::prelude::*; use stm32f4xx_hal::serial::config::Config; use stm32f4xx_hal::stm32; -#[task] +#[embassy::task] async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) { dp.DBGMCU.cr.modify(|_, w| { w.dbg_sleep().set_bit(); diff --git a/embassy-stm32f4-examples/src/bin/usb_serial.rs b/embassy-stm32f4-examples/src/bin/usb_serial.rs index f1c4631d..6d3b2cc1 100644 --- a/embassy-stm32f4-examples/src/bin/usb_serial.rs +++ b/embassy-stm32f4-examples/src/bin/usb_serial.rs @@ -10,7 +10,7 @@ use example_common::*; use cortex_m_rt::entry; use defmt::panic; -use embassy::executor::{task, Executor}; +use embassy::executor::Executor; use embassy::interrupt::InterruptExt; use embassy::io::{AsyncBufReadExt, AsyncWriteExt}; use embassy::time::{Duration, Timer}; @@ -25,7 +25,7 @@ use stm32f4xx_hal::prelude::*; use usb_device::bus::UsbBusAllocator; use usb_device::prelude::*; -#[task] +#[embassy::task] async fn run1(bus: &'static mut UsbBusAllocator>) { info!("Async task"); diff --git a/embassy/src/executor/mod.rs b/embassy/src/executor/mod.rs index b2c42190..8a3a8991 100644 --- a/embassy/src/executor/mod.rs +++ b/embassy/src/executor/mod.rs @@ -1,5 +1,3 @@ -pub use embassy_macros::{main, task}; - use core::marker::PhantomData; use core::ptr::NonNull; use core::{mem, ptr}; diff --git a/embassy/src/executor/timer.rs b/embassy/src/executor/timer.rs index 541f96f5..774613eb 100644 --- a/embassy/src/executor/timer.rs +++ b/embassy/src/executor/timer.rs @@ -60,7 +60,7 @@ impl Timer { /// use embassy::executor::task; /// use embassy::time::{Duration, Timer}; /// - /// #[task] + /// #[embassy::task] /// async fn demo_sleep_seconds() { /// // suspend this task for one second. /// Timer::after(Duration::from_secs(1)).await; @@ -104,7 +104,7 @@ impl Future for Timer { /// use embassy::time::{Duration, Timer}; /// # fn foo() {} /// -/// #[task] +/// #[embassy::task] /// async fn ticker_example_0() { /// loop { /// foo(); @@ -129,7 +129,7 @@ impl Future for Timer { /// use futures::StreamExt; /// # fn foo(){} /// -/// #[task] +/// #[embassy::task] /// async fn ticker_example_1() { /// let mut ticker = Ticker::every(Duration::from_secs(1)); /// loop { diff --git a/embassy/src/lib.rs b/embassy/src/lib.rs index 482d5b36..af05a794 100644 --- a/embassy/src/lib.rs +++ b/embassy/src/lib.rs @@ -17,8 +17,8 @@ pub mod io; pub mod time; pub mod util; +pub use embassy_macros::*; pub use embassy_traits as traits; -pub use executor::{main, task}; #[doc(hidden)] /// Implementation details for embassy macros. DO NOT USE. diff --git a/embassy/src/util/signal.rs b/embassy/src/util/signal.rs index 749b3224..e4629bf9 100644 --- a/embassy/src/util/signal.rs +++ b/embassy/src/util/signal.rs @@ -122,7 +122,7 @@ unsafe impl cortex_m::interrupt::Nr for NrWrap { /// use embassy::util::InterruptFuture; /// use embassy::executor::task; /// use embassy_stm32f4::interrupt; // Adjust this to your MCU's embassy HAL. -/// #[task] +/// #[embassy::task] /// async fn demo_interrupt_future() { /// // Using STM32f446 interrupt names, adjust this to your application as necessary. /// // Wait for TIM2 to tick.