diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-08-17 22:25:58 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-08-17 22:25:58 +0200 |
| commit | 2e85eaf7d5f4dcf6d84f426542b8ec87aa51c429 (patch) | |
| tree | 1d22c32eae26435677df89083d71f50fc298a09f /examples/stm32l5/src | |
| parent | fc6e1e06b305d302d1b7ad17e8ef3a9be986c358 (diff) | |
examples Remove the `fn config()` idiom.
It was only useful for doing #[embassy_executor::main(config = "config()")]`. Now that
it's gone, it makes more sense to build the config in main directly.
Diffstat (limited to 'examples/stm32l5/src')
| -rw-r--r-- | examples/stm32l5/src/bin/rng.rs | 9 | ||||
| -rw-r--r-- | examples/stm32l5/src/bin/usb_ethernet.rs | 12 | ||||
| -rw-r--r-- | examples/stm32l5/src/bin/usb_hid_mouse.rs | 12 | ||||
| -rw-r--r-- | examples/stm32l5/src/bin/usb_serial.rs | 12 |
4 files changed, 12 insertions, 33 deletions
diff --git a/examples/stm32l5/src/bin/rng.rs b/examples/stm32l5/src/bin/rng.rs index b7919424a..cec9078e6 100644 --- a/examples/stm32l5/src/bin/rng.rs +++ b/examples/stm32l5/src/bin/rng.rs | |||
| @@ -9,7 +9,8 @@ use embassy_stm32::rng::Rng; | |||
| 9 | use embassy_stm32::Config; | 9 | use embassy_stm32::Config; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | fn config() -> Config { | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) { | ||
| 13 | let mut config = Config::default(); | 14 | let mut config = Config::default(); |
| 14 | config.rcc.mux = ClockSrc::PLL( | 15 | config.rcc.mux = ClockSrc::PLL( |
| 15 | PLLSource::HSI16, | 16 | PLLSource::HSI16, |
| @@ -18,12 +19,8 @@ fn config() -> Config { | |||
| 18 | PLLMul::Mul8, | 19 | PLLMul::Mul8, |
| 19 | Some(PLLClkDiv::Div2), | 20 | Some(PLLClkDiv::Div2), |
| 20 | ); | 21 | ); |
| 21 | config | 22 | let p = embassy_stm32::init(config); |
| 22 | } | ||
| 23 | 23 | ||
| 24 | #[embassy_executor::main] | ||
| 25 | async fn main(_spawner: Spawner) { | ||
| 26 | let p = embassy_stm32::init(config()); | ||
| 27 | info!("Hello World!"); | 24 | info!("Hello World!"); |
| 28 | 25 | ||
| 29 | let mut rng = Rng::new(p.RNG); | 26 | let mut rng = Rng::new(p.RNG); |
diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index cc7578990..769b67a2b 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs | |||
| @@ -83,19 +83,13 @@ async fn net_task(stack: &'static Stack<Device>) -> ! { | |||
| 83 | stack.run().await | 83 | stack.run().await |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | fn config() -> Config { | 86 | #[embassy_executor::main] |
| 87 | async fn main(spawner: Spawner) { | ||
| 87 | let mut config = Config::default(); | 88 | let mut config = Config::default(); |
| 88 | config.rcc.mux = ClockSrc::HSE(Hertz(16_000_000)); | ||
| 89 | |||
| 90 | config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); | 89 | config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); |
| 91 | config.rcc.hsi48 = true; | 90 | config.rcc.hsi48 = true; |
| 91 | let p = embassy_stm32::init(config); | ||
| 92 | 92 | ||
| 93 | config | ||
| 94 | } | ||
| 95 | |||
| 96 | #[embassy_executor::main] | ||
| 97 | async fn main(spawner: Spawner) { | ||
| 98 | let p = embassy_stm32::init(config()); | ||
| 99 | // Create the driver, from the HAL. | 93 | // Create the driver, from the HAL. |
| 100 | let irq = interrupt::take!(USB_FS); | 94 | let irq = interrupt::take!(USB_FS); |
| 101 | let driver = Driver::new(p.USB, irq, p.PA12, p.PA11); | 95 | let driver = Driver::new(p.USB, irq, p.PA12, p.PA11); |
diff --git a/examples/stm32l5/src/bin/usb_hid_mouse.rs b/examples/stm32l5/src/bin/usb_hid_mouse.rs index b8eef6d0d..ef0a20a42 100644 --- a/examples/stm32l5/src/bin/usb_hid_mouse.rs +++ b/examples/stm32l5/src/bin/usb_hid_mouse.rs | |||
| @@ -17,19 +17,13 @@ use futures::future::join; | |||
| 17 | use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; | 17 | use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; |
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| 20 | fn config() -> Config { | 20 | #[embassy_executor::main] |
| 21 | async fn main(_spawner: Spawner) { | ||
| 21 | let mut config = Config::default(); | 22 | let mut config = Config::default(); |
| 22 | config.rcc.mux = ClockSrc::HSE(Hertz(16_000_000)); | ||
| 23 | |||
| 24 | config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); | 23 | config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); |
| 25 | config.rcc.hsi48 = true; | 24 | config.rcc.hsi48 = true; |
| 25 | let p = embassy_stm32::init(config); | ||
| 26 | 26 | ||
| 27 | config | ||
| 28 | } | ||
| 29 | |||
| 30 | #[embassy_executor::main] | ||
| 31 | async fn main(_spawner: Spawner) { | ||
| 32 | let p = embassy_stm32::init(config()); | ||
| 33 | // Create the driver, from the HAL. | 27 | // Create the driver, from the HAL. |
| 34 | let irq = interrupt::take!(USB_FS); | 28 | let irq = interrupt::take!(USB_FS); |
| 35 | let driver = Driver::new(p.USB, irq, p.PA12, p.PA11); | 29 | let driver = Driver::new(p.USB, irq, p.PA12, p.PA11); |
diff --git a/examples/stm32l5/src/bin/usb_serial.rs b/examples/stm32l5/src/bin/usb_serial.rs index f8894231c..a763a0b56 100644 --- a/examples/stm32l5/src/bin/usb_serial.rs +++ b/examples/stm32l5/src/bin/usb_serial.rs | |||
| @@ -14,19 +14,13 @@ use embassy_usb_serial::{CdcAcmClass, State}; | |||
| 14 | use futures::future::join; | 14 | use futures::future::join; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
| 17 | fn config() -> Config { | 17 | #[embassy_executor::main] |
| 18 | async fn main(_spawner: Spawner) { | ||
| 18 | let mut config = Config::default(); | 19 | let mut config = Config::default(); |
| 19 | config.rcc.mux = ClockSrc::HSE(Hertz(16_000_000)); | ||
| 20 | |||
| 21 | config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); | 20 | config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); |
| 22 | config.rcc.hsi48 = true; | 21 | config.rcc.hsi48 = true; |
| 22 | let p = embassy_stm32::init(config); | ||
| 23 | 23 | ||
| 24 | config | ||
| 25 | } | ||
| 26 | |||
| 27 | #[embassy_executor::main] | ||
| 28 | async fn main(_spawner: Spawner) { | ||
| 29 | let p = embassy_stm32::init(config()); | ||
| 30 | info!("Hello World!"); | 24 | info!("Hello World!"); |
| 31 | 25 | ||
| 32 | // Create the driver, from the HAL. | 26 | // Create the driver, from the HAL. |
