diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-01-19 20:47:07 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-01-19 20:47:07 +0000 |
| commit | 6b0cb0609b4bfa3e464e4603ce373a9de9886103 (patch) | |
| tree | 70a6590ad9da8c625eb69c21faddb5721bfbcea4 /examples | |
| parent | 071b034a5dbece727b28aee6362e36d66bcb763b (diff) | |
| parent | 889d757ab8bcfc10caf0a7d75ffb7733a7e71ed1 (diff) | |
Merge #581
581: stm32: expose all functionality as inherent methods. r=Dirbaio a=Dirbaio
This is the previous step to implementing both the embedded-hal 0.2 and embedded-hal 1.0 + embedded-hal-async traits.
The equivalent in nrf was done in #552
- Removes need for `unwrap` in gpio.
- Removes need for `use embedded_hal::whatever` in all cases.
Co-authored-by: Dario Nieuwenhuis <[email protected]>
Diffstat (limited to 'examples')
57 files changed, 97 insertions, 190 deletions
diff --git a/examples/stm32f1/src/bin/blinky.rs b/examples/stm32f1/src/bin/blinky.rs index 1e4f2deec..0d9537453 100644 --- a/examples/stm32f1/src/bin/blinky.rs +++ b/examples/stm32f1/src/bin/blinky.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy::time::{Duration, Timer}; | 8 | use embassy::time::{Duration, Timer}; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embedded_hal::digital::v2::OutputPin; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
| @@ -19,11 +18,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 19 | 18 | ||
| 20 | loop { | 19 | loop { |
| 21 | info!("high"); | 20 | info!("high"); |
| 22 | unwrap!(led.set_high()); | 21 | led.set_high(); |
| 23 | Timer::after(Duration::from_millis(300)).await; | 22 | Timer::after(Duration::from_millis(300)).await; |
| 24 | 23 | ||
| 25 | info!("low"); | 24 | info!("low"); |
| 26 | unwrap!(led.set_low()); | 25 | led.set_low(); |
| 27 | Timer::after(Duration::from_millis(300)).await; | 26 | Timer::after(Duration::from_millis(300)).await; |
| 28 | } | 27 | } |
| 29 | } | 28 | } |
diff --git a/examples/stm32f3/src/bin/blinky.rs b/examples/stm32f3/src/bin/blinky.rs index 321643557..e8b8dc23f 100644 --- a/examples/stm32f3/src/bin/blinky.rs +++ b/examples/stm32f3/src/bin/blinky.rs | |||
| @@ -9,7 +9,6 @@ use embassy::executor::Spawner; | |||
| 9 | use embassy::time::{Duration, Timer}; | 9 | use embassy::time::{Duration, Timer}; |
| 10 | use embassy_stm32::gpio::{Level, Output, Speed}; | 10 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 11 | use embassy_stm32::Peripherals; | 11 | use embassy_stm32::Peripherals; |
| 12 | use embedded_hal::digital::v2::OutputPin; | ||
| 13 | use example_common::*; | 12 | use example_common::*; |
| 14 | 13 | ||
| 15 | #[embassy::main] | 14 | #[embassy::main] |
| @@ -20,11 +19,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 20 | 19 | ||
| 21 | loop { | 20 | loop { |
| 22 | info!("high"); | 21 | info!("high"); |
| 23 | unwrap!(led.set_high()); | 22 | led.set_high(); |
| 24 | Timer::after(Duration::from_millis(1000)).await; | 23 | Timer::after(Duration::from_millis(1000)).await; |
| 25 | 24 | ||
| 26 | info!("low"); | 25 | info!("low"); |
| 27 | unwrap!(led.set_low()); | 26 | led.set_low(); |
| 28 | Timer::after(Duration::from_millis(1000)).await; | 27 | Timer::after(Duration::from_millis(1000)).await; |
| 29 | } | 28 | } |
| 30 | } | 29 | } |
diff --git a/examples/stm32f3/src/bin/button.rs b/examples/stm32f3/src/bin/button.rs index c5fab138b..131d4af42 100644 --- a/examples/stm32f3/src/bin/button.rs +++ b/examples/stm32f3/src/bin/button.rs | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use cortex_m_rt::entry; | 7 | use cortex_m_rt::entry; |
| 8 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 8 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 9 | use embedded_hal::digital::v2::{InputPin, OutputPin}; | ||
| 10 | use example_common::*; | 9 | use example_common::*; |
| 11 | 10 | ||
| 12 | #[entry] | 11 | #[entry] |
| @@ -20,14 +19,14 @@ fn main() -> ! { | |||
| 20 | let mut led2 = Output::new(p.PE15, Level::High, Speed::Low); | 19 | let mut led2 = Output::new(p.PE15, Level::High, Speed::Low); |
| 21 | 20 | ||
| 22 | loop { | 21 | loop { |
| 23 | if unwrap!(button.is_high()) { | 22 | if button.is_high() { |
| 24 | info!("high"); | 23 | info!("high"); |
| 25 | unwrap!(led1.set_high()); | 24 | led1.set_high(); |
| 26 | unwrap!(led2.set_low()); | 25 | led2.set_low(); |
| 27 | } else { | 26 | } else { |
| 28 | info!("low"); | 27 | info!("low"); |
| 29 | unwrap!(led1.set_low()); | 28 | led1.set_low(); |
| 30 | unwrap!(led2.set_high()); | 29 | led2.set_high(); |
| 31 | } | 30 | } |
| 32 | } | 31 | } |
| 33 | } | 32 | } |
diff --git a/examples/stm32f3/src/bin/button_exti.rs b/examples/stm32f3/src/bin/button_exti.rs index d45e4365b..b11f38ea5 100644 --- a/examples/stm32f3/src/bin/button_exti.rs +++ b/examples/stm32f3/src/bin/button_exti.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy_stm32::exti::ExtiInput; | 8 | use embassy_stm32::exti::ExtiInput; |
| 9 | use embassy_stm32::gpio::{Input, Pull}; | 9 | use embassy_stm32::gpio::{Input, Pull}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
diff --git a/examples/stm32f3/src/bin/usart_dma.rs b/examples/stm32f3/src/bin/usart_dma.rs index 99530b5c0..0e67bb1f1 100644 --- a/examples/stm32f3/src/bin/usart_dma.rs +++ b/examples/stm32f3/src/bin/usart_dma.rs | |||
| @@ -9,7 +9,6 @@ use embassy::executor::Spawner; | |||
| 9 | use embassy_stm32::dma::NoDma; | 9 | use embassy_stm32::dma::NoDma; |
| 10 | use embassy_stm32::usart::{Config, Uart}; | 10 | use embassy_stm32::usart::{Config, Uart}; |
| 11 | use embassy_stm32::Peripherals; | 11 | use embassy_stm32::Peripherals; |
| 12 | use embassy_traits::uart::Write as _; | ||
| 13 | use example_common::*; | 12 | use example_common::*; |
| 14 | use heapless::String; | 13 | use heapless::String; |
| 15 | 14 | ||
diff --git a/examples/stm32f4/src/bin/blinky.rs b/examples/stm32f4/src/bin/blinky.rs index c4857195f..00d67dac0 100644 --- a/examples/stm32f4/src/bin/blinky.rs +++ b/examples/stm32f4/src/bin/blinky.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy::time::{Duration, Timer}; | 8 | use embassy::time::{Duration, Timer}; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embedded_hal::digital::v2::OutputPin; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
| @@ -19,11 +18,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 19 | 18 | ||
| 20 | loop { | 19 | loop { |
| 21 | info!("high"); | 20 | info!("high"); |
| 22 | unwrap!(led.set_high()); | 21 | led.set_high(); |
| 23 | Timer::after(Duration::from_millis(300)).await; | 22 | Timer::after(Duration::from_millis(300)).await; |
| 24 | 23 | ||
| 25 | info!("low"); | 24 | info!("low"); |
| 26 | unwrap!(led.set_low()); | 25 | led.set_low(); |
| 27 | Timer::after(Duration::from_millis(300)).await; | 26 | Timer::after(Duration::from_millis(300)).await; |
| 28 | } | 27 | } |
| 29 | } | 28 | } |
diff --git a/examples/stm32f4/src/bin/button.rs b/examples/stm32f4/src/bin/button.rs index 95dee7c74..24eef75b2 100644 --- a/examples/stm32f4/src/bin/button.rs +++ b/examples/stm32f4/src/bin/button.rs | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use cortex_m_rt::entry; | 7 | use cortex_m_rt::entry; |
| 8 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 8 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 9 | use embedded_hal::digital::v2::{InputPin, OutputPin}; | ||
| 10 | use example_common::*; | 9 | use example_common::*; |
| 11 | 10 | ||
| 12 | #[entry] | 11 | #[entry] |
| @@ -21,14 +20,14 @@ fn main() -> ! { | |||
| 21 | let mut led3 = Output::new(p.PB14, Level::High, Speed::Low); | 20 | let mut led3 = Output::new(p.PB14, Level::High, Speed::Low); |
| 22 | 21 | ||
| 23 | loop { | 22 | loop { |
| 24 | if unwrap!(button.is_high()) { | 23 | if button.is_high() { |
| 25 | info!("high"); | 24 | info!("high"); |
| 26 | unwrap!(led1.set_high()); | 25 | led1.set_high(); |
| 27 | unwrap!(led3.set_low()); | 26 | led3.set_low(); |
| 28 | } else { | 27 | } else { |
| 29 | info!("low"); | 28 | info!("low"); |
| 30 | unwrap!(led1.set_low()); | 29 | led1.set_low(); |
| 31 | unwrap!(led3.set_high()); | 30 | led3.set_high(); |
| 32 | } | 31 | } |
| 33 | } | 32 | } |
| 34 | } | 33 | } |
diff --git a/examples/stm32f4/src/bin/button_exti.rs b/examples/stm32f4/src/bin/button_exti.rs index 2c4318d64..852fbe3c6 100644 --- a/examples/stm32f4/src/bin/button_exti.rs +++ b/examples/stm32f4/src/bin/button_exti.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy_stm32::exti::ExtiInput; | 8 | use embassy_stm32::exti::ExtiInput; |
| 9 | use embassy_stm32::gpio::{Input, Pull}; | 9 | use embassy_stm32::gpio::{Input, Pull}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
diff --git a/examples/stm32f4/src/bin/spi.rs b/examples/stm32f4/src/bin/spi.rs index 0192e1865..6b04f1fed 100644 --- a/examples/stm32f4/src/bin/spi.rs +++ b/examples/stm32f4/src/bin/spi.rs | |||
| @@ -10,8 +10,6 @@ use embassy_stm32::dma::NoDma; | |||
| 10 | use embassy_stm32::gpio::{Level, Output, Speed}; | 10 | use embassy_stm32::gpio::{Level, Output, 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 embedded_hal::blocking::spi::Transfer; | ||
| 14 | use embedded_hal::digital::v2::OutputPin; | ||
| 15 | use example_common::*; | 13 | use example_common::*; |
| 16 | 14 | ||
| 17 | #[entry] | 15 | #[entry] |
| @@ -35,9 +33,9 @@ fn main() -> ! { | |||
| 35 | 33 | ||
| 36 | loop { | 34 | loop { |
| 37 | let mut buf = [0x0Au8; 4]; | 35 | let mut buf = [0x0Au8; 4]; |
| 38 | unwrap!(cs.set_low()); | 36 | cs.set_low(); |
| 39 | unwrap!(spi.transfer(&mut buf)); | 37 | unwrap!(spi.blocking_transfer_in_place(&mut buf)); |
| 40 | unwrap!(cs.set_high()); | 38 | cs.set_high(); |
| 41 | info!("xfer {=[u8]:x}", buf); | 39 | info!("xfer {=[u8]:x}", buf); |
| 42 | } | 40 | } |
| 43 | } | 41 | } |
diff --git a/examples/stm32f4/src/bin/spi_dma.rs b/examples/stm32f4/src/bin/spi_dma.rs index b3bf6fc28..9171f7516 100644 --- a/examples/stm32f4/src/bin/spi_dma.rs +++ b/examples/stm32f4/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/stm32f4/src/bin/usart.rs b/examples/stm32f4/src/bin/usart.rs index 391a8b9b0..b5ea98cca 100644 --- a/examples/stm32f4/src/bin/usart.rs +++ b/examples/stm32f4/src/bin/usart.rs | |||
| @@ -7,7 +7,6 @@ mod example_common; | |||
| 7 | use cortex_m_rt::entry; | 7 | use cortex_m_rt::entry; |
| 8 | use embassy_stm32::dma::NoDma; | 8 | use embassy_stm32::dma::NoDma; |
| 9 | use embassy_stm32::usart::{Config, Uart}; | 9 | use embassy_stm32::usart::{Config, Uart}; |
| 10 | use embedded_hal::blocking::serial::Write; | ||
| 11 | use example_common::*; | 10 | use example_common::*; |
| 12 | 11 | ||
| 13 | #[entry] | 12 | #[entry] |
| @@ -19,12 +18,12 @@ fn main() -> ! { | |||
| 19 | let config = Config::default(); | 18 | let config = Config::default(); |
| 20 | let mut usart = Uart::new(p.USART3, p.PD9, p.PD8, NoDma, NoDma, config); | 19 | let mut usart = Uart::new(p.USART3, p.PD9, p.PD8, NoDma, NoDma, config); |
| 21 | 20 | ||
| 22 | unwrap!(usart.bwrite_all(b"Hello Embassy World!\r\n")); | 21 | unwrap!(usart.blocking_write(b"Hello Embassy World!\r\n")); |
| 23 | info!("wrote Hello, starting echo"); | 22 | info!("wrote Hello, starting echo"); |
| 24 | 23 | ||
| 25 | let mut buf = [0u8; 1]; | 24 | let mut buf = [0u8; 1]; |
| 26 | loop { | 25 | loop { |
| 27 | unwrap!(usart.read_blocking(&mut buf)); | 26 | unwrap!(usart.blocking_read(&mut buf)); |
| 28 | unwrap!(usart.bwrite_all(&buf)); | 27 | unwrap!(usart.blocking_write(&buf)); |
| 29 | } | 28 | } |
| 30 | } | 29 | } |
diff --git a/examples/stm32f4/src/bin/usart_dma.rs b/examples/stm32f4/src/bin/usart_dma.rs index 0dbdd7c05..862a91ea8 100644 --- a/examples/stm32f4/src/bin/usart_dma.rs +++ b/examples/stm32f4/src/bin/usart_dma.rs | |||
| @@ -9,7 +9,6 @@ use embassy::executor::Spawner; | |||
| 9 | use embassy_stm32::dma::NoDma; | 9 | use embassy_stm32::dma::NoDma; |
| 10 | use embassy_stm32::usart::{Config, Uart}; | 10 | use embassy_stm32::usart::{Config, Uart}; |
| 11 | use embassy_stm32::Peripherals; | 11 | use embassy_stm32::Peripherals; |
| 12 | use embassy_traits::uart::Write as _; | ||
| 13 | use example_common::*; | 12 | use example_common::*; |
| 14 | use heapless::String; | 13 | use heapless::String; |
| 15 | 14 | ||
diff --git a/examples/stm32f7/src/bin/blinky.rs b/examples/stm32f7/src/bin/blinky.rs index c4857195f..00d67dac0 100644 --- a/examples/stm32f7/src/bin/blinky.rs +++ b/examples/stm32f7/src/bin/blinky.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy::time::{Duration, Timer}; | 8 | use embassy::time::{Duration, Timer}; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embedded_hal::digital::v2::OutputPin; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
| @@ -19,11 +18,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 19 | 18 | ||
| 20 | loop { | 19 | loop { |
| 21 | info!("high"); | 20 | info!("high"); |
| 22 | unwrap!(led.set_high()); | 21 | led.set_high(); |
| 23 | Timer::after(Duration::from_millis(300)).await; | 22 | Timer::after(Duration::from_millis(300)).await; |
| 24 | 23 | ||
| 25 | info!("low"); | 24 | info!("low"); |
| 26 | unwrap!(led.set_low()); | 25 | led.set_low(); |
| 27 | Timer::after(Duration::from_millis(300)).await; | 26 | Timer::after(Duration::from_millis(300)).await; |
| 28 | } | 27 | } |
| 29 | } | 28 | } |
diff --git a/examples/stm32f7/src/bin/button.rs b/examples/stm32f7/src/bin/button.rs index 95dee7c74..24eef75b2 100644 --- a/examples/stm32f7/src/bin/button.rs +++ b/examples/stm32f7/src/bin/button.rs | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use cortex_m_rt::entry; | 7 | use cortex_m_rt::entry; |
| 8 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 8 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 9 | use embedded_hal::digital::v2::{InputPin, OutputPin}; | ||
| 10 | use example_common::*; | 9 | use example_common::*; |
| 11 | 10 | ||
| 12 | #[entry] | 11 | #[entry] |
| @@ -21,14 +20,14 @@ fn main() -> ! { | |||
| 21 | let mut led3 = Output::new(p.PB14, Level::High, Speed::Low); | 20 | let mut led3 = Output::new(p.PB14, Level::High, Speed::Low); |
| 22 | 21 | ||
| 23 | loop { | 22 | loop { |
| 24 | if unwrap!(button.is_high()) { | 23 | if button.is_high() { |
| 25 | info!("high"); | 24 | info!("high"); |
| 26 | unwrap!(led1.set_high()); | 25 | led1.set_high(); |
| 27 | unwrap!(led3.set_low()); | 26 | led3.set_low(); |
| 28 | } else { | 27 | } else { |
| 29 | info!("low"); | 28 | info!("low"); |
| 30 | unwrap!(led1.set_low()); | 29 | led1.set_low(); |
| 31 | unwrap!(led3.set_high()); | 30 | led3.set_high(); |
| 32 | } | 31 | } |
| 33 | } | 32 | } |
| 34 | } | 33 | } |
diff --git a/examples/stm32f7/src/bin/button_exti.rs b/examples/stm32f7/src/bin/button_exti.rs index 2c4318d64..852fbe3c6 100644 --- a/examples/stm32f7/src/bin/button_exti.rs +++ b/examples/stm32f7/src/bin/button_exti.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy_stm32::exti::ExtiInput; | 8 | use embassy_stm32::exti::ExtiInput; |
| 9 | use embassy_stm32::gpio::{Input, Pull}; | 9 | use embassy_stm32::gpio::{Input, Pull}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
diff --git a/examples/stm32f7/src/bin/usart_dma.rs b/examples/stm32f7/src/bin/usart_dma.rs index 82af0bc22..00deae8b3 100644 --- a/examples/stm32f7/src/bin/usart_dma.rs +++ b/examples/stm32f7/src/bin/usart_dma.rs | |||
| @@ -9,7 +9,6 @@ use embassy::executor::Spawner; | |||
| 9 | use embassy_stm32::dma::NoDma; | 9 | use embassy_stm32::dma::NoDma; |
| 10 | use embassy_stm32::usart::{Config, Uart}; | 10 | use embassy_stm32::usart::{Config, Uart}; |
| 11 | use embassy_stm32::Peripherals; | 11 | use embassy_stm32::Peripherals; |
| 12 | use embassy_traits::uart::Write as _Write; | ||
| 13 | use example_common::*; | 12 | use example_common::*; |
| 14 | 13 | ||
| 15 | use heapless::String; | 14 | use heapless::String; |
diff --git a/examples/stm32g0/src/bin/blinky.rs b/examples/stm32g0/src/bin/blinky.rs index c4857195f..00d67dac0 100644 --- a/examples/stm32g0/src/bin/blinky.rs +++ b/examples/stm32g0/src/bin/blinky.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy::time::{Duration, Timer}; | 8 | use embassy::time::{Duration, Timer}; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embedded_hal::digital::v2::OutputPin; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
| @@ -19,11 +18,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 19 | 18 | ||
| 20 | loop { | 19 | loop { |
| 21 | info!("high"); | 20 | info!("high"); |
| 22 | unwrap!(led.set_high()); | 21 | led.set_high(); |
| 23 | Timer::after(Duration::from_millis(300)).await; | 22 | Timer::after(Duration::from_millis(300)).await; |
| 24 | 23 | ||
| 25 | info!("low"); | 24 | info!("low"); |
| 26 | unwrap!(led.set_low()); | 25 | led.set_low(); |
| 27 | Timer::after(Duration::from_millis(300)).await; | 26 | Timer::after(Duration::from_millis(300)).await; |
| 28 | } | 27 | } |
| 29 | } | 28 | } |
diff --git a/examples/stm32g0/src/bin/button.rs b/examples/stm32g0/src/bin/button.rs index 4ca2a43b2..e901c5750 100644 --- a/examples/stm32g0/src/bin/button.rs +++ b/examples/stm32g0/src/bin/button.rs | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use cortex_m_rt::entry; | 7 | use cortex_m_rt::entry; |
| 8 | use embassy_stm32::gpio::{Input, Pull}; | 8 | use embassy_stm32::gpio::{Input, Pull}; |
| 9 | use embedded_hal::digital::v2::InputPin; | ||
| 10 | use example_common::*; | 9 | use example_common::*; |
| 11 | 10 | ||
| 12 | #[entry] | 11 | #[entry] |
| @@ -18,7 +17,7 @@ fn main() -> ! { | |||
| 18 | let button = Input::new(p.PC13, Pull::Up); | 17 | let button = Input::new(p.PC13, Pull::Up); |
| 19 | 18 | ||
| 20 | loop { | 19 | loop { |
| 21 | if unwrap!(button.is_high()) { | 20 | if button.is_high() { |
| 22 | info!("high"); | 21 | info!("high"); |
| 23 | } else { | 22 | } else { |
| 24 | info!("low"); | 23 | info!("low"); |
diff --git a/examples/stm32g0/src/bin/button_exti.rs b/examples/stm32g0/src/bin/button_exti.rs index 0c2483ecb..848818bf2 100644 --- a/examples/stm32g0/src/bin/button_exti.rs +++ b/examples/stm32g0/src/bin/button_exti.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy_stm32::exti::ExtiInput; | 8 | use embassy_stm32::exti::ExtiInput; |
| 9 | use embassy_stm32::gpio::{Input, Pull}; | 9 | use embassy_stm32::gpio::{Input, Pull}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
diff --git a/examples/stm32g4/src/bin/blinky.rs b/examples/stm32g4/src/bin/blinky.rs index a43922a63..1dc67f99e 100644 --- a/examples/stm32g4/src/bin/blinky.rs +++ b/examples/stm32g4/src/bin/blinky.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy::time::{Duration, Timer}; | 8 | use embassy::time::{Duration, Timer}; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embedded_hal::digital::v2::OutputPin; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
| @@ -19,11 +18,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 19 | 18 | ||
| 20 | loop { | 19 | loop { |
| 21 | info!("high"); | 20 | info!("high"); |
| 22 | unwrap!(led.set_high()); | 21 | led.set_high(); |
| 23 | Timer::after(Duration::from_millis(300)).await; | 22 | Timer::after(Duration::from_millis(300)).await; |
| 24 | 23 | ||
| 25 | info!("low"); | 24 | info!("low"); |
| 26 | unwrap!(led.set_low()); | 25 | led.set_low(); |
| 27 | Timer::after(Duration::from_millis(300)).await; | 26 | Timer::after(Duration::from_millis(300)).await; |
| 28 | } | 27 | } |
| 29 | } | 28 | } |
diff --git a/examples/stm32g4/src/bin/button.rs b/examples/stm32g4/src/bin/button.rs index f0a4c8745..8c0d7d4fe 100644 --- a/examples/stm32g4/src/bin/button.rs +++ b/examples/stm32g4/src/bin/button.rs | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use cortex_m_rt::entry; | 7 | use cortex_m_rt::entry; |
| 8 | use embassy_stm32::gpio::{Input, Pull}; | 8 | use embassy_stm32::gpio::{Input, Pull}; |
| 9 | use embedded_hal::digital::v2::InputPin; | ||
| 10 | use example_common::*; | 9 | use example_common::*; |
| 11 | 10 | ||
| 12 | #[entry] | 11 | #[entry] |
| @@ -18,7 +17,7 @@ fn main() -> ! { | |||
| 18 | let button = Input::new(p.PC13, Pull::Down); | 17 | let button = Input::new(p.PC13, Pull::Down); |
| 19 | 18 | ||
| 20 | loop { | 19 | loop { |
| 21 | if unwrap!(button.is_high()) { | 20 | if button.is_high() { |
| 22 | info!("high"); | 21 | info!("high"); |
| 23 | } else { | 22 | } else { |
| 24 | info!("low"); | 23 | info!("low"); |
diff --git a/examples/stm32g4/src/bin/button_exti.rs b/examples/stm32g4/src/bin/button_exti.rs index 2c4318d64..852fbe3c6 100644 --- a/examples/stm32g4/src/bin/button_exti.rs +++ b/examples/stm32g4/src/bin/button_exti.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy_stm32::exti::ExtiInput; | 8 | use embassy_stm32::exti::ExtiInput; |
| 9 | use embassy_stm32::gpio::{Input, Pull}; | 9 | use embassy_stm32::gpio::{Input, Pull}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
diff --git a/examples/stm32h7/src/bin/blinky.rs b/examples/stm32h7/src/bin/blinky.rs index 78edb5e27..7e5934239 100644 --- a/examples/stm32h7/src/bin/blinky.rs +++ b/examples/stm32h7/src/bin/blinky.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy::time::{Duration, Timer}; | 8 | use embassy::time::{Duration, Timer}; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embedded_hal::digital::v2::OutputPin; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
| @@ -19,11 +18,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 19 | 18 | ||
| 20 | loop { | 19 | loop { |
| 21 | info!("high"); | 20 | info!("high"); |
| 22 | unwrap!(led.set_high()); | 21 | led.set_high(); |
| 23 | Timer::after(Duration::from_millis(500)).await; | 22 | Timer::after(Duration::from_millis(500)).await; |
| 24 | 23 | ||
| 25 | info!("low"); | 24 | info!("low"); |
| 26 | unwrap!(led.set_low()); | 25 | led.set_low(); |
| 27 | Timer::after(Duration::from_millis(500)).await; | 26 | Timer::after(Duration::from_millis(500)).await; |
| 28 | } | 27 | } |
| 29 | } | 28 | } |
diff --git a/examples/stm32h7/src/bin/button_exti.rs b/examples/stm32h7/src/bin/button_exti.rs index 2c4318d64..852fbe3c6 100644 --- a/examples/stm32h7/src/bin/button_exti.rs +++ b/examples/stm32h7/src/bin/button_exti.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy_stm32::exti::ExtiInput; | 8 | use embassy_stm32::exti::ExtiInput; |
| 9 | use embassy_stm32::gpio::{Input, Pull}; | 9 | use embassy_stm32::gpio::{Input, Pull}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
diff --git a/examples/stm32h7/src/bin/camera.rs b/examples/stm32h7/src/bin/camera.rs index d94592071..9e8071bb3 100644 --- a/examples/stm32h7/src/bin/camera.rs +++ b/examples/stm32h7/src/bin/camera.rs | |||
| @@ -11,7 +11,6 @@ use embassy_stm32::interrupt; | |||
| 11 | use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; | 11 | use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; |
| 12 | use embassy_stm32::time::U32Ext; | 12 | use embassy_stm32::time::U32Ext; |
| 13 | use embassy_stm32::Peripherals; | 13 | use embassy_stm32::Peripherals; |
| 14 | use embedded_hal::digital::v2::OutputPin; | ||
| 15 | 14 | ||
| 16 | use defmt_rtt as _; // global logger | 15 | use defmt_rtt as _; // global logger |
| 17 | use panic_probe as _; | 16 | use panic_probe as _; |
| @@ -114,11 +113,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 114 | defmt::info!("main loop running"); | 113 | defmt::info!("main loop running"); |
| 115 | loop { | 114 | loop { |
| 116 | defmt::info!("high"); | 115 | defmt::info!("high"); |
| 117 | defmt::unwrap!(led.set_high()); | 116 | led.set_high(); |
| 118 | Timer::after(Duration::from_millis(500)).await; | 117 | Timer::after(Duration::from_millis(500)).await; |
| 119 | 118 | ||
| 120 | defmt::info!("low"); | 119 | defmt::info!("low"); |
| 121 | defmt::unwrap!(led.set_low()); | 120 | led.set_low(); |
| 122 | Timer::after(Duration::from_millis(500)).await; | 121 | Timer::after(Duration::from_millis(500)).await; |
| 123 | } | 122 | } |
| 124 | } | 123 | } |
diff --git a/examples/stm32h7/src/bin/mco.rs b/examples/stm32h7/src/bin/mco.rs index 4cecd9b04..f27bd8ef8 100644 --- a/examples/stm32h7/src/bin/mco.rs +++ b/examples/stm32h7/src/bin/mco.rs | |||
| @@ -9,7 +9,6 @@ use embassy::time::{Duration, Timer}; | |||
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; | 10 | use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; |
| 11 | use embassy_stm32::Peripherals; | 11 | use embassy_stm32::Peripherals; |
| 12 | use embedded_hal::digital::v2::OutputPin; | ||
| 13 | use example_common::*; | 12 | use example_common::*; |
| 14 | 13 | ||
| 15 | #[embassy::main] | 14 | #[embassy::main] |
| @@ -22,11 +21,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 22 | 21 | ||
| 23 | loop { | 22 | loop { |
| 24 | info!("high"); | 23 | info!("high"); |
| 25 | unwrap!(led.set_high()); | 24 | led.set_high(); |
| 26 | Timer::after(Duration::from_millis(500)).await; | 25 | Timer::after(Duration::from_millis(500)).await; |
| 27 | 26 | ||
| 28 | info!("low"); | 27 | info!("low"); |
| 29 | unwrap!(led.set_low()); | 28 | led.set_low(); |
| 30 | Timer::after(Duration::from_millis(500)).await; | 29 | Timer::after(Duration::from_millis(500)).await; |
| 31 | } | 30 | } |
| 32 | } | 31 | } |
diff --git a/examples/stm32h7/src/bin/rng.rs b/examples/stm32h7/src/bin/rng.rs index d64ad9bcd..8e03861d5 100644 --- a/examples/stm32h7/src/bin/rng.rs +++ b/examples/stm32h7/src/bin/rng.rs | |||
| @@ -10,7 +10,6 @@ use embassy::traits::rng::Random; | |||
| 10 | use embassy_stm32::gpio::{Level, Output, Speed}; | 10 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 11 | use embassy_stm32::rng::Rng; | 11 | use embassy_stm32::rng::Rng; |
| 12 | use embassy_stm32::Peripherals; | 12 | use embassy_stm32::Peripherals; |
| 13 | use embedded_hal::digital::v2::OutputPin; | ||
| 14 | use example_common::*; | 13 | use example_common::*; |
| 15 | 14 | ||
| 16 | #[embassy::main] | 15 | #[embassy::main] |
| @@ -23,11 +22,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 23 | 22 | ||
| 24 | loop { | 23 | loop { |
| 25 | info!("high {}", unwrap!(rng.next_u8(16).await)); | 24 | info!("high {}", unwrap!(rng.next_u8(16).await)); |
| 26 | unwrap!(led.set_high()); | 25 | led.set_high(); |
| 27 | Timer::after(Duration::from_millis(500)).await; | 26 | Timer::after(Duration::from_millis(500)).await; |
| 28 | 27 | ||
| 29 | info!("low {}", unwrap!(rng.next_u8(16).await)); | 28 | info!("low {}", unwrap!(rng.next_u8(16).await)); |
| 30 | unwrap!(led.set_low()); | 29 | led.set_low(); |
| 31 | Timer::after(Duration::from_millis(500)).await; | 30 | Timer::after(Duration::from_millis(500)).await; |
| 32 | } | 31 | } |
| 33 | } | 32 | } |
diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index 0b375b0d0..17e64da79 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs | |||
| @@ -10,7 +10,6 @@ use embassy::executor::Executor; | |||
| 10 | use embassy::util::Forever; | 10 | use embassy::util::Forever; |
| 11 | use embassy_stm32::dma::NoDma; | 11 | use embassy_stm32::dma::NoDma; |
| 12 | use embassy_stm32::spi; | 12 | use embassy_stm32::spi; |
| 13 | use embedded_hal::blocking::spi::Transfer; | ||
| 14 | use example_common::*; | 13 | use example_common::*; |
| 15 | 14 | ||
| 16 | use core::str::from_utf8; | 15 | use core::str::from_utf8; |
| @@ -25,7 +24,7 @@ async fn main_task(mut spi: spi::Spi<'static, SPI3, NoDma, NoDma>) { | |||
| 25 | let mut write: String<128> = String::new(); | 24 | let mut write: String<128> = String::new(); |
| 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 | unsafe { | 26 | unsafe { |
| 28 | let result = spi.transfer(write.as_bytes_mut()); | 27 | let result = spi.blocking_transfer_in_place(write.as_bytes_mut()); |
| 29 | if let Err(_) = result { | 28 | if let Err(_) = result { |
| 30 | defmt::panic!("crap"); | 29 | defmt::panic!("crap"); |
| 31 | } | 30 | } |
diff --git a/examples/stm32h7/src/bin/usart.rs b/examples/stm32h7/src/bin/usart.rs index 95f0a8604..211e57cda 100644 --- a/examples/stm32h7/src/bin/usart.rs +++ b/examples/stm32h7/src/bin/usart.rs | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #[path = "../example_common.rs"] | 5 | #[path = "../example_common.rs"] |
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use cortex_m::prelude::_embedded_hal_blocking_serial_Write; | ||
| 8 | use embassy::executor::Executor; | 7 | use embassy::executor::Executor; |
| 9 | use embassy::util::Forever; | 8 | use embassy::util::Forever; |
| 10 | use embassy_stm32::dma::NoDma; | 9 | use embassy_stm32::dma::NoDma; |
| @@ -20,13 +19,13 @@ async fn main_task() { | |||
| 20 | let config = Config::default(); | 19 | let config = Config::default(); |
| 21 | let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, NoDma, NoDma, config); | 20 | let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, NoDma, NoDma, config); |
| 22 | 21 | ||
| 23 | unwrap!(usart.bwrite_all(b"Hello Embassy World!\r\n")); | 22 | unwrap!(usart.blocking_write(b"Hello Embassy World!\r\n")); |
| 24 | info!("wrote Hello, starting echo"); | 23 | info!("wrote Hello, starting echo"); |
| 25 | 24 | ||
| 26 | let mut buf = [0u8; 1]; | 25 | let mut buf = [0u8; 1]; |
| 27 | loop { | 26 | loop { |
| 28 | unwrap!(usart.read_blocking(&mut buf)); | 27 | unwrap!(usart.blocking_read(&mut buf)); |
| 29 | unwrap!(usart.bwrite_all(&buf)); | 28 | unwrap!(usart.blocking_write(&buf)); |
| 30 | } | 29 | } |
| 31 | } | 30 | } |
| 32 | 31 | ||
diff --git a/examples/stm32h7/src/bin/usart_dma.rs b/examples/stm32h7/src/bin/usart_dma.rs index d603347ac..a9221e1b6 100644 --- a/examples/stm32h7/src/bin/usart_dma.rs +++ b/examples/stm32h7/src/bin/usart_dma.rs | |||
| @@ -9,7 +9,6 @@ use embassy::executor::Executor; | |||
| 9 | use embassy::util::Forever; | 9 | use embassy::util::Forever; |
| 10 | use embassy_stm32::dma::NoDma; | 10 | use embassy_stm32::dma::NoDma; |
| 11 | use embassy_stm32::usart::{Config, Uart}; | 11 | use embassy_stm32::usart::{Config, Uart}; |
| 12 | use embassy_traits::uart::Write as _Write; | ||
| 13 | use example_common::*; | 12 | use example_common::*; |
| 14 | 13 | ||
| 15 | use cortex_m_rt::entry; | 14 | use cortex_m_rt::entry; |
diff --git a/examples/stm32l0/.cargo/config.toml b/examples/stm32l0/.cargo/config.toml index 4ea047484..840faa62e 100644 --- a/examples/stm32l0/.cargo/config.toml +++ b/examples/stm32l0/.cargo/config.toml | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] |
| 2 | # replace your chip as listed in `probe-run --list-chips` | 2 | # replace your chip as listed in `probe-run --list-chips` |
| 3 | runner = "probe-run --chip STM32L072CZ" | 3 | runner = "probe-run --chip STM32L072CZTx" |
| 4 | 4 | ||
| 5 | [build] | 5 | [build] |
| 6 | target = "thumbv6m-none-eabi" | 6 | target = "thumbv6m-none-eabi" |
diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 7056d580a..20a2ec8d0 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-tim3", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-tim3", "exti", "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/stm32l0/build.rs b/examples/stm32l0/build.rs index 30691aa97..8cd32d7ed 100644 --- a/examples/stm32l0/build.rs +++ b/examples/stm32l0/build.rs | |||
| @@ -1,34 +1,4 @@ | |||
| 1 | //! This build script copies the `memory.x` file from the crate root into | ||
| 2 | //! a directory where the linker can always find it at build time. | ||
| 3 | //! For many projects this is optional, as the linker always searches the | ||
| 4 | //! project root directory -- wherever `Cargo.toml` is. However, if you | ||
| 5 | //! are using a workspace or have a more complicated build setup, this | ||
| 6 | //! build script becomes required. Additionally, by requesting that | ||
| 7 | //! Cargo re-run the build script whenever `memory.x` is changed, | ||
| 8 | //! updating `memory.x` ensures a rebuild of the application with the | ||
| 9 | //! new memory settings. | ||
| 10 | |||
| 11 | use std::env; | ||
| 12 | use std::fs::File; | ||
| 13 | use std::io::Write; | ||
| 14 | use std::path::PathBuf; | ||
| 15 | |||
| 16 | fn main() { | 1 | fn main() { |
| 17 | // Put `memory.x` in our output directory and ensure it's | ||
| 18 | // on the linker search path. | ||
| 19 | let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); | ||
| 20 | File::create(out.join("memory.x")) | ||
| 21 | .unwrap() | ||
| 22 | .write_all(include_bytes!("memory.x")) | ||
| 23 | .unwrap(); | ||
| 24 | println!("cargo:rustc-link-search={}", out.display()); | ||
| 25 | |||
| 26 | // By default, Cargo will re-run a build script whenever | ||
| 27 | // any file in the project changes. By specifying `memory.x` | ||
| 28 | // here, we ensure the build script is only re-run when | ||
| 29 | // `memory.x` is changed. | ||
| 30 | println!("cargo:rerun-if-changed=memory.x"); | ||
| 31 | |||
| 32 | println!("cargo:rustc-link-arg-bins=--nmagic"); | 2 | println!("cargo:rustc-link-arg-bins=--nmagic"); |
| 33 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); | 3 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); |
| 34 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); | 4 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); |
diff --git a/examples/stm32l0/memory.x b/examples/stm32l0/memory.x deleted file mode 100644 index 67a50a5ff..000000000 --- a/examples/stm32l0/memory.x +++ /dev/null | |||
| @@ -1,5 +0,0 @@ | |||
| 1 | MEMORY | ||
| 2 | { | ||
| 3 | FLASH : ORIGIN = 0x08000000, LENGTH = 192K | ||
| 4 | RAM : ORIGIN = 0x20000000, LENGTH = 20K | ||
| 5 | } | ||
diff --git a/examples/stm32l0/src/bin/blinky.rs b/examples/stm32l0/src/bin/blinky.rs index 1198b29da..46e29a897 100644 --- a/examples/stm32l0/src/bin/blinky.rs +++ b/examples/stm32l0/src/bin/blinky.rs | |||
| @@ -9,7 +9,6 @@ use embassy::executor::Spawner; | |||
| 9 | use embassy::time::{Duration, Timer}; | 9 | use embassy::time::{Duration, Timer}; |
| 10 | use embassy_stm32::gpio::{Level, Output, Speed}; | 10 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 11 | use embassy_stm32::Peripherals; | 11 | use embassy_stm32::Peripherals; |
| 12 | use embedded_hal::digital::v2::OutputPin; | ||
| 13 | use example_common::*; | 12 | use example_common::*; |
| 14 | 13 | ||
| 15 | #[embassy::main] | 14 | #[embassy::main] |
| @@ -20,11 +19,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 20 | 19 | ||
| 21 | loop { | 20 | loop { |
| 22 | info!("high"); | 21 | info!("high"); |
| 23 | unwrap!(led.set_high()); | 22 | led.set_high(); |
| 24 | Timer::after(Duration::from_millis(300)).await; | 23 | Timer::after(Duration::from_millis(300)).await; |
| 25 | 24 | ||
| 26 | info!("low"); | 25 | info!("low"); |
| 27 | unwrap!(led.set_low()); | 26 | led.set_low(); |
| 28 | Timer::after(Duration::from_millis(300)).await; | 27 | Timer::after(Duration::from_millis(300)).await; |
| 29 | } | 28 | } |
| 30 | } | 29 | } |
diff --git a/examples/stm32l0/src/bin/button.rs b/examples/stm32l0/src/bin/button.rs index c29155302..046c43caf 100644 --- a/examples/stm32l0/src/bin/button.rs +++ b/examples/stm32l0/src/bin/button.rs | |||
| @@ -7,7 +7,6 @@ mod example_common; | |||
| 7 | use embassy::executor::Spawner; | 7 | use embassy::executor::Spawner; |
| 8 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 8 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 9 | use embassy_stm32::Peripherals; | 9 | use embassy_stm32::Peripherals; |
| 10 | use embedded_hal::digital::v2::{InputPin, OutputPin}; | ||
| 11 | use example_common::*; | 10 | use example_common::*; |
| 12 | 11 | ||
| 13 | #[embassy::main] | 12 | #[embassy::main] |
| @@ -19,14 +18,14 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 19 | let mut led2 = Output::new(p.PB5, Level::High, Speed::Low); | 18 | let mut led2 = Output::new(p.PB5, Level::High, Speed::Low); |
| 20 | 19 | ||
| 21 | loop { | 20 | loop { |
| 22 | if unwrap!(button.is_high()) { | 21 | if button.is_high() { |
| 23 | info!("high"); | 22 | info!("high"); |
| 24 | unwrap!(led1.set_high()); | 23 | led1.set_high(); |
| 25 | unwrap!(led2.set_low()); | 24 | led2.set_low(); |
| 26 | } else { | 25 | } else { |
| 27 | info!("low"); | 26 | info!("low"); |
| 28 | unwrap!(led1.set_low()); | 27 | led1.set_low(); |
| 29 | unwrap!(led2.set_high()); | 28 | led2.set_high(); |
| 30 | } | 29 | } |
| 31 | } | 30 | } |
| 32 | } | 31 | } |
diff --git a/examples/stm32l0/src/bin/button_exti.rs b/examples/stm32l0/src/bin/button_exti.rs index 88c75ce6d..3edea3976 100644 --- a/examples/stm32l0/src/bin/button_exti.rs +++ b/examples/stm32l0/src/bin/button_exti.rs | |||
| @@ -9,7 +9,6 @@ use embassy::executor::Spawner; | |||
| 9 | use embassy_stm32::exti::ExtiInput; | 9 | use embassy_stm32::exti::ExtiInput; |
| 10 | use embassy_stm32::gpio::{Input, Pull}; | 10 | use embassy_stm32::gpio::{Input, Pull}; |
| 11 | use embassy_stm32::Peripherals; | 11 | use embassy_stm32::Peripherals; |
| 12 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | ||
| 13 | use example_common::*; | 12 | use example_common::*; |
| 14 | 13 | ||
| 15 | fn config() -> embassy_stm32::Config { | 14 | fn config() -> embassy_stm32::Config { |
diff --git a/examples/stm32l0/src/bin/spi.rs b/examples/stm32l0/src/bin/spi.rs index f768a5227..8d6e89d91 100644 --- a/examples/stm32l0/src/bin/spi.rs +++ b/examples/stm32l0/src/bin/spi.rs | |||
| @@ -7,14 +7,12 @@ mod example_common; | |||
| 7 | 7 | ||
| 8 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embedded_hal::digital::v2::OutputPin; | ||
| 11 | use example_common::*; | 10 | use example_common::*; |
| 12 | 11 | ||
| 13 | use embassy_stm32::dma::NoDma; | 12 | use embassy_stm32::dma::NoDma; |
| 14 | use embassy_stm32::spi::{Config, Spi}; | 13 | use embassy_stm32::spi::{Config, Spi}; |
| 15 | use embassy_stm32::time::Hertz; | 14 | use embassy_stm32::time::Hertz; |
| 16 | use embassy_stm32::Peripherals; | 15 | use embassy_stm32::Peripherals; |
| 17 | use embedded_hal::blocking::spi::Transfer; | ||
| 18 | 16 | ||
| 19 | #[embassy::main] | 17 | #[embassy::main] |
| 20 | async fn main(_spawner: Spawner, p: Peripherals) { | 18 | async fn main(_spawner: Spawner, p: Peripherals) { |
| @@ -35,9 +33,9 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 35 | 33 | ||
| 36 | loop { | 34 | loop { |
| 37 | let mut buf = [0x0Au8; 4]; | 35 | let mut buf = [0x0Au8; 4]; |
| 38 | unwrap!(cs.set_low()); | 36 | cs.set_low(); |
| 39 | unwrap!(spi.transfer(&mut buf)); | 37 | unwrap!(spi.blocking_transfer_in_place(&mut buf)); |
| 40 | unwrap!(cs.set_high()); | 38 | cs.set_high(); |
| 41 | info!("xfer {=[u8]:x}", buf); | 39 | info!("xfer {=[u8]:x}", buf); |
| 42 | } | 40 | } |
| 43 | } | 41 | } |
diff --git a/examples/stm32l0/src/bin/usart_dma.rs b/examples/stm32l0/src/bin/usart_dma.rs index 3fe61c13d..543e66f62 100644 --- a/examples/stm32l0/src/bin/usart_dma.rs +++ b/examples/stm32l0/src/bin/usart_dma.rs | |||
| @@ -10,7 +10,6 @@ use example_common::*; | |||
| 10 | use embassy::executor::Spawner; | 10 | use embassy::executor::Spawner; |
| 11 | use embassy_stm32::usart::{Config, Uart}; | 11 | use embassy_stm32::usart::{Config, Uart}; |
| 12 | use embassy_stm32::Peripherals; | 12 | use embassy_stm32::Peripherals; |
| 13 | use embassy_traits::uart::{Read, Write}; | ||
| 14 | 13 | ||
| 15 | #[embassy::main] | 14 | #[embassy::main] |
| 16 | async fn main(_spawner: Spawner, p: Peripherals) { | 15 | async fn main(_spawner: Spawner, p: Peripherals) { |
diff --git a/examples/stm32l1/src/bin/blinky.rs b/examples/stm32l1/src/bin/blinky.rs index deabdddba..07c804e9f 100644 --- a/examples/stm32l1/src/bin/blinky.rs +++ b/examples/stm32l1/src/bin/blinky.rs | |||
| @@ -9,7 +9,6 @@ use embassy::executor::Spawner; | |||
| 9 | use embassy::time::{Duration, Timer}; | 9 | use embassy::time::{Duration, Timer}; |
| 10 | use embassy_stm32::gpio::{Level, Output, Speed}; | 10 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 11 | use embassy_stm32::Peripherals; | 11 | use embassy_stm32::Peripherals; |
| 12 | use embedded_hal::digital::v2::OutputPin; | ||
| 13 | use example_common::*; | 12 | use example_common::*; |
| 14 | 13 | ||
| 15 | #[embassy::main] | 14 | #[embassy::main] |
| @@ -20,11 +19,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 20 | 19 | ||
| 21 | loop { | 20 | loop { |
| 22 | info!("high"); | 21 | info!("high"); |
| 23 | unwrap!(led.set_high()); | 22 | led.set_high(); |
| 24 | Timer::after(Duration::from_millis(1000)).await; | 23 | Timer::after(Duration::from_millis(1000)).await; |
| 25 | 24 | ||
| 26 | info!("low"); | 25 | info!("low"); |
| 27 | unwrap!(led.set_low()); | 26 | led.set_low(); |
| 28 | Timer::after(Duration::from_millis(1000)).await; | 27 | Timer::after(Duration::from_millis(1000)).await; |
| 29 | } | 28 | } |
| 30 | } | 29 | } |
diff --git a/examples/stm32l1/src/bin/spi.rs b/examples/stm32l1/src/bin/spi.rs index 3cfbe3fc4..e97e3ebb4 100644 --- a/examples/stm32l1/src/bin/spi.rs +++ b/examples/stm32l1/src/bin/spi.rs | |||
| @@ -7,14 +7,12 @@ mod example_common; | |||
| 7 | 7 | ||
| 8 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embedded_hal::digital::v2::OutputPin; | ||
| 11 | use example_common::*; | 10 | use example_common::*; |
| 12 | 11 | ||
| 13 | use embassy_stm32::dma::NoDma; | 12 | use embassy_stm32::dma::NoDma; |
| 14 | use embassy_stm32::spi::{Config, Spi}; | 13 | use embassy_stm32::spi::{Config, Spi}; |
| 15 | use embassy_stm32::time::Hertz; | 14 | use embassy_stm32::time::Hertz; |
| 16 | use embassy_stm32::Peripherals; | 15 | use embassy_stm32::Peripherals; |
| 17 | use embedded_hal::blocking::spi::Transfer; | ||
| 18 | 16 | ||
| 19 | #[embassy::main] | 17 | #[embassy::main] |
| 20 | async fn main(_spawner: Spawner, p: Peripherals) { | 18 | async fn main(_spawner: Spawner, p: Peripherals) { |
| @@ -35,9 +33,9 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 35 | 33 | ||
| 36 | loop { | 34 | loop { |
| 37 | let mut buf = [0x0Au8; 4]; | 35 | let mut buf = [0x0Au8; 4]; |
| 38 | unwrap!(cs.set_low()); | 36 | cs.set_low(); |
| 39 | unwrap!(spi.transfer(&mut buf)); | 37 | unwrap!(spi.blocking_transfer_in_place(&mut buf)); |
| 40 | unwrap!(cs.set_high()); | 38 | cs.set_high(); |
| 41 | info!("xfer {=[u8]:x}", buf); | 39 | info!("xfer {=[u8]:x}", buf); |
| 42 | } | 40 | } |
| 43 | } | 41 | } |
diff --git a/examples/stm32l4/src/bin/blinky.rs b/examples/stm32l4/src/bin/blinky.rs index 8a65858f8..030283756 100644 --- a/examples/stm32l4/src/bin/blinky.rs +++ b/examples/stm32l4/src/bin/blinky.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy::time::{Duration, Timer}; | 8 | use embassy::time::{Duration, Timer}; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embedded_hal::digital::v2::OutputPin; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
| @@ -18,9 +17,9 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 18 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); | 17 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); |
| 19 | 18 | ||
| 20 | loop { | 19 | loop { |
| 21 | unwrap!(led.set_high()); | 20 | led.set_high(); |
| 22 | Timer::after(Duration::from_millis(300)).await; | 21 | Timer::after(Duration::from_millis(300)).await; |
| 23 | unwrap!(led.set_low()); | 22 | led.set_low(); |
| 24 | Timer::after(Duration::from_millis(300)).await; | 23 | Timer::after(Duration::from_millis(300)).await; |
| 25 | } | 24 | } |
| 26 | } | 25 | } |
diff --git a/examples/stm32l4/src/bin/button.rs b/examples/stm32l4/src/bin/button.rs index fd8674549..6073c137e 100644 --- a/examples/stm32l4/src/bin/button.rs +++ b/examples/stm32l4/src/bin/button.rs | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | #[path = "../example_common.rs"] | 5 | #[path = "../example_common.rs"] |
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::{Input, Pull}; |
| 8 | use embedded_hal::digital::v2::InputPin; | ||
| 9 | use example_common::*; | 8 | use example_common::*; |
| 10 | 9 | ||
| 11 | #[cortex_m_rt::entry] | 10 | #[cortex_m_rt::entry] |
| @@ -17,7 +16,7 @@ fn main() -> ! { | |||
| 17 | let button = Input::new(p.PC13, Pull::Up); | 16 | let button = Input::new(p.PC13, Pull::Up); |
| 18 | 17 | ||
| 19 | loop { | 18 | loop { |
| 20 | if unwrap!(button.is_high()) { | 19 | if button.is_high() { |
| 21 | info!("high"); | 20 | info!("high"); |
| 22 | } else { | 21 | } else { |
| 23 | info!("low"); | 22 | info!("low"); |
diff --git a/examples/stm32l4/src/bin/button_exti.rs b/examples/stm32l4/src/bin/button_exti.rs index 0c2483ecb..848818bf2 100644 --- a/examples/stm32l4/src/bin/button_exti.rs +++ b/examples/stm32l4/src/bin/button_exti.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy_stm32::exti::ExtiInput; | 8 | use embassy_stm32::exti::ExtiInput; |
| 9 | use embassy_stm32::gpio::{Input, Pull}; | 9 | use embassy_stm32::gpio::{Input, Pull}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
diff --git a/examples/stm32l4/src/bin/i2c.rs b/examples/stm32l4/src/bin/i2c.rs index 86215697b..615012a06 100644 --- a/examples/stm32l4/src/bin/i2c.rs +++ b/examples/stm32l4/src/bin/i2c.rs | |||
| @@ -11,7 +11,6 @@ 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 embedded_hal::blocking::i2c::WriteRead; | ||
| 15 | use example_common::{info, unwrap}; | 14 | use example_common::{info, unwrap}; |
| 16 | 15 | ||
| 17 | const ADDRESS: u8 = 0x5F; | 16 | const ADDRESS: u8 = 0x5F; |
| @@ -23,6 +22,6 @@ async fn main(_spawner: Spawner, p: Peripherals) -> ! { | |||
| 23 | let mut i2c = I2c::new(p.I2C2, p.PB10, p.PB11, irq, NoDma, NoDma, Hertz(100_000)); | 22 | let mut i2c = I2c::new(p.I2C2, p.PB10, p.PB11, irq, NoDma, NoDma, Hertz(100_000)); |
| 24 | 23 | ||
| 25 | let mut data = [0u8; 1]; | 24 | let mut data = [0u8; 1]; |
| 26 | unwrap!(i2c.write_read(ADDRESS, &[WHOAMI], &mut data)); | 25 | unwrap!(i2c.blocking_write_read(ADDRESS, &[WHOAMI], &mut data)); |
| 27 | info!("Whoami: {}", data[0]); | 26 | info!("Whoami: {}", data[0]); |
| 28 | } | 27 | } |
diff --git a/examples/stm32l4/src/bin/i2c_dma.rs b/examples/stm32l4/src/bin/i2c_dma.rs index b0596aab8..d77bee8c1 100644 --- a/examples/stm32l4/src/bin/i2c_dma.rs +++ b/examples/stm32l4/src/bin/i2c_dma.rs | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | 7 | ||
| 8 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| 9 | use embassy::traits::i2c::I2c as I2cTrait; | ||
| 10 | use embassy_stm32::i2c::I2c; | 9 | use embassy_stm32::i2c::I2c; |
| 11 | use embassy_stm32::interrupt; | 10 | use embassy_stm32::interrupt; |
| 12 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
diff --git a/examples/stm32l4/src/bin/spi.rs b/examples/stm32l4/src/bin/spi.rs index 5b9ae1ce0..8567d3062 100644 --- a/examples/stm32l4/src/bin/spi.rs +++ b/examples/stm32l4/src/bin/spi.rs | |||
| @@ -9,8 +9,6 @@ use embassy_stm32::dma::NoDma; | |||
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, 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 embedded_hal::blocking::spi::Transfer; | ||
| 13 | use embedded_hal::digital::v2::OutputPin; | ||
| 14 | use example_common::*; | 12 | use example_common::*; |
| 15 | 13 | ||
| 16 | #[cortex_m_rt::entry] | 14 | #[cortex_m_rt::entry] |
| @@ -34,9 +32,9 @@ fn main() -> ! { | |||
| 34 | 32 | ||
| 35 | loop { | 33 | loop { |
| 36 | let mut buf = [0x0Au8; 4]; | 34 | let mut buf = [0x0Au8; 4]; |
| 37 | unwrap!(cs.set_low()); | 35 | cs.set_low(); |
| 38 | unwrap!(spi.transfer(&mut buf)); | 36 | unwrap!(spi.blocking_transfer_in_place(&mut buf)); |
| 39 | unwrap!(cs.set_high()); | 37 | cs.set_high(); |
| 40 | info!("xfer {=[u8]:x}", buf); | 38 | info!("xfer {=[u8]:x}", buf); |
| 41 | } | 39 | } |
| 42 | } | 40 | } |
diff --git a/examples/stm32l4/src/bin/spi_blocking_async.rs b/examples/stm32l4/src/bin/spi_blocking_async.rs index f092706d4..3be3f21c9 100644 --- a/examples/stm32l4/src/bin/spi_blocking_async.rs +++ b/examples/stm32l4/src/bin/spi_blocking_async.rs | |||
| @@ -12,7 +12,6 @@ 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, spi::FullDuplex}; |
| 15 | use embedded_hal::digital::v2::{InputPin, OutputPin}; | ||
| 16 | use example_common::*; | 15 | use example_common::*; |
| 17 | 16 | ||
| 18 | #[embassy::main] | 17 | #[embassy::main] |
| @@ -41,17 +40,17 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 41 | let ready = Input::new(p.PE1, Pull::Up); | 40 | let ready = Input::new(p.PE1, Pull::Up); |
| 42 | 41 | ||
| 43 | cortex_m::asm::delay(100_000); | 42 | cortex_m::asm::delay(100_000); |
| 44 | unwrap!(reset.set_high()); | 43 | reset.set_high(); |
| 45 | cortex_m::asm::delay(100_000); | 44 | cortex_m::asm::delay(100_000); |
| 46 | 45 | ||
| 47 | while unwrap!(ready.is_low()) { | 46 | while ready.is_low() { |
| 48 | info!("waiting for ready"); | 47 | info!("waiting for ready"); |
| 49 | } | 48 | } |
| 50 | 49 | ||
| 51 | let write = [0x0A; 10]; | 50 | let write = [0x0A; 10]; |
| 52 | let mut read = [0; 10]; | 51 | let mut read = [0; 10]; |
| 53 | unwrap!(cs.set_low()); | 52 | cs.set_low(); |
| 54 | spi.read_write(&mut read, &write).await.ok(); | 53 | spi.read_write(&mut read, &write).await.ok(); |
| 55 | unwrap!(cs.set_high()); | 54 | cs.set_high(); |
| 56 | info!("xfer {=[u8]:x}", read); | 55 | info!("xfer {=[u8]:x}", read); |
| 57 | } | 56 | } |
diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index 4b74c7d7d..d6464bbfa 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs | |||
| @@ -11,7 +11,6 @@ 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; | 13 | use embassy_traits::spi::FullDuplex; |
| 14 | use embedded_hal::digital::v2::{InputPin, OutputPin}; | ||
| 15 | use example_common::*; | 14 | use example_common::*; |
| 16 | 15 | ||
| 17 | #[embassy::main] | 16 | #[embassy::main] |
| @@ -38,17 +37,17 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 38 | let ready = Input::new(p.PE1, Pull::Up); | 37 | let ready = Input::new(p.PE1, Pull::Up); |
| 39 | 38 | ||
| 40 | cortex_m::asm::delay(100_000); | 39 | cortex_m::asm::delay(100_000); |
| 41 | unwrap!(reset.set_high()); | 40 | reset.set_high(); |
| 42 | cortex_m::asm::delay(100_000); | 41 | cortex_m::asm::delay(100_000); |
| 43 | 42 | ||
| 44 | while unwrap!(ready.is_low()) { | 43 | while ready.is_low() { |
| 45 | info!("waiting for ready"); | 44 | info!("waiting for ready"); |
| 46 | } | 45 | } |
| 47 | 46 | ||
| 48 | let write = [0x0A; 10]; | 47 | let write = [0x0A; 10]; |
| 49 | let mut read = [0; 10]; | 48 | let mut read = [0; 10]; |
| 50 | unwrap!(cs.set_low()); | 49 | cs.set_low(); |
| 51 | spi.read_write(&mut read, &write).await.ok(); | 50 | spi.read_write(&mut read, &write).await.ok(); |
| 52 | unwrap!(cs.set_high()); | 51 | cs.set_high(); |
| 53 | info!("xfer {=[u8]:x}", read); | 52 | info!("xfer {=[u8]:x}", read); |
| 54 | } | 53 | } |
diff --git a/examples/stm32l4/src/bin/usart.rs b/examples/stm32l4/src/bin/usart.rs index b6decbc9d..00875c896 100644 --- a/examples/stm32l4/src/bin/usart.rs +++ b/examples/stm32l4/src/bin/usart.rs | |||
| @@ -7,7 +7,6 @@ mod example_common; | |||
| 7 | 7 | ||
| 8 | use embassy_stm32::dma::NoDma; | 8 | use embassy_stm32::dma::NoDma; |
| 9 | use embassy_stm32::usart::{Config, Uart}; | 9 | use embassy_stm32::usart::{Config, Uart}; |
| 10 | use embedded_hal::blocking::serial::Write; | ||
| 11 | use example_common::*; | 10 | use example_common::*; |
| 12 | 11 | ||
| 13 | #[cortex_m_rt::entry] | 12 | #[cortex_m_rt::entry] |
| @@ -19,12 +18,12 @@ fn main() -> ! { | |||
| 19 | let config = Config::default(); | 18 | let config = Config::default(); |
| 20 | let mut usart = Uart::new(p.UART4, p.PA1, p.PA0, NoDma, NoDma, config); | 19 | let mut usart = Uart::new(p.UART4, p.PA1, p.PA0, NoDma, NoDma, config); |
| 21 | 20 | ||
| 22 | unwrap!(usart.bwrite_all(b"Hello Embassy World!\r\n")); | 21 | unwrap!(usart.blocking_write(b"Hello Embassy World!\r\n")); |
| 23 | info!("wrote Hello, starting echo"); | 22 | info!("wrote Hello, starting echo"); |
| 24 | 23 | ||
| 25 | let mut buf = [0u8; 1]; | 24 | let mut buf = [0u8; 1]; |
| 26 | loop { | 25 | loop { |
| 27 | unwrap!(usart.read_blocking(&mut buf)); | 26 | unwrap!(usart.blocking_read(&mut buf)); |
| 28 | unwrap!(usart.bwrite_all(&buf)); | 27 | unwrap!(usart.blocking_write(&buf)); |
| 29 | } | 28 | } |
| 30 | } | 29 | } |
diff --git a/examples/stm32l4/src/bin/usart_dma.rs b/examples/stm32l4/src/bin/usart_dma.rs index b49d3d882..b3a1e3897 100644 --- a/examples/stm32l4/src/bin/usart_dma.rs +++ b/examples/stm32l4/src/bin/usart_dma.rs | |||
| @@ -9,7 +9,6 @@ use embassy::executor::Spawner; | |||
| 9 | use embassy_stm32::dma::NoDma; | 9 | use embassy_stm32::dma::NoDma; |
| 10 | use embassy_stm32::usart::{Config, Uart}; | 10 | use embassy_stm32::usart::{Config, Uart}; |
| 11 | use embassy_stm32::Peripherals; | 11 | use embassy_stm32::Peripherals; |
| 12 | use embassy_traits::uart::Write as _; | ||
| 13 | use example_common::*; | 12 | use example_common::*; |
| 14 | use heapless::String; | 13 | use heapless::String; |
| 15 | 14 | ||
diff --git a/examples/stm32wb55/src/bin/blinky.rs b/examples/stm32wb55/src/bin/blinky.rs index 42522fe9b..e1dbb30de 100644 --- a/examples/stm32wb55/src/bin/blinky.rs +++ b/examples/stm32wb55/src/bin/blinky.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy::time::{Duration, Timer}; | 8 | use embassy::time::{Duration, Timer}; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embedded_hal::digital::v2::OutputPin; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
| @@ -19,11 +18,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 19 | 18 | ||
| 20 | loop { | 19 | loop { |
| 21 | info!("high"); | 20 | info!("high"); |
| 22 | unwrap!(led.set_high()); | 21 | led.set_high(); |
| 23 | Timer::after(Duration::from_millis(500)).await; | 22 | Timer::after(Duration::from_millis(500)).await; |
| 24 | 23 | ||
| 25 | info!("low"); | 24 | info!("low"); |
| 26 | unwrap!(led.set_low()); | 25 | led.set_low(); |
| 27 | Timer::after(Duration::from_millis(500)).await; | 26 | Timer::after(Duration::from_millis(500)).await; |
| 28 | } | 27 | } |
| 29 | } | 28 | } |
diff --git a/examples/stm32wb55/src/bin/button_exti.rs b/examples/stm32wb55/src/bin/button_exti.rs index aeb7bd8a6..4592fa308 100644 --- a/examples/stm32wb55/src/bin/button_exti.rs +++ b/examples/stm32wb55/src/bin/button_exti.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy_stm32::exti::ExtiInput; | 8 | use embassy_stm32::exti::ExtiInput; |
| 9 | use embassy_stm32::gpio::{Input, Pull}; | 9 | use embassy_stm32::gpio::{Input, Pull}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
diff --git a/examples/stm32wl55/src/bin/blinky.rs b/examples/stm32wl55/src/bin/blinky.rs index 3c12a79d0..9ec208c3d 100644 --- a/examples/stm32wl55/src/bin/blinky.rs +++ b/examples/stm32wl55/src/bin/blinky.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy::time::{Duration, Timer}; | 8 | use embassy::time::{Duration, Timer}; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embedded_hal::digital::v2::OutputPin; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
| @@ -19,11 +18,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 19 | 18 | ||
| 20 | loop { | 19 | loop { |
| 21 | info!("high"); | 20 | info!("high"); |
| 22 | unwrap!(led.set_high()); | 21 | led.set_high(); |
| 23 | Timer::after(Duration::from_millis(500)).await; | 22 | Timer::after(Duration::from_millis(500)).await; |
| 24 | 23 | ||
| 25 | info!("low"); | 24 | info!("low"); |
| 26 | unwrap!(led.set_low()); | 25 | led.set_low(); |
| 27 | Timer::after(Duration::from_millis(500)).await; | 26 | Timer::after(Duration::from_millis(500)).await; |
| 28 | } | 27 | } |
| 29 | } | 28 | } |
diff --git a/examples/stm32wl55/src/bin/button.rs b/examples/stm32wl55/src/bin/button.rs index 55b688663..be8f60e26 100644 --- a/examples/stm32wl55/src/bin/button.rs +++ b/examples/stm32wl55/src/bin/button.rs | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | #[path = "../example_common.rs"] | 5 | #[path = "../example_common.rs"] |
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 7 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 8 | use embedded_hal::digital::v2::{InputPin, OutputPin}; | ||
| 9 | use example_common::*; | 8 | use example_common::*; |
| 10 | 9 | ||
| 11 | use cortex_m_rt::entry; | 10 | use cortex_m_rt::entry; |
| @@ -21,12 +20,12 @@ fn main() -> ! { | |||
| 21 | let mut led2 = Output::new(p.PB9, Level::High, Speed::Low); | 20 | let mut led2 = Output::new(p.PB9, Level::High, Speed::Low); |
| 22 | 21 | ||
| 23 | loop { | 22 | loop { |
| 24 | if button.is_high().unwrap() { | 23 | if button.is_high() { |
| 25 | led1.set_high().unwrap(); | 24 | led1.set_high(); |
| 26 | led2.set_low().unwrap(); | 25 | led2.set_low(); |
| 27 | } else { | 26 | } else { |
| 28 | led1.set_low().unwrap(); | 27 | led1.set_low(); |
| 29 | led2.set_high().unwrap(); | 28 | led2.set_high(); |
| 30 | } | 29 | } |
| 31 | } | 30 | } |
| 32 | } | 31 | } |
diff --git a/examples/stm32wl55/src/bin/button_exti.rs b/examples/stm32wl55/src/bin/button_exti.rs index 31adfb5d1..8d66c7258 100644 --- a/examples/stm32wl55/src/bin/button_exti.rs +++ b/examples/stm32wl55/src/bin/button_exti.rs | |||
| @@ -8,7 +8,6 @@ use embassy::executor::Spawner; | |||
| 8 | use embassy_stm32::exti::ExtiInput; | 8 | use embassy_stm32::exti::ExtiInput; |
| 9 | use embassy_stm32::gpio::{Input, Pull}; | 9 | use embassy_stm32::gpio::{Input, Pull}; |
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | ||
| 12 | use example_common::*; | 11 | use example_common::*; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
diff --git a/examples/stm32wl55/src/bin/subghz.rs b/examples/stm32wl55/src/bin/subghz.rs index 52fe6e9fa..42d4eb64c 100644 --- a/examples/stm32wl55/src/bin/subghz.rs +++ b/examples/stm32wl55/src/bin/subghz.rs | |||
| @@ -10,14 +10,12 @@ mod example_common; | |||
| 10 | 10 | ||
| 11 | use embassy::channel::signal::Signal; | 11 | use embassy::channel::signal::Signal; |
| 12 | use embassy::interrupt::{Interrupt, InterruptExt}; | 12 | use embassy::interrupt::{Interrupt, InterruptExt}; |
| 13 | use embassy::traits::gpio::WaitForRisingEdge; | ||
| 14 | use embassy_stm32::dma::NoDma; | 13 | use embassy_stm32::dma::NoDma; |
| 15 | use embassy_stm32::exti::ExtiInput; | 14 | use embassy_stm32::exti::ExtiInput; |
| 16 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 15 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 17 | use embassy_stm32::interrupt; | 16 | use embassy_stm32::interrupt; |
| 18 | use embassy_stm32::subghz::*; | 17 | use embassy_stm32::subghz::*; |
| 19 | use embassy_stm32::Peripherals; | 18 | use embassy_stm32::Peripherals; |
| 20 | use embedded_hal::digital::v2::OutputPin; | ||
| 21 | use example_common::unwrap; | 19 | use example_common::unwrap; |
| 22 | 20 | ||
| 23 | const PING_DATA: &str = "PING"; | 21 | const PING_DATA: &str = "PING"; |
| @@ -89,9 +87,9 @@ async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { | |||
| 89 | 87 | ||
| 90 | defmt::info!("Radio ready for use"); | 88 | defmt::info!("Radio ready for use"); |
| 91 | 89 | ||
| 92 | unwrap!(led1.set_low()); | 90 | led1.set_low(); |
| 93 | 91 | ||
| 94 | unwrap!(led2.set_high()); | 92 | led2.set_high(); |
| 95 | 93 | ||
| 96 | unwrap!(radio.set_standby(StandbyClk::Rc)); | 94 | unwrap!(radio.set_standby(StandbyClk::Rc)); |
| 97 | unwrap!(radio.set_tcxo_mode(&TCXO_MODE)); | 95 | unwrap!(radio.set_tcxo_mode(&TCXO_MODE)); |
| @@ -110,11 +108,11 @@ async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { | |||
| 110 | 108 | ||
| 111 | defmt::info!("Status: {:?}", unwrap!(radio.status())); | 109 | defmt::info!("Status: {:?}", unwrap!(radio.status())); |
| 112 | 110 | ||
| 113 | unwrap!(led2.set_low()); | 111 | led2.set_low(); |
| 114 | 112 | ||
| 115 | loop { | 113 | loop { |
| 116 | pin.wait_for_rising_edge().await; | 114 | pin.wait_for_rising_edge().await; |
| 117 | unwrap!(led3.set_high()); | 115 | led3.set_high(); |
| 118 | unwrap!(radio.set_irq_cfg(&CfgIrq::new().irq_enable_all(Irq::TxDone))); | 116 | unwrap!(radio.set_irq_cfg(&CfgIrq::new().irq_enable_all(Irq::TxDone))); |
| 119 | unwrap!(radio.write_buffer(TX_BUF_OFFSET, PING_DATA_BYTES)); | 117 | unwrap!(radio.write_buffer(TX_BUF_OFFSET, PING_DATA_BYTES)); |
| 120 | unwrap!(radio.set_tx(Timeout::DISABLED)); | 118 | unwrap!(radio.set_tx(Timeout::DISABLED)); |
| @@ -127,6 +125,6 @@ async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { | |||
| 127 | defmt::info!("TX done"); | 125 | defmt::info!("TX done"); |
| 128 | } | 126 | } |
| 129 | unwrap!(radio.clear_irq_status(irq_status)); | 127 | unwrap!(radio.clear_irq_status(irq_status)); |
| 130 | unwrap!(led3.set_low()); | 128 | led3.set_low(); |
| 131 | } | 129 | } |
| 132 | } | 130 | } |
