From 3e6aceaaa73617913d2a1fdd4df7533e3a021477 Mon Sep 17 00:00:00 2001 From: Bob McWhirter Date: Tue, 3 Aug 2021 14:31:41 -0400 Subject: [PATCH] Run cargo-fmt on the h7 examples. --- examples/stm32h7/src/bin/dac.rs | 14 ++++++-------- examples/stm32h7/src/bin/spi.rs | 24 +++++++++++------------- examples/stm32h7/src/bin/spi_dma.rs | 27 +++++++++++---------------- 3 files changed, 28 insertions(+), 37 deletions(-) diff --git a/examples/stm32h7/src/bin/dac.rs b/examples/stm32h7/src/bin/dac.rs index f1df5425d..658449f11 100644 --- a/examples/stm32h7/src/bin/dac.rs +++ b/examples/stm32h7/src/bin/dac.rs @@ -13,20 +13,18 @@ use embassy_stm32::gpio::NoPin; use example_common::*; use cortex_m_rt::entry; -use embassy_stm32::Config; -use embassy_stm32::rcc; use embassy_stm32::dac::{Channel, Dac, Value}; +use embassy_stm32::rcc; use embassy_stm32::time::U32Ext; +use embassy_stm32::Config; #[entry] fn main() -> ! { info!("Hello World, dude!"); - let p = embassy_stm32::init(Config::default().rcc( - rcc::Config::default() - .sys_ck(400.mhz()) - .pll1_q(100.mhz()) - )); + let p = embassy_stm32::init( + Config::default().rcc(rcc::Config::default().sys_ck(400.mhz()).pll1_q(100.mhz())), + ); unsafe { Dbgmcu::enable_all(); @@ -42,8 +40,8 @@ fn main() -> ! { } } -use micromath::F32Ext; use embassy_stm32::dbgmcu::Dbgmcu; +use micromath::F32Ext; fn to_sine_wave(v: u8) -> u8 { if v >= 128 { diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index ee11d32ec..3ae2ae7d7 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs @@ -12,20 +12,20 @@ mod example_common; use core::fmt::Write; use embassy::executor::Executor; use embassy::time::Clock; -use embassy_stm32::Config; use embassy::util::Forever; use embassy_stm32::dma::NoDma; -use embassy_stm32::spi; use embassy_stm32::rcc; -use example_common::*; +use embassy_stm32::spi; +use embassy_stm32::Config; use embedded_hal::blocking::spi::Transfer; +use example_common::*; -use cortex_m_rt::entry; -use heapless::String; -use embassy_stm32::time::U32Ext; -use embassy_stm32::peripherals::SPI3; -use embassy_stm32::dbgmcu::Dbgmcu; use core::str::from_utf8; +use cortex_m_rt::entry; +use embassy_stm32::dbgmcu::Dbgmcu; +use embassy_stm32::peripherals::SPI3; +use embassy_stm32::time::U32Ext; +use heapless::String; #[embassy::task] async fn main_task(mut spi: spi::Spi<'static, SPI3, NoDma, NoDma>) { @@ -60,11 +60,9 @@ fn main() -> ! { Dbgmcu::enable_all(); } - let p = embassy_stm32::init(Config::default().rcc( - rcc::Config::default() - .sys_ck(400.mhz()) - .pll1_q(100.mhz()) - )); + let p = embassy_stm32::init( + Config::default().rcc(rcc::Config::default().sys_ck(400.mhz()).pll1_q(100.mhz())), + ); let spi = spi::Spi::new( p.SPI3, diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index eb213f650..17cc98f95 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs @@ -11,32 +11,30 @@ mod example_common; use core::fmt::Write; use embassy::executor::Executor; use embassy::time::Clock; -use embassy_stm32::time::U32Ext; use embassy::util::Forever; -use example_common::*; +use embassy_stm32::time::U32Ext; use embassy_traits::spi::FullDuplex; +use example_common::*; +use core::str::from_utf8; use cortex_m_rt::entry; -use heapless::String; +use embassy_stm32::dbgmcu::Dbgmcu; +use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; +use embassy_stm32::rcc; use embassy_stm32::spi; use embassy_stm32::Config; -use core::str::from_utf8; -use embassy_stm32::dbgmcu::Dbgmcu; -use embassy_stm32::rcc; -use embassy_stm32::peripherals::{DMA1_CH4, DMA1_CH3, SPI3}; +use heapless::String; #[embassy::task] async fn main_task(mut spi: spi::Spi<'static, SPI3, DMA1_CH3, DMA1_CH4>) { - for n in 0u32.. { let mut write: String<128> = String::new(); - let mut read = [0;128]; + let mut read = [0; 128]; core::write!(&mut write, "Hello DMA World {}!\r\n", n).unwrap(); // read_write will slice the &mut read down to &write's actual length. spi.read_write(&mut read, write.as_bytes()).await.ok(); info!("read via spi+dma: {}", from_utf8(&read).unwrap()); } - } struct ZeroClock; @@ -49,7 +47,6 @@ impl Clock for ZeroClock { static EXECUTOR: Forever = Forever::new(); - #[entry] fn main() -> ! { info!("Hello World!"); @@ -58,11 +55,9 @@ fn main() -> ! { Dbgmcu::enable_all(); } - let p = embassy_stm32::init(Config::default().rcc( - rcc::Config::default() - .sys_ck(400.mhz()) - .pll1_q(100.mhz()) - )); + let p = embassy_stm32::init( + Config::default().rcc(rcc::Config::default().sys_ck(400.mhz()).pll1_q(100.mhz())), + ); let spi = spi::Spi::new( p.SPI3,