diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-04-22 19:58:24 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-04-22 19:58:24 +0200 |
| commit | 3251a21fb7f7d0bcbd4e900274f4917c58ab9c87 (patch) | |
| tree | 1193acee1e41822b0cbf538f6271ccad35c056aa /examples | |
| parent | ea0a701ebd142ea42e05e51e844bd53cc9bdf354 (diff) | |
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.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/rp/Cargo.toml | 5 | ||||
| -rw-r--r-- | examples/rp/src/bin/spi_display.rs | 12 | ||||
| -rw-r--r-- | examples/stm32h7/Cargo.toml | 3 | ||||
| -rw-r--r-- | examples/stm32l4/Cargo.toml | 3 | ||||
| -rw-r--r-- | examples/stm32l4/src/bin/usart_blocking_async.rs | 30 |
5 files changed, 13 insertions, 40 deletions
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 | |||
| 20 | display-interface-spi = "0.4.1" | 20 | display-interface-spi = "0.4.1" |
| 21 | embedded-graphics = "0.7.1" | 21 | embedded-graphics = "0.7.1" |
| 22 | st7789 = "0.6.1" | 22 | st7789 = "0.6.1" |
| 23 | |||
| 24 | embedded-hal = { version = "1.0.0-alpha.7", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2" } | ||
| 25 | display-interface = "0.4.1" | 23 | display-interface = "0.4.1" |
| 26 | byte-slice-cast = { version = "1.2.0", default-features = false } | 24 | byte-slice-cast = { version = "1.2.0", default-features = false } |
| 25 | |||
| 26 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } | ||
| 27 | 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 { | |||
| 110 | use core::cell::RefCell; | 110 | use core::cell::RefCell; |
| 111 | use core::fmt::Debug; | 111 | use core::fmt::Debug; |
| 112 | 112 | ||
| 113 | use embedded_hal::digital::blocking::OutputPin; | 113 | use embedded_hal_1::digital::blocking::OutputPin; |
| 114 | use embedded_hal::spi; | 114 | use embedded_hal_1::spi; |
| 115 | use embedded_hal::spi::blocking::SpiDevice; | 115 | use embedded_hal_1::spi::blocking::SpiDevice; |
| 116 | 116 | ||
| 117 | #[derive(Copy, Clone, Eq, PartialEq, Debug)] | 117 | #[derive(Copy, Clone, Eq, PartialEq, Debug)] |
| 118 | pub enum SpiDeviceWithCsError<BUS, CS> { | 118 | pub enum SpiDeviceWithCsError<BUS, CS> { |
| @@ -184,7 +184,7 @@ mod shared_spi { | |||
| 184 | 184 | ||
| 185 | /// Driver for the XPT2046 resistive touchscreen sensor | 185 | /// Driver for the XPT2046 resistive touchscreen sensor |
| 186 | mod touch { | 186 | mod touch { |
| 187 | use embedded_hal::spi::blocking::{SpiBus, SpiBusRead, SpiBusWrite, SpiDevice}; | 187 | use embedded_hal_1::spi::blocking::{SpiBus, SpiBusRead, SpiBusWrite, SpiDevice}; |
| 188 | 188 | ||
| 189 | struct Calibration { | 189 | struct Calibration { |
| 190 | x1: i32, | 190 | x1: i32, |
| @@ -248,8 +248,8 @@ mod touch { | |||
| 248 | 248 | ||
| 249 | mod my_display_interface { | 249 | mod my_display_interface { |
| 250 | use display_interface::{DataFormat, DisplayError, WriteOnlyDataCommand}; | 250 | use display_interface::{DataFormat, DisplayError, WriteOnlyDataCommand}; |
| 251 | use embedded_hal::digital::blocking::OutputPin; | 251 | use embedded_hal_1::digital::blocking::OutputPin; |
| 252 | use embedded_hal::spi::blocking::{SpiBusWrite, SpiDevice}; | 252 | use embedded_hal_1::spi::blocking::{SpiBusWrite, SpiDevice}; |
| 253 | 253 | ||
| 254 | /// SPI display interface. | 254 | /// SPI display interface. |
| 255 | /// | 255 | /// |
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" | |||
| 18 | cortex-m = "0.7.3" | 18 | cortex-m = "0.7.3" |
| 19 | cortex-m-rt = "0.7.0" | 19 | cortex-m-rt = "0.7.0" |
| 20 | embedded-hal = "0.2.6" | 20 | embedded-hal = "0.2.6" |
| 21 | embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2"} | 21 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } |
| 22 | embedded-hal-async = { version = "0.1.0-alpha.0" } | ||
| 22 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 23 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 23 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 24 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
| 24 | heapless = { version = "0.7.5", default-features = false } | 25 | 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" | |||
| 18 | cortex-m = "0.7.3" | 18 | cortex-m = "0.7.3" |
| 19 | cortex-m-rt = "0.7.0" | 19 | cortex-m-rt = "0.7.0" |
| 20 | embedded-hal = "0.2.6" | 20 | embedded-hal = "0.2.6" |
| 21 | embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2"} | 21 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } |
| 22 | embedded-hal-async = { version = "0.1.0-alpha.0" } | ||
| 22 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 23 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 23 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 24 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
| 24 | heapless = { version = "0.7.5", default-features = false } | 25 | 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 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt_rtt as _; // global logger | ||
| 6 | use panic_probe as _; | ||
| 7 | |||
| 8 | use defmt::*; | ||
| 9 | use embassy::executor::Spawner; | ||
| 10 | use embassy_stm32::dma::NoDma; | ||
| 11 | use embassy_stm32::usart::{Config, Uart}; | ||
| 12 | use embassy_stm32::Peripherals; | ||
| 13 | use embassy_traits::adapter::BlockingAsync; | ||
| 14 | use embedded_hal_async::serial::{Read, Write}; | ||
| 15 | |||
| 16 | #[embassy::main] | ||
| 17 | async fn main(_spawner: Spawner, p: Peripherals) { | ||
| 18 | let config = Config::default(); | ||
| 19 | let usart = Uart::new(p.UART4, p.PA1, p.PA0, NoDma, NoDma, config); | ||
| 20 | let mut usart = BlockingAsync::new(usart); | ||
| 21 | |||
| 22 | unwrap!(usart.write(b"Hello Embassy World!\r\n").await); | ||
| 23 | info!("wrote Hello, starting echo"); | ||
| 24 | |||
| 25 | let mut buf = [0u8; 1]; | ||
| 26 | loop { | ||
| 27 | unwrap!(usart.read(&mut buf).await); | ||
| 28 | unwrap!(usart.write(&buf).await); | ||
| 29 | } | ||
| 30 | } | ||
