mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 06:42:32 +00:00
Reexport macros at root, use eveywhere as #[embassy::task]
This commit is contained in:
parent
d5ab02792c
commit
d7c3a38efc
@ -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
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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();
|
||||
|
@ -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<UsbBus<USB>>) {
|
||||
info!("Async task");
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
pub use embassy_macros::{main, task};
|
||||
|
||||
use core::marker::PhantomData;
|
||||
use core::ptr::NonNull;
|
||||
use core::{mem, ptr};
|
||||
|
@ -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 {
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user