From 3251a21fb7f7d0bcbd4e900274f4917c58ab9c87 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 22 Apr 2022 19:58:24 +0200 Subject: [PATCH] Switch to crates.io embedded-hal, embedded-hal-async. This temporarily removes support for the async UART trait, since it's not yet in embedded-hal-async. --- embassy-lora/Cargo.toml | 4 +-- embassy-nrf/Cargo.toml | 4 +-- embassy-nrf/src/uarte.rs | 2 +- embassy-rp/Cargo.toml | 4 +-- embassy-stm32/Cargo.toml | 4 +-- embassy-stm32/src/usart/mod.rs | 2 +- embassy-traits/Cargo.toml | 4 +-- embassy-traits/src/adapter.rs | 2 ++ embassy/Cargo.toml | 4 +-- examples/rp/Cargo.toml | 5 ++-- examples/rp/src/bin/spi_display.rs | 12 ++++---- examples/stm32h7/Cargo.toml | 3 +- examples/stm32l4/Cargo.toml | 3 +- .../stm32l4/src/bin/usart_blocking_async.rs | 30 ------------------- tests/stm32/Cargo.toml | 3 +- 15 files changed, 31 insertions(+), 55 deletions(-) delete mode 100644 examples/stm32l4/src/bin/usart_blocking_async.rs diff --git a/embassy-lora/Cargo.toml b/embassy-lora/Cargo.toml index 97af7dd79..9ce5d9af0 100644 --- a/embassy-lora/Cargo.toml +++ b/embassy-lora/Cargo.toml @@ -27,8 +27,8 @@ log = { version = "0.4.14", optional = true } embassy = { version = "0.1.0", path = "../embassy", default-features = false } embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false, optional = true } -embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.7", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2", optional = true} -embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2"} +embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } +embedded-hal-async = { version = "0.1.0-alpha.0" } embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common", default-features = false } futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] } embedded-hal = { version = "0.2", features = ["unproven"] } diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 5299c04a8..5bb76abf4 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -67,8 +67,8 @@ embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } embassy-usb = {version = "0.1.0", path = "../embassy-usb", optional=true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.7", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2", optional = true} -embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true} +embedded-hal-async = { version = "0.1.0-alpha.0", optional = true} defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 2b01dd075..4f1c3da1e 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs @@ -935,7 +935,7 @@ mod eh1 { } cfg_if::cfg_if! { - if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] { + if #[cfg(all(feature = "unstable-traits", feature = "nightly", feature = "_todo_embedded_hal_serial"))] { use core::future::Future; impl<'d, T: Instance> embedded_hal_async::serial::Read for Uarte<'d, T> { diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index deed88730..17fce54e5 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -42,5 +42,5 @@ rp2040-pac2 = { git = "https://github.com/embassy-rs/rp2040-pac2", rev="9ad7223a #rp2040-pac2 = { path = "../../rp/rp2040-pac2", features = ["rt"] } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.7", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2", optional = true} -embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true} +embedded-hal-async = { version = "0.1.0-alpha.0", optional = true} diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 91a65193f..1c9616b71 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -39,8 +39,8 @@ embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" } embassy-net = { version = "0.1.0", path = "../embassy-net", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.7", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2", optional = true} -embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true} +embedded-hal-async = { version = "0.1.0-alpha.0", optional = true} defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index caea8d71b..22224215c 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs @@ -363,7 +363,7 @@ mod eh1 { } cfg_if::cfg_if! { - if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] { + if #[cfg(all(feature = "unstable-traits", feature = "nightly", feature = "_todo_embedded_hal_serial"))] { use core::future::Future; impl<'d, T: Instance, TxDma> embedded_hal_async::serial::Write for UartTx<'d, T, TxDma> diff --git a/embassy-traits/Cargo.toml b/embassy-traits/Cargo.toml index e23259eb4..4e0e7d22d 100644 --- a/embassy-traits/Cargo.toml +++ b/embassy-traits/Cargo.toml @@ -9,8 +9,8 @@ std = [] [dependencies] embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.7", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2" } -embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2"} +embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } +embedded-hal-async = { version = "0.1.0-alpha.0" } embedded-storage = "0.3.0" embedded-storage-async = "0.3.0" nb = "1.0.0" diff --git a/embassy-traits/src/adapter.rs b/embassy-traits/src/adapter.rs index b709f389f..033efb7ef 100644 --- a/embassy-traits/src/adapter.rs +++ b/embassy-traits/src/adapter.rs @@ -161,6 +161,7 @@ where type Error = E; } +#[cfg(feature = "_todo_embedded_hal_serial")] impl embedded_hal_async::serial::Read for BlockingAsync where T: serial::Read, @@ -185,6 +186,7 @@ where } } +#[cfg(feature = "_todo_embedded_hal_serial")] impl embedded_hal_async::serial::Write for BlockingAsync where T: blocking::serial::Write + serial::Read, diff --git a/embassy/Cargo.toml b/embassy/Cargo.toml index 7753c3b05..1baeb6c3d 100644 --- a/embassy/Cargo.toml +++ b/embassy/Cargo.toml @@ -57,8 +57,8 @@ defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6" } -embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.7", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2", optional = true} -embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true} +embedded-hal-async = { version = "0.1.0-alpha.0", optional = true} futures = { version = "0.3.17", default-features = false, features = [ "cfg-target-has-atomic", "unstable" ] } pin-project = { version = "1.0.8", default-features = false } diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 2cce0af37..827adea23 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml @@ -20,7 +20,8 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa display-interface-spi = "0.4.1" embedded-graphics = "0.7.1" st7789 = "0.6.1" - -embedded-hal = { version = "1.0.0-alpha.7", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2" } display-interface = "0.4.1" byte-slice-cast = { version = "1.2.0", default-features = false } + +embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } +embedded-hal-async = { version = "0.1.0-alpha.0" } diff --git a/examples/rp/src/bin/spi_display.rs b/examples/rp/src/bin/spi_display.rs index bc93e0617..5c3c4c4c5 100644 --- a/examples/rp/src/bin/spi_display.rs +++ b/examples/rp/src/bin/spi_display.rs @@ -110,9 +110,9 @@ mod shared_spi { use core::cell::RefCell; use core::fmt::Debug; - use embedded_hal::digital::blocking::OutputPin; - use embedded_hal::spi; - use embedded_hal::spi::blocking::SpiDevice; + use embedded_hal_1::digital::blocking::OutputPin; + use embedded_hal_1::spi; + use embedded_hal_1::spi::blocking::SpiDevice; #[derive(Copy, Clone, Eq, PartialEq, Debug)] pub enum SpiDeviceWithCsError { @@ -184,7 +184,7 @@ mod shared_spi { /// Driver for the XPT2046 resistive touchscreen sensor mod touch { - use embedded_hal::spi::blocking::{SpiBus, SpiBusRead, SpiBusWrite, SpiDevice}; + use embedded_hal_1::spi::blocking::{SpiBus, SpiBusRead, SpiBusWrite, SpiDevice}; struct Calibration { x1: i32, @@ -248,8 +248,8 @@ mod touch { mod my_display_interface { use display_interface::{DataFormat, DisplayError, WriteOnlyDataCommand}; - use embedded_hal::digital::blocking::OutputPin; - use embedded_hal::spi::blocking::{SpiBusWrite, SpiDevice}; + use embedded_hal_1::digital::blocking::OutputPin; + use embedded_hal_1::spi::blocking::{SpiBusWrite, SpiDevice}; /// SPI display interface. /// diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index f237a8173..419bbec31 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -18,7 +18,8 @@ defmt-rtt = "0.3" cortex-m = "0.7.3" cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2"} +embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } +embedded-hal-async = { version = "0.1.0-alpha.0" } panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.7.5", default-features = false } diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index 5838d01db..2da549bb2 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml @@ -18,7 +18,8 @@ defmt-rtt = "0.3" cortex-m = "0.7.3" cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2"} +embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } +embedded-hal-async = { version = "0.1.0-alpha.0" } panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.7.5", default-features = false } diff --git a/examples/stm32l4/src/bin/usart_blocking_async.rs b/examples/stm32l4/src/bin/usart_blocking_async.rs deleted file mode 100644 index 7efccace5..000000000 --- a/examples/stm32l4/src/bin/usart_blocking_async.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![no_std] -#![no_main] -#![feature(type_alias_impl_trait)] - -use defmt_rtt as _; // global logger -use panic_probe as _; - -use defmt::*; -use embassy::executor::Spawner; -use embassy_stm32::dma::NoDma; -use embassy_stm32::usart::{Config, Uart}; -use embassy_stm32::Peripherals; -use embassy_traits::adapter::BlockingAsync; -use embedded_hal_async::serial::{Read, Write}; - -#[embassy::main] -async fn main(_spawner: Spawner, p: Peripherals) { - let config = Config::default(); - let usart = Uart::new(p.UART4, p.PA1, p.PA0, NoDma, NoDma, config); - let mut usart = BlockingAsync::new(usart); - - unwrap!(usart.write(b"Hello Embassy World!\r\n").await); - info!("wrote Hello, starting echo"); - - let mut buf = [0u8; 1]; - loop { - unwrap!(usart.read(&mut buf).await); - unwrap!(usart.write(&buf).await); - } -} diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 9893b0289..260ac223b 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -23,7 +23,8 @@ defmt-rtt = "0.3.0" cortex-m = "0.7.3" cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2"} +embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } +embedded-hal-async = { version = "0.1.0-alpha.0" } panic-probe = { version = "0.3.0", features = ["print-defmt"] } [profile.dev]