diff options
| author | Bob McWhirter <[email protected]> | 2021-08-04 11:32:39 -0400 |
|---|---|---|
| committer | Bob McWhirter <[email protected]> | 2021-08-04 11:32:39 -0400 |
| commit | 03f15d3a6093fe169791c5b132688bb115e8046f (patch) | |
| tree | 86d415c30411417c2038fc1b853c55e4aac1f9da /examples | |
| parent | 07a095be0d439a0977de09aa5341885cbf399f06 (diff) | |
Remove builders from Config(s) and examples.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32f0/src/example_common.rs | 4 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/hello.rs | 4 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/dac.rs | 17 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/eth.rs | 25 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/spi.rs | 17 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/spi_dma.rs | 18 |
6 files changed, 66 insertions, 19 deletions
diff --git a/examples/stm32f0/src/example_common.rs b/examples/stm32f0/src/example_common.rs index e0ba4cd01..c166522e2 100644 --- a/examples/stm32f0/src/example_common.rs +++ b/examples/stm32f0/src/example_common.rs | |||
| @@ -12,7 +12,9 @@ use embassy_stm32::Config; | |||
| 12 | pub fn config() -> Config { | 12 | pub fn config() -> Config { |
| 13 | let mut rcc_config = rcc::Config::default(); | 13 | let mut rcc_config = rcc::Config::default(); |
| 14 | rcc_config.enable_debug_wfe = true; | 14 | rcc_config.enable_debug_wfe = true; |
| 15 | Config::default().rcc(rcc_config) | 15 | let mut config = Config::default(); |
| 16 | config.rcc = rcc_config; | ||
| 17 | config | ||
| 16 | } | 18 | } |
| 17 | 19 | ||
| 18 | defmt::timestamp! {"{=u64}", { | 20 | defmt::timestamp! {"{=u64}", { |
diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs index 8ee6c1ef8..8cbd46d6e 100644 --- a/examples/stm32f4/src/bin/hello.rs +++ b/examples/stm32f4/src/bin/hello.rs | |||
| @@ -22,7 +22,9 @@ fn config() -> Config { | |||
| 22 | rcc_config.sys_ck = Some(Hertz(84_000_000)); | 22 | rcc_config.sys_ck = Some(Hertz(84_000_000)); |
| 23 | rcc_config.enable_debug_wfe = true; | 23 | rcc_config.enable_debug_wfe = true; |
| 24 | 24 | ||
| 25 | Config::default().rcc(rcc_config) | 25 | let mut config = Config::default(); |
| 26 | config.rcc = rcc_config; | ||
| 27 | config | ||
| 26 | } | 28 | } |
| 27 | 29 | ||
| 28 | #[embassy::main(config = "config()")] | 30 | #[embassy::main(config = "config()")] |
diff --git a/examples/stm32h7/src/bin/dac.rs b/examples/stm32h7/src/bin/dac.rs index 658449f11..fb2feb7bb 100644 --- a/examples/stm32h7/src/bin/dac.rs +++ b/examples/stm32h7/src/bin/dac.rs | |||
| @@ -22,9 +22,7 @@ use embassy_stm32::Config; | |||
| 22 | fn main() -> ! { | 22 | fn main() -> ! { |
| 23 | info!("Hello World, dude!"); | 23 | info!("Hello World, dude!"); |
| 24 | 24 | ||
| 25 | let p = embassy_stm32::init( | 25 | let p = embassy_stm32::init( config() ); |
| 26 | Config::default().rcc(rcc::Config::default().sys_ck(400.mhz()).pll1_q(100.mhz())), | ||
| 27 | ); | ||
| 28 | 26 | ||
| 29 | unsafe { | 27 | unsafe { |
| 30 | Dbgmcu::enable_all(); | 28 | Dbgmcu::enable_all(); |
| @@ -54,3 +52,16 @@ fn to_sine_wave(v: u8) -> u8 { | |||
| 54 | (r.sin() * 128.0 + 127.0) as u8 | 52 | (r.sin() * 128.0 + 127.0) as u8 |
| 55 | } | 53 | } |
| 56 | } | 54 | } |
| 55 | |||
| 56 | fn config() -> Config { | ||
| 57 | let mut config = Config::default(); | ||
| 58 | config.rcc = rcc_config(); | ||
| 59 | config | ||
| 60 | } | ||
| 61 | |||
| 62 | fn rcc_config() -> rcc::Config { | ||
| 63 | let mut config = rcc::Config::default(); | ||
| 64 | config.sys_ck = Some(400.mhz().into()); | ||
| 65 | config.pll1.q_ck = Some( 100.mhz().into() ); | ||
| 66 | config | ||
| 67 | } \ No newline at end of file | ||
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index e49a101bf..233c5e4c3 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs | |||
| @@ -22,9 +22,10 @@ use embassy_net::{ | |||
| 22 | use embassy_stm32::clock::{Alarm, Clock}; | 22 | use embassy_stm32::clock::{Alarm, Clock}; |
| 23 | use embassy_stm32::eth::lan8742a::LAN8742A; | 23 | use embassy_stm32::eth::lan8742a::LAN8742A; |
| 24 | use embassy_stm32::eth::{Ethernet, State}; | 24 | use embassy_stm32::eth::{Ethernet, State}; |
| 25 | use embassy_stm32::rcc::{Config as RccConfig, Rcc}; | 25 | use embassy_stm32::rcc::{self, Rcc}; |
| 26 | use embassy_stm32::rng::Random; | 26 | use embassy_stm32::rng::Random; |
| 27 | use embassy_stm32::time::Hertz; | 27 | use embassy_stm32::time::Hertz; |
| 28 | use embassy_stm32::time::U32Ext; | ||
| 28 | use embassy_stm32::{interrupt, peripherals, Config}; | 29 | use embassy_stm32::{interrupt, peripherals, Config}; |
| 29 | use heapless::Vec; | 30 | use heapless::Vec; |
| 30 | use panic_probe as _; | 31 | use panic_probe as _; |
| @@ -108,16 +109,11 @@ fn main() -> ! { | |||
| 108 | info!("Hello World!"); | 109 | info!("Hello World!"); |
| 109 | 110 | ||
| 110 | info!("Setup RCC..."); | 111 | info!("Setup RCC..."); |
| 111 | let mut rcc_config = RccConfig::default(); | 112 | let mut p = embassy_stm32::init(config()); |
| 112 | rcc_config.sys_ck = Some(Hertz(400_000_000)); | ||
| 113 | rcc_config.pll1.q_ck = Some(Hertz(100_000_000)); | ||
| 114 | let config = Config::default().rcc(rcc_config); | ||
| 115 | |||
| 116 | let mut p = embassy_stm32::init(config); | ||
| 117 | 113 | ||
| 118 | // Constrain and Freeze clock | 114 | // Constrain and Freeze clock |
| 119 | 115 | ||
| 120 | let mut rcc = Rcc::new(&mut p.RCC, RccConfig::default()); | 116 | let mut rcc = Rcc::new(&mut p.RCC, rcc::Config::default()); |
| 121 | rcc.enable_debug_wfe(&mut p.DBGMCU, true); | 117 | rcc.enable_debug_wfe(&mut p.DBGMCU, true); |
| 122 | 118 | ||
| 123 | let rtc_int = interrupt_take!(TIM2); | 119 | let rtc_int = interrupt_take!(TIM2); |
| @@ -157,3 +153,16 @@ fn main() -> ! { | |||
| 157 | unwrap!(spawner.spawn(main_task(eth, config, spawner))); | 153 | unwrap!(spawner.spawn(main_task(eth, config, spawner))); |
| 158 | }) | 154 | }) |
| 159 | } | 155 | } |
| 156 | |||
| 157 | fn config() -> Config { | ||
| 158 | let mut config = Config::default(); | ||
| 159 | config.rcc = rcc_config(); | ||
| 160 | config | ||
| 161 | } | ||
| 162 | |||
| 163 | fn rcc_config() -> rcc::Config { | ||
| 164 | let mut config = rcc::Config::default(); | ||
| 165 | config.sys_ck = Some(400.mhz().into()); | ||
| 166 | config.pll1.q_ck = Some( 100.mhz().into() ); | ||
| 167 | config | ||
| 168 | } \ No newline at end of file | ||
diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index 3ae2ae7d7..b2cf19615 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs | |||
| @@ -60,9 +60,7 @@ fn main() -> ! { | |||
| 60 | Dbgmcu::enable_all(); | 60 | Dbgmcu::enable_all(); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | let p = embassy_stm32::init( | 63 | let p = embassy_stm32::init( config() ); |
| 64 | Config::default().rcc(rcc::Config::default().sys_ck(400.mhz()).pll1_q(100.mhz())), | ||
| 65 | ); | ||
| 66 | 64 | ||
| 67 | let spi = spi::Spi::new( | 65 | let spi = spi::Spi::new( |
| 68 | p.SPI3, | 66 | p.SPI3, |
| @@ -82,3 +80,16 @@ fn main() -> ! { | |||
| 82 | unwrap!(spawner.spawn(main_task(spi))); | 80 | unwrap!(spawner.spawn(main_task(spi))); |
| 83 | }) | 81 | }) |
| 84 | } | 82 | } |
| 83 | |||
| 84 | fn config() -> Config { | ||
| 85 | let mut config = Config::default(); | ||
| 86 | config.rcc = rcc_config(); | ||
| 87 | config | ||
| 88 | } | ||
| 89 | |||
| 90 | fn rcc_config() -> rcc::Config { | ||
| 91 | let mut config = rcc::Config::default(); | ||
| 92 | config.sys_ck = Some(400.mhz().into()); | ||
| 93 | config.pll1.q_ck = Some( 100.mhz().into() ); | ||
| 94 | config | ||
| 95 | } \ No newline at end of file | ||
diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index 17cc98f95..0ce4212b8 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #[path = "../example_common.rs"] | 9 | #[path = "../example_common.rs"] |
| 10 | mod example_common; | 10 | mod example_common; |
| 11 | |||
| 11 | use core::fmt::Write; | 12 | use core::fmt::Write; |
| 12 | use embassy::executor::Executor; | 13 | use embassy::executor::Executor; |
| 13 | use embassy::time::Clock; | 14 | use embassy::time::Clock; |
| @@ -55,9 +56,7 @@ fn main() -> ! { | |||
| 55 | Dbgmcu::enable_all(); | 56 | Dbgmcu::enable_all(); |
| 56 | } | 57 | } |
| 57 | 58 | ||
| 58 | let p = embassy_stm32::init( | 59 | let p = embassy_stm32::init( config() ); |
| 59 | Config::default().rcc(rcc::Config::default().sys_ck(400.mhz()).pll1_q(100.mhz())), | ||
| 60 | ); | ||
| 61 | 60 | ||
| 62 | let spi = spi::Spi::new( | 61 | let spi = spi::Spi::new( |
| 63 | p.SPI3, | 62 | p.SPI3, |
| @@ -77,3 +76,16 @@ fn main() -> ! { | |||
| 77 | unwrap!(spawner.spawn(main_task(spi))); | 76 | unwrap!(spawner.spawn(main_task(spi))); |
| 78 | }) | 77 | }) |
| 79 | } | 78 | } |
| 79 | |||
| 80 | fn config() -> Config { | ||
| 81 | let mut config = Config::default(); | ||
| 82 | config.rcc = rcc_config(); | ||
| 83 | config | ||
| 84 | } | ||
| 85 | |||
| 86 | fn rcc_config() -> rcc::Config { | ||
| 87 | let mut config = rcc::Config::default(); | ||
| 88 | config.sys_ck = Some(400.mhz().into()); | ||
| 89 | config.pll1.q_ck = Some( 100.mhz().into() ); | ||
| 90 | config | ||
| 91 | } | ||
