diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-01-26 22:01:46 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-01-26 22:01:46 +0000 |
| commit | d76cd5ceaf5140c48ef97180beae156c0c0e07c8 (patch) | |
| tree | a453271d10c017854184335584188bc8709ed517 /examples | |
| parent | cd36e3f7332d08865e670ca5b515d1c6efa1bf85 (diff) | |
| parent | c8347fafb0814078466d7ed220224b9f4c7d78cf (diff) | |
Merge #592
592: Initial work on unstable-trait feature for stm32 r=lulf a=lulf
Implements async traits for exti for now.
Co-authored-by: Ulf Lilleengen <[email protected]>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32f3/src/bin/spi_dma.rs | 3 | ||||
| -rw-r--r-- | examples/stm32h7/Cargo.toml | 3 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/camera.rs | 2 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/spi_dma.rs | 5 | ||||
| -rw-r--r-- | examples/stm32l0/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/stm32l4/Cargo.toml | 3 | ||||
| -rw-r--r-- | examples/stm32l4/src/bin/i2c_blocking_async.rs | 3 | ||||
| -rw-r--r-- | examples/stm32l4/src/bin/spi_blocking_async.rs | 9 | ||||
| -rw-r--r-- | examples/stm32l4/src/bin/spi_dma.rs | 3 | ||||
| -rw-r--r-- | examples/stm32l4/src/bin/usart_blocking_async.rs | 6 |
10 files changed, 19 insertions, 20 deletions
diff --git a/examples/stm32f3/src/bin/spi_dma.rs b/examples/stm32f3/src/bin/spi_dma.rs index a87a36f73..bd66b1202 100644 --- a/examples/stm32f3/src/bin/spi_dma.rs +++ b/examples/stm32f3/src/bin/spi_dma.rs | |||
| @@ -10,7 +10,6 @@ use embassy::executor::Spawner; | |||
| 10 | use embassy_stm32::spi::{Config, Spi}; | 10 | use embassy_stm32::spi::{Config, Spi}; |
| 11 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
| 12 | use embassy_stm32::Peripherals; | 12 | use embassy_stm32::Peripherals; |
| 13 | use embassy_traits::spi::FullDuplex; | ||
| 14 | use example_common::*; | 13 | use example_common::*; |
| 15 | use heapless::String; | 14 | use heapless::String; |
| 16 | 15 | ||
| @@ -33,7 +32,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 33 | let mut write: String<128> = String::new(); | 32 | let mut write: String<128> = String::new(); |
| 34 | let mut read = [0; 128]; | 33 | let mut read = [0; 128]; |
| 35 | core::write!(&mut write, "Hello DMA World {}!\r\n", n).unwrap(); | 34 | core::write!(&mut write, "Hello DMA World {}!\r\n", n).unwrap(); |
| 36 | spi.read_write(&mut read[0..write.len()], write.as_bytes()) | 35 | spi.transfer(&mut read[0..write.len()], write.as_bytes()) |
| 37 | .await | 36 | .await |
| 38 | .ok(); | 37 | .ok(); |
| 39 | info!("read via spi+dma: {}", from_utf8(&read).unwrap()); | 38 | info!("read via spi+dma: {}", from_utf8(&read).unwrap()); |
diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 67f1cfc94..16adcdb91 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml | |||
| @@ -10,7 +10,7 @@ resolver = "2" | |||
| 10 | [dependencies] | 10 | [dependencies] |
| 11 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } | 11 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } |
| 12 | embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } | 12 | embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } |
| 13 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h743zi", "net", "time-driver-any", "exti", "unstable-pac"] } | 13 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h743zi", "net", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } |
| 14 | embassy-net = { path = "../../embassy-net", default-features = false, features = ["defmt", "tcp", "medium-ethernet", "pool-16"] } | 14 | embassy-net = { path = "../../embassy-net", default-features = false, features = ["defmt", "tcp", "medium-ethernet", "pool-16"] } |
| 15 | embassy-hal-common = { path = "../../embassy-hal-common", default-features = false, features = ["defmt"] } | 15 | embassy-hal-common = { path = "../../embassy-hal-common", default-features = false, features = ["defmt"] } |
| 16 | 16 | ||
| @@ -20,6 +20,7 @@ defmt-rtt = "0.3" | |||
| 20 | cortex-m = "0.7.3" | 20 | cortex-m = "0.7.3" |
| 21 | cortex-m-rt = "0.7.0" | 21 | cortex-m-rt = "0.7.0" |
| 22 | embedded-hal = "0.2.6" | 22 | embedded-hal = "0.2.6" |
| 23 | embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy"} | ||
| 23 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 24 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 24 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 25 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
| 25 | heapless = { version = "0.7.5", default-features = false } | 26 | heapless = { version = "0.7.5", default-features = false } |
diff --git a/examples/stm32h7/src/bin/camera.rs b/examples/stm32h7/src/bin/camera.rs index 9e8071bb3..9760d0f74 100644 --- a/examples/stm32h7/src/bin/camera.rs +++ b/examples/stm32h7/src/bin/camera.rs | |||
| @@ -128,7 +128,7 @@ mod ov7725 { | |||
| 128 | use defmt::Format; | 128 | use defmt::Format; |
| 129 | use embassy::time::{Duration, Timer}; | 129 | use embassy::time::{Duration, Timer}; |
| 130 | use embassy_stm32::rcc::{Mco, McoInstance}; | 130 | use embassy_stm32::rcc::{Mco, McoInstance}; |
| 131 | use embassy_traits::i2c::I2c; | 131 | use embedded_hal_async::i2c::I2c; |
| 132 | 132 | ||
| 133 | #[repr(u8)] | 133 | #[repr(u8)] |
| 134 | pub enum RgbFormat { | 134 | pub enum RgbFormat { |
diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index 192e2e864..15ae09973 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs | |||
| @@ -9,7 +9,6 @@ use core::fmt::Write; | |||
| 9 | use embassy::executor::Executor; | 9 | use embassy::executor::Executor; |
| 10 | use embassy::util::Forever; | 10 | use embassy::util::Forever; |
| 11 | use embassy_stm32::time::U32Ext; | 11 | use embassy_stm32::time::U32Ext; |
| 12 | use embassy_traits::spi::FullDuplex; | ||
| 13 | use example_common::*; | 12 | use example_common::*; |
| 14 | 13 | ||
| 15 | use core::str::from_utf8; | 14 | use core::str::from_utf8; |
| @@ -24,8 +23,8 @@ async fn main_task(mut spi: spi::Spi<'static, SPI3, DMA1_CH3, DMA1_CH4>) { | |||
| 24 | let mut write: String<128> = String::new(); | 23 | let mut write: String<128> = String::new(); |
| 25 | let mut read = [0; 128]; | 24 | let mut read = [0; 128]; |
| 26 | core::write!(&mut write, "Hello DMA World {}!\r\n", n).unwrap(); | 25 | core::write!(&mut write, "Hello DMA World {}!\r\n", n).unwrap(); |
| 27 | // read_write will slice the &mut read down to &write's actual length. | 26 | // transfer will slice the &mut read down to &write's actual length. |
| 28 | spi.read_write(&mut read, write.as_bytes()).await.ok(); | 27 | spi.transfer(&mut read, write.as_bytes()).await.ok(); |
| 29 | info!("read via spi+dma: {}", from_utf8(&read).unwrap()); | 28 | info!("read via spi+dma: {}", from_utf8(&read).unwrap()); |
| 30 | } | 29 | } |
| 31 | } | 30 | } |
diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index f101c15f5..2c27e276c 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml | |||
| @@ -8,7 +8,7 @@ resolver = "2" | |||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } | 9 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } |
| 10 | embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } | 10 | embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } |
| 12 | 12 | ||
| 13 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx127x", "time", "defmt"] } | 13 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx127x", "time", "defmt"] } |
| 14 | 14 | ||
diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index d01c76f6e..ca76a1299 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml | |||
| @@ -10,7 +10,7 @@ resolver = "2" | |||
| 10 | [dependencies] | 10 | [dependencies] |
| 11 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt" ] } | 11 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt" ] } |
| 12 | embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } | 12 | embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } |
| 13 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "unstable-pac", "stm32l4s5vi", "time-driver-any", "exti"] } | 13 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "unstable-pac", "stm32l4s5vi", "time-driver-any", "exti", "unstable-traits"] } |
| 14 | 14 | ||
| 15 | defmt = "0.3" | 15 | defmt = "0.3" |
| 16 | defmt-rtt = "0.3" | 16 | defmt-rtt = "0.3" |
| @@ -18,6 +18,7 @@ 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 = "embassy"} | ||
| 21 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 22 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 22 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 23 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
| 23 | heapless = { version = "0.7.5", default-features = false } | 24 | heapless = { version = "0.7.5", default-features = false } |
diff --git a/examples/stm32l4/src/bin/i2c_blocking_async.rs b/examples/stm32l4/src/bin/i2c_blocking_async.rs index 0339ed4d3..07077f9fb 100644 --- a/examples/stm32l4/src/bin/i2c_blocking_async.rs +++ b/examples/stm32l4/src/bin/i2c_blocking_async.rs | |||
| @@ -11,7 +11,8 @@ use embassy_stm32::i2c::I2c; | |||
| 11 | use embassy_stm32::interrupt; | 11 | use embassy_stm32::interrupt; |
| 12 | use embassy_stm32::time::Hertz; | 12 | use embassy_stm32::time::Hertz; |
| 13 | use embassy_stm32::Peripherals; | 13 | use embassy_stm32::Peripherals; |
| 14 | use embassy_traits::{adapter::BlockingAsync, i2c::I2c as _}; | 14 | use embassy_traits::adapter::BlockingAsync; |
| 15 | use embedded_hal_async::i2c::I2c as I2cTrait; | ||
| 15 | use example_common::{info, unwrap}; | 16 | use example_common::{info, unwrap}; |
| 16 | 17 | ||
| 17 | const ADDRESS: u8 = 0x5F; | 18 | const ADDRESS: u8 = 0x5F; |
diff --git a/examples/stm32l4/src/bin/spi_blocking_async.rs b/examples/stm32l4/src/bin/spi_blocking_async.rs index 3be3f21c9..bcd2e32d5 100644 --- a/examples/stm32l4/src/bin/spi_blocking_async.rs +++ b/examples/stm32l4/src/bin/spi_blocking_async.rs | |||
| @@ -11,7 +11,8 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | |||
| 11 | use embassy_stm32::spi::{Config, Spi}; | 11 | use embassy_stm32::spi::{Config, Spi}; |
| 12 | use embassy_stm32::time::Hertz; | 12 | use embassy_stm32::time::Hertz; |
| 13 | use embassy_stm32::Peripherals; | 13 | use embassy_stm32::Peripherals; |
| 14 | use embassy_traits::{adapter::BlockingAsync, spi::FullDuplex}; | 14 | use embassy_traits::adapter::BlockingAsync; |
| 15 | use embedded_hal_async::spi::ReadWrite; | ||
| 15 | use example_common::*; | 16 | use example_common::*; |
| 16 | 17 | ||
| 17 | #[embassy::main] | 18 | #[embassy::main] |
| @@ -47,10 +48,10 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 47 | info!("waiting for ready"); | 48 | info!("waiting for ready"); |
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | let write = [0x0A; 10]; | 51 | let write: [u8; 10] = [0x0A; 10]; |
| 51 | let mut read = [0; 10]; | 52 | let mut read: [u8; 10] = [0; 10]; |
| 52 | cs.set_low(); | 53 | cs.set_low(); |
| 53 | spi.read_write(&mut read, &write).await.ok(); | 54 | spi.transfer(&mut read, &write).await.ok(); |
| 54 | cs.set_high(); | 55 | cs.set_high(); |
| 55 | info!("xfer {=[u8]:x}", read); | 56 | info!("xfer {=[u8]:x}", read); |
| 56 | } | 57 | } |
diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index d6464bbfa..b4d5091b2 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs | |||
| @@ -10,7 +10,6 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | |||
| 10 | use embassy_stm32::spi::{Config, Spi}; | 10 | use embassy_stm32::spi::{Config, Spi}; |
| 11 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
| 12 | use embassy_stm32::Peripherals; | 12 | use embassy_stm32::Peripherals; |
| 13 | use embassy_traits::spi::FullDuplex; | ||
| 14 | use example_common::*; | 13 | use example_common::*; |
| 15 | 14 | ||
| 16 | #[embassy::main] | 15 | #[embassy::main] |
| @@ -47,7 +46,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 47 | let write = [0x0A; 10]; | 46 | let write = [0x0A; 10]; |
| 48 | let mut read = [0; 10]; | 47 | let mut read = [0; 10]; |
| 49 | cs.set_low(); | 48 | cs.set_low(); |
| 50 | spi.read_write(&mut read, &write).await.ok(); | 49 | spi.transfer(&mut read, &write).await.ok(); |
| 51 | cs.set_high(); | 50 | cs.set_high(); |
| 52 | info!("xfer {=[u8]:x}", read); | 51 | info!("xfer {=[u8]:x}", read); |
| 53 | } | 52 | } |
diff --git a/examples/stm32l4/src/bin/usart_blocking_async.rs b/examples/stm32l4/src/bin/usart_blocking_async.rs index 679d4e0da..10b7127da 100644 --- a/examples/stm32l4/src/bin/usart_blocking_async.rs +++ b/examples/stm32l4/src/bin/usart_blocking_async.rs | |||
| @@ -6,13 +6,11 @@ | |||
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | 7 | ||
| 8 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| 9 | use embassy::traits::{ | 9 | use embassy::traits::adapter::BlockingAsync; |
| 10 | adapter::BlockingAsync, | ||
| 11 | uart::{Read, Write}, | ||
| 12 | }; | ||
| 13 | use embassy_stm32::dma::NoDma; | 10 | use embassy_stm32::dma::NoDma; |
| 14 | use embassy_stm32::usart::{Config, Uart}; | 11 | use embassy_stm32::usart::{Config, Uart}; |
| 15 | use embassy_stm32::Peripherals; | 12 | use embassy_stm32::Peripherals; |
| 13 | use embedded_hal_async::serial::{Read, Write}; | ||
| 16 | use example_common::*; | 14 | use example_common::*; |
| 17 | 15 | ||
| 18 | #[embassy::main] | 16 | #[embassy::main] |
