summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/rust.yml2
-rw-r--r--Cargo.lock43
-rw-r--r--Cargo.toml1
-rwxr-xr-xci.sh (renamed from test-build.sh)0
-rw-r--r--examples/Cargo.toml1
-rw-r--r--examples/src/bin/ble_peripheral_onoff.rs2
-rw-r--r--examples/src/bin/flash.rs8
-rw-r--r--nrf-softdevice/src/flash.rs15
8 files changed, 46 insertions, 26 deletions
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index 955c1bb..225b523 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -31,7 +31,7 @@ jobs:
components: rustfmt
- name: Build
- run: ./test-build.sh
+ run: ./ci.sh
- name: Format
run: cargo fmt --verbose
diff --git a/Cargo.lock b/Cargo.lock
index f007078..2fa159f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -42,12 +42,12 @@ dependencies = [
[[package]]
name = "as-slice"
-version = "0.1.4"
+version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bb4d1c23475b74e3672afa8c2be22040b8b7783ad9b461021144ed10a46bb0e6"
+checksum = "45403b49e3954a4b8428a0ac21a4b7afadccf92bfd96273f1a58cd4812496ae0"
dependencies = [
- "generic-array 0.12.3",
- "generic-array 0.13.2",
+ "generic-array 0.12.4",
+ "generic-array 0.13.3",
"generic-array 0.14.4",
"stable_deref_trait",
]
@@ -249,11 +249,12 @@ dependencies = [
[[package]]
name = "embassy"
version = "0.1.0"
-source = "git+https://github.com/akiles/embassy#de796d3e80cb7af24bcf4c9cc0f8167bfa93cc84"
+source = "git+https://github.com/akiles/embassy#88946840d1f6fdc924a4f0a9980d17f1d2c456fa"
dependencies = [
"cortex-m 0.7.1",
"defmt",
"embassy-macros",
+ "embassy-traits",
"futures",
"pin-project",
]
@@ -261,7 +262,7 @@ dependencies = [
[[package]]
name = "embassy-macros"
version = "0.1.0"
-source = "git+https://github.com/akiles/embassy#de796d3e80cb7af24bcf4c9cc0f8167bfa93cc84"
+source = "git+https://github.com/akiles/embassy#88946840d1f6fdc924a4f0a9980d17f1d2c456fa"
dependencies = [
"darling",
"quote",
@@ -271,7 +272,7 @@ dependencies = [
[[package]]
name = "embassy-nrf"
version = "0.1.0"
-source = "git+https://github.com/akiles/embassy#de796d3e80cb7af24bcf4c9cc0f8167bfa93cc84"
+source = "git+https://github.com/akiles/embassy#88946840d1f6fdc924a4f0a9980d17f1d2c456fa"
dependencies = [
"cortex-m 0.7.1",
"cortex-m-rt",
@@ -279,11 +280,20 @@ dependencies = [
"embassy",
"embedded-dma",
"embedded-hal",
+ "futures",
"nrf52840-hal",
"nrf52840-pac",
]
[[package]]
+name = "embassy-traits"
+version = "0.1.0"
+source = "git+https://github.com/akiles/embassy#88946840d1f6fdc924a4f0a9980d17f1d2c456fa"
+dependencies = [
+ "defmt",
+]
+
+[[package]]
name = "embedded-dma"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -380,18 +390,18 @@ dependencies = [
[[package]]
name = "generic-array"
-version = "0.12.3"
+version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
+checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
dependencies = [
"typenum",
]
[[package]]
name = "generic-array"
-version = "0.13.2"
+version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ed1e761351b56f54eb9dcd0cfaca9fd0daecf93918e1cfc01c8a3d26ee7adcd"
+checksum = "f797e67af32588215eaaab8327027ee8e71b9dd0b2b26996aedf20c030fce309"
dependencies = [
"typenum",
]
@@ -428,7 +438,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74911a68a1658cfcfb61bc0ccfbd536e3b6e906f8c2f7883ee50157e3e2184f1"
dependencies = [
"as-slice",
- "generic-array 0.13.2",
+ "generic-array 0.13.3",
"hash32",
"stable_deref_trait",
]
@@ -554,6 +564,7 @@ dependencies = [
"defmt",
"embassy",
"embassy-nrf",
+ "embassy-traits",
"fixed",
"futures",
"heapless",
@@ -694,9 +705,9 @@ dependencies = [
[[package]]
name = "once_cell"
-version = "1.7.0"
+version = "1.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "10acf907b94fc1b1a152d08ef97e7759650268cf986bf127f387e602b02c7e5a"
+checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3"
[[package]]
name = "panic-probe"
@@ -739,9 +750,9 @@ dependencies = [
[[package]]
name = "pin-project-lite"
-version = "0.2.4"
+version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827"
+checksum = "0cf491442e4b033ed1c722cb9f0df5fcfcf4de682466c46469c36bc47dc5548a"
[[package]]
name = "pin-utils"
diff --git a/Cargo.toml b/Cargo.toml
index a00e7f2..6396993 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,6 +24,7 @@ exclude = [
embassy = { git = "https://github.com/akiles/embassy" }
embassy-nrf = { git = "https://github.com/akiles/embassy" }
embassy-macros = { git = "https://github.com/akiles/embassy" }
+embassy-traits = { git = "https://github.com/akiles/embassy" }
[profile.dev]
codegen-units = 1
diff --git a/test-build.sh b/ci.sh
index 4e89ded..4e89ded 100755
--- a/test-build.sh
+++ b/ci.sh
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
index b5b5bfa..09449c6 100644
--- a/examples/Cargo.toml
+++ b/examples/Cargo.toml
@@ -24,6 +24,7 @@ ble-gatt-client = ["nrf-softdevice/ble-gatt-client"]
[dependencies]
embassy = { version = "0.1.0", features = ["defmt"]}
+embassy-traits = { version = "0.1.0", features = ["defmt"]}
embassy-nrf = { version = "0.1.0", features = [ "defmt", "52840" ]}
cortex-m = { version = "0.6.4" }
cortex-m-rt = "0.6.13"
diff --git a/examples/src/bin/ble_peripheral_onoff.rs b/examples/src/bin/ble_peripheral_onoff.rs
index d516991..9b65597 100644
--- a/examples/src/bin/ble_peripheral_onoff.rs
+++ b/examples/src/bin/ble_peripheral_onoff.rs
@@ -11,7 +11,7 @@ use core::mem;
use cortex_m_rt::entry;
use defmt::{panic, *};
use embassy::executor::{task, Executor};
-use embassy::gpio::WaitForLow;
+use embassy::traits::gpio::WaitForLow;
use embassy::util::Forever;
use embassy_nrf::gpiote::{Gpiote, GpiotePin};
use embassy_nrf::interrupt;
diff --git a/examples/src/bin/flash.rs b/examples/src/bin/flash.rs
index 84a71ab..e8407cd 100644
--- a/examples/src/bin/flash.rs
+++ b/examples/src/bin/flash.rs
@@ -10,9 +10,10 @@ use example_common::*;
use cortex_m_rt::entry;
use defmt::*;
use embassy::executor::{task, Executor};
-use embassy::flash::Flash as _;
+use embassy::traits::flash::Flash as _;
use embassy::util::Forever;
+use futures::pin_mut;
use nrf_softdevice::{Flash, Softdevice};
static EXECUTOR: Forever<Executor> = Forever::new();
@@ -25,13 +26,14 @@ async fn softdevice_task(sd: &'static Softdevice) {
#[task]
async fn flash_task(sd: &'static Softdevice) {
let mut f = Flash::take(sd);
+ pin_mut!(f);
info!("starting erase");
- unwrap!(f.erase(0x80000).await);
+ unwrap!(f.as_mut().erase(0x80000).await);
info!("erased!");
info!("starting write");
- unwrap!(f.write(0x80000, &[1, 2, 3, 4]).await);
+ unwrap!(f.as_mut().write(0x80000, &[1, 2, 3, 4]).await);
info!("write done!");
}
diff --git a/nrf-softdevice/src/flash.rs b/nrf-softdevice/src/flash.rs
index 46edda2..4fd2db6 100644
--- a/nrf-softdevice/src/flash.rs
+++ b/nrf-softdevice/src/flash.rs
@@ -1,7 +1,8 @@
use core::future::Future;
use core::marker::PhantomData;
+use core::pin::Pin;
use core::sync::atomic::{AtomicBool, Ordering};
-use embassy::flash::Error as FlashError;
+use embassy::traits::flash::Error as FlashError;
use crate::fmt::{panic, *};
use crate::raw;
@@ -48,12 +49,16 @@ pub(crate) fn on_flash_error() {
SIGNAL.signal(Err(FlashError::Failed))
}
-impl embassy::flash::Flash for Flash {
+impl embassy::traits::flash::Flash for Flash {
type ReadFuture<'a> = impl Future<Output = Result<(), FlashError>> + 'a;
type WriteFuture<'a> = impl Future<Output = Result<(), FlashError>> + 'a;
type ErasePageFuture<'a> = impl Future<Output = Result<(), FlashError>> + 'a;
- fn read<'a>(&'a mut self, address: usize, data: &'a mut [u8]) -> Self::ReadFuture<'a> {
+ fn read<'a>(
+ self: Pin<&'a mut Self>,
+ address: usize,
+ data: &'a mut [u8],
+ ) -> Self::ReadFuture<'a> {
async move {
// Reading is simple since SoC flash is memory-mapped :)
// TODO check addr/len is in bounds.
@@ -66,7 +71,7 @@ impl embassy::flash::Flash for Flash {
}
}
- fn write<'a>(&'a mut self, address: usize, data: &'a [u8]) -> Self::WriteFuture<'a> {
+ fn write<'a>(self: Pin<&'a mut Self>, address: usize, data: &'a [u8]) -> Self::WriteFuture<'a> {
async move {
let data_ptr = data.as_ptr();
let data_len = data.len() as u32;
@@ -97,7 +102,7 @@ impl embassy::flash::Flash for Flash {
}
}
- fn erase<'a>(&'a mut self, address: usize) -> Self::ErasePageFuture<'a> {
+ fn erase<'a>(self: Pin<&'a mut Self>, address: usize) -> Self::ErasePageFuture<'a> {
async move {
if address % Self::PAGE_SIZE != 0 {
return Err(FlashError::AddressMisaligned);