Merge pull request #120 from embassy-rs/main-nrf
nrf: add main macro support
This commit is contained in:
commit
95726b730b
@ -8,6 +8,7 @@ edition = "2018"
|
|||||||
syn = { version = "1.0.39", features = ["full", "extra-traits"] }
|
syn = { version = "1.0.39", features = ["full", "extra-traits"] }
|
||||||
quote = "1.0.7"
|
quote = "1.0.7"
|
||||||
darling = "0.10.2"
|
darling = "0.10.2"
|
||||||
|
proc-macro2 = "1.0.24"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
62
embassy-macros/src/chip/nrf.rs
Normal file
62
embassy-macros/src/chip/nrf.rs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
use darling::FromMeta;
|
||||||
|
use proc_macro2::TokenStream;
|
||||||
|
use quote::{format_ident, quote};
|
||||||
|
use syn::spanned::Spanned;
|
||||||
|
|
||||||
|
#[derive(Debug, FromMeta)]
|
||||||
|
pub enum HfclkSource {
|
||||||
|
Internal,
|
||||||
|
ExternalXtal,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for HfclkSource {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::Internal
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, FromMeta)]
|
||||||
|
pub enum LfclkSource {
|
||||||
|
InternalRC,
|
||||||
|
Synthesized,
|
||||||
|
ExternalXtal,
|
||||||
|
ExternalLowSwing,
|
||||||
|
ExternalFullSwing,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for LfclkSource {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::InternalRC
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, FromMeta)]
|
||||||
|
pub struct Args {
|
||||||
|
#[darling(default)]
|
||||||
|
pub hfclk_source: HfclkSource,
|
||||||
|
#[darling(default)]
|
||||||
|
pub lfclk_source: LfclkSource,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn generate(args: Args) -> TokenStream {
|
||||||
|
let hfclk_source = format_ident!("{}", format!("{:?}", args.hfclk_source));
|
||||||
|
let lfclk_source = format_ident!("{}", format!("{:?}", args.lfclk_source));
|
||||||
|
|
||||||
|
quote!(
|
||||||
|
use embassy_nrf::{interrupt, peripherals, rtc};
|
||||||
|
|
||||||
|
let mut config = embassy_nrf::system::Config::default();
|
||||||
|
config.hfclk_source = embassy_nrf::system::HfclkSource::#hfclk_source;
|
||||||
|
config.lfclk_source = embassy_nrf::system::LfclkSource::#lfclk_source;
|
||||||
|
unsafe { embassy_nrf::system::configure(config) };
|
||||||
|
|
||||||
|
let mut rtc = rtc::RTC::new(unsafe { <peripherals::RTC1 as embassy::util::Steal>::steal() }, interrupt::take!(RTC1));
|
||||||
|
let rtc = unsafe { make_static(&mut rtc) };
|
||||||
|
rtc.start();
|
||||||
|
let mut alarm = rtc.alarm0();
|
||||||
|
|
||||||
|
unsafe { embassy::time::set_clock(rtc) };
|
||||||
|
|
||||||
|
let alarm = unsafe { make_static(&mut alarm) };
|
||||||
|
)
|
||||||
|
}
|
51
embassy-macros/src/chip/stm32.rs
Normal file
51
embassy-macros/src/chip/stm32.rs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
use darling::FromMeta;
|
||||||
|
use proc_macro2::TokenStream;
|
||||||
|
use quote::{format_ident, quote};
|
||||||
|
use syn::spanned::Spanned;
|
||||||
|
|
||||||
|
#[derive(Debug, FromMeta)]
|
||||||
|
pub struct Args {
|
||||||
|
#[darling(default)]
|
||||||
|
pub use_hse: Option<u32>,
|
||||||
|
#[darling(default)]
|
||||||
|
pub sysclk: Option<u32>,
|
||||||
|
#[darling(default)]
|
||||||
|
pub pclk1: Option<u32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn generate(args: Args) -> TokenStream {
|
||||||
|
let mut clock_cfg_args = quote! {};
|
||||||
|
if args.use_hse.is_some() {
|
||||||
|
let mhz = args.use_hse.unwrap();
|
||||||
|
clock_cfg_args = quote! { #clock_cfg_args.use_hse(#mhz.mhz()) };
|
||||||
|
}
|
||||||
|
|
||||||
|
if args.sysclk.is_some() {
|
||||||
|
let mhz = args.sysclk.unwrap();
|
||||||
|
clock_cfg_args = quote! { #clock_cfg_args.sysclk(#mhz.mhz()) };
|
||||||
|
}
|
||||||
|
|
||||||
|
if args.pclk1.is_some() {
|
||||||
|
let mhz = args.pclk1.unwrap();
|
||||||
|
clock_cfg_args = quote! { #clock_cfg_args.pclk1(#mhz.mhz()) };
|
||||||
|
}
|
||||||
|
|
||||||
|
quote!(
|
||||||
|
use embassy_stm32::{rtc, interrupt, Peripherals, pac, hal::rcc::RccExt, hal::time::U32Ext};
|
||||||
|
|
||||||
|
let dp = pac::Peripherals::take().unwrap();
|
||||||
|
let rcc = dp.RCC.constrain();
|
||||||
|
let clocks = rcc.cfgr#clock_cfg_args.freeze();
|
||||||
|
|
||||||
|
unsafe { Peripherals::set_peripherals(clocks) };
|
||||||
|
|
||||||
|
let mut rtc = rtc::RTC::new(dp.TIM3, interrupt::take!(TIM3), clocks);
|
||||||
|
let rtc = unsafe { make_static(&mut rtc) };
|
||||||
|
rtc.start();
|
||||||
|
let mut alarm = rtc.alarm1();
|
||||||
|
|
||||||
|
unsafe { embassy::time::set_clock(rtc) };
|
||||||
|
|
||||||
|
let alarm = unsafe { make_static(&mut alarm) };
|
||||||
|
)
|
||||||
|
}
|
@ -191,22 +191,21 @@ pub fn interrupt_take(item: TokenStream) -> TokenStream {
|
|||||||
result.into()
|
result.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, FromMeta)]
|
#[cfg(feature = "nrf")]
|
||||||
struct MainMacroArgs {
|
#[path = "chip/nrf.rs"]
|
||||||
#[darling(default)]
|
mod chip;
|
||||||
use_hse: Option<u32>,
|
|
||||||
#[darling(default)]
|
|
||||||
sysclk: Option<u32>,
|
|
||||||
#[darling(default)]
|
|
||||||
pclk1: Option<u32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#[cfg(feature = "stm32")]
|
||||||
|
#[path = "chip/stm32.rs"]
|
||||||
|
mod chip;
|
||||||
|
|
||||||
|
#[cfg(any(feature = "nrf", feature = "stm32"))]
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
|
pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
let macro_args = syn::parse_macro_input!(args as syn::AttributeArgs);
|
let macro_args = syn::parse_macro_input!(args as syn::AttributeArgs);
|
||||||
let mut task_fn = syn::parse_macro_input!(item as syn::ItemFn);
|
let mut task_fn = syn::parse_macro_input!(item as syn::ItemFn);
|
||||||
|
|
||||||
let macro_args = match MainMacroArgs::from_list(¯o_args) {
|
let macro_args = match chip::Args::from_list(¯o_args) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
return TokenStream::from(e.write_errors());
|
return TokenStream::from(e.write_errors());
|
||||||
@ -254,55 +253,30 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
let name = task_fn.sig.ident.clone();
|
let name = task_fn.sig.ident.clone();
|
||||||
let task_fn_body = task_fn.block.clone();
|
let task_fn_body = task_fn.block.clone();
|
||||||
|
|
||||||
let mut clock_cfg_args = quote! {};
|
let chip_setup = chip::generate(macro_args);
|
||||||
if macro_args.use_hse.is_some() {
|
|
||||||
let mhz = macro_args.use_hse.unwrap();
|
|
||||||
clock_cfg_args = quote! { #clock_cfg_args.use_hse(#mhz.mhz()) };
|
|
||||||
}
|
|
||||||
|
|
||||||
if macro_args.sysclk.is_some() {
|
|
||||||
let mhz = macro_args.sysclk.unwrap();
|
|
||||||
clock_cfg_args = quote! { #clock_cfg_args.sysclk(#mhz.mhz()) };
|
|
||||||
}
|
|
||||||
|
|
||||||
if macro_args.pclk1.is_some() {
|
|
||||||
let mhz = macro_args.pclk1.unwrap();
|
|
||||||
clock_cfg_args = quote! { #clock_cfg_args.pclk1(#mhz.mhz()) };
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = quote! {
|
let result = quote! {
|
||||||
static __embassy_rtc: embassy::util::Forever<embassy_stm32::rtc::RTC<embassy_stm32::pac::TIM3>> = embassy::util::Forever::new();
|
#[embassy::task]
|
||||||
static __embassy_alarm: embassy::util::Forever<embassy_stm32::rtc::Alarm<embassy_stm32::pac::TIM3>> = embassy::util::Forever::new();
|
|
||||||
static __embassy_executor: embassy::util::Forever<embassy::executor::Executor> = embassy::util::Forever::new();
|
|
||||||
|
|
||||||
#[embassy::executor::task]
|
|
||||||
async fn __embassy_main(#args) {
|
async fn __embassy_main(#args) {
|
||||||
#task_fn_body
|
#task_fn_body
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cortex_m_rt::entry]
|
#[cortex_m_rt::entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
use embassy::executor::Executor;
|
unsafe fn make_static<T>(t: &mut T) -> &'static mut T {
|
||||||
use embassy_stm32::{rtc, interrupt, Peripherals, pac, hal::rcc::RccExt, hal::time::U32Ext};
|
::core::mem::transmute(t)
|
||||||
|
}
|
||||||
|
|
||||||
let dp = pac::Peripherals::take().unwrap();
|
#chip_setup
|
||||||
let rcc = dp.RCC.constrain();
|
|
||||||
let clocks = rcc.cfgr#clock_cfg_args.freeze();
|
|
||||||
|
|
||||||
unsafe { Peripherals::set_peripherals(clocks) };
|
let mut executor = ::embassy::executor::Executor::new();
|
||||||
|
let executor = unsafe { make_static(&mut executor) };
|
||||||
let rtc = __embassy_rtc.put(rtc::RTC::new(dp.TIM3, interrupt::take!(TIM3), clocks));
|
|
||||||
rtc.start();
|
|
||||||
|
|
||||||
unsafe { embassy::time::set_clock(rtc) };
|
|
||||||
|
|
||||||
let alarm = __embassy_alarm.put(rtc.alarm1());
|
|
||||||
let executor = __embassy_executor.put(Executor::new());
|
|
||||||
executor.set_alarm(alarm);
|
executor.set_alarm(alarm);
|
||||||
|
|
||||||
executor.run(|spawner| {
|
executor.run(|spawner| {
|
||||||
spawner.spawn(__embassy_main(spawner)).unwrap();
|
spawner.spawn(__embassy_main(spawner)).unwrap();
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
result.into()
|
result.into()
|
||||||
|
@ -8,19 +8,17 @@
|
|||||||
#[path = "../example_common.rs"]
|
#[path = "../example_common.rs"]
|
||||||
mod example_common;
|
mod example_common;
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
|
||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::Spawner;
|
||||||
use embassy::io::{AsyncBufReadExt, AsyncWriteExt};
|
use embassy::io::{AsyncBufReadExt, AsyncWriteExt};
|
||||||
use embassy::util::{Forever, Steal};
|
|
||||||
use embassy_nrf::gpio::NoPin;
|
use embassy_nrf::gpio::NoPin;
|
||||||
use embassy_nrf::{buffered_uarte::BufferedUarte, interrupt, peripherals, rtc, uarte, Peripherals};
|
use embassy_nrf::{buffered_uarte::BufferedUarte, interrupt, uarte, Peripherals};
|
||||||
use example_common::*;
|
use example_common::*;
|
||||||
use futures::pin_mut;
|
use futures::pin_mut;
|
||||||
|
|
||||||
#[task]
|
#[embassy::main]
|
||||||
async fn run() {
|
async fn main(spawner: Spawner) {
|
||||||
let p = unsafe { Peripherals::steal() };
|
let p = Peripherals::take().unwrap();
|
||||||
|
|
||||||
let mut config = uarte::Config::default();
|
let mut config = uarte::Config::default();
|
||||||
config.parity = uarte::Parity::EXCLUDED;
|
config.parity = uarte::Parity::EXCLUDED;
|
||||||
@ -70,27 +68,3 @@ async fn run() {
|
|||||||
info!("write done");
|
info!("write done");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static RTC: Forever<rtc::RTC<peripherals::RTC1>> = Forever::new();
|
|
||||||
static ALARM: Forever<rtc::Alarm<peripherals::RTC1>> = Forever::new();
|
|
||||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
|
||||||
|
|
||||||
#[entry]
|
|
||||||
fn main() -> ! {
|
|
||||||
info!("Hello World!");
|
|
||||||
|
|
||||||
let p = unwrap!(embassy_nrf::Peripherals::take());
|
|
||||||
|
|
||||||
unsafe { embassy_nrf::system::configure(Default::default()) };
|
|
||||||
let rtc = RTC.put(rtc::RTC::new(p.RTC1, interrupt::take!(RTC1)));
|
|
||||||
rtc.start();
|
|
||||||
unsafe { embassy::time::set_clock(rtc) };
|
|
||||||
|
|
||||||
let alarm = ALARM.put(rtc.alarm0());
|
|
||||||
let executor = EXECUTOR.put(Executor::new());
|
|
||||||
executor.set_alarm(alarm);
|
|
||||||
|
|
||||||
executor.run(|spawner| {
|
|
||||||
unwrap!(spawner.spawn(run()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -10,15 +10,12 @@ mod example_common;
|
|||||||
use example_common::*;
|
use example_common::*;
|
||||||
|
|
||||||
use core::task::Poll;
|
use core::task::Poll;
|
||||||
use cortex_m_rt::entry;
|
|
||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::Spawner;
|
||||||
use embassy::time::{Duration, Instant, Timer};
|
use embassy::time::{Duration, Instant, Timer};
|
||||||
use embassy::util::Forever;
|
use embassy_nrf::interrupt;
|
||||||
use embassy_nrf::peripherals;
|
|
||||||
use embassy_nrf::{interrupt, rtc};
|
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run1() {
|
async fn run1() {
|
||||||
loop {
|
loop {
|
||||||
info!("DING DONG");
|
info!("DING DONG");
|
||||||
@ -26,14 +23,14 @@ async fn run1() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run2() {
|
async fn run2() {
|
||||||
loop {
|
loop {
|
||||||
Timer::at(Instant::from_ticks(0)).await;
|
Timer::at(Instant::from_ticks(0)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run3() {
|
async fn run3() {
|
||||||
futures::future::poll_fn(|cx| {
|
futures::future::poll_fn(|cx| {
|
||||||
cx.waker().wake_by_ref();
|
cx.waker().wake_by_ref();
|
||||||
@ -42,27 +39,9 @@ async fn run3() {
|
|||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
static RTC: Forever<rtc::RTC<peripherals::RTC1>> = Forever::new();
|
#[embassy::main]
|
||||||
static ALARM: Forever<rtc::Alarm<peripherals::RTC1>> = Forever::new();
|
async fn main(spawner: Spawner) {
|
||||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
unwrap!(spawner.spawn(run1()));
|
||||||
|
unwrap!(spawner.spawn(run2()));
|
||||||
#[entry]
|
unwrap!(spawner.spawn(run3()));
|
||||||
fn main() -> ! {
|
|
||||||
info!("Hello World!");
|
|
||||||
|
|
||||||
let p = unwrap!(embassy_nrf::Peripherals::take());
|
|
||||||
|
|
||||||
unsafe { embassy_nrf::system::configure(Default::default()) };
|
|
||||||
let rtc = RTC.put(rtc::RTC::new(p.RTC1, interrupt::take!(RTC1)));
|
|
||||||
rtc.start();
|
|
||||||
unsafe { embassy::time::set_clock(rtc) };
|
|
||||||
|
|
||||||
let alarm = ALARM.put(rtc.alarm0());
|
|
||||||
let executor = EXECUTOR.put(Executor::new());
|
|
||||||
executor.set_alarm(alarm);
|
|
||||||
executor.run(|spawner| {
|
|
||||||
unwrap!(spawner.spawn(run1()));
|
|
||||||
unwrap!(spawner.spawn(run2()));
|
|
||||||
unwrap!(spawner.spawn(run3()));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
@ -9,17 +9,14 @@
|
|||||||
mod example_common;
|
mod example_common;
|
||||||
use example_common::*;
|
use example_common::*;
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
|
||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
|
use embassy::executor::Spawner;
|
||||||
use embassy::executor::{task, Executor};
|
|
||||||
use embassy::util::Forever;
|
|
||||||
use embassy_nrf::gpio::{Input, Pull};
|
use embassy_nrf::gpio::{Input, Pull};
|
||||||
use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity};
|
use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity};
|
||||||
use embassy_nrf::{interrupt, Peripherals};
|
use embassy_nrf::{interrupt, Peripherals};
|
||||||
|
|
||||||
#[task]
|
#[embassy::main]
|
||||||
async fn run() {
|
async fn main(spawner: Spawner) {
|
||||||
let p = Peripherals::take().unwrap();
|
let p = Peripherals::take().unwrap();
|
||||||
let g = gpiote::initialize(p.GPIOTE, interrupt::take!(GPIOTE));
|
let g = gpiote::initialize(p.GPIOTE, interrupt::take!(GPIOTE));
|
||||||
|
|
||||||
@ -80,15 +77,3 @@ async fn run() {
|
|||||||
|
|
||||||
futures::join!(button1, button2, button3, button4);
|
futures::join!(button1, button2, button3, button4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
|
||||||
|
|
||||||
#[entry]
|
|
||||||
fn main() -> ! {
|
|
||||||
info!("Hello World!");
|
|
||||||
|
|
||||||
let executor = EXECUTOR.put(Executor::new());
|
|
||||||
executor.run(|spawner| {
|
|
||||||
unwrap!(spawner.spawn(run()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -9,11 +9,9 @@
|
|||||||
mod example_common;
|
mod example_common;
|
||||||
|
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use cortex_m_rt::entry;
|
|
||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::Spawner;
|
||||||
use embassy::traits::gpio::{WaitForHigh, WaitForLow};
|
use embassy::traits::gpio::{WaitForHigh, WaitForLow};
|
||||||
use embassy::util::Forever;
|
|
||||||
use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull};
|
use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull};
|
||||||
use embassy_nrf::gpiote::{self, PortInput};
|
use embassy_nrf::gpiote::{self, PortInput};
|
||||||
use embassy_nrf::interrupt;
|
use embassy_nrf::interrupt;
|
||||||
@ -29,8 +27,8 @@ async fn button(n: usize, mut pin: PortInput<'static, AnyPin>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task]
|
#[embassy::main]
|
||||||
async fn run() {
|
async fn main(spawner: Spawner) {
|
||||||
let p = Peripherals::take().unwrap();
|
let p = Peripherals::take().unwrap();
|
||||||
|
|
||||||
let g = gpiote::initialize(p.GPIOTE, interrupt::take!(GPIOTE));
|
let g = gpiote::initialize(p.GPIOTE, interrupt::take!(GPIOTE));
|
||||||
@ -53,15 +51,3 @@ async fn run() {
|
|||||||
);
|
);
|
||||||
futures::join!(button1, button2, button3, button4);
|
futures::join!(button1, button2, button3, button4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
|
||||||
|
|
||||||
#[entry]
|
|
||||||
fn main() -> ! {
|
|
||||||
info!("Hello World!");
|
|
||||||
|
|
||||||
let executor = EXECUTOR.put(Executor::new());
|
|
||||||
executor.run(|spawner| {
|
|
||||||
unwrap!(spawner.spawn(run()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -66,13 +66,13 @@ use example_common::*;
|
|||||||
|
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
use embassy::executor::{task, Executor, InterruptExecutor};
|
use embassy::executor::{Executor, InterruptExecutor};
|
||||||
use embassy::interrupt::InterruptExt;
|
use embassy::interrupt::InterruptExt;
|
||||||
use embassy::time::{Duration, Instant, Timer};
|
use embassy::time::{Duration, Instant, Timer};
|
||||||
use embassy::util::Forever;
|
use embassy::util::Forever;
|
||||||
use embassy_nrf::{interrupt, peripherals, rtc};
|
use embassy_nrf::{interrupt, peripherals, rtc};
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run_high() {
|
async fn run_high() {
|
||||||
loop {
|
loop {
|
||||||
info!(" [high] tick!");
|
info!(" [high] tick!");
|
||||||
@ -80,7 +80,7 @@ async fn run_high() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run_med() {
|
async fn run_med() {
|
||||||
loop {
|
loop {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
@ -97,7 +97,7 @@ async fn run_med() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run_low() {
|
async fn run_low() {
|
||||||
loop {
|
loop {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
|
@ -7,23 +7,19 @@
|
|||||||
|
|
||||||
#[path = "../example_common.rs"]
|
#[path = "../example_common.rs"]
|
||||||
mod example_common;
|
mod example_common;
|
||||||
use core::future::pending;
|
|
||||||
|
|
||||||
use example_common::*;
|
use example_common::*;
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
use core::future::pending;
|
||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
|
use embassy::executor::Spawner;
|
||||||
use embassy::executor::{task, Executor};
|
|
||||||
use embassy::util::Forever;
|
|
||||||
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
|
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
|
||||||
use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity};
|
use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity};
|
||||||
use embassy_nrf::ppi::Ppi;
|
use embassy_nrf::ppi::Ppi;
|
||||||
use embassy_nrf::{interrupt, Peripherals};
|
use embassy_nrf::{interrupt, Peripherals};
|
||||||
use gpiote::{OutputChannel, OutputChannelPolarity};
|
use gpiote::{OutputChannel, OutputChannelPolarity};
|
||||||
|
|
||||||
#[task]
|
#[embassy::main]
|
||||||
async fn run() {
|
async fn main(spawner: Spawner) {
|
||||||
let p = Peripherals::take().unwrap();
|
let p = Peripherals::take().unwrap();
|
||||||
let g = gpiote::initialize(p.GPIOTE, interrupt::take!(GPIOTE));
|
let g = gpiote::initialize(p.GPIOTE, interrupt::take!(GPIOTE));
|
||||||
|
|
||||||
@ -94,18 +90,7 @@ async fn run() {
|
|||||||
info!("Press button 2 to turn on LED 1");
|
info!("Press button 2 to turn on LED 1");
|
||||||
info!("Press button 3 to turn off LED 1");
|
info!("Press button 3 to turn off LED 1");
|
||||||
info!("Press button 4 to toggle LEDs 1 and 2");
|
info!("Press button 4 to toggle LEDs 1 and 2");
|
||||||
|
|
||||||
// Block forever so the above drivers don't get dropped
|
// Block forever so the above drivers don't get dropped
|
||||||
pending::<()>().await;
|
pending::<()>().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
|
||||||
|
|
||||||
#[entry]
|
|
||||||
fn main() -> ! {
|
|
||||||
info!("Hello World!");
|
|
||||||
|
|
||||||
let executor = EXECUTOR.put(Executor::new());
|
|
||||||
executor.run(|spawner| {
|
|
||||||
unwrap!(spawner.spawn(run()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -8,11 +8,9 @@
|
|||||||
#[path = "../example_common.rs"]
|
#[path = "../example_common.rs"]
|
||||||
mod example_common;
|
mod example_common;
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
|
||||||
use defmt::{assert_eq, panic};
|
use defmt::{assert_eq, panic};
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::Spawner;
|
||||||
use embassy::traits::flash::Flash;
|
use embassy::traits::flash::Flash;
|
||||||
use embassy::util::Forever;
|
|
||||||
use embassy_nrf::Peripherals;
|
use embassy_nrf::Peripherals;
|
||||||
use embassy_nrf::{interrupt, qspi};
|
use embassy_nrf::{interrupt, qspi};
|
||||||
use example_common::*;
|
use example_common::*;
|
||||||
@ -25,8 +23,8 @@ const PAGE_SIZE: usize = 4096;
|
|||||||
#[repr(C, align(4))]
|
#[repr(C, align(4))]
|
||||||
struct AlignedBuf([u8; 4096]);
|
struct AlignedBuf([u8; 4096]);
|
||||||
|
|
||||||
#[task]
|
#[embassy::main]
|
||||||
async fn run() {
|
async fn main(spawner: Spawner) {
|
||||||
let p = Peripherals::take().unwrap();
|
let p = Peripherals::take().unwrap();
|
||||||
|
|
||||||
let csn = p.P0_17;
|
let csn = p.P0_17;
|
||||||
@ -96,15 +94,3 @@ async fn run() {
|
|||||||
|
|
||||||
info!("done!")
|
info!("done!")
|
||||||
}
|
}
|
||||||
|
|
||||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
|
||||||
|
|
||||||
#[entry]
|
|
||||||
fn main() -> ! {
|
|
||||||
info!("Hello World!");
|
|
||||||
|
|
||||||
let executor = EXECUTOR.put(Executor::new());
|
|
||||||
executor.run(|spawner| {
|
|
||||||
unwrap!(spawner.spawn(run()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -8,21 +8,19 @@
|
|||||||
#[path = "../example_common.rs"]
|
#[path = "../example_common.rs"]
|
||||||
mod example_common;
|
mod example_common;
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
|
||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::Spawner;
|
||||||
use embassy::util::Forever;
|
|
||||||
use embassy::util::Steal;
|
use embassy::util::Steal;
|
||||||
use embassy_nrf::gpio::{Level, Output, OutputDrive};
|
use embassy_nrf::gpio::{Level, Output, OutputDrive};
|
||||||
use embassy_nrf::{interrupt, rtc, spim};
|
use embassy_nrf::Peripherals;
|
||||||
use embassy_nrf::{peripherals, Peripherals};
|
use embassy_nrf::{interrupt, spim};
|
||||||
use embassy_traits::spi::FullDuplex;
|
use embassy_traits::spi::FullDuplex;
|
||||||
use embedded_hal::digital::v2::*;
|
use embedded_hal::digital::v2::*;
|
||||||
use example_common::*;
|
use example_common::*;
|
||||||
use futures::pin_mut;
|
use futures::pin_mut;
|
||||||
|
|
||||||
#[task]
|
#[embassy::main]
|
||||||
async fn run() {
|
async fn main(spawner: Spawner) {
|
||||||
info!("running!");
|
info!("running!");
|
||||||
|
|
||||||
let p = unsafe { Peripherals::steal() };
|
let p = unsafe { Peripherals::steal() };
|
||||||
@ -84,29 +82,3 @@ async fn run() {
|
|||||||
|
|
||||||
info!("erevid: {=[?]}", rx);
|
info!("erevid: {=[?]}", rx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RTC: Forever<rtc::RTC<peripherals::RTC1>> = Forever::new();
|
|
||||||
static ALARM: Forever<rtc::Alarm<peripherals::RTC1>> = Forever::new();
|
|
||||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
|
||||||
|
|
||||||
#[entry]
|
|
||||||
fn main() -> ! {
|
|
||||||
info!("Hello World!");
|
|
||||||
|
|
||||||
let p = unwrap!(embassy_nrf::Peripherals::take());
|
|
||||||
|
|
||||||
unsafe { embassy_nrf::system::configure(Default::default()) };
|
|
||||||
let rtc = RTC.put(rtc::RTC::new(p.RTC1, interrupt::take!(RTC1)));
|
|
||||||
rtc.start();
|
|
||||||
unsafe { embassy::time::set_clock(rtc) };
|
|
||||||
|
|
||||||
unsafe { embassy::time::set_clock(rtc) };
|
|
||||||
|
|
||||||
let alarm = ALARM.put(rtc.alarm0());
|
|
||||||
let executor = EXECUTOR.put(Executor::new());
|
|
||||||
executor.set_alarm(alarm);
|
|
||||||
|
|
||||||
executor.run(|spawner| {
|
|
||||||
unwrap!(spawner.spawn(run()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -9,14 +9,11 @@
|
|||||||
mod example_common;
|
mod example_common;
|
||||||
use example_common::*;
|
use example_common::*;
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
|
||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::Spawner;
|
||||||
use embassy::time::{Duration, Timer};
|
use embassy::time::{Duration, Timer};
|
||||||
use embassy::util::Forever;
|
|
||||||
use embassy_nrf::{interrupt, peripherals, rtc};
|
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run1() {
|
async fn run1() {
|
||||||
loop {
|
loop {
|
||||||
info!("BIG INFREQUENT TICK");
|
info!("BIG INFREQUENT TICK");
|
||||||
@ -24,7 +21,7 @@ async fn run1() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run2() {
|
async fn run2() {
|
||||||
loop {
|
loop {
|
||||||
info!("tick");
|
info!("tick");
|
||||||
@ -32,26 +29,8 @@ async fn run2() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static RTC: Forever<rtc::RTC<peripherals::RTC1>> = Forever::new();
|
#[embassy::main]
|
||||||
static ALARM: Forever<rtc::Alarm<peripherals::RTC1>> = Forever::new();
|
async fn main(spawner: Spawner) {
|
||||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
unwrap!(spawner.spawn(run1()));
|
||||||
|
unwrap!(spawner.spawn(run2()));
|
||||||
#[entry]
|
|
||||||
fn main() -> ! {
|
|
||||||
info!("Hello World!");
|
|
||||||
|
|
||||||
let p = unwrap!(embassy_nrf::Peripherals::take());
|
|
||||||
|
|
||||||
unsafe { embassy_nrf::system::configure(Default::default()) };
|
|
||||||
let rtc = RTC.put(rtc::RTC::new(p.RTC1, interrupt::take!(RTC1)));
|
|
||||||
rtc.start();
|
|
||||||
unsafe { embassy::time::set_clock(rtc) };
|
|
||||||
|
|
||||||
let alarm = ALARM.put(rtc.alarm0());
|
|
||||||
let executor = EXECUTOR.put(Executor::new());
|
|
||||||
executor.set_alarm(alarm);
|
|
||||||
executor.run(|spawner| {
|
|
||||||
unwrap!(spawner.spawn(run1()));
|
|
||||||
unwrap!(spawner.spawn(run2()));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
@ -9,17 +9,16 @@
|
|||||||
mod example_common;
|
mod example_common;
|
||||||
use example_common::*;
|
use example_common::*;
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
|
||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::Spawner;
|
||||||
use embassy::traits::uart::{Read, Write};
|
use embassy::traits::uart::{Read, Write};
|
||||||
use embassy::util::{Forever, Steal};
|
use embassy::util::Steal;
|
||||||
use embassy_nrf::gpio::NoPin;
|
use embassy_nrf::gpio::NoPin;
|
||||||
use embassy_nrf::{interrupt, peripherals, rtc, uarte, Peripherals};
|
use embassy_nrf::{interrupt, uarte, Peripherals};
|
||||||
use futures::pin_mut;
|
use futures::pin_mut;
|
||||||
|
|
||||||
#[task]
|
#[embassy::main]
|
||||||
async fn run() {
|
async fn main(spawner: Spawner) {
|
||||||
let p = unsafe { Peripherals::steal() };
|
let p = unsafe { Peripherals::steal() };
|
||||||
|
|
||||||
let mut config = uarte::Config::default();
|
let mut config = uarte::Config::default();
|
||||||
@ -74,27 +73,3 @@ async fn run() {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static RTC: Forever<rtc::RTC<peripherals::RTC1>> = Forever::new();
|
|
||||||
static ALARM: Forever<rtc::Alarm<peripherals::RTC1>> = Forever::new();
|
|
||||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
|
||||||
|
|
||||||
#[entry]
|
|
||||||
fn main() -> ! {
|
|
||||||
info!("Hello World!");
|
|
||||||
|
|
||||||
let p = unwrap!(embassy_nrf::Peripherals::take());
|
|
||||||
|
|
||||||
unsafe { embassy_nrf::system::configure(Default::default()) };
|
|
||||||
let rtc = RTC.put(rtc::RTC::new(p.RTC1, interrupt::take!(RTC1)));
|
|
||||||
rtc.start();
|
|
||||||
unsafe { embassy::time::set_clock(rtc) };
|
|
||||||
|
|
||||||
let alarm = ALARM.put(rtc.alarm0());
|
|
||||||
let executor = EXECUTOR.put(Executor::new());
|
|
||||||
executor.set_alarm(alarm);
|
|
||||||
|
|
||||||
executor.run(|spawner| {
|
|
||||||
unwrap!(spawner.spawn(run()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
mod serial_port;
|
mod serial_port;
|
||||||
|
|
||||||
use async_io::Async;
|
use async_io::Async;
|
||||||
use embassy::executor::task;
|
|
||||||
use embassy::io::AsyncBufReadExt;
|
use embassy::io::AsyncBufReadExt;
|
||||||
use embassy::util::Forever;
|
use embassy::util::Forever;
|
||||||
use embassy_std::Executor;
|
use embassy_std::Executor;
|
||||||
@ -15,7 +14,7 @@ use nix::sys::termios;
|
|||||||
|
|
||||||
use self::serial_port::SerialPort;
|
use self::serial_port::SerialPort;
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run() {
|
async fn run() {
|
||||||
// Open the serial port.
|
// Open the serial port.
|
||||||
let baudrate = termios::BaudRate::B115200;
|
let baudrate = termios::BaudRate::B115200;
|
||||||
|
@ -2,13 +2,12 @@
|
|||||||
#![feature(impl_trait_in_bindings)]
|
#![feature(impl_trait_in_bindings)]
|
||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
use embassy::executor::task;
|
|
||||||
use embassy::time::{Duration, Timer};
|
use embassy::time::{Duration, Timer};
|
||||||
use embassy::util::Forever;
|
use embassy::util::Forever;
|
||||||
use embassy_std::Executor;
|
use embassy_std::Executor;
|
||||||
use log::*;
|
use log::*;
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run() {
|
async fn run() {
|
||||||
loop {
|
loop {
|
||||||
info!("tick");
|
info!("tick");
|
||||||
|
@ -11,13 +11,13 @@ use example_common::{panic, *};
|
|||||||
|
|
||||||
use bxcan::filter::Mask32;
|
use bxcan::filter::Mask32;
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::Executor;
|
||||||
use embassy::util::Forever;
|
use embassy::util::Forever;
|
||||||
use embassy_stm32f4::{can, interrupt};
|
use embassy_stm32f4::{can, interrupt};
|
||||||
use stm32f4xx_hal::prelude::*;
|
use stm32f4xx_hal::prelude::*;
|
||||||
use stm32f4xx_hal::{can::Can, stm32};
|
use stm32f4xx_hal::{can::Can, stm32};
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) {
|
async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) {
|
||||||
let gpioa = dp.GPIOA.split();
|
let gpioa = dp.GPIOA.split();
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ mod example_common;
|
|||||||
use example_common::{panic, *};
|
use example_common::{panic, *};
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::Executor;
|
||||||
use embassy::traits::gpio::*;
|
use embassy::traits::gpio::*;
|
||||||
use embassy::util::Forever;
|
use embassy::util::Forever;
|
||||||
use embassy_stm32f4::exti::ExtiPin;
|
use embassy_stm32f4::exti::ExtiPin;
|
||||||
@ -19,7 +19,7 @@ use futures::pin_mut;
|
|||||||
use stm32f4xx_hal::prelude::*;
|
use stm32f4xx_hal::prelude::*;
|
||||||
use stm32f4xx_hal::stm32;
|
use stm32f4xx_hal::stm32;
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) {
|
async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) {
|
||||||
let gpioa = dp.GPIOA.split();
|
let gpioa = dp.GPIOA.split();
|
||||||
|
|
||||||
|
@ -11,12 +11,11 @@ use example_common::*;
|
|||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
use embassy;
|
use embassy;
|
||||||
use embassy::executor::Spawner;
|
use embassy::executor::Spawner;
|
||||||
use embassy::task;
|
|
||||||
use embassy::time::{Duration, Timer};
|
use embassy::time::{Duration, Timer};
|
||||||
use embassy_stm32f4;
|
use embassy_stm32f4;
|
||||||
use embassy_stm32f4::hal;
|
use embassy_stm32f4::hal;
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run1() {
|
async fn run1() {
|
||||||
loop {
|
loop {
|
||||||
info!("BIG INFREQUENT TICK");
|
info!("BIG INFREQUENT TICK");
|
||||||
@ -24,7 +23,7 @@ async fn run1() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run2() {
|
async fn run2() {
|
||||||
loop {
|
loop {
|
||||||
info!("tick");
|
info!("tick");
|
||||||
|
@ -11,7 +11,7 @@ use example_common::{panic, *};
|
|||||||
|
|
||||||
use cortex_m::singleton;
|
use cortex_m::singleton;
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::Executor;
|
||||||
use embassy::traits::uart::{Read, Write};
|
use embassy::traits::uart::{Read, Write};
|
||||||
use embassy::util::Forever;
|
use embassy::util::Forever;
|
||||||
use embassy_stm32f4::interrupt;
|
use embassy_stm32f4::interrupt;
|
||||||
@ -22,7 +22,7 @@ use stm32f4xx_hal::prelude::*;
|
|||||||
use stm32f4xx_hal::serial::config::Config;
|
use stm32f4xx_hal::serial::config::Config;
|
||||||
use stm32f4xx_hal::stm32;
|
use stm32f4xx_hal::stm32;
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) {
|
async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) {
|
||||||
dp.DBGMCU.cr.modify(|_, w| {
|
dp.DBGMCU.cr.modify(|_, w| {
|
||||||
w.dbg_sleep().set_bit();
|
w.dbg_sleep().set_bit();
|
||||||
|
@ -10,7 +10,7 @@ use example_common::*;
|
|||||||
|
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::Executor;
|
||||||
use embassy::interrupt::InterruptExt;
|
use embassy::interrupt::InterruptExt;
|
||||||
use embassy::io::{AsyncBufReadExt, AsyncWriteExt};
|
use embassy::io::{AsyncBufReadExt, AsyncWriteExt};
|
||||||
use embassy::time::{Duration, Timer};
|
use embassy::time::{Duration, Timer};
|
||||||
@ -25,7 +25,7 @@ use stm32f4xx_hal::prelude::*;
|
|||||||
use usb_device::bus::UsbBusAllocator;
|
use usb_device::bus::UsbBusAllocator;
|
||||||
use usb_device::prelude::*;
|
use usb_device::prelude::*;
|
||||||
|
|
||||||
#[task]
|
#[embassy::task]
|
||||||
async fn run1(bus: &'static mut UsbBusAllocator<UsbBus<USB>>) {
|
async fn run1(bus: &'static mut UsbBusAllocator<UsbBus<USB>>) {
|
||||||
info!("Async task");
|
info!("Async task");
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
pub use embassy_macros::{main, task};
|
|
||||||
|
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use core::ptr::NonNull;
|
use core::ptr::NonNull;
|
||||||
use core::{mem, ptr};
|
use core::{mem, ptr};
|
||||||
|
@ -60,7 +60,7 @@ impl Timer {
|
|||||||
/// use embassy::executor::task;
|
/// use embassy::executor::task;
|
||||||
/// use embassy::time::{Duration, Timer};
|
/// use embassy::time::{Duration, Timer};
|
||||||
///
|
///
|
||||||
/// #[task]
|
/// #[embassy::task]
|
||||||
/// async fn demo_sleep_seconds() {
|
/// async fn demo_sleep_seconds() {
|
||||||
/// // suspend this task for one second.
|
/// // suspend this task for one second.
|
||||||
/// Timer::after(Duration::from_secs(1)).await;
|
/// Timer::after(Duration::from_secs(1)).await;
|
||||||
@ -104,7 +104,7 @@ impl Future for Timer {
|
|||||||
/// use embassy::time::{Duration, Timer};
|
/// use embassy::time::{Duration, Timer};
|
||||||
/// # fn foo() {}
|
/// # fn foo() {}
|
||||||
///
|
///
|
||||||
/// #[task]
|
/// #[embassy::task]
|
||||||
/// async fn ticker_example_0() {
|
/// async fn ticker_example_0() {
|
||||||
/// loop {
|
/// loop {
|
||||||
/// foo();
|
/// foo();
|
||||||
@ -129,7 +129,7 @@ impl Future for Timer {
|
|||||||
/// use futures::StreamExt;
|
/// use futures::StreamExt;
|
||||||
/// # fn foo(){}
|
/// # fn foo(){}
|
||||||
///
|
///
|
||||||
/// #[task]
|
/// #[embassy::task]
|
||||||
/// async fn ticker_example_1() {
|
/// async fn ticker_example_1() {
|
||||||
/// let mut ticker = Ticker::every(Duration::from_secs(1));
|
/// let mut ticker = Ticker::every(Duration::from_secs(1));
|
||||||
/// loop {
|
/// loop {
|
||||||
|
@ -17,8 +17,8 @@ pub mod io;
|
|||||||
pub mod time;
|
pub mod time;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
|
||||||
|
pub use embassy_macros::*;
|
||||||
pub use embassy_traits as traits;
|
pub use embassy_traits as traits;
|
||||||
pub use executor::{main, task};
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
/// Implementation details for embassy macros. DO NOT USE.
|
/// 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::util::InterruptFuture;
|
||||||
/// use embassy::executor::task;
|
/// use embassy::executor::task;
|
||||||
/// use embassy_stm32f4::interrupt; // Adjust this to your MCU's embassy HAL.
|
/// use embassy_stm32f4::interrupt; // Adjust this to your MCU's embassy HAL.
|
||||||
/// #[task]
|
/// #[embassy::task]
|
||||||
/// async fn demo_interrupt_future() {
|
/// async fn demo_interrupt_future() {
|
||||||
/// // Using STM32f446 interrupt names, adjust this to your application as necessary.
|
/// // Using STM32f446 interrupt names, adjust this to your application as necessary.
|
||||||
/// // Wait for TIM2 to tick.
|
/// // Wait for TIM2 to tick.
|
||||||
|
Loading…
Reference in New Issue
Block a user