Merge remote-tracking branch 'origin/master' into nrf-pdm

This commit is contained in:
Quentin Smith
2022-08-23 23:01:51 -04:00
164 changed files with 923 additions and 434 deletions

View File

@ -4,7 +4,7 @@ name = "embassy-boot-nrf-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../../../embassy-util" }
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" }
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly"] }
embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly", "nrf52840"] }

View File

@ -4,7 +4,7 @@ name = "embassy-boot-stm32f3-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] }

View File

@ -4,7 +4,7 @@ name = "embassy-boot-stm32f7-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] }

View File

@ -4,7 +4,7 @@ name = "embassy-boot-stm32h7-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] }

View File

@ -4,7 +4,7 @@ name = "embassy-boot-stm32l0-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] }

View File

@ -4,7 +4,7 @@ name = "embassy-boot-stm32l1-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] }

View File

@ -4,7 +4,7 @@ name = "embassy-boot-stm32l4-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] }

View File

@ -4,7 +4,7 @@ name = "embassy-boot-stm32wl-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] }

View File

@ -0,0 +1,9 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# replace nRF82840_xxAA with your chip as listed in `probe-run --list-chips`
runner = "probe-run --chip nRF52840_xxAA"
[build]
target = "thumbv7em-none-eabi"
[env]
DEFMT_LOG = "trace"

View File

@ -0,0 +1,35 @@
[package]
edition = "2021"
name = "embassy-nrf-rtos-trace-examples"
version = "0.1.0"
[features]
default = ["log", "nightly"]
nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-nrf/unstable-traits"]
log = [
"dep:log",
"embassy-sync/log",
"embassy-executor/log",
"embassy-time/log",
"embassy-nrf/log",
]
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../embassy-sync" }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features=["rtos-trace", "rtos-trace-interrupt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time" }
embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] }
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0"
panic-probe = { version = "0.3" }
futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
rand = { version = "0.8.4", default-features = false }
serde = { version = "1.0.136", default-features = false }
rtos-trace = "0.1.3"
systemview-target = { version = "0.1.2", features = ["callbacks-app", "callbacks-os", "log", "cortex-m"] }
log = { version = "0.4.17", optional = true }
[[bin]]
name = "rtos_trace"
required-features = ["nightly"]

View File

@ -0,0 +1,36 @@
//! This build script copies the `memory.x` file from the crate root into
//! a directory where the linker can always find it at build time.
//! For many projects this is optional, as the linker always searches the
//! project root directory -- wherever `Cargo.toml` is. However, if you
//! are using a workspace or have a more complicated build setup, this
//! build script becomes required. Additionally, by requesting that
//! Cargo re-run the build script whenever `memory.x` is changed,
//! updating `memory.x` ensures a rebuild of the application with the
//! new memory settings.
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
// Put `memory.x` in our output directory and ensure it's
// on the linker search path.
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("memory.x"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
// By default, Cargo will re-run a build script whenever
// any file in the project changes. By specifying `memory.x`
// here, we ensure the build script is only re-run when
// `memory.x` is changed.
println!("cargo:rerun-if-changed=memory.x");
println!("cargo:rustc-link-arg-bins=--nmagic");
println!("cargo:rustc-link-arg-bins=-Tlink.x");
#[cfg(feature = "defmt")]
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
}

View File

@ -0,0 +1,7 @@
MEMORY
{
/* NOTE 1 K = 1 KiBi = 1024 bytes */
/* These values correspond to the NRF52840 with Softdevices S140 7.0.1 */
FLASH : ORIGIN = 0x00000000, LENGTH = 1024K
RAM : ORIGIN = 0x20000000, LENGTH = 256K
}

View File

@ -0,0 +1,69 @@
#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
use core::task::Poll;
use embassy_executor::Spawner;
use embassy_time::{Duration, Instant, Timer};
#[cfg(feature = "log")]
use log::*;
use panic_probe as _;
// N.B. systemview_target cannot be used at the same time as defmt_rtt.
use rtos_trace;
use systemview_target::SystemView;
static LOGGER: systemview_target::SystemView = systemview_target::SystemView::new();
rtos_trace::global_trace! {SystemView}
struct TraceInfo();
impl rtos_trace::RtosTraceApplicationCallbacks for TraceInfo {
fn system_description() {}
fn sysclock() -> u32 {
64000000
}
}
rtos_trace::global_application_callbacks! {TraceInfo}
#[embassy_executor::task]
async fn run1() {
loop {
#[cfg(feature = "log")]
info!("DING DONG");
#[cfg(not(feature = "log"))]
rtos_trace::trace::marker(13);
Timer::after(Duration::from_ticks(16000)).await;
}
}
#[embassy_executor::task]
async fn run2() {
loop {
Timer::at(Instant::from_ticks(0)).await;
}
}
#[embassy_executor::task]
async fn run3() {
futures::future::poll_fn(|cx| {
cx.waker().wake_by_ref();
Poll::<()>::Pending
})
.await;
}
#[embassy_executor::main]
async fn main(spawner: Spawner) {
let _p = embassy_nrf::init(Default::default());
LOGGER.init();
#[cfg(feature = "log")]
{
::log::set_logger(&LOGGER).ok();
::log::set_max_level(::log::LevelFilter::Trace);
}
spawner.spawn(run1()).unwrap();
spawner.spawn(run2()).unwrap();
spawner.spawn(run3()).unwrap();
}

