Move traits to separate crate.
This commit is contained in:
parent
084b64053a
commit
9626aee7db
20 changed files with 53 additions and 22 deletions
2
.cargo/config
Normal file
2
.cargo/config
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[unstable]
|
||||||
|
namespaced-features = true
|
|
@ -2,6 +2,7 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"embassy",
|
"embassy",
|
||||||
|
"embassy-traits",
|
||||||
"embassy-nrf",
|
"embassy-nrf",
|
||||||
"embassy-stm32f4",
|
"embassy-stm32f4",
|
||||||
"embassy-nrf-examples",
|
"embassy-nrf-examples",
|
||||||
|
|
|
@ -7,7 +7,7 @@ Embassy is a project to make async/await a first-class option for embedded devel
|
||||||
`embassy` provides a set of traits and types specifically designed for `async` usage.
|
`embassy` provides a set of traits and types specifically designed for `async` usage.
|
||||||
|
|
||||||
- `embassy::io`: `AsyncBufRead`, `AsyncWrite`. Traits for byte-stream IO, essentially `no_std` compatible versions of `futures::io`.
|
- `embassy::io`: `AsyncBufRead`, `AsyncWrite`. Traits for byte-stream IO, essentially `no_std` compatible versions of `futures::io`.
|
||||||
- `embassy::flash`: Flash device trait.
|
- `embassy::traits::flash`: Flash device trait.
|
||||||
- `embassy::time`: `Clock` and `Alarm` traits. Std-like `Duration` and `Instant`.
|
- `embassy::time`: `Clock` and `Alarm` traits. Std-like `Duration` and `Instant`.
|
||||||
- More traits for SPI, I2C, UART async HAL coming soon.
|
- More traits for SPI, I2C, UART async HAL coming soon.
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ use defmt::panic;
|
||||||
use nrf52840_hal::gpio;
|
use nrf52840_hal::gpio;
|
||||||
|
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::{task, Executor};
|
||||||
use embassy::gpio::{WaitForHigh, WaitForLow};
|
use embassy::traits::gpio::{WaitForHigh, WaitForLow};
|
||||||
use embassy::util::Forever;
|
use embassy::util::Forever;
|
||||||
use embassy_nrf::gpiote::{Gpiote, GpiotePin};
|
use embassy_nrf::gpiote::{Gpiote, GpiotePin};
|
||||||
use embassy_nrf::interrupt;
|
use embassy_nrf::interrupt;
|
||||||
|
|
|
@ -12,7 +12,7 @@ use futures::pin_mut;
|
||||||
use nrf52840_hal::gpio;
|
use nrf52840_hal::gpio;
|
||||||
|
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::{task, Executor};
|
||||||
use embassy::flash::Flash;
|
use embassy::traits::flash::Flash;
|
||||||
use embassy::util::Forever;
|
use embassy::util::Forever;
|
||||||
use embassy_nrf::{interrupt, qspi};
|
use embassy_nrf::{interrupt, qspi};
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use cortex_m_rt::entry;
|
||||||
use defmt::panic;
|
use defmt::panic;
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::{task, Executor};
|
||||||
use embassy::time::{Duration, Timer};
|
use embassy::time::{Duration, Timer};
|
||||||
use embassy::uart::Uart;
|
use embassy::traits::uart::Uart;
|
||||||
use embassy::util::Forever;
|
use embassy::util::Forever;
|
||||||
use embassy_nrf::{interrupt, pac, rtc, uarte};
|
use embassy_nrf::{interrupt, pac, rtc, uarte};
|
||||||
use futures::future::{select, Either};
|
use futures::future::{select, Either};
|
||||||
|
|
|
@ -4,7 +4,7 @@ use core::ops::Deref;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
use core::ptr;
|
use core::ptr;
|
||||||
use core::task::{Context, Poll};
|
use core::task::{Context, Poll};
|
||||||
use embassy::gpio::{WaitForHigh, WaitForLow};
|
use embassy::traits::gpio::{WaitForHigh, WaitForLow};
|
||||||
use embassy::interrupt::InterruptExt;
|
use embassy::interrupt::InterruptExt;
|
||||||
use embassy::util::Signal;
|
use embassy::util::Signal;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::util::peripheral::{PeripheralMutex, PeripheralState};
|
||||||
// - activate/deactivate
|
// - activate/deactivate
|
||||||
// - set gpio in high drive
|
// - set gpio in high drive
|
||||||
|
|
||||||
use embassy::flash::{Error, Flash};
|
use embassy::traits::flash::{Error, Flash};
|
||||||
use embassy::util::{DropBomb, WakerRegistration};
|
use embassy::util::{DropBomb, WakerRegistration};
|
||||||
use futures::future::poll_fn;
|
use futures::future::poll_fn;
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Instance> embassy::uart::Uart for Uarte<T> {
|
impl<T: Instance> embassy::traits::uart::Uart for Uarte<T> {
|
||||||
type ReceiveFuture<'a> = ReceiveFuture<'a, T>;
|
type ReceiveFuture<'a> = ReceiveFuture<'a, T>;
|
||||||
type SendFuture<'a> = SendFuture<'a, T>;
|
type SendFuture<'a> = SendFuture<'a, T>;
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ impl<'a, T> Future for SendFuture<'a, T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
{
|
{
|
||||||
type Output = Result<(), embassy::uart::Error>;
|
type Output = Result<(), embassy::traits::uart::Error>;
|
||||||
|
|
||||||
fn poll(self: core::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(self: core::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
let Self { uarte, buf } = unsafe { self.get_unchecked_mut() };
|
let Self { uarte, buf } = unsafe { self.get_unchecked_mut() };
|
||||||
|
@ -355,7 +355,7 @@ impl<'a, T> Future for ReceiveFuture<'a, T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
{
|
{
|
||||||
type Output = Result<(), embassy::uart::Error>;
|
type Output = Result<(), embassy::traits::uart::Error>;
|
||||||
|
|
||||||
fn poll(self: core::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(self: core::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
let Self { uarte, buf } = unsafe { self.get_unchecked_mut() };
|
let Self { uarte, buf } = unsafe { self.get_unchecked_mut() };
|
||||||
|
|
|
@ -9,7 +9,7 @@ use example_common::{panic, *};
|
||||||
|
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::{task, Executor};
|
||||||
use embassy::gpio::*;
|
use embassy::traits::gpio::*;
|
||||||
use embassy::util::Forever;
|
use embassy::util::Forever;
|
||||||
use embassy_stm32f4::exti;
|
use embassy_stm32f4::exti;
|
||||||
use embassy_stm32f4::interrupt;
|
use embassy_stm32f4::interrupt;
|
||||||
|
|
|
@ -10,7 +10,7 @@ use example_common::{panic, *};
|
||||||
use cortex_m::singleton;
|
use cortex_m::singleton;
|
||||||
use cortex_m_rt::entry;
|
use cortex_m_rt::entry;
|
||||||
use embassy::executor::{task, Executor};
|
use embassy::executor::{task, Executor};
|
||||||
use embassy::uart::Uart;
|
use embassy::traits::uart::Uart;
|
||||||
use embassy::util::Forever;
|
use embassy::util::Forever;
|
||||||
use embassy_stm32f4::interrupt;
|
use embassy_stm32f4::interrupt;
|
||||||
use embassy_stm32f4::serial;
|
use embassy_stm32f4::serial;
|
||||||
|
|
|
@ -2,8 +2,8 @@ use core::future::Future;
|
||||||
use core::mem;
|
use core::mem;
|
||||||
use core::pin::Pin;
|
use core::pin::Pin;
|
||||||
|
|
||||||
use embassy::gpio::{WaitForFallingEdge, WaitForRisingEdge};
|
|
||||||
use embassy::interrupt::Interrupt;
|
use embassy::interrupt::Interrupt;
|
||||||
|
use embassy::traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
|
||||||
use embassy::util::InterruptFuture;
|
use embassy::util::InterruptFuture;
|
||||||
|
|
||||||
use crate::hal::gpio;
|
use crate::hal::gpio;
|
||||||
|
|
|
@ -9,7 +9,7 @@ use core::ptr;
|
||||||
use core::sync::atomic::{self, Ordering};
|
use core::sync::atomic::{self, Ordering};
|
||||||
|
|
||||||
use embassy::interrupt::InterruptExt;
|
use embassy::interrupt::InterruptExt;
|
||||||
use embassy::uart::{Error, Uart};
|
use embassy::traits::uart::{Error, Uart};
|
||||||
use embassy::util::Signal;
|
use embassy::util::Signal;
|
||||||
|
|
||||||
use crate::hal::dma::config::DmaConfig;
|
use crate::hal::dma::config::DmaConfig;
|
||||||
|
|
17
embassy-traits/Cargo.toml
Normal file
17
embassy-traits/Cargo.toml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
[package]
|
||||||
|
name = "embassy-traits"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Dario Nieuwenhuis <dirbaio@dirbaio.net>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
defmt = { version = "0.2.0", optional = true }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
std = []
|
||||||
|
|
||||||
|
defmt-trace = []
|
||||||
|
defmt-debug = []
|
||||||
|
defmt-info = []
|
||||||
|
defmt-warn = []
|
||||||
|
defmt-error = []
|
10
embassy-traits/src/lib.rs
Normal file
10
embassy-traits/src/lib.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
#![feature(generic_associated_types)]
|
||||||
|
#![feature(const_fn)]
|
||||||
|
#![feature(const_fn_fn_ptr_basics)]
|
||||||
|
#![feature(const_option)]
|
||||||
|
#![allow(incomplete_features)]
|
||||||
|
|
||||||
|
pub mod flash;
|
||||||
|
pub mod gpio;
|
||||||
|
pub mod uart;
|
|
@ -5,12 +5,13 @@ authors = ["Dario Nieuwenhuis <dirbaio@dirbaio.net>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
std = ["futures/std"]
|
std = ["futures/std", "embassy-traits/std"]
|
||||||
defmt-trace = []
|
defmt = ["embassy-traits/defmt", "dep:defmt"]
|
||||||
defmt-debug = []
|
defmt-trace = ["embassy-traits/defmt-trace"]
|
||||||
defmt-info = []
|
defmt-debug = ["embassy-traits/defmt-debug"]
|
||||||
defmt-warn = []
|
defmt-info = ["embassy-traits/defmt-info"]
|
||||||
defmt-error = []
|
defmt-warn = ["embassy-traits/defmt-warn"]
|
||||||
|
defmt-error = ["embassy-traits/defmt-error"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
defmt = { version = "0.2.0", optional = true }
|
defmt = { version = "0.2.0", optional = true }
|
||||||
|
@ -20,4 +21,5 @@ cortex-m = "0.7.1"
|
||||||
futures = { version = "0.3.5", default-features = false }
|
futures = { version = "0.3.5", default-features = false }
|
||||||
pin-project = { version = "1.0.2", default-features = false }
|
pin-project = { version = "1.0.2", default-features = false }
|
||||||
embassy-macros = { version = "0.1.0", path = "../embassy-macros"}
|
embassy-macros = { version = "0.1.0", path = "../embassy-macros"}
|
||||||
|
embassy-traits = { version = "0.1.0", path = "../embassy-traits"}
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,9 @@
|
||||||
pub(crate) mod fmt;
|
pub(crate) mod fmt;
|
||||||
|
|
||||||
pub mod executor;
|
pub mod executor;
|
||||||
pub mod flash;
|
|
||||||
pub mod gpio;
|
|
||||||
pub mod interrupt;
|
pub mod interrupt;
|
||||||
pub mod io;
|
pub mod io;
|
||||||
pub mod time;
|
pub mod time;
|
||||||
pub mod uart;
|
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
|
||||||
|
pub use embassy_traits as traits;
|
||||||
|
|
Loading…
Reference in a new issue