diff options
| -rw-r--r-- | .cargo/config | 2 | ||||
| -rw-r--r-- | Cargo.toml | 1 | ||||
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | embassy-nrf-examples/src/bin/gpiote_port.rs | 2 | ||||
| -rw-r--r-- | embassy-nrf-examples/src/bin/qspi.rs | 2 | ||||
| -rw-r--r-- | embassy-nrf-examples/src/bin/uart.rs | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/qspi.rs | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/uarte.rs | 6 | ||||
| -rw-r--r-- | embassy-stm32f4-examples/src/bin/exti.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32f4-examples/src/bin/serial.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32f4/src/exti.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32f4/src/serial.rs | 2 | ||||
| -rw-r--r-- | embassy-traits/Cargo.toml | 17 | ||||
| -rw-r--r-- | embassy-traits/src/flash.rs (renamed from embassy/src/flash.rs) | 0 | ||||
| -rw-r--r-- | embassy-traits/src/gpio.rs (renamed from embassy/src/gpio.rs) | 0 | ||||
| -rw-r--r-- | embassy-traits/src/lib.rs | 10 | ||||
| -rw-r--r-- | embassy-traits/src/uart.rs (renamed from embassy/src/uart.rs) | 0 | ||||
| -rw-r--r-- | embassy/Cargo.toml | 14 | ||||
| -rw-r--r-- | embassy/src/lib.rs | 5 |
20 files changed, 53 insertions, 22 deletions
diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 000000000..a14129b9d --- /dev/null +++ b/.cargo/config | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | [unstable] | ||
| 2 | namespaced-features = true | ||
diff --git a/Cargo.toml b/Cargo.toml index 4feeb2624..80ae93745 100644 --- a/Cargo.toml +++ b/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | [workspace] | 2 | [workspace] |
| 3 | members = [ | 3 | members = [ |
| 4 | "embassy", | 4 | "embassy", |
| 5 | "embassy-traits", | ||
| 5 | "embassy-nrf", | 6 | "embassy-nrf", |
| 6 | "embassy-stm32f4", | 7 | "embassy-stm32f4", |
| 7 | "embassy-nrf-examples", | 8 | "embassy-nrf-examples", |
| @@ -7,7 +7,7 @@ Embassy is a project to make async/await a first-class option for embedded devel | |||
| 7 | `embassy` provides a set of traits and types specifically designed for `async` usage. | 7 | `embassy` provides a set of traits and types specifically designed for `async` usage. |
| 8 | 8 | ||
| 9 | - `embassy::io`: `AsyncBufRead`, `AsyncWrite`. Traits for byte-stream IO, essentially `no_std` compatible versions of `futures::io`. | 9 | - `embassy::io`: `AsyncBufRead`, `AsyncWrite`. Traits for byte-stream IO, essentially `no_std` compatible versions of `futures::io`. |
| 10 | - `embassy::flash`: Flash device trait. | 10 | - `embassy::traits::flash`: Flash device trait. |
| 11 | - `embassy::time`: `Clock` and `Alarm` traits. Std-like `Duration` and `Instant`. | 11 | - `embassy::time`: `Clock` and `Alarm` traits. Std-like `Duration` and `Instant`. |
| 12 | - More traits for SPI, I2C, UART async HAL coming soon. | 12 | - More traits for SPI, I2C, UART async HAL coming soon. |
| 13 | 13 | ||
diff --git a/embassy-nrf-examples/src/bin/gpiote_port.rs b/embassy-nrf-examples/src/bin/gpiote_port.rs index 0f1637faf..ccb5bb97c 100644 --- a/embassy-nrf-examples/src/bin/gpiote_port.rs +++ b/embassy-nrf-examples/src/bin/gpiote_port.rs | |||
| @@ -12,7 +12,7 @@ use defmt::panic; | |||
| 12 | use nrf52840_hal::gpio; | 12 | use nrf52840_hal::gpio; |
| 13 | 13 | ||
| 14 | use embassy::executor::{task, Executor}; | 14 | use embassy::executor::{task, Executor}; |
| 15 | use embassy::gpio::{WaitForHigh, WaitForLow}; | 15 | use embassy::traits::gpio::{WaitForHigh, WaitForLow}; |
| 16 | use embassy::util::Forever; | 16 | use embassy::util::Forever; |
| 17 | use embassy_nrf::gpiote::{Gpiote, GpiotePin}; | 17 | use embassy_nrf::gpiote::{Gpiote, GpiotePin}; |
| 18 | use embassy_nrf::interrupt; | 18 | use embassy_nrf::interrupt; |
diff --git a/embassy-nrf-examples/src/bin/qspi.rs b/embassy-nrf-examples/src/bin/qspi.rs index 790dedc91..587ed7ddb 100644 --- a/embassy-nrf-examples/src/bin/qspi.rs +++ b/embassy-nrf-examples/src/bin/qspi.rs | |||
| @@ -12,7 +12,7 @@ use futures::pin_mut; | |||
| 12 | use nrf52840_hal::gpio; | 12 | use nrf52840_hal::gpio; |
| 13 | 13 | ||
| 14 | use embassy::executor::{task, Executor}; | 14 | use embassy::executor::{task, Executor}; |
| 15 | use embassy::flash::Flash; | 15 | use embassy::traits::flash::Flash; |
| 16 | use embassy::util::Forever; | 16 | use embassy::util::Forever; |
| 17 | use embassy_nrf::{interrupt, qspi}; | 17 | use embassy_nrf::{interrupt, qspi}; |
| 18 | 18 | ||
diff --git a/embassy-nrf-examples/src/bin/uart.rs b/embassy-nrf-examples/src/bin/uart.rs index 50cdfd1e6..41f9e1276 100644 --- a/embassy-nrf-examples/src/bin/uart.rs +++ b/embassy-nrf-examples/src/bin/uart.rs | |||
| @@ -10,7 +10,7 @@ use cortex_m_rt::entry; | |||
| 10 | use defmt::panic; | 10 | use defmt::panic; |
| 11 | use embassy::executor::{task, Executor}; | 11 | use embassy::executor::{task, Executor}; |
| 12 | use embassy::time::{Duration, Timer}; | 12 | use embassy::time::{Duration, Timer}; |
| 13 | use embassy::uart::Uart; | 13 | use embassy::traits::uart::Uart; |
| 14 | use embassy::util::Forever; | 14 | use embassy::util::Forever; |
| 15 | use embassy_nrf::{interrupt, pac, rtc, uarte}; | 15 | use embassy_nrf::{interrupt, pac, rtc, uarte}; |
| 16 | use futures::future::{select, Either}; | 16 | use futures::future::{select, Either}; |
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index 78bb2aeb6..7cc649107 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -4,7 +4,7 @@ use core::ops::Deref; | |||
| 4 | use core::pin::Pin; | 4 | use core::pin::Pin; |
| 5 | use core::ptr; | 5 | use core::ptr; |
| 6 | use core::task::{Context, Poll}; | 6 | use core::task::{Context, Poll}; |
| 7 | use embassy::gpio::{WaitForHigh, WaitForLow}; | 7 | use embassy::traits::gpio::{WaitForHigh, WaitForLow}; |
| 8 | use embassy::interrupt::InterruptExt; | 8 | use embassy::interrupt::InterruptExt; |
| 9 | use embassy::util::Signal; | 9 | use embassy::util::Signal; |
| 10 | 10 | ||
diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs index bee6abfa1..cb7f5a5be 100644 --- a/embassy-nrf/src/qspi.rs +++ b/embassy-nrf/src/qspi.rs | |||
| @@ -23,7 +23,7 @@ use crate::util::peripheral::{PeripheralMutex, PeripheralState}; | |||
| 23 | // - activate/deactivate | 23 | // - activate/deactivate |
| 24 | // - set gpio in high drive | 24 | // - set gpio in high drive |
| 25 | 25 | ||
| 26 | use embassy::flash::{Error, Flash}; | 26 | use embassy::traits::flash::{Error, Flash}; |
| 27 | use embassy::util::{DropBomb, WakerRegistration}; | 27 | use embassy::util::{DropBomb, WakerRegistration}; |
| 28 | use futures::future::poll_fn; | 28 | use futures::future::poll_fn; |
| 29 | 29 | ||
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 9d5ff81aa..0cc9790b2 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs | |||
| @@ -207,7 +207,7 @@ where | |||
| 207 | } | 207 | } |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | impl<T: Instance> embassy::uart::Uart for Uarte<T> { | 210 | impl<T: Instance> embassy::traits::uart::Uart for Uarte<T> { |
| 211 | type ReceiveFuture<'a> = ReceiveFuture<'a, T>; | 211 | type ReceiveFuture<'a> = ReceiveFuture<'a, T>; |
| 212 | type SendFuture<'a> = SendFuture<'a, T>; | 212 | type SendFuture<'a> = SendFuture<'a, T>; |
| 213 | 213 | ||
| @@ -287,7 +287,7 @@ impl<'a, T> Future for SendFuture<'a, T> | |||
| 287 | where | 287 | where |
| 288 | T: Instance, | 288 | T: Instance, |
| 289 | { | 289 | { |
| 290 | type Output = Result<(), embassy::uart::Error>; | 290 | type Output = Result<(), embassy::traits::uart::Error>; |
| 291 | 291 | ||
| 292 | fn poll(self: core::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | 292 | fn poll(self: core::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { |
| 293 | let Self { uarte, buf } = unsafe { self.get_unchecked_mut() }; | 293 | let Self { uarte, buf } = unsafe { self.get_unchecked_mut() }; |
| @@ -355,7 +355,7 @@ impl<'a, T> Future for ReceiveFuture<'a, T> | |||
| 355 | where | 355 | where |
| 356 | T: Instance, | 356 | T: Instance, |
| 357 | { | 357 | { |
| 358 | type Output = Result<(), embassy::uart::Error>; | 358 | type Output = Result<(), embassy::traits::uart::Error>; |
| 359 | 359 | ||
| 360 | fn poll(self: core::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | 360 | fn poll(self: core::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { |
| 361 | let Self { uarte, buf } = unsafe { self.get_unchecked_mut() }; | 361 | let Self { uarte, buf } = unsafe { self.get_unchecked_mut() }; |
diff --git a/embassy-stm32f4-examples/src/bin/exti.rs b/embassy-stm32f4-examples/src/bin/exti.rs index d8de33816..6b3568d65 100644 --- a/embassy-stm32f4-examples/src/bin/exti.rs +++ b/embassy-stm32f4-examples/src/bin/exti.rs | |||
| @@ -9,7 +9,7 @@ use example_common::{panic, *}; | |||
| 9 | 9 | ||
| 10 | use cortex_m_rt::entry; | 10 | use cortex_m_rt::entry; |
| 11 | use embassy::executor::{task, Executor}; | 11 | use embassy::executor::{task, Executor}; |
| 12 | use embassy::gpio::*; | 12 | use embassy::traits::gpio::*; |
| 13 | use embassy::util::Forever; | 13 | use embassy::util::Forever; |
| 14 | use embassy_stm32f4::exti; | 14 | use embassy_stm32f4::exti; |
| 15 | use embassy_stm32f4::interrupt; | 15 | use embassy_stm32f4::interrupt; |
diff --git a/embassy-stm32f4-examples/src/bin/serial.rs b/embassy-stm32f4-examples/src/bin/serial.rs index 2cd1c8c35..72fd1a2f9 100644 --- a/embassy-stm32f4-examples/src/bin/serial.rs +++ b/embassy-stm32f4-examples/src/bin/serial.rs | |||
| @@ -10,7 +10,7 @@ use example_common::{panic, *}; | |||
| 10 | use cortex_m::singleton; | 10 | use cortex_m::singleton; |
| 11 | use cortex_m_rt::entry; | 11 | use cortex_m_rt::entry; |
| 12 | use embassy::executor::{task, Executor}; | 12 | use embassy::executor::{task, Executor}; |
| 13 | use embassy::uart::Uart; | 13 | use embassy::traits::uart::Uart; |
| 14 | use embassy::util::Forever; | 14 | use embassy::util::Forever; |
| 15 | use embassy_stm32f4::interrupt; | 15 | use embassy_stm32f4::interrupt; |
| 16 | use embassy_stm32f4::serial; | 16 | use embassy_stm32f4::serial; |
diff --git a/embassy-stm32f4/src/exti.rs b/embassy-stm32f4/src/exti.rs index 6a1e13000..7ec2197ef 100644 --- a/embassy-stm32f4/src/exti.rs +++ b/embassy-stm32f4/src/exti.rs | |||
| @@ -2,8 +2,8 @@ use core::future::Future; | |||
| 2 | use core::mem; | 2 | use core::mem; |
| 3 | use core::pin::Pin; | 3 | use core::pin::Pin; |
| 4 | 4 | ||
| 5 | use embassy::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | ||
| 6 | use embassy::interrupt::Interrupt; | 5 | use embassy::interrupt::Interrupt; |
| 6 | use embassy::traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | ||
| 7 | use embassy::util::InterruptFuture; | 7 | use embassy::util::InterruptFuture; |
| 8 | 8 | ||
| 9 | use crate::hal::gpio; | 9 | use crate::hal::gpio; |
diff --git a/embassy-stm32f4/src/serial.rs b/embassy-stm32f4/src/serial.rs index 8f594ca13..8a90e9fa3 100644 --- a/embassy-stm32f4/src/serial.rs +++ b/embassy-stm32f4/src/serial.rs | |||
| @@ -9,7 +9,7 @@ use core::ptr; | |||
| 9 | use core::sync::atomic::{self, Ordering}; | 9 | use core::sync::atomic::{self, Ordering}; |
| 10 | 10 | ||
| 11 | use embassy::interrupt::InterruptExt; | 11 | use embassy::interrupt::InterruptExt; |
| 12 | use embassy::uart::{Error, Uart}; | 12 | use embassy::traits::uart::{Error, Uart}; |
| 13 | use embassy::util::Signal; | 13 | use embassy::util::Signal; |
| 14 | 14 | ||
| 15 | use crate::hal::dma::config::DmaConfig; | 15 | use crate::hal::dma::config::DmaConfig; |
diff --git a/embassy-traits/Cargo.toml b/embassy-traits/Cargo.toml new file mode 100644 index 000000000..09db74ab9 --- /dev/null +++ b/embassy-traits/Cargo.toml | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | [package] | ||
| 2 | name = "embassy-traits" | ||
| 3 | version = "0.1.0" | ||
| 4 | authors = ["Dario Nieuwenhuis <[email protected]>"] | ||
| 5 | edition = "2018" | ||
| 6 | |||
| 7 | [dependencies] | ||
| 8 | defmt = { version = "0.2.0", optional = true } | ||
| 9 | |||
| 10 | [features] | ||
| 11 | std = [] | ||
| 12 | |||
| 13 | defmt-trace = [] | ||
| 14 | defmt-debug = [] | ||
| 15 | defmt-info = [] | ||
| 16 | defmt-warn = [] | ||
| 17 | defmt-error = [] \ No newline at end of file | ||
diff --git a/embassy/src/flash.rs b/embassy-traits/src/flash.rs index 145cc7684..145cc7684 100644 --- a/embassy/src/flash.rs +++ b/embassy-traits/src/flash.rs | |||
diff --git a/embassy/src/gpio.rs b/embassy-traits/src/gpio.rs index 4c3feac21..4c3feac21 100644 --- a/embassy/src/gpio.rs +++ b/embassy-traits/src/gpio.rs | |||
diff --git a/embassy-traits/src/lib.rs b/embassy-traits/src/lib.rs new file mode 100644 index 000000000..55af46cff --- /dev/null +++ b/embassy-traits/src/lib.rs | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | #![cfg_attr(not(feature = "std"), no_std)] | ||
| 2 | #![feature(generic_associated_types)] | ||
| 3 | #![feature(const_fn)] | ||
| 4 | #![feature(const_fn_fn_ptr_basics)] | ||
| 5 | #![feature(const_option)] | ||
| 6 | #![allow(incomplete_features)] | ||
| 7 | |||
| 8 | pub mod flash; | ||
| 9 | pub mod gpio; | ||
| 10 | pub mod uart; | ||
diff --git a/embassy/src/uart.rs b/embassy-traits/src/uart.rs index b40b9e9bd..b40b9e9bd 100644 --- a/embassy/src/uart.rs +++ b/embassy-traits/src/uart.rs | |||
diff --git a/embassy/Cargo.toml b/embassy/Cargo.toml index 1c977d84d..116ab2245 100644 --- a/embassy/Cargo.toml +++ b/embassy/Cargo.toml | |||
| @@ -5,12 +5,13 @@ authors = ["Dario Nieuwenhuis <[email protected]>"] | |||
| 5 | edition = "2018" | 5 | edition = "2018" |
| 6 | 6 | ||
| 7 | [features] | 7 | [features] |
| 8 | std = ["futures/std"] | 8 | std = ["futures/std", "embassy-traits/std"] |
| 9 | defmt-trace = [] | 9 | defmt = ["embassy-traits/defmt", "dep:defmt"] |
| 10 | defmt-debug = [] | 10 | defmt-trace = ["embassy-traits/defmt-trace"] |
| 11 | defmt-info = [] | 11 | defmt-debug = ["embassy-traits/defmt-debug"] |
| 12 | defmt-warn = [] | 12 | defmt-info = ["embassy-traits/defmt-info"] |
| 13 | defmt-error = [] | 13 | defmt-warn = ["embassy-traits/defmt-warn"] |
| 14 | defmt-error = ["embassy-traits/defmt-error"] | ||
| 14 | 15 | ||
| 15 | [dependencies] | 16 | [dependencies] |
| 16 | defmt = { version = "0.2.0", optional = true } | 17 | defmt = { version = "0.2.0", optional = true } |
| @@ -20,4 +21,5 @@ cortex-m = "0.7.1" | |||
| 20 | futures = { version = "0.3.5", default-features = false } | 21 | futures = { version = "0.3.5", default-features = false } |
| 21 | pin-project = { version = "1.0.2", default-features = false } | 22 | pin-project = { version = "1.0.2", default-features = false } |
| 22 | embassy-macros = { version = "0.1.0", path = "../embassy-macros"} | 23 | embassy-macros = { version = "0.1.0", path = "../embassy-macros"} |
| 24 | embassy-traits = { version = "0.1.0", path = "../embassy-traits"} | ||
| 23 | 25 | ||
diff --git a/embassy/src/lib.rs b/embassy/src/lib.rs index 0844df37c..f32a7a795 100644 --- a/embassy/src/lib.rs +++ b/embassy/src/lib.rs | |||
| @@ -9,10 +9,9 @@ | |||
| 9 | pub(crate) mod fmt; | 9 | pub(crate) mod fmt; |
| 10 | 10 | ||
| 11 | pub mod executor; | 11 | pub mod executor; |
| 12 | pub mod flash; | ||
| 13 | pub mod gpio; | ||
| 14 | pub mod interrupt; | 12 | pub mod interrupt; |
| 15 | pub mod io; | 13 | pub mod io; |
| 16 | pub mod time; | 14 | pub mod time; |
| 17 | pub mod uart; | ||
| 18 | pub mod util; | 15 | pub mod util; |
| 16 | |||
| 17 | pub use embassy_traits as traits; | ||
