embassy, embassy-nrf: add nightly Cargo feature to gate nightly-only features.

This commit is contained in:
Dario Nieuwenhuis 2022-02-12 00:24:04 +01:00
parent 611961b499
commit 20e14b8edb
19 changed files with 182 additions and 126 deletions

15
.vscode/settings.json vendored
View File

@ -4,16 +4,19 @@
"rust-analyzer.assist.importGranularity": "module", "rust-analyzer.assist.importGranularity": "module",
"rust-analyzer.checkOnSave.allFeatures": false, "rust-analyzer.checkOnSave.allFeatures": false,
"rust-analyzer.checkOnSave.allTargets": 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.cargo.noDefaultFeatures": true,
"rust-analyzer.experimental.procAttrMacros": false, "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.target": "thumbv7em-none-eabi",
"rust-analyzer.cargo.features": [ "rust-analyzer.cargo.features": [
// These are needed to prevent embassy-net from failing to build // These are needed to prevent embassy-net from failing to build
//"embassy-net/medium-ethernet", //"embassy-net/medium-ethernet",
//"embassy-net/tcp", //"embassy-net/tcp",
//"embassy-net/pool-16", //"embassy-net/pool-16",
"nightly",
], ],
"rust-analyzer.linkedProjects": [ "rust-analyzer.linkedProjects": [
// Declare for the target you wish to develop // Declare for the target you wish to develop
@ -35,12 +38,4 @@
// "examples/stm32wl55/Cargo.toml", // "examples/stm32wl55/Cargo.toml",
// "examples/wasm/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
} }

36
ci.sh
View File

@ -24,24 +24,24 @@ rm -rf stm32-metapac
mv stm32-metapac-gen/out stm32-metapac mv stm32-metapac-gen/out stm32-metapac
cargo batch \ 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 nightly \
--- 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 nightly,log,executor-agnostic \
--- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features defmt \ --- 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 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 nrf52805,gpiote,time-driver-rtc1 \ --- 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 nrf52810,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 nrf52811,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 nrf52820,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 nrf52832,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 nrf52833,gpiote,time-driver-rtc1,unstable-traits \ --- 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 nrf9160-s,gpiote,time-driver-rtc1 \ --- 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 nrf9160-ns,gpiote,time-driver-rtc1,unstable-traits \ --- 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 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-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 nightly,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 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 nrf52840,gpiote,time-driver-rtc1 \ --- 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 nrf52840,log,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 nrf52840,defmt,gpiote,time-driver-rtc1,unstable-traits \ --- 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 \
--- 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 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 \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any \

View File

@ -5,8 +5,8 @@ name = "embassy-basic-example"
version = "0.1.0" version = "0.1.0"
[dependencies] [dependencies]
embassy = { version = "0.1.0", path = "../../../../../embassy", features = ["defmt"] } 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"] } embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "nightly"] }
defmt = "0.3" defmt = "0.3"
defmt-rtt = "0.3" defmt-rtt = "0.3"

View File

