diff options
| -rw-r--r-- | .vscode/settings.json | 15 | ||||
| -rwxr-xr-x | ci.sh | 36 | ||||
| -rw-r--r-- | docs/modules/ROOT/examples/basic/Cargo.toml | 4 | ||||
| -rw-r--r-- | embassy-nrf/Cargo.toml | 8 | ||||
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 7 | ||||
| -rw-r--r-- | embassy-nrf/src/lib.rs | 6 | ||||
| -rw-r--r-- | embassy-nrf/src/spim.rs | 9 | ||||
| -rw-r--r-- | embassy-nrf/src/twim.rs | 85 | ||||
| -rw-r--r-- | embassy-nrf/src/uarte.rs | 61 | ||||
| -rw-r--r-- | embassy-rp/Cargo.toml | 2 | ||||
| -rw-r--r-- | embassy-stm32/Cargo.toml | 2 | ||||
| -rw-r--r-- | embassy/Cargo.toml | 6 | ||||
| -rw-r--r-- | embassy/src/channel/signal.rs | 4 | ||||
| -rw-r--r-- | embassy/src/executor/raw/mod.rs | 28 | ||||
| -rw-r--r-- | embassy/src/lib.rs | 16 | ||||
| -rw-r--r-- | embassy/src/time/delay.rs | 12 | ||||
| -rw-r--r-- | examples/nrf/Cargo.toml | 3 | ||||
| -rw-r--r-- | examples/std/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/wasm/Cargo.toml | 2 |
19 files changed, 182 insertions, 126 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json index 3defc9077..79433a7c9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json | |||
| @@ -4,16 +4,19 @@ | |||
| 4 | "rust-analyzer.assist.importGranularity": "module", | 4 | "rust-analyzer.assist.importGranularity": "module", |
| 5 | "rust-analyzer.checkOnSave.allFeatures": false, | 5 | "rust-analyzer.checkOnSave.allFeatures": false, |
| 6 | "rust-analyzer.checkOnSave.allTargets": false, | 6 | "rust-analyzer.checkOnSave.allTargets": false, |
| 7 | "rust-analyzer.checkOnSave.command": "clippy", | 7 | "rust-analyzer.checkOnSave.noDefaultFeatures": true, |
| 8 | "rust-analyzer.cargo.allFeatures": false, | ||
| 8 | "rust-analyzer.cargo.noDefaultFeatures": true, | 9 | "rust-analyzer.cargo.noDefaultFeatures": true, |
| 9 | "rust-analyzer.experimental.procAttrMacros": false, | 10 | "rust-analyzer.experimental.procAttrMacros": false, |
| 10 | "rust-analyzer.checkOnSave.noDefaultFeatures": true, | 11 | "rust-analyzer.procMacro.enable": true, |
| 12 | "rust-analyzer.cargo.runBuildScripts": true, | ||
| 11 | "rust-analyzer.cargo.target": "thumbv7em-none-eabi", | 13 | "rust-analyzer.cargo.target": "thumbv7em-none-eabi", |
| 12 | "rust-analyzer.cargo.features": [ | 14 | "rust-analyzer.cargo.features": [ |
| 13 | // These are needed to prevent embassy-net from failing to build | 15 | // These are needed to prevent embassy-net from failing to build |
| 14 | //"embassy-net/medium-ethernet", | 16 | //"embassy-net/medium-ethernet", |
| 15 | //"embassy-net/tcp", | 17 | //"embassy-net/tcp", |
| 16 | //"embassy-net/pool-16", | 18 | //"embassy-net/pool-16", |
| 19 | "nightly", | ||
| 17 | ], | 20 | ], |
| 18 | "rust-analyzer.linkedProjects": [ | 21 | "rust-analyzer.linkedProjects": [ |
| 19 | // Declare for the target you wish to develop | 22 | // Declare for the target you wish to develop |
| @@ -35,12 +38,4 @@ | |||
| 35 | // "examples/stm32wl55/Cargo.toml", | 38 | // "examples/stm32wl55/Cargo.toml", |
| 36 | // "examples/wasm/Cargo.toml", | 39 | // "examples/wasm/Cargo.toml", |
| 37 | ], | 40 | ], |
| 38 | "rust-analyzer.procMacro.enable": true, | ||
| 39 | "rust-analyzer.cargo.runBuildScripts": true, | ||
| 40 | "files.watcherExclude": { | ||
| 41 | "**/.git/objects/**": true, | ||
| 42 | "**/.git/subtree-cache/**": true, | ||
| 43 | "**/target/**": true | ||
| 44 | }, | ||
| 45 | "git.ignoreLimitWarning": true | ||
| 46 | } \ No newline at end of file | 41 | } \ No newline at end of file |
| @@ -24,24 +24,24 @@ rm -rf stm32-metapac | |||
| 24 | mv stm32-metapac-gen/out stm32-metapac | 24 | mv stm32-metapac-gen/out stm32-metapac |
| 25 | 25 | ||
| 26 | cargo batch \ | 26 | cargo batch \ |
| 27 | --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi \ | 27 | --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features nightly \ |
| 28 | --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features log,executor-agnostic \ | 28 | --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features nightly,log,executor-agnostic \ |
| 29 | --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features defmt \ | 29 | --- build --release --manifest-path embassy/Cargo.toml --target thumbv7em-none-eabi --features nightly,defmt \ |
| 30 | --- build --release --manifest-path embassy/Cargo.toml --target thumbv6m-none-eabi --features defmt \ | 30 | --- build --release --manifest-path embassy/Cargo.toml --target thumbv6m-none-eabi --features nightly,defmt \ |
| 31 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52805,gpiote,time-driver-rtc1 \ | 31 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52805,gpiote,time-driver-rtc1 \ |
| 32 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52810,gpiote,time-driver-rtc1 \ | 32 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52810,gpiote,time-driver-rtc1 \ |
| 33 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52811,gpiote,time-driver-rtc1 \ | 33 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52811,gpiote,time-driver-rtc1 \ |
| 34 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52820,gpiote,time-driver-rtc1 \ | 34 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52820,gpiote,time-driver-rtc1 \ |
| 35 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52832,gpiote,time-driver-rtc1 \ | 35 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52832,gpiote,time-driver-rtc1 \ |
| 36 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52833,gpiote,time-driver-rtc1,unstable-traits \ | 36 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52833,gpiote,time-driver-rtc1,unstable-traits \ |
| 37 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160-s,gpiote,time-driver-rtc1 \ | 37 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf9160-s,gpiote,time-driver-rtc1 \ |
| 38 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160-ns,gpiote,time-driver-rtc1,unstable-traits \ | 38 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf9160-ns,gpiote,time-driver-rtc1,unstable-traits \ |
| 39 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-app-s,gpiote,time-driver-rtc1,unstable-traits \ | 39 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf5340-app-s,gpiote,time-driver-rtc1,unstable-traits \ |
| 40 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-app-ns,gpiote,time-driver-rtc1 \ | 40 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf5340-app-ns,gpiote,time-driver-rtc1 \ |
| 41 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-net,gpiote,time-driver-rtc1,unstable-traits \ | 41 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf5340-net,gpiote,time-driver-rtc1,unstable-traits \ |
| 42 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,gpiote,time-driver-rtc1 \ | 42 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52840,gpiote,time-driver-rtc1 \ |
| 43 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,log,gpiote,time-driver-rtc1 \ | 43 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52840,log,gpiote,time-driver-rtc1 \ |
| 44 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,defmt,gpiote,time-driver-rtc1,unstable-traits \ | 44 | --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52840,defmt,gpiote,time-driver-rtc1,unstable-traits \ |
| 45 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any \ | 45 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any \ |
| 46 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,unstable-traits \ | 46 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,unstable-traits \ |
| 47 | --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any \ | 47 | --- 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 0f1c30da3..ed1c3cb1c 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" | |||
| 5 | version = "0.1.0" | 5 | version = "0.1.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy = { version = "0.1.0", path = "../../../../../embassy", features = ["defmt"] } | 8 | embassy = { version = "0.1.0", path = "../../../../../embassy", features = ["defmt", "nightly"] } |
| 9 | embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote"] } | 9 | embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "nightly"] } |
| 10 | 10 | ||
| 11 | defmt = "0.3" | 11 | defmt = "0.3" |
| 12 | defmt-rtt = "0.3" | 12 | defmt-rtt = "0.3" |
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 4ed922ba9..5ced9b1b2 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml | |||
| @@ -6,14 +6,18 @@ edition = "2018" | |||
| 6 | 6 | ||
| 7 | [features] | 7 | [features] |
| 8 | 8 | ||
| 9 | # Enable nightly-only features | ||
| 10 | nightly = ["embassy/nightly", "embedded-hal-1", "embedded-hal-async"] | ||
| 11 | |||
| 9 | # Reexport the PAC for the currently enabled chip at `embassy_nrf::pac`. | 12 | # Reexport the PAC for the currently enabled chip at `embassy_nrf::pac`. |
| 10 | # This is unstable because semver-minor (non-breaking) releases of embassy-nrf may major-bump (breaking) the PAC version. | 13 | # This is unstable because semver-minor (non-breaking) releases of embassy-nrf may major-bump (breaking) the PAC version. |
| 11 | # If this is an issue for you, you're encouraged to directly depend on a fixed version of the PAC. | 14 | # If this is an issue for you, you're encouraged to directly depend on a fixed version of the PAC. |
| 12 | # There are no plans to make this stable. | 15 | # There are no plans to make this stable. |
| 13 | unstable-pac = [] | 16 | unstable-pac = [] |
| 14 | 17 | ||
| 15 | # Implement embedded-hal 1.0 alpha and embedded-hal-async traits. | 18 | # Implement embedded-hal 1.0 alpha traits. |
| 16 | unstable-traits = ["embedded-hal-1", "embedded-hal-async"] | 19 | # Implement embedded-hal-async traits if `nightly` is set as well. |
| 20 | unstable-traits = ["embedded-hal-1"] | ||
| 17 | 21 | ||
| 18 | nrf52805 = ["nrf52805-pac", "_ppi"] | 22 | nrf52805 = ["nrf52805-pac", "_ppi"] |
| 19 | nrf52810 = ["nrf52810-pac", "_ppi"] | 23 | nrf52810 = ["nrf52810-pac", "_ppi"] |
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index a4c24058c..b856c2dfe 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -463,7 +463,6 @@ mod eh02 { | |||
| 463 | #[cfg(feature = "unstable-traits")] | 463 | #[cfg(feature = "unstable-traits")] |
| 464 | mod eh1 { | 464 | mod eh1 { |
| 465 | use super::*; | 465 | use super::*; |
| 466 | use futures::FutureExt; | ||
| 467 | 466 | ||
| 468 | impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::ErrorType for InputChannel<'d, C, T> { | 467 | impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::ErrorType for InputChannel<'d, C, T> { |
| 469 | type Error = Infallible; | 468 | type Error = Infallible; |
| @@ -480,6 +479,12 @@ mod eh1 { | |||
| 480 | self.pin.is_low() | 479 | self.pin.is_low() |
| 481 | } | 480 | } |
| 482 | } | 481 | } |
| 482 | } | ||
| 483 | |||
| 484 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] | ||
| 485 | mod eh1a { | ||
| 486 | use super::*; | ||
| 487 | use futures::FutureExt; | ||
| 483 | 488 | ||
| 484 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> { | 489 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> { |
| 485 | type WaitForHighFuture<'a> | 490 | type WaitForHighFuture<'a> |
diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index 8e05d9b6a..b448f6ab6 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![feature(generic_associated_types)] | 2 | #![cfg_attr( |
| 3 | #![feature(type_alias_impl_trait)] | 3 | feature = "nightly", |
| 4 | feature(generic_associated_types, type_alias_impl_trait) | ||
| 5 | )] | ||
| 4 | 6 | ||
| 5 | #[cfg(not(any( | 7 | #[cfg(not(any( |
| 6 | feature = "nrf51", | 8 | feature = "nrf51", |
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index cd43b26e6..aac20e174 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs | |||
| @@ -333,7 +333,6 @@ mod eh02 { | |||
| 333 | #[cfg(feature = "unstable-traits")] | 333 | #[cfg(feature = "unstable-traits")] |
| 334 | mod eh1 { | 334 | mod eh1 { |
| 335 | use super::*; | 335 | use super::*; |
| 336 | use core::future::Future; | ||
| 337 | 336 | ||
| 338 | impl embedded_hal_1::spi::Error for Error { | 337 | impl embedded_hal_1::spi::Error for Error { |
| 339 | fn kind(&self) -> embedded_hal_1::spi::ErrorKind { | 338 | fn kind(&self) -> embedded_hal_1::spi::ErrorKind { |
| @@ -396,7 +395,7 @@ mod eh1 { | |||
| 396 | 395 | ||
| 397 | fn transaction<'a>( | 396 | fn transaction<'a>( |
| 398 | &mut self, | 397 | &mut self, |
| 399 | operations: &mut [embedded_hal_async::spi::Operation<'a, u8>], | 398 | operations: &mut [embedded_hal_1::spi::blocking::Operation<'a, u8>], |
| 400 | ) -> Result<(), Self::Error> { | 399 | ) -> Result<(), Self::Error> { |
| 401 | use embedded_hal_1::spi::blocking::Operation; | 400 | use embedded_hal_1::spi::blocking::Operation; |
| 402 | for o in operations { | 401 | for o in operations { |
| @@ -410,6 +409,12 @@ mod eh1 { | |||
| 410 | Ok(()) | 409 | Ok(()) |
| 411 | } | 410 | } |
| 412 | } | 411 | } |
| 412 | } | ||
| 413 | |||
| 414 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] | ||
| 415 | mod eh1a { | ||
| 416 | use super::*; | ||
| 417 | use core::future::Future; | ||
| 413 | 418 | ||
| 414 | impl<'d, T: Instance> embedded_hal_async::spi::Read<u8> for Spim<'d, T> { | 419 | impl<'d, T: Instance> embedded_hal_async::spi::Read<u8> for Spim<'d, T> { |
| 415 | type ReadFuture<'a> | 420 | type ReadFuture<'a> |
diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs index 4cd47c897..ed2844f79 100644 --- a/embassy-nrf/src/twim.rs +++ b/embassy-nrf/src/twim.rs | |||
| @@ -679,7 +679,7 @@ mod eh1 { | |||
| 679 | fn transaction<'a>( | 679 | fn transaction<'a>( |
| 680 | &mut self, | 680 | &mut self, |
| 681 | _address: u8, | 681 | _address: u8, |
| 682 | _operations: &mut [embedded_hal_async::i2c::Operation<'a>], | 682 | _operations: &mut [embedded_hal_1::i2c::blocking::Operation<'a>], |
| 683 | ) -> Result<(), Self::Error> { | 683 | ) -> Result<(), Self::Error> { |
| 684 | todo!(); | 684 | todo!(); |
| 685 | } | 685 | } |
| @@ -690,58 +690,59 @@ mod eh1 { | |||
| 690 | _operations: O, | 690 | _operations: O, |
| 691 | ) -> Result<(), Self::Error> | 691 | ) -> Result<(), Self::Error> |
| 692 | where | 692 | where |
| 693 | O: IntoIterator<Item = embedded_hal_async::i2c::Operation<'a>>, | 693 | O: IntoIterator<Item = embedded_hal_1::i2c::blocking::Operation<'a>>, |
| 694 | { | 694 | { |
| 695 | todo!(); | 695 | todo!(); |
| 696 | } | 696 | } |
| 697 | } | 697 | } |
| 698 | } | ||
| 698 | 699 | ||
| 699 | impl<'d, T: Instance> embedded_hal_async::i2c::I2c for Twim<'d, T> { | 700 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] |
| 700 | type ReadFuture<'a> | 701 | impl<'d, T: Instance> embedded_hal_async::i2c::I2c for Twim<'d, T> { |
| 701 | where | 702 | type ReadFuture<'a> |
| 702 | Self: 'a, | 703 | where |
| 703 | = impl Future<Output = Result<(), Self::Error>> + 'a; | 704 | Self: 'a, |
| 705 | = impl Future<Output = Result<(), Self::Error>> + 'a; | ||
| 704 | 706 | ||
| 705 | fn read<'a>(&'a mut self, address: u8, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { | 707 | fn read<'a>(&'a mut self, address: u8, buffer: &'a mut [u8]) -> Self::ReadFuture<'a> { |
| 706 | self.read(address, buffer) | 708 | self.read(address, buffer) |
| 707 | } | 709 | } |
| 708 | 710 | ||
| 709 | type WriteFuture<'a> | 711 | type WriteFuture<'a> |
| 710 | where | 712 | where |
| 711 | Self: 'a, | 713 | Self: 'a, |
| 712 | = impl Future<Output = Result<(), Self::Error>> + 'a; | 714 | = impl Future<Output = Result<(), Self::Error>> + 'a; |
| 713 | 715 | ||
| 714 | fn write<'a>(&'a mut self, address: u8, bytes: &'a [u8]) -> Self::WriteFuture<'a> { | 716 | fn write<'a>(&'a mut self, address: u8, bytes: &'a [u8]) -> Self::WriteFuture<'a> { |
| 715 | self.write(address, bytes) | 717 | self.write(address, bytes) |
| 716 | } | 718 | } |
| 717 | 719 | ||
| 718 | type WriteReadFuture<'a> | 720 | type WriteReadFuture<'a> |
| 719 | where | 721 | where |
| 720 | Self: 'a, | 722 | Self: 'a, |
| 721 | = impl Future<Output = Result<(), Self::Error>> + 'a; | 723 | = impl Future<Output = Result<(), Self::Error>> + 'a; |
| 722 | 724 | ||
| 723 | fn write_read<'a>( | 725 | fn write_read<'a>( |
| 724 | &'a mut self, | 726 | &'a mut self, |
| 725 | address: u8, | 727 | address: u8, |
| 726 | wr_buffer: &'a [u8], | 728 | wr_buffer: &'a [u8], |
| 727 | rd_buffer: &'a mut [u8], | 729 | rd_buffer: &'a mut [u8], |
| 728 | ) -> Self::WriteReadFuture<'a> { | 730 | ) -> Self::WriteReadFuture<'a> { |
| 729 | self.write_read(address, wr_buffer, rd_buffer) | 731 | self.write_read(address, wr_buffer, rd_buffer) |
| 730 | } | 732 | } |
| 731 | 733 | ||
| 732 | type TransactionFuture<'a> | 734 | type TransactionFuture<'a> |
| 733 | where | 735 | where |
| 734 | Self: 'a, | 736 | Self: 'a, |
| 735 | = impl Future<Output = Result<(), Self::Error>> + 'a; | 737 | = impl Future<Output = Result<(), Self::Error>> + 'a; |
| 736 | 738 | ||
| 737 | fn transaction<'a>( | 739 | fn transaction<'a>( |
| 738 | &'a mut self, | 740 | &'a mut self, |
| 739 | address: u8, | 741 | address: u8, |
| 740 | operations: &mut [embedded_hal_async::i2c::Operation<'a>], | 742 | operations: &mut [embedded_hal_async::i2c::Operation<'a>], |
| 741 | ) -> Self::TransactionFuture<'a> { | 743 | ) -> Self::TransactionFuture<'a> { |
| 742 | let _ = address; | 744 | let _ = address; |
| 743 | let _ = operations; | 745 | let _ = operations; |
| 744 | async move { todo!() } | 746 | async move { todo!() } |
| 745 | } | ||
| 746 | } | 747 | } |
| 747 | } | 748 | } |
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index b10e55a05..c7177dc2c 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs | |||
| @@ -760,7 +760,6 @@ mod eh02 { | |||
| 760 | #[cfg(feature = "unstable-traits")] | 760 | #[cfg(feature = "unstable-traits")] |
| 761 | mod eh1 { | 761 | mod eh1 { |
| 762 | use super::*; | 762 | use super::*; |
| 763 | use core::future::Future; | ||
| 764 | 763 | ||
| 765 | impl embedded_hal_1::serial::Error for Error { | 764 | impl embedded_hal_1::serial::Error for Error { |
| 766 | fn kind(&self) -> embedded_hal_1::serial::ErrorKind { | 765 | fn kind(&self) -> embedded_hal_1::serial::ErrorKind { |
| @@ -788,6 +787,36 @@ mod eh1 { | |||
| 788 | } | 787 | } |
| 789 | } | 788 | } |
| 790 | 789 | ||
| 790 | impl<'d, T: Instance> embedded_hal_1::serial::ErrorType for UarteTx<'d, T> { | ||
| 791 | type Error = Error; | ||
| 792 | } | ||
| 793 | |||
| 794 | impl<'d, T: Instance> embedded_hal_1::serial::blocking::Write for UarteTx<'d, T> { | ||
| 795 | fn write(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { | ||
| 796 | self.blocking_write(buffer) | ||
| 797 | } | ||
| 798 | |||
| 799 | fn flush(&mut self) -> Result<(), Self::Error> { | ||
| 800 | Ok(()) | ||
| 801 | } | ||
| 802 | } | ||
| 803 | |||
| 804 | impl<'d, T: Instance> embedded_hal_1::serial::ErrorType for UarteRx<'d, T> { | ||
| 805 | type Error = Error; | ||
| 806 | } | ||
| 807 | |||
| 808 | impl<'d, U: Instance, T: TimerInstance> embedded_hal_1::serial::ErrorType | ||
| 809 | for UarteWithIdle<'d, U, T> | ||
| 810 | { | ||
| 811 | type Error = Error; | ||
| 812 | } | ||
| 813 | } | ||
| 814 | |||
| 815 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] | ||
| 816 | mod eh1a { | ||
| 817 | use super::*; | ||
| 818 | use core::future::Future; | ||
| 819 | |||
| 791 | impl<'d, T: Instance> embedded_hal_async::serial::Read for Uarte<'d, T> { | 820 | impl<'d, T: Instance> embedded_hal_async::serial::Read for Uarte<'d, T> { |
| 792 | type ReadFuture<'a> | 821 | type ReadFuture<'a> |
| 793 | where | 822 | where |
| @@ -819,22 +848,6 @@ mod eh1 { | |||
| 819 | } | 848 | } |
| 820 | } | 849 | } |
| 821 | 850 | ||
| 822 | // ===================== | ||
| 823 | |||
| 824 | impl<'d, T: Instance> embedded_hal_1::serial::ErrorType for UarteTx<'d, T> { | ||
| 825 | type Error = Error; | ||
| 826 | } | ||
| 827 | |||
| 828 | impl<'d, T: Instance> embedded_hal_1::serial::blocking::Write for UarteTx<'d, T> { | ||
| 829 | fn write(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { | ||
| 830 | self.blocking_write(buffer) | ||
| 831 | } | ||
| 832 | |||
| 833 | fn flush(&mut self) -> Result<(), Self::Error> { | ||
| 834 | Ok(()) | ||
| 835 | } | ||
| 836 | } | ||
| 837 | |||
| 838 | impl<'d, T: Instance> embedded_hal_async::serial::Write for UarteTx<'d, T> { | 851 | impl<'d, T: Instance> embedded_hal_async::serial::Write for UarteTx<'d, T> { |
| 839 | type WriteFuture<'a> | 852 | type WriteFuture<'a> |
| 840 | where | 853 | where |
| @@ -855,12 +868,6 @@ mod eh1 { | |||
| 855 | } | 868 | } |
| 856 | } | 869 | } |
| 857 | 870 | ||
| 858 | // ===================== | ||
| 859 | |||
| 860 | impl<'d, T: Instance> embedded_hal_1::serial::ErrorType for UarteRx<'d, T> { | ||
| 861 | type Error = Error; | ||
| 862 | } | ||
| 863 | |||
| 864 | impl<'d, T: Instance> embedded_hal_async::serial::Read for UarteRx<'d, T> { | 871 | impl<'d, T: Instance> embedded_hal_async::serial::Read for UarteRx<'d, T> { |
| 865 | type ReadFuture<'a> | 872 | type ReadFuture<'a> |
| 866 | where | 873 | where |
| @@ -872,14 +879,6 @@ mod eh1 { | |||
| 872 | } | 879 | } |
| 873 | } | 880 | } |
| 874 | 881 | ||
| 875 | // ===================== | ||
| 876 | |||
| 877 | impl<'d, U: Instance, T: TimerInstance> embedded_hal_1::serial::ErrorType | ||
| 878 | for UarteWithIdle<'d, U, T> | ||
| 879 | { | ||
| 880 | type Error = Error; | ||
| 881 | } | ||
| 882 | |||
| 883 | impl<'d, U: Instance, T: TimerInstance> embedded_hal_async::serial::Read | 882 | impl<'d, U: Instance, T: TimerInstance> embedded_hal_async::serial::Read |
| 884 | for UarteWithIdle<'d, U, T> | 883 | for UarteWithIdle<'d, U, T> |
| 885 | { | 884 | { |
diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index be41f95eb..cb6544028 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml | |||
| @@ -13,7 +13,7 @@ edition = "2018" | |||
| 13 | unstable-pac = [] | 13 | unstable-pac = [] |
| 14 | 14 | ||
| 15 | [dependencies] | 15 | [dependencies] |
| 16 | embassy = { version = "0.1.0", path = "../embassy", features = [ "time-tick-1mhz" ] } | 16 | embassy = { version = "0.1.0", path = "../embassy", features = [ "time-tick-1mhz", "nightly"] } |
| 17 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } | 17 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } |
| 18 | embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["rp"]} | 18 | embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["rp"]} |
| 19 | atomic-polyfill = "0.1.5" | 19 | atomic-polyfill = "0.1.5" |
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 386722d47..55a646d4a 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml | |||
| @@ -6,7 +6,7 @@ edition = "2018" | |||
| 6 | resolver = "2" | 6 | resolver = "2" |
| 7 | 7 | ||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | embassy = { version = "0.1.0", path = "../embassy" } | 9 | embassy = { version = "0.1.0", path = "../embassy", features = ["nightly"]} |
| 10 | embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["stm32"] } | 10 | embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["stm32"] } |
| 11 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } | 11 | embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } |
| 12 | embassy-net = { version = "0.1.0", path = "../embassy-net", default-features = false, optional = true } | 12 | 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 ccb5574d7..d10a8874e 100644 --- a/embassy/Cargo.toml +++ b/embassy/Cargo.toml | |||
| @@ -10,8 +10,12 @@ default = [] | |||
| 10 | std = ["futures/std", "time", "time-tick-1mhz", "embassy-macros/std"] | 10 | std = ["futures/std", "time", "time-tick-1mhz", "embassy-macros/std"] |
| 11 | wasm = ["wasm-bindgen", "js-sys", "embassy-macros/wasm", "wasm-timer", "time", "time-tick-1mhz"] | 11 | wasm = ["wasm-bindgen", "js-sys", "embassy-macros/wasm", "wasm-timer", "time", "time-tick-1mhz"] |
| 12 | 12 | ||
| 13 | # Enable nightly-only features | ||
| 14 | nightly = ["embedded-hal-async"] | ||
| 15 | |||
| 13 | # Implement embedded-hal 1.0 alpha and embedded-hal-async traits. | 16 | # Implement embedded-hal 1.0 alpha and embedded-hal-async traits. |
| 14 | unstable-traits = ["embedded-hal-1", "embedded-hal-async"] | 17 | # Implement embedded-hal-async traits if `nightly` is set as well. |
| 18 | unstable-traits = ["embedded-hal-1"] | ||
| 15 | 19 | ||
| 16 | # Enable `embassy::time` module. | 20 | # Enable `embassy::time` module. |
| 17 | # NOTE: This feature is only intended to be enabled by crates providing the time driver implementation. | 21 | # 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 87922b2fd..027f4f47c 100644 --- a/embassy/src/channel/signal.rs +++ b/embassy/src/channel/signal.rs | |||
| @@ -32,13 +32,15 @@ enum State<T> { | |||
| 32 | unsafe impl<T: Send> Send for Signal<T> {} | 32 | unsafe impl<T: Send> Send for Signal<T> {} |
| 33 | unsafe impl<T: Send> Sync for Signal<T> {} | 33 | unsafe impl<T: Send> Sync for Signal<T> {} |
| 34 | 34 | ||
| 35 | impl<T: Send> Signal<T> { | 35 | impl<T> Signal<T> { |
| 36 | pub const fn new() -> Self { | 36 | pub const fn new() -> Self { |
| 37 | Self { | 37 | Self { |
| 38 | state: UnsafeCell::new(State::None), | 38 | state: UnsafeCell::new(State::None), |
| 39 | } | 39 | } |
| 40 | } | 40 | } |
| 41 | } | ||
| 41 | 42 | ||
| 43 | impl<T: Send> Signal<T> { | ||
| 42 | /// Mark this Signal as completed. | 44 | /// Mark this Signal as completed. |
| 43 | pub fn signal(&self, val: T) { | 45 | pub fn signal(&self, val: T) { |
| 44 | critical_section::with(|_| unsafe { | 46 | critical_section::with(|_| unsafe { |
diff --git a/embassy/src/executor/raw/mod.rs b/embassy/src/executor/raw/mod.rs index 5ee38715d..3ae52ae31 100644 --- a/embassy/src/executor/raw/mod.rs +++ b/embassy/src/executor/raw/mod.rs | |||
| @@ -57,6 +57,7 @@ pub struct TaskHeader { | |||
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | impl TaskHeader { | 59 | impl TaskHeader { |
| 60 | #[cfg(feature = "nightly")] | ||
| 60 | pub(crate) const fn new() -> Self { | 61 | pub(crate) const fn new() -> Self { |
| 61 | Self { | 62 | Self { |
| 62 | state: AtomicU32::new(0), | 63 | state: AtomicU32::new(0), |
| @@ -71,6 +72,21 @@ impl TaskHeader { | |||
| 71 | } | 72 | } |
| 72 | } | 73 | } |
| 73 | 74 | ||
| 75 | #[cfg(not(feature = "nightly"))] | ||
| 76 | pub(crate) fn new() -> Self { | ||
| 77 | Self { | ||
| 78 | state: AtomicU32::new(0), | ||
| 79 | run_queue_item: RunQueueItem::new(), | ||
| 80 | executor: Cell::new(ptr::null()), | ||
| 81 | poll_fn: UninitCell::uninit(), | ||
| 82 | |||
| 83 | #[cfg(feature = "time")] | ||
| 84 | expires_at: Cell::new(Instant::from_ticks(0)), | ||
| 85 | #[cfg(feature = "time")] | ||
| 86 | timer_queue_item: timer_queue::TimerQueueItem::new(), | ||
| 87 | } | ||
| 88 | } | ||
| 89 | |||
| 74 | pub(crate) unsafe fn enqueue(&self) { | 90 | pub(crate) unsafe fn enqueue(&self) { |
| 75 | critical_section::with(|cs| { | 91 | critical_section::with(|cs| { |
| 76 | let state = self.state.load(Ordering::Relaxed); | 92 | let state = self.state.load(Ordering::Relaxed); |
| @@ -113,7 +129,8 @@ pub struct TaskStorage<F: Future + 'static> { | |||
| 113 | } | 129 | } |
| 114 | 130 | ||
| 115 | impl<F: Future + 'static> TaskStorage<F> { | 131 | impl<F: Future + 'static> TaskStorage<F> { |
| 116 | /// Create a new Task, in not-spawned state. | 132 | /// Create a new TaskStorage, in not-spawned state. |
| 133 | #[cfg(feature = "nightly")] | ||
| 117 | pub const fn new() -> Self { | 134 | pub const fn new() -> Self { |
| 118 | Self { | 135 | Self { |
| 119 | raw: TaskHeader::new(), | 136 | raw: TaskHeader::new(), |
| @@ -121,6 +138,15 @@ impl<F: Future + 'static> TaskStorage<F> { | |||
| 121 | } | 138 | } |
| 122 | } | 139 | } |
| 123 | 140 | ||
| 141 | /// Create a new TaskStorage, in not-spawned state. | ||
| 142 | #[cfg(not(feature = "nightly"))] | ||
| 143 | pub fn new() -> Self { | ||
| 144 | Self { | ||
| 145 | raw: TaskHeader::new(), | ||
| 146 | future: UninitCell::uninit(), | ||
| 147 | } | ||
| 148 | } | ||
| 149 | |||
| 124 | /// Try to spawn a task in a pool. | 150 | /// Try to spawn a task in a pool. |
| 125 | /// | 151 | /// |
| 126 | /// See [`Self::spawn()`] for details. | 152 | /// See [`Self::spawn()`] for details. |
diff --git a/embassy/src/lib.rs b/embassy/src/lib.rs index 2be0e0052..acc71e105 100644 --- a/embassy/src/lib.rs +++ b/embassy/src/lib.rs | |||
| @@ -1,8 +1,13 @@ | |||
| 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] | 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] |
| 2 | #![feature(generic_associated_types)] | 2 | #![cfg_attr( |
| 3 | #![feature(const_fn_trait_bound)] | 3 | feature = "nightly", |
| 4 | #![feature(const_fn_fn_ptr_basics)] | 4 | feature( |
| 5 | #![feature(type_alias_impl_trait)] | 5 | const_fn_trait_bound, |
| 6 | const_fn_fn_ptr_basics, | ||
| 7 | generic_associated_types, | ||
| 8 | type_alias_impl_trait | ||
| 9 | ) | ||
| 10 | )] | ||
| 6 | #![allow(clippy::new_without_default)] | 11 | #![allow(clippy::new_without_default)] |
| 7 | 12 | ||
| 8 | // This mod MUST go first, so that the others see its macros. | 13 | // This mod MUST go first, so that the others see its macros. |
| @@ -20,7 +25,8 @@ pub mod io; | |||
| 20 | pub mod time; | 25 | pub mod time; |
| 21 | pub mod util; | 26 | pub mod util; |
| 22 | 27 | ||
| 23 | pub use embassy_macros::*; | 28 | #[cfg(feature = "nightly")] |
| 29 | pub use embassy_macros::{main, task}; | ||
| 24 | 30 | ||
| 25 | #[doc(hidden)] | 31 | #[doc(hidden)] |
| 26 | /// Implementation details for embassy macros. DO NOT USE. | 32 | /// Implementation details for embassy macros. DO NOT USE. |
diff --git a/embassy/src/time/delay.rs b/embassy/src/time/delay.rs index ff32941ee..27ec61fe6 100644 --- a/embassy/src/time/delay.rs +++ b/embassy/src/time/delay.rs | |||
| @@ -16,11 +16,7 @@ pub struct Delay; | |||
| 16 | 16 | ||
| 17 | #[cfg(feature = "unstable-traits")] | 17 | #[cfg(feature = "unstable-traits")] |
| 18 | mod eh1 { | 18 | mod eh1 { |
| 19 | use core::future::Future; | ||
| 20 | use futures::FutureExt; | ||
| 21 | |||
| 22 | use super::*; | 19 | use super::*; |
| 23 | use crate::time::Timer; | ||
| 24 | 20 | ||
| 25 | impl embedded_hal_1::delay::blocking::DelayUs for Delay { | 21 | impl embedded_hal_1::delay::blocking::DelayUs for Delay { |
| 26 | type Error = core::convert::Infallible; | 22 | type Error = core::convert::Infallible; |
| @@ -33,6 +29,14 @@ mod eh1 { | |||
| 33 | Ok(block_for(Duration::from_millis(ms as u64))) | 29 | Ok(block_for(Duration::from_millis(ms as u64))) |
| 34 | } | 30 | } |
| 35 | } | 31 | } |
| 32 | } | ||
| 33 | |||
| 34 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] | ||
| 35 | mod eh1a { | ||
| 36 | use super::*; | ||
| 37 | use crate::time::Timer; | ||
| 38 | use core::future::Future; | ||
| 39 | use futures::FutureExt; | ||
| 36 | 40 | ||
| 37 | impl embedded_hal_async::delay::DelayUs for Delay { | 41 | impl embedded_hal_async::delay::DelayUs for Delay { |
| 38 | type Error = core::convert::Infallible; | 42 | type Error = core::convert::Infallible; |
diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index da16bcbaf..2d9c99530 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml | |||
| @@ -4,6 +4,9 @@ edition = "2018" | |||
| 4 | name = "embassy-nrf-examples" | 4 | name = "embassy-nrf-examples" |
| 5 | version = "0.1.0" | 5 | version = "0.1.0" |
| 6 | 6 | ||
| 7 | [features] | ||
| 8 | default = ["nightly"] | ||
| 9 | nightly = ["embassy-nrf/nightly"] | ||
| 7 | 10 | ||
| 8 | [dependencies] | 11 | [dependencies] |
| 9 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } | 12 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } |
diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 450911fa1..ef60fe992 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml | |||
| @@ -5,7 +5,7 @@ name = "embassy-std-examples" | |||
| 5 | version = "0.1.0" | 5 | version = "0.1.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy = { version = "0.1.0", path = "../../embassy", features = ["log", "std", "time"] } | 8 | embassy = { version = "0.1.0", path = "../../embassy", features = ["log", "std", "time", "nightly"] } |
| 9 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features=["std", "log", "medium-ethernet", "tcp", "dhcpv4"] } | 9 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features=["std", "log", "medium-ethernet", "tcp", "dhcpv4"] } |
| 10 | 10 | ||
| 11 | async-io = "1.6.0" | 11 | async-io = "1.6.0" |
diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml index c6218a805..6750f6a6c 100644 --- a/examples/wasm/Cargo.toml +++ b/examples/wasm/Cargo.toml | |||
| @@ -8,7 +8,7 @@ version = "0.1.0" | |||
| 8 | crate-type = ["cdylib"] | 8 | crate-type = ["cdylib"] |
| 9 | 9 | ||
| 10 | [dependencies] | 10 | [dependencies] |
| 11 | embassy = { version = "0.1.0", path = "../../embassy", features = ["log", "wasm"] } | 11 | embassy = { version = "0.1.0", path = "../../embassy", features = ["log", "wasm", "nightly"] } |
| 12 | 12 | ||
| 13 | wasm-logger = "0.2.0" | 13 | wasm-logger = "0.2.0" |
| 14 | wasm-bindgen = "0.2" | 14 | wasm-bindgen = "0.2" |
