diff --git a/.vscode/settings.json b/.vscode/settings.json index 3defc907..79433a7c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,16 +4,19 @@ "rust-analyzer.assist.importGranularity": "module", "rust-analyzer.checkOnSave.allFeatures": false, "rust-analyzer.checkOnSave.allTargets": false, - "rust-analyzer.checkOnSave.command": "clippy", + "rust-analyzer.checkOnSave.noDefaultFeatures": true, + "rust-analyzer.cargo.allFeatures": false, "rust-analyzer.cargo.noDefaultFeatures": true, "rust-analyzer.experimental.procAttrMacros": false, - "rust-analyzer.checkOnSave.noDefaultFeatures": true, + "rust-analyzer.procMacro.enable": true, + "rust-analyzer.cargo.runBuildScripts": true, "rust-analyzer.cargo.target": "thumbv7em-none-eabi", "rust-analyzer.cargo.features": [ // These are needed to prevent embassy-net from failing to build //"embassy-net/medium-ethernet", //"embassy-net/tcp", //"embassy-net/pool-16", + "nightly", ], "rust-analyzer.linkedProjects": [ // Declare for the target you wish to develop @@ -35,12 +38,4 @@ // "examples/stm32wl55/Cargo.toml", // "examples/wasm/Cargo.toml", ], - "rust-analyzer.procMacro.enable": true, - "rust-analyzer.cargo.runBuildScripts": true, - "files.watcherExclude": { - "**/.git/objects/**": true, - "**/.git/subtree-cache/**": true, - "**/target/**": true - }, - "git.ignoreLimitWarning": true } \ No newline at end of file diff --git a/ci.sh b/ci.sh index 452130be..cd0db286 100755 --- a/ci.sh +++ b/ci.sh @@ -24,24 +24,24 @@ rm -rf stm32-metapac mv stm32-metapac-gen/out stm32-metapac cargo batch \ - --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi \ - --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features log,executor-agnostic \ - --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features defmt \ - --- build --release --manifest-path embassy/Cargo.toml --target thumbv6m-none-eabi --features defmt \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52805,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52810,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52811,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52820,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52832,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52833,gpiote,time-driver-rtc1,unstable-traits \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160-s,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160-ns,gpiote,time-driver-rtc1,unstable-traits \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-app-s,gpiote,time-driver-rtc1,unstable-traits \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-app-ns,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-net,gpiote,time-driver-rtc1,unstable-traits \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,log,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,defmt,gpiote,time-driver-rtc1,unstable-traits \ + --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features nightly \ + --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features nightly,log,executor-agnostic \ + --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features nightly,defmt \ + --- build --release --manifest-path embassy/Cargo.toml --target thumbv6m-none-eabi --features nightly,defmt \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52805,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52810,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52811,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52820,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52832,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52833,gpiote,time-driver-rtc1,unstable-traits \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf9160-s,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf9160-ns,gpiote,time-driver-rtc1,unstable-traits \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf5340-app-s,gpiote,time-driver-rtc1,unstable-traits \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf5340-app-ns,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf5340-net,gpiote,time-driver-rtc1,unstable-traits \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52840,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52840,log,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52840,defmt,gpiote,time-driver-rtc1,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any \ diff --git a/docs/modules/ROOT/examples/basic/Cargo.toml b/docs/modules/ROOT/examples/basic/Cargo.toml index 0f1c30da..ed1c3cb1 100644 --- a/docs/modules/ROOT/examples/basic/Cargo.toml +++ b/docs/modules/ROOT/examples/basic/Cargo.toml @@ -5,8 +5,8 @@ name = "embassy-basic-example" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../../../../embassy", features = ["defmt"] } -embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote"] } +embassy = { version = "0.1.0", path = "../../../../../embassy", features = ["defmt", "nightly"] } +embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "nightly"] } defmt = "0.3" defmt-rtt = "0.3" diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 4ed922ba..5ced9b1b 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -6,14 +6,18 @@ edition = "2018" [features] +# Enable nightly-only features +nightly = ["embassy/nightly", "embedded-hal-1", "embedded-hal-async"] + # Reexport the PAC for the currently enabled chip at `embassy_nrf::pac`. # This is unstable because semver-minor (non-breaking) releases of embassy-nrf may major-bump (breaking) the PAC version. # If this is an issue for you, you're encouraged to directly depend on a fixed version of the PAC. # There are no plans to make this stable. unstable-pac = [] -# Implement embedded-hal 1.0 alpha and embedded-hal-async traits. -unstable-traits = ["embedded-hal-1", "embedded-hal-async"] +# Implement embedded-hal 1.0 alpha traits. +# Implement embedded-hal-async traits if `nightly` is set as well. +unstable-traits = ["embedded-hal-1"] nrf52805 = ["nrf52805-pac", "_ppi"] nrf52810 = ["nrf52810-pac", "_ppi"] diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index a4c24058..b856c2df 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs @@ -463,7 +463,6 @@ mod eh02 { #[cfg(feature = "unstable-traits")] mod eh1 { use super::*; - use futures::FutureExt; impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::ErrorType for InputChannel<'d, C, T> { type Error = Infallible; @@ -480,6 +479,12 @@ mod eh1 { self.pin.is_low() } } +} + +#[cfg(all(feature = "unstable-traits", feature = "nightly"))] +mod eh1a { + use super::*; + use futures::FutureExt; impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> { type WaitForHighFuture<'a> diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index 8e05d9b6..b448f6ab 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs @@ -1,6 +1,8 @@ #![no_std] -#![feature(generic_associated_types)] -#![feature(type_alias_impl_trait)] +#![cfg_attr( + feature = "nightly", + feature(generic_associated_types, type_alias_impl_trait) +)] #[cfg(not(any( feature = "nrf51", diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index cd43b26e..aac20e17 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs @@ -333,7 +333,6 @@ mod eh02 { #[cfg(feature = "unstable-traits")] mod eh1 { use super::*; - use core::future::Future; impl embedded_hal_1::spi::Error for Error { fn kind(&self) -> embedded_hal_1::spi::ErrorKind { @@ -396,7 +395,7 @@ mod eh1 { fn transaction<'a>( &mut self, - operations: &mut [embedded_hal_async::spi::Operation<'a, u8>], + operations: &mut [embedded_hal_1::spi::blocking::Operation<'a, u8>], ) -> Result<(), Self::Error> { use embedded_hal_1::spi::blocking::Operation; for o in operations { @@ -410,6 +409,12 @@ mod eh1 { Ok(()) } } +} + +#[cfg(all(feature = "unstable-traits", feature = "nightly"))] +mod eh1a { + use super::*; + use core::future::Future; impl<'d, T: Instance> embedded_hal_async::spi::Read for Spim<'d, T> { type ReadFuture<'a> diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs index 4cd47c89..ed2844f7 100644 --- a/embassy-nrf/src/twim.rs +++ b/embassy-nrf/src/twim.rs @@ -679,7 +679,7 @@ mod eh1 { fn transaction<'a>( &mut self, _address: u8, - _operations: &mut [embedded_hal_async::i2c::Operation<'a>], + _operations: &mut [embedded_hal_1::i2c::blocking::Operation<'a>], ) -> Result<(), Self::Error> { todo!(); } @@ -690,58 +690,59 @@ mod eh1 { _operations: O, ) -> Result<(), Self::Error> where - O: IntoIterator>, + O: IntoIterator>, { todo!(); } } +} - impl<'d, T: Instance> embedded_hal_async::i2c::I2c for Twim<'d, T> { - type ReadFuture<'a> - where - Self: 'a, - = impl Future> + 'a; +#[cfg(all(feature = "unstable-traits", feature = "nightly"))] +impl<'d, T: Instance> embedded_hal_async::i2c::I2c for Twim<'d, T> { + type ReadFuture<'a> + where + Self: 'a, + = impl Future> + 'a; - fn read<'a>(&'a mut self, address: u8, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { - self.read(address, buffer) - } + fn read<'a>(&'a mut self, address: u8, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { + self.read(address, buffer) + } - type WriteFuture<'a> - where - Self: 'a, - = impl Future> + 'a; + type WriteFuture<'a> + where + Self: 'a, + = impl Future> + 'a; - fn write<'a>(&'a mut self, address: u8, bytes: &'a [u8]) -> Self::WriteFuture<'a> { - self.write(address, bytes) - } + fn write<'a>(&'a mut self, address: u8, bytes: &'a [u8]) -> Self::WriteFuture<'a> { + self.write(address, bytes) + } - type WriteReadFuture<'a> - where - Self: 'a, - = impl Future> + 'a; + type WriteReadFuture<'a> + where + Self: 'a, + = impl Future> + 'a; - fn write_read<'a>( - &'a mut self, - address: u8, - wr_buffer: &'a [u8], - rd_buffer: &'a mut [u8], - ) -> Self::WriteReadFuture<'a> { - self.write_read(address, wr_buffer, rd_buffer) - } + fn write_read<'a>( + &'a mut self, + address: u8, + wr_buffer: &'a [u8], + rd_buffer: &'a mut [u8], + ) -> Self::WriteReadFuture<'a> { + self.write_read(address, wr_buffer, rd_buffer) + } - type TransactionFuture<'a> - where - Self: 'a, - = impl Future> + 'a; + type TransactionFuture<'a> + where + Self: 'a, + = impl Future> + 'a; - fn transaction<'a>( - &'a mut self, - address: u8, - operations: &mut [embedded_hal_async::i2c::Operation<'a>], - ) -> Self::TransactionFuture<'a> { - let _ = address; - let _ = operations; - async move { todo!() } - } + fn transaction<'a>( + &'a mut self, + address: u8, + operations: &mut [embedded_hal_async::i2c::Operation<'a>], + ) -> Self::TransactionFuture<'a> { + let _ = address; + let _ = operations; + async move { todo!() } } } diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index b10e55a0..c7177dc2 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs @@ -760,7 +760,6 @@ mod eh02 { #[cfg(feature = "unstable-traits")] mod eh1 { use super::*; - use core::future::Future; impl embedded_hal_1::serial::Error for Error { fn kind(&self) -> embedded_hal_1::serial::ErrorKind { @@ -788,6 +787,36 @@ mod eh1 { } } + impl<'d, T: Instance> embedded_hal_1::serial::ErrorType for UarteTx<'d, T> { + type Error = Error; + } + + impl<'d, T: Instance> embedded_hal_1::serial::blocking::Write for UarteTx<'d, T> { + fn write(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { + self.blocking_write(buffer) + } + + fn flush(&mut self) -> Result<(), Self::Error> { + Ok(()) + } + } + + impl<'d, T: Instance> embedded_hal_1::serial::ErrorType for UarteRx<'d, T> { + type Error = Error; + } + + impl<'d, U: Instance, T: TimerInstance> embedded_hal_1::serial::ErrorType + for UarteWithIdle<'d, U, T> + { + type Error = Error; + } +} + +#[cfg(all(feature = "unstable-traits", feature = "nightly"))] +mod eh1a { + use super::*; + use core::future::Future; + impl<'d, T: Instance> embedded_hal_async::serial::Read for Uarte<'d, T> { type ReadFuture<'a> where @@ -819,22 +848,6 @@ mod eh1 { } } - // ===================== - - impl<'d, T: Instance> embedded_hal_1::serial::ErrorType for UarteTx<'d, T> { - type Error = Error; - } - - impl<'d, T: Instance> embedded_hal_1::serial::blocking::Write for UarteTx<'d, T> { - fn write(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { - self.blocking_write(buffer) - } - - fn flush(&mut self) -> Result<(), Self::Error> { - Ok(()) - } - } - impl<'d, T: Instance> embedded_hal_async::serial::Write for UarteTx<'d, T> { type WriteFuture<'a> where @@ -855,12 +868,6 @@ mod eh1 { } } - // ===================== - - impl<'d, T: Instance> embedded_hal_1::serial::ErrorType for UarteRx<'d, T> { - type Error = Error; - } - impl<'d, T: Instance> embedded_hal_async::serial::Read for UarteRx<'d, T> { type ReadFuture<'a> where @@ -872,14 +879,6 @@ mod eh1 { } } - // ===================== - - impl<'d, U: Instance, T: TimerInstance> embedded_hal_1::serial::ErrorType - for UarteWithIdle<'d, U, T> - { - type Error = Error; - } - impl<'d, U: Instance, T: TimerInstance> embedded_hal_async::serial::Read for UarteWithIdle<'d, U, T> { diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index be41f95e..cb654402 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -13,7 +13,7 @@ edition = "2018" unstable-pac = [] [dependencies] -embassy = { version = "0.1.0", path = "../embassy", features = [ "time-tick-1mhz" ] } +embassy = { version = "0.1.0", path = "../embassy", features = [ "time-tick-1mhz", "nightly"] } embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["rp"]} atomic-polyfill = "0.1.5" diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 386722d4..55a646d4 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" resolver = "2" [dependencies] -embassy = { version = "0.1.0", path = "../embassy" } +embassy = { version = "0.1.0", path = "../embassy", features = ["nightly"]} embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["stm32"] } embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } embassy-net = { version = "0.1.0", path = "../embassy-net", default-features = false, optional = true } diff --git a/embassy/Cargo.toml b/embassy/Cargo.toml index ccb5574d..d10a8874 100644 --- a/embassy/Cargo.toml +++ b/embassy/Cargo.toml @@ -10,8 +10,12 @@ default = [] std = ["futures/std", "time", "time-tick-1mhz", "embassy-macros/std"] wasm = ["wasm-bindgen", "js-sys", "embassy-macros/wasm", "wasm-timer", "time", "time-tick-1mhz"] +# Enable nightly-only features +nightly = ["embedded-hal-async"] + # Implement embedded-hal 1.0 alpha and embedded-hal-async traits. -unstable-traits = ["embedded-hal-1", "embedded-hal-async"] +# Implement embedded-hal-async traits if `nightly` is set as well. +unstable-traits = ["embedded-hal-1"] # Enable `embassy::time` module. # NOTE: This feature is only intended to be enabled by crates providing the time driver implementation. diff --git a/embassy/src/channel/signal.rs b/embassy/src/channel/signal.rs index 87922b2f..027f4f47 100644 --- a/embassy/src/channel/signal.rs +++ b/embassy/src/channel/signal.rs @@ -32,13 +32,15 @@ enum State { unsafe impl Send for Signal {} unsafe impl Sync for Signal {} -impl Signal { +impl Signal { pub const fn new() -> Self { Self { state: UnsafeCell::new(State::None), } } +} +impl Signal { /// Mark this Signal as completed. pub fn signal(&self, val: T) { critical_section::with(|_| unsafe { diff --git a/embassy/src/executor/raw/mod.rs b/embassy/src/executor/raw/mod.rs index 5ee38715..3ae52ae3 100644 --- a/embassy/src/executor/raw/mod.rs +++ b/embassy/src/executor/raw/mod.rs @@ -57,6 +57,7 @@ pub struct TaskHeader { } impl TaskHeader { + #[cfg(feature = "nightly")] pub(crate) const fn new() -> Self { Self { state: AtomicU32::new(0), @@ -71,6 +72,21 @@ impl TaskHeader { } } + #[cfg(not(feature = "nightly"))] + pub(crate) fn new() -> Self { + Self { + state: AtomicU32::new(0), + run_queue_item: RunQueueItem::new(), + executor: Cell::new(ptr::null()), + poll_fn: UninitCell::uninit(), + + #[cfg(feature = "time")] + expires_at: Cell::new(Instant::from_ticks(0)), + #[cfg(feature = "time")] + timer_queue_item: timer_queue::TimerQueueItem::new(), + } + } + pub(crate) unsafe fn enqueue(&self) { critical_section::with(|cs| { let state = self.state.load(Ordering::Relaxed); @@ -113,7 +129,8 @@ pub struct TaskStorage { } impl TaskStorage { - /// Create a new Task, in not-spawned state. + /// Create a new TaskStorage, in not-spawned state. + #[cfg(feature = "nightly")] pub const fn new() -> Self { Self { raw: TaskHeader::new(), @@ -121,6 +138,15 @@ impl TaskStorage { } } + /// Create a new TaskStorage, in not-spawned state. + #[cfg(not(feature = "nightly"))] + pub fn new() -> Self { + Self { + raw: TaskHeader::new(), + future: UninitCell::uninit(), + } + } + /// Try to spawn a task in a pool. /// /// See [`Self::spawn()`] for details. diff --git a/embassy/src/lib.rs b/embassy/src/lib.rs index 2be0e005..acc71e10 100644 --- a/embassy/src/lib.rs +++ b/embassy/src/lib.rs @@ -1,8 +1,13 @@ #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] -#![feature(generic_associated_types)] -#![feature(const_fn_trait_bound)] -#![feature(const_fn_fn_ptr_basics)] -#![feature(type_alias_impl_trait)] +#![cfg_attr( + feature = "nightly", + feature( + const_fn_trait_bound, + const_fn_fn_ptr_basics, + generic_associated_types, + type_alias_impl_trait + ) +)] #![allow(clippy::new_without_default)] // This mod MUST go first, so that the others see its macros. @@ -20,7 +25,8 @@ pub mod io; pub mod time; pub mod util; -pub use embassy_macros::*; +#[cfg(feature = "nightly")] +pub use embassy_macros::{main, task}; #[doc(hidden)] /// Implementation details for embassy macros. DO NOT USE. diff --git a/embassy/src/time/delay.rs b/embassy/src/time/delay.rs index ff32941e..27ec61fe 100644 --- a/embassy/src/time/delay.rs +++ b/embassy/src/time/delay.rs @@ -16,11 +16,7 @@ pub struct Delay; #[cfg(feature = "unstable-traits")] mod eh1 { - use core::future::Future; - use futures::FutureExt; - use super::*; - use crate::time::Timer; impl embedded_hal_1::delay::blocking::DelayUs for Delay { type Error = core::convert::Infallible; @@ -33,6 +29,14 @@ mod eh1 { Ok(block_for(Duration::from_millis(ms as u64))) } } +} + +#[cfg(all(feature = "unstable-traits", feature = "nightly"))] +mod eh1a { + use super::*; + use crate::time::Timer; + use core::future::Future; + use futures::FutureExt; impl embedded_hal_async::delay::DelayUs for Delay { type Error = core::convert::Infallible; diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index da16bcba..2d9c9953 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml @@ -4,6 +4,9 @@ edition = "2018" name = "embassy-nrf-examples" version = "0.1.0" +[features] +default = ["nightly"] +nightly = ["embassy-nrf/nightly"] [dependencies] embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 450911fa..ef60fe99 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml @@ -5,7 +5,7 @@ name = "embassy-std-examples" version = "0.1.0" [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["log", "std", "time"] } +embassy = { version = "0.1.0", path = "../../embassy", features = ["log", "std", "time", "nightly"] } embassy-net = { version = "0.1.0", path = "../../embassy-net", features=["std", "log", "medium-ethernet", "tcp", "dhcpv4"] } async-io = "1.6.0" diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml index c6218a80..6750f6a6 100644 --- a/examples/wasm/Cargo.toml +++ b/examples/wasm/Cargo.toml @@ -8,7 +8,7 @@ version = "0.1.0" crate-type = ["cdylib"] [dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["log", "wasm"] } +embassy = { version = "0.1.0", path = "../../embassy", features = ["log", "wasm", "nightly"] } wasm-logger = "0.2.0" wasm-bindgen = "0.2"