@ -6,14 +6,18 @@ edition = "2018"
[features] [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`. # 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. # 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. # 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. # There are no plans to make this stable.
unstable-pac = [] unstable-pac = []
# Implement embedded-hal 1.0 alpha and embedded-hal-async traits. # Implement embedded-hal 1.0 alpha 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"]
nrf52805 = ["nrf52805-pac", "_ppi"] nrf52805 = ["nrf52805-pac", "_ppi"]
nrf52810 = ["nrf52810-pac", "_ppi"] nrf52810 = ["nrf52810-pac", "_ppi"]

View File

@ -463,7 +463,6 @@ mod eh02 {
#[cfg(feature = "unstable-traits")] #[cfg(feature = "unstable-traits")]
mod eh1 { mod eh1 {
use super::*; use super::*;
use futures::FutureExt;
impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::ErrorType for InputChannel<'d, C, T> { impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::ErrorType for InputChannel<'d, C, T> {
type Error = Infallible; type Error = Infallible;
@ -480,6 +479,12 @@ mod eh1 {
self.pin.is_low() 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> { impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> {
type WaitForHighFuture<'a> type WaitForHighFuture<'a>

View File

@ -1,6 +1,8 @@
#![no_std] #![no_std]
#![feature(generic_associated_types)] #![cfg_attr(
#![feature(type_alias_impl_trait)] feature = "nightly",
feature(generic_associated_types, type_alias_impl_trait)
)]
#[cfg(not(any( #[cfg(not(any(
feature = "nrf51", feature = "nrf51",

View File

@ -333,7 +333,6 @@ mod eh02 {
#[cfg(feature = "unstable-traits")] #[cfg(feature = "unstable-traits")]
mod eh1 { mod eh1 {
use super::*; use super::*;
use core::future::Future;
impl embedded_hal_1::spi::Error for Error { impl embedded_hal_1::spi::Error for Error {
fn kind(&self) -> embedded_hal_1::spi::ErrorKind { fn kind(&self) -> embedded_hal_1::spi::ErrorKind {
@ -396,7 +395,7 @@ mod eh1 {
fn transaction<'a>( fn transaction<'a>(
&mut self, &mut self,
operations: &mut [embedded_hal_async::spi::Operation<'a, u8>], operations: &mut [embedded_hal_1::spi::blocking::Operation<'a, u8>],
) -> Result<(), Self::Error> { ) -> Result<(), Self::Error> {
use embedded_hal_1::spi::blocking::Operation; use embedded_hal_1::spi::blocking::Operation;
for o in operations { for o in operations {
@ -410,6 +409,12 @@ mod eh1 {
Ok(()) 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<u8> for Spim<'d, T> { impl<'d, T: Instance> embedded_hal_async::spi::Read<u8> for Spim<'d, T> {
type ReadFuture<'a> type ReadFuture<'a>

View File

@ -679,7 +679,7 @@ mod eh1 {
fn transaction<'a>( fn transaction<'a>(
&mut self, &mut self,
_address: u8, _address: u8,
_operations: &mut [embedded_hal_async::i2c::Operation<'a>], _operations: &mut [embedded_hal_1::i2c::blocking::Operation<'a>],
) -> Result<(), Self::Error> { ) -> Result<(), Self::Error> {
todo!(); todo!();
} }
@ -690,58 +690,59 @@ mod eh1 {
_operations: O, _operations: O,
) -> Result<(), Self::Error> ) -> Result<(), Self::Error>
where where
O: IntoIterator<Item = embedded_hal_async::i2c::Operation<'a>>, O: IntoIterator<Item = embedded_hal_1::i2c::blocking::Operation<'a>>,
{ {
todo!(); todo!();
} }
} }
}
impl<'d, T: Instance> embedded_hal_async::i2c::I2c for Twim<'d, T> { #[cfg(all(feature = "unstable-traits", feature = "nightly"))]
type ReadFuture<'a> impl<'d, T: Instance> embedded_hal_async::i2c::I2c for Twim<'d, T> {
where type ReadFuture<'a>
Self: 'a, where
= impl Future<Output = Result<(), Self::Error>> + 'a; Self: 'a,
= impl Future<Output = Result<(), Self::Error>> + 'a;
fn read<'a>(&'a mut self, address: u8, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { fn read<'a>(&'a mut self, address: u8, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> {
self.read(address, buffer) self.read(address, buffer)
} }
type WriteFuture<'a> type WriteFuture<'a>
where where
Self: 'a, Self: 'a,
= impl Future<Output = Result<(), Self::Error>> + 'a; = impl Future<Output = Result<(), Self::Error>> + 'a;
fn write<'a>(&'a mut self, address: u8, bytes: &'a [u8]) -> Self::WriteFuture<'a> { fn write<'a>(&'a mut self, address: u8, bytes: &'a [u8]) -> Self::WriteFuture<'a> {
self.write(address, bytes) self.write(address, bytes)
} }
type WriteReadFuture<'a> type WriteReadFuture<'a>
where where
Self: 'a, Self: 'a,
= impl Future<Output = Result<(), Self::Error>> + 'a; = impl Future<Output = Result<(), Self::Error>> + 'a;
fn write_read<'a>( fn write_read<'a>(
&'a mut self, &'a mut self,
address: u8, address: u8,
wr_buffer: &'a [u8], wr_buffer: &'a [u8],
rd_buffer: &'a mut [u8], rd_buffer: &'a mut [u8],
) -> Self::WriteReadFuture<'a> { ) -> Self::WriteReadFuture<'a> {
self.write_read(address, wr_buffer, rd_buffer) self.write_read(address, wr_buffer, rd_buffer)
} }
type TransactionFuture<'a> type TransactionFuture<'a>
where where
Self: 'a, Self: 'a,
= impl Future<Output = Result<(), Self::Error>> + 'a; = impl Future<Output = Result<(), Self::Error>> + 'a;
fn transaction<'a>( fn transaction<'a>(
&'a mut self, &'a mut self,
address: u8, address: u8,
operations: &mut [embedded_hal_async::i2c::Operation<'a>], operations: &mut [embedded_hal_async::i2c::Operation<'a>],
) -> Self::TransactionFuture<'a> { ) -> Self::TransactionFuture<'a> {
let _ = address; let _ = address;
let _ = operations; let _ = operations;
async move { todo!() } async move { todo!() }
}
} }
} }

View File

@ -760,7 +760,6 @@ mod eh02 {
#[cfg(feature = "unstable-traits")] #[cfg(feature = "unstable-traits")]
mod eh1 { mod eh1 {
use super::*; use super::*;
use core::future::Future;
impl embedded_hal_1::serial::Error for Error { impl embedded_hal_1::serial::Error for Error {
fn kind(&self) -> embedded_hal_1::serial::ErrorKind { 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> { impl<'d, T: Instance> embedded_hal_async::serial::Read for Uarte<'d, T> {
type ReadFuture<'a> type ReadFuture<'a>
where 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> { impl<'d, T: Instance> embedded_hal_async::serial::Write for UarteTx<'d, T> {
type WriteFuture<'a> type WriteFuture<'a>
where 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> { impl<'d, T: Instance> embedded_hal_async::serial::Read for UarteRx<'d, T> {
type ReadFuture<'a> type ReadFuture<'a>
where 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 impl<'d, U: Instance, T: TimerInstance> embedded_hal_async::serial::Read
for UarteWithIdle<'d, U, T> for UarteWithIdle<'d, U, T>
{ {

View File

@ -13,7 +13,7 @@ edition = "2018"
unstable-pac = [] unstable-pac = []
[dependencies] [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-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["rp"]} embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["rp"]}
atomic-polyfill = "0.1.5" atomic-polyfill = "0.1.5"

View File

@ -6,7 +6,7 @@ edition = "2018"
resolver = "2" resolver = "2"
[dependencies] [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-macros = { version = "0.1.0", path = "../embassy-macros", features = ["stm32"] }
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } 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 } embassy-net = { version = "0.1.0", path = "../embassy-net", default-features = false, optional = true }

View File

@ -10,8 +10,12 @@ default = []
std = ["futures/std", "time", "time-tick-1mhz", "embassy-macros/std"] std = ["futures/std", "time", "time-tick-1mhz", "embassy-macros/std"]
wasm = ["wasm-bindgen", "js-sys", "embassy-macros/wasm", "wasm-timer", "time", "time-tick-1mhz"] 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. # 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. # Enable `embassy::time` module.
# NOTE: This feature is only intended to be enabled by crates providing the time driver implementation. # NOTE: This feature is only intended to be enabled by crates providing the time driver implementation.

View File

@ -32,13 +32,15 @@ enum State<T> {
unsafe impl<T: Send> Send for Signal<T> {} unsafe impl<T: Send> Send for Signal<T> {}
unsafe impl<T: Send> Sync for Signal<T> {} unsafe impl<T: Send> Sync for Signal<T> {}
impl<T: Send> Signal<T> { impl<T> Signal<T> {
pub const fn new() -> Self { pub const fn new() -> Self {
Self { Self {
state: UnsafeCell::new(State::None), state: UnsafeCell::new(State::None),
} }
} }
}
impl<T: Send> Signal<T> {
/// Mark this Signal as completed. /// Mark this Signal as completed.
pub fn signal(&self, val: T) { pub fn signal(&self, val: T) {
critical_section::with(|_| unsafe { critical_section::with(|_| unsafe {

View File

@ -57,6 +57,7 @@ pub struct TaskHeader {
} }
impl TaskHeader { impl TaskHeader {
#[cfg(feature = "nightly")]
pub(crate) const fn new() -> Self { pub(crate) const fn new() -> Self {
Self { Self {
state: AtomicU32::new(0), 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) { pub(crate) unsafe fn enqueue(&self) {
critical_section::with(|cs| { critical_section::with(|cs| {
let state = self.state.load(Ordering::Relaxed); let state = self.state.load(Ordering::Relaxed);
@ -113,7 +129,8 @@ pub struct TaskStorage<F: Future + 'static> {
} }
impl<F: Future + 'static> TaskStorage<F> { impl<F: Future + 'static> TaskStorage<F> {
/// Create a new Task, in not-spawned state. /// Create a new TaskStorage, in not-spawned state.
#[cfg(feature = "nightly")]
pub const fn new() -> Self { pub const fn new() -> Self {
Self { Self {
raw: TaskHeader::new(), raw: TaskHeader::new(),
@ -121,6 +138,15 @@ impl<F: Future + 'static> TaskStorage<F> {
} }
} }
/// 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. /// Try to spawn a task in a pool.
/// ///
/// See [`Self::spawn()`] for details. /// See [`Self::spawn()`] for details.

View File

@ -1,8 +1,13 @@
#![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)]
#![feature(generic_associated_types)] #![cfg_attr(
#![feature(const_fn_trait_bound)] feature = "nightly",
#![feature(const_fn_fn_ptr_basics)] feature(
#![feature(type_alias_impl_trait)] const_fn_trait_bound,
const_fn_fn_ptr_basics,
generic_associated_types,
type_alias_impl_trait
)
)]
#![allow(clippy::new_without_default)] #![allow(clippy::new_without_default)]
// This mod MUST go first, so that the others see its macros. // This mod MUST go first, so that the others see its macros.
@ -20,7 +25,8 @@ pub mod io;
pub mod time; pub mod time;
pub mod util; pub mod util;
pub use embassy_macros::*; #[cfg(feature = "nightly")]
pub use embassy_macros::{main, task};
#[doc(hidden)] #[doc(hidden)]
/// Implementation details for embassy macros. DO NOT USE. /// Implementation details for embassy macros. DO NOT USE.

View File

@ -16,11 +16,7 @@ pub struct Delay;
#[cfg(feature = "unstable-traits")] #[cfg(feature = "unstable-traits")]
mod eh1 { mod eh1 {
use core::future::Future;
use futures::FutureExt;
use super::*; use super::*;
use crate::time::Timer;
impl embedded_hal_1::delay::blocking::DelayUs for Delay { impl embedded_hal_1::delay::blocking::DelayUs for Delay {
type Error = core::convert::Infallible; type Error = core::convert::Infallible;
@ -33,6 +29,14 @@ mod eh1 {
Ok(block_for(Duration::from_millis(ms as u64))) 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 { impl embedded_hal_async::delay::DelayUs for Delay {
type Error = core::convert::Infallible; type Error = core::convert::Infallible;

View File

@ -4,6 +4,9 @@ edition = "2018"
name = "embassy-nrf-examples" name = "embassy-nrf-examples"
version = "0.1.0" version = "0.1.0"
[features]
default = ["nightly"]
nightly = ["embassy-nrf/nightly"]
[dependencies] [dependencies]
embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] }

View File

@ -5,7 +5,7 @@ name = "embassy-std-examples"
version = "0.1.0" version = "0.1.0"
[dependencies] [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"] } embassy-net = { version = "0.1.0", path = "../../embassy-net", features=["std", "log", "medium-ethernet", "tcp", "dhcpv4"] }
async-io = "1.6.0" async-io = "1.6.0"

View File

@ -8,7 +8,7 @@ version = "0.1.0"
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [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-logger = "0.2.0"
wasm-bindgen = "0.2" wasm-bindgen = "0.2"