Remove HAL initialization from #[embassy::main] macro.

This commit is contained in:
Dario Nieuwenhuis 2022-08-17 18:49:55 +02:00
parent d881f3ad91
commit fc6e1e06b3
182 changed files with 454 additions and 423 deletions

View file

@ -65,7 +65,9 @@ async fn blink(pin: AnyPin) {
// Main is itself an async task as well.
#[embassy_executor::main]
async fn main(spawner: Spawner, p: Peripherals) {
async fn main(spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
// Spawned tasks run in the background, concurrently.
spawner.spawn(blink(p.P0_13.degrade())).unwrap();

View file

@ -7,7 +7,6 @@ use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::gpio::{Level, Output, OutputDrive};
use embassy_nrf::peripherals::P0_13;
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _}; // global logger
#[embassy_executor::task]
@ -21,7 +20,9 @@ async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) {
}
#[embassy_executor::main]
async fn main(spawner: Spawner, p: Peripherals) {
async fn main(spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
unwrap!(spawner.spawn(blinker(led, Duration::from_millis(300))));
}

View file

@ -5,11 +5,11 @@
use embassy_executor::executor::Spawner;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_s: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh);
let mut button = ExtiInput::new(Input::new(p.PC13, Pull::Up), p.EXTI13);

View file

@ -6,10 +6,11 @@ use cortex_m::peripheral::NVIC;
use embassy_hal_common::Peripheral;
pub use embassy_macros::cortex_m_interrupt_take as take;
/// Do not use. Used for macros only. Not covered by semver guarantees.
/// Do not use. Used for macros and HALs only. Not covered by semver guarantees.
#[doc(hidden)]
pub mod _export {
pub use atomic_polyfill as atomic;
pub use embassy_macros::{cortex_m_interrupt as interrupt, cortex_m_interrupt_declare as declare};
}
/// Implementation detail, do not use outside embassy crates.

View file

@ -13,8 +13,5 @@ proc-macro2 = "1.0.29"
proc-macro = true
[features]
nrf = []
stm32 = []
rp = []
std = []
wasm = []

View file

@ -5,11 +5,7 @@ use quote::quote;
use crate::util::ctxt::Ctxt;
#[derive(Debug, FromMeta)]
struct Args {
#[allow(unused)]
#[darling(default)]
config: Option<syn::LitStr>,
}
struct Args {}
pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, TokenStream> {
#[allow(unused_variables)]
@ -20,26 +16,14 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke
let ctxt = Ctxt::new();
if f.sig.asyncness.is_none() {
ctxt.error_spanned_by(&f.sig, "task functions must be async");
ctxt.error_spanned_by(&f.sig, "main function must be async");
}
if !f.sig.generics.params.is_empty() {
ctxt.error_spanned_by(&f.sig, "task functions must not be generic");
ctxt.error_spanned_by(&f.sig, "main function must not be generic");
}
#[cfg(feature = "stm32")]
let hal = Some(quote!(::embassy_stm32));
#[cfg(feature = "nrf")]
let hal = Some(quote!(::embassy_nrf));
#[cfg(feature = "rp")]
let hal = Some(quote!(::embassy_rp));
#[cfg(not(any(feature = "stm32", feature = "nrf", feature = "rp")))]
let hal: Option<TokenStream> = None;
if hal.is_some() && fargs.len() != 2 {
ctxt.error_spanned_by(&f.sig, "main function must have 2 arguments");
}
if hal.is_none() && fargs.len() != 1 {
ctxt.error_spanned_by(&f.sig, "main function must have 1 argument");
if fargs.len() != 1 {
ctxt.error_spanned_by(&f.sig, "main function must have 1 argument: the spawner.");
}
ctxt.check()?;
@ -74,35 +58,15 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke
};
#[cfg(all(not(feature = "std"), not(feature = "wasm")))]
let main = {
let config = args.config.map(|s| s.parse::<syn::Expr>().unwrap()).unwrap_or_else(|| {
syn::Expr::Verbatim(quote! {
Default::default()
let main = quote! {
#[cortex_m_rt::entry]
fn main() -> ! {
let mut executor = ::embassy_executor::executor::Executor::new();
let executor = unsafe { __make_static(&mut executor) };
executor.run(|spawner| {
spawner.must_spawn(__embassy_main(spawner));
})
});
let (hal_setup, peris_arg) = match hal {
Some(hal) => (
quote!(
let p = #hal::init(#config);
),
quote!(p),
),
None => (quote!(), quote!()),
};
quote! {
#[cortex_m_rt::entry]
fn main() -> ! {
#hal_setup
let mut executor = ::embassy_executor::executor::Executor::new();
let executor = unsafe { __make_static(&mut executor) };
executor.run(|spawner| {
spawner.must_spawn(__embassy_main(spawner, #peris_arg));
})
}
}
};

View file

@ -67,7 +67,6 @@ _gpio-p1 = []
embassy-executor = { version = "0.1.0", path = "../embassy-executor", optional = true }
embassy-util = { version = "0.1.0", path = "../embassy-util" }
embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]}
embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["nrf"]}
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" }
embassy-usb = {version = "0.1.0", path = "../embassy-usb", optional=true }

View file

@ -197,7 +197,7 @@ impl_saadc_input!(P0_04, ANALOGINPUT2);
impl_saadc_input!(P0_05, ANALOGINPUT3);
pub mod irqs {
use embassy_macros::cortex_m_interrupt_declare as declare;
use embassy_cortex_m::interrupt::_export::declare;
use crate::pac::Interrupt as InterruptEnum;

View file

@ -218,7 +218,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6);
impl_saadc_input!(P0_31, ANALOGINPUT7);
pub mod irqs {
use embassy_macros::cortex_m_interrupt_declare as declare;
use embassy_cortex_m::interrupt::_export::declare;
use crate::pac::Interrupt as InterruptEnum;

View file

@ -219,7 +219,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6);
impl_saadc_input!(P0_31, ANALOGINPUT7);
pub mod irqs {
use embassy_macros::cortex_m_interrupt_declare as declare;
use embassy_cortex_m::interrupt::_export::declare;
use crate::pac::Interrupt as InterruptEnum;

View file

@ -211,7 +211,7 @@ impl_ppi_channel!(PPI_CH30, 30 => static);
impl_ppi_channel!(PPI_CH31, 31 => static);
pub mod irqs {
use embassy_macros::cortex_m_interrupt_declare as declare;
use embassy_cortex_m::interrupt::_export::declare;
use crate::pac::Interrupt as InterruptEnum;

View file

@ -235,7 +235,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6);
impl_saadc_input!(P0_31, ANALOGINPUT7);
pub mod irqs {
use embassy_macros::cortex_m_interrupt_declare as declare;
use embassy_cortex_m::interrupt::_export::declare;
use crate::pac::Interrupt as InterruptEnum;

View file

@ -278,7 +278,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6);
impl_saadc_input!(P0_31, ANALOGINPUT7);
pub mod irqs {
use embassy_macros::cortex_m_interrupt_declare as declare;
use embassy_cortex_m::interrupt::_export::declare;
use crate::pac::Interrupt as InterruptEnum;

View file

@ -283,7 +283,7 @@ impl_saadc_input!(P0_30, ANALOGINPUT6);
impl_saadc_input!(P0_31, ANALOGINPUT7);
pub mod irqs {
use embassy_macros::cortex_m_interrupt_declare as declare;
use embassy_cortex_m::interrupt::_export::declare;
use crate::pac::Interrupt as InterruptEnum;

View file

@ -468,7 +468,7 @@ impl_saadc_input!(P0_19, ANALOGINPUT6);
impl_saadc_input!(P0_20, ANALOGINPUT7);
pub mod irqs {
use embassy_macros::cortex_m_interrupt_declare as declare;
use embassy_cortex_m::interrupt::_export::declare;
use crate::pac::Interrupt as InterruptEnum;

View file

@ -328,7 +328,7 @@ impl_ppi_channel!(PPI_CH30, 30 => configurable);
impl_ppi_channel!(PPI_CH31, 31 => configurable);
pub mod irqs {
use embassy_macros::cortex_m_interrupt_declare as declare;
use embassy_cortex_m::interrupt::_export::declare;
use crate::pac::Interrupt as InterruptEnum;

View file

@ -346,7 +346,7 @@ impl_saadc_input!(P0_19, ANALOGINPUT6);
impl_saadc_input!(P0_20, ANALOGINPUT7);
pub mod irqs {
use embassy_macros::cortex_m_interrupt_declare as declare;
use embassy_cortex_m::interrupt::_export::declare;
use crate::pac::Interrupt as InterruptEnum;

View file

@ -135,8 +135,8 @@ pub use chip::pac;
pub(crate) use chip::pac;
pub use chip::{peripherals, Peripherals};
pub use embassy_cortex_m::executor;
pub use embassy_cortex_m::interrupt::_export::interrupt;
pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
pub use embassy_macros::cortex_m_interrupt as interrupt;
pub mod config {
//! Configuration options used when initializing the HAL.

View file

@ -32,7 +32,6 @@ embassy-executor = { version = "0.1.0", path = "../embassy-executor", features =
embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-3"]}
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" }
embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["rp"]}
atomic-polyfill = "1.0.1"
defmt = { version = "0.3", optional = true }
log = { version = "0.4.14", optional = true }

View file

@ -4,8 +4,8 @@
//! nrf_softdevice::interrupt. Intended for switching between the two at compile-time.
// Re-exports
use embassy_cortex_m::interrupt::_export::declare;
pub use embassy_cortex_m::interrupt::*;
use embassy_macros::cortex_m_interrupt_declare as declare;
use crate::pac::Interrupt as InterruptEnum;
declare!(TIMER_IRQ_0);

View file

@ -17,8 +17,8 @@ mod reset;
// Reexports
pub use embassy_cortex_m::executor;
pub use embassy_cortex_m::interrupt::_export::interrupt;
pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
pub use embassy_macros::cortex_m_interrupt as interrupt;
#[cfg(feature = "unstable-pac")]
pub use rp2040_pac2 as pac;
#[cfg(not(feature = "unstable-pac"))]

View file

@ -34,7 +34,6 @@ flavors = [
embassy-util = { version = "0.1.0", path = "../embassy-util" }
embassy-executor = { version = "0.1.0", path = "../embassy-executor" }
embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-4"]}
embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["stm32"] }
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" }
embassy-net = { version = "0.1.0", path = "../embassy-net", optional = true }

View file

@ -96,7 +96,7 @@ fn main() {
g.extend(quote! {
pub mod interrupt {
use crate::pac::Interrupt as InterruptEnum;
use embassy_macros::cortex_m_interrupt_declare as declare;
use embassy_cortex_m::interrupt::_export::declare;
#(
declare!(#irqs);
)*

View file

@ -75,8 +75,8 @@ pub(crate) mod _generated {
// Reexports
pub use _generated::{peripherals, Peripherals};
pub use embassy_cortex_m::executor;
pub use embassy_cortex_m::interrupt::_export::interrupt;
pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
pub use embassy_macros::cortex_m_interrupt as interrupt;
#[cfg(feature = "unstable-pac")]
pub use stm32_metapac as pac;
#[cfg(not(feature = "unstable-pac"))]

View file

@ -6,15 +6,16 @@
use embassy_boot_nrf::FirmwareUpdater;
use embassy_embedded_hal::adapter::BlockingAsync;
use embassy_executor::executor::Spawner;
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
use embassy_nrf::nvmc::Nvmc;
use embassy_nrf::Peripherals;
use panic_reset as _;
static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let mut button = Input::new(p.P0_11, Pull::Up);
let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
//let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard);

View file

@ -4,13 +4,14 @@
#![feature(generic_associated_types)]
#![feature(type_alias_impl_trait)]
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::gpio::{Level, Output, OutputDrive};
use embassy_nrf::Peripherals;
use panic_reset as _;
#[embassy_executor::main]
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
//let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard);

View file

@ -6,16 +6,17 @@
use defmt_rtt::*;
use embassy_boot_stm32::FirmwareUpdater;
use embassy_embedded_hal::adapter::BlockingAsync;
use embassy_executor::executor::Spawner;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::flash::Flash;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::Peripherals;
use panic_reset as _;
static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let flash = Flash::unlock(p.FLASH);
let mut flash = BlockingAsync::new(flash);

View file

@ -7,11 +7,11 @@ use defmt_rtt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use panic_reset as _;
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let mut led = Output::new(p.PA5, Level::High, Speed::Low);
loop {

View file

@ -6,16 +6,17 @@
use defmt_rtt::*;
use embassy_boot_stm32::FirmwareUpdater;
use embassy_embedded_hal::adapter::BlockingAsync;
use embassy_executor::executor::Spawner;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::flash::Flash;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::Peripherals;
use panic_reset as _;
static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let flash = Flash::unlock(p.FLASH);
let mut flash = BlockingAsync::new(flash);

View file

@ -7,11 +7,11 @@ use defmt_rtt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use panic_reset as _;
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
Timer::after(Duration::from_millis(300)).await;
let mut led = Output::new(p.PB7, Level::High, Speed::Low);
led.set_high();

View file

@ -6,16 +6,17 @@
use defmt_rtt::*;
use embassy_boot_stm32::FirmwareUpdater;
use embassy_embedded_hal::adapter::BlockingAsync;
use embassy_executor::executor::Spawner;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::flash::Flash;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::Peripherals;
use panic_reset as _;
static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let flash = Flash::unlock(p.FLASH);
let mut flash = BlockingAsync::new(flash);

View file

@ -7,11 +7,11 @@ use defmt_rtt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use panic_reset as _;
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
Timer::after(Duration::from_millis(300)).await;
let mut led = Output::new(p.PB14, Level::High, Speed::Low);
led.set_high();

View file

@ -6,17 +6,18 @@
use defmt_rtt::*;
use embassy_boot_stm32::FirmwareUpdater;
use embassy_embedded_hal::adapter::BlockingAsync;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::flash::Flash;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::Peripherals;
use panic_reset as _;
static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let flash = Flash::unlock(p.FLASH);
let mut flash = BlockingAsync::new(flash);

View file

@ -7,11 +7,11 @@ use defmt_rtt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use panic_reset as _;
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let mut led = Output::new(p.PB6, Level::High, Speed::Low);
loop {

View file

@ -6,17 +6,18 @@
use defmt_rtt::*;
use embassy_boot_stm32::FirmwareUpdater;
use embassy_embedded_hal::adapter::BlockingAsync;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::flash::Flash;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::Peripherals;
use panic_reset as _;
static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let flash = Flash::unlock(p.FLASH);
let mut flash = BlockingAsync::new(flash);

View file

@ -7,11 +7,11 @@ use defmt_rtt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use panic_reset as _;
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let mut led = Output::new(p.PB6, Level::High, Speed::Low);
loop {

View file

@ -6,16 +6,17 @@
use defmt_rtt::*;
use embassy_boot_stm32::FirmwareUpdater;
use embassy_embedded_hal::adapter::BlockingAsync;
use embassy_executor::executor::Spawner;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::flash::Flash;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::Peripherals;
use panic_reset as _;
static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let flash = Flash::unlock(p.FLASH);
let mut flash = BlockingAsync::new(flash);

View file

@ -7,11 +7,11 @@ use defmt_rtt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use panic_reset as _;
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let mut led = Output::new(p.PA5, Level::High, Speed::Low);
loop {

View file

@ -6,16 +6,17 @@
use defmt_rtt::*;
use embassy_boot_stm32::FirmwareUpdater;
use embassy_embedded_hal::adapter::BlockingAsync;
use embassy_executor::executor::Spawner;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::flash::Flash;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::Peripherals;
use panic_reset as _;
static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
async fn main(_s: embassy_executor::executor::Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let flash = Flash::unlock(p.FLASH);
let mut flash = BlockingAsync::new(flash);

View file

@ -7,11 +7,11 @@ use defmt_rtt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use panic_reset as _;
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let mut led = Output::new(p.PB15, Level::High, Speed::Low);
loop {

View file

@ -4,12 +4,13 @@
use defmt::info;
use embassy_executor::executor::Spawner;
use embassy_nrf::interrupt;
use embassy_nrf::timer::Timer;
use embassy_nrf::{interrupt, Peripherals};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let mut t = Timer::new_awaitable(p.TIMER0, interrupt::take!(TIMER0));
// default frequency is 1MHz, so this triggers every second
t.cc(0).write(1_000_000);

View file

@ -5,11 +5,11 @@
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::gpio::{Level, Output, OutputDrive};
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
loop {

View file

@ -5,13 +5,14 @@
use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_nrf::buffered_uarte::{BufferedUarte, State};
use embassy_nrf::{interrupt, uarte, Peripherals};
use embassy_nrf::{interrupt, uarte};
use embedded_io::asynch::{BufRead, Write};
use futures::pin_mut;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let mut config = uarte::Config::default();
config.parity = uarte::Parity::EXCLUDED;
config.baudrate = uarte::Baudrate::BAUD115200;

View file

@ -6,7 +6,6 @@ use defmt::unwrap;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::gpio::{Level, Output, OutputDrive};
use embassy_nrf::Peripherals;
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::channel::mpmc::Channel;
use {defmt_rtt as _, panic_probe as _};
@ -29,7 +28,8 @@ async fn my_task() {
}
#[embassy_executor::main]
async fn main(spawner: Spawner, p: Peripherals) {
async fn main(spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
unwrap!(spawner.spawn(my_task()));

View file

@ -6,7 +6,6 @@ use defmt::unwrap;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin};
use embassy_nrf::Peripherals;
use embassy_util::blocking_mutex::raw::NoopRawMutex;
use embassy_util::channel::mpmc::{Channel, Receiver, Sender};
use embassy_util::Forever;
@ -42,7 +41,8 @@ async fn recv_task(led: AnyPin, receiver: Receiver<'static, NoopRawMutex, LedSta
}
#[embassy_executor::main]
async fn main(spawner: Spawner, p: Peripherals) {
async fn main(spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let channel = CHANNEL.put(Channel::new());
unwrap!(spawner.spawn(send_task(channel.sender())));

View file

@ -7,7 +7,6 @@ use core::task::Poll;
use defmt::{info, unwrap};
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Instant, Timer};
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
@ -35,7 +34,8 @@ async fn run3() {
}
#[embassy_executor::main]
async fn main(spawner: Spawner, _p: Peripherals) {
async fn main(spawner: Spawner) {
let _p = embassy_nrf::init(Default::default());
unwrap!(spawner.spawn(run1()));
unwrap!(spawner.spawn(run2()));
unwrap!(spawner.spawn(run3()));

View file

@ -6,11 +6,11 @@ use defmt::info;
use embassy_executor::executor::Spawner;
use embassy_nrf::gpio::{Input, Pull};
use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity};
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
info!("Starting!");
let ch1 = InputChannel::new(

View file

@ -5,7 +5,6 @@
use defmt::{info, unwrap};
use embassy_executor::executor::Spawner;
use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull};
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task(pool_size = 4)]
@ -19,7 +18,8 @@ async fn button_task(n: usize, mut pin: Input<'static, AnyPin>) {
}
#[embassy_executor::main]
async fn main(spawner: Spawner, p: Peripherals) {
async fn main(spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
info!("Starting!");
let btn1 = Input::new(p.P0_11.degrade(), Pull::Up);

View file

@ -5,7 +5,6 @@
use defmt::{info, unwrap};
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::Peripherals;
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::mutex::Mutex;
use {defmt_rtt as _, panic_probe as _};
@ -30,7 +29,8 @@ async fn my_task() {
}
#[embassy_executor::main]
async fn main(spawner: Spawner, _p: Peripherals) {
async fn main(spawner: Spawner) {
let _p = embassy_nrf::init(Default::default());
unwrap!(spawner.spawn(my_task()));
loop {

View file

@ -6,12 +6,12 @@ use defmt::{info, unwrap};
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::nvmc::Nvmc;
use embassy_nrf::Peripherals;
use embedded_storage::nor_flash::{NorFlash, ReadNorFlash};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
info!("Hello NVMC!");
// probe-run breaks without this, I'm not sure why.

View file

@ -9,12 +9,12 @@ use embassy_executor::executor::Spawner;
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity};
use embassy_nrf::ppi::Ppi;
use embassy_nrf::Peripherals;
use gpiote::{OutputChannel, OutputChannelPolarity};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
info!("Starting!");
let button1 = InputChannel::new(

View file

@ -20,7 +20,8 @@ enum Message {
}
#[embassy_executor::main]
async fn main(spawner: Spawner, _p: embassy_nrf::Peripherals) {
async fn main(spawner: Spawner) {
let _p = embassy_nrf::init(Default::default());
defmt::info!("Hello World!");
// It's good to set up the subscribers before publishing anything.

View file

@ -6,7 +6,6 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::pwm::{Prescaler, SimplePwm};
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _};
// for i in range(1024): print(int((math.sin(i/512*math.pi)*0.4+0.5)**2*32767), ', ', end='')
@ -71,7 +70,8 @@ static DUTY: [u16; 1024] = [
];
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let mut pwm = SimplePwm::new_4ch(p.PWM0, p.P0_13, p.P0_14, p.P0_16, p.P0_15);
pwm.set_prescaler(Prescaler::Div1);
pwm.set_max_duty(32767);

View file

@ -8,11 +8,11 @@ use embassy_executor::time::{Duration, Timer};
use embassy_nrf::pwm::{
Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, StartSequence,
};
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let seq_words_0: [u16; 5] = [1000, 250, 100, 50, 0];
let seq_words_1: [u16; 4] = [50, 100, 250, 1000];

View file

@ -6,11 +6,11 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer};
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let seq_words: [u16; 5] = [1000, 250, 100, 50, 0];
let mut config = Config::default();

View file

@ -10,11 +10,11 @@ use embassy_nrf::gpio::{Input, Pull};
use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity};
use embassy_nrf::ppi::Ppi;
use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer};
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let seq_words: [u16; 5] = [1000, 250, 100, 50, 0];
let mut config = Config::default();

View file

@ -8,7 +8,6 @@ use embassy_executor::time::{Duration, Timer};
use embassy_nrf::pwm::{
Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, SingleSequencer,
};
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _};
// WS2812B LED light demonstration. Drives just one light.
@ -27,7 +26,8 @@ const RES: u16 = 0x8000;
// Provides data to a WS2812b (Neopixel) LED and makes it go blue. The data
// line is assumed to be P1_05.
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let mut config = Config::default();
config.sequence_load = SequenceLoad::Common;
config.prescaler = Prescaler::Div1;

View file

@ -6,11 +6,11 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::pwm::{Prescaler, SimplePwm};
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let mut pwm = SimplePwm::new_1ch(p.PWM0, p.P0_05);
// sg90 microervo requires 50hz or 20ms period
// set_period can only set down to 125khz so we cant use it directly

View file

@ -4,12 +4,13 @@
use defmt::info;
use embassy_executor::executor::Spawner;
use embassy_nrf::interrupt;
use embassy_nrf::qdec::{self, Qdec};
use embassy_nrf::{interrupt, Peripherals};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let irq = interrupt::take!(QDEC);
let config = qdec::Config::default();
let mut rotary_enc = Qdec::new(p.QDEC, irq, p.P0_31, p.P0_30, config);

View file

@ -4,7 +4,7 @@
use defmt::{assert_eq, info, unwrap};
use embassy_executor::executor::Spawner;
use embassy_nrf::{interrupt, qspi, Peripherals};
use embassy_nrf::{interrupt, qspi};
use {defmt_rtt as _, panic_probe as _};
const PAGE_SIZE: usize = 4096;
@ -15,7 +15,8 @@ const PAGE_SIZE: usize = 4096;
struct AlignedBuf([u8; 4096]);
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
// Config for the MX25R64 present in the nRF52840 DK
let mut config = qspi::Config::default();
config.read_opcode = qspi::ReadOpcode::READ4IO;

View file

@ -7,7 +7,7 @@ use core::mem;
use defmt::{info, unwrap};
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::{interrupt, qspi, Peripherals};
use embassy_nrf::{interrupt, qspi};
use {defmt_rtt as _, panic_probe as _};
// Workaround for alignment requirements.
@ -16,7 +16,8 @@ use {defmt_rtt as _, panic_probe as _};
struct AlignedBuf([u8; 64]);
#[embassy_executor::main]
async fn main(_spawner: Spawner, mut p: Peripherals) {
async fn main(_p: Spawner) {
let mut p = embassy_nrf::init(Default::default());
let mut irq = interrupt::take!(QSPI);
loop {

View file

@ -3,13 +3,14 @@
#![feature(type_alias_impl_trait)]
use embassy_executor::executor::Spawner;
use embassy_nrf::interrupt;
use embassy_nrf::rng::Rng;
use embassy_nrf::{interrupt, Peripherals};
use rand::Rng as _;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let mut rng = Rng::new(p.RNG, interrupt::take!(RNG));
// Async API

View file

@ -5,12 +5,13 @@
use defmt::info;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::interrupt;
use embassy_nrf::saadc::{ChannelConfig, Config, Saadc};
use embassy_nrf::{interrupt, Peripherals};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, mut p: Peripherals) {
async fn main(_p: Spawner) {
let mut p = embassy_nrf::init(Default::default());
let config = Config::default();
let channel_config = ChannelConfig::single_ended(&mut p.P0_02);
let mut saadc = Saadc::new(p.SAADC, interrupt::take!(SAADC), config, [channel_config]);

View file

@ -5,15 +5,16 @@
use defmt::info;
use embassy_executor::executor::Spawner;
use embassy_executor::time::Duration;
use embassy_nrf::interrupt;
use embassy_nrf::saadc::{ChannelConfig, Config, Saadc, SamplerState};
use embassy_nrf::timer::Frequency;
use embassy_nrf::{interrupt, Peripherals};
use {defmt_rtt as _, panic_probe as _};
// Demonstrates both continuous sampling and scanning multiple channels driven by a PPI linked timer
#[embassy_executor::main]
async fn main(_spawner: Spawner, mut p: Peripherals) {
async fn main(_p: Spawner) {
let mut p = embassy_nrf::init(Default::default());
let config = Config::default();
let channel_1_config = ChannelConfig::single_ended(&mut p.P0_02);
let channel_2_config = ChannelConfig::single_ended(&mut p.P0_03);

View file

@ -5,7 +5,6 @@
use defmt::{info, unwrap};
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task(pool_size = 2)]
@ -16,7 +15,8 @@ async fn my_task(spawner: Spawner, n: u32) {
}
#[embassy_executor::main]
async fn main(spawner: Spawner, _p: Peripherals) {
async fn main(spawner: Spawner) {
let _p = embassy_nrf::init(Default::default());
info!("Hello World!");
unwrap!(spawner.spawn(my_task(spawner, 0)));
}

View file

@ -5,7 +5,6 @@
use defmt::{info, unwrap};
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task(pool_size = 2)]
@ -16,7 +15,8 @@ async fn my_task(n: u32) {
}
#[embassy_executor::main]
async fn main(spawner: Spawner, _p: Peripherals) {
async fn main(spawner: Spawner) {
let _p = embassy_nrf::init(Default::default());
info!("Hello World!");
unwrap!(spawner.spawn(my_task(0)));
}

View file

@ -5,11 +5,12 @@
use defmt::{info, unwrap};
use embassy_executor::executor::Spawner;
use embassy_nrf::gpio::{Level, Output, OutputDrive};
use embassy_nrf::{interrupt, spim, Peripherals};
use embassy_nrf::{interrupt, spim};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
info!("running!");
let mut config = spim::Config::default();

View file

@ -5,12 +5,13 @@
use defmt::info;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::interrupt;
use embassy_nrf::temp::Temp;
use embassy_nrf::{interrupt, Peripherals};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let irq = interrupt::take!(TEMP);
let mut temp = Temp::new(p.TEMP, irq);

View file

@ -5,7 +5,6 @@
use defmt::{info, unwrap};
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
@ -25,7 +24,8 @@ async fn run2() {
}
#[embassy_executor::main]
async fn main(spawner: Spawner, _p: Peripherals) {
async fn main(spawner: Spawner) {
let _p = embassy_nrf::init(Default::default());
unwrap!(spawner.spawn(run1()));
unwrap!(spawner.spawn(run2()));
}

View file

@ -8,14 +8,15 @@
use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_nrf::interrupt;
use embassy_nrf::twim::{self, Twim};
use embassy_nrf::{interrupt, Peripherals};
use {defmt_rtt as _, panic_probe as _};
const ADDRESS: u8 = 0x50;
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
info!("Initializing TWI...");
let config = twim::Config::default();
let irq = interrupt::take!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0);

View file

@ -13,14 +13,15 @@ use core::mem;
use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::interrupt;
use embassy_nrf::twim::{self, Twim};
use embassy_nrf::{interrupt, Peripherals};
use {defmt_rtt as _, panic_probe as _};
const ADDRESS: u8 = 0x50;
#[embassy_executor::main]
async fn main(_spawner: Spawner, mut p: Peripherals) {
async fn main(_p: Spawner) {
let mut p = embassy_nrf::init(Default::default());
info!("Started!");
let mut irq = interrupt::take!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0);

View file

@ -4,11 +4,12 @@
use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_nrf::{interrupt, uarte, Peripherals};
use embassy_nrf::{interrupt, uarte};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let mut config = uarte::Config::default();
config.parity = uarte::Parity::EXCLUDED;
config.baudrate = uarte::Baudrate::BAUD115200;

View file

@ -4,11 +4,12 @@
use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_nrf::{interrupt, uarte, Peripherals};
use embassy_nrf::{interrupt, uarte};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let mut config = uarte::Config::default();
config.parity = uarte::Parity::EXCLUDED;
config.baudrate = uarte::Baudrate::BAUD115200;

View file

@ -6,7 +6,7 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_nrf::peripherals::UARTE0;
use embassy_nrf::uarte::UarteRx;
use embassy_nrf::{interrupt, uarte, Peripherals};
use embassy_nrf::{interrupt, uarte};
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::channel::mpmc::Channel;
use {defmt_rtt as _, panic_probe as _};
@ -14,7 +14,8 @@ use {defmt_rtt as _, panic_probe as _};
static CHANNEL: Channel<ThreadModeRawMutex, [u8; 8], 1> = Channel::new();
#[embassy_executor::main]
async fn main(spawner: Spawner, p: Peripherals) {
async fn main(spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let mut config = uarte::Config::default();
config.parity = uarte::Parity::EXCLUDED;
config.baudrate = uarte::Baudrate::BAUD115200;

View file

@ -13,7 +13,7 @@ use embassy_net::tcp::TcpSocket;
use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources};
use embassy_nrf::rng::Rng;
use embassy_nrf::usb::{Driver, PowerUsb};
use embassy_nrf::{interrupt, pac, peripherals, Peripherals};
use embassy_nrf::{interrupt, pac, peripherals};
use embassy_usb::{Builder, Config, UsbDevice};
use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State};
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
@ -82,7 +82,8 @@ async fn net_task(stack: &'static Stack<Device>) -> ! {
}
#[embassy_executor::main]
async fn main(spawner: Spawner, p: Peripherals) {
async fn main(spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let clock: pac::CLOCK = unsafe { mem::transmute(()) };
info!("Enabling ext hfosc...");

View file

@ -10,7 +10,7 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_nrf::gpio::{Input, Pin, Pull};
use embassy_nrf::usb::{Driver, PowerUsb};
use embassy_nrf::{interrupt, pac, Peripherals};
use embassy_nrf::{interrupt, pac};
use embassy_usb::control::OutResponse;
use embassy_usb::{Builder, Config, DeviceStateHandler};
use embassy_usb_hid::{HidReaderWriter, ReportId, RequestHandler, State};
@ -23,7 +23,8 @@ use {defmt_rtt as _, panic_probe as _};
static SUSPENDED: AtomicBool = AtomicBool::new(false);
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let clock: pac::CLOCK = unsafe { mem::transmute(()) };
info!("Enabling ext hfosc...");

View file

@ -9,7 +9,7 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_nrf::usb::{Driver, PowerUsb};
use embassy_nrf::{interrupt, pac, Peripherals};
use embassy_nrf::{interrupt, pac};
use embassy_usb::control::OutResponse;
use embassy_usb::{Builder, Config};
use embassy_usb_hid::{HidWriter, ReportId, RequestHandler, State};
@ -18,7 +18,8 @@ use usbd_hid::descriptor::{MouseReport, SerializedDescriptor};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let clock: pac::CLOCK = unsafe { mem::transmute(()) };
info!("Enabling ext hfosc...");

View file

@ -8,7 +8,7 @@ use core::mem;
use defmt::{info, panic};
use embassy_executor::executor::Spawner;
use embassy_nrf::usb::{Driver, Instance, PowerUsb, UsbSupply};
use embassy_nrf::{interrupt, pac, Peripherals};
use embassy_nrf::{interrupt, pac};
use embassy_usb::driver::EndpointError;
use embassy_usb::{Builder, Config};
use embassy_usb_serial::{CdcAcmClass, State};
@ -16,7 +16,8 @@ use futures::future::join;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let clock: pac::CLOCK = unsafe { mem::transmute(()) };
info!("Enabling ext hfosc...");

View file

@ -8,7 +8,7 @@ use core::mem;
use defmt::{info, panic, unwrap};
use embassy_executor::executor::Spawner;
use embassy_nrf::usb::{Driver, PowerUsb};
use embassy_nrf::{interrupt, pac, peripherals, Peripherals};
use embassy_nrf::{interrupt, pac, peripherals};
use embassy_usb::driver::EndpointError;
use embassy_usb::{Builder, Config, UsbDevice};
use embassy_usb_serial::{CdcAcmClass, State};
@ -33,7 +33,8 @@ async fn echo_task(mut class: CdcAcmClass<'static, MyDriver>) {
}
#[embassy_executor::main]
async fn main(spawner: Spawner, p: Peripherals) {
async fn main(spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let clock: pac::CLOCK = unsafe { mem::transmute(()) };
info!("Enabling ext hfosc...");

View file

@ -6,11 +6,11 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_nrf::gpio::{Input, Pull};
use embassy_nrf::wdt::{Config, Watchdog};
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
info!("Hello World!");
let mut config = Config::default();

View file

@ -5,12 +5,13 @@
use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_rp::{gpio, Peripherals};
use embassy_rp::gpio;
use gpio::{Level, Output};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_rp::init(Default::default());
let mut led = Output::new(p.PIN_25, Level::Low);
loop {

View file

@ -4,11 +4,11 @@
use embassy_executor::executor::Spawner;
use embassy_rp::gpio::{Input, Level, Output, Pull};
use embassy_rp::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_rp::init(Default::default());
let button = Input::new(p.PIN_28, Pull::Up);
let mut led = Output::new(p.PIN_25, Level::Low);

View file

@ -5,7 +5,7 @@
use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_rp::{gpio, Peripherals};
use embassy_rp::gpio;
use gpio::{Input, Level, Output, Pull};
use {defmt_rtt as _, panic_probe as _};
@ -20,7 +20,8 @@ use {defmt_rtt as _, panic_probe as _};
/// continue and turn off the LED, and then wait for 2 seconds before completing
/// the loop and starting over again.
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_rp::init(Default::default());
let mut led = Output::new(p.PIN_25, Level::Low);
let mut async_input = Input::new(p.PIN_16, Pull::None);

View file

@ -5,12 +5,13 @@
use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_rp::spi::Spi;
use embassy_rp::{gpio, spi, Peripherals};
use embassy_rp::{gpio, spi};
use gpio::{Level, Output};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_rp::init(Default::default());
info!("Hello World!");
// Example for resistive touch sensor in Waveshare Pico-ResTouch

View file

@ -8,8 +8,8 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::Delay;
use embassy_rp::gpio::{Level, Output};
use embassy_rp::spi;
use embassy_rp::spi::Spi;
use embassy_rp::{spi, Peripherals};
use embedded_graphics::image::{Image, ImageRawLE};
use embedded_graphics::mono_font::ascii::FONT_10X20;
use embedded_graphics::mono_font::MonoTextStyle;
@ -28,7 +28,8 @@ use crate::touch::Touch;
const TOUCH_FREQ: u32 = 200_000;
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_rp::init(Default::default());
info!("Hello World!");
let bl = p.PIN_13;

View file

@ -3,11 +3,12 @@
#![feature(type_alias_impl_trait)]
use embassy_executor::executor::Spawner;
use embassy_rp::{uart, Peripherals};
use embassy_rp::uart;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_rp::init(Default::default());
let config = uart::Config::default();
let mut uart = uart::Uart::new(p.UART0, p.PIN_0, p.PIN_1, p.PIN_2, p.PIN_3, config);
uart.send("Hello World!\r\n".as_bytes());

View file

@ -5,11 +5,11 @@
use defmt::info;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, _p: Peripherals) -> ! {
async fn main(_spawner: Spawner) -> ! {
let _p = embassy_stm32::init(Default::default());
loop {
Timer::after(Duration::from_secs(1)).await;
info!("Hello");

View file

@ -6,11 +6,11 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Delay, Duration, Timer};
use embassy_stm32::adc::Adc;
use embassy_stm32::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
info!("Hello World!");
let mut adc = Adc::new(p.ADC1, &mut Delay);

View file

@ -6,11 +6,11 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
info!("Hello World!");
let mut led = Output::new(p.PC13, Level::High, Speed::Low);

View file

@ -6,7 +6,7 @@ use defmt::info;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::time::Hertz;
use embassy_stm32::{Config, Peripherals};
use embassy_stm32::Config;
use {defmt_rtt as _, panic_probe as _};
fn config() -> Config {
@ -15,8 +15,9 @@ fn config() -> Config {
config
}
#[embassy_executor::main(config = "config()")]
async fn main(_spawner: Spawner, _p: Peripherals) -> ! {
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
let _p = embassy_stm32::init(config());
loop {
info!("Hello World!");
Timer::after(Duration::from_secs(1)).await;

View file

@ -8,7 +8,7 @@ use embassy_executor::time::{Duration, Timer};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::time::Hertz;
use embassy_stm32::usb::{Driver, Instance};
use embassy_stm32::{interrupt, Config, Peripherals};
use embassy_stm32::{interrupt, Config};
use embassy_usb::driver::EndpointError;
use embassy_usb::Builder;
use embassy_usb_serial::{CdcAcmClass, State};
@ -23,8 +23,9 @@ fn config() -> Config {
config
}
#[embassy_executor::main(config = "config()")]
async fn main(_spawner: Spawner, mut p: Peripherals) {
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let mut p = embassy_stm32::init(config());
info!("Hello World!");
{

View file

@ -6,11 +6,11 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
info!("Hello World!");
let mut led = Output::new(p.PB14, Level::High, Speed::Low);

View file

@ -11,7 +11,7 @@ use embassy_stm32::rcc::{
APBPrescaler, ClockSrc, HSEConfig, HSESrc, PLL48Div, PLLConfig, PLLMainDiv, PLLMul, PLLPreDiv, PLLSrc,
};
use embassy_stm32::time::Hertz;
use embassy_stm32::{Config, Peripherals};
use embassy_stm32::Config;
use {defmt_rtt as _, panic_probe as _};
// Example config for maximum performance on a NUCLEO-F207ZG board
@ -43,8 +43,9 @@ fn config() -> Config {
config
}
#[embassy_executor::main(config = "config()")]
async fn main(_spawner: Spawner, _p: Peripherals) {
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let _p = embassy_stm32::init(config());
loop {
Timer::after(Duration::from_millis(1000)).await;
info!("1s elapsed");

View file

@ -6,11 +6,11 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
info!("Hello World!");
let mut led = Output::new(p.PA5, Level::High, Speed::Low);

View file

@ -16,7 +16,6 @@ use embassy_executor::time::{with_timeout, Duration, Timer};
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed};
use embassy_stm32::peripherals::PA0;
use embassy_stm32::Peripherals;
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::channel::mpmc::Channel;
use {defmt_rtt as _, panic_probe as _};
@ -100,7 +99,8 @@ enum ButtonEvent {
static CHANNEL: Channel<ThreadModeRawMutex, ButtonEvent, 4> = Channel::new();
#[embassy_executor::main]
async fn main(spawner: Spawner, p: Peripherals) {
async fn main(spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let button = Input::new(p.PA0, Pull::Down);
let button = ExtiInput::new(button, p.EXTI0);
info!("Press the USER button...");

View file

@ -6,11 +6,11 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::gpio::{Input, Pull};
use embassy_stm32::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
info!("Hello World!");
let button = Input::new(p.PA0, Pull::Down);

View file

@ -5,12 +5,12 @@
use defmt::{info, unwrap};
use embassy_executor::executor::Spawner;
use embassy_stm32::flash::Flash;
use embassy_stm32::Peripherals;
use embedded_storage::nor_flash::{NorFlash, ReadNorFlash};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
info!("Hello Flash!");
const ADDR: u32 = 0x26000;

View file

@ -6,7 +6,7 @@ use defmt::info;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::time::Hertz;
use embassy_stm32::{Config, Peripherals};
use embassy_stm32::Config;
use {defmt_rtt as _, panic_probe as _};
fn config() -> Config {
@ -16,8 +16,9 @@ fn config() -> Config {
config
}
#[embassy_executor::main(config = "config()")]
async fn main(_spawner: Spawner, _p: Peripherals) -> ! {
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
let _p = embassy_stm32::init(config());
loop {
info!("Hello World!");
Timer::after(Duration::from_secs(1)).await;

View file

@ -9,12 +9,12 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_stm32::spi::{Config, Spi};
use embassy_stm32::time::Hertz;
use embassy_stm32::Peripherals;
use heapless::String;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
info!("Hello World!");
let mut spi = Spi::new(

View file

@ -8,12 +8,12 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_stm32::dma::NoDma;
use embassy_stm32::usart::{Config, Uart};
use embassy_stm32::Peripherals;
use heapless::String;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner, p: Peripherals) {
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
info!("Hello World!");
let config = Config::default();

Some files were not shown because too many files have changed in this diff Show more