View File

@ -8,7 +8,8 @@ default = ["nightly"]
nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-nrf/unstable-traits", "embassy-usb", "embassy-usb-serial", "embassy-usb-hid", "embassy-usb-ncm", "embedded-io/async", "embassy-net"]
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] }
@ -22,6 +23,7 @@ embedded-io = "0.3.0"
defmt = "0.3"
defmt-rtt = "0.3"
static_cell = "1.0"
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0"
panic-probe = { version = "0.3", features = ["print-defmt"] }

View File

@ -5,9 +5,9 @@
use defmt::unwrap;
use embassy_executor::Spawner;
use embassy_nrf::gpio::{Level, Output, OutputDrive};
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_sync::channel::Channel;
use embassy_time::{Duration, Timer};
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::channel::mpmc::Channel;
use {defmt_rtt as _, panic_probe as _};
enum LedState {

View File

@ -5,10 +5,10 @@
use defmt::unwrap;
use embassy_executor::Spawner;
use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin};
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
use embassy_sync::channel::{Channel, Receiver, Sender};
use embassy_time::{Duration, Timer};
use embassy_util::blocking_mutex::raw::NoopRawMutex;
use embassy_util::channel::mpmc::{Channel, Receiver, Sender};
use embassy_util::Forever;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
enum LedState {
@ -16,7 +16,7 @@ enum LedState {
Off,
}
static CHANNEL: Forever<Channel<NoopRawMutex, LedState, 1>> = Forever::new();
static CHANNEL: StaticCell<Channel<NoopRawMutex, LedState, 1>> = StaticCell::new();
#[embassy_executor::task]
async fn send_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) {
@ -43,7 +43,7 @@ async fn recv_task(led: AnyPin, receiver: Receiver<'static, NoopRawMutex, LedSta
#[embassy_executor::main]
async fn main(spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let channel = CHANNEL.put(Channel::new());
let channel = CHANNEL.init(Channel::new());
unwrap!(spawner.spawn(send_task(channel.sender())));
unwrap!(spawner.spawn(recv_task(p.P0_13.degrade(), channel.receiver())));

View File

@ -63,7 +63,7 @@ use embassy_nrf::executor::{Executor, InterruptExecutor};
use embassy_nrf::interrupt;
use embassy_nrf::interrupt::InterruptExt;
use embassy_time::{Duration, Instant, Timer};
use embassy_util::Forever;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
@ -108,9 +108,9 @@ async fn run_low() {
}
}
static EXECUTOR_HIGH: Forever<InterruptExecutor<interrupt::SWI1_EGU1>> = Forever::new();
static EXECUTOR_MED: Forever<InterruptExecutor<interrupt::SWI0_EGU0>> = Forever::new();
static EXECUTOR_LOW: Forever<Executor> = Forever::new();
static EXECUTOR_HIGH: StaticCell<InterruptExecutor<interrupt::SWI1_EGU1>> = StaticCell::new();
static EXECUTOR_MED: StaticCell<InterruptExecutor<interrupt::SWI0_EGU0>> = StaticCell::new();
static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new();
#[entry]
fn main() -> ! {
@ -121,19 +121,19 @@ fn main() -> ! {
// High-priority executor: SWI1_EGU1, priority level 6
let irq = interrupt::take!(SWI1_EGU1);
irq.set_priority(interrupt::Priority::P6);
let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq));
let executor = EXECUTOR_HIGH.init(InterruptExecutor::new(irq));
let spawner = executor.start();
unwrap!(spawner.spawn(run_high()));
// Medium-priority executor: SWI0_EGU0, priority level 7
let irq = interrupt::take!(SWI0_EGU0);
irq.set_priority(interrupt::Priority::P7);
let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq));
let executor = EXECUTOR_MED.init(InterruptExecutor::new(irq));
let spawner = executor.start();
unwrap!(spawner.spawn(run_med()));
// Low priority executor: runs in thread mode, using WFE/SEV
let executor = EXECUTOR_LOW.put(Executor::new());
let executor = EXECUTOR_LOW.init(Executor::new());
executor.run(|spawner| {
unwrap!(spawner.spawn(run_low()));
});

