aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBob McWhirter <[email protected]>2021-08-03 14:31:41 -0400
committerBob McWhirter <[email protected]>2021-08-03 14:31:41 -0400
commit3e6aceaaa73617913d2a1fdd4df7533e3a021477 (patch)
tree94881b44715fb47afd26fae0f9fe2affec57c2ed /examples
parent88c11a653ca6d9db35c2ad27f253aaa9fa9ae921 (diff)
Run cargo-fmt on the h7 examples.
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32h7/src/bin/dac.rs14
-rw-r--r--examples/stm32h7/src/bin/spi.rs22
-rw-r--r--examples/stm32h7/src/bin/spi_dma.rs27
3 files changed, 27 insertions, 36 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;
13use example_common::*; 13use example_common::*;
14 14
15use cortex_m_rt::entry; 15use cortex_m_rt::entry;
16use embassy_stm32::Config;
17use embassy_stm32::rcc;
18use embassy_stm32::dac::{Channel, Dac, Value}; 16use embassy_stm32::dac::{Channel, Dac, Value};
17use embassy_stm32::rcc;
19use embassy_stm32::time::U32Ext; 18use embassy_stm32::time::U32Ext;
19use embassy_stm32::Config;
20 20
21#[entry] 21#[entry]
22fn main() -> ! { 22fn main() -> ! {
23 info!("Hello World, dude!"); 23 info!("Hello World, dude!");
24 24
25 let p = embassy_stm32::init(Config::default().rcc( 25 let p = embassy_stm32::init(
26 rcc::Config::default() 26 Config::default().rcc(rcc::Config::default().sys_ck(400.mhz()).pll1_q(100.mhz())),
27 .sys_ck(400.mhz()) 27 );
28 .pll1_q(100.mhz())
29 ));
30 28
31 unsafe { 29 unsafe {
32 Dbgmcu::enable_all(); 30 Dbgmcu::enable_all();
@@ -42,8 +40,8 @@ fn main() -> ! {
42 } 40 }
43} 41}
44 42
45use micromath::F32Ext;
46use embassy_stm32::dbgmcu::Dbgmcu; 43use embassy_stm32::dbgmcu::Dbgmcu;
44use micromath::F32Ext;
47 45
48fn to_sine_wave(v: u8) -> u8 { 46fn to_sine_wave(v: u8) -> u8 {
49 if v >= 128 { 47 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;
12use core::fmt::Write; 12use core::fmt::Write;
13use embassy::executor::Executor; 13use embassy::executor::Executor;
14use embassy::time::Clock; 14use embassy::time::Clock;
15use embassy_stm32::Config;
16use embassy::util::Forever; 15use embassy::util::Forever;
17use embassy_stm32::dma::NoDma; 16use embassy_stm32::dma::NoDma;
18use embassy_stm32::spi;
19use embassy_stm32::rcc; 17use embassy_stm32::rcc;
20use example_common::*; 18use embassy_stm32::spi;
19use embassy_stm32::Config;
21use embedded_hal::blocking::spi::Transfer; 20use embedded_hal::blocking::spi::Transfer;
21use example_common::*;
22 22
23use core::str::from_utf8;
23use cortex_m_rt::entry; 24use cortex_m_rt::entry;
24use heapless::String;
25use embassy_stm32::time::U32Ext;
26use embassy_stm32::peripherals::SPI3;
27use embassy_stm32::dbgmcu::Dbgmcu; 25use embassy_stm32::dbgmcu::Dbgmcu;
28use core::str::from_utf8; 26use embassy_stm32::peripherals::SPI3;
27use embassy_stm32::time::U32Ext;
28use heapless::String;
29 29
30#[embassy::task] 30#[embassy::task]
31async fn main_task(mut spi: spi::Spi<'static, SPI3, NoDma, NoDma>) { 31async fn main_task(mut spi: spi::Spi<'static, SPI3, NoDma, NoDma>) {
@@ -60,11 +60,9 @@ fn main() -> ! {
60 Dbgmcu::enable_all(); 60 Dbgmcu::enable_all();
61 } 61 }
62 62
63 let p = embassy_stm32::init(Config::default().rcc( 63 let p = embassy_stm32::init(
64 rcc::Config::default() 64 Config::default().rcc(rcc::Config::default().sys_ck(400.mhz()).pll1_q(100.mhz())),
65 .sys_ck(400.mhz()) 65 );
66 .pll1_q(100.mhz())
67 ));
68 66
69 let spi = spi::Spi::new( 67 let spi = spi::Spi::new(
70 p.SPI3, 68 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;
11use core::fmt::Write; 11use core::fmt::Write;
12use embassy::executor::Executor; 12use embassy::executor::Executor;
13use embassy::time::Clock; 13use embassy::time::Clock;
14use embassy_stm32::time::U32Ext;
15use embassy::util::Forever; 14use embassy::util::Forever;
16use example_common::*; 15use embassy_stm32::time::U32Ext;
17use embassy_traits::spi::FullDuplex; 16use embassy_traits::spi::FullDuplex;
17use example_common::*;
18 18
19use cortex_m_rt::entry;
20use heapless::String;
21use embassy_stm32::spi;
22use embassy_stm32::Config;
23use core::str::from_utf8; 19use core::str::from_utf8;
20use cortex_m_rt::entry;
24use embassy_stm32::dbgmcu::Dbgmcu; 21use embassy_stm32::dbgmcu::Dbgmcu;
22use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3};
25use embassy_stm32::rcc; 23use embassy_stm32::rcc;
26use embassy_stm32::peripherals::{DMA1_CH4, DMA1_CH3, SPI3}; 24use embassy_stm32::spi;
25use embassy_stm32::Config;
26use heapless::String;
27 27
28#[embassy::task] 28#[embassy::task]
29async fn main_task(mut spi: spi::Spi<'static, SPI3, DMA1_CH3, DMA1_CH4>) { 29async fn main_task(mut spi: spi::Spi<'static, SPI3, DMA1_CH3, DMA1_CH4>) {
30
31 for n in 0u32.. { 30 for n in 0u32.. {
32 let mut write: String<128> = String::new(); 31 let mut write: String<128> = String::new();
33 let mut read = [0;128]; 32 let mut read = [0; 128];
34 core::write!(&mut write, "Hello DMA World {}!\r\n", n).unwrap(); 33 core::write!(&mut write, "Hello DMA World {}!\r\n", n).unwrap();
35 // read_write will slice the &mut read down to &write's actual length. 34 // read_write will slice the &mut read down to &write's actual length.
36 spi.read_write(&mut read, write.as_bytes()).await.ok(); 35 spi.read_write(&mut read, write.as_bytes()).await.ok();
37 info!("read via spi+dma: {}", from_utf8(&read).unwrap()); 36 info!("read via spi+dma: {}", from_utf8(&read).unwrap());
38 } 37 }
39
40} 38}
41 39
42struct ZeroClock; 40struct ZeroClock;
@@ -49,7 +47,6 @@ impl Clock for ZeroClock {
49 47
50static EXECUTOR: Forever<Executor> = Forever::new(); 48static EXECUTOR: Forever<Executor> = Forever::new();
51 49
52
53#[entry] 50#[entry]
54fn main() -> ! { 51fn main() -> ! {
55 info!("Hello World!"); 52 info!("Hello World!");
@@ -58,11 +55,9 @@ fn main() -> ! {
58 Dbgmcu::enable_all(); 55 Dbgmcu::enable_all();
59 } 56 }
60 57
61 let p = embassy_stm32::init(Config::default().rcc( 58 let p = embassy_stm32::init(
62 rcc::Config::default() 59 Config::default().rcc(rcc::Config::default().sys_ck(400.mhz()).pll1_q(100.mhz())),
63 .sys_ck(400.mhz()) 60 );
64 .pll1_q(100.mhz())
65 ));
66 61
67 let spi = spi::Spi::new( 62 let spi = spi::Spi::new(
68 p.SPI3, 63 p.SPI3,