Merge #908
908: Remove HAL initialization from #[embassy_executor::main] macro. r=Dirbaio a=Dirbaio Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
This commit is contained in:
commit
1c5b54a482
185 changed files with 480 additions and 557 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -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))));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -13,8 +13,5 @@ proc-macro2 = "1.0.29"
|
|||
proc-macro = true
|
||||
|
||||
[features]
|
||||
nrf = []
|
||||
stm32 = []
|
||||
rp = []
|
||||
std = []
|
||||
wasm = []
|
||||
|
|
|
@ -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));
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"))]
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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);
|
||||
)*
|
||||
|
|
|
@ -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"))]
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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())));
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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...");
|
||||
|
|
|
@ -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...");
|
||||
|
|
|
@ -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...");
|
||||
|
|
|
@ -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...");
|
||||
|
|
|
@ -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...");
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -6,17 +6,15 @@ 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 {
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) -> ! {
|
||||
let mut config = Config::default();
|
||||
config.rcc.sys_ck = Some(Hertz(36_000_000));
|
||||
config
|
||||
}
|
||||
let _p = embassy_stm32::init(config);
|
||||
|
||||
#[embassy_executor::main(config = "config()")]
|
||||
async fn main(_spawner: Spawner, _p: Peripherals) -> ! {
|
||||
loop {
|
||||
info!("Hello World!");
|
||||
Timer::after(Duration::from_secs(1)).await;
|
||||
|
|
|
@ -8,23 +8,21 @@ 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};
|
||||
use futures::future::join;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
fn config() -> Config {
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
let mut config = Config::default();
|
||||
config.rcc.hse = Some(Hertz(8_000_000));
|
||||
config.rcc.sys_ck = Some(Hertz(48_000_000));
|
||||
config.rcc.pclk1 = Some(Hertz(24_000_000));
|
||||
config
|
||||
}
|
||||
let mut p = embassy_stm32::init(config);
|
||||
|
||||
#[embassy_executor::main(config = "config()")]
|
||||
async fn main(_spawner: Spawner, mut p: Peripherals) {
|
||||
info!("Hello World!");
|
||||
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -11,11 +11,13 @@ 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
|
||||
fn config() -> Config {
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
// Example config for maximum performance on a NUCLEO-F207ZG board
|
||||
|
||||
let mut config = Config::default();
|
||||
// By default, HSE on the board comes from a 8 MHz clock signal (not a crystal)
|
||||
config.rcc.hse = Some(HSEConfig {
|
||||
|
@ -40,11 +42,9 @@ fn config() -> Config {
|
|||
config.rcc.apb1_pre = APBPrescaler::Div4;
|
||||
// 120 MHz / 2 = 60 MHz APB2 frequency
|
||||
config.rcc.apb2_pre = APBPrescaler::Div2;
|
||||
config
|
||||
}
|
||||
|
||||
#[embassy_executor::main(config = "config()")]
|
||||
async fn main(_spawner: Spawner, _p: Peripherals) {
|
||||
let _p = embassy_stm32::init(config);
|
||||
|
||||
loop {
|
||||
Timer::after(Duration::from_millis(1000)).await;
|
||||
info!("1s elapsed");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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...");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -6,18 +6,16 @@ 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 {
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) -> ! {
|
||||
let mut config = Config::default();
|
||||
config.rcc.hse = Some(Hertz(8_000_000));
|
||||
config.rcc.sysclk = Some(Hertz(16_000_000));
|
||||
config
|
||||
}
|
||||
let _p = embassy_stm32::init(config);
|
||||
|
||||
#[embassy_executor::main(config = "config()")]
|
||||
async fn main(_spawner: Spawner, _p: Peripherals) -> ! {
|
||||
loop {
|
||||
info!("Hello World!");
|
||||
Timer::after(Duration::from_secs(1)).await;
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
Loading…
Reference in a new issue