View File

@ -4,9 +4,9 @@
use defmt::{info, unwrap};
use embassy_executor::Spawner;
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_sync::mutex::Mutex;
use embassy_time::{Duration, Timer};
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::mutex::Mutex;
use {defmt_rtt as _, panic_probe as _};
static MUTEX: Mutex<ThreadModeRawMutex, u32> = Mutex::new(0);

View File

@ -4,9 +4,9 @@
use defmt::unwrap;
use embassy_executor::Spawner;
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_sync::pubsub::{DynSubscriber, PubSubChannel, Subscriber};
use embassy_time::{Duration, Timer};
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::channel::pubsub::{DynSubscriber, PubSubChannel, Subscriber};
use {defmt_rtt as _, panic_probe as _};
/// Create the message bus. It has a queue of 4, supports 3 subscribers and 1 publisher

View File

@ -8,7 +8,7 @@ use defmt::{info, unwrap};
use embassy_executor::raw::TaskStorage;
use embassy_executor::Executor;
use embassy_time::{Duration, Timer};
use embassy_util::Forever;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
async fn run1() {
@ -25,14 +25,14 @@ async fn run2() {
}
}
static EXECUTOR: Forever<Executor> = Forever::new();
static EXECUTOR: StaticCell<Executor> = StaticCell::new();
#[entry]
fn main() -> ! {
info!("Hello World!");
let _p = embassy_nrf::init(Default::default());
let executor = EXECUTOR.put(Executor::new());
let executor = EXECUTOR.init(Executor::new());
let run1_task = TaskStorage::new();
let run2_task = TaskStorage::new();

View File

@ -7,8 +7,8 @@ use embassy_executor::Spawner;
use embassy_nrf::peripherals::UARTE0;
use embassy_nrf::uarte::UarteRx;
use embassy_nrf::{interrupt, uarte};
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::channel::mpmc::Channel;
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_sync::channel::Channel;
use {defmt_rtt as _, panic_probe as _};
static CHANNEL: Channel<ThreadModeRawMutex, [u8; 8], 1> = Channel::new();

View File

@ -14,21 +14,21 @@ 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};
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_sync::channel::Channel;
use embassy_usb::{Builder, Config, UsbDevice};
use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State};
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::channel::mpmc::Channel;
use embassy_util::Forever;
use embedded_io::asynch::{Read, Write};
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
type MyDriver = Driver<'static, peripherals::USBD, PowerUsb>;
macro_rules! forever {
macro_rules! singleton {
($val:expr) => {{
type T = impl Sized;
static FOREVER: Forever<T> = Forever::new();
FOREVER.put_with(move || $val)
static STATIC_CELL: StaticCell<T> = StaticCell::new();
STATIC_CELL.init_with(move || $val)
}};
}
@ -116,7 +116,7 @@ async fn main(spawner: Spawner) {
control_buf: [u8; 128],
serial_state: State<'static>,
}
let res: &mut Resources = forever!(Resources {
let res: &mut Resources = singleton!(Resources {
device_descriptor: [0; 256],
config_descriptor: [0; 256],
bos_descriptor: [0; 256],
@ -174,10 +174,10 @@ async fn main(spawner: Spawner) {
// Init network stack
let device = Device { mac_addr: our_mac_addr };
let stack = &*forever!(Stack::new(
let stack = &*singleton!(Stack::new(
device,
config,
forever!(StackResources::<1, 2, 8>::new()),
singleton!(StackResources::<1, 2, 8>::new()),
seed
));

View File

@ -8,14 +8,14 @@ use core::sync::atomic::{AtomicBool, Ordering};
use defmt::*;
use embassy_executor::Spawner;
use embassy_futures::{select, Either};
use embassy_nrf::gpio::{Input, Pin, Pull};
use embassy_nrf::usb::{Driver, PowerUsb};
use embassy_nrf::{interrupt, pac};
use embassy_sync::signal::Signal;
use embassy_usb::control::OutResponse;
use embassy_usb::{Builder, Config, DeviceStateHandler};
use embassy_usb_hid::{HidReaderWriter, ReportId, RequestHandler, State};
use embassy_util::channel::signal::Signal;
use embassy_util::{select, Either};
use futures::future::join;
use usbd_hid::descriptor::{KeyboardReport, SerializedDescriptor};
use {defmt_rtt as _, panic_probe as _};

View File

@ -12,7 +12,7 @@ use embassy_nrf::{interrupt, pac, peripherals};
use embassy_usb::driver::EndpointError;
use embassy_usb::{Builder, Config, UsbDevice};
use embassy_usb_serial::{CdcAcmClass, State};
use embassy_util::Forever;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
type MyDriver = Driver<'static, peripherals::USBD, PowerUsb>;
@ -67,8 +67,8 @@ async fn main(spawner: Spawner) {
control_buf: [u8; 64],
serial_state: State<'static>,
}
static RESOURCES: Forever<Resources> = Forever::new();
let res = RESOURCES.put(Resources {
static RESOURCES: StaticCell<Resources> = StaticCell::new();
let res = RESOURCES.init(Resources {
device_descriptor: [0; 256],
config_descriptor: [0; 256],
bos_descriptor: [0; 256],

View File

@ -5,7 +5,7 @@ version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac"] }

View File

@ -4,7 +4,7 @@ name = "embassy-std-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["log"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["log"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "std", "nightly", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["log", "std", "nightly"] }
embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "log", "medium-ethernet", "tcp", "udp", "dhcpv4", "pool-16"] }
@ -20,3 +20,4 @@ libc = "0.2.101"
clap = { version = "3.0.0-beta.5", features = ["derive"] }
rand_core = { version = "0.6.3", features = ["std"] }
heapless = { version = "0.7.5", default-features = false }
static_cell = "1.0"

View File

@ -4,22 +4,22 @@ use clap::Parser;
use embassy_executor::{Executor, Spawner};
use embassy_net::tcp::TcpSocket;
use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, Stack, StackResources};
use embassy_util::Forever;
use embedded_io::asynch::Write;
use heapless::Vec;
use log::*;
use rand_core::{OsRng, RngCore};
use static_cell::StaticCell;
#[path = "../tuntap.rs"]
mod tuntap;
use crate::tuntap::TunTapDevice;
macro_rules! forever {
macro_rules! singleton {
($val:expr) => {{
type T = impl Sized;
static FOREVER: Forever<T> = Forever::new();
FOREVER.put_with(move || $val)
static STATIC_CELL: StaticCell<T> = StaticCell::new();
STATIC_CELL.init_with(move || $val)
}};
}
@ -63,10 +63,10 @@ async fn main_task(spawner: Spawner) {
let seed = u64::from_le_bytes(seed);
// Init network stack
let stack = &*forever!(Stack::new(
let stack = &*singleton!(Stack::new(
device,
config,
forever!(StackResources::<1, 2, 8>::new()),
singleton!(StackResources::<1, 2, 8>::new()),
seed
));
@ -97,7 +97,7 @@ async fn main_task(spawner: Spawner) {
}
}
static EXECUTOR: Forever<Executor> = Forever::new();
static EXECUTOR: StaticCell<Executor> = StaticCell::new();
fn main() {
env_logger::builder()
@ -106,7 +106,7 @@ fn main() {
.format_timestamp_nanos()
.init();
let executor = EXECUTOR.put(Executor::new());
let executor = EXECUTOR.init(Executor::new());
executor.run(|spawner| {
spawner.spawn(main_task(spawner)).unwrap();
});

View File

@ -4,21 +4,21 @@ use clap::Parser;
use embassy_executor::{Executor, Spawner};
use embassy_net::udp::UdpSocket;
use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, PacketMetadata, Stack, StackResources};
use embassy_util::Forever;
use heapless::Vec;
use log::*;
use rand_core::{OsRng, RngCore};
use static_cell::StaticCell;
#[path = "../tuntap.rs"]
mod tuntap;
use crate::tuntap::TunTapDevice;
macro_rules! forever {
macro_rules! singleton {
($val:expr) => {{
type T = impl Sized;
static FOREVER: Forever<T> = Forever::new();
FOREVER.put_with(move || $val)
static STATIC_CELL: StaticCell<T> = StaticCell::new();
STATIC_CELL.init_with(move || $val)
}};
}
@ -62,10 +62,10 @@ async fn main_task(spawner: Spawner) {
let seed = u64::from_le_bytes(seed);
// Init network stack
let stack = &*forever!(Stack::new(
let stack = &*singleton!(Stack::new(
device,
config,
forever!(StackResources::<1, 2, 8>::new()),
singleton!(StackResources::<1, 2, 8>::new()),
seed
));
@ -93,7 +93,7 @@ async fn main_task(spawner: Spawner) {
}
}
static EXECUTOR: Forever<Executor> = Forever::new();
static EXECUTOR: StaticCell<Executor> = StaticCell::new();
fn main() {
env_logger::builder()
@ -102,7 +102,7 @@ fn main() {
.format_timestamp_nanos()
.init();
let executor = EXECUTOR.put(Executor::new());
let executor = EXECUTOR.init(Executor::new());
executor.run(|spawner| {
spawner.spawn(main_task(spawner)).unwrap();
});

View File

@ -5,10 +5,10 @@ mod serial_port;
use async_io::Async;
use embassy_executor::Executor;
use embassy_util::Forever;
use embedded_io::asynch::Read;
use log::*;
use nix::sys::termios;
use static_cell::StaticCell;
use self::serial_port::SerialPort;
@ -40,7 +40,7 @@ async fn run() {
}
}
static EXECUTOR: Forever<Executor> = Forever::new();
static EXECUTOR: StaticCell<Executor> = StaticCell::new();
fn main() {
env_logger::builder()
@ -49,7 +49,7 @@ fn main() {
.format_timestamp_nanos()
.init();
let executor = EXECUTOR.put(Executor::new());
let executor = EXECUTOR.init(Executor::new());
executor.run(|spawner| {
spawner.spawn(run()).unwrap();
});

View File

@ -11,7 +11,7 @@ cortex-m-rt = "0.7.0"
defmt = "0.3"
defmt-rtt = "0.3"
panic-probe = "0.3"
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "memory-x", "stm32f030f4", "time-driver-any"] }

View File

@ -4,7 +4,7 @@ name = "embassy-stm32f1-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any"] }

View File

@ -4,7 +4,7 @@ name = "embassy-stm32f2-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] }

View File

@ -4,7 +4,7 @@ name = "embassy-stm32f3-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] }
@ -23,3 +23,4 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa
heapless = { version = "0.7.5", default-features = false }
nb = "1.0.0"
embedded-storage = "0.3.0"
static_cell = "1.0"

View File

@ -15,9 +15,9 @@ use embassy_executor::Spawner;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed};
use embassy_stm32::peripherals::PA0;
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_sync::channel::Channel;
use embassy_time::{with_timeout, Duration, Timer};
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::channel::mpmc::Channel;
use {defmt_rtt as _, panic_probe as _};
struct Leds<'a> {

View File

@ -63,7 +63,7 @@ use embassy_stm32::executor::{Executor, InterruptExecutor};
use embassy_stm32::interrupt;
use embassy_stm32::interrupt::InterruptExt;
use embassy_time::{Duration, Instant, Timer};
use embassy_util::Forever;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
@ -108,9 +108,9 @@ async fn run_low() {
}
}
static EXECUTOR_HIGH: Forever<InterruptExecutor<interrupt::UART4>> = Forever::new();
static EXECUTOR_MED: Forever<InterruptExecutor<interrupt::UART5>> = Forever::new();
static EXECUTOR_LOW: Forever<Executor> = Forever::new();
static EXECUTOR_HIGH: StaticCell<InterruptExecutor<interrupt::UART4>> = StaticCell::new();
static EXECUTOR_MED: StaticCell<InterruptExecutor<interrupt::UART5>> = StaticCell::new();
static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new();
#[entry]
fn main() -> ! {
@ -121,19 +121,19 @@ fn main() -> ! {
// High-priority executor: SWI1_EGU1, priority level 6
let irq = interrupt::take!(UART4);
irq.set_priority(interrupt::Priority::P6);
let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq));
let executor = EXECUTOR_HIGH.init(InterruptExecutor::new(irq));
let spawner = executor.start();
unwrap!(spawner.spawn(run_high()));
// Medium-priority executor: SWI0_EGU0, priority level 7
let irq = interrupt::take!(UART5);
irq.set_priority(interrupt::Priority::P7);
let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq));
let executor = EXECUTOR_MED.init(InterruptExecutor::new(irq));
let spawner = executor.start();
unwrap!(spawner.spawn(run_med()));
// Low priority executor: runs in thread mode, using WFE/SEV
let executor = EXECUTOR_LOW.put(Executor::new());
let executor = EXECUTOR_LOW.init(Executor::new());
executor.run(|spawner| {
unwrap!(spawner.spawn(run_low()));
});

View File

@ -5,7 +5,7 @@ version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti"] }
@ -23,6 +23,7 @@ heapless = { version = "0.7.5", default-features = false }
nb = "1.0.0"
embedded-storage = "0.3.0"
micromath = "2.0.0"
static_cell = "1.0"
usb-device = "0.2"
usbd-serial = "0.1.1"

View File

@ -63,7 +63,7 @@ use embassy_stm32::executor::{Executor, InterruptExecutor};
use embassy_stm32::interrupt;
use embassy_stm32::interrupt::InterruptExt;
use embassy_time::{Duration, Instant, Timer};
use embassy_util::Forever;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
@ -108,9 +108,9 @@ async fn run_low() {
}
}
static EXECUTOR_HIGH: Forever<InterruptExecutor<interrupt::UART4>> = Forever::new();
static EXECUTOR_MED: Forever<InterruptExecutor<interrupt::UART5>> = Forever::new();
static EXECUTOR_LOW: Forever<Executor> = Forever::new();
static EXECUTOR_HIGH: StaticCell<InterruptExecutor<interrupt::UART4>> = StaticCell::new();
static EXECUTOR_MED: StaticCell<InterruptExecutor<interrupt::UART5>> = StaticCell::new();
static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new();
#[entry]
fn main() -> ! {
@ -121,19 +121,19 @@ fn main() -> ! {
// High-priority executor: SWI1_EGU1, priority level 6
let irq = interrupt::take!(UART4);
irq.set_priority(interrupt::Priority::P6);
let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq));
let executor = EXECUTOR_HIGH.init(InterruptExecutor::new(irq));
let spawner = executor.start();
unwrap!(spawner.spawn(run_high()));
// Medium-priority executor: SWI0_EGU0, priority level 7
let irq = interrupt::take!(UART5);
irq.set_priority(interrupt::Priority::P7);
let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq));
let executor = EXECUTOR_MED.init(InterruptExecutor::new(irq));
let spawner = executor.start();
unwrap!(spawner.spawn(run_med()));
// Low priority executor: runs in thread mode, using WFE/SEV
let executor = EXECUTOR_LOW.put(Executor::new());
let executor = EXECUTOR_LOW.init(Executor::new());
executor.run(|spawner| {
unwrap!(spawner.spawn(run_low()));
});

View File

@ -4,7 +4,7 @@ name = "embassy-stm32f7-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "net", "stm32f767zi", "unstable-pac", "time-driver-any", "exti"] }
@ -24,3 +24,4 @@ nb = "1.0.0"
rand_core = "0.6.3"
critical-section = "1.1"
embedded-storage = "0.3.0"
static_cell = "1.0"

View File

@ -13,16 +13,16 @@ use embassy_stm32::rng::Rng;
use embassy_stm32::time::mhz;
use embassy_stm32::{interrupt, Config};
use embassy_time::{Duration, Timer};
use embassy_util::Forever;
use embedded_io::asynch::Write;
use rand_core::RngCore;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
macro_rules! forever {
macro_rules! singleton {
($val:expr) => {{
type T = impl Sized;
static FOREVER: Forever<T> = Forever::new();
FOREVER.put_with(move || $val)
static STATIC_CELL: StaticCell<T> = StaticCell::new();
STATIC_CELL.init_with(move || $val)
}};
}
@ -52,7 +52,7 @@ async fn main(spawner: Spawner) -> ! {
let device = unsafe {
Ethernet::new(
forever!(State::new()),
singleton!(State::new()),
p.ETH,
eth_int,
p.PA1,
@ -78,10 +78,10 @@ async fn main(spawner: Spawner) -> ! {
//});
// Init network stack
let stack = &*forever!(Stack::new(
let stack = &*singleton!(Stack::new(
device,
config,
forever!(StackResources::<1, 2, 8>::new()),
singleton!(StackResources::<1, 2, 8>::new()),
seed
));

View File

@ -4,7 +4,7 @@ name = "embassy-stm32g0-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] }

View File

@ -4,7 +4,7 @@ name = "embassy-stm32g4-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] }

View File

@ -4,7 +4,7 @@ name = "embassy-stm32h7-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "net", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] }
@ -28,6 +28,7 @@ critical-section = "1.1"
micromath = "2.0.0"
stm32-fmc = "0.2.4"
embedded-storage = "0.3.0"
static_cell = "1.0"
# cargo build/run
[profile.dev]

View File

@ -13,16 +13,16 @@ use embassy_stm32::rng::Rng;
use embassy_stm32::time::mhz;
use embassy_stm32::{interrupt, Config};
use embassy_time::{Duration, Timer};
use embassy_util::Forever;
use embedded_io::asynch::Write;
use rand_core::RngCore;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
macro_rules! forever {
macro_rules! singleton {
($val:expr) => {{
type T = impl Sized;
static FOREVER: Forever<T> = Forever::new();
FOREVER.put_with(move || $val)
static STATIC_CELL: StaticCell<T> = StaticCell::new();
STATIC_CELL.init_with(move || $val)
}};
}
@ -53,7 +53,7 @@ async fn main(spawner: Spawner) -> ! {
let device = unsafe {
Ethernet::new(
forever!(State::new()),
singleton!(State::new()),
p.ETH,
eth_int,
p.PA1,
@ -79,10 +79,10 @@ async fn main(spawner: Spawner) -> ! {
//});
// Init network stack
let stack = &*forever!(Stack::new(
let stack = &*singleton!(Stack::new(
device,
config,
forever!(StackResources::<1, 2, 8>::new()),
singleton!(StackResources::<1, 2, 8>::new()),
seed
));

View File

@ -13,17 +13,17 @@ use embassy_stm32::rng::Rng;
use embassy_stm32::time::mhz;
use embassy_stm32::{interrupt, Config};
use embassy_time::{Duration, Timer};
use embassy_util::Forever;
use embedded_io::asynch::Write;
use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect};
use rand_core::RngCore;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
macro_rules! forever {
macro_rules! singleton {
($val:expr) => {{
type T = impl Sized;
static FOREVER: Forever<T> = Forever::new();
FOREVER.put_with(move || $val)
static STATIC_CELL: StaticCell<T> = StaticCell::new();
STATIC_CELL.init_with(move || $val)
}};
}
@ -54,7 +54,7 @@ async fn main(spawner: Spawner) -> ! {
let device = unsafe {
Ethernet::new(
forever!(State::new()),
singleton!(State::new()),
p.ETH,
eth_int,
p.PA1,
@ -80,10 +80,10 @@ async fn main(spawner: Spawner) -> ! {
//});
// Init network stack
let stack = &*forever!(Stack::new(
let stack = &*singleton!(Stack::new(
device,
config,
forever!(StackResources::<1, 2, 8>::new()),
singleton!(StackResources::<1, 2, 8>::new()),
seed
));

View File

@ -4,8 +4,8 @@
use defmt::{info, unwrap};
use embassy_executor::Spawner;
use embassy_sync::signal::Signal;
use embassy_time::{Duration, Timer};
use embassy_util::channel::signal::Signal;
use {defmt_rtt as _, panic_probe as _};
static SIGNAL: Signal<u32> = Signal::new();

View File

@ -12,8 +12,8 @@ use embassy_stm32::dma::NoDma;
use embassy_stm32::peripherals::SPI3;
use embassy_stm32::time::mhz;
use embassy_stm32::{spi, Config};
use embassy_util::Forever;
use heapless::String;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
@ -31,7 +31,7 @@ async fn main_task(mut spi: spi::Spi<'static, SPI3, NoDma, NoDma>) {
}
}
static EXECUTOR: Forever<Executor> = Forever::new();
static EXECUTOR: StaticCell<Executor> = StaticCell::new();
#[entry]
fn main() -> ! {
@ -54,7 +54,7 @@ fn main() -> ! {
spi::Config::default(),
);
let executor = EXECUTOR.put(Executor::new());
let executor = EXECUTOR.init(Executor::new());
executor.run(|spawner| {
unwrap!(spawner.spawn(main_task(spi)));

View File

@ -11,8 +11,8 @@ use embassy_executor::Executor;
use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3};
use embassy_stm32::time::mhz;
use embassy_stm32::{spi, Config};
use embassy_util::Forever;
use heapless::String;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
@ -27,7 +27,7 @@ async fn main_task(mut spi: spi::Spi<'static, SPI3, DMA1_CH3, DMA1_CH4>) {
}
}
static EXECUTOR: Forever<Executor> = Forever::new();
static EXECUTOR: StaticCell<Executor> = StaticCell::new();
#[entry]
fn main() -> ! {
@ -50,7 +50,7 @@ fn main() -> ! {
spi::Config::default(),
);
let executor = EXECUTOR.put(Executor::new());
let executor = EXECUTOR.init(Executor::new());
executor.run(|spawner| {
unwrap!(spawner.spawn(main_task(spi)));

View File

@ -7,7 +7,7 @@ use defmt::*;
use embassy_executor::Executor;
use embassy_stm32::dma::NoDma;
use embassy_stm32::usart::{Config, Uart};
use embassy_util::Forever;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
@ -27,13 +27,13 @@ async fn main_task() {
}
}
static EXECUTOR: Forever<Executor> = Forever::new();
static EXECUTOR: StaticCell<Executor> = StaticCell::new();
#[entry]
fn main() -> ! {
info!("Hello World!");
let executor = EXECUTOR.put(Executor::new());
let executor = EXECUTOR.init(Executor::new());
executor.run(|spawner| {
unwrap!(spawner.spawn(main_task()));

View File

@ -9,8 +9,8 @@ use defmt::*;
use embassy_executor::Executor;
use embassy_stm32::dma::NoDma;
use embassy_stm32::usart::{Config, Uart};
use embassy_util::Forever;
use heapless::String;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
@ -30,13 +30,13 @@ async fn main_task() {
}
}
static EXECUTOR: Forever<Executor> = Forever::new();
static EXECUTOR: StaticCell<Executor> = StaticCell::new();
#[entry]
fn main() -> ! {
info!("Hello World!");
let executor = EXECUTOR.put(Executor::new());
let executor = EXECUTOR.init(Executor::new());
executor.run(|spawner| {
unwrap!(spawner.spawn(main_task()));

View File

@ -7,8 +7,8 @@ use embassy_executor::Spawner;
use embassy_stm32::dma::NoDma;
use embassy_stm32::peripherals::{DMA1_CH1, UART7};
use embassy_stm32::usart::{Config, Uart, UartRx};
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::channel::mpmc::Channel;
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_sync::channel::Channel;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]

View File

@ -8,7 +8,7 @@ default = ["nightly"]
nightly = ["embassy-stm32/nightly", "embassy-lora", "lorawan-device", "lorawan", "embedded-io/async"]
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] }
@ -29,3 +29,4 @@ panic-probe = { version = "0.3", features = ["print-defmt"] }
futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
heapless = { version = "0.7.5", default-features = false }
embedded-hal = "0.2.6"
static_cell = "1.0"

View File

@ -8,7 +8,7 @@ use defmt::*;
use embassy_executor::raw::TaskStorage;
use embassy_executor::Executor;
use embassy_time::{Duration, Timer};
use embassy_util::Forever;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
async fn run1() {
@ -25,14 +25,14 @@ async fn run2() {
}
}
static EXECUTOR: Forever<Executor> = Forever::new();
static EXECUTOR: StaticCell<Executor> = StaticCell::new();
#[entry]
fn main() -> ! {
info!("Hello World!");
let _p = embassy_stm32::init(Default::default());
let executor = EXECUTOR.put(Executor::new());
let executor = EXECUTOR.init(Executor::new());
let run1_task = TaskStorage::new();
let run2_task = TaskStorage::new();

View File

@ -4,7 +4,7 @@ name = "embassy-stm32l1-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] }

View File

@ -6,7 +6,7 @@ version = "0.1.0"
[features]
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" }

View File

@ -6,7 +6,7 @@ version = "0.1.0"
[features]
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "unstable-traits", "memory-x"] }
@ -28,3 +28,4 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa
heapless = { version = "0.7.5", default-features = false }
rand_core = { version = "0.6.3", default-features = false }
embedded-io = { version = "0.3.0", features = ["async"] }
static_cell = "1.0"

View File

@ -15,22 +15,22 @@ use embassy_stm32::rng::Rng;
use embassy_stm32::time::Hertz;
use embassy_stm32::usb::Driver;
use embassy_stm32::{interrupt, Config};
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_sync::channel::Channel;
use embassy_usb::{Builder, UsbDevice};
use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State};
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
use embassy_util::channel::mpmc::Channel;
use embassy_util::Forever;
use embedded_io::asynch::{Read, Write};
use rand_core::RngCore;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
type MyDriver = Driver<'static, embassy_stm32::peripherals::USB>;
macro_rules! forever {
macro_rules! singleton {
($val:expr) => {{
type T = impl Sized;
static FOREVER: Forever<T> = Forever::new();
FOREVER.put_with(move || $val)
static STATIC_CELL: StaticCell<T> = StaticCell::new();
STATIC_CELL.init_with(move || $val)
}};
}
@ -115,7 +115,7 @@ async fn main(spawner: Spawner) {
control_buf: [u8; 128],
serial_state: State<'static>,
}
let res: &mut Resources = forever!(Resources {
let res: &mut Resources = singleton!(Resources {
device_descriptor: [0; 256],
config_descriptor: [0; 256],
bos_descriptor: [0; 256],
@ -171,10 +171,10 @@ async fn main(spawner: Spawner) {
// Init network stack
let device = Device { mac_addr: our_mac_addr };
let stack = &*forever!(Stack::new(
let stack = &*singleton!(Stack::new(
device,
config,
forever!(StackResources::<1, 2, 8>::new()),
singleton!(StackResources::<1, 2, 8>::new()),
seed
));

View File

@ -4,7 +4,7 @@ name = "embassy-stm32u5-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] }

View File

@ -4,7 +4,7 @@ name = "embassy-stm32wb-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55cc", "time-driver-any", "exti"] }

View File

@ -4,7 +4,7 @@ name = "embassy-stm32wl-examples"
version = "0.1.0"
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "subghz", "unstable-pac", "exti"] }

View File

@ -13,7 +13,7 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::interrupt;
use embassy_stm32::interrupt::{Interrupt, InterruptExt};
use embassy_stm32::subghz::*;
use embassy_util::channel::signal::Signal;
use embassy_sync::signal::Signal;
use {defmt_rtt as _, panic_probe as _};
const PING_DATA: &str = "PING";

View File

@ -7,7 +7,7 @@ version = "0.1.0"
crate-type = ["cdylib"]
[dependencies]
embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["log"] }
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["log"] }
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "wasm", "nightly", "integrated-timers"] }
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["log", "wasm", "nightly"] }
@ -15,4 +15,4 @@ wasm-logger = "0.2.0"
wasm-bindgen = "0.2"
web-sys = { version = "0.3", features = ["Document", "Element", "HtmlElement", "Node", "Window" ] }
log = "0.4.11"
critical-section = "1.1"
critical-section = { version = "1.1", features = ["std"] }

View File

@ -3,7 +3,7 @@
Examples use a CLI tool named `wasm-pack` to build this example:
```
cargo install wasm-pack
cargo install wasm-pack --version 0.9.1
```
## Building