From 18671b94ba173d6b5c2d2ec5e3569e39a03b61bb Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Mon, 8 Aug 2022 16:51:34 +0200 Subject: [PATCH 01/31] Implement embedded-nal-async traits for embassy-net --- embassy-net/Cargo.toml | 3 + embassy-net/src/tcp.rs | 167 ++++++++++++++++++++++++++++++++++++ examples/stm32h7/Cargo.toml | 2 +- 3 files changed, 171 insertions(+), 1 deletion(-) diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index 64cb5bd8..fface207 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml @@ -31,6 +31,7 @@ pool-16 = [] pool-32 = [] pool-64 = [] pool-128 = [] +unstable-traits = [] [dependencies] @@ -48,6 +49,8 @@ generic-array = { version = "0.14.4", default-features = false } stable_deref_trait = { version = "1.2.0", default-features = false } futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] } atomic-pool = "0.2.1" +atomic-polyfill = "0.1.5" +embedded-nal-async = "0.2.0" [dependencies.smoltcp] version = "0.8.0" diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index c18391ac..96a6dfe2 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs @@ -328,3 +328,170 @@ impl<'d> embedded_io::asynch::Write for TcpWriter<'d> { self.io.flush() } } + +#[cfg(feature = "unstable-traits")] +pub mod client { + use core::mem::MaybeUninit; + use core::ptr::NonNull; + + use atomic_polyfill::{AtomicBool, Ordering}; + use embedded_nal_async::IpAddr; + + use super::*; + + pub struct TcpClient<'d, D: Device, const N: usize, const TX_SZ: usize = 1024, const RX_SZ: usize = 1024> { + stack: &'d Stack, + tx: &'d BufferPool, + rx: &'d BufferPool, + } + + impl<'d, D: Device, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpClient<'d, D, N, TX_SZ, RX_SZ> { + pub fn new(stack: &'d Stack, tx: &'d BufferPool, rx: &'d BufferPool) -> Self { + Self { stack, tx, rx } + } + } + + impl<'d, D: Device, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_nal_async::TcpConnect + for TcpClient<'d, D, N, TX_SZ, RX_SZ> + { + type Error = Error; + type Connection<'m> = TcpConnection<'m, N, TX_SZ, RX_SZ> where Self: 'm; + type ConnectFuture<'m> = impl Future, Self::Error>> + 'm + where + Self: 'm; + + fn connect<'m>(&'m self, remote: embedded_nal_async::SocketAddr) -> Self::ConnectFuture<'m> { + async move { + let addr: crate::IpAddress = match remote.ip() { + IpAddr::V4(addr) => crate::IpAddress::Ipv4(crate::Ipv4Address::from_bytes(&addr.octets())), + #[cfg(feature = "proto-ipv6")] + IpAddr::V6(addr) => crate::IpAddress::Ipv6(crate::Ipv6Address::from_bytes(&addr.octets())), + #[cfg(not(feature = "proto-ipv6"))] + IpAddr::V6(_) => panic!("ipv6 support not enabled"), + }; + let remote_endpoint = (addr, remote.port()); + let mut socket = TcpConnection::new(&self.stack, self.tx, self.rx)?; + socket + .socket + .connect(remote_endpoint) + .await + .map_err(|_| Error::ConnectionReset)?; + Ok(socket) + } + } + } + + pub struct TcpConnection<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> { + socket: TcpSocket<'d>, + tx: &'d BufferPool, + rx: &'d BufferPool, + txb: NonNull<[u8; TX_SZ]>, + rxb: NonNull<[u8; RX_SZ]>, + } + + impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpConnection<'d, N, TX_SZ, RX_SZ> { + fn new( + stack: &'d Stack, + tx: &'d BufferPool, + rx: &'d BufferPool, + ) -> Result { + let mut txb = tx.alloc().ok_or(Error::ConnectionReset)?; + let mut rxb = rx.alloc().ok_or(Error::ConnectionReset)?; + Ok(Self { + socket: unsafe { TcpSocket::new(stack, rxb.as_mut(), txb.as_mut()) }, + tx, + rx, + txb, + rxb, + }) + } + } + + impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> Drop for TcpConnection<'d, N, TX_SZ, RX_SZ> { + fn drop(&mut self) { + unsafe { + self.socket.close(); + self.rx.free(self.rxb); + self.tx.free(self.txb); + } + } + } + + impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_io::Io + for TcpConnection<'d, N, TX_SZ, RX_SZ> + { + type Error = Error; + } + + impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_io::asynch::Read + for TcpConnection<'d, N, TX_SZ, RX_SZ> + { + type ReadFuture<'a> = impl Future> + where + Self: 'a; + + fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { + self.socket.read(buf) + } + } + + impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_io::asynch::Write + for TcpConnection<'d, N, TX_SZ, RX_SZ> + { + type WriteFuture<'a> = impl Future> + where + Self: 'a; + + fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { + self.socket.write(buf) + } + + type FlushFuture<'a> = impl Future> + where + Self: 'a; + + fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { + self.socket.flush() + } + } + + pub type BufferPool = Pool<[u8; BUFSZ], N>; + + pub struct Pool { + used: [AtomicBool; N], + data: [UnsafeCell>; N], + } + + impl Pool { + const VALUE: AtomicBool = AtomicBool::new(false); + const UNINIT: UnsafeCell> = UnsafeCell::new(MaybeUninit::uninit()); + + pub const fn new() -> Self { + Self { + used: [Self::VALUE; N], + data: [Self::UNINIT; N], + } + } + } + + impl Pool { + fn alloc(&self) -> Option> { + for n in 0..N { + if self.used[n].swap(true, Ordering::SeqCst) == false { + let p = self.data[n].get() as *mut T; + return Some(unsafe { NonNull::new_unchecked(p) }); + } + } + None + } + + /// safety: p must be a pointer obtained from self.alloc that hasn't been freed yet. + unsafe fn free(&self, p: NonNull) { + let origin = self.data.as_ptr() as *mut T; + let n = p.as_ptr().offset_from(origin); + assert!(n >= 0); + assert!((n as usize) < N); + self.used[n as usize].store(false, Ordering::SeqCst); + } + } +} diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 8b1999b3..07b7e493 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -7,7 +7,7 @@ version = "0.1.0" embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "time-tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "net", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } -embassy-net = { path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"] } +embassy-net = { path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16", "unstable-traits"] } embedded-io = { version = "0.3.0", features = ["async"] } defmt = "0.3" From 80c1551153b06a14e5dc475f6fbd945db06b8117 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Tue, 9 Aug 2022 14:43:55 +0200 Subject: [PATCH 02/31] Wrap buffers in a single state type --- embassy-net/src/tcp.rs | 53 +++++++++++++++++++++---------------- examples/stm32h7/Cargo.toml | 1 + 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index 96a6dfe2..814e7ab6 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs @@ -339,15 +339,16 @@ pub mod client { use super::*; + /// TCP client capable of creating up to N multiple connections with tx and rx buffers according to TX_SZ and RX_SZ. pub struct TcpClient<'d, D: Device, const N: usize, const TX_SZ: usize = 1024, const RX_SZ: usize = 1024> { stack: &'d Stack, - tx: &'d BufferPool, - rx: &'d BufferPool, + state: &'d TcpClientState, } impl<'d, D: Device, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpClient<'d, D, N, TX_SZ, RX_SZ> { - pub fn new(stack: &'d Stack, tx: &'d BufferPool, rx: &'d BufferPool) -> Self { - Self { stack, tx, rx } + /// Create a new TcpClient + pub fn new(stack: &'d Stack, state: &'d TcpClientState) -> Self { + Self { stack, state } } } @@ -370,7 +371,7 @@ pub mod client { IpAddr::V6(_) => panic!("ipv6 support not enabled"), }; let remote_endpoint = (addr, remote.port()); - let mut socket = TcpConnection::new(&self.stack, self.tx, self.rx)?; + let mut socket = TcpConnection::new(&self.stack, self.state)?; socket .socket .connect(remote_endpoint) @@ -383,26 +384,20 @@ pub mod client { pub struct TcpConnection<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> { socket: TcpSocket<'d>, - tx: &'d BufferPool, - rx: &'d BufferPool, - txb: NonNull<[u8; TX_SZ]>, - rxb: NonNull<[u8; RX_SZ]>, + state: &'d TcpClientState, + bufs: NonNull<([u8; TX_SZ], [u8; RX_SZ])>, } impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpConnection<'d, N, TX_SZ, RX_SZ> { fn new( stack: &'d Stack, - tx: &'d BufferPool, - rx: &'d BufferPool, + state: &'d TcpClientState, ) -> Result { - let mut txb = tx.alloc().ok_or(Error::ConnectionReset)?; - let mut rxb = rx.alloc().ok_or(Error::ConnectionReset)?; + let mut bufs = state.pool.alloc().ok_or(Error::ConnectionReset)?; Ok(Self { - socket: unsafe { TcpSocket::new(stack, rxb.as_mut(), txb.as_mut()) }, - tx, - rx, - txb, - rxb, + socket: unsafe { TcpSocket::new(stack, &mut bufs.as_mut().0, &mut bufs.as_mut().1) }, + state, + bufs, }) } } @@ -411,8 +406,7 @@ pub mod client { fn drop(&mut self) { unsafe { self.socket.close(); - self.rx.free(self.rxb); - self.tx.free(self.txb); + self.state.pool.free(self.bufs); } } } @@ -455,9 +449,22 @@ pub mod client { } } - pub type BufferPool = Pool<[u8; BUFSZ], N>; + /// State for TcpClient + pub struct TcpClientState { + pool: Pool<([u8; TX_SZ], [u8; RX_SZ]), N>, + } - pub struct Pool { + impl TcpClientState { + pub const fn new() -> Self { + Self { + pool: Pool::new() + } + } + } + + unsafe impl Sync for TcpClientState {} + + struct Pool { used: [AtomicBool; N], data: [UnsafeCell>; N], } @@ -466,7 +473,7 @@ pub mod client { const VALUE: AtomicBool = AtomicBool::new(false); const UNINIT: UnsafeCell> = UnsafeCell::new(MaybeUninit::uninit()); - pub const fn new() -> Self { + const fn new() -> Self { Self { used: [Self::VALUE; N], data: [Self::UNINIT; N], diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 07b7e493..89604675 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -18,6 +18,7 @@ cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } embedded-hal-async = { version = "0.1.0-alpha.1" } +embedded-nal-async = "0.2.0" 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 } From 2e76b13a4c5fcf46b3a9fc58ceef91e9317c12b7 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Tue, 9 Aug 2022 14:44:18 +0200 Subject: [PATCH 03/31] Add example using embedded-nal-async traits --- examples/stm32h7/src/bin/eth_client.rs | 125 +++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 examples/stm32h7/src/bin/eth_client.rs diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs new file mode 100644 index 00000000..a66c6f19 --- /dev/null +++ b/examples/stm32h7/src/bin/eth_client.rs @@ -0,0 +1,125 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use defmt::*; +use embassy_executor::executor::Spawner; +use embassy_executor::time::{Duration, Timer}; +use embassy_net::tcp::client::{TcpClient, TcpClientState}; +use embassy_net::{Stack, StackResources}; +use embassy_stm32::eth::generic_smi::GenericSMI; +use embassy_stm32::eth::{Ethernet, State}; +use embassy_stm32::peripherals::ETH; +use embassy_stm32::rng::Rng; +use embassy_stm32::time::mhz; +use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_util::Forever; +use embedded_io::asynch::Write; +use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; +use rand_core::RngCore; +use {defmt_rtt as _, panic_probe as _}; + +macro_rules! forever { + ($val:expr) => {{ + type T = impl Sized; + static FOREVER: Forever = Forever::new(); + FOREVER.put_with(move || $val) + }}; +} + +type Device = Ethernet<'static, ETH, GenericSMI, 4, 4>; + +#[embassy_executor::task] +async fn net_task(stack: &'static Stack) -> ! { + stack.run().await +} + +pub fn config() -> Config { + let mut config = Config::default(); + config.rcc.sys_ck = Some(mhz(400)); + config.rcc.hclk = Some(mhz(200)); + config.rcc.pll1.q_ck = Some(mhz(100)); + config +} + +#[embassy_executor::main(config = "config()")] +async fn main(spawner: Spawner, p: Peripherals) -> ! { + info!("Hello World!"); + + // Generate random seed. + let mut rng = Rng::new(p.RNG); + let mut seed = [0; 8]; + rng.fill_bytes(&mut seed); + let seed = u64::from_le_bytes(seed); + + let eth_int = interrupt::take!(ETH); + let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; + + let device = unsafe { + Ethernet::new( + forever!(State::new()), + p.ETH, + eth_int, + p.PA1, + p.PA2, + p.PC1, + p.PA7, + p.PC4, + p.PC5, + p.PG13, + p.PB13, + p.PG11, + GenericSMI, + mac_addr, + 0, + ) + }; + + let config = embassy_net::ConfigStrategy::Dhcp; + //let config = embassy_net::ConfigStrategy::Static(embassy_net::Config { + // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), + // dns_servers: Vec::new(), + // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), + //}); + + // Init network stack + let stack = &*forever!(Stack::new( + device, + config, + forever!(StackResources::<1, 2, 8>::new()), + seed + )); + + // Launch network task + unwrap!(spawner.spawn(net_task(&stack))); + + info!("Network task initialized"); + + // To ensure DHCP configuration before trying connect + Timer::after(Duration::from_secs(20)).await; + + static STATE: TcpClientState<1, 1024, 1024> = TcpClientState::new(); + let client = TcpClient::new(&stack, &STATE); + + loop { + let addr = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(10, 42, 0, 1), 8000)); + + info!("connecting..."); + let r = client.connect(addr).await; + if let Err(e) = r { + info!("connect error: {:?}", e); + Timer::after(Duration::from_secs(1)).await; + continue; + } + let mut connection = r.unwrap(); + info!("connected!"); + loop { + let r = connection.write_all(b"Hello\n").await; + if let Err(e) = r { + info!("write error: {:?}", e); + return; + } + Timer::after(Duration::from_secs(1)).await; + } + } +} From 87401c49b71eb22a4f1a9ce4b318ebd20ea38000 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Tue, 9 Aug 2022 14:51:32 +0200 Subject: [PATCH 04/31] Fix formatting --- embassy-net/src/tcp.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index 814e7ab6..2e276ecd 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs @@ -389,10 +389,7 @@ pub mod client { } impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpConnection<'d, N, TX_SZ, RX_SZ> { - fn new( - stack: &'d Stack, - state: &'d TcpClientState, - ) -> Result { + fn new(stack: &'d Stack, state: &'d TcpClientState) -> Result { let mut bufs = state.pool.alloc().ok_or(Error::ConnectionReset)?; Ok(Self { socket: unsafe { TcpSocket::new(stack, &mut bufs.as_mut().0, &mut bufs.as_mut().1) }, @@ -456,9 +453,7 @@ pub mod client { impl TcpClientState { pub const fn new() -> Self { - Self { - pool: Pool::new() - } + Self { pool: Pool::new() } } } From 6498324b58dd287d252482aaf377ad7e0b8c778b Mon Sep 17 00:00:00 2001 From: chemicstry Date: Tue, 9 Aug 2022 22:13:35 +0300 Subject: [PATCH 05/31] Implement I2C pullup configuration --- embassy-stm32/src/gpio.rs | 8 +++---- embassy-stm32/src/i2c/v1.rs | 23 +++++++++++++++++-- embassy-stm32/src/i2c/v2.rs | 23 +++++++++++++++++-- examples/stm32h7/src/bin/camera.rs | 11 ++++++++- examples/stm32l4/src/bin/i2c.rs | 11 ++++++++- .../stm32l4/src/bin/i2c_blocking_async.rs | 11 ++++++++- examples/stm32l4/src/bin/i2c_dma.rs | 11 ++++++++- 7 files changed, 86 insertions(+), 12 deletions(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 3c4cdb88..d794e398 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -213,7 +213,7 @@ impl<'d, T: Pin> Drop for Flex<'d, T> { } /// Pull setting for an input. -#[derive(Debug, Eq, PartialEq)] +#[derive(Debug, Eq, PartialEq, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Pull { None, @@ -235,7 +235,7 @@ impl From for vals::Pupdr { } /// Speed settings -#[derive(Debug)] +#[derive(Debug, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Speed { Low, @@ -303,7 +303,7 @@ impl<'d, T: Pin> Input<'d, T> { } /// Digital input or output level. -#[derive(Debug, Eq, PartialEq)] +#[derive(Debug, Eq, PartialEq, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Level { Low, @@ -470,7 +470,7 @@ pub(crate) mod sealed { use super::*; /// Alternate function type settings - #[derive(Debug)] + #[derive(Debug, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum AFType { Input, diff --git a/embassy-stm32/src/i2c/v1.rs b/embassy-stm32/src/i2c/v1.rs index 613815a9..5b3eb2f8 100644 --- a/embassy-stm32/src/i2c/v1.rs +++ b/embassy-stm32/src/i2c/v1.rs @@ -4,11 +4,24 @@ use embassy_embedded_hal::SetConfig; use embassy_hal_common::into_ref; use crate::gpio::sealed::AFType; +use crate::gpio::Pull; use crate::i2c::{Error, Instance, SclPin, SdaPin}; use crate::pac::i2c; use crate::time::Hertz; use crate::Peripheral; +#[non_exhaustive] +#[derive(Copy, Clone)] +pub struct Config { + pullup_enable: bool, +} + +impl Default for Config { + fn default() -> Self { + Self { pullup_enable: true } + } +} + pub struct State {} impl State { @@ -27,15 +40,21 @@ impl<'d, T: Instance> I2c<'d, T> { scl: impl Peripheral

> + 'd, sda: impl Peripheral

> + 'd, freq: Hertz, + config: Config, ) -> Self { into_ref!(scl, sda); T::enable(); T::reset(); + let pull = match config.pullup_enable { + true => Pull::Up, + false => Pull::None, + }; + unsafe { - scl.set_as_af(scl.af_num(), AFType::OutputOpenDrain); - sda.set_as_af(sda.af_num(), AFType::OutputOpenDrain); + scl.set_as_af_pull(scl.af_num(), AFType::OutputOpenDrain, pull); + sda.set_as_af_pull(sda.af_num(), AFType::OutputOpenDrain, pull); } unsafe { diff --git a/embassy-stm32/src/i2c/v2.rs b/embassy-stm32/src/i2c/v2.rs index f8067e8b..7c1033e0 100644 --- a/embassy-stm32/src/i2c/v2.rs +++ b/embassy-stm32/src/i2c/v2.rs @@ -10,12 +10,25 @@ use futures::future::poll_fn; use crate::dma::NoDma; use crate::gpio::sealed::AFType; +use crate::gpio::Pull; use crate::i2c::{Error, Instance, SclPin, SdaPin}; use crate::interrupt::InterruptExt; use crate::pac::i2c; use crate::time::Hertz; use crate::Peripheral; +#[non_exhaustive] +#[derive(Copy, Clone)] +pub struct Config { + pullup_enable: bool, +} + +impl Default for Config { + fn default() -> Self { + Self { pullup_enable: true } + } +} + pub struct State { waker: AtomicWaker, chunks_transferred: AtomicUsize, @@ -46,15 +59,21 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { tx_dma: impl Peripheral

+ 'd, rx_dma: impl Peripheral

+ 'd, freq: Hertz, + config: Config, ) -> Self { into_ref!(peri, irq, scl, sda, tx_dma, rx_dma); T::enable(); T::reset(); + let pull = match config.pullup_enable { + true => Pull::Up, + false => Pull::None, + }; + unsafe { - scl.set_as_af(scl.af_num(), AFType::OutputOpenDrain); - sda.set_as_af(sda.af_num(), AFType::OutputOpenDrain); + scl.set_as_af_pull(scl.af_num(), AFType::OutputOpenDrain, pull); + sda.set_as_af_pull(sda.af_num(), AFType::OutputOpenDrain, pull); } unsafe { diff --git a/examples/stm32h7/src/bin/camera.rs b/examples/stm32h7/src/bin/camera.rs index 69187182..a3bb2d5e 100644 --- a/examples/stm32h7/src/bin/camera.rs +++ b/examples/stm32h7/src/bin/camera.rs @@ -39,7 +39,16 @@ async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.PE3, Level::High, Speed::Low); let i2c_irq = interrupt::take!(I2C1_EV); - let cam_i2c = I2c::new(p.I2C1, p.PB8, p.PB9, i2c_irq, p.DMA1_CH1, p.DMA1_CH2, khz(100)); + let cam_i2c = I2c::new( + p.I2C1, + p.PB8, + p.PB9, + i2c_irq, + p.DMA1_CH1, + p.DMA1_CH2, + khz(100), + Default::default(), + ); let mut camera = Ov7725::new(cam_i2c, mco); diff --git a/examples/stm32l4/src/bin/i2c.rs b/examples/stm32l4/src/bin/i2c.rs index 058529ec..5bfa560d 100644 --- a/examples/stm32l4/src/bin/i2c.rs +++ b/examples/stm32l4/src/bin/i2c.rs @@ -16,7 +16,16 @@ const WHOAMI: u8 = 0x0F; #[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) -> ! { let irq = interrupt::take!(I2C2_EV); - let mut i2c = I2c::new(p.I2C2, p.PB10, p.PB11, irq, NoDma, NoDma, Hertz(100_000)); + let mut i2c = I2c::new( + p.I2C2, + p.PB10, + p.PB11, + irq, + NoDma, + NoDma, + Hertz(100_000), + Default::default(), + ); let mut data = [0u8; 1]; unwrap!(i2c.blocking_write_read(ADDRESS, &[WHOAMI], &mut data)); diff --git a/examples/stm32l4/src/bin/i2c_blocking_async.rs b/examples/stm32l4/src/bin/i2c_blocking_async.rs index 2dae9c2d..c924bc9c 100644 --- a/examples/stm32l4/src/bin/i2c_blocking_async.rs +++ b/examples/stm32l4/src/bin/i2c_blocking_async.rs @@ -18,7 +18,16 @@ const WHOAMI: u8 = 0x0F; #[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) -> ! { let irq = interrupt::take!(I2C2_EV); - let i2c = I2c::new(p.I2C2, p.PB10, p.PB11, irq, NoDma, NoDma, Hertz(100_000)); + let i2c = I2c::new( + p.I2C2, + p.PB10, + p.PB11, + irq, + NoDma, + NoDma, + Hertz(100_000), + Default::default(), + ); let mut i2c = BlockingAsync::new(i2c); let mut data = [0u8; 1]; diff --git a/examples/stm32l4/src/bin/i2c_dma.rs b/examples/stm32l4/src/bin/i2c_dma.rs index 9e71d404..2b338427 100644 --- a/examples/stm32l4/src/bin/i2c_dma.rs +++ b/examples/stm32l4/src/bin/i2c_dma.rs @@ -15,7 +15,16 @@ const WHOAMI: u8 = 0x0F; #[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) -> ! { let irq = interrupt::take!(I2C2_EV); - let mut i2c = I2c::new(p.I2C2, p.PB10, p.PB11, irq, p.DMA1_CH4, p.DMA1_CH5, Hertz(100_000)); + let mut i2c = I2c::new( + p.I2C2, + p.PB10, + p.PB11, + irq, + p.DMA1_CH4, + p.DMA1_CH5, + Hertz(100_000), + Default::default(), + ); let mut data = [0u8; 1]; unwrap!(i2c.write_read(ADDRESS, &[WHOAMI], &mut data).await); From 936473b68adb3a526846ff30233936dc3c52de25 Mon Sep 17 00:00:00 2001 From: chemicstry Date: Wed, 10 Aug 2022 12:36:15 +0300 Subject: [PATCH 06/31] Make sda/scl pullups separate as in nRF HAL --- embassy-stm32/src/i2c/v1.rs | 31 ++++++++++++++++++++++--------- embassy-stm32/src/i2c/v2.rs | 31 ++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/embassy-stm32/src/i2c/v1.rs b/embassy-stm32/src/i2c/v1.rs index 5b3eb2f8..9dc75789 100644 --- a/embassy-stm32/src/i2c/v1.rs +++ b/embassy-stm32/src/i2c/v1.rs @@ -13,12 +13,16 @@ use crate::Peripheral; #[non_exhaustive] #[derive(Copy, Clone)] pub struct Config { - pullup_enable: bool, + pub sda_pullup: bool, + pub scl_pullup: bool, } impl Default for Config { fn default() -> Self { - Self { pullup_enable: true } + Self { + sda_pullup: false, + scl_pullup: false, + } } } @@ -47,14 +51,23 @@ impl<'d, T: Instance> I2c<'d, T> { T::enable(); T::reset(); - let pull = match config.pullup_enable { - true => Pull::Up, - false => Pull::None, - }; - unsafe { - scl.set_as_af_pull(scl.af_num(), AFType::OutputOpenDrain, pull); - sda.set_as_af_pull(sda.af_num(), AFType::OutputOpenDrain, pull); + scl.set_as_af_pull( + scl.af_num(), + AFType::OutputOpenDrain, + match config.scl_pullup { + true => Pull::Up, + false => Pull::None, + }, + ); + sda.set_as_af_pull( + sda.af_num(), + AFType::OutputOpenDrain, + match config.sda_pullup { + true => Pull::Up, + false => Pull::None, + }, + ); } unsafe { diff --git a/embassy-stm32/src/i2c/v2.rs b/embassy-stm32/src/i2c/v2.rs index 7c1033e0..b4303d3d 100644 --- a/embassy-stm32/src/i2c/v2.rs +++ b/embassy-stm32/src/i2c/v2.rs @@ -20,12 +20,16 @@ use crate::Peripheral; #[non_exhaustive] #[derive(Copy, Clone)] pub struct Config { - pullup_enable: bool, + pub sda_pullup: bool, + pub scl_pullup: bool, } impl Default for Config { fn default() -> Self { - Self { pullup_enable: true } + Self { + sda_pullup: false, + scl_pullup: false, + } } } @@ -66,14 +70,23 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { T::enable(); T::reset(); - let pull = match config.pullup_enable { - true => Pull::Up, - false => Pull::None, - }; - unsafe { - scl.set_as_af_pull(scl.af_num(), AFType::OutputOpenDrain, pull); - sda.set_as_af_pull(sda.af_num(), AFType::OutputOpenDrain, pull); + scl.set_as_af_pull( + scl.af_num(), + AFType::OutputOpenDrain, + match config.scl_pullup { + true => Pull::Up, + false => Pull::None, + }, + ); + sda.set_as_af_pull( + sda.af_num(), + AFType::OutputOpenDrain, + match config.sda_pullup { + true => Pull::Up, + false => Pull::None, + }, + ); } unsafe { From d5ab0d3ebb119c7ffd95da4b67325f75cae05b7e Mon Sep 17 00:00:00 2001 From: Artur Kowalski Date: Thu, 28 Jul 2022 10:25:47 +0200 Subject: [PATCH 07/31] Add UDP socket support --- embassy-net/Cargo.toml | 1 + embassy-net/src/lib.rs | 5 + embassy-net/src/udp.rs | 227 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 233 insertions(+) create mode 100644 embassy-net/src/udp.rs diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index fface207..e4d8c2c2 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml @@ -18,6 +18,7 @@ std = [] defmt = ["dep:defmt", "smoltcp/defmt"] +udp = ["smoltcp/socket-udp"] tcp = ["smoltcp/socket-tcp"] dns = ["smoltcp/socket-dns"] dhcpv4 = ["medium-ethernet", "smoltcp/socket-dhcpv4"] diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs index 1c5ba103..83d36471 100644 --- a/embassy-net/src/lib.rs +++ b/embassy-net/src/lib.rs @@ -16,6 +16,9 @@ pub use stack::{Config, ConfigStrategy, Stack, StackResources}; #[cfg(feature = "tcp")] pub mod tcp; +#[cfg(feature = "udp")] +pub mod udp; + // smoltcp reexports pub use smoltcp::phy::{DeviceCapabilities, Medium}; pub use smoltcp::time::{Duration as SmolDuration, Instant as SmolInstant}; @@ -24,3 +27,5 @@ pub use smoltcp::wire::{EthernetAddress, HardwareAddress}; pub use smoltcp::wire::{IpAddress, IpCidr, Ipv4Address, Ipv4Cidr}; #[cfg(feature = "proto-ipv6")] pub use smoltcp::wire::{Ipv6Address, Ipv6Cidr}; +#[cfg(feature = "udp")] +pub use smoltcp::{socket::udp::PacketMetadata, wire::IpListenEndpoint}; diff --git a/embassy-net/src/udp.rs b/embassy-net/src/udp.rs new file mode 100644 index 00000000..6b15805c --- /dev/null +++ b/embassy-net/src/udp.rs @@ -0,0 +1,227 @@ +use core::cell::UnsafeCell; +use core::mem; +use core::task::Poll; + +use futures::future::poll_fn; +use smoltcp::iface::{Interface, SocketHandle}; +use smoltcp::socket::udp::{self, PacketMetadata}; +use smoltcp::wire::{IpEndpoint, IpListenEndpoint}; + +use super::stack::SocketStack; +use crate::{Device, Stack}; + +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +pub enum BindError { + /// The socket was already open. + InvalidState, + /// No route to host. + NoRoute, +} + +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +pub enum Error { + /// No route to host. + NoRoute, +} + +pub struct UdpSocket<'a> { + io: UdpIo<'a>, +} + +pub struct UdpReader<'a> { + io: UdpIo<'a>, +} + +pub struct UdpWriter<'a> { + io: UdpIo<'a>, +} + +impl<'a> UdpSocket<'a> { + pub fn new( + stack: &'a Stack, + rx_meta: &'a mut [PacketMetadata], + rx_buffer: &'a mut [u8], + tx_meta: &'a mut [PacketMetadata], + tx_buffer: &'a mut [u8], + ) -> Self { + // safety: not accessed reentrantly. + let s = unsafe { &mut *stack.socket.get() }; + + let rx_meta: &'static mut [PacketMetadata] = unsafe { mem::transmute(rx_meta) }; + let rx_buffer: &'static mut [u8] = unsafe { mem::transmute(rx_buffer) }; + let tx_meta: &'static mut [PacketMetadata] = unsafe { mem::transmute(tx_meta) }; + let tx_buffer: &'static mut [u8] = unsafe { mem::transmute(tx_buffer) }; + let handle = s.sockets.add(udp::Socket::new( + udp::PacketBuffer::new(rx_meta, rx_buffer), + udp::PacketBuffer::new(tx_meta, tx_buffer), + )); + + Self { + io: UdpIo { + stack: &stack.socket, + handle, + }, + } + } + + pub fn split(&mut self) -> (UdpReader<'_>, UdpWriter<'_>) { + (UdpReader { io: self.io }, UdpWriter { io: self.io }) + } + + pub fn bind(&mut self, endpoint: T) -> Result<(), BindError> + where + T: Into, + { + let mut endpoint = endpoint.into(); + + // safety: not accessed reentrantly. + if endpoint.port == 0 { + // If user didn't specify port allocate a dynamic port. + endpoint.port = unsafe { &mut *self.io.stack.get() }.get_local_port(); + } + + // safety: not accessed reentrantly. + match unsafe { self.io.with_mut(|s, _| s.bind(endpoint)) } { + Ok(()) => Ok(()), + Err(udp::BindError::InvalidState) => Err(BindError::InvalidState), + Err(udp::BindError::Unaddressable) => Err(BindError::NoRoute), + } + } + + pub async fn send_to(&mut self, buf: &[u8], remote_endpoint: T) -> Result<(), Error> + where + T: Into, + { + self.io.write(buf, remote_endpoint.into()).await + } + + pub async fn recv_from(&mut self, buf: &mut [u8]) -> Result<(usize, IpEndpoint), Error> { + self.io.read(buf).await + } + + pub async fn flush(&mut self) -> Result<(), Error> { + self.io.flush().await + } + + pub fn endpoint(&self) -> IpListenEndpoint { + unsafe { self.io.with(|s, _| s.endpoint()) } + } + + pub fn is_open(&self) -> bool { + unsafe { self.io.with(|s, _| s.is_open()) } + } + + pub fn close(&mut self) { + unsafe { self.io.with_mut(|s, _| s.close()) } + } + + pub fn may_send(&self) -> bool { + unsafe { self.io.with(|s, _| s.can_send()) } + } + + pub fn may_recv(&self) -> bool { + unsafe { self.io.with(|s, _| s.can_recv()) } + } +} + +impl Drop for UdpSocket<'_> { + fn drop(&mut self) { + // safety: not accessed reentrantly. + let s = unsafe { &mut *self.io.stack.get() }; + s.sockets.remove(self.io.handle); + } +} + +#[derive(Copy, Clone)] +pub struct UdpIo<'a> { + stack: &'a UnsafeCell, + handle: SocketHandle, +} + +impl UdpIo<'_> { + /// SAFETY: must not call reentrantly. + unsafe fn with(&self, f: impl FnOnce(&udp::Socket, &Interface) -> R) -> R { + let s = &*self.stack.get(); + let socket = s.sockets.get::(self.handle); + f(socket, &s.iface) + } + + /// SAFETY: must not call reentrantly. + unsafe fn with_mut(&mut self, f: impl FnOnce(&mut udp::Socket, &mut Interface) -> R) -> R { + let s = &mut *self.stack.get(); + let socket = s.sockets.get_mut::(self.handle); + let res = f(socket, &mut s.iface); + s.waker.wake(); + res + } + + async fn read(&mut self, buf: &mut [u8]) -> Result<(usize, IpEndpoint), Error> { + poll_fn(move |cx| unsafe { + self.with_mut(|s, _| match s.recv_slice(buf) { + Ok(x) => Poll::Ready(Ok(x)), + // No data ready + Err(udp::RecvError::Exhausted) => { + //s.register_recv_waker(cx.waker()); + cx.waker().wake_by_ref(); + Poll::Pending + } + }) + }) + .await + } + + async fn write(&mut self, buf: &[u8], ep: IpEndpoint) -> Result<(), Error> { + poll_fn(move |cx| unsafe { + self.with_mut(|s, _| match s.send_slice(buf, ep) { + // Entire datagram has been sent + Ok(()) => Poll::Ready(Ok(())), + Err(udp::SendError::BufferFull) => { + s.register_send_waker(cx.waker()); + Poll::Pending + } + Err(udp::SendError::Unaddressable) => Poll::Ready(Err(Error::NoRoute)), + }) + }) + .await + } + + async fn flush(&mut self) -> Result<(), Error> { + poll_fn(move |_| { + Poll::Ready(Ok(())) // TODO: Is there a better implementation for this? + }) + .await + } +} + +impl UdpReader<'_> { + pub async fn recv_from(&mut self, buf: &mut [u8]) -> Result<(usize, IpEndpoint), Error> { + self.io.read(buf).await + } +} + +impl UdpWriter<'_> { + pub async fn send_to(&mut self, buf: &[u8], remote_endpoint: T) -> Result<(), Error> + where + T: Into, + { + self.io.write(buf, remote_endpoint.into()).await + } + + pub async fn flush(&mut self) -> Result<(), Error> { + self.io.flush().await + } +} + +impl embedded_io::Error for BindError { + fn kind(&self) -> embedded_io::ErrorKind { + embedded_io::ErrorKind::Other + } +} + +impl embedded_io::Error for Error { + fn kind(&self) -> embedded_io::ErrorKind { + embedded_io::ErrorKind::Other + } +} From 865a91976c5b6b5c45b37e0286e7c328e8404dde Mon Sep 17 00:00:00 2001 From: Artur Kowalski Date: Wed, 10 Aug 2022 19:38:34 +0200 Subject: [PATCH 08/31] Add UDP example app --- examples/std/Cargo.toml | 2 +- examples/std/src/bin/net_udp.rs | 109 ++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 examples/std/src/bin/net_udp.rs diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 54499796..427b9343 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml @@ -6,7 +6,7 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["log"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "std", "time", "nightly"] } -embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "log", "medium-ethernet", "tcp", "dhcpv4", "pool-16"] } +embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "log", "medium-ethernet", "tcp", "udp", "dhcpv4", "pool-16"] } embedded-io = { version = "0.3.0", features = ["async", "std", "futures"] } async-io = "1.6.0" diff --git a/examples/std/src/bin/net_udp.rs b/examples/std/src/bin/net_udp.rs new file mode 100644 index 00000000..7fe36e23 --- /dev/null +++ b/examples/std/src/bin/net_udp.rs @@ -0,0 +1,109 @@ +#![feature(type_alias_impl_trait)] + +use clap::Parser; +use embassy_executor::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}; + +#[path = "../tuntap.rs"] +mod tuntap; + +use crate::tuntap::TunTapDevice; + +macro_rules! forever { + ($val:expr) => {{ + type T = impl Sized; + static FOREVER: Forever = Forever::new(); + FOREVER.put_with(move || $val) + }}; +} + +#[derive(Parser)] +#[clap(version = "1.0")] +struct Opts { + /// TAP device name + #[clap(long, default_value = "tap0")] + tap: String, + /// use a static IP instead of DHCP + #[clap(long)] + static_ip: bool, +} + +#[embassy_executor::task] +async fn net_task(stack: &'static Stack) -> ! { + stack.run().await +} + +#[embassy_executor::task] +async fn main_task(spawner: Spawner) { + let opts: Opts = Opts::parse(); + + // Init network device + let device = TunTapDevice::new(&opts.tap).unwrap(); + + // Choose between dhcp or static ip + let config = if opts.static_ip { + ConfigStrategy::Static(embassy_net::Config { + address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), + dns_servers: Vec::new(), + gateway: Some(Ipv4Address::new(192, 168, 69, 1)), + }) + } else { + ConfigStrategy::Dhcp + }; + + // Generate random seed + let mut seed = [0; 8]; + OsRng.fill_bytes(&mut seed); + let seed = u64::from_le_bytes(seed); + + // Init network stack + let stack = &*forever!(Stack::new( + device, + config, + forever!(StackResources::<1, 2, 8>::new()), + seed + )); + + // Launch network task + spawner.spawn(net_task(stack)).unwrap(); + + // Then we can use it! + let mut rx_meta = [PacketMetadata::EMPTY; 16]; + let mut rx_buffer = [0; 4096]; + let mut tx_meta = [PacketMetadata::EMPTY; 16]; + let mut tx_buffer = [0; 4096]; + let mut buf = [0; 4096]; + + let mut socket = UdpSocket::new(stack, &mut rx_meta, &mut rx_buffer, &mut tx_meta, &mut tx_buffer); + socket.bind(9400).unwrap(); + + loop { + let (n, ep) = socket.recv_from(&mut buf).await.unwrap(); + if let Ok(s) = core::str::from_utf8(&buf[..n]) { + info!("ECHO (to {}): {}", ep, s); + } else { + info!("ECHO (to {}): bytearray len {}", ep, n); + } + socket.send_to(&buf[..n], ep).await.unwrap(); + } +} + +static EXECUTOR: Forever = Forever::new(); + +fn main() { + env_logger::builder() + .filter_level(log::LevelFilter::Debug) + .filter_module("async_io", log::LevelFilter::Info) + .format_timestamp_nanos() + .init(); + + let executor = EXECUTOR.put(Executor::new()); + executor.run(|spawner| { + spawner.spawn(main_task(spawner)).unwrap(); + }); +} From b97983242d16a321bab8c13f9df4c8af99d89a0f Mon Sep 17 00:00:00 2001 From: Artur Kowalski Date: Thu, 11 Aug 2022 08:23:18 +0200 Subject: [PATCH 09/31] Simplify UDP code Drop unneeded APIs: remove impls of embedded_io error traits, remove flush() and split() methods. --- embassy-net/src/udp.rs | 64 ++++-------------------------------------- 1 file changed, 5 insertions(+), 59 deletions(-) diff --git a/embassy-net/src/udp.rs b/embassy-net/src/udp.rs index 6b15805c..ee90c301 100644 --- a/embassy-net/src/udp.rs +++ b/embassy-net/src/udp.rs @@ -30,14 +30,6 @@ pub struct UdpSocket<'a> { io: UdpIo<'a>, } -pub struct UdpReader<'a> { - io: UdpIo<'a>, -} - -pub struct UdpWriter<'a> { - io: UdpIo<'a>, -} - impl<'a> UdpSocket<'a> { pub fn new( stack: &'a Stack, @@ -66,10 +58,6 @@ impl<'a> UdpSocket<'a> { } } - pub fn split(&mut self) -> (UdpReader<'_>, UdpWriter<'_>) { - (UdpReader { io: self.io }, UdpWriter { io: self.io }) - } - pub fn bind(&mut self, endpoint: T) -> Result<(), BindError> where T: Into, @@ -90,21 +78,17 @@ impl<'a> UdpSocket<'a> { } } - pub async fn send_to(&mut self, buf: &[u8], remote_endpoint: T) -> Result<(), Error> + pub async fn send_to(&self, buf: &[u8], remote_endpoint: T) -> Result<(), Error> where T: Into, { self.io.write(buf, remote_endpoint.into()).await } - pub async fn recv_from(&mut self, buf: &mut [u8]) -> Result<(usize, IpEndpoint), Error> { + pub async fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, IpEndpoint), Error> { self.io.read(buf).await } - pub async fn flush(&mut self) -> Result<(), Error> { - self.io.flush().await - } - pub fn endpoint(&self) -> IpListenEndpoint { unsafe { self.io.with(|s, _| s.endpoint()) } } @@ -149,7 +133,7 @@ impl UdpIo<'_> { } /// SAFETY: must not call reentrantly. - unsafe fn with_mut(&mut self, f: impl FnOnce(&mut udp::Socket, &mut Interface) -> R) -> R { + unsafe fn with_mut(&self, f: impl FnOnce(&mut udp::Socket, &mut Interface) -> R) -> R { let s = &mut *self.stack.get(); let socket = s.sockets.get_mut::(self.handle); let res = f(socket, &mut s.iface); @@ -157,7 +141,7 @@ impl UdpIo<'_> { res } - async fn read(&mut self, buf: &mut [u8]) -> Result<(usize, IpEndpoint), Error> { + async fn read(&self, buf: &mut [u8]) -> Result<(usize, IpEndpoint), Error> { poll_fn(move |cx| unsafe { self.with_mut(|s, _| match s.recv_slice(buf) { Ok(x) => Poll::Ready(Ok(x)), @@ -172,7 +156,7 @@ impl UdpIo<'_> { .await } - async fn write(&mut self, buf: &[u8], ep: IpEndpoint) -> Result<(), Error> { + async fn write(&self, buf: &[u8], ep: IpEndpoint) -> Result<(), Error> { poll_fn(move |cx| unsafe { self.with_mut(|s, _| match s.send_slice(buf, ep) { // Entire datagram has been sent @@ -186,42 +170,4 @@ impl UdpIo<'_> { }) .await } - - async fn flush(&mut self) -> Result<(), Error> { - poll_fn(move |_| { - Poll::Ready(Ok(())) // TODO: Is there a better implementation for this? - }) - .await - } -} - -impl UdpReader<'_> { - pub async fn recv_from(&mut self, buf: &mut [u8]) -> Result<(usize, IpEndpoint), Error> { - self.io.read(buf).await - } -} - -impl UdpWriter<'_> { - pub async fn send_to(&mut self, buf: &[u8], remote_endpoint: T) -> Result<(), Error> - where - T: Into, - { - self.io.write(buf, remote_endpoint.into()).await - } - - pub async fn flush(&mut self) -> Result<(), Error> { - self.io.flush().await - } -} - -impl embedded_io::Error for BindError { - fn kind(&self) -> embedded_io::ErrorKind { - embedded_io::ErrorKind::Other - } -} - -impl embedded_io::Error for Error { - fn kind(&self) -> embedded_io::ErrorKind { - embedded_io::ErrorKind::Other - } } From 0a98f9f48ef11f36bb1ed5c8adbe07611916ba0b Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 11 Aug 2022 13:58:13 +0200 Subject: [PATCH 10/31] net: make TcpIo private. It's just an implementation detail to share code between Socket, Reader, Writer. It wasn't supposed to be public. --- embassy-net/src/tcp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index 2e276ecd..910772c7 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs @@ -181,7 +181,7 @@ impl<'a> Drop for TcpSocket<'a> { // ======================= #[derive(Copy, Clone)] -pub struct TcpIo<'a> { +struct TcpIo<'a> { stack: &'a UnsafeCell, handle: SocketHandle, } From ef473827a2beaca120f45fbe490f84a0be7d381d Mon Sep 17 00:00:00 2001 From: Artur Kowalski Date: Thu, 11 Aug 2022 15:52:32 +0200 Subject: [PATCH 11/31] Remove UdpIo struct UdpIo was shared by split sender/receives halves. Since split() API is no more UdpIo is not needed and its APIs may be moved into UdpSocket. --- embassy-net/src/udp.rs | 98 ++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 57 deletions(-) diff --git a/embassy-net/src/udp.rs b/embassy-net/src/udp.rs index ee90c301..78b09a49 100644 --- a/embassy-net/src/udp.rs +++ b/embassy-net/src/udp.rs @@ -27,7 +27,8 @@ pub enum Error { } pub struct UdpSocket<'a> { - io: UdpIo<'a>, + stack: &'a UnsafeCell, + handle: SocketHandle, } impl<'a> UdpSocket<'a> { @@ -51,10 +52,8 @@ impl<'a> UdpSocket<'a> { )); Self { - io: UdpIo { - stack: &stack.socket, - handle, - }, + stack: &stack.socket, + handle, } } @@ -67,64 +66,17 @@ impl<'a> UdpSocket<'a> { // safety: not accessed reentrantly. if endpoint.port == 0 { // If user didn't specify port allocate a dynamic port. - endpoint.port = unsafe { &mut *self.io.stack.get() }.get_local_port(); + endpoint.port = unsafe { &mut *self.stack.get() }.get_local_port(); } // safety: not accessed reentrantly. - match unsafe { self.io.with_mut(|s, _| s.bind(endpoint)) } { + match unsafe { self.with_mut(|s, _| s.bind(endpoint)) } { Ok(()) => Ok(()), Err(udp::BindError::InvalidState) => Err(BindError::InvalidState), Err(udp::BindError::Unaddressable) => Err(BindError::NoRoute), } } - pub async fn send_to(&self, buf: &[u8], remote_endpoint: T) -> Result<(), Error> - where - T: Into, - { - self.io.write(buf, remote_endpoint.into()).await - } - - pub async fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, IpEndpoint), Error> { - self.io.read(buf).await - } - - pub fn endpoint(&self) -> IpListenEndpoint { - unsafe { self.io.with(|s, _| s.endpoint()) } - } - - pub fn is_open(&self) -> bool { - unsafe { self.io.with(|s, _| s.is_open()) } - } - - pub fn close(&mut self) { - unsafe { self.io.with_mut(|s, _| s.close()) } - } - - pub fn may_send(&self) -> bool { - unsafe { self.io.with(|s, _| s.can_send()) } - } - - pub fn may_recv(&self) -> bool { - unsafe { self.io.with(|s, _| s.can_recv()) } - } -} - -impl Drop for UdpSocket<'_> { - fn drop(&mut self) { - // safety: not accessed reentrantly. - let s = unsafe { &mut *self.io.stack.get() }; - s.sockets.remove(self.io.handle); - } -} - -#[derive(Copy, Clone)] -pub struct UdpIo<'a> { - stack: &'a UnsafeCell, - handle: SocketHandle, -} - -impl UdpIo<'_> { /// SAFETY: must not call reentrantly. unsafe fn with(&self, f: impl FnOnce(&udp::Socket, &Interface) -> R) -> R { let s = &*self.stack.get(); @@ -141,7 +93,7 @@ impl UdpIo<'_> { res } - async fn read(&self, buf: &mut [u8]) -> Result<(usize, IpEndpoint), Error> { + pub async fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, IpEndpoint), Error> { poll_fn(move |cx| unsafe { self.with_mut(|s, _| match s.recv_slice(buf) { Ok(x) => Poll::Ready(Ok(x)), @@ -156,9 +108,13 @@ impl UdpIo<'_> { .await } - async fn write(&self, buf: &[u8], ep: IpEndpoint) -> Result<(), Error> { + pub async fn send_to(&self, buf: &[u8], remote_endpoint: T) -> Result<(), Error> + where + T: Into, + { + let remote_endpoint = remote_endpoint.into(); poll_fn(move |cx| unsafe { - self.with_mut(|s, _| match s.send_slice(buf, ep) { + self.with_mut(|s, _| match s.send_slice(buf, remote_endpoint) { // Entire datagram has been sent Ok(()) => Poll::Ready(Ok(())), Err(udp::SendError::BufferFull) => { @@ -170,4 +126,32 @@ impl UdpIo<'_> { }) .await } + + pub fn endpoint(&self) -> IpListenEndpoint { + unsafe { self.with(|s, _| s.endpoint()) } + } + + pub fn is_open(&self) -> bool { + unsafe { self.with(|s, _| s.is_open()) } + } + + pub fn close(&mut self) { + unsafe { self.with_mut(|s, _| s.close()) } + } + + pub fn may_send(&self) -> bool { + unsafe { self.with(|s, _| s.can_send()) } + } + + pub fn may_recv(&self) -> bool { + unsafe { self.with(|s, _| s.can_recv()) } + } +} + +impl Drop for UdpSocket<'_> { + fn drop(&mut self) { + // safety: not accessed reentrantly. + let s = unsafe { &mut *self.stack.get() }; + s.sockets.remove(self.handle); + } } From f53367d8ba50c96e510495113ced82c8e2dcf671 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 15 Aug 2022 15:42:48 +0200 Subject: [PATCH 12/31] embassy-docs fixes. --- embassy-embedded-hal/Cargo.toml | 10 ++++++++++ embassy-usb-hid/Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/embassy-embedded-hal/Cargo.toml b/embassy-embedded-hal/Cargo.toml index f245783c..698d6582 100644 --- a/embassy-embedded-hal/Cargo.toml +++ b/embassy-embedded-hal/Cargo.toml @@ -3,6 +3,16 @@ name = "embassy-embedded-hal" version = "0.1.0" edition = "2021" + +[package.metadata.embassy_docs] +src_base = "https://github.com/embassy-rs/embassy/blob/embassy-embedded-hal-v$VERSION/embassy-embedded-hal/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-embedded-hal/src/" +features = ["nightly"] +flavors = [ + { name = "default", target = "x86_64-unknown-linux-gnu", features = ["std"] }, +] + + [features] std = [] # Enable nightly-only features diff --git a/embassy-usb-hid/Cargo.toml b/embassy-usb-hid/Cargo.toml index 53b6db3d..e4315714 100644 --- a/embassy-usb-hid/Cargo.toml +++ b/embassy-usb-hid/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-usb-hid-v$VERSION/embassy-usb-hid/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-usb-hid/src/" -features = ["defmt", "embassy-executor/time-tick-1mhz"] +features = ["defmt"] flavors = [ { name = "default", target = "thumbv7em-none-eabihf" }, ] From 17b9eb5f86fe35a0951d90752fd99ca2d63783cb Mon Sep 17 00:00:00 2001 From: Bob McWhirter Date: Mon, 15 Aug 2022 11:07:46 -0400 Subject: [PATCH 13/31] Update signal.rs Allow `poll_wait` to be public so higher-order futures around Signal can be built. --- embassy-util/src/channel/signal.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-util/src/channel/signal.rs b/embassy-util/src/channel/signal.rs index a58469c4..ff53934e 100644 --- a/embassy-util/src/channel/signal.rs +++ b/embassy-util/src/channel/signal.rs @@ -69,7 +69,7 @@ impl Signal { }) } - fn poll_wait(&self, cx: &mut Context<'_>) -> Poll { + pub fn poll_wait(&self, cx: &mut Context<'_>) -> Poll { critical_section::with(|_| unsafe { let state = &mut *self.state.get(); match state { From b273128990f1bab01925d10f221f0e2f8dab2590 Mon Sep 17 00:00:00 2001 From: Bob McWhirter Date: Mon, 15 Aug 2022 11:20:35 -0400 Subject: [PATCH 14/31] Add documentation to Signal::poll_wait(..). --- embassy-util/src/channel/signal.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/embassy-util/src/channel/signal.rs b/embassy-util/src/channel/signal.rs index ff53934e..05889f5a 100644 --- a/embassy-util/src/channel/signal.rs +++ b/embassy-util/src/channel/signal.rs @@ -69,6 +69,7 @@ impl Signal { }) } + /// Manually poll the Signal future. pub fn poll_wait(&self, cx: &mut Context<'_>) -> Poll { critical_section::with(|_| unsafe { let state = &mut *self.state.get(); From b4ab39c6fa4b7469fdf5f36f610d40ccfc965fec Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Mon, 15 Aug 2022 19:37:48 +0200 Subject: [PATCH 15/31] Use special ROOT component for embassy docs --- docs/antora.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/antora.yml b/docs/antora.yml index 807c97c3..9a00fa82 100644 --- a/docs/antora.yml +++ b/docs/antora.yml @@ -1,4 +1,4 @@ -name: embassy +name: ROOT title: Embassy version: dev nav: From dff6847e9c77fa658bea95ba16c11519f0506800 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 15 Aug 2022 20:40:41 +0200 Subject: [PATCH 16/31] Add -boot docserver metadata. --- .vscode/settings.json | 2 -- embassy-boot/boot/Cargo.toml | 5 +++++ embassy-boot/nrf/Cargo.toml | 6 ++++++ embassy-boot/stm32/Cargo.toml | 6 ++++++ embassy-embedded-hal/Cargo.toml | 7 ++----- embassy-usb-hid/Cargo.toml | 4 +--- embassy-usb-ncm/Cargo.toml | 4 +--- embassy-usb-serial/Cargo.toml | 4 +--- embassy-usb/Cargo.toml | 4 +--- embassy-util/Cargo.toml | 4 +--- 10 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 1ac3fc51..d6ce75c9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,9 +1,7 @@ { "editor.formatOnSave": true, - "rust-analyzer.checkOnSave.allFeatures": false, "rust-analyzer.checkOnSave.allTargets": false, "rust-analyzer.checkOnSave.noDefaultFeatures": true, - "rust-analyzer.cargo.allFeatures": false, "rust-analyzer.cargo.noDefaultFeatures": true, "rust-analyzer.procMacro.enable": true, "rust-analyzer.cargo.target": "thumbv7em-none-eabi", diff --git a/embassy-boot/boot/Cargo.toml b/embassy-boot/boot/Cargo.toml index abb7bb5c..9c2e72be 100644 --- a/embassy-boot/boot/Cargo.toml +++ b/embassy-boot/boot/Cargo.toml @@ -4,6 +4,11 @@ name = "embassy-boot" version = "0.1.0" description = "Bootloader using Embassy" +[package.metadata.embassy_docs] +src_base = "https://github.com/embassy-rs/embassy/blob/embassy-boot-v$VERSION/embassy-boot/boot/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-boot/boot/src/" +target = "thumbv7em-none-eabi" + [lib] [dependencies] diff --git a/embassy-boot/nrf/Cargo.toml b/embassy-boot/nrf/Cargo.toml index 5dc3ce52..4db6892b 100644 --- a/embassy-boot/nrf/Cargo.toml +++ b/embassy-boot/nrf/Cargo.toml @@ -4,6 +4,12 @@ name = "embassy-boot-nrf" version = "0.1.0" description = "Bootloader lib for nRF chips" +[package.metadata.embassy_docs] +src_base = "https://github.com/embassy-rs/embassy/blob/embassy-boot-nrf-v$VERSION/embassy-boot/nrf/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-boot/nrf/src/" +features = ["embassy-nrf/nrf52840"] +target = "thumbv7em-none-eabi" + [lib] [dependencies] diff --git a/embassy-boot/stm32/Cargo.toml b/embassy-boot/stm32/Cargo.toml index eab8d160..f891f769 100644 --- a/embassy-boot/stm32/Cargo.toml +++ b/embassy-boot/stm32/Cargo.toml @@ -4,6 +4,12 @@ name = "embassy-boot-stm32" version = "0.1.0" description = "Bootloader lib for STM32 chips" +[package.metadata.embassy_docs] +src_base = "https://github.com/embassy-rs/embassy/blob/embassy-boot-nrf-v$VERSION/embassy-boot/stm32/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-boot/stm32/src/" +features = ["embassy-stm32/stm32f429zi"] +target = "thumbv7em-none-eabi" + [lib] [dependencies] diff --git a/embassy-embedded-hal/Cargo.toml b/embassy-embedded-hal/Cargo.toml index 698d6582..86666687 100644 --- a/embassy-embedded-hal/Cargo.toml +++ b/embassy-embedded-hal/Cargo.toml @@ -7,11 +7,8 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-embedded-hal-v$VERSION/embassy-embedded-hal/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-embedded-hal/src/" -features = ["nightly"] -flavors = [ - { name = "default", target = "x86_64-unknown-linux-gnu", features = ["std"] }, -] - +features = ["nightly", "std"] +target = "thumbv7em-none-eabi" [features] std = [] diff --git a/embassy-usb-hid/Cargo.toml b/embassy-usb-hid/Cargo.toml index e4315714..5e9cfebf 100644 --- a/embassy-usb-hid/Cargo.toml +++ b/embassy-usb-hid/Cargo.toml @@ -7,9 +7,7 @@ edition = "2021" src_base = "https://github.com/embassy-rs/embassy/blob/embassy-usb-hid-v$VERSION/embassy-usb-hid/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-usb-hid/src/" features = ["defmt"] -flavors = [ - { name = "default", target = "thumbv7em-none-eabihf" }, -] +target = "thumbv7em-none-eabi" [features] default = ["usbd-hid"] diff --git a/embassy-usb-ncm/Cargo.toml b/embassy-usb-ncm/Cargo.toml index fa6fa017..47c1f36b 100644 --- a/embassy-usb-ncm/Cargo.toml +++ b/embassy-usb-ncm/Cargo.toml @@ -7,9 +7,7 @@ edition = "2021" src_base = "https://github.com/embassy-rs/embassy/blob/embassy-usb-ncm-v$VERSION/embassy-usb-ncm/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-usb-ncm/src/" features = ["defmt"] -flavors = [ - { name = "default", target = "thumbv7em-none-eabihf" }, -] +target = "thumbv7em-none-eabi" [dependencies] embassy-util = { version = "0.1.0", path = "../embassy-util" } diff --git a/embassy-usb-serial/Cargo.toml b/embassy-usb-serial/Cargo.toml index 495dd9fe..63361047 100644 --- a/embassy-usb-serial/Cargo.toml +++ b/embassy-usb-serial/Cargo.toml @@ -7,9 +7,7 @@ edition = "2021" src_base = "https://github.com/embassy-rs/embassy/blob/embassy-usb-serial-v$VERSION/embassy-usb-serial/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-usb-serial/src/" features = ["defmt"] -flavors = [ - { name = "default", target = "thumbv7em-none-eabihf" }, -] +target = "thumbv7em-none-eabi" [dependencies] embassy-util = { version = "0.1.0", path = "../embassy-util" } diff --git a/embassy-usb/Cargo.toml b/embassy-usb/Cargo.toml index 98734e98..6adbd399 100644 --- a/embassy-usb/Cargo.toml +++ b/embassy-usb/Cargo.toml @@ -7,9 +7,7 @@ edition = "2021" src_base = "https://github.com/embassy-rs/embassy/blob/embassy-usb-v$VERSION/embassy-usb/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-usb/src/" features = ["defmt"] -flavors = [ - { name = "default", target = "thumbv7em-none-eabihf" }, -] +target = "thumbv7em-none-eabi" [dependencies] embassy-util = { version = "0.1.0", path = "../embassy-util" } diff --git a/embassy-util/Cargo.toml b/embassy-util/Cargo.toml index ef5acc0f..00de5e85 100644 --- a/embassy-util/Cargo.toml +++ b/embassy-util/Cargo.toml @@ -7,9 +7,7 @@ edition = "2021" src_base = "https://github.com/embassy-rs/embassy/blob/embassy-util-v$VERSION/embassy-util/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-util/src/" features = ["nightly"] -flavors = [ - { name = "default", target = "x86_64-unknown-linux-gnu" }, -] +target = "thumbv7em-none-eabi" [features] nightly = ["embedded-io/async"] From 68931a36d5b04151cbe2bd343253b6bfffd8a7d6 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 15 Aug 2022 20:42:36 +0200 Subject: [PATCH 17/31] More docserver metadata fix. --- embassy-net/Cargo.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index e4d8c2c2..11e39a87 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml @@ -8,9 +8,7 @@ edition = "2021" src_base = "https://github.com/embassy-rs/embassy/blob/embassy-net-v$VERSION/embassy-net/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-net/src/" features = [ "pool-4", "defmt", "tcp", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "embassy-executor/time", "embassy-executor/time-tick-1mhz"] -flavors = [ - { name = "default", target = "thumbv7em-none-eabihf" }, -] +target = "thumbv7em-none-eabi" [features] default = [] From d769e562c04261d86916f53c83e44d1a51f59c76 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Tue, 16 Aug 2022 11:23:04 +0200 Subject: [PATCH 18/31] Rewrite documentation using correct module names * Remove traits section now that we have embedded-hal-async and refer to it. * Explanation that embassy is multiple things. * Bootloader description image --- docs/modules/ROOT/images/bootloader_flash.png | Bin 0 -> 32147 bytes docs/modules/ROOT/nav.adoc | 12 +++++------ .../modules/ROOT/pages/basic_application.adoc | 20 +++++++++--------- docs/modules/ROOT/pages/bootloader.adoc | 5 ++++- docs/modules/ROOT/pages/getting_started.adoc | 6 ++---- docs/modules/ROOT/pages/hal.adoc | 5 +++-- docs/modules/ROOT/pages/index.adoc | 18 ++++++++++++++-- docs/modules/ROOT/pages/runtime.adoc | 4 ++-- docs/modules/ROOT/pages/traits.adoc | 8 ------- 9 files changed, 43 insertions(+), 35 deletions(-) create mode 100644 docs/modules/ROOT/images/bootloader_flash.png delete mode 100644 docs/modules/ROOT/pages/traits.adoc diff --git a/docs/modules/ROOT/images/bootloader_flash.png b/docs/modules/ROOT/images/bootloader_flash.png new file mode 100644 index 0000000000000000000000000000000000000000..635783b05cd18b70f02c7d69c1c9faef7927b4bc GIT binary patch literal 32147 zcmc$_XH=6*^ggOsK#`)TC|xBYDuhnxy@Y`D-VV}h0tvmzp~+E1qYygML_|R8JqiLM zN(m*>J28|{LWhL=at{1%`>%Ds+`H}v-h_E~rtI0XXV3HOiPL+e!Ell7;;B=o7@(S} z2B%KZ5P&~Uy7NFuCSzYU@NpVxprL%Kq>F=i>eRUhC^a*bXMmHdhvO-bsLFreKq5je za3l&OstOVjQS)%LNBO|LfUiKgC)~l+$<@)}zjq=+A|e7pVge!%BVh@UsFJu8@DLRi zl#&p)_)p%>+0pB`B5^?>pn`ikcJ{7bC^*suB&rPj5A{MhdH|n5G4Rwi1RiF>-)!h;J&~UVOhadgK z!N<;D&=n4d3rh-$2_AJ^#l;8i2?(hR3keAd35r3aBm^anI`qGfPhA)Syb%V<4DFok zd|dwztsT|i=jelU1@!Q*R!-_Ydf|w&bN;W?*GyPn%GN?xz!t875H-{CdaMl8awLNa zL^%E@9wvIi9wJJfcEYB>jH#<>0*?T9Q#%Jk9Zf$U zJ$ICbAJRp|+s#PT#LU>w$ko8e7v-Vh0Zg#6sh1|gUf97y+{siD_?5A$T>wyOE)F*n zcZ2F3Nr-F0M3AD7R3z2ZghfPL;Y#*UA*~<>A3Y5xQ!i5uZ7EarKz(yNWtcuh)z}=4 zaI%wfG4OyI78AbJ6s1 z2Fy&|$->nKu41nQ6L<9SQbtL+xY{}Ri|eY2dpt&oc$hvm*Y|WbLi+kbG<3a;A3J#q z`AB*x>H8aNYN5o9P-+gkdLEMc{(vc|s{}#}A)+3R%3@lkf$Bi(8YW_@zA74l!fM*8 zUc!upR5)uj2aPbiebaU45Q4VnN@b|ZX zJ6Z%7nQPcdIV$-=oYlltE$r2l5pGZu9i$`lF-+S?!U5s$X{;IaSX(&2$l1WzPR}_| z)BuUlSJCm)fLlCL)j|1~8*3OrT_D1`J|=p)-bzTIVNrJvVO>Y4vcIDd1m*_xU)8}t zU&T$u9O7*1>;`po)^c~yb%cpI0I%To#+qV*Vj4;keoBuW9;+XfnWHoSLsEw*0ZS72 zJXw|hE>YnBW4|b>wqxB(bLte&DX6NFQGm_T*tr^GV`|$P>k>!%=lV1BzE|rE*Sb6wx@&RE+%C} za?%l`Zm8Cs)aiTqy(z?22gf3?@h1>^hBxCXjk|y}Nl~^wFAEgPF8C=o&mH9Z3S}=K zINU6SPuh5zCkL{&Xy3ALw2{54==nFZSvq%! zkD!+Q-{FigZ|>+vi`JipK{ zlfM0`LL;U35_+8Bbf^h53;*RM!sbkWUIA}9U*cnhs<4zl=dN{SEY!;dMpGleIIiRg~#Mb#M>RCg|CltL>m# zF$Yw@r?N^4$6H-S!k#{^GrOWSqPF5Ah$zm-s5H8~wQHr&WaX09-DvbDGP1U%CVc)2 zX@YSlIp6^Uff}!jUp=$kZmaHe(N^6mh8%nk>m3}Lx!c@C{TpFu;q@+QSP7!LPuDAd ztRl^4ij6I`DhtSLGGi@c8DsXi$(s$-4w;G;e2J>e8&hGd5%Zl^z_CXg2&~9<~y|3Q zpTy2taUC}=a;N7Hf=i`VaDPb8pTx7LV&>;PB?66oTsl8JOftSgBH&U6n`@mLUt9GN zEW|>j5Pb)hr|?hrZ|PRIGkHpx{lJxwSW-)isuS=r6PFz{`IUI9W!6oo%pRr2rPYq&kLLpD#EG7@*Xo(?ETJ0}k-jD?M zfzYP)6c=p1ScmwG$W_ctO$dl_k~%6n$w(-X3cvRz|4q~Ecd*U+4>86WZwOWo7iQPd z+NVWQ$4>#(RuAf0`M4?{=^2U3#gi&c$k!E|VHJ>j2yz2<# z54zdTi{H2?ViP(S2F+CSANmI?v_t=-nhPz+GzVs!9%rPdkiFAlx~CEHmdQ7_+ih4V ztv%rGpTUJ~YP`D<2F-zs+oHidPZT51Wpb=Hm`wB_>1Vt;QC6z##nojmmOsbd&FD|K zXdI5@q0W|S zXysp?-toKXcJD@+QY7&B3zZ(fy^puA1wrOm@|gd)ktwwuEKGIZ-%DE&o4AsZ`-D1V z$>f%la%jA{b-AnP(T@w472kHzxH1uZ=O=wCfp7q?oQS;r@=?TEG_pD%anld~vcMK6 z1D+_}onNzx5%cLUmEQd+A2j(YJ7{s4sdADA>ALu9u=m#f@@n-uW^jvr=bKQ5kDu*s zmgp}?qckPh+j?|gQ%>R!cIIb#wO@(ZHW}R18(%H=o|ZdM3)~>9TvXDpUsO_oGWvI` z(p5OjG3;*A5?oxX8eHgfjbo&DNwa=o1ngPH__18el@Qey+h9wWK$D))Lb)?uK)hFV zIoE!SN)~L=mtz{y>BjEF2-Z!TWT1Z94Cj=y?mt#J712P?+(nje=KsSzC3`MXk%jsF z>n}UayL~M&?yZ&neLkJ2p7Mn4XBJ{^{cwxG#u9zHr>V1{67<-Je)u-JsSY8;|zzlra|N@dtkWyShM7_r!2 z9*40FEh?6@)xg^ZmfcNpn0_b1kwqBWZZyN7W{eBm>IFnMskPE$-d5)$4uA-cEcvc* z@$!_cuZnUc^ZOJhu$G>~ndjBXDdHxhnP#FfN0MX9;~?GJcO5Y|&*&dH4{Q$v%tla!S8%L08@EXl{;q z$hPB@W7Sh-GHvNtQSE%P8o@dwl2N{_x@zdLwKdWetRugh7qq$QUpYNouMUz0Tx2() zX&)BZQjNXmQANqtw_T~Nt(F)QEEv1`$3-o%HEBY*E+maxci;o%mpvIahd2tcm zM9G%F>5X+t^KE+v?8AiLufeVt36@KU8q(5Xve&YIOx5tul@a!O2DZJwO-A0P`3-yB z*{nbK_72fRO3m2l8DsShzV$@$E713I?5pZ13}T$lwszguiG_cPR{Ec{XsCkjfwAi*EFW8TX~@3{p@)^qV)P{GJ=`)iHr6dyfXU?| z!TYKIpUjZ;j#NKR@df<7rTRx>|8C?T*Kx_g$wjw&T!3&oSL5v|JYPENUoVNbX_Vep z(kfe*Hy*IntNIcW#)AvrWq4M)47FbFo>-GqiJdmTZU+9a%ypobrMh2xzM&G)L~L{C zmB%mM88?ibt9mg!H$hXQ9un7jy=St(<~i3e3bIWQ{aNl;J~g`kv9V)ZXKFOmH|3ei zj_Pu|{DFC$K*Qu{-Rcq-gXP|T_-;%+HIblV}bb=RWER!rawl}R{FaWr`+TMzS( z?CzIq`g(qUQT8Yro25jGP2Fcp*~NyrckaY0_ipV5TlcBa#iJSL+Rw<7r;r9O$ki{_ z+^H+HmMQ)AVENO&aNX1(Z4RR8yE6GbMd84WKE7NwkNaTb%-gj~JL~RC9CBiN(=XX8 z`mfN7Zw_FMZ>$Z{rjob~-M5CEZl{y|FGlr!wc0t#ELVdorIw-Iw4iUG%a$ zs73_M3_St+oFkue8zS+ce(Ow9@N$!*(bg1CSf_Y_#)G79BN1|4gXb{g{qvM*1Q-6p ze#jj7mR8WOnoD!VtSirdnC6_K?&9_1Yq5IY#0iU@b#S93gFSSv!XXEz9P@$@S1g&r zBx873dvHA?=%7h@p=T_0FKE};-=+JEu5oE*usYKdiG_S4TVPX zzbBl`1EDS6bR-jx9!CUjz{2YM75K#AD&U{C-LAUj=AWmvDZc5vQ;-=-GWNAVVqB`} zyBD$p2`K_WitEpjrEyy719VG?U9eUo+}$k5#?wv~5t$t1j1-y0?&(P`}^w z8Qk`wWw#(JG=GS7Txjp->Bbo}{o)Y8ruRaD4OiuMJi#l0>mDebm9RoDr}kC~FxvI~ z+l+)@Xx+nIyCo=uz@_*WLKAkOdx6~#Ue!_}>Mzx~rs0dP=+hpk=;qwM^d|CCWN<^^ zT+&FXj3N1_xMkY5%;ai0YRXYkqkZ>l7r{12MaEa=k>rLPC@An{H81{Pwhvsn{k5Rz zkfJM5X@?O!EXb&yfLKs_mN~an6)3?(#=70D*orYPxwI|hZ~4QYEjhG*fw7Y=z9YWm zKhE6;+t+-FL8!jHIqFZQMjP)bVT-~(bgw*qO!lwzt?LBFoB}!?z|_N-0E4omcXqnH>{@0Mb*tVbuvy9}t+24I{>`nUz<`h}Y%jL>P_*Lx?<8cPHTeZh zFps|g;XCu2l__+cXqp;6E|qGMvgQnK5K}hP6?fba0b%vt*9w#fAO3mWEk5#4RGlfM zZFA`yn@`<8r)UJ|X8F@~`H8AfYDV_6GZU{-(Rnal%FR86=sbH~Paan#s13`a3A9l~ zAn>PHC9iJ8$LsPp?sb#~lZP$lL;R#ztTgIQjvl=$CCCjGckdBZvmpw;9&B0?>Zod1@XSL6UUZxxkI7 z7&R%&a$X88b_Xq65!STl=I9889M{>RkJZJ0^}7mWdvC@&bemV;qmq16=sV1Y&OKk^ z4YzJNdin67fZC+7%~@~rXV|llZweev_?a=e;3lto@!o~nQBaVLgsx$$msV%RCMOsQ}QS+Rv7zf#;4xQ$Gw?Wv~M8_;X*_sa`zr#t)oae*Aq zVZS*rhoek(UiV#tp_1oX0@P*0cs9mA{hXGt6HiRu15R6-!y{my*Bg5GVBVjwf=goh z0X+Q=YQ9Y!H0yPeK&-kCZc1W9TfqF%@(-8I2)A@50Obl>04zIM`lBN*_Vj;W|6M2~SC(*nCIQihSf(Ne0hQqxf+wP0g zDc-ajte{;szNl-D4-js|Gx@}ZGYdWUn*%vt)}B2c$gJ|wKq9AD=>uD@;Un79Fse)X z>o4D9%r^}F$=?r{OA-Jz+WMrMdd4|VQa(FRFumzFMLV}qeD1(Ac*l5Lo6z=+F+q}0 z6{L5pQ8r5y`96=&#bf)s7p0ilTub|Nj?ZRd6i&bSyn3;zQxf~hMITxs7cM8ODg7>m zav*ZM`}^Tl8?$~Kee^UNQsMbRiVqfAQA@ry9phH=I*Q!PD95RBe4LiJI4h7|{ds@M zh6!-1a&KzSpA19^zzAdYwF9|

h==HTGDIg#cn#;B;?><8|tUW37#5{b@(GdnV zXFYz=F?ZDp92?=O2nPTRba=F69C2!@fku{5?YLQGAZn!-AB`tIoN5pzSzSBE6Uz7$ zA>HH2jwP*8c?*n}?&1wG}2ZUU4$-gfg*TT#^ zm7ex?9%wn01$k2TJq~~)`Oc)wdog$Q$x2r+9KXQv0#3NkWwt_q$)j>8Io&Vb>v%|~ zXpC81OgBY+l+S9N<>7JMk<-bBEpz~wW?H`yfN2`qJbH1gA*m|>rs*Qo zH+-!*&_W}|??gkxN0=u2D~_sIL}rUpKI{b3WC0YfV_%35YAL zs?`B{*38whJr;j^1!xl##F3^6O!CvXjFag)eYvalf}5Zsq*O|n^#pNA2YOI0{&E?l zBS@5lhCAdFqsSkhUtLx`o=bK5Z&M*`P=$(~WH5*U4d91(_OZ#UR@kh(O^^UT5eZ$< zO2tO|joorZLW{K6tfH$*1&EiS!CG|<388=IUjK)GKT$k=_D9QZJ9_@%qQ4B3RdX18K>k8g zQ_#;Q&D zXup*D9`ueP0Ik+q;B?Ek-{c2zf?PSFxy`#-FDqj6n$VeEbJFtNC(vuNlx*&Sb4O25 zRc%4u9B(LyCv$YYA@J$UhACc{6>s&Hj2E=>v@}a2}&imWyc(3PqH3vHRDsI zD@Mvm#U#iVy;ni zZl#-kYd=Bn^>`xk0HBYsAKTMVpO?W~yEVKy=-u(`Oim{xCh7|{HP4i{n7706S^~_6 zj*F9~!Tl5GQuw9Q&TY8dX4YTPKk0mnda<`OU0FuVEi4wW0EwE@o@Cw9SF7QR)9#-s!U!Z|iY&ah{c% z;e?CAEOL4Ef(Ez8(LGC)M{iJS$#K3<{9j@%&?*g)J9%i*1<`uOK2xZ)Do)DodO$mK zp4{SoNDU$o0>-{@Ug5q}zQ~x$SXx56jX9(6aR`V2g!-0w7Kdiqd23ajF+DM7c&(EW z+_n>v~gqCVvw{%#;-q5kG%7$w(erUCax;T!AM(slJwNaYesbIz{!{MAT6e` z1%5ZA>GBlp`zTuel3ioNylkOeYxp%f!Zj8jnv-??R1wJ(Rn_l{$>*@Rk|~Ge!qk3i zZ(vg{aE_dLyPO4}$R(T-)rnVE2q|8e)Ng5>4ps{WTwR@|ETw->A3?=0wm;m{)v7bW zb)mhID&q5CEv%PHHASIjuC2DJ9A>YVW?(gkw6Q)cr9lQAKX<3lU4pLL)7cKKwvdCl z?^8k9pPK*SmX4Ri(C;esL(+o>!{>y8Nht`p;DdEctZ$21Ky=1D7oCn9Fbn7Y@3SD6 zJ5uy<#WpI)3op}dX*FnIvA;C8H*Eo@oy7UpSZ7hOv36d@g{zRI5@5Q?^nrciKT7AXipy`W~)OR_)NCqt)HbKWkf>s&6*4K3fyW zzfn3^_BeSiq0>U*B2!Y^av26MxLtdle;2uXCEj~EyfBubJ{o-kvlS564pbWgoBCfX z9G6P=c>zgpzcs9ofY#ch(tt>mZc{NRSs@`*C7 z*jr{sICk_jfYhg*lK98+Q35q5Y#n7@nPE*cGB?U7|? z%DLZe+!t7z|FR@RGS-!UHM_b1rt$8G?UZR?dv5CP{eBY@$-7_k<{Jn^W%zQaRYI7! zUnAC@4^rtQ-6>U{S!ad!LHC+?(?`BsUz;DWqb;5L-Q4Ba$ zhQbc&iV9kDkHnwn?HeD)>o&Ndlfb5M|@r#Fh44~Im6mre{1YZ09WYccEtBY`~>qfG0>f^EwH&itC zkxbBrOX$WfA?Wb6uK3zF7S|GU=YjO{0C6h`VEs;lBiv%ib1l-tO@DW4jnkKwY_CT! zwveMfS=D8^k8(OSy1^PA+5>~M8xfuH{uHW@?k3)J!2hcE8euXBvi6}h$NUITW5MSI zZ?Y(8E`Tpk%X)_84==!!gEntw<)VsnT$URck5OOCF_`!5u>pS_ZOMq={~zpxIcYuJ2=3cQD1 zd)QR!ZDpp@F1ioB^nkjr3@J^1$-<*&9I;uqQpk6>XexgYn&!Pn++1mue(zlEW#P59 z{-I?-e5#&1tVj2bhFj82r=D*ty9z0|1NIjg`vHWo?zMinW%(j0Xzo|_#=u{tAietK zl&O}=iH-ud9m}xIc3aB=P*P7JE$7=r%+}wI_SN$t=&Fxs``0#+6lTS@RW!ilIKNH{ zR&hZJAYS^_pomeneuj0Pmz%S?Z^CVATbY8}nC$kD;5ovOWvSNmuSMTr^)b=!jM+9} z-XVD6Rb_vUKcS464?9!eYrcJR6tyYqJza&W2d9tBfs2=C$QeW0anKNXtp31xU>T>4 zOoMOc7Yzb*8%%evVQn5PNNv{JJ7lyOxLX3>4r3e)lPSXT>`0!KZ(o|~j9w(pET?`t z-^i`Lc_ZK*1#1`Qt~0fLk_*sT!#HtRy0`@rez<5da+ru1_Y-}g_%?~gePvun#U?<> zT4G$YPe*i1VPJx?lRF-A7)se5_?+Q* zQ>WvPYDoH_OvL~|Z>i*mAu3PUE6qCf^UF7 z^pTa<4CTP`VyP?(9Lm7A!*wfNSBR7LwjN6aBpus($n{IKKK$}7-Y+PtNqQ>hSuS(n zV0OvRBC1IRB5d`h^8z{z9w)nOQJ3Mr>?^%KO3ndmh3fi<-<@jM^XG6@<*}rxyhteK z4;UOPpDrodvJ`0CwS!@N0`87|l?%I9R*7^Z67r`)Mkn~43;8@<9!xbbm@WOI$axlU zyWHFo+U!fU)qX=2<$^Nf#t8fB0^1;SXKUZe%+OYFSdxjE&jrrvZ5xZnO5OPfm6cT! znT?P7pD0Cc4pdL5=W`rZ@3~0_5HeCT{$=Bhxj96Pm@aXBq&?3R7sm2w7>gOGdrpNXjWVmyT@D6(mJ>FvZMs;j&gx@uZD{4Mo4T$o6n)i zc5yW>hfLXgHr)6~mcMTBMcP4D7nT&%NbQng3n{ie6eeBATplB5(N~OXg}H9ojz~^~ zmwGZvY197{cb*+XCnUHOXU)h+K(iJQi{2N`GHdemyhm_hGeq`Qbdo!Kzh;}t4~h0e z`CP*0{cfc@dwq8iqS<9};ZHx@+Fw}+`suA-*gD2)^LEpei=7u9zH@mQ@$FS_mZXiR zIAy1^TSt8Hj9{&qyYKoPg^sO}t)3R~)fDHA88BA$Ygl>ZV1IA0A2;6-KFhGppoh0_ z4~u)cSY=(tQb}kS*AH$STc1=J-o2*~T>8F*T3(7BVWgB82H3$$u z{qp$9Zn?#W`h^MGwKE6giiI+2G~u^Mx_)jOwYhJOnE5z43irsQ^S2*psGi$eWM?otL{qj z9ek#|F=M(pa1ka@ctlRxIcIPtrUA#WpUJ`&_V|+ZmNX1U@N>U~2I$5Yw^7sZlut?= zU7lqdx1as_-MIbS>Dx@KWhXqoTH!$Nf!~mDUD$!+Uz9}C!5^Iuiy2JJr7mveTOu75 zpnF8*8}5-LdB>fkcSO2bt+%hHWKCb9-Z=vKME1N=HcRi8NBPB3mvJ3lJpkqADZ;N4UK;GBpSMhP7>&N^tgeOaA-PxC~#QMj?L;S(0iL-mb4OnAbkIDb*ZR2fjiU; zKOw28u_0eQ6nm4xlgsUba`A`gmSw4gxidx8#mEqAM<0Q81D53|o6}D(2N7};Qhyjv zBf``H|3%Gt=1aL*;NIzr-yL}xpgtlxVxuK2n7@X3J;!Q$0N<}29JdSkYvMtrLHi3G zM*&;e-GFDH`vMFU{NcW>m`wO$Bop!7exqhe&dr?yubPrpL}p&ruV`}B27h$*eI4bu zFM)% zY+a1a^sN%CTYLAuYCi=N%QxIDJ_)caGgPF04$`w?;e-C}KUlp0@};W9Izkrm5oaj% z+&?X~kxgg9v3-vQBo_By0h-16b~QHSj?5#PW|hOkd&K2)@J;)FCY}i-1rRl8*G@;C zcO{uS_bqe=W|v^$)W@H8oNOY@g2+wO-e+;C4|Jfo?)m0G%f0^L(3Wn1iIxY(vIk+^ zyAKSBNg+cwThVjHRh>7Lu zKB?IKMlX9wynS~iX|FdjBU5VI?OqxwTyX>R%~oBjy1Qvl>u`Un-NpDCzK+itL+Jx! z`$O10#KvjWDd(mNS#5EKc-w+}R%-{2EazA(`u+do>_j86QvH>)j15_GYss16%bWLZ z)G_Y2j==j=?Gi7?4g}&Sgi;;Dg1-wkA`*Mplm5 z$@M$t#`kZ}es+%vmf0=q%sp%sCD@?7a%NSvP1(pJ&}yd^*BO? zmaj>>F7O{v#ej&qH)y{lA(hKScK?$~r7dPTH>=fAP!Kv)NIrC(eXlQFzB16;MBomL z+8T9Q8Uep1`41Yza$2Ho`J8QJH(F%nqtO7U>iK7(=w>ul&O5(IeFwSX_z4q z=1%eGl5ou`3pMQvI=g;HFApIfo0o6|-o{EW+JV}u)(mz>G7yrYM1`B$P% z>4`O~w|nXRr^UM(yQ?P--^vAV{$p~9f9#+QM!Vy;d@wyVyD#;|EBLov5U}WT*%0`@ z+eHUgMinH?09Oh73pgjZUae{jynC2x_-N2~d;CEu0||V!ByPJi%x^hR+o*&E&iEsY zZV=4pWB#oAD2Iqeun7{>Q;CwXn+Qey5tPyBgati-!`=O(xPLD7*8BIhd|0D;t%Qxh z3tId~Dv4ilKt#S(UJGoDg_ZKF$g|Av69CjSMHKimEDyf?9}sE4J9*_ocapBcm_o(( z2C_tA=o`t;0{av)cVATiSC(W)ZG+QpxNWGhD3zR*3THed1TD>9b9k2#I zs%PJ3+;aT|MbUs88n#$aeGA>Nl{9gCsye+6HNWl9@^Yn-jADbs)jR0GrmM+=gn&wHcT!@qW83hEpc$Pl^*1F)P5}}^!Ja?y0JVY zFl|`HVTlm^#1PoGXk5>6TN}WDUvLVXVEcO)XF=%`4_(=z7%gdK9245=TeZVIowdlf zzoL=dHKiO*-Eu4>&x=rhn1!i9tlss$(a&MkJ&0HT2AhZVjdrD$zojD=i`XAT2Y5|Z?58`j%VwA4lr4@DqCRmH0~!z~K@5?%!qMD;l^DjPUAqyne@*2u`2n1!y6L{}nBS6nW`N zIzJ`*D_3RYgm=~f>K2Pve>9>D=_Y=`37o9XI)I5<$V>kO+yLm3i#VPZI$jnaM+Nz~ z^eE%&+NAfrV~t+b0ywqzQ(oH67YOm*gbycXCkOOwtL-6D;O_D9^uHHk0FO1!vvb=z z31O4h`>ym@To2&<8m`E_&^hAxzI}W2KNnQFfK^2r{{Ot7U{7mk z-N3+VYZNv;AtFQQgpipD-rBxkz#(vPv7Kz7{D3wJT!hw#uQmtTXe5Q5IF8CAO8WX- z$jlKX&40pi{{KTsPl8nc-}Df4gwd-f)~qN3ED906tq+R8{GaBE{h#D@U`a)@k=js6 zi18c#B`2P62v~8>@Sh_1$IXHBG0)GR>~xWUIK$syoZ|(88k^_diFo1>|J*zCTNSWp zRqdsdYzn&7E4N7z!+^=S!+%~oS^L~HKhp{J9EM}`&4C|cW7|$<;vb-HezxZg62NsH z{HuK1llAEd^t@6{Y61d8U0x?y4nWj(6m+r#8w2@K|0ZSsX8>>YXk0H53^f;cT<=1; zVL=)=a5P(Dx^EI9v;1_v%t@W15n|Eg6p-~T*Vj%#!8LjGyc84BxZ(7g#=IdAbMc zWs1gKrk(N!{bJo3vBB|XSL7X#(|9*8oSvv>dR6h)z3N(HG|VszQ(@{-q*BdowHa0( zn;xEiv@Ei#DKZw$Ftg}4x03yk+SwB&thXF>Ov=?d@@}@yM&Z6IzkGkG}}pf zh3|Du6^MV$miCT1nxy;tuqpHrfB+%QxSNxvWw?;#VQ|6`ti)`M@2T$uBE6 z*QubX(d?n}Ka2#HSbI53tX1;zBZEPov^)V=lU|L^qGk}JKd-(xWgKXVOP(#^cz5!> z3N#gNfct=^3J`0fLgDTZ{~q7f7Xavu2`80Z?{2HlYt5D#AC<4}EBd%(b)`!ejk4+p zqt%iwowe)cof^fHeZdU*BJyLcQ{9Jr9p#Jv%OGhXd#b@TG8V<;p(bq4Q z59VrZZ7=QCq0ehs)bpm-U#IS&DOL2HciIR#SGpQY_F1Pm`eMV|It9C4ex1A1UK@IW z;CsOSEB|CQ_R+Y~5xg^Y?9g4VO2F;PNEMf@O93!ZLIF%VCnc4c~PMtj0u<*HgD4=_~vlw$f-IGMAzP?DCCLBXUjNVU)Y$-g)E<5GiphOP}mAzE=Pp zB`h{r1Nmw6qOGPe1Lh5Tai%VDErEf%P^%;Zs-g=HK>~4FgU5wG;;t}7E_Sdo7Bz&R zdD5#L=ST6YK_sd&!p^LnatcaSo*u9j!2)-j6rxZkB>w_0aQAFnP?l~%aXHbTVbrd{ zE$(L3J@b(eFDQ3RDgulRP&RwqyZ?*DM0G9b4+~ot=ZkInPWGV2&45L&ACDVUbGaYJ zo4UKY&Ns-W*B6h(ycU;qU#T2dNSwXG3ZH=a*uwC^rF{bWlulp=g#WmCl2nuRuL3`X zftj&4x&GcjM|H;1ic#*A%7yvFhGZr{Ov{LTcIzum#)5fq&$IHmL}U?NF=yIUq2 z!`Zr+vtN#HRw?pkw=yIR7$4wr>tSq*L*Au{q!d5!$e-oE(Zg%4&2@xdmB7uw?pXT+ z%O^|=LR8<{vr`R%KdsIl2M0bpFW(`!kU`N`N|UEq*BS&nME?kQ+NiZ=kC&6elFKbD zt?cEUlli&1oCtgy2j!YRyIsyRQW2$dXwK4H(q=yrxS@s=eS zUIdx|a_RnA1NN+1mH!W-fsykotel}BS85ff$x`D5LMvBz(1|DM078+D;s(M~<}Op$ z5xds$G=$C4TEX_ot^)+cnWO*6@##H5$VVVJVopviESkX(tO3p+UGfU`G_RFc089kv z8!hR#9^XhWH>&curpSw+M)s{0epe8%C$5J%V;bUsJ46^5a0N5lQx@xQE7#!hJ@m#y zqB@YPnyQ4;4{Ra>fh?Ex-bo_^SAj+jm2p?ITl%8jE(gJ}07c!%4}VK1>$C^=E2&KL1pm}sdYsrRljtW&a{ca(!q zd{8lsIURxVb2m)d26qNcb+L!|3t>%gHt4Wd74PyQ(0i~2z-_)JnR0bm%6KgZb*@mP zp+P3NZ)m~9is0l9zVw1kINkDbjC%U)!o8P?2okMO?3 zZis6J)xcthH!7l$_{89WlyWVTSKj5;>N7rUK%NbGf_eC4is<_Fd5QoQWP%J`Z%I<1 zEk!Ep_zySlUPNc2XTdC-%8m7DAs_QtfDNEwr1mNeorA^XdrAUMu6hg4f$Ywv&1|w= z9jBG{WtogLt~F zfGg(H!asP~?O{Uw`DCD{l8ZJ__Smhx?!%;hPz5H1>^9z;P7hpB=U;8vR&Z&JrhNG4 z^T;Np)UbU{x~jI+He@e)(89^nv!S(3nmjFwXzzpbyqNe36Bd#+V0V`8U7=wLJwYGx8dd5W=Ic7G4ptPP z79Ub0Q>&1ly8?&RqqcZn%0-Nn)a$f!`~5wi63*3l*tI|Gh4=JbB2v#ej8p-X!${Yc zaljfBJ0695!1Js6VmiehU=Gm#WtTX9>Mo z4!WzBe~mCy^*sPL3OOvxSIAY_IK?(Lq|;Cjml6Z}B`2&-4xcwljr#JccF&uCcWPw!XhwWln; zTaM1|9gayoL7m0i(c64BK@I#4hr8`r7T&KCH^{mQiz(HagZ+Kl#r90{CjO%kzsn{0 z7+VYOhW&^p%HGI(uQ5VKz!fa~#Zm6AOB&$jJ#ARZs-3%Np%&)oPV)ohoIu`UcBcbV z%*JL^I^;n+fPRP=RIo&#E^f&0T5ay?a%bQPR>k#ebwN8#vA#VdTK8gxL0q({ZBPH7 zFwAD(&GxLDp46{d+?23S681jqtr+1sekd+jv7{7+Jg;I9@PFjw#lAeNKyE z;C#18s+G7nHlE43{?TuwtVm+SPc*}a+QGKBqvs2lVUmSk;k~E(&%TsmsUIl*a*8Tk z>{mkL-iFC#Y_k+A^DG0~(%$oz6Fha1c?`V8cZma^{_Z5+`h+jI#!z?hD0$cFdISgE z0bmFguKL}c?+c%|=0E7{S|lvAhs~RN!81%pj8+aJm$@=P~)V&++UB-qmj{ zx-MB6Tk$`PB*xw$`^@3>)UEeXv&nrgdbjF5`M|GgzInjZ6~cFCFk-#mSj0#E2J#36 zvZM})v044D+1GM<4rf>SX3^Kfl@Ou9RtsfoKMq;tlIw5_58QAa)DOXj%XnMyjktoG zQ!6~(M?SH_7{Gf>gty@3fD!z1-~fVAC7#S|uM2rCXin6kO7))t?r?*GbEZ#~55BN+ zdG>;#knOK>TT;r~W8PU_VUu?$J1x4y_Gxkz-FEvf6D?bDU5y7c8995%*wwhyz#U}f zE@7azV9S962p=LOfRJHCyX~|maG|Q&_&MdW;uo5Ukj;1#%g388=l4t6Nk;WsATTG} z9nZQpr{1MqIoZfnB&PB_<)oB1;)4l%^bt%b7c zI_}>(6Jcb9K>qgADl2`XAdHCp7)>kdam=l?{)rFe(wGL ze!rjPmUyJ@q%)dg?AKMF#GHS9iSQavZ;MI~?eS9UEL1s?wt8}9a1lj7WU1<5Q>-1k z;*p{Cem!-SneUq!RWW{gX3f6d9k;uyy5?@<^Ecsc!g|u8e)%+QD|K4! zaqf9-i+=teUujE4U8H9_`KKN;`3J0{q(t#OvhcA|z{?j^Oe^=FWG`n5TQK%&UQl;1e;{ToV-Xy`xSpUTRdbe4vHCkyyun%I#l*3`IlV8?mz=gDxP<{ z$yq3U>JT2SnvC5k=Xelg>S%b6Ik9Lb@py_C4lJ!1SA9Og59x2l8=O`7X;;oxdx!!(lE-eYQSYx|__PlJ+*#vYUEczvTyMr;jmO48$vSVt{` z+EggeoSy#0<>ulMf4!j=mGhsUSH5S=nd_#ye-d^GK3?W+Z7Js5(X9cBjW-XZf$9*9 zn1f=he2|ixM+YZjpUO=fq8^2ro6b%NGL2f#HWXIJg%)COlan(%V0LGS=TW$nuRf?q z`0SKyjj7!^;$c`Vq!#i~dEIP?j^fVZ2(=6>+%fRL$Fuub`Rc*~)z>>7t53nw4T%dV z?bgAHbBpi%yT@t80BC00_y=O5_RvbEgpCmVaY?GBfEX^fxZRUuoLZBrbK0w(pI%e-N`G{ zQ~a&Yi1xZ72%dlPI4q{&*0LXJ-+fhCOtZI7jLocDF0OWF=6A49><+y8P-!c(!a(U* zeS}it?bDnQlGyZGv`vbCy~e(q4ND($S{kz|(7VvcQ!-xXzIFShRhn38i^ZLO@Hp&7 z65K=lB_1_AJsF5@h4{!&7f@EN+SewtYHp2O^LKJ?SXpU4&J8PGEdwl67dAdVmiai0 zYKCicK7e!TY6}rzS36wwcM^72;^br+f*&qH!$iU)A|s$-*-UR4J1X+9y>8IQx*FuY z-*AVEtP!@xsD`9*YPEczjqdm#&{4UCb>=Rw7BWkp8@II$p{t8>2(no=(S^WjH3!b20N6t-B3pc zDHDF6MH>O{wFde6K_%w>dgcXKSfXu!p3Rv0IcRj$la+jwU7()LvK=%>iWS_tIBiie ziPUcfwTh^IrLOl{2zB~&e!~i@3_xj*vi=68Nn=ta-bO)ucGOojJ855=5ITo@oz(1v z%T2Nl*O1v->Cq=K%ba=OmLcQn)_t*m z?+OpaHDM?{gxxI==_@EX%{bQLzcRPD-jc1M1P{0p%SovF0xC0gUuEUWCLZEjL0#;Bt@*e@ zQ>{&o9LL?wz4p>zGKCy(j!s#0)0-*x2oFfJK7TNVP=eN@9YsD?qc}ZogiBAJnH`kL z+V5o9Q8wx{*q-66J*-I+t4ASc<{7^gbXkQRJcV=I+4CbkjF1`C8j8HEmu*LKk{S|L zUcxyw>yR9pCXuIV-?{pNweOpVO5v=6WG>>aHt)VK=@^n9Z%E}rOGTFneY7H76Q}jF z$xqmaItcizcKhn;H`kJkr)=4`OQt*{j_cWawS>!0P= zRn3`^Glp+xTawCG8VAUc2iKVOXj2C-IDdK5zHzO6MR58M73r8AY9eg`2Sshg5DoP; zC~Fu7a{K&_Q(n%X1}-6z&N)Gzf)C~Un#^`d*GI74-<9Ol%6-6x%K}CUr%j)Q1(^IKu+Ys8#v^064s ze>Vkx^WKku%d(*9vim~+%(laMx6}0}K<%PTeRK<_Rw1z7y>0GD%F{_Mvi6q-gCS0; zZwS7pcMuC)e! zK(14vEQvIoqhIyU93$rha5}m=8aFrZEe66VO2|d3@LJQ)*#n%#=S-V=3J~mNY~U;a zlYd08=XBzojztt`=tOcA$KP$(;L5|f=v%JOqJU@C{B%2Xt)nKZj%y39sY%8|BvL2|MAc)a_*dZ8V8yM znZ*uIbZ&Y3UGXhHyH;Ku;SRP{L+a#l)X7)$L%5VGUD81HOKs$`+v=SJgady7vj5DT zbP`J0S5O7+l+kw%9Ed0o@Nx(r^`BIU0q#jEzYm9MqYAFUPE}D2A3m~n{ziDkTEnx) zzzy*1PGEiDsx2l*y8jQ^V*Yz2{d*<-%NF{-qu>2|CH=pBCH?oXg(9|4*!NWxZjsKT zeEr-Z#dk|YAigj1D7&|AI%oJUogXc`d@DkA3QPh5}FL{P(4tw5AujyhG1WnOoOKQ>K?RQIhwE9|rh6rp)8#^ga3LGUVub_SHbh+DPt#gRk`MrP|Hb zp(F+7zgr_7?;84Ir!7`z!PB2-nn)_4jGKxc@R~pol<${@Ez+3~$8)nP^%`WH4SPPj zVlBI~2#LobgNk)n1z5Ec7S4|qFl<5hHxl*CX^*AR>AJX&$XYoGaaRBMW39y|F*3&A zX&#@A5nSuaO}R9>|6~U(lH!L5+*RB+Xg3SA=i|9iF|-sHU?@x5uVlNQd1snD=CYaO zrl{mKb1W6Rm}CB*v_cjUl(&@Ae#evsG-EjsbUy8Fu-!*O4f64>RCMqKo}uD|>Ogc& z_>K2FPjn}-`CK6_#u3HXgJ&G_>K;I{@~6efxM}bJ1?Q_4(&l7s7j#BHuqVq>X}K$a zR(0QC4o$*_qI5If3HE%X)=U`l^9vOSM=p$fE;PQ&_V}wF5C0HpA=`ZRffV@qwXIxV6KFLj+e{bxjUK1s7n8 z(6C6$KfG)%J+Pt^Qtqi*5=p2wRB0}@2x0~SWRqGsAEl?yv4(Qn?tF$5;i&ThUA6X> zS%;-dVAbb{QmArXHZ3)pwN0*yHmUl|h~7U0LC)S0odfO=o9F z;-i#%G-a6U36cM@#E<{YGqpJ^G>sPJRONr-Qn5*p#*!Hd!Zs3JSsDC({mLO2 z|CCZ#_bK9Tl&`X_+Iy8Btg2=kT^`E38V-*a4^E>+!l252#m#mOmxjP^k>1%e5(e#H zT3s%T@j%}C2*(FiJe)bwU!|b9^o9HwA@{|9eS3@)%TqFst?j5gyq=H=odP`#(1{hl+%@kf-$WWHssMk;cHfVHp?Hlrz#?i5Io|rNzgtatgKv+_GzMw`*we=Xm z9@r7_p)zkWM?dwLL(Lz90bIMMB0*`-Sq{@`OUE;_Df=5XX2KhID)3o4`eSh(otC)z zPp&y8Vu@2xCvm+WA{N@I2T?3J>x-$QQPpkMCw@$YFjoQrSmFF@89)Fj+u7<}0B|2? zuV7!kuVz02GE+B^0kr*GU$dqpE zcZmOofXT9r$PId#E-Ir}lIddvO|1iL&v+wVg^1aJiDO?+iI3O0`IqdUxFTu0%rcjT|Ab05uQn#>ow}RyCl|25XLf=|y zq+>|Kqx7R+T-7hH&Zyc3v#pfwEe9uE%Ktzt)&s=CTwsF*k?Cn(Tb8~$O%11=x=q6!VAjS34yNG|_;IqVYZq$e^K@{X>IMr4ft&eTUH%6MAtlUsCed2GM#!=kTRm0A=h zD7;uH&QR-gPxw23R^v5#hmZO|L3h_cPO2}uc3<9hZB5`a}g}|;Vu#;`ElW;o>}Yr)Rwa; zU;3nC*SEoO#Kx?+# zw^W$b|8Y}&;4>nbk?To)%Z~Lbn4f&50d@dG(Kv#N2g$L=-5$>xWLL0bLaNG_ zGeWrQW}Y_^ynj|tQO^>pwgP4iuzl1GzQ?rFC_XbOEb{8!uHS}n5NYJzD{n4=iJfa? zmsvP#drAQtdZdKT+5MRdW$~`YDuI(s0+b4`4*c5K2{!Y{oofD2#OehT;F^yr~ zdbmuI8z6p`2<;FUB^iZ)h%Vlg%aWH8yT8PlH5VK&%nsg2^Z$@!fDMF+6MC7prNZz`^w9&nQ$UU4(7 zi5=|R*tNLC=$&tlq6pv~1-Id{yh?a?KL067S;e*PnnLk5#Ofzd(4hD=vhuOZ+3@_4aV{q8%PM_>LvowYkmWH8SAsGX><=wLK3@{3WqG9gWc zz`8Z9_0Tjz?7Fy3?a@%Y6(DSs&j#tmQZZO>t(1Nnq8Cb6vM#O$k~*wMe4g7F3Z$i% zh4O0Gf@BM{{uXld3m_v&-j>troF(Ixh<(2CCvJLaAfcF^M$2l*_8@Doe3MzRg>}C& zPMn?~Fxje8TPX{==B7Pg36ij$L(%80eZ+zsfqc^RIEOx+P2O-25wtU`O~cukIOL)l zW9f_SlOg4i-$vz4SL~Pd-B0C1xhEjclz4{+le&DFMo>TI zFSp=byG+zDaYi8H^i3-bLpGW>9H^9f|GC)CH=3zH4MLqqc&TKzz0P*kBLvXJ7au`di!0qb9;Nt8I(`HuIDZV|XGq#5 zDB%Q67xiNNCDR(ndeW6X26Z6$C?#?e12Z{N`{tt;V&o!xLd^36pzPMe^IBF!!!m}JoB`>EA_hkz3_%>*=w*?v*S1j~m9BEW5^1|BJYaUEP$P!h1 zt)I6}NCS>_$a}mzRTPF!blVXJp`LXayJ>A{tJNYLW}|0H3`-37gbXsbt+F5np>T-Y zE-gaw_t|YQm4@XpVUtMf#lGf)k(ZM5%SvPSVk%g>*KsQKTee_#v{j@H&$rfUe!@(@ zd6NGq+8Sl;`_V7f% z{*v&=p8GkAVHGs3*`QddOU7{-K1t&2wBIGCMyHRWR^41VVVK|n01hhyH&;23y2|}h zh1vmCsGn8U_^J)A(RZ(m{rfBT*YRb$hry(gkk*zzpU(wJKHOX(=5W(}qVQ4eIt#9Rlclovj#1`(8+KA`ON3froA2`JGV z<&p)~Gt&j%r#4Se^jWfG++fYa&NWiVx(&Da-U+su;qGCt$!Y9LZ8qbhZl&=*XSid5%|piZ#s*a*=Judo@ORqo4tDT+1`K#3##-A@ZTxs~D3(&;3|qEe9sivt ze~teZu5`&ZotSs)`{v4P`z0jHqfZgl>phlk&xt`M`pH3eK~||@5%uW?)o>p1jm(VP|EetThjLBGJ-{v%1cIt4pIj^yvFMsW=w+f zFvgUa`XI>ZtwhT&!7yUe>Im6Qz8s%;Fr9dsyLV$f9Vh=uFX7DC<%5lSCYt6%;>&$i zl;>F@b!cbP04y_l`LKD7&^ zxXbh+-B#CE-odFzm*r14r;RLAzlHfqT7}uG-=t|Coyh6q-s$?cjc1=V^>uy#uN)fjflEa!xo_e9_O{+w?)JE~ zBH96YaO%o8#!lH>@n@w_p`7Zi9XO5sY~POmP$J{_!4oZO1-v8RsB|r~yXdnIV|@N_ z`X9xBbsNgSY3!ZnM@ZnMOg#N%mJkRI;lNmN$5qw!x*Lvb7ty-)FaVKX%LI(^sM9T6 zYd@9V4(=4$gv){IJQTARzwqgO;L{oBl1~D!1oP6D!5l)4JaCe*29Gmofh4JK=i1G3 zMgIu+$dUaE^5BIO<@i5eZETkZKYsqn(HvMM%>Qy0xDK2xB%NDxR~cZ{s6P$C3jiC< zX=ilCYD99j>`!BhyMQ~61}g6ppi?LQuJR_WcIGcC?``Xi+Byqd^8mfbFF4{)qlDj0 z7_u*5S7rFm?)?&Zmw^oG5}-=~ABDfLi*^C}n=mkb*a80Hj$b|2MWGtlB;+0XF{@uMQ0@UEvPUOH5yalgf46=3v13gv6Te;k4}Zf0`v3p{ literal 0 HcmV?d00001 diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index a45da195..86f2996f 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -1,10 +1,10 @@ -* xref:runtime.adoc[Runtime] -* xref:traits.adoc[APIs] -* xref:hal.adoc[Hardware Abstraction Layer] -** xref:nrf.adoc[nRF] -** xref:stm32.adoc[STM32] -* xref:bootloader.adoc[Bootloader] * xref:getting_started.adoc[Getting started] ** xref:basic_application.adoc[Basic application] ** xref:layer_by_layer.adoc[Layer by Layer] +* xref:runtime.adoc[Executor] +* xref:hal.adoc[HAL] +** xref:nrf.adoc[nRF] +** xref:stm32.adoc[STM32] +* xref:bootloader.adoc[Bootloader] + * xref:examples.adoc[Examples] diff --git a/docs/modules/ROOT/pages/basic_application.adoc b/docs/modules/ROOT/pages/basic_application.adoc index a8875aa9..4dc4a635 100644 --- a/docs/modules/ROOT/pages/basic_application.adoc +++ b/docs/modules/ROOT/pages/basic_application.adoc @@ -21,7 +21,7 @@ Then, what follows are some declarations on how to deal with panics and faults. [source,rust] ---- -include::example$basic/src/main.rs[lines="5..6"] +include::example$basic/src/main.rs[lines="11..12"] ---- === Task declaration @@ -30,7 +30,7 @@ After a bit of import declaration, the tasks run by the application should be de [source,rust] ---- -include::example$basic/src/main.rs[lines="18..27"] +include::example$basic/src/main.rs[lines="13..22"] ---- An embassy task must be declared `async`, and may NOT take generic arguments. In this case, we are handed the LED that should be blinked and the interval of the blinking. @@ -39,32 +39,32 @@ NOTE: Notice that there is no busy waiting going on in this task. It is using th === Main -The main entry point of an Embassy application is defined using the `#[embassy::main]` macro. The entry point is also required to take a `Spawner` and a `Peripherals` argument. +The main entry point of an Embassy application is defined using the `#[embassy_executor::main]` macro. The entry point is also required to take a `Spawner` and a `Peripherals` argument. -The `Spawner` is the way the main application spawns other tasks. The `Peripherals` type holds all peripherals that the application may use. In this case, we want to configure one of the pins as a GPIO output driving the LED: +The `Spawner` is the way the main application spawns other tasks. The `Peripherals` type comes from the HAL and holds all peripherals that the application may use. In this case, we want to configure one of the pins as a GPIO output driving the LED: [source,rust] ---- -include::example$basic/src/main.rs[lines="28..-1"] +include::example$basic/src/main.rs[lines="23..-1"] ---- -`#[embassy::main]` takes an optional `config` paramter specifying a function that returns an instance of HAL's `Config` struct. For example: +`#[embassy_executor::main]` takes an optional `config` parameter specifying a function that returns an instance of HAL's `Config` struct. For example: ```rust fn embassy_config() -> embassy_nrf::config::Config { embassy_nrf::config::Config::default() } -#[embassy::main(config = "embassy_config()")] -async fn main(_spawner: embassy::executor::Spawner, p: embassy_nrf::Peripherals) { +#[embassy_executor::main(config = "embassy_config()")] +async fn main(_spawner: Spawner, p: embassy_nrf::Peripherals) { // ... } ``` What happens when the `blinker` task have been spawned and main returns? Well, the main entry point is actually just like any other task, except that you can only have one and it takes some specific type arguments. The magic lies within the `#[embassy::main]` macro. The macro does the following: -. Creates an Embassy Executor instance -. Initializes the microcontroller to get the `Peripherals` +. Creates an Embassy Executor +. Initializes the microcontroller HAL to get the `Peripherals` . Defines a main task for the entry point . Runs the executor spawning the main task diff --git a/docs/modules/ROOT/pages/bootloader.adoc b/docs/modules/ROOT/pages/bootloader.adoc index 3df2daf5..ae92e9d5 100644 --- a/docs/modules/ROOT/pages/bootloader.adoc +++ b/docs/modules/ROOT/pages/bootloader.adoc @@ -20,7 +20,10 @@ In general, the bootloader works on any platform that implements the `embedded-s == Design -The bootloader divides the storage into 4 main partitions, configured by a linker script: +image::bootloader_flash.png[Bootloader flash layout] + +The bootloader divides the storage into 4 main partitions, configurable when creating the bootloader +instance or via linker scripts: * BOOTLOADER - Where the bootloader is placed. The bootloader itself consumes about 8kB of flash. * ACTIVE - Where the main application is placed. The bootloader will attempt to load the application at the start of this partition. This partition is only written to by the bootloader. diff --git a/docs/modules/ROOT/pages/getting_started.adoc b/docs/modules/ROOT/pages/getting_started.adoc index 23102b3b..f3492a3d 100644 --- a/docs/modules/ROOT/pages/getting_started.adoc +++ b/docs/modules/ROOT/pages/getting_started.adoc @@ -46,15 +46,13 @@ You can run an example by opening a terminal and entering the following commands [source, bash] ---- cd examples/nrf -DEFMT_LOG=info cargo run --bin blinky --release +cargo run --bin blinky --release ---- -IMPORTANT: The DEFMT_LOG environment variable controls the example log verbosity. If you do not specify it, you will not see anything logged to the console. - == Whats next? Congratulations, you have your first Embassy application running! Here are some alternatives on where to go from here: -* Read more about the xref:runtime.adoc[runtime]. +* Read more about the xref:runtime.adoc[executor]. * Read more about the xref:hal.adoc[HAL]. * Start xref:basic_application.adoc[writing your application]. diff --git a/docs/modules/ROOT/pages/hal.adoc b/docs/modules/ROOT/pages/hal.adoc index 0b15e2fc..de4ab33b 100644 --- a/docs/modules/ROOT/pages/hal.adoc +++ b/docs/modules/ROOT/pages/hal.adoc @@ -1,9 +1,10 @@ = Hardware Abstraction Layer (HAL) -Embassy provides HAL's for several microcontroller families: +Embassy provides HALs for several microcontroller families: * `embassy-nrf` for the nRF microcontrollers from Nordic Semiconductor * `embassy-stm32` for STM32 microcontrollers from ST Microelectronics * `embassy-rp` for the Raspberry Pi RP2040 microcontrollers -These HALs implement async/await functionality for most peripherals while also implementing the async traits in Embassy. +These HALs implement async/await functionality for most peripherals while also implementing the +async traits in `embedded-hal-async`. You can also use these HALs with another executor. diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc index 9a14e465..0a17c673 100644 --- a/docs/modules/ROOT/pages/index.adoc +++ b/docs/modules/ROOT/pages/index.adoc @@ -15,6 +15,20 @@ In Rust, non-blocking operations can be implemented using async-await. Async-awa == What is Embassy? -Embassy is an executor and a Hardware Access Layer (HAL). The executor is a scheduler that generally executes a fixed number of tasks, allocated at startup, though more can be added later. The HAL is an API that you can use to access peripherals, such as USART, UART, I2C, SPI, CAN, and USB. Embassy provides implementations of both async and blocking APIs where it makes sense. DMA (Direct Memory Access) is an example where async is a good fit, whereas GPIO states are a better fit for a blocking API. +The Embassy project consists of several crates that you can use together or independently: -Embassy may also provide a system timer that you can use for both async and blocking delays. For less than one microsecond, blocking delays should be used because the cost of context-switching is too high and the executor will be unable to provide accurate timing. +* **Executor** - The link:https://docs.embassy.dev/embassy-executor/[embassy-executor] is an async/await executor that generally executes a fixed number of tasks, allocated at startup, though more can be added later. The HAL is an API that you can use to access peripherals, such as USART, UART, I2C, SPI, CAN, and USB. Embassy provides implementations of both async and blocking APIs where it makes sense. DMA (Direct Memory Access) is an example where async is a good fit, whereas GPIO states are a better fit for a blocking API. The executor may also provide a system timer that you can use for both async and blocking delays. For less than one microsecond, blocking delays should be used because the cost of context-switching is too high and the executor will be unable to provide accurate timing. + +* **Hardware Abstraction Layers** - HALs implement safe, idiomatic Rust APIs to use the hardware capabilities, so raw register manipulation is not needed. The Embassy project maintains HALs for select hardware, but you can still use HALs from other projects with Embassy. +** link:https://docs.embassy.dev/embassy-stm32/[embassy-stm32], for all STM32 microcontroller families. +** link:https://docs.embassy.dev/embassy-nrf/[embassy-nrf], for the Nordic Semiconductor nRF52, nRF53, nRF91 series. + +* **Networking** - The link:https://docs.embassy.dev/embassy-net/[embassy-net] network stack implements extensive networking functionality, including Ethernet, IP, TCP, UDP, ICMP and DHCP. Async drastically simplifies managing timeouts and serving multiple connections concurrently. + +* **Bluetooth** - The link:https://github.com/embassy-rs/nrf-softdevice[nrf-softdevice] crate provides Bluetooth Low Energy 4.x and 5.x support for nRF52 microcontrollers. + +* **LoRa** - link:https://docs.embassy.dev/embassy-lora/[embassy-lora] supports LoRa networking on STM32WL wireless microcontrollers and Semtech SX127x transceivers. + +* **USB** - link:https://docs.embassy.dev/embassy-usb/[embassy-usb] implements a device-side USB stack. Implementations for common classes such as USB serial (CDC ACM) and USB HID are available, and a rich builder API allows building your own. + +* **Bootloader and DFU** - link:https://github.com/embassy-rs/embassy/tree/master/embassy-boot[embassy-boot] is a lightweight bootloader supporting firmware application upgrades in a power-fail-safe way, with trial boots and rollbacks. diff --git a/docs/modules/ROOT/pages/runtime.adoc b/docs/modules/ROOT/pages/runtime.adoc index 0adaa21a..a7d6a8d0 100644 --- a/docs/modules/ROOT/pages/runtime.adoc +++ b/docs/modules/ROOT/pages/runtime.adoc @@ -1,6 +1,6 @@ -= Embassy runtime += Embassy executor -The Embassy runtime is an async/await executor designed for embedded usage along with support functionality for interrupts and timers. +The Embassy executor is an async/await executor designed for embedded usage along with support functionality for interrupts and timers. == Features diff --git a/docs/modules/ROOT/pages/traits.adoc b/docs/modules/ROOT/pages/traits.adoc deleted file mode 100644 index 38b8f286..00000000 --- a/docs/modules/ROOT/pages/traits.adoc +++ /dev/null @@ -1,8 +0,0 @@ -= Embassy Traits - -Embassy provides a set of traits and types specifically designed for `async` usage. Many of these futures will be upstreamed to the `embedded-hal` crate at some point in the future, probably when the required GAT (Generic Associated Types) feature is stabilized in Rust. - -* `embassy::io`: `AsyncBufRead`, `AsyncWrite`. Traits for byte-stream IO, essentially `no_std` compatible versions of `futures::io`. The primary reason for re-defining these traits is that the `futures::io` variant requires `std::io::Error`, which does not work in the `no_std` environment. -* `embassy::time`: Time `Driver` trait that is implemented for different platforms. Time in Embassy is represented using the `Duration` and `Instant` types. - -These traits are implemented by the platform-specific crates, such as `embassy-nrf` or `embassy-stm32`. From 13b1ca1eb65ddf969526fd71841145ad9a0502f8 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 17 Aug 2022 13:44:24 +0200 Subject: [PATCH 19/31] Update nightly. --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index c6d0f485..f5e342ed 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ # Before upgrading check that everything is available on all tier1 targets here: # https://rust-lang.github.io/rustup-components-history [toolchain] -channel = "nightly-2022-07-13" +channel = "nightly-2022-08-16" components = [ "rust-src", "rustfmt" ] targets = [ "thumbv7em-none-eabi", From 72cd015c1ad107003e56ffcec3441b43066e4bda Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 17 Aug 2022 14:44:18 +0200 Subject: [PATCH 20/31] stm32/sdmmc: remove cast no longer allowed on latest nightly due to nonexhaustive enum. --- embassy-stm32/src/sdmmc/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/embassy-stm32/src/sdmmc/mod.rs b/embassy-stm32/src/sdmmc/mod.rs index 1de4b2aa..3ad31ec8 100644 --- a/embassy-stm32/src/sdmmc/mod.rs +++ b/embassy-stm32/src/sdmmc/mod.rs @@ -999,10 +999,17 @@ impl SdmmcInner { fn clkcr_set_clkdiv(&self, freq: u32, width: BusWidth, ker_ck: Hertz, clock: &mut Hertz) -> Result<(), Error> { let regs = self.0; + let width_u32 = match width { + BusWidth::One => 1u32, + BusWidth::Four => 4u32, + BusWidth::Eight => 8u32, + _ => panic!("Invalid Bus Width"), + }; + let (clkdiv, new_clock) = clk_div(ker_ck, freq)?; // Enforce AHB and SDMMC_CK clock relation. See RM0433 Rev 7 // Section 55.5.8 - let sdmmc_bus_bandwidth = new_clock.0 * (width as u32); + let sdmmc_bus_bandwidth = new_clock.0 * width_u32; assert!(ker_ck.0 > 3 * sdmmc_bus_bandwidth / 32); *clock = new_clock; From 2649f13dc7c0bff87752f4fbf0d3cab7b1468e12 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 17 Aug 2022 15:01:07 +0200 Subject: [PATCH 21/31] stm32/rcc: fix unnecessary parentheses --- embassy-stm32/src/rcc/u5.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/embassy-stm32/src/rcc/u5.rs b/embassy-stm32/src/rcc/u5.rs index 1f7e3907..960c4532 100644 --- a/embassy-stm32/src/rcc/u5.rs +++ b/embassy-stm32/src/rcc/u5.rs @@ -63,7 +63,7 @@ seq_macro::seq!(N in 2..=128 { match self { PllClkDiv::NotDivided => 1, #( - PllClkDiv::Div~N => (N + 1), + PllClkDiv::Div~N => N + 1, )* } } @@ -81,7 +81,7 @@ seq_macro::seq!(N in 4..=512 { pub enum PllN { NotMultiplied, #( - Mul~N = (N-1), + Mul~N = N-1, )* } @@ -90,7 +90,7 @@ seq_macro::seq!(N in 4..=512 { match self { PllN::NotMultiplied => 1, #( - PllN::Mul~N => (N + 1), + PllN::Mul~N => N + 1, )* } } From ef9e373ec444c781a81a528b4215582b018b43d5 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 17 Aug 2022 14:49:42 +0200 Subject: [PATCH 22/31] macros/interrupt_take: do not assume embassy-executor is a dependency of the user crate. --- embassy-cortex-m/src/interrupt.rs | 6 ++++++ embassy-macros/src/macros/cortex_m_interrupt_take.rs | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/embassy-cortex-m/src/interrupt.rs b/embassy-cortex-m/src/interrupt.rs index 7358caa4..be11c5eb 100644 --- a/embassy-cortex-m/src/interrupt.rs +++ b/embassy-cortex-m/src/interrupt.rs @@ -6,6 +6,12 @@ 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. +#[doc(hidden)] +pub mod _export { + pub use atomic_polyfill as atomic; +} + /// Implementation detail, do not use outside embassy crates. #[doc(hidden)] pub struct Handler { diff --git a/embassy-macros/src/macros/cortex_m_interrupt_take.rs b/embassy-macros/src/macros/cortex_m_interrupt_take.rs index 133eb5c2..9e40a56f 100644 --- a/embassy-macros/src/macros/cortex_m_interrupt_take.rs +++ b/embassy-macros/src/macros/cortex_m_interrupt_take.rs @@ -16,15 +16,15 @@ pub fn run(name: syn::Ident) -> Result { static HANDLER: interrupt::Handler; } - let func = HANDLER.func.load(::embassy_executor::export::atomic::Ordering::Relaxed); - let ctx = HANDLER.ctx.load(::embassy_executor::export::atomic::Ordering::Relaxed); + let func = HANDLER.func.load(interrupt::_export::atomic::Ordering::Relaxed); + let ctx = HANDLER.ctx.load(interrupt::_export::atomic::Ordering::Relaxed); let func: fn(*mut ()) = ::core::mem::transmute(func); func(ctx) } - static TAKEN: ::embassy_executor::export::atomic::AtomicBool = ::embassy_executor::export::atomic::AtomicBool::new(false); + static TAKEN: interrupt::_export::atomic::AtomicBool = interrupt::_export::atomic::AtomicBool::new(false); - if TAKEN.compare_exchange(false, true, ::embassy_executor::export::atomic::Ordering::AcqRel, ::embassy_executor::export::atomic::Ordering::Acquire).is_err() { + if TAKEN.compare_exchange(false, true, interrupt::_export::atomic::Ordering::AcqRel, interrupt::_export::atomic::Ordering::Acquire).is_err() { core::panic!("IRQ Already taken"); } From bd0aaec6242c86d126fdb3784ae603cbf329957b Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 17 Aug 2022 15:03:12 +0200 Subject: [PATCH 23/31] macros: remove embassy_prefix attr. This was used in the past for reexporting the macros from drogue-device, which is no longer using it. Also, it is a pain to support, so we don't want it. --- embassy-macros/src/macros/main.rs | 57 +++++++++++++------------------ embassy-macros/src/macros/task.rs | 10 ++---- embassy-macros/src/util/mod.rs | 1 - embassy-macros/src/util/path.rs | 41 ---------------------- 4 files changed, 26 insertions(+), 83 deletions(-) delete mode 100644 embassy-macros/src/util/path.rs diff --git a/embassy-macros/src/macros/main.rs b/embassy-macros/src/macros/main.rs index a8c8bb0d..b040edc5 100644 --- a/embassy-macros/src/macros/main.rs +++ b/embassy-macros/src/macros/main.rs @@ -3,28 +3,16 @@ use proc_macro2::TokenStream; use quote::quote; use crate::util::ctxt::Ctxt; -use crate::util::path::ModulePrefix; - -#[cfg(feature = "stm32")] -const HAL: Option<&str> = Some("embassy_stm32"); -#[cfg(feature = "nrf")] -const HAL: Option<&str> = Some("embassy_nrf"); -#[cfg(feature = "rp")] -const HAL: Option<&str> = Some("embassy_rp"); -#[cfg(not(any(feature = "stm32", feature = "nrf", feature = "rp")))] -const HAL: Option<&str> = None; #[derive(Debug, FromMeta)] struct Args { - #[darling(default)] - embassy_prefix: ModulePrefix, - #[allow(unused)] #[darling(default)] config: Option, } pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result { + #[allow(unused_variables)] let args = Args::from_list(&args).map_err(|e| e.write_errors())?; let fargs = f.sig.inputs.clone(); @@ -38,26 +26,32 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result = 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 { + if hal.is_none() && fargs.len() != 1 { ctxt.error_spanned_by(&f.sig, "main function must have 1 argument"); } ctxt.check()?; - let embassy_prefix = args.embassy_prefix; - let embassy_prefix_lit = embassy_prefix.literal(); - let embassy_path = embassy_prefix.append("embassy_executor").path(); let f_body = f.block; #[cfg(feature = "wasm")] let main = quote! { #[wasm_bindgen::prelude::wasm_bindgen(start)] pub fn main() -> Result<(), wasm_bindgen::JsValue> { - static EXECUTOR: ::embassy_util::Forever<#embassy_path::executor::Executor> = ::embassy_util::Forever::new(); - let executor = EXECUTOR.put(#embassy_path::executor::Executor::new()); + static EXECUTOR: ::embassy_util::Forever<::embassy_executor::executor::Executor> = ::embassy_util::Forever::new(); + let executor = EXECUTOR.put(::embassy_executor::executor::Executor::new()); executor.start(|spawner| { spawner.spawn(__embassy_main(spawner)).unwrap(); @@ -70,7 +64,7 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result ! { - let mut executor = #embassy_path::executor::Executor::new(); + let mut executor = ::embassy_executor::executor::Executor::new(); let executor = unsafe { __make_static(&mut executor) }; executor.run(|spawner| { @@ -87,16 +81,13 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result { - let embassy_hal_path = embassy_prefix.append(hal).path(); - ( - quote!( - let p = #embassy_hal_path::init(#config); - ), - quote!(p), - ) - } + let (hal_setup, peris_arg) = match hal { + Some(hal) => ( + quote!( + let p = #hal::init(#config); + ), + quote!(p), + ), None => (quote!(), quote!()), }; @@ -105,7 +96,7 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result ! { #hal_setup - let mut executor = #embassy_path::executor::Executor::new(); + let mut executor = ::embassy_executor::executor::Executor::new(); let executor = unsafe { __make_static(&mut executor) }; executor.run(|spawner| { @@ -116,7 +107,7 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result, - #[darling(default)] - embassy_prefix: ModulePrefix, } pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result { let args = Args::from_list(&args).map_err(|e| e.write_errors())?; - let embassy_prefix = args.embassy_prefix.append("embassy_executor"); - let embassy_path = embassy_prefix.path(); - let pool_size: usize = args.pool_size.unwrap_or(1); let ctxt = Ctxt::new(); @@ -70,9 +64,9 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result #embassy_path::executor::SpawnToken { + #visibility fn #task_ident(#fargs) -> ::embassy_executor::executor::SpawnToken { type Fut = impl ::core::future::Future + 'static; - static POOL: #embassy_path::executor::raw::TaskPool = #embassy_path::executor::raw::TaskPool::new(); + static POOL: ::embassy_executor::executor::raw::TaskPool = ::embassy_executor::executor::raw::TaskPool::new(); unsafe { POOL._spawn_async_fn(move || #task_inner_ident(#(#arg_names,)*)) } } }; diff --git a/embassy-macros/src/util/mod.rs b/embassy-macros/src/util/mod.rs index c2f2dfd6..28702809 100644 --- a/embassy-macros/src/util/mod.rs +++ b/embassy-macros/src/util/mod.rs @@ -1,2 +1 @@ pub mod ctxt; -pub mod path; diff --git a/embassy-macros/src/util/path.rs b/embassy-macros/src/util/path.rs deleted file mode 100644 index 00fca7bd..00000000 --- a/embassy-macros/src/util/path.rs +++ /dev/null @@ -1,41 +0,0 @@ -use darling::{FromMeta, Result}; -use proc_macro2::Span; -use syn::{LitStr, Path}; - -#[derive(Debug)] -pub struct ModulePrefix { - literal: LitStr, -} - -impl ModulePrefix { - pub fn new(path: &str) -> Self { - let literal = LitStr::new(path, Span::call_site()); - Self { literal } - } - - pub fn append(&self, component: &str) -> ModulePrefix { - let mut lit = self.literal().value(); - lit.push_str(component); - Self::new(lit.as_str()) - } - - pub fn path(&self) -> Path { - self.literal.parse().unwrap() - } - - pub fn literal(&self) -> &LitStr { - &self.literal - } -} - -impl FromMeta for ModulePrefix { - fn from_string(value: &str) -> Result { - Ok(ModulePrefix::new(value)) - } -} - -impl Default for ModulePrefix { - fn default() -> ModulePrefix { - ModulePrefix::new("::") - } -} From 67edea41686084a444e1455d17d5482b10c54abd Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sun, 14 Aug 2022 23:16:06 +0200 Subject: [PATCH 24/31] Update to critical-section 1.0, atomic-polyfill 1.0 --- embassy-boot/nrf/Cargo.toml | 2 +- embassy-boot/stm32/Cargo.toml | 2 +- embassy-cortex-m/Cargo.toml | 6 +++--- embassy-executor/Cargo.toml | 4 ++-- embassy-nrf/Cargo.toml | 4 ++-- embassy-rp/Cargo.toml | 6 +++--- embassy-stm32/Cargo.toml | 7 +++---- embassy-stm32/src/interrupt.rs | 3 +-- embassy-util/Cargo.toml | 7 +++++-- examples/boot/application/nrf/Cargo.toml | 2 +- examples/boot/application/stm32f3/Cargo.toml | 2 +- examples/boot/application/stm32f7/Cargo.toml | 2 +- examples/boot/application/stm32h7/Cargo.toml | 2 +- examples/boot/application/stm32l0/Cargo.toml | 2 +- examples/boot/application/stm32l1/Cargo.toml | 2 +- examples/boot/application/stm32l4/Cargo.toml | 2 +- examples/boot/application/stm32wl/Cargo.toml | 2 +- examples/boot/bootloader/nrf/Cargo.toml | 2 +- examples/boot/bootloader/stm32/Cargo.toml | 2 +- examples/nrf/Cargo.toml | 2 +- examples/rp/Cargo.toml | 3 +-- examples/std/Cargo.toml | 1 + examples/stm32f0/Cargo.toml | 2 +- examples/stm32f1/Cargo.toml | 2 +- examples/stm32f2/Cargo.toml | 2 +- examples/stm32f3/Cargo.toml | 2 +- examples/stm32f4/Cargo.toml | 2 +- examples/stm32f7/Cargo.toml | 4 ++-- examples/stm32g0/Cargo.toml | 2 +- examples/stm32g4/Cargo.toml | 2 +- examples/stm32h7/Cargo.toml | 4 ++-- examples/stm32l0/Cargo.toml | 2 +- examples/stm32l1/Cargo.toml | 2 +- examples/stm32l4/Cargo.toml | 2 +- examples/stm32l5/Cargo.toml | 2 +- examples/stm32u5/Cargo.toml | 2 +- examples/stm32wb/Cargo.toml | 2 +- examples/stm32wl/Cargo.toml | 2 +- examples/wasm/Cargo.toml | 2 +- stm32-metapac/Cargo.toml | 2 +- tests/rp/Cargo.toml | 2 +- tests/stm32/Cargo.toml | 2 +- 42 files changed, 56 insertions(+), 55 deletions(-) diff --git a/embassy-boot/nrf/Cargo.toml b/embassy-boot/nrf/Cargo.toml index 4db6892b..b06e8102 100644 --- a/embassy-boot/nrf/Cargo.toml +++ b/embassy-boot/nrf/Cargo.toml @@ -18,7 +18,7 @@ defmt = { version = "0.3", optional = true } embassy-util = { path = "../../embassy-util" } embassy-nrf = { path = "../../embassy-nrf", default-features = false, features = ["nightly"] } embassy-boot = { path = "../boot", default-features = false } -cortex-m = { version = "0.7" } +cortex-m = { version = "0.7.6" } cortex-m-rt = { version = "0.7" } embedded-storage = "0.3.0" embedded-storage-async = "0.3.0" diff --git a/embassy-boot/stm32/Cargo.toml b/embassy-boot/stm32/Cargo.toml index f891f769..d8f49253 100644 --- a/embassy-boot/stm32/Cargo.toml +++ b/embassy-boot/stm32/Cargo.toml @@ -20,7 +20,7 @@ log = { version = "0.4", optional = true } embassy-util = { path = "../../embassy-util" } embassy-stm32 = { path = "../../embassy-stm32", default-features = false, features = ["nightly"] } embassy-boot = { path = "../boot", default-features = false } -cortex-m = { version = "0.7" } +cortex-m = { version = "0.7.6" } cortex-m-rt = { version = "0.7" } embedded-storage = "0.3.0" embedded-storage-async = "0.3.0" diff --git a/embassy-cortex-m/Cargo.toml b/embassy-cortex-m/Cargo.toml index 454f34e0..1f16da31 100644 --- a/embassy-cortex-m/Cargo.toml +++ b/embassy-cortex-m/Cargo.toml @@ -39,8 +39,8 @@ embassy-util = { version = "0.1.0", path = "../embassy-util" } embassy-executor = { version = "0.1.0", path = "../embassy-executor"} embassy-macros = { version = "0.1.0", path = "../embassy-macros"} embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common"} -atomic-polyfill = "0.1.5" -critical-section = "0.2.5" +atomic-polyfill = "1.0.1" +critical-section = "1.1" cfg-if = "1.0.0" -cortex-m = "0.7.3" +cortex-m = "0.7.6" diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml index d8ac4ac0..45d0d2de 100644 --- a/embassy-executor/Cargo.toml +++ b/embassy-executor/Cargo.toml @@ -60,8 +60,8 @@ embedded-hal-async = { version = "0.1.0-alpha.1", optional = true} futures-util = { version = "0.3.17", default-features = false } embassy-macros = { version = "0.1.0", path = "../embassy-macros"} -atomic-polyfill = "0.1.5" -critical-section = "0.2.5" +atomic-polyfill = "1.0.1" +critical-section = "1.1" cfg-if = "1.0.0" # WASM dependencies diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 75780d41..72f4b538 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -80,9 +80,9 @@ embedded-io = { version = "0.3.0", features = ["async"], optional = true } defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } cortex-m-rt = ">=0.6.15,<0.8" -cortex-m = "0.7.3" +cortex-m = "0.7.6" futures = { version = "0.3.17", default-features = false } -critical-section = "0.2.5" +critical-section = "1.1" rand_core = "0.6.3" fixed = "1.10.0" embedded-storage = "0.3.0" diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index 303617ff..eeb4ec43 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -33,12 +33,12 @@ embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = 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 = "0.1.5" +atomic-polyfill = "1.0.1" defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } cortex-m-rt = ">=0.6.15,<0.8" -cortex-m = "0.7.3" -critical-section = "0.2.5" +cortex-m = "0.7.6" +critical-section = "1.1" futures = { version = "0.3.17", default-features = false, features = ["async-await"] } rp2040-pac2 = { git = "https://github.com/embassy-rs/rp2040-pac2", rev="9ad7223a48a065e612bc7dc7be5bf5bd0b41cfc4", features = ["rt"] } diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index ff228cc8..7260f06d 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -50,14 +50,13 @@ embedded-storage-async = { version = "0.3.0", optional = true } defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } cortex-m-rt = ">=0.6.15,<0.8" -cortex-m = "0.7.3" +cortex-m = "0.7.6" futures = { version = "0.3.17", default-features = false, features = ["async-await"] } rand_core = "0.6.3" sdio-host = "0.5.0" embedded-sdmmc = { git = "https://github.com/thalesfragoso/embedded-sdmmc-rs", branch = "async", optional = true } -critical-section = "0.2.5" -bare-metal = "1.0.0" -atomic-polyfill = "0.1.5" +critical-section = "1.1" +atomic-polyfill = "1.0.1" stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", features = ["rt"] } vcell = "0.1.3" bxcan = "0.7.0" diff --git a/embassy-stm32/src/interrupt.rs b/embassy-stm32/src/interrupt.rs index 9dc1f204..b66e4c7e 100644 --- a/embassy-stm32/src/interrupt.rs +++ b/embassy-stm32/src/interrupt.rs @@ -1,5 +1,4 @@ -pub use bare_metal::Mutex; -pub use critical_section::CriticalSection; +pub use critical_section::{CriticalSection, Mutex}; pub use embassy_cortex_m::interrupt::*; pub use crate::_generated::interrupt::*; diff --git a/embassy-util/Cargo.toml b/embassy-util/Cargo.toml index 00de5e85..d4708d73 100644 --- a/embassy-util/Cargo.toml +++ b/embassy-util/Cargo.toml @@ -17,8 +17,8 @@ defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } futures-util = { version = "0.3.17", default-features = false } -atomic-polyfill = "0.1.5" -critical-section = "0.2.5" +atomic-polyfill = "1.0.1" +critical-section = "1.1" heapless = "0.7.5" cfg-if = "1.0.0" embedded-io = "0.3.0" @@ -28,3 +28,6 @@ futures-executor = { version = "0.3.17", features = [ "thread-pool" ] } futures-test = "0.3.17" futures-timer = "3.0.2" futures-util = { version = "0.3.17", features = [ "channel" ] } + +# Enable critical-section implementation for std, for tests +critical-section = { version = "1.1", features = ["std"] } diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml index dd9bcc09..ca4fb984 100644 --- a/examples/boot/application/nrf/Cargo.toml +++ b/examples/boot/application/nrf/Cargo.toml @@ -15,5 +15,5 @@ defmt-rtt = { version = "0.3", optional = true } panic-reset = { version = "0.1.1" } embedded-hal = { version = "0.2.6" } -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml index 313808a0..17df1816 100644 --- a/examples/boot/application/stm32f3/Cargo.toml +++ b/examples/boot/application/stm32f3/Cargo.toml @@ -15,7 +15,7 @@ defmt-rtt = { version = "0.3", optional = true } panic-reset = { version = "0.1.1" } embedded-hal = { version = "0.2.6" } -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" [features] diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml index 2a4741dc..e3a3ff38 100644 --- a/examples/boot/application/stm32f7/Cargo.toml +++ b/examples/boot/application/stm32f7/Cargo.toml @@ -15,7 +15,7 @@ defmt-rtt = { version = "0.3", optional = true } panic-reset = { version = "0.1.1" } embedded-hal = { version = "0.2.6" } -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" [features] diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml index c6420e8a..24dd3410 100644 --- a/examples/boot/application/stm32h7/Cargo.toml +++ b/examples/boot/application/stm32h7/Cargo.toml @@ -15,7 +15,7 @@ defmt-rtt = { version = "0.3", optional = true } panic-reset = { version = "0.1.1" } embedded-hal = { version = "0.2.6" } -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" [features] diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml index a6936419..48659d80 100644 --- a/examples/boot/application/stm32l0/Cargo.toml +++ b/examples/boot/application/stm32l0/Cargo.toml @@ -15,7 +15,7 @@ defmt-rtt = { version = "0.3", optional = true } panic-reset = { version = "0.1.1" } embedded-hal = { version = "0.2.6" } -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" [features] diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml index 5e53cd5f..f9693326 100644 --- a/examples/boot/application/stm32l1/Cargo.toml +++ b/examples/boot/application/stm32l1/Cargo.toml @@ -15,7 +15,7 @@ defmt-rtt = { version = "0.3", optional = true } panic-reset = { version = "0.1.1" } embedded-hal = { version = "0.2.6" } -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" [features] diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml index bbb5e7e1..f529c871 100644 --- a/examples/boot/application/stm32l4/Cargo.toml +++ b/examples/boot/application/stm32l4/Cargo.toml @@ -15,7 +15,7 @@ defmt-rtt = { version = "0.3", optional = true } panic-reset = { version = "0.1.1" } embedded-hal = { version = "0.2.6" } -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" [features] diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml index 62123a87..67973a24 100644 --- a/examples/boot/application/stm32wl/Cargo.toml +++ b/examples/boot/application/stm32wl/Cargo.toml @@ -15,7 +15,7 @@ defmt-rtt = { version = "0.3", optional = true } panic-reset = { version = "0.1.1" } embedded-hal = { version = "0.2.6" } -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" [features] diff --git a/examples/boot/bootloader/nrf/Cargo.toml b/examples/boot/bootloader/nrf/Cargo.toml index 9683bff1..aa2a13ec 100644 --- a/examples/boot/bootloader/nrf/Cargo.toml +++ b/examples/boot/bootloader/nrf/Cargo.toml @@ -10,7 +10,7 @@ defmt-rtt = { version = "0.3", optional = true } embassy-nrf = { path = "../../../../embassy-nrf", default-features = false, features = ["nightly"] } embassy-boot-nrf = { path = "../../../../embassy-boot/nrf", default-features = false } -cortex-m = { version = "0.7" } +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = { version = "0.7" } cfg-if = "1.0.0" diff --git a/examples/boot/bootloader/stm32/Cargo.toml b/examples/boot/bootloader/stm32/Cargo.toml index 4a331952..49177710 100644 --- a/examples/boot/bootloader/stm32/Cargo.toml +++ b/examples/boot/bootloader/stm32/Cargo.toml @@ -10,7 +10,7 @@ defmt-rtt = { version = "0.3", optional = true } embassy-stm32 = { path = "../../../../embassy-stm32", default-features = false, features = ["nightly"] } embassy-boot-stm32 = { path = "../../../../embassy-boot/stm32", default-features = false } -cortex-m = { version = "0.7" } +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = { version = "0.7" } embedded-storage = "0.3.0" embedded-storage-async = "0.3.0" diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index 91edbd36..2d28623c 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml @@ -21,7 +21,7 @@ embedded-io = "0.3.0" defmt = "0.3" defmt-rtt = "0.3" -cortex-m = "0.7.3" +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"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 94c3d801..f58ec194 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml @@ -8,12 +8,11 @@ version = "0.1.0" embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime"] } embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac"] } -atomic-polyfill = "0.1.5" defmt = "0.3" defmt-rtt = "0.3" -cortex-m = "0.7.3" +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"] } futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] } diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 427b9343..47933894 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml @@ -8,6 +8,7 @@ embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["lo embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "std", "time", "nightly"] } embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "log", "medium-ethernet", "tcp", "udp", "dhcpv4", "pool-16"] } embedded-io = { version = "0.3.0", features = ["async", "std", "futures"] } +critical-section = { version = "1.1", features = ["std"] } async-io = "1.6.0" env_logger = "0.9.0" diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml index 3ba29763..27bd8a69 100644 --- a/examples/stm32f0/Cargo.toml +++ b/examples/stm32f0/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" defmt = "0.3" defmt-rtt = "0.3" diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml index 9ce553b6..f0e046f5 100644 --- a/examples/stm32f1/Cargo.toml +++ b/examples/stm32f1/Cargo.toml @@ -13,7 +13,7 @@ embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", fea defmt = "0.3" defmt-rtt = "0.3" -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" panic-probe = { version = "0.3", features = ["print-defmt"] } diff --git a/examples/stm32f2/Cargo.toml b/examples/stm32f2/Cargo.toml index a3fb736d..0825f618 100644 --- a/examples/stm32f2/Cargo.toml +++ b/examples/stm32f2/Cargo.toml @@ -11,7 +11,7 @@ embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [" defmt = "0.3" defmt-rtt = "0.3" -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" panic-probe = { version = "0.3", features = ["print-defmt"] } diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml index 410e9b3e..b7f70b11 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/Cargo.toml @@ -14,7 +14,7 @@ embassy-usb-hid = { version = "0.1.0", path = "../../embassy-usb-hid", features defmt = "0.3" defmt-rtt = "0.3" -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" panic-probe = { version = "0.3", features = ["print-defmt"] } diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index 3c58320d..e69974c5 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml @@ -12,7 +12,7 @@ embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [" defmt = "0.3" defmt-rtt = "0.3" -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" embedded-io = "0.3.0" diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index 081bed84..8dde9d4f 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml @@ -13,7 +13,7 @@ embedded-io = { version = "0.3.0", features = ["async"] } defmt = "0.3" defmt-rtt = "0.3" -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" panic-probe = { version = "0.3", features = ["print-defmt"] } @@ -21,5 +21,5 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa heapless = { version = "0.7.5", default-features = false } nb = "1.0.0" rand_core = "0.6.3" -critical-section = "0.2.3" +critical-section = "1.1" embedded-storage = "0.3.0" diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml index 3dedeac6..ab5567bb 100644 --- a/examples/stm32g0/Cargo.toml +++ b/examples/stm32g0/Cargo.toml @@ -11,7 +11,7 @@ embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [" defmt = "0.3" defmt-rtt = "0.3" -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" panic-probe = { version = "0.3", features = ["print-defmt"] } diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml index 60c62ad1..61150a4e 100644 --- a/examples/stm32g4/Cargo.toml +++ b/examples/stm32g4/Cargo.toml @@ -12,7 +12,7 @@ embassy-hal-common = {version = "0.1.0", path = "../../embassy-hal-common" } defmt = "0.3" defmt-rtt = "0.3" -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" panic-probe = { version = "0.3", features = ["print-defmt"] } diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 89604675..70038d15 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -13,7 +13,7 @@ embedded-io = { version = "0.3.0", features = ["async"] } defmt = "0.3" defmt-rtt = "0.3" -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } @@ -23,7 +23,7 @@ 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 } rand_core = "0.6.3" -critical-section = "0.2.5" +critical-section = "1.1" micromath = "2.0.0" stm32-fmc = "0.2.4" embedded-storage = "0.3.0" diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 7edda042..367b89db 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml @@ -22,7 +22,7 @@ defmt-rtt = "0.3" embedded-storage = "0.3.0" embedded-io = "0.3.0" -cortex-m = "0.7.3" +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"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml index d69de9c5..dba1dd7d 100644 --- a/examples/stm32l1/Cargo.toml +++ b/examples/stm32l1/Cargo.toml @@ -11,7 +11,7 @@ embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [" defmt = "0.3" defmt-rtt = "0.3" -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" panic-probe = { version = "0.3", features = ["print-defmt"] } diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index 8ac974c9..1d9c21a0 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml @@ -14,7 +14,7 @@ embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [" defmt = "0.3" defmt-rtt = "0.3" -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index 6466994e..3e3a11d0 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml @@ -20,7 +20,7 @@ defmt = "0.3" defmt-rtt = "0.3" panic-probe = { version = "0.3", features = ["print-defmt"] } -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" futures = { version = "0.3.17", default-features = false, features = ["async-await"] } diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml index 4ce95be4..d80260f0 100644 --- a/examples/stm32u5/Cargo.toml +++ b/examples/stm32u5/Cargo.toml @@ -11,7 +11,7 @@ embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [" defmt = "0.3" defmt-rtt = "0.3" -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" panic-probe = { version = "0.3", features = ["print-defmt"] } diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index dc9107dd..59f9401b 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml @@ -11,7 +11,7 @@ embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [" defmt = "0.3" defmt-rtt = "0.3" -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" panic-probe = { version = "0.3", features = ["print-defmt"] } diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index 00d63f02..f886fae7 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml @@ -15,7 +15,7 @@ lorawan = { version = "0.7.1", default-features = false, features = ["default-cr defmt = "0.3" defmt-rtt = "0.3" -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" embedded-storage = "0.3.0" diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml index 4e26f023..20433689 100644 --- a/examples/wasm/Cargo.toml +++ b/examples/wasm/Cargo.toml @@ -14,4 +14,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 = "0.2.5" +critical-section = "1.1" diff --git a/stm32-metapac/Cargo.toml b/stm32-metapac/Cargo.toml index 31d70778..9d5aba0c 100644 --- a/stm32-metapac/Cargo.toml +++ b/stm32-metapac/Cargo.toml @@ -40,7 +40,7 @@ flavors = [ ] [dependencies] -cortex-m = "0.7.3" +cortex-m = "0.7.6" cortex-m-rt = { version = ">=0.6.15,<0.8", optional = true } # BEGIN BUILD DEPENDENCIES diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index d19243b9..d105f0e6 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -11,7 +11,7 @@ embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["nightl defmt = "0.3.0" defmt-rtt = "0.3.0" -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index c1cca99d..5fc67e13 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -20,7 +20,7 @@ embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [" defmt = "0.3.0" defmt-rtt = "0.3.0" -cortex-m = "0.7.3" +cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } From fc6e1e06b305d302d1b7ad17e8ef3a9be986c358 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 17 Aug 2022 18:49:55 +0200 Subject: [PATCH 25/31] Remove HAL initialization from #[embassy::main] macro. --- README.md | 4 +- docs/modules/ROOT/examples/basic/src/main.rs | 5 +- .../layer-by-layer/blinky-async/src/main.rs | 4 +- embassy-cortex-m/src/interrupt.rs | 3 +- embassy-macros/Cargo.toml | 3 - embassy-macros/src/macros/main.rs | 62 ++++--------------- embassy-nrf/Cargo.toml | 1 - embassy-nrf/src/chips/nrf52805.rs | 2 +- embassy-nrf/src/chips/nrf52810.rs | 2 +- embassy-nrf/src/chips/nrf52811.rs | 2 +- embassy-nrf/src/chips/nrf52820.rs | 2 +- embassy-nrf/src/chips/nrf52832.rs | 2 +- embassy-nrf/src/chips/nrf52833.rs | 2 +- embassy-nrf/src/chips/nrf52840.rs | 2 +- embassy-nrf/src/chips/nrf5340_app.rs | 2 +- embassy-nrf/src/chips/nrf5340_net.rs | 2 +- embassy-nrf/src/chips/nrf9160.rs | 2 +- embassy-nrf/src/lib.rs | 2 +- embassy-rp/Cargo.toml | 1 - embassy-rp/src/interrupt.rs | 2 +- embassy-rp/src/lib.rs | 2 +- embassy-stm32/Cargo.toml | 1 - embassy-stm32/build.rs | 2 +- embassy-stm32/src/lib.rs | 2 +- examples/boot/application/nrf/src/bin/a.rs | 5 +- examples/boot/application/nrf/src/bin/b.rs | 5 +- .../boot/application/stm32f3/src/bin/a.rs | 5 +- .../boot/application/stm32f3/src/bin/b.rs | 4 +- .../boot/application/stm32f7/src/bin/a.rs | 5 +- .../boot/application/stm32f7/src/bin/b.rs | 4 +- .../boot/application/stm32h7/src/bin/a.rs | 5 +- .../boot/application/stm32h7/src/bin/b.rs | 4 +- .../boot/application/stm32l0/src/bin/a.rs | 5 +- .../boot/application/stm32l0/src/bin/b.rs | 4 +- .../boot/application/stm32l1/src/bin/a.rs | 5 +- .../boot/application/stm32l1/src/bin/b.rs | 4 +- .../boot/application/stm32l4/src/bin/a.rs | 5 +- .../boot/application/stm32l4/src/bin/b.rs | 4 +- .../boot/application/stm32wl/src/bin/a.rs | 5 +- .../boot/application/stm32wl/src/bin/b.rs | 4 +- examples/nrf/src/bin/awaitable_timer.rs | 5 +- examples/nrf/src/bin/blinky.rs | 4 +- examples/nrf/src/bin/buffered_uart.rs | 5 +- examples/nrf/src/bin/channel.rs | 4 +- .../nrf/src/bin/channel_sender_receiver.rs | 4 +- .../nrf/src/bin/executor_fairness_test.rs | 4 +- examples/nrf/src/bin/gpiote_channel.rs | 4 +- examples/nrf/src/bin/gpiote_port.rs | 4 +- examples/nrf/src/bin/mutex.rs | 4 +- examples/nrf/src/bin/nvmc.rs | 4 +- examples/nrf/src/bin/ppi.rs | 4 +- examples/nrf/src/bin/pubsub.rs | 3 +- examples/nrf/src/bin/pwm.rs | 4 +- examples/nrf/src/bin/pwm_double_sequence.rs | 4 +- examples/nrf/src/bin/pwm_sequence.rs | 4 +- examples/nrf/src/bin/pwm_sequence_ppi.rs | 4 +- examples/nrf/src/bin/pwm_sequence_ws2812b.rs | 4 +- examples/nrf/src/bin/pwm_servo.rs | 4 +- examples/nrf/src/bin/qdec.rs | 5 +- examples/nrf/src/bin/qspi.rs | 5 +- examples/nrf/src/bin/qspi_lowpower.rs | 5 +- examples/nrf/src/bin/rng.rs | 5 +- examples/nrf/src/bin/saadc.rs | 5 +- examples/nrf/src/bin/saadc_continuous.rs | 5 +- examples/nrf/src/bin/self_spawn.rs | 4 +- .../src/bin/self_spawn_current_executor.rs | 4 +- examples/nrf/src/bin/spim.rs | 5 +- examples/nrf/src/bin/temp.rs | 5 +- examples/nrf/src/bin/timer.rs | 4 +- examples/nrf/src/bin/twim.rs | 5 +- examples/nrf/src/bin/twim_lowpower.rs | 5 +- examples/nrf/src/bin/uart.rs | 5 +- examples/nrf/src/bin/uart_idle.rs | 5 +- examples/nrf/src/bin/uart_split.rs | 5 +- examples/nrf/src/bin/usb_ethernet.rs | 5 +- examples/nrf/src/bin/usb_hid_keyboard.rs | 5 +- examples/nrf/src/bin/usb_hid_mouse.rs | 5 +- examples/nrf/src/bin/usb_serial.rs | 5 +- examples/nrf/src/bin/usb_serial_multitask.rs | 5 +- examples/nrf/src/bin/wdt.rs | 4 +- examples/rp/src/bin/blinky.rs | 5 +- examples/rp/src/bin/button.rs | 4 +- examples/rp/src/bin/gpio_async.rs | 5 +- examples/rp/src/bin/spi.rs | 5 +- examples/rp/src/bin/spi_display.rs | 5 +- examples/rp/src/bin/uart.rs | 5 +- examples/stm32f0/src/bin/hello.rs | 4 +- examples/stm32f1/src/bin/adc.rs | 4 +- examples/stm32f1/src/bin/blinky.rs | 4 +- examples/stm32f1/src/bin/hello.rs | 7 ++- examples/stm32f1/src/bin/usb_serial.rs | 7 ++- examples/stm32f2/src/bin/blinky.rs | 4 +- examples/stm32f2/src/bin/pll.rs | 7 ++- examples/stm32f3/src/bin/blinky.rs | 4 +- examples/stm32f3/src/bin/button_events.rs | 4 +- examples/stm32f3/src/bin/button_exti.rs | 4 +- examples/stm32f3/src/bin/flash.rs | 4 +- examples/stm32f3/src/bin/hello.rs | 7 ++- examples/stm32f3/src/bin/spi_dma.rs | 4 +- examples/stm32f3/src/bin/usart_dma.rs | 4 +- examples/stm32f3/src/bin/usb_serial.rs | 7 ++- examples/stm32f4/src/bin/adc.rs | 4 +- examples/stm32f4/src/bin/blinky.rs | 4 +- examples/stm32f4/src/bin/button_exti.rs | 4 +- examples/stm32f4/src/bin/dac.rs | 4 +- examples/stm32f4/src/bin/flash.rs | 4 +- examples/stm32f4/src/bin/hello.rs | 7 ++- examples/stm32f4/src/bin/pwm.rs | 4 +- examples/stm32f4/src/bin/sdmmc.rs | 7 ++- examples/stm32f4/src/bin/spi_dma.rs | 4 +- examples/stm32f4/src/bin/usart_buffered.rs | 5 +- examples/stm32f4/src/bin/usart_dma.rs | 4 +- examples/stm32f4/src/bin/wdt.rs | 4 +- examples/stm32f7/src/bin/adc.rs | 4 +- examples/stm32f7/src/bin/blinky.rs | 4 +- examples/stm32f7/src/bin/button_exti.rs | 4 +- examples/stm32f7/src/bin/eth.rs | 7 ++- examples/stm32f7/src/bin/flash.rs | 4 +- examples/stm32f7/src/bin/hello.rs | 7 ++- examples/stm32f7/src/bin/sdmmc.rs | 7 ++- examples/stm32f7/src/bin/usart_dma.rs | 4 +- examples/stm32g0/src/bin/blinky.rs | 4 +- examples/stm32g0/src/bin/button_exti.rs | 4 +- examples/stm32g4/src/bin/blinky.rs | 4 +- examples/stm32g4/src/bin/button_exti.rs | 4 +- examples/stm32g4/src/bin/pwm.rs | 4 +- examples/stm32h7/src/bin/adc.rs | 7 ++- examples/stm32h7/src/bin/blinky.rs | 4 +- examples/stm32h7/src/bin/button_exti.rs | 4 +- examples/stm32h7/src/bin/camera.rs | 7 ++- examples/stm32h7/src/bin/eth.rs | 7 ++- examples/stm32h7/src/bin/eth_client.rs | 7 ++- examples/stm32h7/src/bin/flash.rs | 4 +- examples/stm32h7/src/bin/fmc.rs | 7 ++- .../stm32h7/src/bin/low_level_timer_api.rs | 7 ++- examples/stm32h7/src/bin/mco.rs | 4 +- examples/stm32h7/src/bin/pwm.rs | 7 ++- examples/stm32h7/src/bin/rng.rs | 4 +- examples/stm32h7/src/bin/sdmmc.rs | 7 ++- examples/stm32h7/src/bin/signal.rs | 4 +- examples/stm32h7/src/bin/usart_split.rs | 4 +- examples/stm32l0/src/bin/blinky.rs | 4 +- examples/stm32l0/src/bin/button.rs | 4 +- examples/stm32l0/src/bin/button_exti.rs | 6 +- examples/stm32l0/src/bin/flash.rs | 4 +- examples/stm32l0/src/bin/lorawan.rs | 8 ++- examples/stm32l0/src/bin/spi.rs | 4 +- examples/stm32l0/src/bin/usart_dma.rs | 4 +- examples/stm32l0/src/bin/usart_irq.rs | 5 +- examples/stm32l1/src/bin/blinky.rs | 4 +- examples/stm32l1/src/bin/flash.rs | 4 +- examples/stm32l1/src/bin/spi.rs | 4 +- examples/stm32l4/src/bin/blinky.rs | 4 +- examples/stm32l4/src/bin/button_exti.rs | 4 +- examples/stm32l4/src/bin/i2c.rs | 5 +- .../stm32l4/src/bin/i2c_blocking_async.rs | 5 +- examples/stm32l4/src/bin/i2c_dma.rs | 5 +- examples/stm32l4/src/bin/rng.rs | 7 ++- .../stm32l4/src/bin/spi_blocking_async.rs | 4 +- examples/stm32l4/src/bin/spi_dma.rs | 4 +- examples/stm32l4/src/bin/usart_dma.rs | 4 +- examples/stm32l5/src/bin/button_exti.rs | 4 +- examples/stm32l5/src/bin/rng.rs | 7 ++- examples/stm32l5/src/bin/usb_ethernet.rs | 7 ++- examples/stm32l5/src/bin/usb_hid_mouse.rs | 5 +- examples/stm32l5/src/bin/usb_serial.rs | 7 ++- examples/stm32u5/src/bin/blinky.rs | 4 +- examples/stm32wb/src/bin/blinky.rs | 4 +- examples/stm32wb/src/bin/button_exti.rs | 4 +- examples/stm32wl/src/bin/blinky.rs | 4 +- examples/stm32wl/src/bin/button_exti.rs | 4 +- examples/stm32wl/src/bin/flash.rs | 4 +- examples/stm32wl/src/bin/lorawan.rs | 8 ++- examples/stm32wl/src/bin/subghz.rs | 8 ++- tests/rp/src/bin/gpio.rs | 4 +- tests/rp/src/bin/gpio_async.rs | 4 +- tests/stm32/src/bin/gpio.rs | 6 +- tests/stm32/src/bin/spi.rs | 6 +- tests/stm32/src/bin/spi_dma.rs | 6 +- tests/stm32/src/bin/timer.rs | 6 +- tests/stm32/src/bin/usart.rs | 6 +- tests/stm32/src/bin/usart_dma.rs | 6 +- 182 files changed, 454 insertions(+), 423 deletions(-) diff --git a/README.md b/README.md index 42374067..eaa1e10a 100644 --- a/README.md +++ b/README.md @@ -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(); diff --git a/docs/modules/ROOT/examples/basic/src/main.rs b/docs/modules/ROOT/examples/basic/src/main.rs index cec39fd9..d680dd06 100644 --- a/docs/modules/ROOT/examples/basic/src/main.rs +++ b/docs/modules/ROOT/examples/basic/src/main.rs @@ -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)))); } diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs index b944a799..7d62b610 100644 --- a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs +++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs @@ -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); diff --git a/embassy-cortex-m/src/interrupt.rs b/embassy-cortex-m/src/interrupt.rs index be11c5eb..1df8671b 100644 --- a/embassy-cortex-m/src/interrupt.rs +++ b/embassy-cortex-m/src/interrupt.rs @@ -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. diff --git a/embassy-macros/Cargo.toml b/embassy-macros/Cargo.toml index 6abafa58..19a3e9de 100644 --- a/embassy-macros/Cargo.toml +++ b/embassy-macros/Cargo.toml @@ -13,8 +13,5 @@ proc-macro2 = "1.0.29" proc-macro = true [features] -nrf = [] -stm32 = [] -rp = [] std = [] wasm = [] diff --git a/embassy-macros/src/macros/main.rs b/embassy-macros/src/macros/main.rs index b040edc5..a0cb0f0b 100644 --- a/embassy-macros/src/macros/main.rs +++ b/embassy-macros/src/macros/main.rs @@ -5,11 +5,7 @@ use quote::quote; use crate::util::ctxt::Ctxt; #[derive(Debug, FromMeta)] -struct Args { - #[allow(unused)] - #[darling(default)] - config: Option, -} +struct Args {} pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result { #[allow(unused_variables)] @@ -20,26 +16,14 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result = 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().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)); - }) - } } }; diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 72f4b538..9d6690ac 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -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 } diff --git a/embassy-nrf/src/chips/nrf52805.rs b/embassy-nrf/src/chips/nrf52805.rs index 8fca4da1..d078fa0a 100644 --- a/embassy-nrf/src/chips/nrf52805.rs +++ b/embassy-nrf/src/chips/nrf52805.rs @@ -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; diff --git a/embassy-nrf/src/chips/nrf52810.rs b/embassy-nrf/src/chips/nrf52810.rs index 538a617d..faa52d8f 100644 --- a/embassy-nrf/src/chips/nrf52810.rs +++ b/embassy-nrf/src/chips/nrf52810.rs @@ -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; diff --git a/embassy-nrf/src/chips/nrf52811.rs b/embassy-nrf/src/chips/nrf52811.rs index 808adf51..bbdf1cbe 100644 --- a/embassy-nrf/src/chips/nrf52811.rs +++ b/embassy-nrf/src/chips/nrf52811.rs @@ -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; diff --git a/embassy-nrf/src/chips/nrf52820.rs b/embassy-nrf/src/chips/nrf52820.rs index 6be5bd36..dba033b0 100644 --- a/embassy-nrf/src/chips/nrf52820.rs +++ b/embassy-nrf/src/chips/nrf52820.rs @@ -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; diff --git a/embassy-nrf/src/chips/nrf52832.rs b/embassy-nrf/src/chips/nrf52832.rs index cdc644d6..18b8eda6 100644 --- a/embassy-nrf/src/chips/nrf52832.rs +++ b/embassy-nrf/src/chips/nrf52832.rs @@ -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; diff --git a/embassy-nrf/src/chips/nrf52833.rs b/embassy-nrf/src/chips/nrf52833.rs index 4c3c5574..39a0f93f 100644 --- a/embassy-nrf/src/chips/nrf52833.rs +++ b/embassy-nrf/src/chips/nrf52833.rs @@ -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; diff --git a/embassy-nrf/src/chips/nrf52840.rs b/embassy-nrf/src/chips/nrf52840.rs index bdaeadb9..e3d8f34a 100644 --- a/embassy-nrf/src/chips/nrf52840.rs +++ b/embassy-nrf/src/chips/nrf52840.rs @@ -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; diff --git a/embassy-nrf/src/chips/nrf5340_app.rs b/embassy-nrf/src/chips/nrf5340_app.rs index 26dc56bd..edf800ef 100644 --- a/embassy-nrf/src/chips/nrf5340_app.rs +++ b/embassy-nrf/src/chips/nrf5340_app.rs @@ -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; diff --git a/embassy-nrf/src/chips/nrf5340_net.rs b/embassy-nrf/src/chips/nrf5340_net.rs index e28cfe01..ae136e09 100644 --- a/embassy-nrf/src/chips/nrf5340_net.rs +++ b/embassy-nrf/src/chips/nrf5340_net.rs @@ -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; diff --git a/embassy-nrf/src/chips/nrf9160.rs b/embassy-nrf/src/chips/nrf9160.rs index 1a0bd10f..a4be8564 100644 --- a/embassy-nrf/src/chips/nrf9160.rs +++ b/embassy-nrf/src/chips/nrf9160.rs @@ -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; diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index ad6c16c1..f3b3ca0c 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs @@ -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. diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index eeb4ec43..bf4919d5 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -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 } diff --git a/embassy-rp/src/interrupt.rs b/embassy-rp/src/interrupt.rs index d652a8c7..f21a5433 100644 --- a/embassy-rp/src/interrupt.rs +++ b/embassy-rp/src/interrupt.rs @@ -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); diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs index 44150be0..8c053a4f 100644 --- a/embassy-rp/src/lib.rs +++ b/embassy-rp/src/lib.rs @@ -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"))] diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 7260f06d..dea68e44 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -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 } diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 3b4aa5df..c892007a 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -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); )* diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 78025f3d..30ff02d5 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -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"))] diff --git a/examples/boot/application/nrf/src/bin/a.rs b/examples/boot/application/nrf/src/bin/a.rs index 3044645a..6343f570 100644 --- a/examples/boot/application/nrf/src/bin/a.rs +++ b/examples/boot/application/nrf/src/bin/a.rs @@ -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); diff --git a/examples/boot/application/nrf/src/bin/b.rs b/examples/boot/application/nrf/src/bin/b.rs index 2f76d20c..ad44804a 100644 --- a/examples/boot/application/nrf/src/bin/b.rs +++ b/examples/boot/application/nrf/src/bin/b.rs @@ -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); diff --git a/examples/boot/application/stm32f3/src/bin/a.rs b/examples/boot/application/stm32f3/src/bin/a.rs index fd18e937..d06e6aea 100644 --- a/examples/boot/application/stm32f3/src/bin/a.rs +++ b/examples/boot/application/stm32f3/src/bin/a.rs @@ -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); diff --git a/examples/boot/application/stm32f3/src/bin/b.rs b/examples/boot/application/stm32f3/src/bin/b.rs index 934f862d..98d6dbdf 100644 --- a/examples/boot/application/stm32f3/src/bin/b.rs +++ b/examples/boot/application/stm32f3/src/bin/b.rs @@ -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 { diff --git a/examples/boot/application/stm32f7/src/bin/a.rs b/examples/boot/application/stm32f7/src/bin/a.rs index 10d709cf..154d62d2 100644 --- a/examples/boot/application/stm32f7/src/bin/a.rs +++ b/examples/boot/application/stm32f7/src/bin/a.rs @@ -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); diff --git a/examples/boot/application/stm32f7/src/bin/b.rs b/examples/boot/application/stm32f7/src/bin/b.rs index c89e8a31..11883626 100644 --- a/examples/boot/application/stm32f7/src/bin/b.rs +++ b/examples/boot/application/stm32f7/src/bin/b.rs @@ -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(); diff --git a/examples/boot/application/stm32h7/src/bin/a.rs b/examples/boot/application/stm32h7/src/bin/a.rs index cc363bb3..8407adac 100644 --- a/examples/boot/application/stm32h7/src/bin/a.rs +++ b/examples/boot/application/stm32h7/src/bin/a.rs @@ -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); diff --git a/examples/boot/application/stm32h7/src/bin/b.rs b/examples/boot/application/stm32h7/src/bin/b.rs index 3fa63bdc..cc694e84 100644 --- a/examples/boot/application/stm32h7/src/bin/b.rs +++ b/examples/boot/application/stm32h7/src/bin/b.rs @@ -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(); diff --git a/examples/boot/application/stm32l0/src/bin/a.rs b/examples/boot/application/stm32l0/src/bin/a.rs index fcf3f2ef..7ec6bb96 100644 --- a/examples/boot/application/stm32l0/src/bin/a.rs +++ b/examples/boot/application/stm32l0/src/bin/a.rs @@ -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); diff --git a/examples/boot/application/stm32l0/src/bin/b.rs b/examples/boot/application/stm32l0/src/bin/b.rs index 46e394c4..f1e1eaca 100644 --- a/examples/boot/application/stm32l0/src/bin/b.rs +++ b/examples/boot/application/stm32l0/src/bin/b.rs @@ -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 { diff --git a/examples/boot/application/stm32l1/src/bin/a.rs b/examples/boot/application/stm32l1/src/bin/a.rs index fcf3f2ef..7ec6bb96 100644 --- a/examples/boot/application/stm32l1/src/bin/a.rs +++ b/examples/boot/application/stm32l1/src/bin/a.rs @@ -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); diff --git a/examples/boot/application/stm32l1/src/bin/b.rs b/examples/boot/application/stm32l1/src/bin/b.rs index 46e394c4..f1e1eaca 100644 --- a/examples/boot/application/stm32l1/src/bin/b.rs +++ b/examples/boot/application/stm32l1/src/bin/b.rs @@ -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 { diff --git a/examples/boot/application/stm32l4/src/bin/a.rs b/examples/boot/application/stm32l4/src/bin/a.rs index f092f023..91d16ea1 100644 --- a/examples/boot/application/stm32l4/src/bin/a.rs +++ b/examples/boot/application/stm32l4/src/bin/a.rs @@ -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); diff --git a/examples/boot/application/stm32l4/src/bin/b.rs b/examples/boot/application/stm32l4/src/bin/b.rs index 934f862d..98d6dbdf 100644 --- a/examples/boot/application/stm32l4/src/bin/b.rs +++ b/examples/boot/application/stm32l4/src/bin/b.rs @@ -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 { diff --git a/examples/boot/application/stm32wl/src/bin/a.rs b/examples/boot/application/stm32wl/src/bin/a.rs index 14408a90..613694ec 100644 --- a/examples/boot/application/stm32wl/src/bin/a.rs +++ b/examples/boot/application/stm32wl/src/bin/a.rs @@ -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); diff --git a/examples/boot/application/stm32wl/src/bin/b.rs b/examples/boot/application/stm32wl/src/bin/b.rs index e565fd7c..97619814 100644 --- a/examples/boot/application/stm32wl/src/bin/b.rs +++ b/examples/boot/application/stm32wl/src/bin/b.rs @@ -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 { diff --git a/examples/nrf/src/bin/awaitable_timer.rs b/examples/nrf/src/bin/awaitable_timer.rs index f2c1d9fa..a9422480 100644 --- a/examples/nrf/src/bin/awaitable_timer.rs +++ b/examples/nrf/src/bin/awaitable_timer.rs @@ -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); diff --git a/examples/nrf/src/bin/blinky.rs b/examples/nrf/src/bin/blinky.rs index 98db6546..5283d7ea 100644 --- a/examples/nrf/src/bin/blinky.rs +++ b/examples/nrf/src/bin/blinky.rs @@ -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 { diff --git a/examples/nrf/src/bin/buffered_uart.rs b/examples/nrf/src/bin/buffered_uart.rs index f02b7d84..d2a15397 100644 --- a/examples/nrf/src/bin/buffered_uart.rs +++ b/examples/nrf/src/bin/buffered_uart.rs @@ -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; diff --git a/examples/nrf/src/bin/channel.rs b/examples/nrf/src/bin/channel.rs index e97c6c5e..a7ea08d0 100644 --- a/examples/nrf/src/bin/channel.rs +++ b/examples/nrf/src/bin/channel.rs @@ -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())); diff --git a/examples/nrf/src/bin/channel_sender_receiver.rs b/examples/nrf/src/bin/channel_sender_receiver.rs index bca7bb24..ef85e871 100644 --- a/examples/nrf/src/bin/channel_sender_receiver.rs +++ b/examples/nrf/src/bin/channel_sender_receiver.rs @@ -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()))); diff --git a/examples/nrf/src/bin/executor_fairness_test.rs b/examples/nrf/src/bin/executor_fairness_test.rs index b9845493..7aaeda54 100644 --- a/examples/nrf/src/bin/executor_fairness_test.rs +++ b/examples/nrf/src/bin/executor_fairness_test.rs @@ -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())); diff --git a/examples/nrf/src/bin/gpiote_channel.rs b/examples/nrf/src/bin/gpiote_channel.rs index 65c7b4df..f2654cb4 100644 --- a/examples/nrf/src/bin/gpiote_channel.rs +++ b/examples/nrf/src/bin/gpiote_channel.rs @@ -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( diff --git a/examples/nrf/src/bin/gpiote_port.rs b/examples/nrf/src/bin/gpiote_port.rs index 7746a7f9..46c260a4 100644 --- a/examples/nrf/src/bin/gpiote_port.rs +++ b/examples/nrf/src/bin/gpiote_port.rs @@ -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); diff --git a/examples/nrf/src/bin/mutex.rs b/examples/nrf/src/bin/mutex.rs index 5fe7eadb..378a5926 100644 --- a/examples/nrf/src/bin/mutex.rs +++ b/examples/nrf/src/bin/mutex.rs @@ -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 { diff --git a/examples/nrf/src/bin/nvmc.rs b/examples/nrf/src/bin/nvmc.rs index 1d4387de..a0b55580 100644 --- a/examples/nrf/src/bin/nvmc.rs +++ b/examples/nrf/src/bin/nvmc.rs @@ -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. diff --git a/examples/nrf/src/bin/ppi.rs b/examples/nrf/src/bin/ppi.rs index 9a60cc0a..fb2a97f1 100644 --- a/examples/nrf/src/bin/ppi.rs +++ b/examples/nrf/src/bin/ppi.rs @@ -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( diff --git a/examples/nrf/src/bin/pubsub.rs b/examples/nrf/src/bin/pubsub.rs index 5f33f3e0..d1441d5c 100644 --- a/examples/nrf/src/bin/pubsub.rs +++ b/examples/nrf/src/bin/pubsub.rs @@ -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. diff --git a/examples/nrf/src/bin/pwm.rs b/examples/nrf/src/bin/pwm.rs index c8a08329..dca40fd5 100644 --- a/examples/nrf/src/bin/pwm.rs +++ b/examples/nrf/src/bin/pwm.rs @@ -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); diff --git a/examples/nrf/src/bin/pwm_double_sequence.rs b/examples/nrf/src/bin/pwm_double_sequence.rs index cfd8db86..08436c8f 100644 --- a/examples/nrf/src/bin/pwm_double_sequence.rs +++ b/examples/nrf/src/bin/pwm_double_sequence.rs @@ -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]; diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs index b7a04c03..c549b55c 100644 --- a/examples/nrf/src/bin/pwm_sequence.rs +++ b/examples/nrf/src/bin/pwm_sequence.rs @@ -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(); diff --git a/examples/nrf/src/bin/pwm_sequence_ppi.rs b/examples/nrf/src/bin/pwm_sequence_ppi.rs index f5c587c3..4131e084 100644 --- a/examples/nrf/src/bin/pwm_sequence_ppi.rs +++ b/examples/nrf/src/bin/pwm_sequence_ppi.rs @@ -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(); diff --git a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs index d6b3f005..de457822 100644 --- a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs +++ b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs @@ -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; diff --git a/examples/nrf/src/bin/pwm_servo.rs b/examples/nrf/src/bin/pwm_servo.rs index d28a5a17..08a7a1fd 100644 --- a/examples/nrf/src/bin/pwm_servo.rs +++ b/examples/nrf/src/bin/pwm_servo.rs @@ -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 diff --git a/examples/nrf/src/bin/qdec.rs b/examples/nrf/src/bin/qdec.rs index 6bda82f7..f9565e89 100644 --- a/examples/nrf/src/bin/qdec.rs +++ b/examples/nrf/src/bin/qdec.rs @@ -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); diff --git a/examples/nrf/src/bin/qspi.rs b/examples/nrf/src/bin/qspi.rs index 57e0fdbe..976673a2 100644 --- a/examples/nrf/src/bin/qspi.rs +++ b/examples/nrf/src/bin/qspi.rs @@ -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; diff --git a/examples/nrf/src/bin/qspi_lowpower.rs b/examples/nrf/src/bin/qspi_lowpower.rs index 080b27a1..a83fe3fe 100644 --- a/examples/nrf/src/bin/qspi_lowpower.rs +++ b/examples/nrf/src/bin/qspi_lowpower.rs @@ -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 { diff --git a/examples/nrf/src/bin/rng.rs b/examples/nrf/src/bin/rng.rs index a4314e8b..70ab5c73 100644 --- a/examples/nrf/src/bin/rng.rs +++ b/examples/nrf/src/bin/rng.rs @@ -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 diff --git a/examples/nrf/src/bin/saadc.rs b/examples/nrf/src/bin/saadc.rs index 65c78d84..e90fc3df 100644 --- a/examples/nrf/src/bin/saadc.rs +++ b/examples/nrf/src/bin/saadc.rs @@ -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]); diff --git a/examples/nrf/src/bin/saadc_continuous.rs b/examples/nrf/src/bin/saadc_continuous.rs index d0305736..80ecaae7 100644 --- a/examples/nrf/src/bin/saadc_continuous.rs +++ b/examples/nrf/src/bin/saadc_continuous.rs @@ -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); diff --git a/examples/nrf/src/bin/self_spawn.rs b/examples/nrf/src/bin/self_spawn.rs index e0152802..56539eef 100644 --- a/examples/nrf/src/bin/self_spawn.rs +++ b/examples/nrf/src/bin/self_spawn.rs @@ -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))); } diff --git a/examples/nrf/src/bin/self_spawn_current_executor.rs b/examples/nrf/src/bin/self_spawn_current_executor.rs index 1d8309d7..11fe6fb4 100644 --- a/examples/nrf/src/bin/self_spawn_current_executor.rs +++ b/examples/nrf/src/bin/self_spawn_current_executor.rs @@ -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))); } diff --git a/examples/nrf/src/bin/spim.rs b/examples/nrf/src/bin/spim.rs index fd741b21..437a1a80 100644 --- a/examples/nrf/src/bin/spim.rs +++ b/examples/nrf/src/bin/spim.rs @@ -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(); diff --git a/examples/nrf/src/bin/temp.rs b/examples/nrf/src/bin/temp.rs index 654098e0..a898488f 100644 --- a/examples/nrf/src/bin/temp.rs +++ b/examples/nrf/src/bin/temp.rs @@ -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); diff --git a/examples/nrf/src/bin/timer.rs b/examples/nrf/src/bin/timer.rs index 61ff1d6d..de790233 100644 --- a/examples/nrf/src/bin/timer.rs +++ b/examples/nrf/src/bin/timer.rs @@ -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())); } diff --git a/examples/nrf/src/bin/twim.rs b/examples/nrf/src/bin/twim.rs index bb7ee9db..a0a6d359 100644 --- a/examples/nrf/src/bin/twim.rs +++ b/examples/nrf/src/bin/twim.rs @@ -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); diff --git a/examples/nrf/src/bin/twim_lowpower.rs b/examples/nrf/src/bin/twim_lowpower.rs index ebf3d710..916ac07e 100644 --- a/examples/nrf/src/bin/twim_lowpower.rs +++ b/examples/nrf/src/bin/twim_lowpower.rs @@ -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); diff --git a/examples/nrf/src/bin/uart.rs b/examples/nrf/src/bin/uart.rs index 5f363b69..011ad2a5 100644 --- a/examples/nrf/src/bin/uart.rs +++ b/examples/nrf/src/bin/uart.rs @@ -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; diff --git a/examples/nrf/src/bin/uart_idle.rs b/examples/nrf/src/bin/uart_idle.rs index 0f455dff..cf3d9938 100644 --- a/examples/nrf/src/bin/uart_idle.rs +++ b/examples/nrf/src/bin/uart_idle.rs @@ -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; diff --git a/examples/nrf/src/bin/uart_split.rs b/examples/nrf/src/bin/uart_split.rs index 2de5f90c..12c21c09 100644 --- a/examples/nrf/src/bin/uart_split.rs +++ b/examples/nrf/src/bin/uart_split.rs @@ -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 = 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; diff --git a/examples/nrf/src/bin/usb_ethernet.rs b/examples/nrf/src/bin/usb_ethernet.rs index 93cb0590..4f8e59cc 100644 --- a/examples/nrf/src/bin/usb_ethernet.rs +++ b/examples/nrf/src/bin/usb_ethernet.rs @@ -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) -> ! { } #[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..."); diff --git a/examples/nrf/src/bin/usb_hid_keyboard.rs b/examples/nrf/src/bin/usb_hid_keyboard.rs index 863f3e5d..16d1a9a2 100644 --- a/examples/nrf/src/bin/usb_hid_keyboard.rs +++ b/examples/nrf/src/bin/usb_hid_keyboard.rs @@ -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..."); diff --git a/examples/nrf/src/bin/usb_hid_mouse.rs b/examples/nrf/src/bin/usb_hid_mouse.rs index 88bf87bd..0008e0e6 100644 --- a/examples/nrf/src/bin/usb_hid_mouse.rs +++ b/examples/nrf/src/bin/usb_hid_mouse.rs @@ -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..."); diff --git a/examples/nrf/src/bin/usb_serial.rs b/examples/nrf/src/bin/usb_serial.rs index 7d233d24..ce11c6cb 100644 --- a/examples/nrf/src/bin/usb_serial.rs +++ b/examples/nrf/src/bin/usb_serial.rs @@ -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..."); diff --git a/examples/nrf/src/bin/usb_serial_multitask.rs b/examples/nrf/src/bin/usb_serial_multitask.rs index 95631532..d2f1a972 100644 --- a/examples/nrf/src/bin/usb_serial_multitask.rs +++ b/examples/nrf/src/bin/usb_serial_multitask.rs @@ -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..."); diff --git a/examples/nrf/src/bin/wdt.rs b/examples/nrf/src/bin/wdt.rs index 560cb356..47e40b88 100644 --- a/examples/nrf/src/bin/wdt.rs +++ b/examples/nrf/src/bin/wdt.rs @@ -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(); diff --git a/examples/rp/src/bin/blinky.rs b/examples/rp/src/bin/blinky.rs index e53fca1a..dade3bf3 100644 --- a/examples/rp/src/bin/blinky.rs +++ b/examples/rp/src/bin/blinky.rs @@ -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 { diff --git a/examples/rp/src/bin/button.rs b/examples/rp/src/bin/button.rs index 02cbc941..22793735 100644 --- a/examples/rp/src/bin/button.rs +++ b/examples/rp/src/bin/button.rs @@ -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); diff --git a/examples/rp/src/bin/gpio_async.rs b/examples/rp/src/bin/gpio_async.rs index ba905b01..c61b87a3 100644 --- a/examples/rp/src/bin/gpio_async.rs +++ b/examples/rp/src/bin/gpio_async.rs @@ -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); diff --git a/examples/rp/src/bin/spi.rs b/examples/rp/src/bin/spi.rs index a3160c10..7d337002 100644 --- a/examples/rp/src/bin/spi.rs +++ b/examples/rp/src/bin/spi.rs @@ -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 diff --git a/examples/rp/src/bin/spi_display.rs b/examples/rp/src/bin/spi_display.rs index 2760b23f..8b46bd07 100644 --- a/examples/rp/src/bin/spi_display.rs +++ b/examples/rp/src/bin/spi_display.rs @@ -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; diff --git a/examples/rp/src/bin/uart.rs b/examples/rp/src/bin/uart.rs index 0d295489..06721146 100644 --- a/examples/rp/src/bin/uart.rs +++ b/examples/rp/src/bin/uart.rs @@ -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()); diff --git a/examples/stm32f0/src/bin/hello.rs b/examples/stm32f0/src/bin/hello.rs index c9081ea1..a0775bad 100644 --- a/examples/stm32f0/src/bin/hello.rs +++ b/examples/stm32f0/src/bin/hello.rs @@ -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"); diff --git a/examples/stm32f1/src/bin/adc.rs b/examples/stm32f1/src/bin/adc.rs index e54593fe..dae001a8 100644 --- a/examples/stm32f1/src/bin/adc.rs +++ b/examples/stm32f1/src/bin/adc.rs @@ -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); diff --git a/examples/stm32f1/src/bin/blinky.rs b/examples/stm32f1/src/bin/blinky.rs index 5171043e..74e31cbb 100644 --- a/examples/stm32f1/src/bin/blinky.rs +++ b/examples/stm32f1/src/bin/blinky.rs @@ -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); diff --git a/examples/stm32f1/src/bin/hello.rs b/examples/stm32f1/src/bin/hello.rs index 549d1bfb..721b21c3 100644 --- a/examples/stm32f1/src/bin/hello.rs +++ b/examples/stm32f1/src/bin/hello.rs @@ -6,7 +6,7 @@ use defmt::info; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::time::Hertz; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -15,8 +15,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, _p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(_spawner: Spawner) -> ! { + let _p = embassy_stm32::init(config()); loop { info!("Hello World!"); Timer::after(Duration::from_secs(1)).await; diff --git a/examples/stm32f1/src/bin/usb_serial.rs b/examples/stm32f1/src/bin/usb_serial.rs index cf7facb7..7f27e625 100644 --- a/examples/stm32f1/src/bin/usb_serial.rs +++ b/examples/stm32f1/src/bin/usb_serial.rs @@ -8,7 +8,7 @@ use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::time::Hertz; use embassy_stm32::usb::{Driver, Instance}; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use embassy_usb::driver::EndpointError; use embassy_usb::Builder; use embassy_usb_serial::{CdcAcmClass, State}; @@ -23,8 +23,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, mut p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let mut p = embassy_stm32::init(config()); info!("Hello World!"); { diff --git a/examples/stm32f2/src/bin/blinky.rs b/examples/stm32f2/src/bin/blinky.rs index 48ae2e71..2afdeeb3 100644 --- a/examples/stm32f2/src/bin/blinky.rs +++ b/examples/stm32f2/src/bin/blinky.rs @@ -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); diff --git a/examples/stm32f2/src/bin/pll.rs b/examples/stm32f2/src/bin/pll.rs index 01e63b15..bc0c160b 100644 --- a/examples/stm32f2/src/bin/pll.rs +++ b/examples/stm32f2/src/bin/pll.rs @@ -11,7 +11,7 @@ use embassy_stm32::rcc::{ APBPrescaler, ClockSrc, HSEConfig, HSESrc, PLL48Div, PLLConfig, PLLMainDiv, PLLMul, PLLPreDiv, PLLSrc, }; use embassy_stm32::time::Hertz; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; // Example config for maximum performance on a NUCLEO-F207ZG board @@ -43,8 +43,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, _p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let _p = embassy_stm32::init(config()); loop { Timer::after(Duration::from_millis(1000)).await; info!("1s elapsed"); diff --git a/examples/stm32f3/src/bin/blinky.rs b/examples/stm32f3/src/bin/blinky.rs index 7146eaa5..84d7c50a 100644 --- a/examples/stm32f3/src/bin/blinky.rs +++ b/examples/stm32f3/src/bin/blinky.rs @@ -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); diff --git a/examples/stm32f3/src/bin/button_events.rs b/examples/stm32f3/src/bin/button_events.rs index ef511031..404946f2 100644 --- a/examples/stm32f3/src/bin/button_events.rs +++ b/examples/stm32f3/src/bin/button_events.rs @@ -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 = 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..."); diff --git a/examples/stm32f3/src/bin/button_exti.rs b/examples/stm32f3/src/bin/button_exti.rs index dee06e5d..b770b338 100644 --- a/examples/stm32f3/src/bin/button_exti.rs +++ b/examples/stm32f3/src/bin/button_exti.rs @@ -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); diff --git a/examples/stm32f3/src/bin/flash.rs b/examples/stm32f3/src/bin/flash.rs index be2f6f67..c7982884 100644 --- a/examples/stm32f3/src/bin/flash.rs +++ b/examples/stm32f3/src/bin/flash.rs @@ -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; diff --git a/examples/stm32f3/src/bin/hello.rs b/examples/stm32f3/src/bin/hello.rs index bd9953a0..7846912c 100644 --- a/examples/stm32f3/src/bin/hello.rs +++ b/examples/stm32f3/src/bin/hello.rs @@ -6,7 +6,7 @@ use defmt::info; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::time::Hertz; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -16,8 +16,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, _p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(_spawner: Spawner) -> ! { + let _p = embassy_stm32::init(config()); loop { info!("Hello World!"); Timer::after(Duration::from_secs(1)).await; diff --git a/examples/stm32f3/src/bin/spi_dma.rs b/examples/stm32f3/src/bin/spi_dma.rs index f554c509..7f874bb6 100644 --- a/examples/stm32f3/src/bin/spi_dma.rs +++ b/examples/stm32f3/src/bin/spi_dma.rs @@ -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( diff --git a/examples/stm32f3/src/bin/usart_dma.rs b/examples/stm32f3/src/bin/usart_dma.rs index 62d16502..2b27a8da 100644 --- a/examples/stm32f3/src/bin/usart_dma.rs +++ b/examples/stm32f3/src/bin/usart_dma.rs @@ -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(); diff --git a/examples/stm32f3/src/bin/usb_serial.rs b/examples/stm32f3/src/bin/usb_serial.rs index 87b1138f..36d38d87 100644 --- a/examples/stm32f3/src/bin/usb_serial.rs +++ b/examples/stm32f3/src/bin/usb_serial.rs @@ -8,7 +8,7 @@ use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::time::mhz; 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}; @@ -27,8 +27,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); // Needed for nucleo-stm32f303ze diff --git a/examples/stm32f4/src/bin/adc.rs b/examples/stm32f4/src/bin/adc.rs index 27ed4fcc..1dc01edd 100644 --- a/examples/stm32f4/src/bin/adc.rs +++ b/examples/stm32f4/src/bin/adc.rs @@ -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); diff --git a/examples/stm32f4/src/bin/blinky.rs b/examples/stm32f4/src/bin/blinky.rs index f71fe098..249bbd88 100644 --- a/examples/stm32f4/src/bin/blinky.rs +++ b/examples/stm32f4/src/bin/blinky.rs @@ -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.PB7, Level::High, Speed::Low); diff --git a/examples/stm32f4/src/bin/button_exti.rs b/examples/stm32f4/src/bin/button_exti.rs index 60dfb362..25d3bb9c 100644 --- a/examples/stm32f4/src/bin/button_exti.rs +++ b/examples/stm32f4/src/bin/button_exti.rs @@ -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.PC13, Pull::Down); diff --git a/examples/stm32f4/src/bin/dac.rs b/examples/stm32f4/src/bin/dac.rs index 392f5bf4..9098a971 100644 --- a/examples/stm32f4/src/bin/dac.rs +++ b/examples/stm32f4/src/bin/dac.rs @@ -5,11 +5,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::dac::{Channel, Dac, Value}; -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, dude!"); let mut dac = Dac::new_1ch(p.DAC, p.PA4); diff --git a/examples/stm32f4/src/bin/flash.rs b/examples/stm32f4/src/bin/flash.rs index 4f780656..0d96efb6 100644 --- a/examples/stm32f4/src/bin/flash.rs +++ b/examples/stm32f4/src/bin/flash.rs @@ -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!"); let mut f = Flash::unlock(p.FLASH); diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs index f957656e..6facb9bb 100644 --- a/examples/stm32f4/src/bin/hello.rs +++ b/examples/stm32f4/src/bin/hello.rs @@ -6,7 +6,7 @@ use defmt::info; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::time::Hertz; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -15,8 +15,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, _p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(_spawner: Spawner) -> ! { + let _p = embassy_stm32::init(config()); loop { info!("Hello World!"); Timer::after(Duration::from_secs(1)).await; diff --git a/examples/stm32f4/src/bin/pwm.rs b/examples/stm32f4/src/bin/pwm.rs index 0b352c2b..1d4f426b 100644 --- a/examples/stm32f4/src/bin/pwm.rs +++ b/examples/stm32f4/src/bin/pwm.rs @@ -8,11 +8,11 @@ use embassy_executor::time::{Duration, Timer}; use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; use embassy_stm32::pwm::Channel; use embassy_stm32::time::khz; -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 ch1 = PwmPin::new_ch1(p.PE9); diff --git a/examples/stm32f4/src/bin/sdmmc.rs b/examples/stm32f4/src/bin/sdmmc.rs index 6eef1996..996694f2 100644 --- a/examples/stm32f4/src/bin/sdmmc.rs +++ b/examples/stm32f4/src/bin/sdmmc.rs @@ -6,7 +6,7 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::mhz; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -15,8 +15,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(_spawner: Spawner) -> ! { + let p = embassy_stm32::init(config()); info!("Hello World!"); let irq = interrupt::take!(SDIO); diff --git a/examples/stm32f4/src/bin/spi_dma.rs b/examples/stm32f4/src/bin/spi_dma.rs index 023ca097..f871c1d3 100644 --- a/examples/stm32f4/src/bin/spi_dma.rs +++ b/examples/stm32f4/src/bin/spi_dma.rs @@ -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( diff --git a/examples/stm32f4/src/bin/usart_buffered.rs b/examples/stm32f4/src/bin/usart_buffered.rs index 2555998c..9c269ae2 100644 --- a/examples/stm32f4/src/bin/usart_buffered.rs +++ b/examples/stm32f4/src/bin/usart_buffered.rs @@ -5,13 +5,14 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; +use embassy_stm32::interrupt; use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; -use embassy_stm32::{interrupt, Peripherals}; use embedded_io::asynch::BufRead; 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(); diff --git a/examples/stm32f4/src/bin/usart_dma.rs b/examples/stm32f4/src/bin/usart_dma.rs index 7859ba2a..febdec6b 100644 --- a/examples/stm32f4/src/bin/usart_dma.rs +++ b/examples/stm32f4/src/bin/usart_dma.rs @@ -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(); diff --git a/examples/stm32f4/src/bin/wdt.rs b/examples/stm32f4/src/bin/wdt.rs index 48394f4f..a5128525 100644 --- a/examples/stm32f4/src/bin/wdt.rs +++ b/examples/stm32f4/src/bin/wdt.rs @@ -7,11 +7,11 @@ use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::wdg::IndependentWatchdog; -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.PB7, Level::High, Speed::Low); diff --git a/examples/stm32f7/src/bin/adc.rs b/examples/stm32f7/src/bin/adc.rs index 2a813c05..a0b9bc57 100644 --- a/examples/stm32f7/src/bin/adc.rs +++ b/examples/stm32f7/src/bin/adc.rs @@ -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); diff --git a/examples/stm32f7/src/bin/blinky.rs b/examples/stm32f7/src/bin/blinky.rs index f71fe098..249bbd88 100644 --- a/examples/stm32f7/src/bin/blinky.rs +++ b/examples/stm32f7/src/bin/blinky.rs @@ -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.PB7, Level::High, Speed::Low); diff --git a/examples/stm32f7/src/bin/button_exti.rs b/examples/stm32f7/src/bin/button_exti.rs index 60dfb362..25d3bb9c 100644 --- a/examples/stm32f7/src/bin/button_exti.rs +++ b/examples/stm32f7/src/bin/button_exti.rs @@ -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.PC13, Pull::Down); diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index 33504af7..f8904fa0 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs @@ -12,7 +12,7 @@ use embassy_stm32::eth::{Ethernet, State}; use embassy_stm32::peripherals::ETH; use embassy_stm32::rng::Rng; use embassy_stm32::time::mhz; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use embassy_util::Forever; use embedded_io::asynch::Write; use rand_core::RngCore; @@ -39,8 +39,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(spawner: Spawner, p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(spawner: Spawner) -> ! { + let p = embassy_stm32::init(config()); info!("Hello World!"); // Generate random seed. diff --git a/examples/stm32f7/src/bin/flash.rs b/examples/stm32f7/src/bin/flash.rs index 15864cab..f4d8a1c5 100644 --- a/examples/stm32f7/src/bin/flash.rs +++ b/examples/stm32f7/src/bin/flash.rs @@ -6,12 +6,12 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; 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 = 0x8_0000; diff --git a/examples/stm32f7/src/bin/hello.rs b/examples/stm32f7/src/bin/hello.rs index f957656e..6facb9bb 100644 --- a/examples/stm32f7/src/bin/hello.rs +++ b/examples/stm32f7/src/bin/hello.rs @@ -6,7 +6,7 @@ use defmt::info; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::time::Hertz; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -15,8 +15,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, _p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(_spawner: Spawner) -> ! { + let _p = embassy_stm32::init(config()); loop { info!("Hello World!"); Timer::after(Duration::from_secs(1)).await; diff --git a/examples/stm32f7/src/bin/sdmmc.rs b/examples/stm32f7/src/bin/sdmmc.rs index 1f321df1..975c5b91 100644 --- a/examples/stm32f7/src/bin/sdmmc.rs +++ b/examples/stm32f7/src/bin/sdmmc.rs @@ -6,7 +6,7 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::mhz; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -15,8 +15,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(_spawner: Spawner) -> ! { + let p = embassy_stm32::init(config()); info!("Hello World!"); let irq = interrupt::take!(SDMMC1); diff --git a/examples/stm32f7/src/bin/usart_dma.rs b/examples/stm32f7/src/bin/usart_dma.rs index 9884d163..27da10ef 100644 --- a/examples/stm32f7/src/bin/usart_dma.rs +++ b/examples/stm32f7/src/bin/usart_dma.rs @@ -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()); let config = Config::default(); let mut usart = Uart::new(p.UART7, p.PA8, p.PA15, p.DMA1_CH1, NoDma, config); diff --git a/examples/stm32g0/src/bin/blinky.rs b/examples/stm32g0/src/bin/blinky.rs index f71fe098..249bbd88 100644 --- a/examples/stm32g0/src/bin/blinky.rs +++ b/examples/stm32g0/src/bin/blinky.rs @@ -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.PB7, Level::High, Speed::Low); diff --git a/examples/stm32g0/src/bin/button_exti.rs b/examples/stm32g0/src/bin/button_exti.rs index 0832386e..8909a1fe 100644 --- a/examples/stm32g0/src/bin/button_exti.rs +++ b/examples/stm32g0/src/bin/button_exti.rs @@ -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.PC13, Pull::Up); diff --git a/examples/stm32g4/src/bin/blinky.rs b/examples/stm32g4/src/bin/blinky.rs index ea3c563b..e905a311 100644 --- a/examples/stm32g4/src/bin/blinky.rs +++ b/examples/stm32g4/src/bin/blinky.rs @@ -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); diff --git a/examples/stm32g4/src/bin/button_exti.rs b/examples/stm32g4/src/bin/button_exti.rs index 60dfb362..25d3bb9c 100644 --- a/examples/stm32g4/src/bin/button_exti.rs +++ b/examples/stm32g4/src/bin/button_exti.rs @@ -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.PC13, Pull::Down); diff --git a/examples/stm32g4/src/bin/pwm.rs b/examples/stm32g4/src/bin/pwm.rs index 7c16d0a3..f10da3d6 100644 --- a/examples/stm32g4/src/bin/pwm.rs +++ b/examples/stm32g4/src/bin/pwm.rs @@ -8,11 +8,11 @@ use embassy_executor::time::{Duration, Timer}; use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; use embassy_stm32::pwm::Channel; use embassy_stm32::time::khz; -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 ch1 = PwmPin::new_ch1(p.PA5); diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs index f50976a3..96457e76 100644 --- a/examples/stm32h7/src/bin/adc.rs +++ b/examples/stm32h7/src/bin/adc.rs @@ -8,7 +8,7 @@ use embassy_executor::time::{Delay, Duration, Timer}; use embassy_stm32::adc::{Adc, SampleTime}; use embassy_stm32::rcc::AdcClockSource; use embassy_stm32::time::mhz; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { @@ -20,8 +20,9 @@ pub fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, mut p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let mut p = embassy_stm32::init(config()); info!("Hello World!"); let mut adc = Adc::new(p.ADC3, &mut Delay); diff --git a/examples/stm32h7/src/bin/blinky.rs b/examples/stm32h7/src/bin/blinky.rs index 98ce15cc..be2fa64c 100644 --- a/examples/stm32h7/src/bin/blinky.rs +++ b/examples/stm32h7/src/bin/blinky.rs @@ -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); diff --git a/examples/stm32h7/src/bin/button_exti.rs b/examples/stm32h7/src/bin/button_exti.rs index 60dfb362..25d3bb9c 100644 --- a/examples/stm32h7/src/bin/button_exti.rs +++ b/examples/stm32h7/src/bin/button_exti.rs @@ -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.PC13, Pull::Down); diff --git a/examples/stm32h7/src/bin/camera.rs b/examples/stm32h7/src/bin/camera.rs index a3bb2d5e..8e93a54c 100644 --- a/examples/stm32h7/src/bin/camera.rs +++ b/examples/stm32h7/src/bin/camera.rs @@ -9,7 +9,7 @@ use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::i2c::I2c; use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; use embassy_stm32::time::{khz, mhz}; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use {defmt_rtt as _, panic_probe as _}; #[allow(unused)] @@ -32,8 +32,9 @@ const HEIGHT: usize = 100; static mut FRAME: [u32; WIDTH * HEIGHT / 2] = [0u32; WIDTH * HEIGHT / 2]; -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); defmt::info!("Hello World!"); let mco = Mco::new(p.MCO1, p.PA8, Mco1Source::Hsi, McoClock::Divided(3)); diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 4282fced..7ad2f52c 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs @@ -12,7 +12,7 @@ use embassy_stm32::eth::{Ethernet, State}; use embassy_stm32::peripherals::ETH; use embassy_stm32::rng::Rng; use embassy_stm32::time::mhz; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use embassy_util::Forever; use embedded_io::asynch::Write; use rand_core::RngCore; @@ -41,8 +41,9 @@ pub fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(spawner: Spawner, p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(spawner: Spawner) -> ! { + let p = embassy_stm32::init(config()); info!("Hello World!"); // Generate random seed. diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs index a66c6f19..736a2992 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.rs @@ -12,7 +12,7 @@ use embassy_stm32::eth::{Ethernet, State}; use embassy_stm32::peripherals::ETH; use embassy_stm32::rng::Rng; use embassy_stm32::time::mhz; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use embassy_util::Forever; use embedded_io::asynch::Write; use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; @@ -42,8 +42,9 @@ pub fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(spawner: Spawner, p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(spawner: Spawner) -> ! { + let p = embassy_stm32::init(config()); info!("Hello World!"); // Generate random seed. diff --git a/examples/stm32h7/src/bin/flash.rs b/examples/stm32h7/src/bin/flash.rs index 0c477deb..2d6f3a16 100644 --- a/examples/stm32h7/src/bin/flash.rs +++ b/examples/stm32h7/src/bin/flash.rs @@ -6,12 +6,12 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; 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 = 0x08_0000; diff --git a/examples/stm32h7/src/bin/fmc.rs b/examples/stm32h7/src/bin/fmc.rs index 5140a6e2..838427b0 100644 --- a/examples/stm32h7/src/bin/fmc.rs +++ b/examples/stm32h7/src/bin/fmc.rs @@ -7,7 +7,7 @@ use embassy_executor::executor::Spawner; use embassy_executor::time::{Delay, Duration, Timer}; use embassy_stm32::fmc::Fmc; use embassy_stm32::time::mhz; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { @@ -18,8 +18,9 @@ pub fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); let mut core_peri = cortex_m::Peripherals::take().unwrap(); diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index f2477c7a..e759c47a 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs @@ -9,7 +9,7 @@ use embassy_stm32::gpio::low_level::AFType; use embassy_stm32::gpio::Speed; use embassy_stm32::pwm::*; use embassy_stm32::time::{khz, mhz, Hertz}; -use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef, Peripherals}; +use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef}; use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { @@ -24,8 +24,9 @@ pub fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); let mut pwm = SimplePwm32::new(p.TIM5, p.PA0, p.PA1, p.PA2, p.PA3, khz(10)); diff --git a/examples/stm32h7/src/bin/mco.rs b/examples/stm32h7/src/bin/mco.rs index 83ba3742..31aa3f33 100644 --- a/examples/stm32h7/src/bin/mco.rs +++ b/examples/stm32h7/src/bin/mco.rs @@ -7,11 +7,11 @@ use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; -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); diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs index 36ed2e4a..4797de0a 100644 --- a/examples/stm32h7/src/bin/pwm.rs +++ b/examples/stm32h7/src/bin/pwm.rs @@ -8,7 +8,7 @@ use embassy_executor::time::{Duration, Timer}; use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; use embassy_stm32::pwm::Channel; use embassy_stm32::time::{khz, mhz}; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { @@ -23,8 +23,9 @@ pub fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); let ch1 = PwmPin::new_ch1(p.PA6); diff --git a/examples/stm32h7/src/bin/rng.rs b/examples/stm32h7/src/bin/rng.rs index 81fb3d16..2c52f4a0 100644 --- a/examples/stm32h7/src/bin/rng.rs +++ b/examples/stm32h7/src/bin/rng.rs @@ -5,11 +5,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::rng::Rng; -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 rng = Rng::new(p.RNG); diff --git a/examples/stm32h7/src/bin/sdmmc.rs b/examples/stm32h7/src/bin/sdmmc.rs index 19ae5ade..ec98bf14 100644 --- a/examples/stm32h7/src/bin/sdmmc.rs +++ b/examples/stm32h7/src/bin/sdmmc.rs @@ -6,7 +6,7 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::mhz; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -15,8 +15,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) -> ! { +#[embassy_executor::main] +async fn main(_spawner: Spawner) -> ! { + let p = embassy_stm32::init(config()); info!("Hello World!"); let irq = interrupt::take!(SDMMC1); diff --git a/examples/stm32h7/src/bin/signal.rs b/examples/stm32h7/src/bin/signal.rs index 2fc75c7a..c4ec2b60 100644 --- a/examples/stm32h7/src/bin/signal.rs +++ b/examples/stm32h7/src/bin/signal.rs @@ -5,7 +5,6 @@ use defmt::{info, unwrap}; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Timer}; -use embassy_stm32::Peripherals; use embassy_util::channel::signal::Signal; use {defmt_rtt as _, panic_probe as _}; @@ -25,7 +24,8 @@ async fn my_sending_task() { } #[embassy_executor::main] -async fn main(spawner: Spawner, _p: Peripherals) { +async fn main(spawner: Spawner) { + let _p = embassy_stm32::init(Default::default()); unwrap!(spawner.spawn(my_sending_task())); loop { diff --git a/examples/stm32h7/src/bin/usart_split.rs b/examples/stm32h7/src/bin/usart_split.rs index 12bb0ce9..7447319e 100644 --- a/examples/stm32h7/src/bin/usart_split.rs +++ b/examples/stm32h7/src/bin/usart_split.rs @@ -7,7 +7,6 @@ use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::peripherals::{DMA1_CH1, UART7}; use embassy_stm32::usart::{Config, Uart, UartRx}; -use embassy_stm32::Peripherals; use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; use embassy_util::channel::mpmc::Channel; use {defmt_rtt as _, panic_probe as _}; @@ -27,7 +26,8 @@ async fn writer(mut usart: Uart<'static, UART7, NoDma, NoDma>) { static CHANNEL: Channel = Channel::new(); #[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(); diff --git a/examples/stm32l0/src/bin/blinky.rs b/examples/stm32l0/src/bin/blinky.rs index 8cf21eff..06aad4d9 100644 --- a/examples/stm32l0/src/bin/blinky.rs +++ b/examples/stm32l0/src/bin/blinky.rs @@ -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.PB5, Level::High, Speed::Low); diff --git a/examples/stm32l0/src/bin/button.rs b/examples/stm32l0/src/bin/button.rs index a5e05c3a..14200334 100644 --- a/examples/stm32l0/src/bin/button.rs +++ b/examples/stm32l0/src/bin/button.rs @@ -5,11 +5,11 @@ use defmt::*; use embassy_executor::executor::Spawner; 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(_spawner: Spawner, p: Peripherals) { +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(Default::default()); info!("Hello World!"); let button = Input::new(p.PB2, Pull::Up); diff --git a/examples/stm32l0/src/bin/button_exti.rs b/examples/stm32l0/src/bin/button_exti.rs index 22a096af..ab23fd5b 100644 --- a/examples/stm32l0/src/bin/button_exti.rs +++ b/examples/stm32l0/src/bin/button_exti.rs @@ -6,7 +6,6 @@ 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 _}; fn config() -> embassy_stm32::Config { @@ -15,8 +14,9 @@ fn config() -> embassy_stm32::Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); let button = Input::new(p.PB2, Pull::Up); let mut button = ExtiInput::new(button, p.EXTI2); diff --git a/examples/stm32l0/src/bin/flash.rs b/examples/stm32l0/src/bin/flash.rs index 7ad5ae3a..f33bd9bb 100644 --- a/examples/stm32l0/src/bin/flash.rs +++ b/examples/stm32l0/src/bin/flash.rs @@ -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; diff --git a/examples/stm32l0/src/bin/lorawan.rs b/examples/stm32l0/src/bin/lorawan.rs index 29e54c1b..4e5b6936 100644 --- a/examples/stm32l0/src/bin/lorawan.rs +++ b/examples/stm32l0/src/bin/lorawan.rs @@ -6,13 +6,14 @@ #![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] +use embassy_executor::executor::Spawner; use embassy_lora::sx127x::*; use embassy_lora::LoraTimer; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::rng::Rng; +use embassy_stm32::spi; use embassy_stm32::time::khz; -use embassy_stm32::{spi, Peripherals}; use lorawan::default_crypto::DefaultFactory as Crypto; use lorawan_device::async_device::{region, Device, JoinMode}; use {defmt_rtt as _, panic_probe as _}; @@ -24,8 +25,9 @@ fn config() -> embassy_stm32::Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: embassy_executor::executor::Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); // SPI for sx127x let spi = spi::Spi::new( p.SPI1, diff --git a/examples/stm32l0/src/bin/spi.rs b/examples/stm32l0/src/bin/spi.rs index 74694295..e61c642b 100644 --- a/examples/stm32l0/src/bin/spi.rs +++ b/examples/stm32l0/src/bin/spi.rs @@ -8,11 +8,11 @@ use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; -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, folks!"); let mut spi = Spi::new( diff --git a/examples/stm32l0/src/bin/usart_dma.rs b/examples/stm32l0/src/bin/usart_dma.rs index 1c5ce94d..b686c410 100644 --- a/examples/stm32l0/src/bin/usart_dma.rs +++ b/examples/stm32l0/src/bin/usart_dma.rs @@ -5,11 +5,11 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::usart::{Config, Uart}; -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()); let mut usart = Uart::new(p.USART1, p.PB7, p.PB6, p.DMA1_CH2, p.DMA1_CH3, Config::default()); usart.write(b"Hello Embassy World!\r\n").await.unwrap(); diff --git a/examples/stm32l0/src/bin/usart_irq.rs b/examples/stm32l0/src/bin/usart_irq.rs index b77d97f8..f6d99836 100644 --- a/examples/stm32l0/src/bin/usart_irq.rs +++ b/examples/stm32l0/src/bin/usart_irq.rs @@ -5,13 +5,14 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; +use embassy_stm32::interrupt; use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; -use embassy_stm32::{interrupt, Peripherals}; use embedded_io::asynch::{Read, Write}; 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!("Hi!"); static mut TX_BUFFER: [u8; 8] = [0; 8]; diff --git a/examples/stm32l1/src/bin/blinky.rs b/examples/stm32l1/src/bin/blinky.rs index 58306be9..8ecdb7bb 100644 --- a/examples/stm32l1/src/bin/blinky.rs +++ b/examples/stm32l1/src/bin/blinky.rs @@ -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.PA12, Level::High, Speed::Low); diff --git a/examples/stm32l1/src/bin/flash.rs b/examples/stm32l1/src/bin/flash.rs index 78938fe3..399b09f9 100644 --- a/examples/stm32l1/src/bin/flash.rs +++ b/examples/stm32l1/src/bin/flash.rs @@ -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; diff --git a/examples/stm32l1/src/bin/spi.rs b/examples/stm32l1/src/bin/spi.rs index 05e869e7..42441615 100644 --- a/examples/stm32l1/src/bin/spi.rs +++ b/examples/stm32l1/src/bin/spi.rs @@ -8,11 +8,11 @@ use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; -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, folks!"); let mut spi = Spi::new( diff --git a/examples/stm32l4/src/bin/blinky.rs b/examples/stm32l4/src/bin/blinky.rs index 3d689b5e..8e360149 100644 --- a/examples/stm32l4/src/bin/blinky.rs +++ b/examples/stm32l4/src/bin/blinky.rs @@ -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); diff --git a/examples/stm32l4/src/bin/button_exti.rs b/examples/stm32l4/src/bin/button_exti.rs index 0832386e..8909a1fe 100644 --- a/examples/stm32l4/src/bin/button_exti.rs +++ b/examples/stm32l4/src/bin/button_exti.rs @@ -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.PC13, Pull::Up); diff --git a/examples/stm32l4/src/bin/i2c.rs b/examples/stm32l4/src/bin/i2c.rs index 5bfa560d..177f6baf 100644 --- a/examples/stm32l4/src/bin/i2c.rs +++ b/examples/stm32l4/src/bin/i2c.rs @@ -6,15 +6,16 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::i2c::I2c; +use embassy_stm32::interrupt; use embassy_stm32::time::Hertz; -use embassy_stm32::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x5F; const WHOAMI: u8 = 0x0F; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) -> ! { +async fn main(_spawner: Spawner) -> ! { + let p = embassy_stm32::init(Default::default()); let irq = interrupt::take!(I2C2_EV); let mut i2c = I2c::new( p.I2C2, diff --git a/examples/stm32l4/src/bin/i2c_blocking_async.rs b/examples/stm32l4/src/bin/i2c_blocking_async.rs index c924bc9c..8cc069d0 100644 --- a/examples/stm32l4/src/bin/i2c_blocking_async.rs +++ b/examples/stm32l4/src/bin/i2c_blocking_async.rs @@ -7,8 +7,8 @@ use embassy_embedded_hal::adapter::BlockingAsync; use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::i2c::I2c; +use embassy_stm32::interrupt; use embassy_stm32::time::Hertz; -use embassy_stm32::{interrupt, Peripherals}; use embedded_hal_async::i2c::I2c as I2cTrait; use {defmt_rtt as _, panic_probe as _}; @@ -16,7 +16,8 @@ const ADDRESS: u8 = 0x5F; const WHOAMI: u8 = 0x0F; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) -> ! { +async fn main(_spawner: Spawner) -> ! { + let p = embassy_stm32::init(Default::default()); let irq = interrupt::take!(I2C2_EV); let i2c = I2c::new( p.I2C2, diff --git a/examples/stm32l4/src/bin/i2c_dma.rs b/examples/stm32l4/src/bin/i2c_dma.rs index 2b338427..9323fd53 100644 --- a/examples/stm32l4/src/bin/i2c_dma.rs +++ b/examples/stm32l4/src/bin/i2c_dma.rs @@ -5,15 +5,16 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::i2c::I2c; +use embassy_stm32::interrupt; use embassy_stm32::time::Hertz; -use embassy_stm32::{interrupt, Peripherals}; use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x5F; const WHOAMI: u8 = 0x0F; #[embassy_executor::main] -async fn main(_spawner: Spawner, p: Peripherals) -> ! { +async fn main(_spawner: Spawner) -> ! { + let p = embassy_stm32::init(Default::default()); let irq = interrupt::take!(I2C2_EV); let mut i2c = I2c::new( p.I2C2, diff --git a/examples/stm32l4/src/bin/rng.rs b/examples/stm32l4/src/bin/rng.rs index ed47fc6c..d0e1306a 100644 --- a/examples/stm32l4/src/bin/rng.rs +++ b/examples/stm32l4/src/bin/rng.rs @@ -6,7 +6,7 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; use embassy_stm32::rng::Rng; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -22,8 +22,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); let mut rng = Rng::new(p.RNG); diff --git a/examples/stm32l4/src/bin/spi_blocking_async.rs b/examples/stm32l4/src/bin/spi_blocking_async.rs index e06b29b8..a893cef6 100644 --- a/examples/stm32l4/src/bin/spi_blocking_async.rs +++ b/examples/stm32l4/src/bin/spi_blocking_async.rs @@ -9,12 +9,12 @@ use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; -use embassy_stm32::Peripherals; use embedded_hal_async::spi::SpiBus; 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 spi = Spi::new( diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index e44754be..5b19433c 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs @@ -7,11 +7,11 @@ use embassy_executor::executor::Spawner; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; -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 spi = Spi::new( diff --git a/examples/stm32l4/src/bin/usart_dma.rs b/examples/stm32l4/src/bin/usart_dma.rs index fdd5a85e..4b3a9b23 100644 --- a/examples/stm32l4/src/bin/usart_dma.rs +++ b/examples/stm32l4/src/bin/usart_dma.rs @@ -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(); diff --git a/examples/stm32l5/src/bin/button_exti.rs b/examples/stm32l5/src/bin/button_exti.rs index 99462e59..ac394252 100644 --- a/examples/stm32l5/src/bin/button_exti.rs +++ b/examples/stm32l5/src/bin/button_exti.rs @@ -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.PC13, Pull::Down); diff --git a/examples/stm32l5/src/bin/rng.rs b/examples/stm32l5/src/bin/rng.rs index 45094374..b7919424 100644 --- a/examples/stm32l5/src/bin/rng.rs +++ b/examples/stm32l5/src/bin/rng.rs @@ -6,7 +6,7 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; use embassy_stm32::rng::Rng; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { @@ -21,8 +21,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); let mut rng = Rng::new(p.RNG); diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index 9e1df15d..cc757899 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs @@ -14,7 +14,7 @@ use embassy_stm32::rcc::*; use embassy_stm32::rng::Rng; use embassy_stm32::time::Hertz; use embassy_stm32::usb::Driver; -use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_stm32::{interrupt, Config}; use embassy_usb::{Builder, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; @@ -93,8 +93,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(spawner: Spawner) { + let p = embassy_stm32::init(config()); // Create the driver, from the HAL. let irq = interrupt::take!(USB_FS); let driver = Driver::new(p.USB, irq, p.PA12, p.PA11); diff --git a/examples/stm32l5/src/bin/usb_hid_mouse.rs b/examples/stm32l5/src/bin/usb_hid_mouse.rs index 6aac0088..b8eef6d0 100644 --- a/examples/stm32l5/src/bin/usb_hid_mouse.rs +++ b/examples/stm32l5/src/bin/usb_hid_mouse.rs @@ -27,8 +27,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); // Create the driver, from the HAL. let irq = interrupt::take!(USB_FS); let driver = Driver::new(p.USB, irq, p.PA12, p.PA11); diff --git a/examples/stm32l5/src/bin/usb_serial.rs b/examples/stm32l5/src/bin/usb_serial.rs index 508bce8a..f8894231 100644 --- a/examples/stm32l5/src/bin/usb_serial.rs +++ b/examples/stm32l5/src/bin/usb_serial.rs @@ -7,7 +7,7 @@ use embassy_executor::executor::Spawner; use embassy_stm32::rcc::*; 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}; @@ -24,8 +24,9 @@ fn config() -> Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); // Create the driver, from the HAL. diff --git a/examples/stm32u5/src/bin/blinky.rs b/examples/stm32u5/src/bin/blinky.rs index 4f3eabc5..40054295 100644 --- a/examples/stm32u5/src/bin/blinky.rs +++ b/examples/stm32u5/src/bin/blinky.rs @@ -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.PH7, Level::Low, Speed::Medium); diff --git a/examples/stm32wb/src/bin/blinky.rs b/examples/stm32wb/src/bin/blinky.rs index 3d8e8391..47f126e8 100644 --- a/examples/stm32wb/src/bin/blinky.rs +++ b/examples/stm32wb/src/bin/blinky.rs @@ -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.PB0, Level::High, Speed::Low); diff --git a/examples/stm32wb/src/bin/button_exti.rs b/examples/stm32wb/src/bin/button_exti.rs index 41afaf4d..d2816950 100644 --- a/examples/stm32wb/src/bin/button_exti.rs +++ b/examples/stm32wb/src/bin/button_exti.rs @@ -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.PC4, Pull::Up); diff --git a/examples/stm32wl/src/bin/blinky.rs b/examples/stm32wl/src/bin/blinky.rs index e764b4cc..4b8588bb 100644 --- a/examples/stm32wl/src/bin/blinky.rs +++ b/examples/stm32wl/src/bin/blinky.rs @@ -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.PB15, Level::High, Speed::Low); diff --git a/examples/stm32wl/src/bin/button_exti.rs b/examples/stm32wl/src/bin/button_exti.rs index 9f143597..ebc25562 100644 --- a/examples/stm32wl/src/bin/button_exti.rs +++ b/examples/stm32wl/src/bin/button_exti.rs @@ -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::Up); diff --git a/examples/stm32wl/src/bin/flash.rs b/examples/stm32wl/src/bin/flash.rs index 46183b8a..3c4da1e9 100644 --- a/examples/stm32wl/src/bin/flash.rs +++ b/examples/stm32wl/src/bin/flash.rs @@ -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 = 0x36000; diff --git a/examples/stm32wl/src/bin/lorawan.rs b/examples/stm32wl/src/bin/lorawan.rs index 2db022ea..35dae71a 100644 --- a/examples/stm32wl/src/bin/lorawan.rs +++ b/examples/stm32wl/src/bin/lorawan.rs @@ -5,13 +5,14 @@ #![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] +use embassy_executor::executor::Spawner; use embassy_lora::stm32wl::*; use embassy_lora::LoraTimer; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Pin, Speed}; use embassy_stm32::rng::Rng; use embassy_stm32::subghz::*; -use embassy_stm32::{interrupt, pac, Peripherals}; +use embassy_stm32::{interrupt, pac}; use lorawan::default_crypto::DefaultFactory as Crypto; use lorawan_device::async_device::{region, Device, JoinMode}; use {defmt_rtt as _, panic_probe as _}; @@ -23,8 +24,9 @@ fn config() -> embassy_stm32::Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: embassy_executor::executor::Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); unsafe { pac::RCC.ccipr().modify(|w| w.set_rngsel(0b01)) } let ctrl1 = Output::new(p.PC3.degrade(), Level::High, Speed::High); diff --git a/examples/stm32wl/src/bin/subghz.rs b/examples/stm32wl/src/bin/subghz.rs index 775dfbbf..0e2d4103 100644 --- a/examples/stm32wl/src/bin/subghz.rs +++ b/examples/stm32wl/src/bin/subghz.rs @@ -6,12 +6,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; +use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::exti::ExtiInput; 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_stm32::{interrupt, Peripherals}; use embassy_util::channel::signal::Signal; use {defmt_rtt as _, panic_probe as _}; @@ -57,8 +58,9 @@ fn config() -> embassy_stm32::Config { config } -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: embassy_executor::executor::Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); let mut led2 = Output::new(p.PB9, Level::Low, Speed::Low); let mut led3 = Output::new(p.PB11, Level::Low, Speed::Low); diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs index 6f6baf77..2d1a2ee5 100644 --- a/tests/rp/src/bin/gpio.rs +++ b/tests/rp/src/bin/gpio.rs @@ -5,11 +5,11 @@ use defmt::{assert, *}; use embassy_executor::executor::Spawner; use embassy_rp::gpio::{Flex, Input, Level, Output, OutputOpenDrain, 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()); info!("Hello World!"); let (mut a, mut b) = (p.PIN_0, p.PIN_1); diff --git a/tests/rp/src/bin/gpio_async.rs b/tests/rp/src/bin/gpio_async.rs index 1098682a..d8878687 100644 --- a/tests/rp/src/bin/gpio_async.rs +++ b/tests/rp/src/bin/gpio_async.rs @@ -6,12 +6,12 @@ use defmt::{assert, *}; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Instant, Timer}; use embassy_rp::gpio::{Input, Level, Output, Pull}; -use embassy_rp::Peripherals; 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_rp::init(Default::default()); info!("embassy-rp gpio_async test"); // On the CI device the following pins are connected with each other. diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index 8eab731b..dc7223c6 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs @@ -7,11 +7,11 @@ mod example_common; use defmt::assert; use embassy_executor::executor::Spawner; use embassy_stm32::gpio::{Flex, Input, Level, Output, OutputOpenDrain, Pull, Speed}; -use embassy_stm32::Peripherals; use example_common::*; -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); // Arduino pins D0 and D1 diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs index 6d38b0bb..2c0b7fc4 100644 --- a/tests/stm32/src/bin/spi.rs +++ b/tests/stm32/src/bin/spi.rs @@ -9,11 +9,11 @@ use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::spi::{self, Spi}; use embassy_stm32::time::Hertz; -use embassy_stm32::Peripherals; use example_common::*; -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); #[cfg(feature = "stm32f103c8")] diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs index 8147c5f0..af1118b5 100644 --- a/tests/stm32/src/bin/spi_dma.rs +++ b/tests/stm32/src/bin/spi_dma.rs @@ -8,11 +8,11 @@ use defmt::assert_eq; use embassy_executor::executor::Spawner; use embassy_stm32::spi::{self, Spi}; use embassy_stm32::time::Hertz; -use embassy_stm32::Peripherals; use example_common::*; -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); #[cfg(feature = "stm32f103c8")] diff --git a/tests/stm32/src/bin/timer.rs b/tests/stm32/src/bin/timer.rs index 76b07ca1..34903084 100644 --- a/tests/stm32/src/bin/timer.rs +++ b/tests/stm32/src/bin/timer.rs @@ -7,11 +7,11 @@ mod example_common; use defmt::assert; use embassy_executor::executor::Spawner; use embassy_executor::time::{Duration, Instant, Timer}; -use embassy_stm32::Peripherals; use example_common::*; -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, _p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let _p = embassy_stm32::init(config()); info!("Hello World!"); let start = Instant::now(); diff --git a/tests/stm32/src/bin/usart.rs b/tests/stm32/src/bin/usart.rs index 7b60e4b2..f454c1f7 100644 --- a/tests/stm32/src/bin/usart.rs +++ b/tests/stm32/src/bin/usart.rs @@ -8,11 +8,11 @@ use defmt::assert_eq; use embassy_executor::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use embassy_stm32::Peripherals; use example_common::*; -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); #[cfg(feature = "stm32wb55rg")] diff --git a/tests/stm32/src/bin/usart_dma.rs b/tests/stm32/src/bin/usart_dma.rs index 323c41ca..fbaccd17 100644 --- a/tests/stm32/src/bin/usart_dma.rs +++ b/tests/stm32/src/bin/usart_dma.rs @@ -7,11 +7,11 @@ mod example_common; use defmt::assert_eq; use embassy_executor::executor::Spawner; use embassy_stm32::usart::{Config, Uart}; -use embassy_stm32::Peripherals; use example_common::*; -#[embassy_executor::main(config = "config()")] -async fn main(_spawner: Spawner, p: Peripherals) { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_stm32::init(config()); info!("Hello World!"); #[cfg(feature = "stm32wb55rg")] From 2e85eaf7d5f4dcf6d84f426542b8ec87aa51c429 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 17 Aug 2022 22:25:58 +0200 Subject: [PATCH 26/31] examples Remove the `fn config()` idiom. It was only useful for doing #[embassy_executor::main(config = "config()")]`. Now that it's gone, it makes more sense to build the config in main directly. --- examples/stm32f1/src/bin/hello.rs | 11 +++----- examples/stm32f1/src/bin/usb_serial.rs | 9 +++---- examples/stm32f2/src/bin/pll.rs | 13 +++++---- examples/stm32f3/src/bin/hello.rs | 9 +++---- examples/stm32f3/src/bin/usb_serial.rs | 11 +++----- examples/stm32f4/src/bin/hello.rs | 11 +++----- examples/stm32f4/src/bin/sdmmc.rs | 10 +++---- examples/stm32f7/src/bin/eth.rs | 11 +++----- examples/stm32f7/src/bin/hello.rs | 11 +++----- examples/stm32f7/src/bin/sdmmc.rs | 11 +++----- examples/stm32h7/src/bin/adc.rs | 9 +++---- examples/stm32h7/src/bin/camera.rs | 27 ++++++++----------- examples/stm32h7/src/bin/dac.rs | 14 ++++------ examples/stm32h7/src/bin/eth.rs | 10 +++---- examples/stm32h7/src/bin/eth_client.rs | 10 +++---- examples/stm32h7/src/bin/fmc.rs | 9 +++---- .../stm32h7/src/bin/low_level_timer_api.rs | 9 +++---- examples/stm32h7/src/bin/pwm.rs | 10 +++---- examples/stm32h7/src/bin/sdmmc.rs | 10 +++---- examples/stm32h7/src/bin/spi.rs | 14 ++++------ examples/stm32h7/src/bin/spi_dma.rs | 14 ++++------ examples/stm32l0/src/bin/button_exti.rs | 12 ++++----- examples/stm32l0/src/bin/lorawan.rs | 9 +++---- examples/stm32l4/src/bin/rng.rs | 9 +++---- examples/stm32l5/src/bin/rng.rs | 9 +++---- examples/stm32l5/src/bin/usb_ethernet.rs | 16 ++++------- examples/stm32l5/src/bin/usb_hid_mouse.rs | 16 ++++------- examples/stm32l5/src/bin/usb_serial.rs | 16 ++++------- examples/stm32wl/src/bin/lorawan.rs | 9 +++---- examples/stm32wl/src/bin/subghz.rs | 11 +++----- 30 files changed, 121 insertions(+), 229 deletions(-) diff --git a/examples/stm32f1/src/bin/hello.rs b/examples/stm32f1/src/bin/hello.rs index 721b21c3..57892d3c 100644 --- a/examples/stm32f1/src/bin/hello.rs +++ b/examples/stm32f1/src/bin/hello.rs @@ -9,15 +9,12 @@ use embassy_stm32::time::Hertz; use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; -fn config() -> Config { - let mut config = Config::default(); - config.rcc.sys_ck = Some(Hertz(36_000_000)); - config -} - #[embassy_executor::main] async fn main(_spawner: Spawner) -> ! { - let _p = embassy_stm32::init(config()); + let mut config = Config::default(); + config.rcc.sys_ck = Some(Hertz(36_000_000)); + let _p = embassy_stm32::init(config); + loop { info!("Hello World!"); Timer::after(Duration::from_secs(1)).await; diff --git a/examples/stm32f1/src/bin/usb_serial.rs b/examples/stm32f1/src/bin/usb_serial.rs index 7f27e625..2301c51b 100644 --- a/examples/stm32f1/src/bin/usb_serial.rs +++ b/examples/stm32f1/src/bin/usb_serial.rs @@ -15,17 +15,14 @@ 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] -async fn main(_spawner: Spawner) { - let mut p = embassy_stm32::init(config()); info!("Hello World!"); { diff --git a/examples/stm32f2/src/bin/pll.rs b/examples/stm32f2/src/bin/pll.rs index bc0c160b..6fce7a71 100644 --- a/examples/stm32f2/src/bin/pll.rs +++ b/examples/stm32f2/src/bin/pll.rs @@ -14,8 +14,10 @@ use embassy_stm32::time::Hertz; 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,12 +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] -async fn main(_spawner: Spawner) { - let _p = embassy_stm32::init(config()); + let _p = embassy_stm32::init(config); + loop { Timer::after(Duration::from_millis(1000)).await; info!("1s elapsed"); diff --git a/examples/stm32f3/src/bin/hello.rs b/examples/stm32f3/src/bin/hello.rs index 7846912c..cd59f740 100644 --- a/examples/stm32f3/src/bin/hello.rs +++ b/examples/stm32f3/src/bin/hello.rs @@ -9,16 +9,13 @@ use embassy_stm32::time::Hertz; 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] -async fn main(_spawner: Spawner) -> ! { - let _p = embassy_stm32::init(config()); loop { info!("Hello World!"); Timer::after(Duration::from_secs(1)).await; diff --git a/examples/stm32f3/src/bin/usb_serial.rs b/examples/stm32f3/src/bin/usb_serial.rs index 36d38d87..757643ea 100644 --- a/examples/stm32f3/src/bin/usb_serial.rs +++ b/examples/stm32f3/src/bin/usb_serial.rs @@ -15,21 +15,16 @@ 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(mhz(8)); config.rcc.sysclk = Some(mhz(48)); config.rcc.pclk1 = Some(mhz(24)); config.rcc.pclk2 = Some(mhz(24)); config.rcc.pll48 = true; + let p = embassy_stm32::init(config); - config -} - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_stm32::init(config()); info!("Hello World!"); // Needed for nucleo-stm32f303ze diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs index 6facb9bb..26d3555a 100644 --- a/examples/stm32f4/src/bin/hello.rs +++ b/examples/stm32f4/src/bin/hello.rs @@ -9,15 +9,12 @@ use embassy_stm32::time::Hertz; use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; -fn config() -> Config { - let mut config = Config::default(); - config.rcc.sys_ck = Some(Hertz(84_000_000)); - config -} - #[embassy_executor::main] async fn main(_spawner: Spawner) -> ! { - let _p = embassy_stm32::init(config()); + let mut config = Config::default(); + config.rcc.sys_ck = Some(Hertz(84_000_000)); + let _p = embassy_stm32::init(config); + loop { info!("Hello World!"); Timer::after(Duration::from_secs(1)).await; diff --git a/examples/stm32f4/src/bin/sdmmc.rs b/examples/stm32f4/src/bin/sdmmc.rs index 996694f2..b8e56d2e 100644 --- a/examples/stm32f4/src/bin/sdmmc.rs +++ b/examples/stm32f4/src/bin/sdmmc.rs @@ -9,15 +9,11 @@ use embassy_stm32::time::mhz; use embassy_stm32::{interrupt, Config}; use {defmt_rtt as _, panic_probe as _}; -fn config() -> Config { - let mut config = Config::default(); - config.rcc.sys_ck = Some(mhz(48)); - config -} - #[embassy_executor::main] async fn main(_spawner: Spawner) -> ! { - let p = embassy_stm32::init(config()); + let mut config = Config::default(); + config.rcc.sys_ck = Some(mhz(48)); + let p = embassy_stm32::init(config); info!("Hello World!"); let irq = interrupt::take!(SDIO); diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index f8904fa0..1ec30353 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs @@ -33,15 +33,12 @@ async fn net_task(stack: &'static Stack) -> ! { stack.run().await } -fn config() -> Config { - let mut config = Config::default(); - config.rcc.sys_ck = Some(mhz(200)); - config -} - #[embassy_executor::main] async fn main(spawner: Spawner) -> ! { - let p = embassy_stm32::init(config()); + let mut config = Config::default(); + config.rcc.sys_ck = Some(mhz(200)); + let p = embassy_stm32::init(config); + info!("Hello World!"); // Generate random seed. diff --git a/examples/stm32f7/src/bin/hello.rs b/examples/stm32f7/src/bin/hello.rs index 6facb9bb..26d3555a 100644 --- a/examples/stm32f7/src/bin/hello.rs +++ b/examples/stm32f7/src/bin/hello.rs @@ -9,15 +9,12 @@ use embassy_stm32::time::Hertz; use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; -fn config() -> Config { - let mut config = Config::default(); - config.rcc.sys_ck = Some(Hertz(84_000_000)); - config -} - #[embassy_executor::main] async fn main(_spawner: Spawner) -> ! { - let _p = embassy_stm32::init(config()); + let mut config = Config::default(); + config.rcc.sys_ck = Some(Hertz(84_000_000)); + let _p = embassy_stm32::init(config); + loop { info!("Hello World!"); Timer::after(Duration::from_secs(1)).await; diff --git a/examples/stm32f7/src/bin/sdmmc.rs b/examples/stm32f7/src/bin/sdmmc.rs index 975c5b91..9d97a1de 100644 --- a/examples/stm32f7/src/bin/sdmmc.rs +++ b/examples/stm32f7/src/bin/sdmmc.rs @@ -9,15 +9,12 @@ use embassy_stm32::time::mhz; use embassy_stm32::{interrupt, Config}; use {defmt_rtt as _, panic_probe as _}; -fn config() -> Config { - let mut config = Config::default(); - config.rcc.sys_ck = Some(mhz(200)); - config -} - #[embassy_executor::main] async fn main(_spawner: Spawner) -> ! { - let p = embassy_stm32::init(config()); + let mut config = Config::default(); + config.rcc.sys_ck = Some(mhz(200)); + let p = embassy_stm32::init(config); + info!("Hello World!"); let irq = interrupt::take!(SDMMC1); diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs index 96457e76..0715a0f6 100644 --- a/examples/stm32h7/src/bin/adc.rs +++ b/examples/stm32h7/src/bin/adc.rs @@ -11,18 +11,15 @@ use embassy_stm32::time::mhz; use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; -pub fn config() -> Config { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { let mut config = Config::default(); config.rcc.sys_ck = Some(mhz(400)); config.rcc.hclk = Some(mhz(200)); config.rcc.per_ck = Some(mhz(64)); config.rcc.adc_clock_source = AdcClockSource::PerCk; - config -} + let mut p = embassy_stm32::init(config); -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let mut p = embassy_stm32::init(config()); info!("Hello World!"); let mut adc = Adc::new(p.ADC3, &mut Delay); diff --git a/examples/stm32h7/src/bin/camera.rs b/examples/stm32h7/src/bin/camera.rs index 8e93a54c..a281e75c 100644 --- a/examples/stm32h7/src/bin/camera.rs +++ b/examples/stm32h7/src/bin/camera.rs @@ -10,22 +10,8 @@ use embassy_stm32::i2c::I2c; use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; use embassy_stm32::time::{khz, mhz}; use embassy_stm32::{interrupt, Config}; -use {defmt_rtt as _, panic_probe as _}; - -#[allow(unused)] -pub fn config() -> Config { - let mut config = Config::default(); - config.rcc.sys_ck = Some(mhz(400)); - config.rcc.hclk = Some(mhz(400)); - config.rcc.pll1.q_ck = Some(mhz(100)); - config.rcc.pclk1 = Some(mhz(100)); - config.rcc.pclk2 = Some(mhz(100)); - config.rcc.pclk3 = Some(mhz(100)); - config.rcc.pclk4 = Some(mhz(100)); - config -} - use ov7725::*; +use {defmt_rtt as _, panic_probe as _}; const WIDTH: usize = 100; const HEIGHT: usize = 100; @@ -34,7 +20,16 @@ static mut FRAME: [u32; WIDTH * HEIGHT / 2] = [0u32; WIDTH * HEIGHT / 2]; #[embassy_executor::main] async fn main(_spawner: Spawner) { - let p = embassy_stm32::init(config()); + let mut config = Config::default(); + config.rcc.sys_ck = Some(mhz(400)); + config.rcc.hclk = Some(mhz(400)); + config.rcc.pll1.q_ck = Some(mhz(100)); + config.rcc.pclk1 = Some(mhz(100)); + config.rcc.pclk2 = Some(mhz(100)); + config.rcc.pclk3 = Some(mhz(100)); + config.rcc.pclk4 = Some(mhz(100)); + let p = embassy_stm32::init(config); + defmt::info!("Hello World!"); let mco = Mco::new(p.MCO1, p.PA8, Mco1Source::Hsi, McoClock::Divided(3)); diff --git a/examples/stm32h7/src/bin/dac.rs b/examples/stm32h7/src/bin/dac.rs index dece74bb..f1271637 100644 --- a/examples/stm32h7/src/bin/dac.rs +++ b/examples/stm32h7/src/bin/dac.rs @@ -9,19 +9,15 @@ use embassy_stm32::time::mhz; use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; -pub fn config() -> Config { - let mut config = Config::default(); - config.rcc.sys_ck = Some(mhz(400)); - config.rcc.hclk = Some(mhz(200)); - config.rcc.pll1.q_ck = Some(mhz(100)); - config -} - #[entry] fn main() -> ! { info!("Hello World, dude!"); - let p = embassy_stm32::init(config()); + let mut config = Config::default(); + config.rcc.sys_ck = Some(mhz(400)); + config.rcc.hclk = Some(mhz(200)); + config.rcc.pll1.q_ck = Some(mhz(100)); + let p = embassy_stm32::init(config); let mut dac = Dac::new_1ch(p.DAC1, p.PA4); diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 7ad2f52c..9039b7ee 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs @@ -33,17 +33,13 @@ async fn net_task(stack: &'static Stack) -> ! { stack.run().await } -pub fn config() -> Config { +#[embassy_executor::main] +async fn main(spawner: Spawner) -> ! { let mut config = Config::default(); config.rcc.sys_ck = Some(mhz(400)); config.rcc.hclk = Some(mhz(200)); config.rcc.pll1.q_ck = Some(mhz(100)); - config -} - -#[embassy_executor::main] -async fn main(spawner: Spawner) -> ! { - let p = embassy_stm32::init(config()); + let p = embassy_stm32::init(config); info!("Hello World!"); // Generate random seed. diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs index 736a2992..25e75d71 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.rs @@ -34,17 +34,13 @@ async fn net_task(stack: &'static Stack) -> ! { stack.run().await } -pub fn config() -> Config { +#[embassy_executor::main] +async fn main(spawner: Spawner) -> ! { let mut config = Config::default(); config.rcc.sys_ck = Some(mhz(400)); config.rcc.hclk = Some(mhz(200)); config.rcc.pll1.q_ck = Some(mhz(100)); - config -} - -#[embassy_executor::main] -async fn main(spawner: Spawner) -> ! { - let p = embassy_stm32::init(config()); + let p = embassy_stm32::init(config); info!("Hello World!"); // Generate random seed. diff --git a/examples/stm32h7/src/bin/fmc.rs b/examples/stm32h7/src/bin/fmc.rs index 838427b0..1a0d073d 100644 --- a/examples/stm32h7/src/bin/fmc.rs +++ b/examples/stm32h7/src/bin/fmc.rs @@ -10,17 +10,14 @@ use embassy_stm32::time::mhz; use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; -pub fn config() -> Config { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { let mut config = Config::default(); config.rcc.sys_ck = Some(mhz(400)); config.rcc.hclk = Some(mhz(200)); config.rcc.pll1.q_ck = Some(mhz(100)); - config -} + let p = embassy_stm32::init(config); -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_stm32::init(config()); info!("Hello World!"); let mut core_peri = cortex_m::Peripherals::take().unwrap(); diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index e759c47a..59648d4b 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs @@ -12,7 +12,8 @@ use embassy_stm32::time::{khz, mhz, Hertz}; use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef}; use {defmt_rtt as _, panic_probe as _}; -pub fn config() -> Config { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { let mut config = Config::default(); config.rcc.sys_ck = Some(mhz(400)); config.rcc.hclk = Some(mhz(400)); @@ -21,12 +22,8 @@ pub fn config() -> Config { config.rcc.pclk2 = Some(mhz(100)); config.rcc.pclk3 = Some(mhz(100)); config.rcc.pclk4 = Some(mhz(100)); - config -} + let p = embassy_stm32::init(config); -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_stm32::init(config()); info!("Hello World!"); let mut pwm = SimplePwm32::new(p.TIM5, p.PA0, p.PA1, p.PA2, p.PA3, khz(10)); diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs index 4797de0a..b225d66e 100644 --- a/examples/stm32h7/src/bin/pwm.rs +++ b/examples/stm32h7/src/bin/pwm.rs @@ -11,7 +11,8 @@ use embassy_stm32::time::{khz, mhz}; use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; -pub fn config() -> Config { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { let mut config = Config::default(); config.rcc.sys_ck = Some(mhz(400)); config.rcc.hclk = Some(mhz(400)); @@ -20,12 +21,7 @@ pub fn config() -> Config { config.rcc.pclk2 = Some(mhz(100)); config.rcc.pclk3 = Some(mhz(100)); config.rcc.pclk4 = Some(mhz(100)); - config -} - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_stm32::init(config()); + let p = embassy_stm32::init(config); info!("Hello World!"); let ch1 = PwmPin::new_ch1(p.PA6); diff --git a/examples/stm32h7/src/bin/sdmmc.rs b/examples/stm32h7/src/bin/sdmmc.rs index ec98bf14..f44d88ac 100644 --- a/examples/stm32h7/src/bin/sdmmc.rs +++ b/examples/stm32h7/src/bin/sdmmc.rs @@ -9,15 +9,11 @@ use embassy_stm32::time::mhz; use embassy_stm32::{interrupt, Config}; use {defmt_rtt as _, panic_probe as _}; -fn config() -> Config { - let mut config = Config::default(); - config.rcc.sys_ck = Some(mhz(200)); - config -} - #[embassy_executor::main] async fn main(_spawner: Spawner) -> ! { - let p = embassy_stm32::init(config()); + let mut config = Config::default(); + config.rcc.sys_ck = Some(mhz(200)); + let p = embassy_stm32::init(config); info!("Hello World!"); let irq = interrupt::take!(SDMMC1); diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index dc8cb7f4..8f6f1485 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs @@ -16,14 +16,6 @@ use embassy_util::Forever; use heapless::String; use {defmt_rtt as _, panic_probe as _}; -pub fn config() -> Config { - let mut config = Config::default(); - config.rcc.sys_ck = Some(mhz(400)); - config.rcc.hclk = Some(mhz(200)); - config.rcc.pll1.q_ck = Some(mhz(100)); - config -} - #[embassy_executor::task] async fn main_task(mut spi: spi::Spi<'static, SPI3, NoDma, NoDma>) { for n in 0u32.. { @@ -45,7 +37,11 @@ static EXECUTOR: Forever = Forever::new(); fn main() -> ! { info!("Hello World!"); - let p = embassy_stm32::init(config()); + let mut config = Config::default(); + config.rcc.sys_ck = Some(mhz(400)); + config.rcc.hclk = Some(mhz(200)); + config.rcc.pll1.q_ck = Some(mhz(100)); + let p = embassy_stm32::init(config); let spi = spi::Spi::new( p.SPI3, diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index 2631ed30..d4c91a8e 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs @@ -15,14 +15,6 @@ use embassy_util::Forever; use heapless::String; use {defmt_rtt as _, panic_probe as _}; -pub fn config() -> Config { - let mut config = Config::default(); - config.rcc.sys_ck = Some(mhz(400)); - config.rcc.hclk = Some(mhz(200)); - config.rcc.pll1.q_ck = Some(mhz(100)); - config -} - #[embassy_executor::task] async fn main_task(mut spi: spi::Spi<'static, SPI3, DMA1_CH3, DMA1_CH4>) { for n in 0u32.. { @@ -41,7 +33,11 @@ static EXECUTOR: Forever = Forever::new(); fn main() -> ! { info!("Hello World!"); - let p = embassy_stm32::init(config()); + let mut config = Config::default(); + config.rcc.sys_ck = Some(mhz(400)); + config.rcc.hclk = Some(mhz(200)); + config.rcc.pll1.q_ck = Some(mhz(100)); + let p = embassy_stm32::init(config); let spi = spi::Spi::new( p.SPI3, diff --git a/examples/stm32l0/src/bin/button_exti.rs b/examples/stm32l0/src/bin/button_exti.rs index ab23fd5b..bdd2fa3c 100644 --- a/examples/stm32l0/src/bin/button_exti.rs +++ b/examples/stm32l0/src/bin/button_exti.rs @@ -6,17 +6,15 @@ use defmt::*; use embassy_executor::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; -fn config() -> embassy_stm32::Config { - let mut config = embassy_stm32::Config::default(); - config.rcc.enable_hsi48 = true; - config -} - #[embassy_executor::main] async fn main(_spawner: Spawner) { - let p = embassy_stm32::init(config()); + let mut config = Config::default(); + config.rcc.enable_hsi48 = true; + let p = embassy_stm32::init(config); + let button = Input::new(p.PB2, Pull::Up); let mut button = ExtiInput::new(button, p.EXTI2); diff --git a/examples/stm32l0/src/bin/lorawan.rs b/examples/stm32l0/src/bin/lorawan.rs index 4e5b6936..9497cad7 100644 --- a/examples/stm32l0/src/bin/lorawan.rs +++ b/examples/stm32l0/src/bin/lorawan.rs @@ -18,16 +18,13 @@ use lorawan::default_crypto::DefaultFactory as Crypto; use lorawan_device::async_device::{region, Device, JoinMode}; use {defmt_rtt as _, panic_probe as _}; -fn config() -> embassy_stm32::Config { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { let mut config = embassy_stm32::Config::default(); config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16; config.rcc.enable_hsi48 = true; - config -} + let p = embassy_stm32::init(config); -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_stm32::init(config()); // SPI for sx127x let spi = spi::Spi::new( p.SPI1, diff --git a/examples/stm32l4/src/bin/rng.rs b/examples/stm32l4/src/bin/rng.rs index d0e1306a..c9051562 100644 --- a/examples/stm32l4/src/bin/rng.rs +++ b/examples/stm32l4/src/bin/rng.rs @@ -9,7 +9,8 @@ use embassy_stm32::rng::Rng; 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(); // 72Mhz clock (16 / 1 * 18 / 4) config.rcc.mux = ClockSrc::PLL( @@ -19,12 +20,8 @@ fn config() -> Config { PLLMul::Mul18, Some(PLLClkDiv::Div6), // 48Mhz (16 / 1 * 18 / 6) ); - config -} + let p = embassy_stm32::init(config); -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_stm32::init(config()); info!("Hello World!"); let mut rng = Rng::new(p.RNG); diff --git a/examples/stm32l5/src/bin/rng.rs b/examples/stm32l5/src/bin/rng.rs index b7919424..cec9078e 100644 --- a/examples/stm32l5/src/bin/rng.rs +++ b/examples/stm32l5/src/bin/rng.rs @@ -9,7 +9,8 @@ use embassy_stm32::rng::Rng; 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.mux = ClockSrc::PLL( PLLSource::HSI16, @@ -18,12 +19,8 @@ fn config() -> Config { PLLMul::Mul8, Some(PLLClkDiv::Div2), ); - config -} + let p = embassy_stm32::init(config); -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_stm32::init(config()); info!("Hello World!"); let mut rng = Rng::new(p.RNG); diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index cc757899..769b67a2 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs @@ -83,19 +83,13 @@ async fn net_task(stack: &'static Stack) -> ! { stack.run().await } -fn config() -> Config { - let mut config = Config::default(); - config.rcc.mux = ClockSrc::HSE(Hertz(16_000_000)); - - config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); - config.rcc.hsi48 = true; - - config -} - #[embassy_executor::main] async fn main(spawner: Spawner) { - let p = embassy_stm32::init(config()); + let mut config = Config::default(); + config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); + config.rcc.hsi48 = true; + let p = embassy_stm32::init(config); + // Create the driver, from the HAL. let irq = interrupt::take!(USB_FS); let driver = Driver::new(p.USB, irq, p.PA12, p.PA11); diff --git a/examples/stm32l5/src/bin/usb_hid_mouse.rs b/examples/stm32l5/src/bin/usb_hid_mouse.rs index b8eef6d0..ef0a20a4 100644 --- a/examples/stm32l5/src/bin/usb_hid_mouse.rs +++ b/examples/stm32l5/src/bin/usb_hid_mouse.rs @@ -17,19 +17,13 @@ use futures::future::join; use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; use {defmt_rtt as _, panic_probe as _}; -fn config() -> Config { - let mut config = Config::default(); - config.rcc.mux = ClockSrc::HSE(Hertz(16_000_000)); - - config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); - config.rcc.hsi48 = true; - - config -} - #[embassy_executor::main] async fn main(_spawner: Spawner) { - let p = embassy_stm32::init(config()); + let mut config = Config::default(); + config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); + config.rcc.hsi48 = true; + let p = embassy_stm32::init(config); + // Create the driver, from the HAL. let irq = interrupt::take!(USB_FS); let driver = Driver::new(p.USB, irq, p.PA12, p.PA11); diff --git a/examples/stm32l5/src/bin/usb_serial.rs b/examples/stm32l5/src/bin/usb_serial.rs index f8894231..a763a0b5 100644 --- a/examples/stm32l5/src/bin/usb_serial.rs +++ b/examples/stm32l5/src/bin/usb_serial.rs @@ -14,19 +14,13 @@ use embassy_usb_serial::{CdcAcmClass, State}; use futures::future::join; use {defmt_rtt as _, panic_probe as _}; -fn config() -> Config { - let mut config = Config::default(); - config.rcc.mux = ClockSrc::HSE(Hertz(16_000_000)); - - config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); - config.rcc.hsi48 = true; - - config -} - #[embassy_executor::main] async fn main(_spawner: Spawner) { - let p = embassy_stm32::init(config()); + let mut config = Config::default(); + config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); + config.rcc.hsi48 = true; + let p = embassy_stm32::init(config); + info!("Hello World!"); // Create the driver, from the HAL. diff --git a/examples/stm32wl/src/bin/lorawan.rs b/examples/stm32wl/src/bin/lorawan.rs index 35dae71a..b6a3ca90 100644 --- a/examples/stm32wl/src/bin/lorawan.rs +++ b/examples/stm32wl/src/bin/lorawan.rs @@ -17,16 +17,13 @@ use lorawan::default_crypto::DefaultFactory as Crypto; use lorawan_device::async_device::{region, Device, JoinMode}; use {defmt_rtt as _, panic_probe as _}; -fn config() -> embassy_stm32::Config { +#[embassy_executor::main] +async fn main(_spawner: Spawner) { let mut config = embassy_stm32::Config::default(); config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16; config.rcc.enable_lsi = true; - config -} + let p = embassy_stm32::init(config); -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_stm32::init(config()); unsafe { pac::RCC.ccipr().modify(|w| w.set_rngsel(0b01)) } let ctrl1 = Output::new(p.PC3.degrade(), Level::High, Speed::High); diff --git a/examples/stm32wl/src/bin/subghz.rs b/examples/stm32wl/src/bin/subghz.rs index 0e2d4103..1b096514 100644 --- a/examples/stm32wl/src/bin/subghz.rs +++ b/examples/stm32wl/src/bin/subghz.rs @@ -52,15 +52,12 @@ const TCXO_MODE: TcxoMode = TcxoMode::new() const TX_PARAMS: TxParams = TxParams::new().set_power(0x0D).set_ramp_time(RampTime::Micros40); -fn config() -> embassy_stm32::Config { - let mut config = embassy_stm32::Config::default(); - config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; - config -} - #[embassy_executor::main] async fn main(_spawner: Spawner) { - let p = embassy_stm32::init(config()); + let mut config = embassy_stm32::Config::default(); + config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; + let p = embassy_stm32::init(config); + let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); let mut led2 = Output::new(p.PB9, Level::Low, Speed::Low); let mut led3 = Output::new(p.PB11, Level::Low, Speed::Low); From 5daa173ce4b153a532b4daa9e94c7a248231f25b Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 17 Aug 2022 23:40:16 +0200 Subject: [PATCH 27/31] Split embassy-time from embassy-executor. --- README.md | 6 +- ci.sh | 38 +-- ci_stable.sh | 66 ++--- docs/modules/ROOT/examples/basic/Cargo.toml | 1 + docs/modules/ROOT/examples/basic/src/main.rs | 4 +- .../layer-by-layer/blinky-async/src/main.rs | 2 +- embassy-cortex-m/src/executor.rs | 6 +- embassy-executor/Cargo.toml | 38 +-- embassy-executor/README.md | 11 + .../src/{executor => }/arch/cortex_m.rs | 0 .../src/{executor => }/arch/riscv32.rs | 0 .../src/{executor => }/arch/std.rs | 0 .../src/{executor => }/arch/wasm.rs | 0 .../src/{executor => }/arch/xtensa.rs | 0 embassy-executor/src/executor/mod.rs | 44 ---- embassy-executor/src/fmt.rs | 3 - embassy-executor/src/lib.rs | 42 +++- .../src/{executor => }/raw/mod.rs | 45 ++-- .../src/{executor => }/raw/run_queue.rs | 0 .../src/{executor => }/raw/timer_queue.rs | 2 +- .../src/{executor => }/raw/util.rs | 0 .../src/{executor => }/raw/waker.rs | 2 +- .../src/{executor => }/spawner.rs | 0 embassy-lora/Cargo.toml | 6 +- embassy-lora/src/lib.rs | 2 +- embassy-lora/src/sx127x/sx127x_lora/mod.rs | 2 +- embassy-macros/src/macros/main.rs | 8 +- embassy-macros/src/macros/task.rs | 4 +- embassy-net/Cargo.toml | 20 +- embassy-net/src/stack.rs | 2 +- embassy-nrf/Cargo.toml | 5 +- embassy-nrf/src/time_driver.rs | 4 +- embassy-nrf/src/twim.rs | 4 +- embassy-rp/Cargo.toml | 3 +- embassy-rp/src/timer.rs | 4 +- embassy-stm32/Cargo.toml | 5 +- embassy-stm32/src/subghz/mod.rs | 2 +- embassy-stm32/src/subghz/timeout.rs | 4 +- embassy-stm32/src/subghz/tx_params.rs | 18 +- embassy-stm32/src/time_driver.rs | 6 +- embassy-stm32/src/usb/usb.rs | 2 +- embassy-time/Cargo.toml | 54 +++++ .../src/time => embassy-time/src}/delay.rs | 2 +- .../src/time => embassy-time/src}/driver.rs | 44 ++-- .../time => embassy-time/src}/driver_std.rs | 2 +- .../time => embassy-time/src}/driver_wasm.rs | 2 +- .../src/time => embassy-time/src}/duration.rs | 0 embassy-time/src/fmt.rs | 225 ++++++++++++++++++ .../src/time => embassy-time/src}/instant.rs | 0 .../time/mod.rs => embassy-time/src/lib.rs | 28 ++- .../src/time => embassy-time/src}/timer.rs | 23 +- examples/boot/application/nrf/Cargo.toml | 3 +- examples/boot/application/nrf/src/bin/a.rs | 2 +- examples/boot/application/nrf/src/bin/b.rs | 4 +- examples/boot/application/stm32f3/Cargo.toml | 3 +- .../boot/application/stm32f3/src/bin/a.rs | 2 +- .../boot/application/stm32f3/src/bin/b.rs | 4 +- examples/boot/application/stm32f7/Cargo.toml | 3 +- .../boot/application/stm32f7/src/bin/a.rs | 2 +- .../boot/application/stm32f7/src/bin/b.rs | 4 +- examples/boot/application/stm32h7/Cargo.toml | 3 +- .../boot/application/stm32h7/src/bin/a.rs | 2 +- .../boot/application/stm32h7/src/bin/b.rs | 4 +- examples/boot/application/stm32l0/Cargo.toml | 3 +- .../boot/application/stm32l0/src/bin/a.rs | 4 +- .../boot/application/stm32l0/src/bin/b.rs | 4 +- examples/boot/application/stm32l1/Cargo.toml | 3 +- .../boot/application/stm32l1/src/bin/a.rs | 4 +- .../boot/application/stm32l1/src/bin/b.rs | 4 +- examples/boot/application/stm32l4/Cargo.toml | 3 +- .../boot/application/stm32l4/src/bin/a.rs | 2 +- .../boot/application/stm32l4/src/bin/b.rs | 4 +- examples/boot/application/stm32wl/Cargo.toml | 3 +- .../boot/application/stm32wl/src/bin/a.rs | 2 +- .../boot/application/stm32wl/src/bin/b.rs | 4 +- examples/nrf/Cargo.toml | 3 +- examples/nrf/src/bin/awaitable_timer.rs | 2 +- examples/nrf/src/bin/blinky.rs | 4 +- examples/nrf/src/bin/buffered_uart.rs | 2 +- examples/nrf/src/bin/channel.rs | 4 +- .../nrf/src/bin/channel_sender_receiver.rs | 4 +- .../nrf/src/bin/executor_fairness_test.rs | 4 +- examples/nrf/src/bin/gpiote_channel.rs | 2 +- examples/nrf/src/bin/gpiote_port.rs | 2 +- examples/nrf/src/bin/multiprio.rs | 2 +- examples/nrf/src/bin/mutex.rs | 4 +- examples/nrf/src/bin/nvmc.rs | 4 +- examples/nrf/src/bin/ppi.rs | 2 +- examples/nrf/src/bin/pubsub.rs | 4 +- examples/nrf/src/bin/pwm.rs | 4 +- examples/nrf/src/bin/pwm_double_sequence.rs | 4 +- examples/nrf/src/bin/pwm_sequence.rs | 4 +- examples/nrf/src/bin/pwm_sequence_ppi.rs | 2 +- examples/nrf/src/bin/pwm_sequence_ws2812b.rs | 4 +- examples/nrf/src/bin/pwm_servo.rs | 4 +- examples/nrf/src/bin/qdec.rs | 2 +- examples/nrf/src/bin/qspi.rs | 2 +- examples/nrf/src/bin/qspi_lowpower.rs | 4 +- examples/nrf/src/bin/raw_spawn.rs | 6 +- examples/nrf/src/bin/rng.rs | 2 +- examples/nrf/src/bin/saadc.rs | 4 +- examples/nrf/src/bin/saadc_continuous.rs | 6 +- examples/nrf/src/bin/self_spawn.rs | 4 +- .../src/bin/self_spawn_current_executor.rs | 4 +- examples/nrf/src/bin/spim.rs | 2 +- examples/nrf/src/bin/temp.rs | 4 +- examples/nrf/src/bin/timer.rs | 4 +- examples/nrf/src/bin/twim.rs | 2 +- examples/nrf/src/bin/twim_lowpower.rs | 4 +- examples/nrf/src/bin/uart.rs | 2 +- examples/nrf/src/bin/uart_idle.rs | 2 +- examples/nrf/src/bin/uart_split.rs | 2 +- examples/nrf/src/bin/usb_ethernet.rs | 2 +- examples/nrf/src/bin/usb_hid_keyboard.rs | 2 +- examples/nrf/src/bin/usb_hid_mouse.rs | 4 +- examples/nrf/src/bin/usb_serial.rs | 2 +- examples/nrf/src/bin/usb_serial_multitask.rs | 2 +- examples/nrf/src/bin/wdt.rs | 2 +- examples/rp/Cargo.toml | 3 +- examples/rp/src/bin/blinky.rs | 4 +- examples/rp/src/bin/button.rs | 2 +- examples/rp/src/bin/gpio_async.rs | 4 +- examples/rp/src/bin/spi.rs | 2 +- examples/rp/src/bin/spi_display.rs | 4 +- examples/rp/src/bin/uart.rs | 2 +- examples/std/Cargo.toml | 3 +- examples/std/src/bin/net.rs | 2 +- examples/std/src/bin/net_udp.rs | 2 +- examples/std/src/bin/serial.rs | 2 +- examples/std/src/bin/tick.rs | 4 +- examples/stm32f0/Cargo.toml | 3 +- examples/stm32f0/src/bin/hello.rs | 4 +- examples/stm32f1/Cargo.toml | 3 +- examples/stm32f1/src/bin/adc.rs | 4 +- examples/stm32f1/src/bin/blinky.rs | 4 +- examples/stm32f1/src/bin/hello.rs | 4 +- examples/stm32f1/src/bin/usb_serial.rs | 4 +- examples/stm32f2/Cargo.toml | 3 +- examples/stm32f2/src/bin/blinky.rs | 4 +- examples/stm32f2/src/bin/pll.rs | 4 +- examples/stm32f3/Cargo.toml | 3 +- examples/stm32f3/src/bin/blinky.rs | 4 +- examples/stm32f3/src/bin/button_events.rs | 4 +- examples/stm32f3/src/bin/button_exti.rs | 2 +- examples/stm32f3/src/bin/flash.rs | 2 +- examples/stm32f3/src/bin/hello.rs | 4 +- examples/stm32f3/src/bin/multiprio.rs | 2 +- examples/stm32f3/src/bin/spi_dma.rs | 2 +- examples/stm32f3/src/bin/usart_dma.rs | 2 +- examples/stm32f3/src/bin/usb_serial.rs | 4 +- examples/stm32f4/Cargo.toml | 3 +- examples/stm32f4/src/bin/adc.rs | 4 +- examples/stm32f4/src/bin/blinky.rs | 4 +- examples/stm32f4/src/bin/button_exti.rs | 2 +- examples/stm32f4/src/bin/dac.rs | 2 +- examples/stm32f4/src/bin/flash.rs | 2 +- examples/stm32f4/src/bin/hello.rs | 4 +- examples/stm32f4/src/bin/multiprio.rs | 2 +- examples/stm32f4/src/bin/pwm.rs | 4 +- examples/stm32f4/src/bin/sdmmc.rs | 2 +- examples/stm32f4/src/bin/spi_dma.rs | 2 +- examples/stm32f4/src/bin/usart_buffered.rs | 2 +- examples/stm32f4/src/bin/usart_dma.rs | 2 +- examples/stm32f4/src/bin/wdt.rs | 4 +- examples/stm32f7/Cargo.toml | 3 +- examples/stm32f7/src/bin/adc.rs | 4 +- examples/stm32f7/src/bin/blinky.rs | 4 +- examples/stm32f7/src/bin/button_exti.rs | 2 +- examples/stm32f7/src/bin/eth.rs | 4 +- examples/stm32f7/src/bin/flash.rs | 4 +- examples/stm32f7/src/bin/hello.rs | 4 +- examples/stm32f7/src/bin/sdmmc.rs | 2 +- examples/stm32f7/src/bin/usart_dma.rs | 2 +- examples/stm32g0/Cargo.toml | 3 +- examples/stm32g0/src/bin/blinky.rs | 4 +- examples/stm32g0/src/bin/button_exti.rs | 2 +- examples/stm32g4/Cargo.toml | 3 +- examples/stm32g4/src/bin/blinky.rs | 4 +- examples/stm32g4/src/bin/button_exti.rs | 2 +- examples/stm32g4/src/bin/pwm.rs | 4 +- examples/stm32h7/Cargo.toml | 3 +- examples/stm32h7/src/bin/adc.rs | 4 +- examples/stm32h7/src/bin/blinky.rs | 4 +- examples/stm32h7/src/bin/button_exti.rs | 2 +- examples/stm32h7/src/bin/camera.rs | 6 +- examples/stm32h7/src/bin/eth.rs | 4 +- examples/stm32h7/src/bin/eth_client.rs | 4 +- examples/stm32h7/src/bin/flash.rs | 4 +- examples/stm32h7/src/bin/fmc.rs | 4 +- .../stm32h7/src/bin/low_level_timer_api.rs | 4 +- examples/stm32h7/src/bin/mco.rs | 4 +- examples/stm32h7/src/bin/pwm.rs | 4 +- examples/stm32h7/src/bin/rng.rs | 2 +- examples/stm32h7/src/bin/sdmmc.rs | 2 +- examples/stm32h7/src/bin/signal.rs | 4 +- examples/stm32h7/src/bin/spi.rs | 2 +- examples/stm32h7/src/bin/spi_dma.rs | 2 +- examples/stm32h7/src/bin/usart.rs | 2 +- examples/stm32h7/src/bin/usart_dma.rs | 2 +- examples/stm32h7/src/bin/usart_split.rs | 2 +- examples/stm32l0/Cargo.toml | 3 +- examples/stm32l0/src/bin/blinky.rs | 4 +- examples/stm32l0/src/bin/button.rs | 2 +- examples/stm32l0/src/bin/button_exti.rs | 2 +- examples/stm32l0/src/bin/flash.rs | 2 +- examples/stm32l0/src/bin/lorawan.rs | 2 +- examples/stm32l0/src/bin/raw_spawn.rs | 6 +- examples/stm32l0/src/bin/spi.rs | 2 +- examples/stm32l0/src/bin/usart_dma.rs | 2 +- examples/stm32l0/src/bin/usart_irq.rs | 2 +- examples/stm32l1/Cargo.toml | 3 +- examples/stm32l1/src/bin/blinky.rs | 4 +- examples/stm32l1/src/bin/flash.rs | 2 +- examples/stm32l1/src/bin/spi.rs | 2 +- examples/stm32l4/Cargo.toml | 3 +- examples/stm32l4/src/bin/adc.rs | 2 +- examples/stm32l4/src/bin/blinky.rs | 4 +- examples/stm32l4/src/bin/button_exti.rs | 2 +- examples/stm32l4/src/bin/i2c.rs | 2 +- .../stm32l4/src/bin/i2c_blocking_async.rs | 2 +- examples/stm32l4/src/bin/i2c_dma.rs | 2 +- examples/stm32l4/src/bin/rng.rs | 2 +- .../stm32l4/src/bin/spi_blocking_async.rs | 2 +- examples/stm32l4/src/bin/spi_dma.rs | 2 +- examples/stm32l4/src/bin/usart_dma.rs | 2 +- examples/stm32l5/Cargo.toml | 3 +- examples/stm32l5/src/bin/button_exti.rs | 2 +- examples/stm32l5/src/bin/rng.rs | 2 +- examples/stm32l5/src/bin/usb_ethernet.rs | 2 +- examples/stm32l5/src/bin/usb_hid_mouse.rs | 4 +- examples/stm32l5/src/bin/usb_serial.rs | 2 +- examples/stm32u5/Cargo.toml | 3 +- examples/stm32u5/src/bin/blinky.rs | 4 +- examples/stm32wb/Cargo.toml | 3 +- examples/stm32wb/src/bin/blinky.rs | 4 +- examples/stm32wb/src/bin/button_exti.rs | 2 +- examples/stm32wl/Cargo.toml | 3 +- examples/stm32wl/src/bin/blinky.rs | 4 +- examples/stm32wl/src/bin/button_exti.rs | 2 +- examples/stm32wl/src/bin/flash.rs | 2 +- examples/stm32wl/src/bin/lorawan.rs | 2 +- examples/stm32wl/src/bin/subghz.rs | 2 +- examples/wasm/Cargo.toml | 3 +- examples/wasm/src/lib.rs | 4 +- tests/rp/Cargo.toml | 3 +- tests/rp/src/bin/gpio.rs | 2 +- tests/rp/src/bin/gpio_async.rs | 4 +- tests/stm32/Cargo.toml | 3 +- tests/stm32/src/bin/gpio.rs | 2 +- tests/stm32/src/bin/spi.rs | 2 +- tests/stm32/src/bin/spi_dma.rs | 2 +- tests/stm32/src/bin/timer.rs | 4 +- tests/stm32/src/bin/usart.rs | 2 +- tests/stm32/src/bin/usart_dma.rs | 2 +- 254 files changed, 847 insertions(+), 552 deletions(-) create mode 100644 embassy-executor/README.md rename embassy-executor/src/{executor => }/arch/cortex_m.rs (100%) rename embassy-executor/src/{executor => }/arch/riscv32.rs (100%) rename embassy-executor/src/{executor => }/arch/std.rs (100%) rename embassy-executor/src/{executor => }/arch/wasm.rs (100%) rename embassy-executor/src/{executor => }/arch/xtensa.rs (100%) delete mode 100644 embassy-executor/src/executor/mod.rs rename embassy-executor/src/{executor => }/raw/mod.rs (93%) rename embassy-executor/src/{executor => }/raw/run_queue.rs (100%) rename embassy-executor/src/{executor => }/raw/timer_queue.rs (98%) rename embassy-executor/src/{executor => }/raw/util.rs (100%) rename embassy-executor/src/{executor => }/raw/waker.rs (95%) rename embassy-executor/src/{executor => }/spawner.rs (100%) create mode 100644 embassy-time/Cargo.toml rename {embassy-executor/src/time => embassy-time/src}/delay.rs (98%) rename {embassy-executor/src/time => embassy-time/src}/driver.rs (83%) rename {embassy-executor/src/time => embassy-time/src}/driver_std.rs (99%) rename {embassy-executor/src/time => embassy-time/src}/driver_wasm.rs (98%) rename {embassy-executor/src/time => embassy-time/src}/duration.rs (100%) create mode 100644 embassy-time/src/fmt.rs rename {embassy-executor/src/time => embassy-time/src}/instant.rs (100%) rename embassy-executor/src/time/mod.rs => embassy-time/src/lib.rs (75%) rename {embassy-executor/src/time => embassy-time/src}/timer.rs (88%) diff --git a/README.md b/README.md index eaa1e10a..4dbbb5f5 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Rust's async/await allows - embassy-nrf, for the Nordic Semiconductor nRF52, nRF53, nRF91 series. - **Time that Just Works** - -No more messing with hardware timers. embassy_executor::time provides Instant, Duration and Timer types that are globally available and never overflow. +No more messing with hardware timers. embassy_time provides Instant, Duration and Timer types that are globally available and never overflow. - **Real-time ready** - Tasks on the same async executor run cooperatively, but you can create multiple executors with different priorities, so that higher priority tasks preempt lower priority ones. See the example. @@ -44,8 +44,8 @@ The nrf-softdevice cr ```rust,ignore use defmt::info; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; +use embassy_time::{Duration, Timer}; use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull}; use embassy_nrf::Peripherals; diff --git a/ci.sh b/ci.sh index 6ec2410f..77a8a7e2 100755 --- a/ci.sh +++ b/ci.sh @@ -54,25 +54,25 @@ cargo batch \ --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits,log \ --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits \ --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f410tb,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f411ce,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f429zi,log,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h7b3ai,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32l476vg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wb15cc,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l072cz,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l041f6,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32l151cb-a,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f398ve,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32g0c1ve,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f217zg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,stm32l552ze,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32wl54jc-cm0p,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wle5ub,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f107vc,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f103re,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f100c4,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f410tb,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f411ce,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f429zi,log,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h7b3ai,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32l476vg,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wb15cc,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l072cz,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l041f6,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32l151cb-a,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f398ve,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32g0c1ve,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f217zg,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,stm32l552ze,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32wl54jc-cm0p,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wle5ub,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f107vc,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f103re,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f100c4,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ --- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \ --- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4 \ --- build --release --manifest-path docs/modules/ROOT/examples/basic/Cargo.toml --target thumbv7em-none-eabi \ diff --git a/ci_stable.sh b/ci_stable.sh index 7521827d..d388cfee 100755 --- a/ci_stable.sh +++ b/ci_stable.sh @@ -30,38 +30,38 @@ cargo batch \ --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,defmt \ --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,log \ --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g473cc,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585zi,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55vy,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wl55uc-cm4,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l4r9zi,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f303vc,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,embassy-executor/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,embassy-executor/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,embassy-executor/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,embassy-executor/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,embassy-executor/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,embassy-executor/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embassy-executor/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,embassy-executor/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g473cc,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585zi,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55vy,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wl55uc-cm4,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l4r9zi,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f303vc,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,embassy-time?/tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,embassy-time?/tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,embassy-time?/tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,embassy-time?/tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,embassy-time?/tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,embassy-time?/tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embassy-time?/tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,embassy-time?/tick-32768hz \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,embassy-time?/tick-32768hz,unstable-traits \ --- build --release --manifest-path examples/nrf/Cargo.toml --target thumbv7em-none-eabi --no-default-features --out-dir out/examples/nrf --bin raw_spawn \ --- build --release --manifest-path examples/stm32l0/Cargo.toml --target thumbv6m-none-eabi --no-default-features --out-dir out/examples/stm32l0 --bin raw_spawn \ diff --git a/docs/modules/ROOT/examples/basic/Cargo.toml b/docs/modules/ROOT/examples/basic/Cargo.toml index 59e1a437..ae124a87 100644 --- a/docs/modules/ROOT/examples/basic/Cargo.toml +++ b/docs/modules/ROOT/examples/basic/Cargo.toml @@ -6,6 +6,7 @@ version = "0.1.0" [dependencies] embassy-executor = { version = "0.1.0", path = "../../../../../embassy-executor", features = ["defmt", "nightly"] } +embassy-time = { version = "0.1.0", path = "../../../../../embassy-time", features = ["defmt", "nightly"] } embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "nightly"] } defmt = "0.3" diff --git a/docs/modules/ROOT/examples/basic/src/main.rs b/docs/modules/ROOT/examples/basic/src/main.rs index d680dd06..04170db5 100644 --- a/docs/modules/ROOT/examples/basic/src/main.rs +++ b/docs/modules/ROOT/examples/basic/src/main.rs @@ -3,10 +3,10 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::peripherals::P0_13; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; // global logger #[embassy_executor::task] diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs index 7d62b610..8df63224 100644 --- a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs +++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs @@ -2,7 +2,7 @@ #![no_main] #![feature(type_alias_impl_trait)] -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use {defmt_rtt as _, panic_probe as _}; diff --git a/embassy-cortex-m/src/executor.rs b/embassy-cortex-m/src/executor.rs index 4a3fa990..80c452f8 100644 --- a/embassy-cortex-m/src/executor.rs +++ b/embassy-cortex-m/src/executor.rs @@ -1,7 +1,7 @@ //! Executor specific to cortex-m devices. use core::marker::PhantomData; -pub use embassy_executor::executor::*; +pub use embassy_executor::*; use crate::interrupt::{Interrupt, InterruptExt}; @@ -60,11 +60,11 @@ impl InterruptExecutor { /// The executor keeps running in the background through the interrupt. /// /// This returns a [`SendSpawner`] you can use to spawn tasks on it. A [`SendSpawner`] - /// is returned instead of a [`Spawner`](embassy_executor::executor::Spawner) because the executor effectively runs in a + /// is returned instead of a [`Spawner`](embassy_executor::Spawner) because the executor effectively runs in a /// different "thread" (the interrupt), so spawning tasks on it is effectively /// sending them. /// - /// To obtain a [`Spawner`](embassy_executor::executor::Spawner) for this executor, use [`Spawner::for_current_executor()`](embassy_executor::executor::Spawner::for_current_executor()) from + /// To obtain a [`Spawner`](embassy_executor::Spawner) for this executor, use [`Spawner::for_current_executor()`](embassy_executor::Spawner::for_current_executor()) from /// a task running in it. /// /// This function requires `&'static mut self`. This means you have to store the diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml index 45d0d2de..25c3f0ab 100644 --- a/embassy-executor/Cargo.toml +++ b/embassy-executor/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-executor-v$VERSION/embassy-executor/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-executor/src/" -features = ["nightly", "defmt", "unstable-traits", "time", "time-tick-1mhz"] +features = ["nightly", "defmt", "unstable-traits"] flavors = [ { name = "std", target = "x86_64-unknown-linux-gnu", features = ["std"] }, { name = "wasm", target = "wasm32-unknown-unknown", features = ["wasm"] }, @@ -22,49 +22,25 @@ flavors = [ [features] default = [] -std = ["time", "time-tick-1mhz", "embassy-macros/std"] -wasm = ["wasm-bindgen", "js-sys", "embassy-macros/wasm", "wasm-timer", "time", "time-tick-1mhz"] +std = ["embassy-macros/std"] +wasm = ["dep:wasm-bindgen", "dep:js-sys", "embassy-macros/wasm"] # Enable nightly-only features -nightly = ["embedded-hal-async"] +nightly = [] -# Implement embedded-hal 1.0 alpha and embedded-hal-async traits. -# Implement embedded-hal-async traits if `nightly` is set as well. -unstable-traits = ["embedded-hal-1"] - -# Display a timestamp of the number of seconds since startup next to defmt log messages -# To use this you must have a time driver provided. -defmt-timestamp-uptime = ["defmt"] - -# Enable `embassy_executor::time` module. -# NOTE: This feature is only intended to be enabled by crates providing the time driver implementation. -# Enabling it directly without supplying a time driver will fail to link. -time = [] - -# Set the `embassy_executor::time` tick rate. -# NOTE: This feature is only intended to be enabled by crates providing the time driver implementation. -# If you're not writing your own driver, check the driver documentation to customize the tick rate. -# If you're writing a driver and your tick rate is not listed here, please add it and send a PR! -time-tick-32768hz = ["time"] -time-tick-1000hz = ["time"] -time-tick-1mhz = ["time"] -time-tick-16mhz = ["time"] +integrated-timers = ["dep:embassy-time"] [dependencies] defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } -embedded-hal-02 = { package = "embedded-hal", version = "0.2.6" } -embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true} -embedded-hal-async = { version = "0.1.0-alpha.1", optional = true} - futures-util = { version = "0.3.17", default-features = false } embassy-macros = { version = "0.1.0", path = "../embassy-macros"} +embassy-time = { version = "0.1.0", path = "../embassy-time", optional = true} atomic-polyfill = "1.0.1" critical-section = "1.1" cfg-if = "1.0.0" # WASM dependencies wasm-bindgen = { version = "0.2.76", features = ["nightly"], optional = true } -js-sys = { version = "0.3", optional = true } -wasm-timer = { version = "0.2.5", optional = true } \ No newline at end of file +js-sys = { version = "0.3", optional = true } \ No newline at end of file diff --git a/embassy-executor/README.md b/embassy-executor/README.md new file mode 100644 index 00000000..47d0cb8a --- /dev/null +++ b/embassy-executor/README.md @@ -0,0 +1,11 @@ +# embassy-executor + +An async/await executor designed for embedded usage. + +- No `alloc`, no heap needed. Task futures are statically allocated. +- No "fixed capacity" data structures, executor works with 1 or 1000 tasks without needing config/tuning. +- Integrated timer queue: sleeping is easy, just do `Timer::after(Duration::from_secs(1)).await;`. +- No busy-loop polling: CPU sleeps when there's no work to do, using interrupts or `WFE/SEV`. +- Efficient polling: a wake will only poll the woken task, not all of them. +- Fair: a task can't monopolize CPU time even if it's constantly being woken. All other tasks get a chance to run before a given task gets polled for the second time. +- Creating multiple executor instances is supported, to run tasks with multiple priority levels. This allows higher-priority tasks to preempt lower-priority tasks. diff --git a/embassy-executor/src/executor/arch/cortex_m.rs b/embassy-executor/src/arch/cortex_m.rs similarity index 100% rename from embassy-executor/src/executor/arch/cortex_m.rs rename to embassy-executor/src/arch/cortex_m.rs diff --git a/embassy-executor/src/executor/arch/riscv32.rs b/embassy-executor/src/arch/riscv32.rs similarity index 100% rename from embassy-executor/src/executor/arch/riscv32.rs rename to embassy-executor/src/arch/riscv32.rs diff --git a/embassy-executor/src/executor/arch/std.rs b/embassy-executor/src/arch/std.rs similarity index 100% rename from embassy-executor/src/executor/arch/std.rs rename to embassy-executor/src/arch/std.rs diff --git a/embassy-executor/src/executor/arch/wasm.rs b/embassy-executor/src/arch/wasm.rs similarity index 100% rename from embassy-executor/src/executor/arch/wasm.rs rename to embassy-executor/src/arch/wasm.rs diff --git a/embassy-executor/src/executor/arch/xtensa.rs b/embassy-executor/src/arch/xtensa.rs similarity index 100% rename from embassy-executor/src/executor/arch/xtensa.rs rename to embassy-executor/src/arch/xtensa.rs diff --git a/embassy-executor/src/executor/mod.rs b/embassy-executor/src/executor/mod.rs deleted file mode 100644 index 45d00c56..00000000 --- a/embassy-executor/src/executor/mod.rs +++ /dev/null @@ -1,44 +0,0 @@ -//! Async task executor. -//! -//! This module provides an async/await executor designed for embedded usage. -//! -//! - No `alloc`, no heap needed. Task futures are statically allocated. -//! - No "fixed capacity" data structures, executor works with 1 or 1000 tasks without needing config/tuning. -//! - Integrated timer queue: sleeping is easy, just do `Timer::after(Duration::from_secs(1)).await;`. -//! - No busy-loop polling: CPU sleeps when there's no work to do, using interrupts or `WFE/SEV`. -//! - Efficient polling: a wake will only poll the woken task, not all of them. -//! - Fair: a task can't monopolize CPU time even if it's constantly being woken. All other tasks get a chance to run before a given task gets polled for the second time. -//! - Creating multiple executor instances is supported, to run tasks with multiple priority levels. This allows higher-priority tasks to preempt lower-priority tasks. - -cfg_if::cfg_if! { - if #[cfg(cortex_m)] { - #[path="arch/cortex_m.rs"] - mod arch; - pub use arch::*; - } - else if #[cfg(target_arch="riscv32")] { - #[path="arch/riscv32.rs"] - mod arch; - pub use arch::*; - } - else if #[cfg(all(target_arch="xtensa", feature = "nightly"))] { - #[path="arch/xtensa.rs"] - mod arch; - pub use arch::*; - } - else if #[cfg(feature="wasm")] { - #[path="arch/wasm.rs"] - mod arch; - pub use arch::*; - } - else if #[cfg(feature="std")] { - #[path="arch/std.rs"] - mod arch; - pub use arch::*; - } -} - -pub mod raw; - -mod spawner; -pub use spawner::*; diff --git a/embassy-executor/src/fmt.rs b/embassy-executor/src/fmt.rs index f8bb0a03..06697081 100644 --- a/embassy-executor/src/fmt.rs +++ b/embassy-executor/src/fmt.rs @@ -195,9 +195,6 @@ macro_rules! unwrap { } } -#[cfg(feature = "defmt-timestamp-uptime")] -defmt::timestamp! {"{=u64:us}", crate::time::Instant::now().as_micros() } - #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct NoneError; diff --git a/embassy-executor/src/lib.rs b/embassy-executor/src/lib.rs index 69e4aeb4..9328a737 100644 --- a/embassy-executor/src/lib.rs +++ b/embassy-executor/src/lib.rs @@ -1,22 +1,44 @@ #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] -#![cfg_attr(feature = "nightly", feature(generic_associated_types, type_alias_impl_trait))] #![cfg_attr(all(feature = "nightly", target_arch = "xtensa"), feature(asm_experimental_arch))] #![allow(clippy::new_without_default)] -#![doc = include_str!("../../README.md")] +#![doc = include_str!("../README.md")] #![warn(missing_docs)] // This mod MUST go first, so that the others see its macros. pub(crate) mod fmt; -pub mod executor; -#[cfg(feature = "time")] -pub mod time; - #[cfg(feature = "nightly")] pub use embassy_macros::{main, task}; -#[doc(hidden)] -/// Implementation details for embassy macros. DO NOT USE. -pub mod export { - pub use atomic_polyfill as atomic; +cfg_if::cfg_if! { + if #[cfg(cortex_m)] { + #[path="arch/cortex_m.rs"] + mod arch; + pub use arch::*; + } + else if #[cfg(target_arch="riscv32")] { + #[path="arch/riscv32.rs"] + mod arch; + pub use arch::*; + } + else if #[cfg(all(target_arch="xtensa", feature = "nightly"))] { + #[path="arch/xtensa.rs"] + mod arch; + pub use arch::*; + } + else if #[cfg(feature="wasm")] { + #[path="arch/wasm.rs"] + mod arch; + pub use arch::*; + } + else if #[cfg(feature="std")] { + #[path="arch/std.rs"] + mod arch; + pub use arch::*; + } } + +pub mod raw; + +mod spawner; +pub use spawner::*; diff --git a/embassy-executor/src/executor/raw/mod.rs b/embassy-executor/src/raw/mod.rs similarity index 93% rename from embassy-executor/src/executor/raw/mod.rs rename to embassy-executor/src/raw/mod.rs index fb4cc628..afe67dec 100644 --- a/embassy-executor/src/executor/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs @@ -8,7 +8,7 @@ //! executor wrappers in [`executor`](crate::executor) and the [`embassy_executor::task`](embassy_macros::task) macro, which are fully safe. mod run_queue; -#[cfg(feature = "time")] +#[cfg(feature = "integrated-timers")] mod timer_queue; pub(crate) mod util; mod waker; @@ -22,22 +22,22 @@ use core::{mem, ptr}; use atomic_polyfill::{AtomicU32, Ordering}; use critical_section::CriticalSection; +#[cfg(feature = "integrated-timers")] +use embassy_time::driver::{self, AlarmHandle}; +#[cfg(feature = "integrated-timers")] +use embassy_time::Instant; use self::run_queue::{RunQueue, RunQueueItem}; use self::util::UninitCell; pub use self::waker::task_from_waker; use super::SpawnToken; -#[cfg(feature = "time")] -use crate::time::driver::{self, AlarmHandle}; -#[cfg(feature = "time")] -use crate::time::Instant; /// Task is spawned (has a future) pub(crate) const STATE_SPAWNED: u32 = 1 << 0; /// Task is in the executor run queue pub(crate) const STATE_RUN_QUEUED: u32 = 1 << 1; /// Task is in the executor timer queue -#[cfg(feature = "time")] +#[cfg(feature = "integrated-timers")] pub(crate) const STATE_TIMER_QUEUED: u32 = 1 << 2; /// Raw task header for use in task pointers. @@ -50,9 +50,9 @@ pub struct TaskHeader { pub(crate) executor: Cell<*const Executor>, // Valid if state != 0 pub(crate) poll_fn: UninitCell)>, // Valid if STATE_SPAWNED - #[cfg(feature = "time")] + #[cfg(feature = "integrated-timers")] pub(crate) expires_at: Cell, - #[cfg(feature = "time")] + #[cfg(feature = "integrated-timers")] pub(crate) timer_queue_item: timer_queue::TimerQueueItem, } @@ -64,9 +64,9 @@ impl TaskHeader { executor: Cell::new(ptr::null()), poll_fn: UninitCell::uninit(), - #[cfg(feature = "time")] + #[cfg(feature = "integrated-timers")] expires_at: Cell::new(Instant::from_ticks(0)), - #[cfg(feature = "time")] + #[cfg(feature = "integrated-timers")] timer_queue_item: timer_queue::TimerQueueItem::new(), } } @@ -267,9 +267,9 @@ pub struct Executor { signal_fn: fn(*mut ()), signal_ctx: *mut (), - #[cfg(feature = "time")] + #[cfg(feature = "integrated-timers")] pub(crate) timer_queue: timer_queue::TimerQueue, - #[cfg(feature = "time")] + #[cfg(feature = "integrated-timers")] alarm: AlarmHandle, } @@ -281,9 +281,9 @@ impl Executor { /// /// See [`Executor`] docs for details on `signal_fn`. pub fn new(signal_fn: fn(*mut ()), signal_ctx: *mut ()) -> Self { - #[cfg(feature = "time")] + #[cfg(feature = "integrated-timers")] let alarm = unsafe { unwrap!(driver::allocate_alarm()) }; - #[cfg(feature = "time")] + #[cfg(feature = "integrated-timers")] driver::set_alarm_callback(alarm, signal_fn, signal_ctx); Self { @@ -291,9 +291,9 @@ impl Executor { signal_fn, signal_ctx, - #[cfg(feature = "time")] + #[cfg(feature = "integrated-timers")] timer_queue: timer_queue::TimerQueue::new(), - #[cfg(feature = "time")] + #[cfg(feature = "integrated-timers")] alarm, } } @@ -346,13 +346,13 @@ impl Executor { /// somehow schedule for `poll()` to be called later, at a time you know for sure there's /// no `poll()` already running. pub unsafe fn poll(&'static self) { - #[cfg(feature = "time")] + #[cfg(feature = "integrated-timers")] self.timer_queue.dequeue_expired(Instant::now(), |task| wake_task(task)); self.run_queue.dequeue_all(|p| { let task = p.as_ref(); - #[cfg(feature = "time")] + #[cfg(feature = "integrated-timers")] task.expires_at.set(Instant::MAX); let state = task.state.fetch_and(!STATE_RUN_QUEUED, Ordering::AcqRel); @@ -369,11 +369,11 @@ impl Executor { task.poll_fn.read()(p as _); // Enqueue or update into timer_queue - #[cfg(feature = "time")] + #[cfg(feature = "integrated-timers")] self.timer_queue.update(p); }); - #[cfg(feature = "time")] + #[cfg(feature = "integrated-timers")] { // If this is already in the past, set_alarm will immediately trigger the alarm. // This will cause `signal_fn` to be called, which will cause `poll()` to be called again, @@ -418,8 +418,9 @@ pub unsafe fn wake_task(task: NonNull) { }) } -#[cfg(feature = "time")] -pub(crate) unsafe fn register_timer(at: Instant, waker: &core::task::Waker) { +#[cfg(feature = "integrated-timers")] +#[no_mangle] +unsafe fn _embassy_time_schedule_wake(at: Instant, waker: &core::task::Waker) { let task = waker::task_from_waker(waker); let task = task.as_ref(); let expires_at = task.expires_at.get(); diff --git a/embassy-executor/src/executor/raw/run_queue.rs b/embassy-executor/src/raw/run_queue.rs similarity index 100% rename from embassy-executor/src/executor/raw/run_queue.rs rename to embassy-executor/src/raw/run_queue.rs diff --git a/embassy-executor/src/executor/raw/timer_queue.rs b/embassy-executor/src/raw/timer_queue.rs similarity index 98% rename from embassy-executor/src/executor/raw/timer_queue.rs rename to embassy-executor/src/raw/timer_queue.rs index 62fcfc53..24c31892 100644 --- a/embassy-executor/src/executor/raw/timer_queue.rs +++ b/embassy-executor/src/raw/timer_queue.rs @@ -4,9 +4,9 @@ use core::ptr; use core::ptr::NonNull; use atomic_polyfill::Ordering; +use embassy_time::Instant; use super::{TaskHeader, STATE_TIMER_QUEUED}; -use crate::time::Instant; pub(crate) struct TimerQueueItem { next: Cell<*mut TaskHeader>, diff --git a/embassy-executor/src/executor/raw/util.rs b/embassy-executor/src/raw/util.rs similarity index 100% rename from embassy-executor/src/executor/raw/util.rs rename to embassy-executor/src/raw/util.rs diff --git a/embassy-executor/src/executor/raw/waker.rs b/embassy-executor/src/raw/waker.rs similarity index 95% rename from embassy-executor/src/executor/raw/waker.rs rename to embassy-executor/src/raw/waker.rs index 6b9c03a6..5765259f 100644 --- a/embassy-executor/src/executor/raw/waker.rs +++ b/embassy-executor/src/raw/waker.rs @@ -40,7 +40,7 @@ pub fn task_from_waker(waker: &Waker) -> NonNull { // TODO use waker_getters when stable. https://github.com/rust-lang/rust/issues/96992 let hack: &WakerHack = unsafe { mem::transmute(waker) }; if hack.vtable != &VTABLE { - panic!("Found waker not created by the Embassy executor. `embassy_executor::time::Timer` only works with the Embassy executor.") + panic!("Found waker not created by the Embassy executor. `embassy_time::Timer` only works with the Embassy executor.") } // safety: we never create a waker with a null data pointer. diff --git a/embassy-executor/src/executor/spawner.rs b/embassy-executor/src/spawner.rs similarity index 100% rename from embassy-executor/src/executor/spawner.rs rename to embassy-executor/src/spawner.rs diff --git a/embassy-lora/Cargo.toml b/embassy-lora/Cargo.toml index 6c1b01e6..c7435ab3 100644 --- a/embassy-lora/Cargo.toml +++ b/embassy-lora/Cargo.toml @@ -8,8 +8,8 @@ src_base = "https://github.com/embassy-rs/embassy/blob/embassy-lora-v$VERSION/em src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-lora/src/" features = ["time", "defmt"] flavors = [ - { name = "sx127x", target = "thumbv7em-none-eabihf", features = ["sx127x", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy-executor/time-tick-32768hz"] }, - { name = "stm32wl", target = "thumbv7em-none-eabihf", features = ["stm32wl", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy-executor/time-tick-32768hz"] }, + { name = "sx127x", target = "thumbv7em-none-eabihf", features = ["sx127x", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy-time/tick-32768hz"] }, + { name = "stm32wl", target = "thumbv7em-none-eabihf", features = ["stm32wl", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy-time/tick-32768hz"] }, ] [lib] @@ -24,7 +24,7 @@ time = [] defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } -embassy-executor = { version = "0.1.0", path = "../embassy-executor" } +embassy-time = { version = "0.1.0", path = "../embassy-time" } embassy-util = { version = "0.1.0", path = "../embassy-util" } embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false, optional = true } embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } diff --git a/embassy-lora/src/lib.rs b/embassy-lora/src/lib.rs index 29ea4586..1b2dd45c 100644 --- a/embassy-lora/src/lib.rs +++ b/embassy-lora/src/lib.rs @@ -18,6 +18,6 @@ pub struct LoraTimer; impl lorawan_device::async_device::radio::Timer for LoraTimer { type DelayFuture<'m> = impl core::future::Future + 'm; fn delay_ms<'m>(&'m mut self, millis: u64) -> Self::DelayFuture<'m> { - embassy_executor::time::Timer::after(embassy_executor::time::Duration::from_millis(millis)) + embassy_time::Timer::after(embassy_time::Duration::from_millis(millis)) } } diff --git a/embassy-lora/src/sx127x/sx127x_lora/mod.rs b/embassy-lora/src/sx127x/sx127x_lora/mod.rs index b3636d09..aacc9da2 100644 --- a/embassy-lora/src/sx127x/sx127x_lora/mod.rs +++ b/embassy-lora/src/sx127x/sx127x_lora/mod.rs @@ -6,7 +6,7 @@ #![allow(dead_code)] use bit_field::BitField; -use embassy_executor::time::{Duration, Timer}; +use embassy_time::{Duration, Timer}; use embedded_hal::digital::v2::OutputPin; use embedded_hal_async::spi::SpiBus; diff --git a/embassy-macros/src/macros/main.rs b/embassy-macros/src/macros/main.rs index a0cb0f0b..52987d7d 100644 --- a/embassy-macros/src/macros/main.rs +++ b/embassy-macros/src/macros/main.rs @@ -34,8 +34,8 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result Result<(), wasm_bindgen::JsValue> { - static EXECUTOR: ::embassy_util::Forever<::embassy_executor::executor::Executor> = ::embassy_util::Forever::new(); - let executor = EXECUTOR.put(::embassy_executor::executor::Executor::new()); + static EXECUTOR: ::embassy_util::Forever<::embassy_executor::Executor> = ::embassy_util::Forever::new(); + let executor = EXECUTOR.put(::embassy_executor::Executor::new()); executor.start(|spawner| { spawner.spawn(__embassy_main(spawner)).unwrap(); @@ -48,7 +48,7 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result ! { - let mut executor = ::embassy_executor::executor::Executor::new(); + let mut executor = ::embassy_executor::Executor::new(); let executor = unsafe { __make_static(&mut executor) }; executor.run(|spawner| { @@ -61,7 +61,7 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result ! { - let mut executor = ::embassy_executor::executor::Executor::new(); + let mut executor = ::embassy_executor::Executor::new(); let executor = unsafe { __make_static(&mut executor) }; executor.run(|spawner| { diff --git a/embassy-macros/src/macros/task.rs b/embassy-macros/src/macros/task.rs index 414e5cb0..573776f8 100644 --- a/embassy-macros/src/macros/task.rs +++ b/embassy-macros/src/macros/task.rs @@ -64,9 +64,9 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result ::embassy_executor::executor::SpawnToken { + #visibility fn #task_ident(#fargs) -> ::embassy_executor::SpawnToken { type Fut = impl ::core::future::Future + 'static; - static POOL: ::embassy_executor::executor::raw::TaskPool = ::embassy_executor::executor::raw::TaskPool::new(); + static POOL: ::embassy_executor::raw::TaskPool = ::embassy_executor::raw::TaskPool::new(); unsafe { POOL._spawn_async_fn(move || #task_inner_ident(#(#arg_names,)*)) } } }; diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index 11e39a87..1ce4479a 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-net-v$VERSION/embassy-net/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-net/src/" -features = [ "pool-4", "defmt", "tcp", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "embassy-executor/time", "embassy-executor/time-tick-1mhz"] +features = [ "pool-4", "defmt", "tcp", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "embassy-time/tick-1mhz"] target = "thumbv7em-none-eabi" [features] @@ -37,16 +37,16 @@ unstable-traits = [] defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } -embassy-executor = { version = "0.1.0", path = "../embassy-executor" } -embassy-util = { version = "0.1.0", path = "../embassy-util" } -embedded-io = { version = "0.3.0", features = [ "async" ] } +embassy-time = { version = "0.1.0", path = "../embassy-time" } +embassy-util = { version = "0.1.0", path = "../embassy-util" } +embedded-io = { version = "0.3.0", features = [ "async" ] } -managed = { version = "0.8.0", default-features = false, features = [ "map" ] } -heapless = { version = "0.7.5", default-features = false } -as-slice = "0.2.1" -generic-array = { version = "0.14.4", default-features = false } -stable_deref_trait = { version = "1.2.0", default-features = false } -futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] } +managed = { version = "0.8.0", default-features = false, features = [ "map" ] } +heapless = { version = "0.7.5", default-features = false } +as-slice = "0.2.1" +generic-array = { version = "0.14.4", default-features = false } +stable_deref_trait = { version = "1.2.0", default-features = false } +futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] } atomic-pool = "0.2.1" atomic-polyfill = "0.1.5" embedded-nal-async = "0.2.0" diff --git a/embassy-net/src/stack.rs b/embassy-net/src/stack.rs index 06bb732f..4b6a7ae2 100644 --- a/embassy-net/src/stack.rs +++ b/embassy-net/src/stack.rs @@ -2,7 +2,7 @@ use core::cell::UnsafeCell; use core::future::Future; use core::task::{Context, Poll}; -use embassy_executor::time::{Instant, Timer}; +use embassy_time::{Instant, Timer}; use embassy_util::waitqueue::WakerRegistration; use futures::future::poll_fn; use futures::pin_mut; diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 9d6690ac..0ef7f5bb 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -16,7 +16,7 @@ flavors = [ [features] -time = ["embassy-executor/time"] +time = ["dep:embassy-time"] defmt = ["dep:defmt", "embassy-executor/defmt", "embassy-util/defmt", "embassy-usb?/defmt", "embedded-io?/defmt", "embassy-embedded-hal/defmt"] @@ -57,7 +57,7 @@ _nrf5340-net = ["_nrf5340", "nrf5340-net-pac"] _nrf5340 = ["_gpio-p1", "_dppi"] _nrf9160 = ["nrf9160-pac", "_dppi"] -_time-driver = ["embassy-executor/time-tick-32768hz", "time"] +_time-driver = ["dep:embassy-time", "embassy-time?/tick-32768hz"] _ppi = [] _dppi = [] @@ -65,6 +65,7 @@ _gpio-p1 = [] [dependencies] embassy-executor = { version = "0.1.0", path = "../embassy-executor", optional = true } +embassy-time = { version = "0.1.0", path = "../embassy-time", 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-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } diff --git a/embassy-nrf/src/time_driver.rs b/embassy-nrf/src/time_driver.rs index 05fa0aea..b961d65a 100644 --- a/embassy-nrf/src/time_driver.rs +++ b/embassy-nrf/src/time_driver.rs @@ -3,7 +3,7 @@ use core::sync::atomic::{compiler_fence, AtomicU32, AtomicU8, Ordering}; use core::{mem, ptr}; use critical_section::CriticalSection; -use embassy_executor::time::driver::{AlarmHandle, Driver}; +use embassy_time::driver::{AlarmHandle, Driver}; use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex; use embassy_util::blocking_mutex::CriticalSectionMutex as Mutex; @@ -119,7 +119,7 @@ struct RtcDriver { } const ALARM_STATE_NEW: AlarmState = AlarmState::new(); -embassy_executor::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver { +embassy_time::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver { period: AtomicU32::new(0), alarm_count: AtomicU8::new(0), alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [ALARM_STATE_NEW; ALARM_COUNT]), diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs index 494abe0c..9587d1f4 100644 --- a/embassy-nrf/src/twim.rs +++ b/embassy-nrf/src/twim.rs @@ -12,9 +12,9 @@ use core::sync::atomic::Ordering::SeqCst; use core::task::Poll; use embassy_embedded_hal::SetConfig; -#[cfg(feature = "time")] -use embassy_executor::time::{Duration, Instant}; use embassy_hal_common::{into_ref, PeripheralRef}; +#[cfg(feature = "time")] +use embassy_time::{Duration, Instant}; use embassy_util::waitqueue::AtomicWaker; use futures::future::poll_fn; diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index bf4919d5..aaf4ede1 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -28,7 +28,8 @@ unstable-traits = ["embedded-hal-1"] [dependencies] embassy-util = { version = "0.1.0", path = "../embassy-util" } -embassy-executor = { version = "0.1.0", path = "../embassy-executor", features = [ "time-tick-1mhz" ] } +embassy-executor = { version = "0.1.0", path = "../embassy-executor" } +embassy-time = { version = "0.1.0", path = "../embassy-time", features = [ "tick-1mhz" ] } 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" } diff --git a/embassy-rp/src/timer.rs b/embassy-rp/src/timer.rs index 142fd410..5bc1f66c 100644 --- a/embassy-rp/src/timer.rs +++ b/embassy-rp/src/timer.rs @@ -2,7 +2,7 @@ use core::cell::Cell; use atomic_polyfill::{AtomicU8, Ordering}; use critical_section::CriticalSection; -use embassy_executor::time::driver::{AlarmHandle, Driver}; +use embassy_time::driver::{AlarmHandle, Driver}; use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex; use embassy_util::blocking_mutex::Mutex; @@ -26,7 +26,7 @@ struct TimerDriver { next_alarm: AtomicU8, } -embassy_executor::time_driver_impl!(static DRIVER: TimerDriver = TimerDriver{ +embassy_time::time_driver_impl!(static DRIVER: TimerDriver = TimerDriver{ alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [DUMMY_ALARM; ALARM_COUNT]), next_alarm: AtomicU8::new(0), }); diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index dea68e44..c47ea0bc 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -10,7 +10,7 @@ src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-stm32 # TODO: sdmmc # TODO: net # TODO: subghz -features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "embassy-executor/time-tick-32768hz"] +features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "embassy-time/tick-32768hz"] flavors = [ { regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" }, { regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" }, @@ -33,6 +33,7 @@ flavors = [ [dependencies] embassy-util = { version = "0.1.0", path = "../embassy-util" } embassy-executor = { version = "0.1.0", path = "../embassy-executor" } +embassy-time = { version = "0.1.0", path = "../embassy-time", optional = true } embassy-cortex-m = { version = "0.1.0", path = "../embassy-cortex-m", features = ["prio-bits-4"]} embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } @@ -80,7 +81,7 @@ exti = [] # Features starting with `_` are for internal use only. They're not intended # to be enabled by other crates, and are not covered by semver guarantees. -_time-driver = ["embassy-executor/time"] +_time-driver = ["dep:embassy-time"] time-driver-any = ["_time-driver"] time-driver-tim2 = ["_time-driver"] time-driver-tim3 = ["_time-driver"] diff --git a/embassy-stm32/src/subghz/mod.rs b/embassy-stm32/src/subghz/mod.rs index 4e53efed..a74f9a6d 100644 --- a/embassy-stm32/src/subghz/mod.rs +++ b/embassy-stm32/src/subghz/mod.rs @@ -504,7 +504,7 @@ impl<'d> SubGhz<'d, NoDma, NoDma> { /// /// sg.set_standby(StandbyClk::Rc)?; /// unsafe { sg.set_sleep(SleepCfg::default())? }; - /// embassy_executor::time::Timer::after(embassy_executor::time::Duration::from_micros(500)).await; + /// embassy_time::Timer::after(embassy_time::Duration::from_micros(500)).await; /// unsafe { wakeup() }; /// # Ok::<(), embassy_stm32::subghz::Error>(()) /// ``` diff --git a/embassy-stm32/src/subghz/timeout.rs b/embassy-stm32/src/subghz/timeout.rs index b8d6ad8f..28b3b0c2 100644 --- a/embassy-stm32/src/subghz/timeout.rs +++ b/embassy-stm32/src/subghz/timeout.rs @@ -439,9 +439,9 @@ impl From for [u8; 3] { } } -impl From for embassy_executor::time::Duration { +impl From for embassy_time::Duration { fn from(to: Timeout) -> Self { - embassy_executor::time::Duration::from_micros(to.as_micros().into()) + embassy_time::Duration::from_micros(to.as_micros().into()) } } diff --git a/embassy-stm32/src/subghz/tx_params.rs b/embassy-stm32/src/subghz/tx_params.rs index a72c060f..cede6f2c 100644 --- a/embassy-stm32/src/subghz/tx_params.rs +++ b/embassy-stm32/src/subghz/tx_params.rs @@ -44,17 +44,17 @@ impl From for core::time::Duration { } } -impl From for embassy_executor::time::Duration { +impl From for embassy_time::Duration { fn from(rt: RampTime) -> Self { match rt { - RampTime::Micros10 => embassy_executor::time::Duration::from_micros(10), - RampTime::Micros20 => embassy_executor::time::Duration::from_micros(20), - RampTime::Micros40 => embassy_executor::time::Duration::from_micros(40), - RampTime::Micros80 => embassy_executor::time::Duration::from_micros(80), - RampTime::Micros200 => embassy_executor::time::Duration::from_micros(200), - RampTime::Micros800 => embassy_executor::time::Duration::from_micros(800), - RampTime::Micros1700 => embassy_executor::time::Duration::from_micros(1700), - RampTime::Micros3400 => embassy_executor::time::Duration::from_micros(3400), + RampTime::Micros10 => embassy_time::Duration::from_micros(10), + RampTime::Micros20 => embassy_time::Duration::from_micros(20), + RampTime::Micros40 => embassy_time::Duration::from_micros(40), + RampTime::Micros80 => embassy_time::Duration::from_micros(80), + RampTime::Micros200 => embassy_time::Duration::from_micros(200), + RampTime::Micros800 => embassy_time::Duration::from_micros(800), + RampTime::Micros1700 => embassy_time::Duration::from_micros(1700), + RampTime::Micros3400 => embassy_time::Duration::from_micros(3400), } } } diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs index 6cea43f1..7f472316 100644 --- a/embassy-stm32/src/time_driver.rs +++ b/embassy-stm32/src/time_driver.rs @@ -4,8 +4,8 @@ use core::sync::atomic::{compiler_fence, Ordering}; use core::{mem, ptr}; use atomic_polyfill::{AtomicU32, AtomicU8}; -use embassy_executor::time::driver::{AlarmHandle, Driver}; -use embassy_executor::time::TICKS_PER_SECOND; +use embassy_time::driver::{AlarmHandle, Driver}; +use embassy_time::TICKS_PER_SECOND; use embassy_util::blocking_mutex::raw::CriticalSectionRawMutex; use embassy_util::blocking_mutex::Mutex; use stm32_metapac::timer::regs; @@ -133,7 +133,7 @@ struct RtcDriver { const ALARM_STATE_NEW: AlarmState = AlarmState::new(); -embassy_executor::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver { +embassy_time::time_driver_impl!(static DRIVER: RtcDriver = RtcDriver { period: AtomicU32::new(0), alarm_count: AtomicU8::new(0), alarms: Mutex::const_new(CriticalSectionRawMutex::new(), [ALARM_STATE_NEW; ALARM_COUNT]), diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs index 764b2146..3861e42d 100644 --- a/embassy-stm32/src/usb/usb.rs +++ b/embassy-stm32/src/usb/usb.rs @@ -5,8 +5,8 @@ use core::sync::atomic::Ordering; use core::task::Poll; use atomic_polyfill::{AtomicBool, AtomicU8}; -use embassy_executor::time::{block_for, Duration}; use embassy_hal_common::into_ref; +use embassy_time::{block_for, Duration}; use embassy_usb::driver::{self, EndpointAllocError, EndpointError, Event, Unsupported}; use embassy_usb::types::{EndpointAddress, EndpointInfo, EndpointType, UsbDirection}; use embassy_util::waitqueue::AtomicWaker; diff --git a/embassy-time/Cargo.toml b/embassy-time/Cargo.toml new file mode 100644 index 00000000..161c101f --- /dev/null +++ b/embassy-time/Cargo.toml @@ -0,0 +1,54 @@ +[package] +name = "embassy-time" +version = "0.1.0" +edition = "2021" + + +[package.metadata.embassy_docs] +src_base = "https://github.com/embassy-rs/embassy/blob/embassy-time-v$VERSION/embassy-time/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-time/src/" +features = ["nightly", "defmt", "unstable-traits", "std"] +target = "x86_64-unknown-linux-gnu" + +[features] +std = ["tick-1mhz"] +wasm = ["dep:wasm-bindgen", "dep:js-sys", "dep:wasm-timer", "tick-1mhz"] + +# Enable nightly-only features +nightly = ["embedded-hal-async"] + +# Implement embedded-hal 1.0 alpha and embedded-hal-async traits. +# Implement embedded-hal-async traits if `nightly` is set as well. +unstable-traits = ["embedded-hal-1"] + +# Display a timestamp of the number of seconds since startup next to defmt log messages +# To use this you must have a time driver provided. +defmt-timestamp-uptime = ["defmt"] + +# Set the `embassy_time` tick rate. +# NOTE: This feature is only intended to be enabled by crates providing the time driver implementation. +# If you're not writing your own driver, check the driver documentation to customize the tick rate. +# If you're writing a driver and your tick rate is not listed here, please add it and send a PR! +tick-32768hz = [] +tick-1000hz = [] +tick-1mhz = [] +tick-16mhz = [] + +[dependencies] +defmt = { version = "0.3", optional = true } +log = { version = "0.4.14", optional = true } + +embedded-hal-02 = { package = "embedded-hal", version = "0.2.6" } +embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true} +embedded-hal-async = { version = "0.1.0-alpha.1", optional = true} + +futures-util = { version = "0.3.17", default-features = false } +embassy-macros = { version = "0.1.0", path = "../embassy-macros"} +atomic-polyfill = "1.0.1" +critical-section = "1.1" +cfg-if = "1.0.0" + +# WASM dependencies +wasm-bindgen = { version = "0.2.76", features = ["nightly"], optional = true } +js-sys = { version = "0.3", optional = true } +wasm-timer = { version = "0.2.5", optional = true } \ No newline at end of file diff --git a/embassy-executor/src/time/delay.rs b/embassy-time/src/delay.rs similarity index 98% rename from embassy-executor/src/time/delay.rs rename to embassy-time/src/delay.rs index d76ed32e..d010fff9 100644 --- a/embassy-executor/src/time/delay.rs +++ b/embassy-time/src/delay.rs @@ -33,7 +33,7 @@ mod eh1 { cfg_if::cfg_if! { if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] { - use crate::time::Timer; + use crate::Timer; use core::future::Future; use futures_util::FutureExt; diff --git a/embassy-executor/src/time/driver.rs b/embassy-time/src/driver.rs similarity index 83% rename from embassy-executor/src/time/driver.rs rename to embassy-time/src/driver.rs index 48e2f1c7..216b2740 100644 --- a/embassy-executor/src/time/driver.rs +++ b/embassy-time/src/driver.rs @@ -1,17 +1,17 @@ //! Time driver interface //! -//! This module defines the interface a driver needs to implement to power the `embassy_executor::time` module. +//! This module defines the interface a driver needs to implement to power the `embassy_time` module. //! //! # Implementing a driver //! //! - Define a struct `MyDriver` //! - Implement [`Driver`] for it //! - Register it as the global driver with [`time_driver_impl`]. -//! - Enable the Cargo features `embassy-executor/time` and one of `embassy-executor/time-tick-*` corresponding to the +//! - Enable the Cargo features `embassy-executor/time` and one of `embassy-time/tick-*` corresponding to the //! tick rate of your driver. //! //! If you wish to make the tick rate configurable by the end user, you should do so by exposing your own -//! Cargo features and having each enable the corresponding `embassy-executor/time-tick-*`. +//! Cargo features and having each enable the corresponding `embassy-time/tick-*`. //! //! # Linkage details //! @@ -34,10 +34,10 @@ //! # Example //! //! ``` -//! use embassy_executor::time::driver::{Driver, AlarmHandle}; +//! use embassy_time::driver::{Driver, AlarmHandle}; //! //! struct MyDriver{}; // not public! -//! embassy_executor::time_driver_impl!(static DRIVER: MyDriver = MyDriver{}); +//! embassy_time::time_driver_impl!(static DRIVER: MyDriver = MyDriver{}); //! //! impl Driver for MyDriver { //! fn now(&self) -> u64 { @@ -121,17 +121,25 @@ extern "Rust" { fn _embassy_time_set_alarm(alarm: AlarmHandle, timestamp: u64); } -pub(crate) fn now() -> u64 { +/// See [`Driver::now`] +pub fn now() -> u64 { unsafe { _embassy_time_now() } } + +/// See [`Driver::allocate_alarm`] +/// /// Safety: it is UB to make the alarm fire before setting a callback. -pub(crate) unsafe fn allocate_alarm() -> Option { +pub unsafe fn allocate_alarm() -> Option { _embassy_time_allocate_alarm() } -pub(crate) fn set_alarm_callback(alarm: AlarmHandle, callback: fn(*mut ()), ctx: *mut ()) { + +/// See [`Driver::set_alarm_callback`] +pub fn set_alarm_callback(alarm: AlarmHandle, callback: fn(*mut ()), ctx: *mut ()) { unsafe { _embassy_time_set_alarm_callback(alarm, callback, ctx) } } -pub(crate) fn set_alarm(alarm: AlarmHandle, timestamp: u64) { + +/// See [`Driver::set_alarm`] +pub fn set_alarm(alarm: AlarmHandle, timestamp: u64) { unsafe { _embassy_time_set_alarm(alarm, timestamp) } } @@ -145,26 +153,22 @@ macro_rules! time_driver_impl { #[no_mangle] fn _embassy_time_now() -> u64 { - <$t as $crate::time::driver::Driver>::now(&$name) + <$t as $crate::driver::Driver>::now(&$name) } #[no_mangle] - unsafe fn _embassy_time_allocate_alarm() -> Option<$crate::time::driver::AlarmHandle> { - <$t as $crate::time::driver::Driver>::allocate_alarm(&$name) + unsafe fn _embassy_time_allocate_alarm() -> Option<$crate::driver::AlarmHandle> { + <$t as $crate::driver::Driver>::allocate_alarm(&$name) } #[no_mangle] - fn _embassy_time_set_alarm_callback( - alarm: $crate::time::driver::AlarmHandle, - callback: fn(*mut ()), - ctx: *mut (), - ) { - <$t as $crate::time::driver::Driver>::set_alarm_callback(&$name, alarm, callback, ctx) + fn _embassy_time_set_alarm_callback(alarm: $crate::driver::AlarmHandle, callback: fn(*mut ()), ctx: *mut ()) { + <$t as $crate::driver::Driver>::set_alarm_callback(&$name, alarm, callback, ctx) } #[no_mangle] - fn _embassy_time_set_alarm(alarm: $crate::time::driver::AlarmHandle, timestamp: u64) { - <$t as $crate::time::driver::Driver>::set_alarm(&$name, alarm, timestamp) + fn _embassy_time_set_alarm(alarm: $crate::driver::AlarmHandle, timestamp: u64) { + <$t as $crate::driver::Driver>::set_alarm(&$name, alarm, timestamp) } }; } diff --git a/embassy-executor/src/time/driver_std.rs b/embassy-time/src/driver_std.rs similarity index 99% rename from embassy-executor/src/time/driver_std.rs rename to embassy-time/src/driver_std.rs index cb66f7c1..2ddb2e60 100644 --- a/embassy-executor/src/time/driver_std.rs +++ b/embassy-time/src/driver_std.rs @@ -6,7 +6,7 @@ use std::{mem, ptr, thread}; use atomic_polyfill::{AtomicU8, Ordering}; -use crate::time::driver::{AlarmHandle, Driver}; +use crate::driver::{AlarmHandle, Driver}; const ALARM_COUNT: usize = 4; diff --git a/embassy-executor/src/time/driver_wasm.rs b/embassy-time/src/driver_wasm.rs similarity index 98% rename from embassy-executor/src/time/driver_wasm.rs rename to embassy-time/src/driver_wasm.rs index 5f585a19..e4497e6a 100644 --- a/embassy-executor/src/time/driver_wasm.rs +++ b/embassy-time/src/driver_wasm.rs @@ -7,7 +7,7 @@ use atomic_polyfill::{AtomicU8, Ordering}; use wasm_bindgen::prelude::*; use wasm_timer::Instant as StdInstant; -use crate::time::driver::{AlarmHandle, Driver}; +use crate::driver::{AlarmHandle, Driver}; const ALARM_COUNT: usize = 4; diff --git a/embassy-executor/src/time/duration.rs b/embassy-time/src/duration.rs similarity index 100% rename from embassy-executor/src/time/duration.rs rename to embassy-time/src/duration.rs diff --git a/embassy-time/src/fmt.rs b/embassy-time/src/fmt.rs new file mode 100644 index 00000000..06697081 --- /dev/null +++ b/embassy-time/src/fmt.rs @@ -0,0 +1,225 @@ +#![macro_use] +#![allow(unused_macros)] + +#[cfg(all(feature = "defmt", feature = "log"))] +compile_error!("You may not enable both `defmt` and `log` features."); + +macro_rules! assert { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::assert!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::assert!($($x)*); + } + }; +} + +macro_rules! assert_eq { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::assert_eq!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::assert_eq!($($x)*); + } + }; +} + +macro_rules! assert_ne { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::assert_ne!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::assert_ne!($($x)*); + } + }; +} + +macro_rules! debug_assert { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::debug_assert!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::debug_assert!($($x)*); + } + }; +} + +macro_rules! debug_assert_eq { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::debug_assert_eq!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::debug_assert_eq!($($x)*); + } + }; +} + +macro_rules! debug_assert_ne { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::debug_assert_ne!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::debug_assert_ne!($($x)*); + } + }; +} + +macro_rules! todo { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::todo!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::todo!($($x)*); + } + }; +} + +macro_rules! unreachable { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::unreachable!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::unreachable!($($x)*); + } + }; +} + +macro_rules! panic { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::panic!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::panic!($($x)*); + } + }; +} + +macro_rules! trace { + ($s:literal $(, $x:expr)* $(,)?) => { + { + #[cfg(feature = "log")] + ::log::trace!($s $(, $x)*); + #[cfg(feature = "defmt")] + ::defmt::trace!($s $(, $x)*); + #[cfg(not(any(feature = "log", feature="defmt")))] + let _ = ($( & $x ),*); + } + }; +} + +macro_rules! debug { + ($s:literal $(, $x:expr)* $(,)?) => { + { + #[cfg(feature = "log")] + ::log::debug!($s $(, $x)*); + #[cfg(feature = "defmt")] + ::defmt::debug!($s $(, $x)*); + #[cfg(not(any(feature = "log", feature="defmt")))] + let _ = ($( & $x ),*); + } + }; +} + +macro_rules! info { + ($s:literal $(, $x:expr)* $(,)?) => { + { + #[cfg(feature = "log")] + ::log::info!($s $(, $x)*); + #[cfg(feature = "defmt")] + ::defmt::info!($s $(, $x)*); + #[cfg(not(any(feature = "log", feature="defmt")))] + let _ = ($( & $x ),*); + } + }; +} + +macro_rules! warn { + ($s:literal $(, $x:expr)* $(,)?) => { + { + #[cfg(feature = "log")] + ::log::warn!($s $(, $x)*); + #[cfg(feature = "defmt")] + ::defmt::warn!($s $(, $x)*); + #[cfg(not(any(feature = "log", feature="defmt")))] + let _ = ($( & $x ),*); + } + }; +} + +macro_rules! error { + ($s:literal $(, $x:expr)* $(,)?) => { + { + #[cfg(feature = "log")] + ::log::error!($s $(, $x)*); + #[cfg(feature = "defmt")] + ::defmt::error!($s $(, $x)*); + #[cfg(not(any(feature = "log", feature="defmt")))] + let _ = ($( & $x ),*); + } + }; +} + +#[cfg(feature = "defmt")] +macro_rules! unwrap { + ($($x:tt)*) => { + ::defmt::unwrap!($($x)*) + }; +} + +#[cfg(not(feature = "defmt"))] +macro_rules! unwrap { + ($arg:expr) => { + match $crate::fmt::Try::into_result($arg) { + ::core::result::Result::Ok(t) => t, + ::core::result::Result::Err(e) => { + ::core::panic!("unwrap of `{}` failed: {:?}", ::core::stringify!($arg), e); + } + } + }; + ($arg:expr, $($msg:expr),+ $(,)? ) => { + match $crate::fmt::Try::into_result($arg) { + ::core::result::Result::Ok(t) => t, + ::core::result::Result::Err(e) => { + ::core::panic!("unwrap of `{}` failed: {}: {:?}", ::core::stringify!($arg), ::core::format_args!($($msg,)*), e); + } + } + } +} + +#[derive(Debug, Copy, Clone, Eq, PartialEq)] +pub struct NoneError; + +pub trait Try { + type Ok; + type Error; + fn into_result(self) -> Result; +} + +impl Try for Option { + type Ok = T; + type Error = NoneError; + + #[inline] + fn into_result(self) -> Result { + self.ok_or(NoneError) + } +} + +impl Try for Result { + type Ok = T; + type Error = E; + + #[inline] + fn into_result(self) -> Self { + self + } +} diff --git a/embassy-executor/src/time/instant.rs b/embassy-time/src/instant.rs similarity index 100% rename from embassy-executor/src/time/instant.rs rename to embassy-time/src/instant.rs diff --git a/embassy-executor/src/time/mod.rs b/embassy-time/src/lib.rs similarity index 75% rename from embassy-executor/src/time/mod.rs rename to embassy-time/src/lib.rs index b787a5cf..a6454d55 100644 --- a/embassy-executor/src/time/mod.rs +++ b/embassy-time/src/lib.rs @@ -1,3 +1,8 @@ +#![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] +#![cfg_attr(feature = "nightly", feature(generic_associated_types, type_alias_impl_trait))] +#![allow(clippy::new_without_default)] +#![warn(missing_docs)] + //! Timekeeping, delays and timeouts. //! //! Timekeeping is done with elapsed time since system boot. Time is represented in @@ -26,7 +31,7 @@ //! like `2021-08-24 13:33:21`). //! //! If persistence across reboots is not needed, support can be built on top of -//! `embassy_executor::time` by storing the offset between "seconds elapsed since boot" +//! `embassy_time` by storing the offset between "seconds elapsed since boot" //! and "seconds since unix epoch". //! //! # Time driver @@ -35,12 +40,13 @@ //! Only one driver can be active in a program. //! //! All methods and structs transparently call into the active driver. This makes it -//! possible for libraries to use `embassy_executor::time` in a driver-agnostic way without +//! possible for libraries to use `embassy_time` in a driver-agnostic way without //! requiring generic parameters. //! //! For more details, check the [`driver`] module. -#![deny(missing_docs)] +// This mod MUST go first, so that the others see its macros. +pub(crate) mod fmt; mod delay; pub mod driver; @@ -50,7 +56,6 @@ mod timer; #[cfg(feature = "std")] mod driver_std; - #[cfg(feature = "wasm")] mod driver_wasm; @@ -59,24 +64,24 @@ pub use duration::Duration; pub use instant::Instant; pub use timer::{with_timeout, Ticker, TimeoutError, Timer}; -#[cfg(feature = "time-tick-1000hz")] +#[cfg(feature = "tick-1000hz")] const TPS: u64 = 1_000; -#[cfg(feature = "time-tick-32768hz")] +#[cfg(feature = "tick-32768hz")] const TPS: u64 = 32_768; -#[cfg(feature = "time-tick-1mhz")] +#[cfg(feature = "tick-1mhz")] const TPS: u64 = 1_000_000; -#[cfg(feature = "time-tick-16mhz")] +#[cfg(feature = "tick-16mhz")] const TPS: u64 = 16_000_000; /// Ticks per second of the global timebase. /// -/// This value is specified by the `time-tick-*` Cargo features, which +/// This value is specified by the `tick-*` Cargo features, which /// should be set by the time driver. Some drivers support a fixed tick rate, others /// allow you to choose a tick rate with Cargo features of their own. You should not -/// set the `time-tick-*` features for embassy yourself as an end user. +/// set the `tick-*` features for embassy yourself as an end user. pub const TICKS_PER_SECOND: u64 = TPS; const fn gcd(a: u64, b: u64) -> u64 { @@ -89,3 +94,6 @@ const fn gcd(a: u64, b: u64) -> u64 { pub(crate) const GCD_1K: u64 = gcd(TICKS_PER_SECOND, 1_000); pub(crate) const GCD_1M: u64 = gcd(TICKS_PER_SECOND, 1_000_000); + +#[cfg(feature = "defmt-timestamp-uptime")] +defmt::timestamp! {"{=u64:us}", Instant::now().as_micros() } diff --git a/embassy-executor/src/time/timer.rs b/embassy-time/src/timer.rs similarity index 88% rename from embassy-executor/src/time/timer.rs rename to embassy-time/src/timer.rs index b9cdb1be..bd791b81 100644 --- a/embassy-executor/src/time/timer.rs +++ b/embassy-time/src/timer.rs @@ -1,12 +1,11 @@ use core::future::Future; use core::pin::Pin; -use core::task::{Context, Poll}; +use core::task::{Context, Poll, Waker}; use futures_util::future::{select, Either}; use futures_util::{pin_mut, Stream}; -use crate::executor::raw; -use crate::time::{Duration, Instant}; +use crate::{Duration, Instant}; /// Error returned by [`with_timeout`] on timeout. #[derive(Debug, Clone, PartialEq, Eq)] @@ -49,7 +48,7 @@ impl Timer { /// # #![feature(type_alias_impl_trait)] /// # /// # fn foo() {} - /// use embassy_executor::time::{Duration, Timer}; + /// use embassy_time::{Duration, Timer}; /// /// #[embassy_executor::task] /// async fn demo_sleep_seconds() { @@ -73,7 +72,7 @@ impl Future for Timer { if self.yielded_once && self.expires_at <= Instant::now() { Poll::Ready(()) } else { - unsafe { raw::register_timer(self.expires_at, cx.waker()) }; + schedule_wake(self.expires_at, cx.waker()); self.yielded_once = true; Poll::Pending } @@ -88,7 +87,7 @@ impl Future for Timer { /// ``` no_run /// # #![feature(type_alias_impl_trait)] /// # -/// use embassy_executor::time::{Duration, Timer}; +/// use embassy_time::{Duration, Timer}; /// # fn foo() {} /// /// #[embassy_executor::task] @@ -108,7 +107,7 @@ impl Future for Timer { /// ``` no_run /// # #![feature(type_alias_impl_trait)] /// # -/// use embassy_executor::time::{Duration, Ticker}; +/// use embassy_time::{Duration, Ticker}; /// use futures::StreamExt; /// # fn foo(){} /// @@ -144,8 +143,16 @@ impl Stream for Ticker { self.expires_at += dur; Poll::Ready(Some(())) } else { - unsafe { raw::register_timer(self.expires_at, cx.waker()) }; + schedule_wake(self.expires_at, cx.waker()); Poll::Pending } } } + +extern "Rust" { + fn _embassy_time_schedule_wake(at: Instant, waker: &Waker); +} + +fn schedule_wake(at: Instant, waker: &Waker) { + unsafe { _embassy_time_schedule_wake(at, waker) } +} diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml index ca4fb984..ef934663 100644 --- a/examples/boot/application/nrf/Cargo.toml +++ b/examples/boot/application/nrf/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../../../embassy-util" } -embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly"] } +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"] } embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/nrf/src/bin/a.rs b/examples/boot/application/nrf/src/bin/a.rs index 6343f570..bd8fa324 100644 --- a/examples/boot/application/nrf/src/bin/a.rs +++ b/examples/boot/application/nrf/src/bin/a.rs @@ -6,7 +6,7 @@ use embassy_boot_nrf::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; use embassy_nrf::nvmc::Nvmc; use panic_reset as _; diff --git a/examples/boot/application/nrf/src/bin/b.rs b/examples/boot/application/nrf/src/bin/b.rs index ad44804a..5394bf0c 100644 --- a/examples/boot/application/nrf/src/bin/b.rs +++ b/examples/boot/application/nrf/src/bin/b.rs @@ -4,9 +4,9 @@ #![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; +use embassy_time::{Duration, Timer}; use panic_reset as _; #[embassy_executor::main] diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml index 17df1816..27eafa65 100644 --- a/examples/boot/application/stm32f3/Cargo.toml +++ b/examples/boot/application/stm32f3/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } +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"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32f3/src/bin/a.rs b/examples/boot/application/stm32f3/src/bin/a.rs index d06e6aea..11eecc5e 100644 --- a/examples/boot/application/stm32f3/src/bin/a.rs +++ b/examples/boot/application/stm32f3/src/bin/a.rs @@ -6,7 +6,7 @@ use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; diff --git a/examples/boot/application/stm32f3/src/bin/b.rs b/examples/boot/application/stm32f3/src/bin/b.rs index 98d6dbdf..a5862b1b 100644 --- a/examples/boot/application/stm32f3/src/bin/b.rs +++ b/examples/boot/application/stm32f3/src/bin/b.rs @@ -4,9 +4,9 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use panic_reset as _; #[embassy_executor::main] diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml index e3a3ff38..7de0b82d 100644 --- a/examples/boot/application/stm32f7/Cargo.toml +++ b/examples/boot/application/stm32f7/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } +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"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32f7/src/bin/a.rs b/examples/boot/application/stm32f7/src/bin/a.rs index 154d62d2..a3b66e7c 100644 --- a/examples/boot/application/stm32f7/src/bin/a.rs +++ b/examples/boot/application/stm32f7/src/bin/a.rs @@ -6,7 +6,7 @@ use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; diff --git a/examples/boot/application/stm32f7/src/bin/b.rs b/examples/boot/application/stm32f7/src/bin/b.rs index 11883626..16c94d84 100644 --- a/examples/boot/application/stm32f7/src/bin/b.rs +++ b/examples/boot/application/stm32f7/src/bin/b.rs @@ -4,9 +4,9 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use panic_reset as _; #[embassy_executor::main] diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml index 24dd3410..65d34c70 100644 --- a/examples/boot/application/stm32h7/Cargo.toml +++ b/examples/boot/application/stm32h7/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } +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"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32h7/src/bin/a.rs b/examples/boot/application/stm32h7/src/bin/a.rs index 8407adac..0ecf6034 100644 --- a/examples/boot/application/stm32h7/src/bin/a.rs +++ b/examples/boot/application/stm32h7/src/bin/a.rs @@ -6,7 +6,7 @@ use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; diff --git a/examples/boot/application/stm32h7/src/bin/b.rs b/examples/boot/application/stm32h7/src/bin/b.rs index cc694e84..34799279 100644 --- a/examples/boot/application/stm32h7/src/bin/b.rs +++ b/examples/boot/application/stm32h7/src/bin/b.rs @@ -4,9 +4,9 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use panic_reset as _; #[embassy_executor::main] diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml index 48659d80..8f37869e 100644 --- a/examples/boot/application/stm32l0/Cargo.toml +++ b/examples/boot/application/stm32l0/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } +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"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32l0/src/bin/a.rs b/examples/boot/application/stm32l0/src/bin/a.rs index 7ec6bb96..f4f1d711 100644 --- a/examples/boot/application/stm32l0/src/bin/a.rs +++ b/examples/boot/application/stm32l0/src/bin/a.rs @@ -6,11 +6,11 @@ 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_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use embassy_time::{Duration, Timer}; use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); diff --git a/examples/boot/application/stm32l0/src/bin/b.rs b/examples/boot/application/stm32l0/src/bin/b.rs index f1e1eaca..ee40274f 100644 --- a/examples/boot/application/stm32l0/src/bin/b.rs +++ b/examples/boot/application/stm32l0/src/bin/b.rs @@ -4,9 +4,9 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use panic_reset as _; #[embassy_executor::main] diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml index f9693326..6abf1986 100644 --- a/examples/boot/application/stm32l1/Cargo.toml +++ b/examples/boot/application/stm32l1/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } +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"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32l1/src/bin/a.rs b/examples/boot/application/stm32l1/src/bin/a.rs index 7ec6bb96..f4f1d711 100644 --- a/examples/boot/application/stm32l1/src/bin/a.rs +++ b/examples/boot/application/stm32l1/src/bin/a.rs @@ -6,11 +6,11 @@ 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_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use embassy_time::{Duration, Timer}; use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); diff --git a/examples/boot/application/stm32l1/src/bin/b.rs b/examples/boot/application/stm32l1/src/bin/b.rs index f1e1eaca..ee40274f 100644 --- a/examples/boot/application/stm32l1/src/bin/b.rs +++ b/examples/boot/application/stm32l1/src/bin/b.rs @@ -4,9 +4,9 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use panic_reset as _; #[embassy_executor::main] diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml index f529c871..6f2d12ff 100644 --- a/examples/boot/application/stm32l4/Cargo.toml +++ b/examples/boot/application/stm32l4/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } +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"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32l4/src/bin/a.rs b/examples/boot/application/stm32l4/src/bin/a.rs index 91d16ea1..178b2e04 100644 --- a/examples/boot/application/stm32l4/src/bin/a.rs +++ b/examples/boot/application/stm32l4/src/bin/a.rs @@ -6,7 +6,7 @@ use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; diff --git a/examples/boot/application/stm32l4/src/bin/b.rs b/examples/boot/application/stm32l4/src/bin/b.rs index 98d6dbdf..a5862b1b 100644 --- a/examples/boot/application/stm32l4/src/bin/b.rs +++ b/examples/boot/application/stm32l4/src/bin/b.rs @@ -4,9 +4,9 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use panic_reset as _; #[embassy_executor::main] diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml index 67973a24..be97d4eb 100644 --- a/examples/boot/application/stm32wl/Cargo.toml +++ b/examples/boot/application/stm32wl/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "time-tick-32768hz"] } +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"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32wl/src/bin/a.rs b/examples/boot/application/stm32wl/src/bin/a.rs index 613694ec..c71a4265 100644 --- a/examples/boot/application/stm32wl/src/bin/a.rs +++ b/examples/boot/application/stm32wl/src/bin/a.rs @@ -6,7 +6,7 @@ use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::Flash; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; diff --git a/examples/boot/application/stm32wl/src/bin/b.rs b/examples/boot/application/stm32wl/src/bin/b.rs index 97619814..f9f0ffc6 100644 --- a/examples/boot/application/stm32wl/src/bin/b.rs +++ b/examples/boot/application/stm32wl/src/bin/b.rs @@ -4,9 +4,9 @@ #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use panic_reset as _; #[embassy_executor::main] diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index 2d28623c..2fcc3122 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml @@ -9,7 +9,8 @@ nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-nrf/unsta [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime"] } +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"] } embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"], optional = true } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"], optional = true } diff --git a/examples/nrf/src/bin/awaitable_timer.rs b/examples/nrf/src/bin/awaitable_timer.rs index a9422480..b32af236 100644 --- a/examples/nrf/src/bin/awaitable_timer.rs +++ b/examples/nrf/src/bin/awaitable_timer.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::interrupt; use embassy_nrf::timer::Timer; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/blinky.rs b/examples/nrf/src/bin/blinky.rs index 5283d7ea..513f6cd8 100644 --- a/examples/nrf/src/bin/blinky.rs +++ b/examples/nrf/src/bin/blinky.rs @@ -2,9 +2,9 @@ #![no_main] #![feature(type_alias_impl_trait)] -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/nrf/src/bin/buffered_uart.rs b/examples/nrf/src/bin/buffered_uart.rs index d2a15397..ea566f4b 100644 --- a/examples/nrf/src/bin/buffered_uart.rs +++ b/examples/nrf/src/bin/buffered_uart.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::buffered_uarte::{BufferedUarte, State}; use embassy_nrf::{interrupt, uarte}; use embedded_io::asynch::{BufRead, Write}; diff --git a/examples/nrf/src/bin/channel.rs b/examples/nrf/src/bin/channel.rs index a7ea08d0..19520098 100644 --- a/examples/nrf/src/bin/channel.rs +++ b/examples/nrf/src/bin/channel.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::unwrap; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; +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 _}; diff --git a/examples/nrf/src/bin/channel_sender_receiver.rs b/examples/nrf/src/bin/channel_sender_receiver.rs index ef85e871..c9c458ae 100644 --- a/examples/nrf/src/bin/channel_sender_receiver.rs +++ b/examples/nrf/src/bin/channel_sender_receiver.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::unwrap; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; +use embassy_time::{Duration, Timer}; use embassy_util::blocking_mutex::raw::NoopRawMutex; use embassy_util::channel::mpmc::{Channel, Receiver, Sender}; use embassy_util::Forever; diff --git a/examples/nrf/src/bin/executor_fairness_test.rs b/examples/nrf/src/bin/executor_fairness_test.rs index 7aaeda54..9ae030d0 100644 --- a/examples/nrf/src/bin/executor_fairness_test.rs +++ b/examples/nrf/src/bin/executor_fairness_test.rs @@ -5,8 +5,8 @@ use core::task::Poll; use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Instant, Timer}; +use embassy_executor::Spawner; +use embassy_time::{Duration, Instant, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task] diff --git a/examples/nrf/src/bin/gpiote_channel.rs b/examples/nrf/src/bin/gpiote_channel.rs index f2654cb4..5bfd0246 100644 --- a/examples/nrf/src/bin/gpiote_channel.rs +++ b/examples/nrf/src/bin/gpiote_channel.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/gpiote_port.rs b/examples/nrf/src/bin/gpiote_port.rs index 46c260a4..0155d539 100644 --- a/examples/nrf/src/bin/gpiote_port.rs +++ b/examples/nrf/src/bin/gpiote_port.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/multiprio.rs b/examples/nrf/src/bin/multiprio.rs index 7050da37..b653689a 100644 --- a/examples/nrf/src/bin/multiprio.rs +++ b/examples/nrf/src/bin/multiprio.rs @@ -59,10 +59,10 @@ use cortex_m_rt::entry; use defmt::{info, unwrap}; -use embassy_executor::time::{Duration, Instant, Timer}; 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 {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/mutex.rs b/examples/nrf/src/bin/mutex.rs index 378a5926..87629788 100644 --- a/examples/nrf/src/bin/mutex.rs +++ b/examples/nrf/src/bin/mutex.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; +use embassy_time::{Duration, Timer}; use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; use embassy_util::mutex::Mutex; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/nvmc.rs b/examples/nrf/src/bin/nvmc.rs index a0b55580..75d090fb 100644 --- a/examples/nrf/src/bin/nvmc.rs +++ b/examples/nrf/src/bin/nvmc.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::nvmc::Nvmc; +use embassy_time::{Duration, Timer}; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/ppi.rs b/examples/nrf/src/bin/ppi.rs index fb2a97f1..d74ce406 100644 --- a/examples/nrf/src/bin/ppi.rs +++ b/examples/nrf/src/bin/ppi.rs @@ -5,7 +5,7 @@ use core::future::pending; use defmt::info; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity}; use embassy_nrf::ppi::Ppi; diff --git a/examples/nrf/src/bin/pubsub.rs b/examples/nrf/src/bin/pubsub.rs index d1441d5c..1d90217f 100644 --- a/examples/nrf/src/bin/pubsub.rs +++ b/examples/nrf/src/bin/pubsub.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::unwrap; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; +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 _}; diff --git a/examples/nrf/src/bin/pwm.rs b/examples/nrf/src/bin/pwm.rs index dca40fd5..1698c0bc 100644 --- a/examples/nrf/src/bin/pwm.rs +++ b/examples/nrf/src/bin/pwm.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::pwm::{Prescaler, SimplePwm}; +use embassy_time::{Duration, Timer}; 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='') diff --git a/examples/nrf/src/bin/pwm_double_sequence.rs b/examples/nrf/src/bin/pwm_double_sequence.rs index 08436c8f..16e50e90 100644 --- a/examples/nrf/src/bin/pwm_double_sequence.rs +++ b/examples/nrf/src/bin/pwm_double_sequence.rs @@ -3,11 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::pwm::{ Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, StartSequence, }; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs index c549b55c..b9aca9aa 100644 --- a/examples/nrf/src/bin/pwm_sequence.rs +++ b/examples/nrf/src/bin/pwm_sequence.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/nrf/src/bin/pwm_sequence_ppi.rs b/examples/nrf/src/bin/pwm_sequence_ppi.rs index 4131e084..6594fa34 100644 --- a/examples/nrf/src/bin/pwm_sequence_ppi.rs +++ b/examples/nrf/src/bin/pwm_sequence_ppi.rs @@ -5,7 +5,7 @@ use core::future::pending; use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; use embassy_nrf::ppi::Ppi; diff --git a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs index de457822..711c8a17 100644 --- a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs +++ b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs @@ -3,11 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::pwm::{ Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, SingleSequencer, }; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; // WS2812B LED light demonstration. Drives just one light. diff --git a/examples/nrf/src/bin/pwm_servo.rs b/examples/nrf/src/bin/pwm_servo.rs index 08a7a1fd..19228f43 100644 --- a/examples/nrf/src/bin/pwm_servo.rs +++ b/examples/nrf/src/bin/pwm_servo.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::pwm::{Prescaler, SimplePwm}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/nrf/src/bin/qdec.rs b/examples/nrf/src/bin/qdec.rs index f9565e89..600bba07 100644 --- a/examples/nrf/src/bin/qdec.rs +++ b/examples/nrf/src/bin/qdec.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::interrupt; use embassy_nrf::qdec::{self, Qdec}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/qspi.rs b/examples/nrf/src/bin/qspi.rs index 976673a2..bdcf710b 100644 --- a/examples/nrf/src/bin/qspi.rs +++ b/examples/nrf/src/bin/qspi.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::{assert_eq, info, unwrap}; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::{interrupt, qspi}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/qspi_lowpower.rs b/examples/nrf/src/bin/qspi_lowpower.rs index a83fe3fe..9341a237 100644 --- a/examples/nrf/src/bin/qspi_lowpower.rs +++ b/examples/nrf/src/bin/qspi_lowpower.rs @@ -5,9 +5,9 @@ use core::mem; use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::{interrupt, qspi}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; // Workaround for alignment requirements. diff --git a/examples/nrf/src/bin/raw_spawn.rs b/examples/nrf/src/bin/raw_spawn.rs index 9199d3ae..415579be 100644 --- a/examples/nrf/src/bin/raw_spawn.rs +++ b/examples/nrf/src/bin/raw_spawn.rs @@ -5,9 +5,9 @@ use core::mem; use cortex_m_rt::entry; use defmt::{info, unwrap}; -use embassy_executor::executor::raw::TaskStorage; -use embassy_executor::executor::Executor; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::raw::TaskStorage; +use embassy_executor::Executor; +use embassy_time::{Duration, Timer}; use embassy_util::Forever; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/rng.rs b/examples/nrf/src/bin/rng.rs index 70ab5c73..64707394 100644 --- a/examples/nrf/src/bin/rng.rs +++ b/examples/nrf/src/bin/rng.rs @@ -2,7 +2,7 @@ #![no_main] #![feature(type_alias_impl_trait)] -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::interrupt; use embassy_nrf::rng::Rng; use rand::Rng as _; diff --git a/examples/nrf/src/bin/saadc.rs b/examples/nrf/src/bin/saadc.rs index e90fc3df..7cf58809 100644 --- a/examples/nrf/src/bin/saadc.rs +++ b/examples/nrf/src/bin/saadc.rs @@ -3,10 +3,10 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::interrupt; use embassy_nrf::saadc::{ChannelConfig, Config, Saadc}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/nrf/src/bin/saadc_continuous.rs b/examples/nrf/src/bin/saadc_continuous.rs index 80ecaae7..bb50ac65 100644 --- a/examples/nrf/src/bin/saadc_continuous.rs +++ b/examples/nrf/src/bin/saadc_continuous.rs @@ -3,11 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy_executor::executor::Spawner; -use embassy_executor::time::Duration; +use embassy_executor::Spawner; use embassy_nrf::interrupt; use embassy_nrf::saadc::{ChannelConfig, Config, Saadc, SamplerState}; use embassy_nrf::timer::Frequency; +use embassy_time::Duration; use {defmt_rtt as _, panic_probe as _}; // Demonstrates both continuous sampling and scanning multiple channels driven by a PPI linked timer @@ -28,7 +28,7 @@ async fn main(_p: Spawner) { // This delay demonstrates that starting the timer prior to running // the task sampler is benign given the calibration that follows. - embassy_executor::time::Timer::after(Duration::from_millis(500)).await; + embassy_time::Timer::after(Duration::from_millis(500)).await; saadc.calibrate().await; let mut bufs = [[[0; 3]; 500]; 2]; diff --git a/examples/nrf/src/bin/self_spawn.rs b/examples/nrf/src/bin/self_spawn.rs index 56539eef..196255a5 100644 --- a/examples/nrf/src/bin/self_spawn.rs +++ b/examples/nrf/src/bin/self_spawn.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task(pool_size = 2)] diff --git a/examples/nrf/src/bin/self_spawn_current_executor.rs b/examples/nrf/src/bin/self_spawn_current_executor.rs index 11fe6fb4..8a179886 100644 --- a/examples/nrf/src/bin/self_spawn_current_executor.rs +++ b/examples/nrf/src/bin/self_spawn_current_executor.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task(pool_size = 2)] diff --git a/examples/nrf/src/bin/spim.rs b/examples/nrf/src/bin/spim.rs index 437a1a80..132e0166 100644 --- a/examples/nrf/src/bin/spim.rs +++ b/examples/nrf/src/bin/spim.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::{interrupt, spim}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/temp.rs b/examples/nrf/src/bin/temp.rs index a898488f..b06ac709 100644 --- a/examples/nrf/src/bin/temp.rs +++ b/examples/nrf/src/bin/temp.rs @@ -3,10 +3,10 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::interrupt; use embassy_nrf::temp::Temp; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/nrf/src/bin/timer.rs b/examples/nrf/src/bin/timer.rs index de790233..c22b5acd 100644 --- a/examples/nrf/src/bin/timer.rs +++ b/examples/nrf/src/bin/timer.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task] diff --git a/examples/nrf/src/bin/twim.rs b/examples/nrf/src/bin/twim.rs index a0a6d359..a027cc1e 100644 --- a/examples/nrf/src/bin/twim.rs +++ b/examples/nrf/src/bin/twim.rs @@ -7,7 +7,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::interrupt; use embassy_nrf::twim::{self, Twim}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/twim_lowpower.rs b/examples/nrf/src/bin/twim_lowpower.rs index 916ac07e..e30cc968 100644 --- a/examples/nrf/src/bin/twim_lowpower.rs +++ b/examples/nrf/src/bin/twim_lowpower.rs @@ -11,10 +11,10 @@ use core::mem; use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::interrupt; use embassy_nrf::twim::{self, Twim}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x50; diff --git a/examples/nrf/src/bin/uart.rs b/examples/nrf/src/bin/uart.rs index 011ad2a5..600f7a6e 100644 --- a/examples/nrf/src/bin/uart.rs +++ b/examples/nrf/src/bin/uart.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::{interrupt, uarte}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/uart_idle.rs b/examples/nrf/src/bin/uart_idle.rs index cf3d9938..09ec624c 100644 --- a/examples/nrf/src/bin/uart_idle.rs +++ b/examples/nrf/src/bin/uart_idle.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::{interrupt, uarte}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/nrf/src/bin/uart_split.rs b/examples/nrf/src/bin/uart_split.rs index 12c21c09..dab8e475 100644 --- a/examples/nrf/src/bin/uart_split.rs +++ b/examples/nrf/src/bin/uart_split.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::peripherals::UARTE0; use embassy_nrf::uarte::UarteRx; use embassy_nrf::{interrupt, uarte}; diff --git a/examples/nrf/src/bin/usb_ethernet.rs b/examples/nrf/src/bin/usb_ethernet.rs index 4f8e59cc..f0a87031 100644 --- a/examples/nrf/src/bin/usb_ethernet.rs +++ b/examples/nrf/src/bin/usb_ethernet.rs @@ -8,7 +8,7 @@ use core::sync::atomic::{AtomicBool, Ordering}; use core::task::Waker; use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_net::tcp::TcpSocket; use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources}; use embassy_nrf::rng::Rng; diff --git a/examples/nrf/src/bin/usb_hid_keyboard.rs b/examples/nrf/src/bin/usb_hid_keyboard.rs index 16d1a9a2..cf0078ee 100644 --- a/examples/nrf/src/bin/usb_hid_keyboard.rs +++ b/examples/nrf/src/bin/usb_hid_keyboard.rs @@ -7,7 +7,7 @@ use core::mem; use core::sync::atomic::{AtomicBool, Ordering}; use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::gpio::{Input, Pin, Pull}; use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac}; diff --git a/examples/nrf/src/bin/usb_hid_mouse.rs b/examples/nrf/src/bin/usb_hid_mouse.rs index 0008e0e6..7cd2ece1 100644 --- a/examples/nrf/src/bin/usb_hid_mouse.rs +++ b/examples/nrf/src/bin/usb_hid_mouse.rs @@ -6,10 +6,10 @@ use core::mem; use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac}; +use embassy_time::{Duration, Timer}; use embassy_usb::control::OutResponse; use embassy_usb::{Builder, Config}; use embassy_usb_hid::{HidWriter, ReportId, RequestHandler, State}; diff --git a/examples/nrf/src/bin/usb_serial.rs b/examples/nrf/src/bin/usb_serial.rs index ce11c6cb..a68edb32 100644 --- a/examples/nrf/src/bin/usb_serial.rs +++ b/examples/nrf/src/bin/usb_serial.rs @@ -6,7 +6,7 @@ use core::mem; use defmt::{info, panic}; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::usb::{Driver, Instance, PowerUsb, UsbSupply}; use embassy_nrf::{interrupt, pac}; use embassy_usb::driver::EndpointError; diff --git a/examples/nrf/src/bin/usb_serial_multitask.rs b/examples/nrf/src/bin/usb_serial_multitask.rs index d2f1a972..4c1a9308 100644 --- a/examples/nrf/src/bin/usb_serial_multitask.rs +++ b/examples/nrf/src/bin/usb_serial_multitask.rs @@ -6,7 +6,7 @@ use core::mem; use defmt::{info, panic, unwrap}; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::usb::{Driver, PowerUsb}; use embassy_nrf::{interrupt, pac, peripherals}; use embassy_usb::driver::EndpointError; diff --git a/examples/nrf/src/bin/wdt.rs b/examples/nrf/src/bin/wdt.rs index 47e40b88..b0b9c3b8 100644 --- a/examples/nrf/src/bin/wdt.rs +++ b/examples/nrf/src/bin/wdt.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::wdt::{Config, Watchdog}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index f58ec194..c2dcf429 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml @@ -6,7 +6,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime"] } +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"] } defmt = "0.3" diff --git a/examples/rp/src/bin/blinky.rs b/examples/rp/src/bin/blinky.rs index dade3bf3..7aa36a19 100644 --- a/examples/rp/src/bin/blinky.rs +++ b/examples/rp/src/bin/blinky.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_rp::gpio; +use embassy_time::{Duration, Timer}; use gpio::{Level, Output}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/rp/src/bin/button.rs b/examples/rp/src/bin/button.rs index 22793735..c5422c61 100644 --- a/examples/rp/src/bin/button.rs +++ b/examples/rp/src/bin/button.rs @@ -2,7 +2,7 @@ #![no_main] #![feature(type_alias_impl_trait)] -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_rp::gpio::{Input, Level, Output, Pull}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/rp/src/bin/gpio_async.rs b/examples/rp/src/bin/gpio_async.rs index c61b87a3..52d13a9d 100644 --- a/examples/rp/src/bin/gpio_async.rs +++ b/examples/rp/src/bin/gpio_async.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_rp::gpio; +use embassy_time::{Duration, Timer}; use gpio::{Input, Level, Output, Pull}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/rp/src/bin/spi.rs b/examples/rp/src/bin/spi.rs index 7d337002..88003ee1 100644 --- a/examples/rp/src/bin/spi.rs +++ b/examples/rp/src/bin/spi.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_rp::spi::Spi; use embassy_rp::{gpio, spi}; use gpio::{Level, Output}; diff --git a/examples/rp/src/bin/spi_display.rs b/examples/rp/src/bin/spi_display.rs index 8b46bd07..f0e54d87 100644 --- a/examples/rp/src/bin/spi_display.rs +++ b/examples/rp/src/bin/spi_display.rs @@ -5,11 +5,11 @@ use core::cell::RefCell; use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::Delay; +use embassy_executor::Spawner; use embassy_rp::gpio::{Level, Output}; use embassy_rp::spi; use embassy_rp::spi::Spi; +use embassy_time::Delay; use embedded_graphics::image::{Image, ImageRawLE}; use embedded_graphics::mono_font::ascii::FONT_10X20; use embedded_graphics::mono_font::MonoTextStyle; diff --git a/examples/rp/src/bin/uart.rs b/examples/rp/src/bin/uart.rs index 06721146..5fdc3ff7 100644 --- a/examples/rp/src/bin/uart.rs +++ b/examples/rp/src/bin/uart.rs @@ -2,7 +2,7 @@ #![no_main] #![feature(type_alias_impl_trait)] -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_rp::uart; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 47933894..b7009017 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["log"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "std", "time", "nightly"] } +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"] } embedded-io = { version = "0.3.0", features = ["async", "std", "futures"] } critical-section = { version = "1.1", features = ["std"] } diff --git a/examples/std/src/bin/net.rs b/examples/std/src/bin/net.rs index 20258528..52860926 100644 --- a/examples/std/src/bin/net.rs +++ b/examples/std/src/bin/net.rs @@ -1,7 +1,7 @@ #![feature(type_alias_impl_trait)] use clap::Parser; -use embassy_executor::executor::{Executor, Spawner}; +use embassy_executor::{Executor, Spawner}; use embassy_net::tcp::TcpSocket; use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, Stack, StackResources}; use embassy_util::Forever; diff --git a/examples/std/src/bin/net_udp.rs b/examples/std/src/bin/net_udp.rs index 7fe36e23..07e11c38 100644 --- a/examples/std/src/bin/net_udp.rs +++ b/examples/std/src/bin/net_udp.rs @@ -1,7 +1,7 @@ #![feature(type_alias_impl_trait)] use clap::Parser; -use embassy_executor::executor::{Executor, Spawner}; +use embassy_executor::{Executor, Spawner}; use embassy_net::udp::UdpSocket; use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, PacketMetadata, Stack, StackResources}; use embassy_util::Forever; diff --git a/examples/std/src/bin/serial.rs b/examples/std/src/bin/serial.rs index b803d1ef..35cba4ce 100644 --- a/examples/std/src/bin/serial.rs +++ b/examples/std/src/bin/serial.rs @@ -4,7 +4,7 @@ mod serial_port; use async_io::Async; -use embassy_executor::executor::Executor; +use embassy_executor::Executor; use embassy_util::Forever; use embedded_io::asynch::Read; use log::*; diff --git a/examples/std/src/bin/tick.rs b/examples/std/src/bin/tick.rs index 9ca900df..b9de9d87 100644 --- a/examples/std/src/bin/tick.rs +++ b/examples/std/src/bin/tick.rs @@ -1,7 +1,7 @@ #![feature(type_alias_impl_trait)] -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; +use embassy_time::{Duration, Timer}; use log::*; #[embassy_executor::task] diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml index 27bd8a69..8476200d 100644 --- a/examples/stm32f0/Cargo.toml +++ b/examples/stm32f0/Cargo.toml @@ -12,6 +12,7 @@ defmt = "0.3" defmt-rtt = "0.3" panic-probe = "0.3" embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +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"] } diff --git a/examples/stm32f0/src/bin/hello.rs b/examples/stm32f0/src/bin/hello.rs index a0775bad..db78233e 100644 --- a/examples/stm32f0/src/bin/hello.rs +++ b/examples/stm32f0/src/bin/hello.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml index f0e046f5..fbc96400 100644 --- a/examples/stm32f1/Cargo.toml +++ b/examples/stm32f1/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +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"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"] } diff --git a/examples/stm32f1/src/bin/adc.rs b/examples/stm32f1/src/bin/adc.rs index dae001a8..2d6b4a0e 100644 --- a/examples/stm32f1/src/bin/adc.rs +++ b/examples/stm32f1/src/bin/adc.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Delay, Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::adc::Adc; +use embassy_time::{Delay, Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f1/src/bin/blinky.rs b/examples/stm32f1/src/bin/blinky.rs index 74e31cbb..b9b0ac23 100644 --- a/examples/stm32f1/src/bin/blinky.rs +++ b/examples/stm32f1/src/bin/blinky.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f1/src/bin/hello.rs b/examples/stm32f1/src/bin/hello.rs index 57892d3c..180b6aab 100644 --- a/examples/stm32f1/src/bin/hello.rs +++ b/examples/stm32f1/src/bin/hello.rs @@ -3,10 +3,10 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::time::Hertz; use embassy_stm32::Config; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f1/src/bin/usb_serial.rs b/examples/stm32f1/src/bin/usb_serial.rs index 2301c51b..a9c46068 100644 --- a/examples/stm32f1/src/bin/usb_serial.rs +++ b/examples/stm32f1/src/bin/usb_serial.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::{panic, *}; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::time::Hertz; use embassy_stm32::usb::{Driver, Instance}; use embassy_stm32::{interrupt, Config}; +use embassy_time::{Duration, Timer}; use embassy_usb::driver::EndpointError; use embassy_usb::Builder; use embassy_usb_serial::{CdcAcmClass, State}; diff --git a/examples/stm32f2/Cargo.toml b/examples/stm32f2/Cargo.toml index 0825f618..27894df5 100644 --- a/examples/stm32f2/Cargo.toml +++ b/examples/stm32f2/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +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"] } defmt = "0.3" diff --git a/examples/stm32f2/src/bin/blinky.rs b/examples/stm32f2/src/bin/blinky.rs index 2afdeeb3..d8c89a51 100644 --- a/examples/stm32f2/src/bin/blinky.rs +++ b/examples/stm32f2/src/bin/blinky.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f2/src/bin/pll.rs b/examples/stm32f2/src/bin/pll.rs index 6fce7a71..17f09538 100644 --- a/examples/stm32f2/src/bin/pll.rs +++ b/examples/stm32f2/src/bin/pll.rs @@ -5,13 +5,13 @@ use core::convert::TryFrom; use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::rcc::{ APBPrescaler, ClockSrc, HSEConfig, HSESrc, PLL48Div, PLLConfig, PLLMainDiv, PLLMul, PLLPreDiv, PLLSrc, }; use embassy_stm32::time::Hertz; use embassy_stm32::Config; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml index b7f70b11..b5ea28bb 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +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"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"] } diff --git a/examples/stm32f3/src/bin/blinky.rs b/examples/stm32f3/src/bin/blinky.rs index 84d7c50a..185785ce 100644 --- a/examples/stm32f3/src/bin/blinky.rs +++ b/examples/stm32f3/src/bin/blinky.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f3/src/bin/button_events.rs b/examples/stm32f3/src/bin/button_events.rs index 404946f2..61fc6dca 100644 --- a/examples/stm32f3/src/bin/button_events.rs +++ b/examples/stm32f3/src/bin/button_events.rs @@ -11,11 +11,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{with_timeout, Duration, Timer}; +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_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 _}; diff --git a/examples/stm32f3/src/bin/button_exti.rs b/examples/stm32f3/src/bin/button_exti.rs index b770b338..1266778c 100644 --- a/examples/stm32f3/src/bin/button_exti.rs +++ b/examples/stm32f3/src/bin/button_exti.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32f3/src/bin/flash.rs b/examples/stm32f3/src/bin/flash.rs index c7982884..2cf24dbd 100644 --- a/examples/stm32f3/src/bin/flash.rs +++ b/examples/stm32f3/src/bin/flash.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::flash::Flash; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32f3/src/bin/hello.rs b/examples/stm32f3/src/bin/hello.rs index cd59f740..65773210 100644 --- a/examples/stm32f3/src/bin/hello.rs +++ b/examples/stm32f3/src/bin/hello.rs @@ -3,10 +3,10 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::time::Hertz; use embassy_stm32::Config; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f3/src/bin/multiprio.rs b/examples/stm32f3/src/bin/multiprio.rs index fba5b286..e96c3124 100644 --- a/examples/stm32f3/src/bin/multiprio.rs +++ b/examples/stm32f3/src/bin/multiprio.rs @@ -59,10 +59,10 @@ use cortex_m_rt::entry; use defmt::*; -use embassy_executor::time::{Duration, Instant, Timer}; 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 {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32f3/src/bin/spi_dma.rs b/examples/stm32f3/src/bin/spi_dma.rs index 7f874bb6..95b2b686 100644 --- a/examples/stm32f3/src/bin/spi_dma.rs +++ b/examples/stm32f3/src/bin/spi_dma.rs @@ -6,7 +6,7 @@ use core::fmt::Write; use core::str::from_utf8; use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use heapless::String; diff --git a/examples/stm32f3/src/bin/usart_dma.rs b/examples/stm32f3/src/bin/usart_dma.rs index 2b27a8da..3bc5a287 100644 --- a/examples/stm32f3/src/bin/usart_dma.rs +++ b/examples/stm32f3/src/bin/usart_dma.rs @@ -5,7 +5,7 @@ use core::fmt::Write; use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use heapless::String; diff --git a/examples/stm32f3/src/bin/usb_serial.rs b/examples/stm32f3/src/bin/usb_serial.rs index 757643ea..d3702fc3 100644 --- a/examples/stm32f3/src/bin/usb_serial.rs +++ b/examples/stm32f3/src/bin/usb_serial.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::{panic, *}; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::time::mhz; use embassy_stm32::usb::{Driver, Instance}; use embassy_stm32::{interrupt, Config}; +use embassy_time::{Duration, Timer}; use embassy_usb::driver::EndpointError; use embassy_usb::Builder; use embassy_usb_serial::{CdcAcmClass, State}; diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index e69974c5..04a217af 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml @@ -6,7 +6,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "time-tick-32768hz"] } +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"] } defmt = "0.3" diff --git a/examples/stm32f4/src/bin/adc.rs b/examples/stm32f4/src/bin/adc.rs index 1dc01edd..87118507 100644 --- a/examples/stm32f4/src/bin/adc.rs +++ b/examples/stm32f4/src/bin/adc.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Delay, Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::adc::Adc; +use embassy_time::{Delay, Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f4/src/bin/blinky.rs b/examples/stm32f4/src/bin/blinky.rs index 249bbd88..b27bee4c 100644 --- a/examples/stm32f4/src/bin/blinky.rs +++ b/examples/stm32f4/src/bin/blinky.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f4/src/bin/button_exti.rs b/examples/stm32f4/src/bin/button_exti.rs index 25d3bb9c..dfe587d4 100644 --- a/examples/stm32f4/src/bin/button_exti.rs +++ b/examples/stm32f4/src/bin/button_exti.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32f4/src/bin/dac.rs b/examples/stm32f4/src/bin/dac.rs index 9098a971..d97ae708 100644 --- a/examples/stm32f4/src/bin/dac.rs +++ b/examples/stm32f4/src/bin/dac.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dac::{Channel, Dac, Value}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32f4/src/bin/flash.rs b/examples/stm32f4/src/bin/flash.rs index 0d96efb6..393d61e8 100644 --- a/examples/stm32f4/src/bin/flash.rs +++ b/examples/stm32f4/src/bin/flash.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::flash::Flash; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs index 26d3555a..c409703f 100644 --- a/examples/stm32f4/src/bin/hello.rs +++ b/examples/stm32f4/src/bin/hello.rs @@ -3,10 +3,10 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::time::Hertz; use embassy_stm32::Config; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f4/src/bin/multiprio.rs b/examples/stm32f4/src/bin/multiprio.rs index fba5b286..e96c3124 100644 --- a/examples/stm32f4/src/bin/multiprio.rs +++ b/examples/stm32f4/src/bin/multiprio.rs @@ -59,10 +59,10 @@ use cortex_m_rt::entry; use defmt::*; -use embassy_executor::time::{Duration, Instant, Timer}; 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 {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32f4/src/bin/pwm.rs b/examples/stm32f4/src/bin/pwm.rs index 1d4f426b..7c590205 100644 --- a/examples/stm32f4/src/bin/pwm.rs +++ b/examples/stm32f4/src/bin/pwm.rs @@ -3,11 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; use embassy_stm32::pwm::Channel; use embassy_stm32::time::khz; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f4/src/bin/sdmmc.rs b/examples/stm32f4/src/bin/sdmmc.rs index b8e56d2e..0edd8a61 100644 --- a/examples/stm32f4/src/bin/sdmmc.rs +++ b/examples/stm32f4/src/bin/sdmmc.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::mhz; use embassy_stm32::{interrupt, Config}; diff --git a/examples/stm32f4/src/bin/spi_dma.rs b/examples/stm32f4/src/bin/spi_dma.rs index f871c1d3..3d2a1a1a 100644 --- a/examples/stm32f4/src/bin/spi_dma.rs +++ b/examples/stm32f4/src/bin/spi_dma.rs @@ -6,7 +6,7 @@ use core::fmt::Write; use core::str::from_utf8; use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use heapless::String; diff --git a/examples/stm32f4/src/bin/usart_buffered.rs b/examples/stm32f4/src/bin/usart_buffered.rs index 9c269ae2..7bcecbd2 100644 --- a/examples/stm32f4/src/bin/usart_buffered.rs +++ b/examples/stm32f4/src/bin/usart_buffered.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::interrupt; use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; diff --git a/examples/stm32f4/src/bin/usart_dma.rs b/examples/stm32f4/src/bin/usart_dma.rs index febdec6b..bb41b8b4 100644 --- a/examples/stm32f4/src/bin/usart_dma.rs +++ b/examples/stm32f4/src/bin/usart_dma.rs @@ -5,7 +5,7 @@ use core::fmt::Write; use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use heapless::String; diff --git a/examples/stm32f4/src/bin/wdt.rs b/examples/stm32f4/src/bin/wdt.rs index a5128525..b2c587fa 100644 --- a/examples/stm32f4/src/bin/wdt.rs +++ b/examples/stm32f4/src/bin/wdt.rs @@ -3,10 +3,10 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::wdg::IndependentWatchdog; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index 8dde9d4f..29d6da4d 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +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"] } embassy-net = { path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"] } embedded-io = { version = "0.3.0", features = ["async"] } diff --git a/examples/stm32f7/src/bin/adc.rs b/examples/stm32f7/src/bin/adc.rs index a0b9bc57..80fad8c4 100644 --- a/examples/stm32f7/src/bin/adc.rs +++ b/examples/stm32f7/src/bin/adc.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Delay, Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::adc::Adc; +use embassy_time::{Delay, Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f7/src/bin/blinky.rs b/examples/stm32f7/src/bin/blinky.rs index 249bbd88..b27bee4c 100644 --- a/examples/stm32f7/src/bin/blinky.rs +++ b/examples/stm32f7/src/bin/blinky.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f7/src/bin/button_exti.rs b/examples/stm32f7/src/bin/button_exti.rs index 25d3bb9c..dfe587d4 100644 --- a/examples/stm32f7/src/bin/button_exti.rs +++ b/examples/stm32f7/src/bin/button_exti.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index 1ec30353..bdffabcb 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs @@ -3,8 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_net::tcp::TcpSocket; use embassy_net::{Ipv4Address, Stack, StackResources}; use embassy_stm32::eth::generic_smi::GenericSMI; @@ -13,6 +12,7 @@ use embassy_stm32::peripherals::ETH; 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; diff --git a/examples/stm32f7/src/bin/flash.rs b/examples/stm32f7/src/bin/flash.rs index f4d8a1c5..c10781d0 100644 --- a/examples/stm32f7/src/bin/flash.rs +++ b/examples/stm32f7/src/bin/flash.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::flash::Flash; +use embassy_time::{Duration, Timer}; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32f7/src/bin/hello.rs b/examples/stm32f7/src/bin/hello.rs index 26d3555a..c409703f 100644 --- a/examples/stm32f7/src/bin/hello.rs +++ b/examples/stm32f7/src/bin/hello.rs @@ -3,10 +3,10 @@ #![feature(type_alias_impl_trait)] use defmt::info; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::time::Hertz; use embassy_stm32::Config; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32f7/src/bin/sdmmc.rs b/examples/stm32f7/src/bin/sdmmc.rs index 9d97a1de..3bf427ec 100644 --- a/examples/stm32f7/src/bin/sdmmc.rs +++ b/examples/stm32f7/src/bin/sdmmc.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::mhz; use embassy_stm32::{interrupt, Config}; diff --git a/examples/stm32f7/src/bin/usart_dma.rs b/examples/stm32f7/src/bin/usart_dma.rs index 27da10ef..07270479 100644 --- a/examples/stm32f7/src/bin/usart_dma.rs +++ b/examples/stm32f7/src/bin/usart_dma.rs @@ -5,7 +5,7 @@ use core::fmt::Write; use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use heapless::String; diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml index ab5567bb..5c80d43e 100644 --- a/examples/stm32g0/Cargo.toml +++ b/examples/stm32g0/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +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"] } defmt = "0.3" diff --git a/examples/stm32g0/src/bin/blinky.rs b/examples/stm32g0/src/bin/blinky.rs index 249bbd88..b27bee4c 100644 --- a/examples/stm32g0/src/bin/blinky.rs +++ b/examples/stm32g0/src/bin/blinky.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32g0/src/bin/button_exti.rs b/examples/stm32g0/src/bin/button_exti.rs index 8909a1fe..ef32d4c4 100644 --- a/examples/stm32g0/src/bin/button_exti.rs +++ b/examples/stm32g0/src/bin/button_exti.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml index 61150a4e..74c645cf 100644 --- a/examples/stm32g4/Cargo.toml +++ b/examples/stm32g4/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +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"] } embassy-hal-common = {version = "0.1.0", path = "../../embassy-hal-common" } diff --git a/examples/stm32g4/src/bin/blinky.rs b/examples/stm32g4/src/bin/blinky.rs index e905a311..8a65b069 100644 --- a/examples/stm32g4/src/bin/blinky.rs +++ b/examples/stm32g4/src/bin/blinky.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32g4/src/bin/button_exti.rs b/examples/stm32g4/src/bin/button_exti.rs index 25d3bb9c..dfe587d4 100644 --- a/examples/stm32g4/src/bin/button_exti.rs +++ b/examples/stm32g4/src/bin/button_exti.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32g4/src/bin/pwm.rs b/examples/stm32g4/src/bin/pwm.rs index f10da3d6..017e89e4 100644 --- a/examples/stm32g4/src/bin/pwm.rs +++ b/examples/stm32g4/src/bin/pwm.rs @@ -3,11 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; use embassy_stm32::pwm::Channel; use embassy_stm32::time::khz; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 70038d15..a416796e 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "time-tick-32768hz"] } +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"] } embassy-net = { path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16", "unstable-traits"] } embedded-io = { version = "0.3.0", features = ["async"] } diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs index 0715a0f6..0e1e28c7 100644 --- a/examples/stm32h7/src/bin/adc.rs +++ b/examples/stm32h7/src/bin/adc.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Delay, Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::adc::{Adc, SampleTime}; use embassy_stm32::rcc::AdcClockSource; use embassy_stm32::time::mhz; use embassy_stm32::Config; +use embassy_time::{Delay, Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32h7/src/bin/blinky.rs b/examples/stm32h7/src/bin/blinky.rs index be2fa64c..12f08c0f 100644 --- a/examples/stm32h7/src/bin/blinky.rs +++ b/examples/stm32h7/src/bin/blinky.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32h7/src/bin/button_exti.rs b/examples/stm32h7/src/bin/button_exti.rs index 25d3bb9c..dfe587d4 100644 --- a/examples/stm32h7/src/bin/button_exti.rs +++ b/examples/stm32h7/src/bin/button_exti.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32h7/src/bin/camera.rs b/examples/stm32h7/src/bin/camera.rs index a281e75c..9c443b83 100644 --- a/examples/stm32h7/src/bin/camera.rs +++ b/examples/stm32h7/src/bin/camera.rs @@ -2,14 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::dcmi::{self, *}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::i2c::I2c; use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; use embassy_stm32::time::{khz, mhz}; use embassy_stm32::{interrupt, Config}; +use embassy_time::{Duration, Timer}; use ov7725::*; use {defmt_rtt as _, panic_probe as _}; @@ -83,8 +83,8 @@ mod ov7725 { use core::marker::PhantomData; use defmt::Format; - use embassy_executor::time::{Duration, Timer}; use embassy_stm32::rcc::{Mco, McoInstance}; + use embassy_time::{Duration, Timer}; use embedded_hal_async::i2c::I2c; #[repr(u8)] diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 9039b7ee..83210bcb 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs @@ -3,8 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_net::tcp::TcpSocket; use embassy_net::{Ipv4Address, Stack, StackResources}; use embassy_stm32::eth::generic_smi::GenericSMI; @@ -13,6 +12,7 @@ use embassy_stm32::peripherals::ETH; 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; diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs index 25e75d71..99946f50 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.rs @@ -3,8 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_net::tcp::client::{TcpClient, TcpClientState}; use embassy_net::{Stack, StackResources}; use embassy_stm32::eth::generic_smi::GenericSMI; @@ -13,6 +12,7 @@ use embassy_stm32::peripherals::ETH; 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}; diff --git a/examples/stm32h7/src/bin/flash.rs b/examples/stm32h7/src/bin/flash.rs index 2d6f3a16..6682c64d 100644 --- a/examples/stm32h7/src/bin/flash.rs +++ b/examples/stm32h7/src/bin/flash.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::flash::Flash; +use embassy_time::{Duration, Timer}; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32h7/src/bin/fmc.rs b/examples/stm32h7/src/bin/fmc.rs index 1a0d073d..85c690fe 100644 --- a/examples/stm32h7/src/bin/fmc.rs +++ b/examples/stm32h7/src/bin/fmc.rs @@ -3,11 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Delay, Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::fmc::Fmc; use embassy_stm32::time::mhz; use embassy_stm32::Config; +use embassy_time::{Delay, Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index 59648d4b..1972f8ff 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::low_level::AFType; use embassy_stm32::gpio::Speed; use embassy_stm32::pwm::*; use embassy_stm32::time::{khz, mhz, Hertz}; use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32h7/src/bin/mco.rs b/examples/stm32h7/src/bin/mco.rs index 31aa3f33..036455d5 100644 --- a/examples/stm32h7/src/bin/mco.rs +++ b/examples/stm32h7/src/bin/mco.rs @@ -3,10 +3,10 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs index b225d66e..c5c0dd29 100644 --- a/examples/stm32h7/src/bin/pwm.rs +++ b/examples/stm32h7/src/bin/pwm.rs @@ -3,12 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; use embassy_stm32::pwm::Channel; use embassy_stm32::time::{khz, mhz}; use embassy_stm32::Config; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32h7/src/bin/rng.rs b/examples/stm32h7/src/bin/rng.rs index 2c52f4a0..af9be0b6 100644 --- a/examples/stm32h7/src/bin/rng.rs +++ b/examples/stm32h7/src/bin/rng.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::rng::Rng; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32h7/src/bin/sdmmc.rs b/examples/stm32h7/src/bin/sdmmc.rs index f44d88ac..26d1db01 100644 --- a/examples/stm32h7/src/bin/sdmmc.rs +++ b/examples/stm32h7/src/bin/sdmmc.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::mhz; use embassy_stm32::{interrupt, Config}; diff --git a/examples/stm32h7/src/bin/signal.rs b/examples/stm32h7/src/bin/signal.rs index c4ec2b60..be2ac268 100644 --- a/examples/stm32h7/src/bin/signal.rs +++ b/examples/stm32h7/src/bin/signal.rs @@ -3,8 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; +use embassy_time::{Duration, Timer}; use embassy_util::channel::signal::Signal; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index 8f6f1485..c28f937a 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs @@ -7,7 +7,7 @@ use core::str::from_utf8; use cortex_m_rt::entry; use defmt::*; -use embassy_executor::executor::Executor; +use embassy_executor::Executor; use embassy_stm32::dma::NoDma; use embassy_stm32::peripherals::SPI3; use embassy_stm32::time::mhz; diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index d4c91a8e..6c78c194 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs @@ -7,7 +7,7 @@ use core::str::from_utf8; use cortex_m_rt::entry; use defmt::*; -use embassy_executor::executor::Executor; +use embassy_executor::Executor; use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; use embassy_stm32::time::mhz; use embassy_stm32::{spi, Config}; diff --git a/examples/stm32h7/src/bin/usart.rs b/examples/stm32h7/src/bin/usart.rs index e491fb39..1384d54c 100644 --- a/examples/stm32h7/src/bin/usart.rs +++ b/examples/stm32h7/src/bin/usart.rs @@ -4,7 +4,7 @@ use cortex_m_rt::entry; use defmt::*; -use embassy_executor::executor::Executor; +use embassy_executor::Executor; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_util::Forever; diff --git a/examples/stm32h7/src/bin/usart_dma.rs b/examples/stm32h7/src/bin/usart_dma.rs index aacda45b..f8d58bb8 100644 --- a/examples/stm32h7/src/bin/usart_dma.rs +++ b/examples/stm32h7/src/bin/usart_dma.rs @@ -6,7 +6,7 @@ use core::fmt::Write; use cortex_m_rt::entry; use defmt::*; -use embassy_executor::executor::Executor; +use embassy_executor::Executor; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_util::Forever; diff --git a/examples/stm32h7/src/bin/usart_split.rs b/examples/stm32h7/src/bin/usart_split.rs index 7447319e..64080ec4 100644 --- a/examples/stm32h7/src/bin/usart_split.rs +++ b/examples/stm32h7/src/bin/usart_split.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::peripherals::{DMA1_CH1, UART7}; use embassy_stm32::usart::{Config, Uart, UartRx}; diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 367b89db..fdb716d1 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml @@ -9,7 +9,8 @@ nightly = ["embassy-stm32/nightly", "embassy-lora", "lorawan-device", "lorawan", [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +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"] } embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx127x", "time", "defmt"], optional = true} diff --git a/examples/stm32l0/src/bin/blinky.rs b/examples/stm32l0/src/bin/blinky.rs index 06aad4d9..07fad07c 100644 --- a/examples/stm32l0/src/bin/blinky.rs +++ b/examples/stm32l0/src/bin/blinky.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32l0/src/bin/button.rs b/examples/stm32l0/src/bin/button.rs index 14200334..9d194471 100644 --- a/examples/stm32l0/src/bin/button.rs +++ b/examples/stm32l0/src/bin/button.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32l0/src/bin/button_exti.rs b/examples/stm32l0/src/bin/button_exti.rs index bdd2fa3c..af82b995 100644 --- a/examples/stm32l0/src/bin/button_exti.rs +++ b/examples/stm32l0/src/bin/button_exti.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Config; diff --git a/examples/stm32l0/src/bin/flash.rs b/examples/stm32l0/src/bin/flash.rs index f33bd9bb..867cb4d3 100644 --- a/examples/stm32l0/src/bin/flash.rs +++ b/examples/stm32l0/src/bin/flash.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::flash::Flash; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32l0/src/bin/lorawan.rs b/examples/stm32l0/src/bin/lorawan.rs index 9497cad7..303558b9 100644 --- a/examples/stm32l0/src/bin/lorawan.rs +++ b/examples/stm32l0/src/bin/lorawan.rs @@ -6,7 +6,7 @@ #![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_lora::sx127x::*; use embassy_lora::LoraTimer; use embassy_stm32::exti::ExtiInput; diff --git a/examples/stm32l0/src/bin/raw_spawn.rs b/examples/stm32l0/src/bin/raw_spawn.rs index cd711a43..bd87e62a 100644 --- a/examples/stm32l0/src/bin/raw_spawn.rs +++ b/examples/stm32l0/src/bin/raw_spawn.rs @@ -5,9 +5,9 @@ use core::mem; use cortex_m_rt::entry; use defmt::*; -use embassy_executor::executor::raw::TaskStorage; -use embassy_executor::executor::Executor; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::raw::TaskStorage; +use embassy_executor::Executor; +use embassy_time::{Duration, Timer}; use embassy_util::Forever; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32l0/src/bin/spi.rs b/examples/stm32l0/src/bin/spi.rs index e61c642b..9b5b3e27 100644 --- a/examples/stm32l0/src/bin/spi.rs +++ b/examples/stm32l0/src/bin/spi.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; diff --git a/examples/stm32l0/src/bin/usart_dma.rs b/examples/stm32l0/src/bin/usart_dma.rs index b686c410..66657d0f 100644 --- a/examples/stm32l0/src/bin/usart_dma.rs +++ b/examples/stm32l0/src/bin/usart_dma.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::usart::{Config, Uart}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32l0/src/bin/usart_irq.rs b/examples/stm32l0/src/bin/usart_irq.rs index f6d99836..0e223738 100644 --- a/examples/stm32l0/src/bin/usart_irq.rs +++ b/examples/stm32l0/src/bin/usart_irq.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::interrupt; use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml index dba1dd7d..43f844b6 100644 --- a/examples/stm32l1/Cargo.toml +++ b/examples/stm32l1/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +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"] } defmt = "0.3" diff --git a/examples/stm32l1/src/bin/blinky.rs b/examples/stm32l1/src/bin/blinky.rs index 8ecdb7bb..8a345d23 100644 --- a/examples/stm32l1/src/bin/blinky.rs +++ b/examples/stm32l1/src/bin/blinky.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32l1/src/bin/flash.rs b/examples/stm32l1/src/bin/flash.rs index 399b09f9..a76b9879 100644 --- a/examples/stm32l1/src/bin/flash.rs +++ b/examples/stm32l1/src/bin/flash.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::flash::Flash; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32l1/src/bin/spi.rs b/examples/stm32l1/src/bin/spi.rs index 42441615..0a532e8e 100644 --- a/examples/stm32l1/src/bin/spi.rs +++ b/examples/stm32l1/src/bin/spi.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index 1d9c21a0..eaffa253 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml @@ -7,7 +7,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +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" } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l4s5vi", "time-driver-any", "exti", "unstable-traits"] } diff --git a/examples/stm32l4/src/bin/adc.rs b/examples/stm32l4/src/bin/adc.rs index 93a20d5e..281346e5 100644 --- a/examples/stm32l4/src/bin/adc.rs +++ b/examples/stm32l4/src/bin/adc.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::time::Delay; use embassy_stm32::adc::{Adc, Resolution}; use embassy_stm32::pac; +use embassy_time::Delay; use {defmt_rtt as _, panic_probe as _}; #[cortex_m_rt::entry] diff --git a/examples/stm32l4/src/bin/blinky.rs b/examples/stm32l4/src/bin/blinky.rs index 8e360149..033292ff 100644 --- a/examples/stm32l4/src/bin/blinky.rs +++ b/examples/stm32l4/src/bin/blinky.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32l4/src/bin/button_exti.rs b/examples/stm32l4/src/bin/button_exti.rs index 8909a1fe..ef32d4c4 100644 --- a/examples/stm32l4/src/bin/button_exti.rs +++ b/examples/stm32l4/src/bin/button_exti.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32l4/src/bin/i2c.rs b/examples/stm32l4/src/bin/i2c.rs index 177f6baf..d54c080c 100644 --- a/examples/stm32l4/src/bin/i2c.rs +++ b/examples/stm32l4/src/bin/i2c.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::i2c::I2c; use embassy_stm32::interrupt; diff --git a/examples/stm32l4/src/bin/i2c_blocking_async.rs b/examples/stm32l4/src/bin/i2c_blocking_async.rs index 8cc069d0..35a86660 100644 --- a/examples/stm32l4/src/bin/i2c_blocking_async.rs +++ b/examples/stm32l4/src/bin/i2c_blocking_async.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_embedded_hal::adapter::BlockingAsync; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::i2c::I2c; use embassy_stm32::interrupt; diff --git a/examples/stm32l4/src/bin/i2c_dma.rs b/examples/stm32l4/src/bin/i2c_dma.rs index 9323fd53..3ce9398a 100644 --- a/examples/stm32l4/src/bin/i2c_dma.rs +++ b/examples/stm32l4/src/bin/i2c_dma.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::i2c::I2c; use embassy_stm32::interrupt; use embassy_stm32::time::Hertz; diff --git a/examples/stm32l4/src/bin/rng.rs b/examples/stm32l4/src/bin/rng.rs index c9051562..c9302bb9 100644 --- a/examples/stm32l4/src/bin/rng.rs +++ b/examples/stm32l4/src/bin/rng.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; use embassy_stm32::rng::Rng; use embassy_stm32::Config; diff --git a/examples/stm32l4/src/bin/spi_blocking_async.rs b/examples/stm32l4/src/bin/spi_blocking_async.rs index a893cef6..62ef0130 100644 --- a/examples/stm32l4/src/bin/spi_blocking_async.rs +++ b/examples/stm32l4/src/bin/spi_blocking_async.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_embedded_hal::adapter::BlockingAsync; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::spi::{Config, Spi}; diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index 5b19433c..89471db5 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; diff --git a/examples/stm32l4/src/bin/usart_dma.rs b/examples/stm32l4/src/bin/usart_dma.rs index 4b3a9b23..72890689 100644 --- a/examples/stm32l4/src/bin/usart_dma.rs +++ b/examples/stm32l4/src/bin/usart_dma.rs @@ -5,7 +5,7 @@ use core::fmt::Write; use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use heapless::String; diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index 3e3a11d0..4d96d31f 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml @@ -7,7 +7,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +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"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"] } diff --git a/examples/stm32l5/src/bin/button_exti.rs b/examples/stm32l5/src/bin/button_exti.rs index ac394252..e80ad2b3 100644 --- a/examples/stm32l5/src/bin/button_exti.rs +++ b/examples/stm32l5/src/bin/button_exti.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32l5/src/bin/rng.rs b/examples/stm32l5/src/bin/rng.rs index cec9078e..d359847e 100644 --- a/examples/stm32l5/src/bin/rng.rs +++ b/examples/stm32l5/src/bin/rng.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; use embassy_stm32::rng::Rng; use embassy_stm32::Config; diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index 769b67a2..7c53d03c 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs @@ -7,7 +7,7 @@ use core::sync::atomic::{AtomicBool, Ordering}; use core::task::Waker; use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_net::tcp::TcpSocket; use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources}; use embassy_stm32::rcc::*; diff --git a/examples/stm32l5/src/bin/usb_hid_mouse.rs b/examples/stm32l5/src/bin/usb_hid_mouse.rs index ef0a20a4..f7e3d93e 100644 --- a/examples/stm32l5/src/bin/usb_hid_mouse.rs +++ b/examples/stm32l5/src/bin/usb_hid_mouse.rs @@ -4,12 +4,12 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::rcc::*; use embassy_stm32::time::Hertz; use embassy_stm32::usb::Driver; use embassy_stm32::{interrupt, Config, Peripherals}; +use embassy_time::{Duration, Timer}; use embassy_usb::control::OutResponse; use embassy_usb::Builder; use embassy_usb_hid::{HidWriter, ReportId, RequestHandler, State}; diff --git a/examples/stm32l5/src/bin/usb_serial.rs b/examples/stm32l5/src/bin/usb_serial.rs index a763a0b5..323db655 100644 --- a/examples/stm32l5/src/bin/usb_serial.rs +++ b/examples/stm32l5/src/bin/usb_serial.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::{panic, *}; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::rcc::*; use embassy_stm32::time::Hertz; use embassy_stm32::usb::{Driver, Instance}; diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml index d80260f0..48833664 100644 --- a/examples/stm32u5/Cargo.toml +++ b/examples/stm32u5/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +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" ] } defmt = "0.3" diff --git a/examples/stm32u5/src/bin/blinky.rs b/examples/stm32u5/src/bin/blinky.rs index 40054295..976fb0b9 100644 --- a/examples/stm32u5/src/bin/blinky.rs +++ b/examples/stm32u5/src/bin/blinky.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index 59f9401b..b4630076 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +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"] } defmt = "0.3" diff --git a/examples/stm32wb/src/bin/blinky.rs b/examples/stm32wb/src/bin/blinky.rs index 47f126e8..f9bf90d2 100644 --- a/examples/stm32wb/src/bin/blinky.rs +++ b/examples/stm32wb/src/bin/blinky.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32wb/src/bin/button_exti.rs b/examples/stm32wb/src/bin/button_exti.rs index d2816950..3648db6f 100644 --- a/examples/stm32wb/src/bin/button_exti.rs +++ b/examples/stm32wb/src/bin/button_exti.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index f886fae7..ae33478a 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "defmt-timestamp-uptime", "time-tick-32768hz"] } +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"] } embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time", "defmt"] } diff --git a/examples/stm32wl/src/bin/blinky.rs b/examples/stm32wl/src/bin/blinky.rs index 4b8588bb..6af5099c 100644 --- a/examples/stm32wl/src/bin/blinky.rs +++ b/examples/stm32wl/src/bin/blinky.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] diff --git a/examples/stm32wl/src/bin/button_exti.rs b/examples/stm32wl/src/bin/button_exti.rs index ebc25562..1f02db5c 100644 --- a/examples/stm32wl/src/bin/button_exti.rs +++ b/examples/stm32wl/src/bin/button_exti.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32wl/src/bin/flash.rs b/examples/stm32wl/src/bin/flash.rs index 3c4da1e9..eb748976 100644 --- a/examples/stm32wl/src/bin/flash.rs +++ b/examples/stm32wl/src/bin/flash.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::flash::Flash; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32wl/src/bin/lorawan.rs b/examples/stm32wl/src/bin/lorawan.rs index b6a3ca90..7e8a8946 100644 --- a/examples/stm32wl/src/bin/lorawan.rs +++ b/examples/stm32wl/src/bin/lorawan.rs @@ -5,7 +5,7 @@ #![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_lora::stm32wl::*; use embassy_lora::LoraTimer; use embassy_stm32::dma::NoDma; diff --git a/examples/stm32wl/src/bin/subghz.rs b/examples/stm32wl/src/bin/subghz.rs index 1b096514..d16e3f5e 100644 --- a/examples/stm32wl/src/bin/subghz.rs +++ b/examples/stm32wl/src/bin/subghz.rs @@ -6,7 +6,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml index 20433689..c7f98036 100644 --- a/examples/wasm/Cargo.toml +++ b/examples/wasm/Cargo.toml @@ -8,7 +8,8 @@ crate-type = ["cdylib"] [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["log"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "wasm", "nightly"] } +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"] } wasm-logger = "0.2.0" wasm-bindgen = "0.2" diff --git a/examples/wasm/src/lib.rs b/examples/wasm/src/lib.rs index 2e961e65..d44c020b 100644 --- a/examples/wasm/src/lib.rs +++ b/examples/wasm/src/lib.rs @@ -1,8 +1,8 @@ #![feature(type_alias_impl_trait)] #![allow(incomplete_features)] -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Timer}; +use embassy_executor::Spawner; +use embassy_time::{Duration, Timer}; #[embassy_executor::task] async fn ticker() { diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index d105f0e6..8740cc48 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -5,7 +5,8 @@ version = "0.1.0" [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", 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"] } embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["nightly", "defmt", "unstable-pac", "unstable-traits"] } defmt = "0.3.0" diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs index 2d1a2ee5..af22fe27 100644 --- a/tests/rp/src/bin/gpio.rs +++ b/tests/rp/src/bin/gpio.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::{assert, *}; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_rp::gpio::{Flex, Input, Level, Output, OutputOpenDrain, Pull}; use {defmt_rtt as _, panic_probe as _}; diff --git a/tests/rp/src/bin/gpio_async.rs b/tests/rp/src/bin/gpio_async.rs index d8878687..1eeaac1f 100644 --- a/tests/rp/src/bin/gpio_async.rs +++ b/tests/rp/src/bin/gpio_async.rs @@ -3,9 +3,9 @@ #![feature(type_alias_impl_trait)] use defmt::{assert, *}; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Instant, Timer}; +use embassy_executor::Spawner; use embassy_rp::gpio::{Input, Level, Output, Pull}; +use embassy_time::{Duration, Instant, Timer}; use futures::future::join; use {defmt_rtt as _, panic_probe as _}; diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 5fc67e13..1d12995a 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -14,7 +14,8 @@ stm32u585ai = ["embassy-stm32/stm32u585ai"] # IoT board [dependencies] embassy-util = { version = "0.1.0", path = "../../embassy-util", features = ["defmt"] } -embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "time-tick-32768hz"] } +embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } +embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "tick-32768hz"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "memory-x", "time-driver-tim2"] } defmt = "0.3.0" diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index dc7223c6..18fd85d4 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs @@ -5,7 +5,7 @@ #[path = "../example_common.rs"] mod example_common; use defmt::assert; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::gpio::{Flex, Input, Level, Output, OutputOpenDrain, Pull, Speed}; use example_common::*; diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs index 2c0b7fc4..1c5dc87c 100644 --- a/tests/stm32/src/bin/spi.rs +++ b/tests/stm32/src/bin/spi.rs @@ -5,7 +5,7 @@ #[path = "../example_common.rs"] mod example_common; use defmt::assert_eq; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::spi::{self, Spi}; use embassy_stm32::time::Hertz; diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs index af1118b5..cb2152e0 100644 --- a/tests/stm32/src/bin/spi_dma.rs +++ b/tests/stm32/src/bin/spi_dma.rs @@ -5,7 +5,7 @@ #[path = "../example_common.rs"] mod example_common; use defmt::assert_eq; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::spi::{self, Spi}; use embassy_stm32::time::Hertz; use example_common::*; diff --git a/tests/stm32/src/bin/timer.rs b/tests/stm32/src/bin/timer.rs index 34903084..e00e43bf 100644 --- a/tests/stm32/src/bin/timer.rs +++ b/tests/stm32/src/bin/timer.rs @@ -5,8 +5,8 @@ #[path = "../example_common.rs"] mod example_common; use defmt::assert; -use embassy_executor::executor::Spawner; -use embassy_executor::time::{Duration, Instant, Timer}; +use embassy_executor::Spawner; +use embassy_time::{Duration, Instant, Timer}; use example_common::*; #[embassy_executor::main] diff --git a/tests/stm32/src/bin/usart.rs b/tests/stm32/src/bin/usart.rs index f454c1f7..fb4b3fcc 100644 --- a/tests/stm32/src/bin/usart.rs +++ b/tests/stm32/src/bin/usart.rs @@ -5,7 +5,7 @@ #[path = "../example_common.rs"] mod example_common; use defmt::assert_eq; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use example_common::*; diff --git a/tests/stm32/src/bin/usart_dma.rs b/tests/stm32/src/bin/usart_dma.rs index fbaccd17..09382a02 100644 --- a/tests/stm32/src/bin/usart_dma.rs +++ b/tests/stm32/src/bin/usart_dma.rs @@ -5,7 +5,7 @@ #[path = "../example_common.rs"] mod example_common; use defmt::assert_eq; -use embassy_executor::executor::Spawner; +use embassy_executor::Spawner; use embassy_stm32::usart::{Config, Uart}; use example_common::*; From d52c7ded49e4584e678a54f2870a4d855e24ee01 Mon Sep 17 00:00:00 2001 From: Mathias Date: Thu, 18 Aug 2022 10:14:37 +0200 Subject: [PATCH 28/31] Implement remaining logic for blocking UART. async is still todo, awaiting DMA --- embassy-rp/Cargo.toml | 2 + embassy-rp/src/dma.rs | 6 + embassy-rp/src/uart.rs | 401 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 371 insertions(+), 38 deletions(-) diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index 303617ff..b4dab7f4 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -36,6 +36,8 @@ embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["r atomic-polyfill = "0.1.5" defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } +nb = "1.0.0" +cfg-if = "1.0.0" cortex-m-rt = ">=0.6.15,<0.8" cortex-m = "0.7.3" critical-section = "0.2.5" diff --git a/embassy-rp/src/dma.rs b/embassy-rp/src/dma.rs index 235e92d7..42c4fd13 100644 --- a/embassy-rp/src/dma.rs +++ b/embassy-rp/src/dma.rs @@ -1,5 +1,7 @@ use core::sync::atomic::{compiler_fence, Ordering}; +use embassy_hal_common::impl_peripheral; + use crate::pac::dma::vals; use crate::{pac, peripherals}; @@ -35,6 +37,10 @@ impl Dma { } } +pub struct NoDma; + +impl_peripheral!(NoDma); + mod sealed { use super::*; diff --git a/embassy-rp/src/uart.rs b/embassy-rp/src/uart.rs index b19f043f..db135d04 100644 --- a/embassy-rp/src/uart.rs +++ b/embassy-rp/src/uart.rs @@ -1,42 +1,199 @@ -use embassy_hal_common::{into_ref, PeripheralRef}; -use gpio::Pin; +use core::marker::PhantomData; -use crate::{gpio, pac, peripherals, Peripheral}; +use embassy_hal_common::{into_ref, PeripheralRef}; + +use crate::gpio::sealed::Pin; +use crate::gpio::AnyPin; +use crate::{pac, peripherals, Peripheral}; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum DataBits { + DataBits5, + DataBits6, + DataBits7, + DataBits8, +} + +impl DataBits { + fn bits(&self) -> u8 { + match self { + Self::DataBits5 => 0b00, + Self::DataBits6 => 0b01, + Self::DataBits7 => 0b10, + Self::DataBits8 => 0b11, + } + } +} + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum Parity { + ParityNone, + ParityEven, + ParityOdd, +} + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum StopBits { + #[doc = "1 stop bit"] + STOP1, + #[doc = "2 stop bits"] + STOP2, +} #[non_exhaustive] +#[derive(Clone, Copy, PartialEq, Eq, Debug)] pub struct Config { pub baudrate: u32, - pub data_bits: u8, - pub stop_bits: u8, + pub data_bits: DataBits, + pub stop_bits: StopBits, + pub parity: Parity, } impl Default for Config { fn default() -> Self { Self { baudrate: 115200, - data_bits: 8, - stop_bits: 1, + data_bits: DataBits::DataBits8, + stop_bits: StopBits::STOP1, + parity: Parity::ParityNone, } } } +/// Serial error +#[derive(Debug, Eq, PartialEq, Copy, Clone)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[non_exhaustive] +pub enum Error { + /// Triggered when the FIFO (or shift-register) is overflowed. + Overrun, + /// Triggered when a break is received + Break, + /// Triggered when there is a parity mismatch between what's received and + /// our settings. + Parity, + /// Triggered when the received character didn't have a valid stop bit. + Framing, +} + pub struct Uart<'d, T: Instance> { - inner: PeripheralRef<'d, T>, + tx: UartTx<'d, T>, + rx: UartRx<'d, T>, +} + +pub struct UartTx<'d, T: Instance> { + phantom: PhantomData<&'d mut T>, +} + +pub struct UartRx<'d, T: Instance> { + phantom: PhantomData<&'d mut T>, +} + +impl<'d, T: Instance> UartTx<'d, T> { + fn new() -> Self { + Self { phantom: PhantomData } + } + + pub async fn write(&mut self, _buffer: &[u8]) -> Result<(), Error> { + todo!() + } + + pub fn blocking_write(&mut self, buffer: &[u8]) -> Result<(), Error> { + let r = T::regs(); + unsafe { + for &b in buffer { + while r.uartfr().read().txff() {} + r.uartdr().write(|w| w.set_data(b)); + } + } + Ok(()) + } + + pub fn blocking_flush(&mut self) -> Result<(), Error> { + let r = T::regs(); + unsafe { while r.uartfr().read().txff() {} } + Ok(()) + } +} + +impl<'d, T: Instance> UartRx<'d, T> { + fn new() -> Self { + Self { phantom: PhantomData } + } + + pub async fn read(&mut self, _buffer: &mut [u8]) -> Result<(), Error> { + todo!(); + } + + pub fn blocking_read(&mut self, buffer: &mut [u8]) -> Result<(), Error> { + let r = T::regs(); + unsafe { + for b in buffer { + *b = loop { + let dr = r.uartdr().read(); + + if dr.oe() { + return Err(Error::Overrun); + } else if dr.be() { + return Err(Error::Break); + } else if dr.pe() { + return Err(Error::Parity); + } else if dr.fe() { + return Err(Error::Framing); + } else if dr.fe() { + break dr.data(); + } + }; + } + } + Ok(()) + } } impl<'d, T: Instance> Uart<'d, T> { + /// Create a new UARTE without hardware flow control pub fn new( - inner: impl Peripheral

+ 'd, + uart: impl Peripheral

+ 'd, + tx: impl Peripheral

> + 'd, + rx: impl Peripheral

> + 'd, + config: Config, + ) -> Self { + into_ref!(tx, rx); + Self::new_inner(uart, rx.map_into(), tx.map_into(), None, None, config) + } + + /// Create a new UART with hardware flow control (RTS/CTS) + pub fn new_with_rtscts( + uart: impl Peripheral

+ 'd, tx: impl Peripheral

> + 'd, rx: impl Peripheral

> + 'd, cts: impl Peripheral

> + 'd, rts: impl Peripheral

> + 'd, config: Config, ) -> Self { - into_ref!(inner, tx, rx, cts, rts); + into_ref!(tx, rx, cts, rts); + Self::new_inner( + uart, + rx.map_into(), + tx.map_into(), + Some(cts.map_into()), + Some(rts.map_into()), + config, + ) + } + + fn new_inner( + _uart: impl Peripheral

+ 'd, + tx: PeripheralRef<'d, AnyPin>, + rx: PeripheralRef<'d, AnyPin>, + cts: Option>, + rts: Option>, + config: Config, + ) -> Self { + into_ref!(_uart); unsafe { - let p = inner.regs(); + let r = T::regs(); let clk_base = crate::clocks::clk_peri_freq(); @@ -53,49 +210,217 @@ impl<'d, T: Instance> Uart<'d, T> { } // Load PL011's baud divisor registers - p.uartibrd().write_value(pac::uart::regs::Uartibrd(baud_ibrd)); - p.uartfbrd().write_value(pac::uart::regs::Uartfbrd(baud_fbrd)); + r.uartibrd().write_value(pac::uart::regs::Uartibrd(baud_ibrd)); + r.uartfbrd().write_value(pac::uart::regs::Uartfbrd(baud_fbrd)); - p.uartlcr_h().write(|w| { - w.set_wlen(config.data_bits - 5); - w.set_stp2(config.stop_bits == 2); - w.set_pen(false); - w.set_eps(false); + let (pen, eps) = match config.parity { + Parity::ParityNone => (false, false), + Parity::ParityEven => (true, true), + Parity::ParityOdd => (true, false), + }; + + r.uartlcr_h().write(|w| { + w.set_wlen(config.data_bits.bits()); + w.set_stp2(config.stop_bits == StopBits::STOP2); + w.set_pen(pen); + w.set_eps(eps); w.set_fen(true); }); - p.uartcr().write(|w| { + r.uartcr().write(|w| { w.set_uarten(true); w.set_rxe(true); w.set_txe(true); + w.set_ctsen(cts.is_some()); + w.set_rtsen(rts.is_some()); }); tx.io().ctrl().write(|w| w.set_funcsel(2)); rx.io().ctrl().write(|w| w.set_funcsel(2)); - cts.io().ctrl().write(|w| w.set_funcsel(2)); - rts.io().ctrl().write(|w| w.set_funcsel(2)); + if let Some(pin) = &cts { + pin.io().ctrl().write(|w| w.set_funcsel(2)); + } + if let Some(pin) = &rts { + pin.io().ctrl().write(|w| w.set_funcsel(2)); + } + } + + Self { + tx: UartTx::new(), + rx: UartRx::new(), } - Self { inner } } - pub fn send(&mut self, data: &[u8]) { - unsafe { - let p = self.inner.regs(); + pub async fn write(&mut self, buffer: &[u8]) -> Result<(), Error> { + self.tx.write(buffer).await + } - for &byte in data { - if !p.uartfr().read().txff() { - p.uartdr().write(|w| w.set_data(byte)); + pub fn blocking_write(&mut self, buffer: &[u8]) -> Result<(), Error> { + self.tx.blocking_write(buffer) + } + + pub fn blocking_flush(&mut self) -> Result<(), Error> { + self.tx.blocking_flush() + } + + pub async fn read(&mut self, buffer: &mut [u8]) -> Result<(), Error> { + self.rx.read(buffer).await + } + + pub fn blocking_read(&mut self, buffer: &mut [u8]) -> Result<(), Error> { + self.rx.blocking_read(buffer) + } + + /// Split the Uart into a transmitter and receiver, which is + /// particuarly useful when having two tasks correlating to + /// transmitting and receiving. + pub fn split(self) -> (UartTx<'d, T>, UartRx<'d, T>) { + (self.tx, self.rx) + } +} + +mod eh02 { + use super::*; + + impl<'d, T: Instance> embedded_hal_02::serial::Read for UartRx<'d, T> { + type Error = Error; + fn read(&mut self) -> Result> { + let r = T::regs(); + unsafe { + let dr = r.uartdr().read(); + + if dr.oe() { + Err(nb::Error::Other(Error::Overrun)) + } else if dr.be() { + Err(nb::Error::Other(Error::Break)) + } else if dr.pe() { + Err(nb::Error::Other(Error::Parity)) + } else if dr.fe() { + Err(nb::Error::Other(Error::Framing)) + } else if dr.fe() { + Ok(dr.data()) + } else { + Err(nb::Error::WouldBlock) } } } } + + impl<'d, T: Instance> embedded_hal_02::blocking::serial::Write for UartTx<'d, T> { + type Error = Error; + fn bwrite_all(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { + self.blocking_write(buffer) + } + fn bflush(&mut self) -> Result<(), Self::Error> { + self.blocking_flush() + } + } + + impl<'d, T: Instance> embedded_hal_02::serial::Read for Uart<'d, T> { + type Error = Error; + fn read(&mut self) -> Result> { + embedded_hal_02::serial::Read::read(&mut self.rx) + } + } + + impl<'d, T: Instance> embedded_hal_02::blocking::serial::Write for Uart<'d, T> { + type Error = Error; + fn bwrite_all(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { + self.blocking_write(buffer) + } + fn bflush(&mut self) -> Result<(), Self::Error> { + self.blocking_flush() + } + } +} + +#[cfg(feature = "unstable-traits")] +mod eh1 { + use super::*; + + impl embedded_hal_1::serial::Error for Error { + fn kind(&self) -> embedded_hal_1::serial::ErrorKind { + match *self { + Self::Framing => embedded_hal_1::serial::ErrorKind::FrameFormat, + Self::Break => embedded_hal_1::serial::ErrorKind::Other, + Self::Overrun => embedded_hal_1::serial::ErrorKind::Overrun, + Self::Parity => embedded_hal_1::serial::ErrorKind::Parity, + } + } + } + + impl<'d, T: Instance> embedded_hal_1::serial::ErrorType for Uart<'d, T> { + type Error = Error; + } + + impl<'d, T: Instance> embedded_hal_1::serial::ErrorType for UartTx<'d, T> { + type Error = Error; + } + + impl<'d, T: Instance> embedded_hal_1::serial::ErrorType for UartRx<'d, T> { + type Error = Error; + } +} + +cfg_if::cfg_if! { + if #[cfg(all(feature = "unstable-traits", feature = "nightly", feature = "_todo_embedded_hal_serial"))] { + use core::future::Future; + + impl<'d, T: Instance> embedded_hal_async::serial::Write for UartTx<'d, T> + { + type WriteFuture<'a> = impl Future> + 'a where Self: 'a; + + fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { + self.write(buf) + } + + type FlushFuture<'a> = impl Future> + 'a where Self: 'a; + + fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { + async move { Ok(()) } + } + } + + impl<'d, T: Instance> embedded_hal_async::serial::Read for UartRx<'d, T> + { + type ReadFuture<'a> = impl Future> + 'a where Self: 'a; + + fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { + self.read(buf) + } + } + + impl<'d, T: Instance> embedded_hal_async::serial::Write for Uart<'d, T> + { + type WriteFuture<'a> = impl Future> + 'a where Self: 'a; + + fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a> { + self.write(buf) + } + + type FlushFuture<'a> = impl Future> + 'a where Self: 'a; + + fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { + async move { Ok(()) } + } + } + + impl<'d, T: Instance> embedded_hal_async::serial::Read for Uart<'d, T> + { + type ReadFuture<'a> = impl Future> + 'a where Self: 'a; + + fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Self::ReadFuture<'a> { + self.read(buf) + } + } + } } mod sealed { use super::*; pub trait Instance { - fn regs(&self) -> pac::uart::Uart; + fn regs() -> pac::uart::Uart; } pub trait TxPin {} pub trait RxPin {} @@ -106,23 +431,23 @@ mod sealed { pub trait Instance: sealed::Instance {} macro_rules! impl_instance { - ($type:ident, $irq:ident) => { - impl sealed::Instance for peripherals::$type { - fn regs(&self) -> pac::uart::Uart { - pac::$type + ($inst:ident, $irq:ident) => { + impl sealed::Instance for peripherals::$inst { + fn regs() -> pac::uart::Uart { + pac::$inst } } - impl Instance for peripherals::$type {} + impl Instance for peripherals::$inst {} }; } impl_instance!(UART0, UART0); impl_instance!(UART1, UART1); -pub trait TxPin: sealed::TxPin + Pin {} -pub trait RxPin: sealed::RxPin + Pin {} -pub trait CtsPin: sealed::CtsPin + Pin {} -pub trait RtsPin: sealed::RtsPin + Pin {} +pub trait TxPin: sealed::TxPin + crate::gpio::Pin {} +pub trait RxPin: sealed::RxPin + crate::gpio::Pin {} +pub trait CtsPin: sealed::CtsPin + crate::gpio::Pin {} +pub trait RtsPin: sealed::RtsPin + crate::gpio::Pin {} macro_rules! impl_pin { ($pin:ident, $instance:ident, $function:ident) => { From fe38d240e5903a26ed35c25fbaf30e7a31420870 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 18 Aug 2022 11:10:51 +0200 Subject: [PATCH 29/31] hal-common: Remove unused dep --- embassy-hal-common/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/embassy-hal-common/Cargo.toml b/embassy-hal-common/Cargo.toml index 4a6a6100..58f0af6a 100644 --- a/embassy-hal-common/Cargo.toml +++ b/embassy-hal-common/Cargo.toml @@ -9,5 +9,4 @@ edition = "2021" defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } -embassy-util = { version = "0.1.0", path = "../embassy-util" } num-traits = { version = "0.2.14", default-features = false } From 0f74f870b00942a3020a32d44470edf80870676c Mon Sep 17 00:00:00 2001 From: Mathias Date: Thu, 18 Aug 2022 11:47:15 +0200 Subject: [PATCH 30/31] Fix rp uart example --- embassy-rp/src/uart.rs | 2 +- examples/rp/src/bin/uart.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/embassy-rp/src/uart.rs b/embassy-rp/src/uart.rs index db135d04..6c5ab351 100644 --- a/embassy-rp/src/uart.rs +++ b/embassy-rp/src/uart.rs @@ -151,7 +151,7 @@ impl<'d, T: Instance> UartRx<'d, T> { } impl<'d, T: Instance> Uart<'d, T> { - /// Create a new UARTE without hardware flow control + /// Create a new UART without hardware flow control pub fn new( uart: impl Peripheral

+ 'd, tx: impl Peripheral

> + 'd, diff --git a/examples/rp/src/bin/uart.rs b/examples/rp/src/bin/uart.rs index 0d295489..b7014c55 100644 --- a/examples/rp/src/bin/uart.rs +++ b/examples/rp/src/bin/uart.rs @@ -9,11 +9,11 @@ use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] async fn main(_spawner: Spawner, p: Peripherals) { 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()); + let mut uart = uart::Uart::new_with_rtscts(p.UART0, p.PIN_0, p.PIN_1, p.PIN_2, p.PIN_3, config); + uart.blocking_write("Hello World!\r\n".as_bytes()).unwrap(); loop { - uart.send("hello there!\r\n".as_bytes()); + uart.blocking_write("hello there!\r\n".as_bytes()).unwrap(); cortex_m::asm::delay(1_000_000); } } From ce407474a7d6f3f859493523a53dc0ac7cbe27d6 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 18 Aug 2022 14:45:07 +0200 Subject: [PATCH 31/31] net: update atomic-pool, atomic-polyfill. --- embassy-net/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index 1ce4479a..9f9bb226 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml @@ -47,8 +47,8 @@ as-slice = "0.2.1" generic-array = { version = "0.14.4", default-features = false } stable_deref_trait = { version = "1.2.0", default-features = false } futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] } -atomic-pool = "0.2.1" -atomic-polyfill = "0.1.5" +atomic-pool = "1.0" +atomic-polyfill = "1.0.1" embedded-nal-async = "0.2.0" [dependencies.smoltcp]