Merge pull request #30 from embassy-rs/afit
feat: use async fn in trait
This commit is contained in:
commit
432240162a
4 changed files with 50 additions and 65 deletions
|
@ -22,5 +22,5 @@ cortex-m-rt = "0.7.0"
|
||||||
futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] }
|
futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] }
|
||||||
|
|
||||||
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.9" }
|
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.9" }
|
||||||
embedded-hal-async = { version = "0.1.0-alpha.3" }
|
embedded-hal-async = { version = "0.2.0-alpha.0" }
|
||||||
num_enum = { version = "0.5.7", default-features = false }
|
num_enum = { version = "0.5.7", default-features = false }
|
||||||
|
|
|
@ -22,18 +22,18 @@ cortex-m-rt = "0.7.0"
|
||||||
futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] }
|
futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] }
|
||||||
|
|
||||||
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.9" }
|
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.9" }
|
||||||
embedded-hal-async = { version = "0.1.0-alpha.3" }
|
embedded-hal-async = { version = "0.2.0-alpha.0" }
|
||||||
embedded-io = { version = "0.3.0", features = ["async", "defmt"] }
|
embedded-io = { version = "0.4.0", features = ["async", "defmt"] }
|
||||||
heapless = "0.7.15"
|
heapless = "0.7.15"
|
||||||
|
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "c53614f057cd7d9ac6e86aebd1fb6c1a1055d8b6" }
|
embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "645fb66a5122bdc8180e0e65d076ca103431a426" }
|
||||||
embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "c53614f057cd7d9ac6e86aebd1fb6c1a1055d8b6" }
|
embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "645fb66a5122bdc8180e0e65d076ca103431a426" }
|
||||||
embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "c53614f057cd7d9ac6e86aebd1fb6c1a1055d8b6" }
|
embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "645fb66a5122bdc8180e0e65d076ca103431a426" }
|
||||||
embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "c53614f057cd7d9ac6e86aebd1fb6c1a1055d8b6" }
|
embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "645fb66a5122bdc8180e0e65d076ca103431a426" }
|
||||||
embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "c53614f057cd7d9ac6e86aebd1fb6c1a1055d8b6" }
|
embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "645fb66a5122bdc8180e0e65d076ca103431a426" }
|
||||||
embassy-net = { git = "https://github.com/embassy-rs/embassy", rev = "c53614f057cd7d9ac6e86aebd1fb6c1a1055d8b6" }
|
embassy-net = { git = "https://github.com/embassy-rs/embassy", rev = "645fb66a5122bdc8180e0e65d076ca103431a426" }
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
debug = 2
|
debug = 2
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
|
#![feature(async_fn_in_trait)]
|
||||||
|
#![allow(incomplete_features)]
|
||||||
|
|
||||||
use core::convert::Infallible;
|
use core::convert::Infallible;
|
||||||
use core::future::Future;
|
|
||||||
|
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
|
@ -155,22 +156,13 @@ impl ErrorType for MySpi {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SpiBusFlush for MySpi {
|
impl SpiBusFlush for MySpi {
|
||||||
type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>>
|
async fn flush(&mut self) -> Result<(), Self::Error> {
|
||||||
where
|
Ok(())
|
||||||
Self: 'a;
|
|
||||||
|
|
||||||
fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> {
|
|
||||||
async move { Ok(()) }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SpiBusRead<u32> for MySpi {
|
impl SpiBusRead<u32> for MySpi {
|
||||||
type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a
|
async fn read(&mut self, words: &mut [u32]) -> Result<(), Self::Error> {
|
||||||
where
|
|
||||||
Self: 'a;
|
|
||||||
|
|
||||||
fn read<'a>(&'a mut self, words: &'a mut [u32]) -> Self::ReadFuture<'a> {
|
|
||||||
async move {
|
|
||||||
self.dio.set_as_input();
|
self.dio.set_as_input();
|
||||||
for word in words {
|
for word in words {
|
||||||
let mut w = 0;
|
let mut w = 0;
|
||||||
|
@ -192,15 +184,9 @@ impl SpiBusRead<u32> for MySpi {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl SpiBusWrite<u32> for MySpi {
|
impl SpiBusWrite<u32> for MySpi {
|
||||||
type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a
|
async fn write(&mut self, words: &[u32]) -> Result<(), Self::Error> {
|
||||||
where
|
|
||||||
Self: 'a;
|
|
||||||
|
|
||||||
fn write<'a>(&'a mut self, words: &'a [u32]) -> Self::WriteFuture<'a> {
|
|
||||||
async move {
|
|
||||||
self.dio.set_as_output();
|
self.dio.set_as_output();
|
||||||
for word in words {
|
for word in words {
|
||||||
let mut word = *word;
|
let mut word = *word;
|
||||||
|
@ -225,4 +211,3 @@ impl SpiBusWrite<u32> for MySpi {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Before upgrading check that everything is available on all tier1 targets here:
|
# Before upgrading check that everything is available on all tier1 targets here:
|
||||||
# https://rust-lang.github.io/rustup-components-history
|
# https://rust-lang.github.io/rustup-components-history
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2022-10-25"
|
channel = "nightly-2022-11-22"
|
||||||
components = [ "rust-src", "rustfmt" ]
|
components = [ "rust-src", "rustfmt" ]
|
||||||
targets = [
|
targets = [
|
||||||
"thumbv6m-none-eabi",
|
"thumbv6m-none-eabi",
|
||||||
|
|
Loading…
Reference in a new issue