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/stm32h7/src | |
| 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/stm32h7/src')
| -rw-r--r-- | examples/stm32h7/src/bin/blinky.rs | 5 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/button_exti.rs | 1 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/camera.rs | 5 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/mco.rs | 5 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/rng.rs | 5 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/spi.rs | 3 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/usart.rs | 7 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/usart_dma.rs | 1 |
8 files changed, 12 insertions, 20 deletions
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; |
