diff options
Diffstat (limited to 'examples')
172 files changed, 431 insertions, 937 deletions
diff --git a/examples/boot/nrf/src/bin/a.rs b/examples/boot/nrf/src/bin/a.rs index d45d0ff3..0b9715e4 100644 --- a/examples/boot/nrf/src/bin/a.rs +++ b/examples/boot/nrf/src/bin/a.rs @@ -6,12 +6,9 @@ use embassy_boot_nrf::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; -use embassy_nrf::{ - gpio::{Input, Pull}, - gpio::{Level, Output, OutputDrive}, - nvmc::Nvmc, - Peripherals, -}; +use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; +use embassy_nrf::nvmc::Nvmc; +use embassy_nrf::Peripherals; use panic_reset as _; static APP_B: &[u8] = include_bytes!("../../b.bin"); @@ -35,10 +32,7 @@ async fn main(_s: embassy::executor::Spawner, p: Peripherals) { for chunk in APP_B.chunks(4096) { let mut buf: [u8; 4096] = [0; 4096]; buf[..chunk.len()].copy_from_slice(chunk); - updater - .write_firmware(offset, &buf, &mut nvmc, 4096) - .await - .unwrap(); + updater.write_firmware(offset, &buf, &mut nvmc, 4096).await.unwrap(); offset += chunk.len(); } updater.update(&mut nvmc).await.unwrap(); diff --git a/examples/boot/nrf/src/bin/b.rs b/examples/boot/nrf/src/bin/b.rs index 18bb6330..a06c20f8 100644 --- a/examples/boot/nrf/src/bin/b.rs +++ b/examples/boot/nrf/src/bin/b.rs @@ -5,11 +5,8 @@ #![feature(type_alias_impl_trait)] use embassy::time::{Duration, Timer}; -use embassy_nrf::{ - gpio::{Level, Output, OutputDrive}, - Peripherals, -}; - +use embassy_nrf::gpio::{Level, Output, OutputDrive}; +use embassy_nrf::Peripherals; use panic_reset as _; #[embassy::main] diff --git a/examples/boot/stm32f3/src/bin/a.rs b/examples/boot/stm32f3/src/bin/a.rs index 9ad79838..4ff18d7c 100644 --- a/examples/boot/stm32f3/src/bin/a.rs +++ b/examples/boot/stm32f3/src/bin/a.rs @@ -2,6 +2,8 @@ #![no_main] #![feature(type_alias_impl_trait)] +#[cfg(feature = "defmt-rtt")] +use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; use embassy_stm32::exti::ExtiInput; @@ -10,9 +12,6 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[cfg(feature = "defmt-rtt")] -use defmt_rtt::*; - static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy::main] @@ -32,10 +31,7 @@ async fn main(_s: embassy::executor::Spawner, p: Peripherals) { for chunk in APP_B.chunks(2048) { let mut buf: [u8; 2048] = [0; 2048]; buf[..chunk.len()].copy_from_slice(chunk); - updater - .write_firmware(offset, &buf, &mut flash, 2048) - .await - .unwrap(); + updater.write_firmware(offset, &buf, &mut flash, 2048).await.unwrap(); offset += chunk.len(); } updater.update(&mut flash).await.unwrap(); diff --git a/examples/boot/stm32f3/src/bin/b.rs b/examples/boot/stm32f3/src/bin/b.rs index 81427598..4487e586 100644 --- a/examples/boot/stm32f3/src/bin/b.rs +++ b/examples/boot/stm32f3/src/bin/b.rs @@ -2,15 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] +#[cfg(feature = "defmt-rtt")] +use defmt_rtt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[cfg(feature = "defmt-rtt")] -use defmt_rtt::*; - #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.PA5, Level::High, Speed::Low); diff --git a/examples/boot/stm32f7/src/bin/a.rs b/examples/boot/stm32f7/src/bin/a.rs index b4f49d57..9c7921a1 100644 --- a/examples/boot/stm32f7/src/bin/a.rs +++ b/examples/boot/stm32f7/src/bin/a.rs @@ -2,6 +2,8 @@ #![no_main] #![feature(type_alias_impl_trait)] +#[cfg(feature = "defmt-rtt")] +use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; use embassy_stm32::exti::ExtiInput; @@ -10,9 +12,6 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[cfg(feature = "defmt-rtt")] -use defmt_rtt::*; - static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy::main] @@ -32,10 +31,7 @@ async fn main(_s: embassy::executor::Spawner, p: Peripherals) { let mut buf: [u8; 256 * 1024] = [0; 256 * 1024]; for chunk in APP_B.chunks(256 * 1024) { buf[..chunk.len()].copy_from_slice(chunk); - updater - .write_firmware(offset, &buf, &mut flash, 2048) - .await - .unwrap(); + updater.write_firmware(offset, &buf, &mut flash, 2048).await.unwrap(); offset += chunk.len(); } updater.update(&mut flash).await.unwrap(); diff --git a/examples/boot/stm32f7/src/bin/b.rs b/examples/boot/stm32f7/src/bin/b.rs index ed37137f..aa05bbcd 100644 --- a/examples/boot/stm32f7/src/bin/b.rs +++ b/examples/boot/stm32f7/src/bin/b.rs @@ -2,15 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] +#[cfg(feature = "defmt-rtt")] +use defmt_rtt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[cfg(feature = "defmt-rtt")] -use defmt_rtt::*; - #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { Timer::after(Duration::from_millis(300)).await; diff --git a/examples/boot/stm32h7/src/bin/a.rs b/examples/boot/stm32h7/src/bin/a.rs index 1d196e8a..704979db 100644 --- a/examples/boot/stm32h7/src/bin/a.rs +++ b/examples/boot/stm32h7/src/bin/a.rs @@ -2,6 +2,8 @@ #![no_main] #![feature(type_alias_impl_trait)] +#[cfg(feature = "defmt-rtt")] +use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; use embassy_stm32::exti::ExtiInput; @@ -10,9 +12,6 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[cfg(feature = "defmt-rtt")] -use defmt_rtt::*; - static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy::main] @@ -32,10 +31,7 @@ async fn main(_s: embassy::executor::Spawner, p: Peripherals) { let mut buf: [u8; 128 * 1024] = [0; 128 * 1024]; for chunk in APP_B.chunks(128 * 1024) { buf[..chunk.len()].copy_from_slice(chunk); - updater - .write_firmware(offset, &buf, &mut flash, 2048) - .await - .unwrap(); + updater.write_firmware(offset, &buf, &mut flash, 2048).await.unwrap(); offset += chunk.len(); } updater.update(&mut flash).await.unwrap(); diff --git a/examples/boot/stm32h7/src/bin/b.rs b/examples/boot/stm32h7/src/bin/b.rs index 233b93e1..ea014025 100644 --- a/examples/boot/stm32h7/src/bin/b.rs +++ b/examples/boot/stm32h7/src/bin/b.rs @@ -2,15 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] +#[cfg(feature = "defmt-rtt")] +use defmt_rtt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[cfg(feature = "defmt-rtt")] -use defmt_rtt::*; - #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { Timer::after(Duration::from_millis(300)).await; diff --git a/examples/boot/stm32l0/src/bin/a.rs b/examples/boot/stm32l0/src/bin/a.rs index d4b252bf..ce620347 100644 --- a/examples/boot/stm32l0/src/bin/a.rs +++ b/examples/boot/stm32l0/src/bin/a.rs @@ -2,6 +2,8 @@ #![no_main] #![feature(type_alias_impl_trait)] +#[cfg(feature = "defmt-rtt")] +use defmt_rtt::*; use embassy::time::{Duration, Timer}; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; @@ -11,9 +13,6 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[cfg(feature = "defmt-rtt")] -use defmt_rtt::*; - static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy::main] @@ -34,10 +33,7 @@ async fn main(_s: embassy::executor::Spawner, p: Peripherals) { for chunk in APP_B.chunks(128) { let mut buf: [u8; 128] = [0; 128]; buf[..chunk.len()].copy_from_slice(chunk); - updater - .write_firmware(offset, &buf, &mut flash, 128) - .await - .unwrap(); + updater.write_firmware(offset, &buf, &mut flash, 128).await.unwrap(); offset += chunk.len(); } diff --git a/examples/boot/stm32l0/src/bin/b.rs b/examples/boot/stm32l0/src/bin/b.rs index ed774fd7..0b585a14 100644 --- a/examples/boot/stm32l0/src/bin/b.rs +++ b/examples/boot/stm32l0/src/bin/b.rs @@ -2,15 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] +#[cfg(feature = "defmt-rtt")] +use defmt_rtt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[cfg(feature = "defmt-rtt")] -use defmt_rtt::*; - #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.PB6, Level::High, Speed::Low); diff --git a/examples/boot/stm32l1/src/bin/a.rs b/examples/boot/stm32l1/src/bin/a.rs index d4b252bf..ce620347 100644 --- a/examples/boot/stm32l1/src/bin/a.rs +++ b/examples/boot/stm32l1/src/bin/a.rs @@ -2,6 +2,8 @@ #![no_main] #![feature(type_alias_impl_trait)] +#[cfg(feature = "defmt-rtt")] +use defmt_rtt::*; use embassy::time::{Duration, Timer}; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; @@ -11,9 +13,6 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[cfg(feature = "defmt-rtt")] -use defmt_rtt::*; - static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy::main] @@ -34,10 +33,7 @@ async fn main(_s: embassy::executor::Spawner, p: Peripherals) { for chunk in APP_B.chunks(128) { let mut buf: [u8; 128] = [0; 128]; buf[..chunk.len()].copy_from_slice(chunk); - updater - .write_firmware(offset, &buf, &mut flash, 128) - .await - .unwrap(); + updater.write_firmware(offset, &buf, &mut flash, 128).await.unwrap(); offset += chunk.len(); } diff --git a/examples/boot/stm32l1/src/bin/b.rs b/examples/boot/stm32l1/src/bin/b.rs index ed774fd7..0b585a14 100644 --- a/examples/boot/stm32l1/src/bin/b.rs +++ b/examples/boot/stm32l1/src/bin/b.rs @@ -2,15 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] +#[cfg(feature = "defmt-rtt")] +use defmt_rtt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[cfg(feature = "defmt-rtt")] -use defmt_rtt::*; - #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.PB6, Level::High, Speed::Low); diff --git a/examples/boot/stm32l4/src/bin/a.rs b/examples/boot/stm32l4/src/bin/a.rs index 23b1d98b..bf609935 100644 --- a/examples/boot/stm32l4/src/bin/a.rs +++ b/examples/boot/stm32l4/src/bin/a.rs @@ -2,6 +2,8 @@ #![no_main] #![feature(type_alias_impl_trait)] +#[cfg(feature = "defmt-rtt")] +use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; use embassy_stm32::exti::ExtiInput; @@ -10,9 +12,6 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[cfg(feature = "defmt-rtt")] -use defmt_rtt::*; - static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy::main] @@ -32,10 +31,7 @@ async fn main(_s: embassy::executor::Spawner, p: Peripherals) { for chunk in APP_B.chunks(2048) { let mut buf: [u8; 2048] = [0; 2048]; buf[..chunk.len()].copy_from_slice(chunk); - updater - .write_firmware(offset, &buf, &mut flash, 2048) - .await - .unwrap(); + updater.write_firmware(offset, &buf, &mut flash, 2048).await.unwrap(); offset += chunk.len(); } updater.update(&mut flash).await.unwrap(); diff --git a/examples/boot/stm32l4/src/bin/b.rs b/examples/boot/stm32l4/src/bin/b.rs index 81427598..4487e586 100644 --- a/examples/boot/stm32l4/src/bin/b.rs +++ b/examples/boot/stm32l4/src/bin/b.rs @@ -2,15 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] +#[cfg(feature = "defmt-rtt")] +use defmt_rtt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[cfg(feature = "defmt-rtt")] -use defmt_rtt::*; - #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.PA5, Level::High, Speed::Low); diff --git a/examples/boot/stm32wl/src/bin/a.rs b/examples/boot/stm32wl/src/bin/a.rs index 1089eff1..dc1eb9be 100644 --- a/examples/boot/stm32wl/src/bin/a.rs +++ b/examples/boot/stm32wl/src/bin/a.rs @@ -2,6 +2,8 @@ #![no_main] #![feature(type_alias_impl_trait)] +#[cfg(feature = "defmt-rtt")] +use defmt_rtt::*; use embassy_boot_stm32::FirmwareUpdater; use embassy_embedded_hal::adapter::BlockingAsync; use embassy_stm32::exti::ExtiInput; @@ -10,9 +12,6 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[cfg(feature = "defmt-rtt")] -use defmt_rtt::*; - static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy::main] @@ -34,10 +33,7 @@ async fn main(_s: embassy::executor::Spawner, p: Peripherals) { let mut buf: [u8; 2048] = [0; 2048]; buf[..chunk.len()].copy_from_slice(chunk); // defmt::info!("Writing chunk at 0x{:x}", offset); - updater - .write_firmware(offset, &buf, &mut flash, 2048) - .await - .unwrap(); + updater.write_firmware(offset, &buf, &mut flash, 2048).await.unwrap(); offset += chunk.len(); } updater.update(&mut flash).await.unwrap(); diff --git a/examples/boot/stm32wl/src/bin/b.rs b/examples/boot/stm32wl/src/bin/b.rs index ffe15b66..f2344bd5 100644 --- a/examples/boot/stm32wl/src/bin/b.rs +++ b/examples/boot/stm32wl/src/bin/b.rs @@ -2,15 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] +#[cfg(feature = "defmt-rtt")] +use defmt_rtt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; use panic_reset as _; -#[cfg(feature = "defmt-rtt")] -use defmt_rtt::*; - #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.PB15, Level::High, Speed::Low); diff --git a/examples/nrf/src/bin/awaitable_timer.rs b/examples/nrf/src/bin/awaitable_timer.rs index 810b4bd6..34a657cb 100644 --- a/examples/nrf/src/bin/awaitable_timer.rs +++ b/examples/nrf/src/bin/awaitable_timer.rs @@ -4,12 +4,9 @@ use defmt::info; use embassy::executor::Spawner; -use embassy_nrf::interrupt; use embassy_nrf::timer::Timer; -use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use embassy_nrf::{interrupt, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/blinky.rs b/examples/nrf/src/bin/blinky.rs index 4828b08f..23d16f79 100644 --- a/examples/nrf/src/bin/blinky.rs +++ b/examples/nrf/src/bin/blinky.rs @@ -6,9 +6,7 @@ use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/buffered_uart.rs b/examples/nrf/src/bin/buffered_uart.rs index 782c3949..18dd698b 100644 --- a/examples/nrf/src/bin/buffered_uart.rs +++ b/examples/nrf/src/bin/buffered_uart.rs @@ -4,13 +4,11 @@ use defmt::*; use embassy::executor::Spawner; -use embassy_nrf::buffered_uarte::State; -use embassy_nrf::{buffered_uarte::BufferedUarte, interrupt, uarte, Peripherals}; +use embassy_nrf::buffered_uarte::{BufferedUarte, State}; +use embassy_nrf::{interrupt, uarte, Peripherals}; use embedded_io::asynch::{BufRead, Write}; use futures::pin_mut; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/channel.rs b/examples/nrf/src/bin/channel.rs index 12b46358..c57b91a4 100644 --- a/examples/nrf/src/bin/channel.rs +++ b/examples/nrf/src/bin/channel.rs @@ -9,9 +9,7 @@ use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; enum LedState { On, diff --git a/examples/nrf/src/bin/channel_sender_receiver.rs b/examples/nrf/src/bin/channel_sender_receiver.rs index 1742dcc9..847ce238 100644 --- a/examples/nrf/src/bin/channel_sender_receiver.rs +++ b/examples/nrf/src/bin/channel_sender_receiver.rs @@ -10,9 +10,7 @@ use embassy::time::{Duration, Timer}; use embassy::util::Forever; use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; enum LedState { On, diff --git a/examples/nrf/src/bin/executor_fairness_test.rs b/examples/nrf/src/bin/executor_fairness_test.rs index 7a356d14..5a422151 100644 --- a/examples/nrf/src/bin/executor_fairness_test.rs +++ b/examples/nrf/src/bin/executor_fairness_test.rs @@ -3,13 +3,12 @@ #![feature(type_alias_impl_trait)] use core::task::Poll; + use defmt::{info, unwrap}; use embassy::executor::Spawner; use embassy::time::{Duration, Instant, Timer}; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::task] async fn run1() { diff --git a/examples/nrf/src/bin/gpiote_channel.rs b/examples/nrf/src/bin/gpiote_channel.rs index 339f779f..ad8f37c6 100644 --- a/examples/nrf/src/bin/gpiote_channel.rs +++ b/examples/nrf/src/bin/gpiote_channel.rs @@ -7,9 +7,7 @@ use embassy::executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/gpiote_port.rs b/examples/nrf/src/bin/gpiote_port.rs index dc6bd301..30b87b3a 100644 --- a/examples/nrf/src/bin/gpiote_port.rs +++ b/examples/nrf/src/bin/gpiote_port.rs @@ -6,9 +6,7 @@ use defmt::{info, unwrap}; use embassy::executor::Spawner; use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::task(pool_size = 4)] async fn button_task(n: usize, mut pin: Input<'static, AnyPin>) { diff --git a/examples/nrf/src/bin/multiprio.rs b/examples/nrf/src/bin/multiprio.rs index abda18aa..1a4598e2 100644 --- a/examples/nrf/src/bin/multiprio.rs +++ b/examples/nrf/src/bin/multiprio.rs @@ -64,9 +64,7 @@ use embassy::util::Forever; use embassy_nrf::executor::{Executor, InterruptExecutor}; use embassy_nrf::interrupt; use embassy_nrf::interrupt::InterruptExt; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::task] async fn run_high() { diff --git a/examples/nrf/src/bin/mutex.rs b/examples/nrf/src/bin/mutex.rs index db1b72f6..92e01976 100644 --- a/examples/nrf/src/bin/mutex.rs +++ b/examples/nrf/src/bin/mutex.rs @@ -8,9 +8,7 @@ use embassy::executor::Spawner; use embassy::mutex::Mutex; use embassy::time::{Duration, Timer}; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; static MUTEX: Mutex<ThreadModeRawMutex, u32> = Mutex::new(0); diff --git a/examples/nrf/src/bin/nvmc.rs b/examples/nrf/src/bin/nvmc.rs index 7a57399f..b55ef1f6 100644 --- a/examples/nrf/src/bin/nvmc.rs +++ b/examples/nrf/src/bin/nvmc.rs @@ -8,9 +8,7 @@ use embassy::time::{Duration, Timer}; use embassy_nrf::nvmc::Nvmc; use embassy_nrf::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/ppi.rs b/examples/nrf/src/bin/ppi.rs index 3c9a8148..004a1bfa 100644 --- a/examples/nrf/src/bin/ppi.rs +++ b/examples/nrf/src/bin/ppi.rs @@ -3,6 +3,7 @@ #![feature(type_alias_impl_trait)] use core::future::pending; + use defmt::info; use embassy::executor::Spawner; use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; @@ -10,9 +11,7 @@ use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity}; use embassy_nrf::ppi::Ppi; use embassy_nrf::Peripherals; use gpiote::{OutputChannel, OutputChannelPolarity}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { @@ -60,12 +59,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { let mut ppi = Ppi::new_one_to_one(p.PPI_CH2, button3.event_in(), led1.task_set()); ppi.enable(); - let mut ppi = Ppi::new_one_to_two( - p.PPI_CH3, - button4.event_in(), - led1.task_out(), - led2.task_out(), - ); + let mut ppi = Ppi::new_one_to_two(p.PPI_CH3, button4.event_in(), led1.task_out(), led2.task_out()); ppi.enable(); info!("PPI setup!"); diff --git a/examples/nrf/src/bin/pwm.rs b/examples/nrf/src/bin/pwm.rs index 7939e79e..aec5dd73 100644 --- a/examples/nrf/src/bin/pwm.rs +++ b/examples/nrf/src/bin/pwm.rs @@ -7,81 +7,67 @@ use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::pwm::{Prescaler, SimplePwm}; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; // for i in range(1024): print(int((math.sin(i/512*math.pi)*0.4+0.5)**2*32767), ', ', end='') static DUTY: [u16; 1024] = [ - 8191, 8272, 8353, 8434, 8516, 8598, 8681, 8764, 8847, 8931, 9015, 9099, 9184, 9269, 9354, 9440, - 9526, 9613, 9700, 9787, 9874, 9962, 10050, 10139, 10227, 10316, 10406, 10495, 10585, 10675, - 10766, 10857, 10948, 11039, 11131, 11223, 11315, 11407, 11500, 11592, 11685, 11779, 11872, - 11966, 12060, 12154, 12248, 12343, 12438, 12533, 12628, 12723, 12818, 12914, 13010, 13106, - 13202, 13298, 13394, 13491, 13587, 13684, 13781, 13878, 13975, 14072, 14169, 14266, 14364, - 14461, 14558, 14656, 14754, 14851, 14949, 15046, 15144, 15242, 15339, 15437, 15535, 15632, - 15730, 15828, 15925, 16023, 16120, 16218, 16315, 16412, 16510, 16607, 16704, 16801, 16898, - 16995, 17091, 17188, 17284, 17380, 17477, 17572, 17668, 17764, 17859, 17955, 18050, 18145, - 18239, 18334, 18428, 18522, 18616, 18710, 18803, 18896, 18989, 19082, 19174, 19266, 19358, - 19449, 19540, 19631, 19722, 19812, 19902, 19991, 20081, 20169, 20258, 20346, 20434, 20521, - 20608, 20695, 20781, 20867, 20952, 21037, 21122, 21206, 21290, 21373, 21456, 21538, 21620, - 21701, 21782, 21863, 21943, 22022, 22101, 22179, 22257, 22335, 22412, 22488, 22564, 22639, - 22714, 22788, 22861, 22934, 23007, 23079, 23150, 23220, 23290, 23360, 23429, 23497, 23564, - 23631, 23698, 23763, 23828, 23892, 23956, 24019, 24081, 24143, 24204, 24264, 24324, 24383, - 24441, 24499, 24555, 24611, 24667, 24721, 24775, 24828, 24881, 24933, 24983, 25034, 25083, - 25132, 25180, 25227, 25273, 25319, 25363, 25407, 25451, 25493, 25535, 25575, 25615, 25655, - 25693, 25731, 25767, 25803, 25838, 25873, 25906, 25939, 25971, 26002, 26032, 26061, 26089, - 26117, 26144, 26170, 26195, 26219, 26242, 26264, 26286, 26307, 26327, 26346, 26364, 26381, - 26397, 26413, 26427, 26441, 26454, 26466, 26477, 26487, 26496, 26505, 26512, 26519, 26525, - 26530, 26534, 26537, 26539, 26540, 26541, 26540, 26539, 26537, 26534, 26530, 26525, 26519, - 26512, 26505, 26496, 26487, 26477, 26466, 26454, 26441, 26427, 26413, 26397, 26381, 26364, - 26346, 26327, 26307, 26286, 26264, 26242, 26219, 26195, 26170, 26144, 26117, 26089, 26061, - 26032, 26002, 25971, 25939, 25906, 25873, 25838, 25803, 25767, 25731, 25693, 25655, 25615, - 25575, 25535, 25493, 25451, 25407, 25363, 25319, 25273, 25227, 25180, 25132, 25083, 25034, - 24983, 24933, 24881, 24828, 24775, 24721, 24667, 24611, 24555, 24499, 24441, 24383, 24324, - 24264, 24204, 24143, 24081, 24019, 23956, 23892, 23828, 23763, 23698, 23631, 23564, 23497, - 23429, 23360, 23290, 23220, 23150, 23079, 23007, 22934, 22861, 22788, 22714, 22639, 22564, - 22488, 22412, 22335, 22257, 22179, 22101, 22022, 21943, 21863, 21782, 21701, 21620, 21538, - 21456, 21373, 21290, 21206, 21122, 21037, 20952, 20867, 20781, 20695, 20608, 20521, 20434, - 20346, 20258, 20169, 20081, 19991, 19902, 19812, 19722, 19631, 19540, 19449, 19358, 19266, - 19174, 19082, 18989, 18896, 18803, 18710, 18616, 18522, 18428, 18334, 18239, 18145, 18050, - 17955, 17859, 17764, 17668, 17572, 17477, 17380, 17284, 17188, 17091, 16995, 16898, 16801, - 16704, 16607, 16510, 16412, 16315, 16218, 16120, 16023, 15925, 15828, 15730, 15632, 15535, - 15437, 15339, 15242, 15144, 15046, 14949, 14851, 14754, 14656, 14558, 14461, 14364, 14266, - 14169, 14072, 13975, 13878, 13781, 13684, 13587, 13491, 13394, 13298, 13202, 13106, 13010, - 12914, 12818, 12723, 12628, 12533, 12438, 12343, 12248, 12154, 12060, 11966, 11872, 11779, - 11685, 11592, 11500, 11407, 11315, 11223, 11131, 11039, 10948, 10857, 10766, 10675, 10585, - 10495, 10406, 10316, 10227, 10139, 10050, 9962, 9874, 9787, 9700, 9613, 9526, 9440, 9354, 9269, - 9184, 9099, 9015, 8931, 8847, 8764, 8681, 8598, 8516, 8434, 8353, 8272, 8191, 8111, 8031, 7952, - 7873, 7794, 7716, 7638, 7561, 7484, 7407, 7331, 7255, 7180, 7105, 7031, 6957, 6883, 6810, 6738, - 6665, 6594, 6522, 6451, 6381, 6311, 6241, 6172, 6104, 6036, 5968, 5901, 5834, 5767, 5702, 5636, - 5571, 5507, 5443, 5379, 5316, 5253, 5191, 5130, 5068, 5008, 4947, 4888, 4828, 4769, 4711, 4653, - 4596, 4539, 4482, 4426, 4371, 4316, 4261, 4207, 4153, 4100, 4047, 3995, 3943, 3892, 3841, 3791, - 3741, 3691, 3642, 3594, 3546, 3498, 3451, 3404, 3358, 3312, 3267, 3222, 3178, 3134, 3090, 3047, - 3005, 2962, 2921, 2879, 2839, 2798, 2758, 2719, 2680, 2641, 2603, 2565, 2528, 2491, 2454, 2418, - 2382, 2347, 2312, 2278, 2244, 2210, 2177, 2144, 2112, 2080, 2048, 2017, 1986, 1956, 1926, 1896, - 1867, 1838, 1810, 1781, 1754, 1726, 1699, 1673, 1646, 1620, 1595, 1570, 1545, 1520, 1496, 1472, - 1449, 1426, 1403, 1380, 1358, 1336, 1315, 1294, 1273, 1252, 1232, 1212, 1192, 1173, 1154, 1135, - 1117, 1099, 1081, 1063, 1046, 1029, 1012, 996, 980, 964, 948, 933, 918, 903, 888, 874, 860, - 846, 833, 819, 806, 793, 781, 768, 756, 744, 733, 721, 710, 699, 688, 677, 667, 657, 647, 637, - 627, 618, 609, 599, 591, 582, 574, 565, 557, 549, 541, 534, 526, 519, 512, 505, 498, 492, 485, - 479, 473, 467, 461, 455, 450, 444, 439, 434, 429, 424, 419, 415, 410, 406, 402, 398, 394, 390, - 386, 383, 379, 376, 373, 370, 367, 364, 361, 359, 356, 354, 351, 349, 347, 345, 343, 342, 340, - 338, 337, 336, 334, 333, 332, 331, 330, 330, 329, 328, 328, 328, 327, 327, 327, 327, 327, 328, - 328, 328, 329, 330, 330, 331, 332, 333, 334, 336, 337, 338, 340, 342, 343, 345, 347, 349, 351, - 354, 356, 359, 361, 364, 367, 370, 373, 376, 379, 383, 386, 390, 394, 398, 402, 406, 410, 415, - 419, 424, 429, 434, 439, 444, 450, 455, 461, 467, 473, 479, 485, 492, 498, 505, 512, 519, 526, - 534, 541, 549, 557, 565, 574, 582, 591, 599, 609, 618, 627, 637, 647, 657, 667, 677, 688, 699, - 710, 721, 733, 744, 756, 768, 781, 793, 806, 819, 833, 846, 860, 874, 888, 903, 918, 933, 948, - 964, 980, 996, 1012, 1029, 1046, 1063, 1081, 1099, 1117, 1135, 1154, 1173, 1192, 1212, 1232, - 1252, 1273, 1294, 1315, 1336, 1358, 1380, 1403, 1426, 1449, 1472, 1496, 1520, 1545, 1570, 1595, - 1620, 1646, 1673, 1699, 1726, 1754, 1781, 1810, 1838, 1867, 1896, 1926, 1956, 1986, 2017, 2048, - 2080, 2112, 2144, 2177, 2210, 2244, 2278, 2312, 2347, 2382, 2418, 2454, 2491, 2528, 2565, 2603, - 2641, 2680, 2719, 2758, 2798, 2839, 2879, 2921, 2962, 3005, 3047, 3090, 3134, 3178, 3222, 3267, - 3312, 3358, 3404, 3451, 3498, 3546, 3594, 3642, 3691, 3741, 3791, 3841, 3892, 3943, 3995, 4047, - 4100, 4153, 4207, 4261, 4316, 4371, 4426, 4482, 4539, 4596, 4653, 4711, 4769, 4828, 4888, 4947, - 5008, 5068, 5130, 5191, 5253, 5316, 5379, 5443, 5507, 5571, 5636, 5702, 5767, 5834, 5901, 5968, - 6036, 6104, 6172, 6241, 6311, 6381, 6451, 6522, 6594, 6665, 6738, 6810, 6883, 6957, 7031, 7105, - 7180, 7255, 7331, 7407, 7484, 7561, 7638, 7716, 7794, 7873, 7952, 8031, 8111, + 8191, 8272, 8353, 8434, 8516, 8598, 8681, 8764, 8847, 8931, 9015, 9099, 9184, 9269, 9354, 9440, 9526, 9613, 9700, + 9787, 9874, 9962, 10050, 10139, 10227, 10316, 10406, 10495, 10585, 10675, 10766, 10857, 10948, 11039, 11131, 11223, + 11315, 11407, 11500, 11592, 11685, 11779, 11872, 11966, 12060, 12154, 12248, 12343, 12438, 12533, 12628, 12723, + 12818, 12914, 13010, 13106, 13202, 13298, 13394, 13491, 13587, 13684, 13781, 13878, 13975, 14072, 14169, 14266, + 14364, 14461, 14558, 14656, 14754, 14851, 14949, 15046, 15144, 15242, 15339, 15437, 15535, 15632, 15730, 15828, + 15925, 16023, 16120, 16218, 16315, 16412, 16510, 16607, 16704, 16801, 16898, 16995, 17091, 17188, 17284, 17380, + 17477, 17572, 17668, 17764, 17859, 17955, 18050, 18145, 18239, 18334, 18428, 18522, 18616, 18710, 18803, 18896, + 18989, 19082, 19174, 19266, 19358, 19449, 19540, 19631, 19722, 19812, 19902, 19991, 20081, 20169, 20258, 20346, + 20434, 20521, 20608, 20695, 20781, 20867, 20952, 21037, 21122, 21206, 21290, 21373, 21456, 21538, 21620, 21701, + 21782, 21863, 21943, 22022, 22101, 22179, 22257, 22335, 22412, 22488, 22564, 22639, 22714, 22788, 22861, 22934, + 23007, 23079, 23150, 23220, 23290, 23360, 23429, 23497, 23564, 23631, 23698, 23763, 23828, 23892, 23956, 24019, + 24081, 24143, 24204, 24264, 24324, 24383, 24441, 24499, 24555, 24611, 24667, 24721, 24775, 24828, 24881, 24933, + 24983, 25034, 25083, 25132, 25180, 25227, 25273, 25319, 25363, 25407, 25451, 25493, 25535, 25575, 25615, 25655, + 25693, 25731, 25767, 25803, 25838, 25873, 25906, 25939, 25971, 26002, 26032, 26061, 26089, 26117, 26144, 26170, + 26195, 26219, 26242, 26264, 26286, 26307, 26327, 26346, 26364, 26381, 26397, 26413, 26427, 26441, 26454, 26466, + 26477, 26487, 26496, 26505, 26512, 26519, 26525, 26530, 26534, 26537, 26539, 26540, 26541, 26540, 26539, 26537, + 26534, 26530, 26525, 26519, 26512, 26505, 26496, 26487, 26477, 26466, 26454, 26441, 26427, 26413, 26397, 26381, + 26364, 26346, 26327, 26307, 26286, 26264, 26242, 26219, 26195, 26170, 26144, 26117, 26089, 26061, 26032, 26002, + 25971, 25939, 25906, 25873, 25838, 25803, 25767, 25731, 25693, 25655, 25615, 25575, 25535, 25493, 25451, 25407, + 25363, 25319, 25273, 25227, 25180, 25132, 25083, 25034, 24983, 24933, 24881, 24828, 24775, 24721, 24667, 24611, + 24555, 24499, 24441, 24383, 24324, 24264, 24204, 24143, 24081, 24019, 23956, 23892, 23828, 23763, 23698, 23631, + 23564, 23497, 23429, 23360, 23290, 23220, 23150, 23079, 23007, 22934, 22861, 22788, 22714, 22639, 22564, 22488, + 22412, 22335, 22257, 22179, 22101, 22022, 21943, 21863, 21782, 21701, 21620, 21538, 21456, 21373, 21290, 21206, + 21122, 21037, 20952, 20867, 20781, 20695, 20608, 20521, 20434, 20346, 20258, 20169, 20081, 19991, 19902, 19812, + 19722, 19631, 19540, 19449, 19358, 19266, 19174, 19082, 18989, 18896, 18803, 18710, 18616, 18522, 18428, 18334, + 18239, 18145, 18050, 17955, 17859, 17764, 17668, 17572, 17477, 17380, 17284, 17188, 17091, 16995, 16898, 16801, + 16704, 16607, 16510, 16412, 16315, 16218, 16120, 16023, 15925, 15828, 15730, 15632, 15535, 15437, 15339, 15242, + 15144, 15046, 14949, 14851, 14754, 14656, 14558, 14461, 14364, 14266, 14169, 14072, 13975, 13878, 13781, 13684, + 13587, 13491, 13394, 13298, 13202, 13106, 13010, 12914, 12818, 12723, 12628, 12533, 12438, 12343, 12248, 12154, + 12060, 11966, 11872, 11779, 11685, 11592, 11500, 11407, 11315, 11223, 11131, 11039, 10948, 10857, 10766, 10675, + 10585, 10495, 10406, 10316, 10227, 10139, 10050, 9962, 9874, 9787, 9700, 9613, 9526, 9440, 9354, 9269, 9184, 9099, + 9015, 8931, 8847, 8764, 8681, 8598, 8516, 8434, 8353, 8272, 8191, 8111, 8031, 7952, 7873, 7794, 7716, 7638, 7561, + 7484, 7407, 7331, 7255, 7180, 7105, 7031, 6957, 6883, 6810, 6738, 6665, 6594, 6522, 6451, 6381, 6311, 6241, 6172, + 6104, 6036, 5968, 5901, 5834, 5767, 5702, 5636, 5571, 5507, 5443, 5379, 5316, 5253, 5191, 5130, 5068, 5008, 4947, + 4888, 4828, 4769, 4711, 4653, 4596, 4539, 4482, 4426, 4371, 4316, 4261, 4207, 4153, 4100, 4047, 3995, 3943, 3892, + 3841, 3791, 3741, 3691, 3642, 3594, 3546, 3498, 3451, 3404, 3358, 3312, 3267, 3222, 3178, 3134, 3090, 3047, 3005, + 2962, 2921, 2879, 2839, 2798, 2758, 2719, 2680, 2641, 2603, 2565, 2528, 2491, 2454, 2418, 2382, 2347, 2312, 2278, + 2244, 2210, 2177, 2144, 2112, 2080, 2048, 2017, 1986, 1956, 1926, 1896, 1867, 1838, 1810, 1781, 1754, 1726, 1699, + 1673, 1646, 1620, 1595, 1570, 1545, 1520, 1496, 1472, 1449, 1426, 1403, 1380, 1358, 1336, 1315, 1294, 1273, 1252, + 1232, 1212, 1192, 1173, 1154, 1135, 1117, 1099, 1081, 1063, 1046, 1029, 1012, 996, 980, 964, 948, 933, 918, 903, + 888, 874, 860, 846, 833, 819, 806, 793, 781, 768, 756, 744, 733, 721, 710, 699, 688, 677, 667, 657, 647, 637, 627, + 618, 609, 599, 591, 582, 574, 565, 557, 549, 541, 534, 526, 519, 512, 505, 498, 492, 485, 479, 473, 467, 461, 455, + 450, 444, 439, 434, 429, 424, 419, 415, 410, 406, 402, 398, 394, 390, 386, 383, 379, 376, 373, 370, 367, 364, 361, + 359, 356, 354, 351, 349, 347, 345, 343, 342, 340, 338, 337, 336, 334, 333, 332, 331, 330, 330, 329, 328, 328, 328, + 327, 327, 327, 327, 327, 328, 328, 328, 329, 330, 330, 331, 332, 333, 334, 336, 337, 338, 340, 342, 343, 345, 347, + 349, 351, 354, 356, 359, 361, 364, 367, 370, 373, 376, 379, 383, 386, 390, 394, 398, 402, 406, 410, 415, 419, 424, + 429, 434, 439, 444, 450, 455, 461, 467, 473, 479, 485, 492, 498, 505, 512, 519, 526, 534, 541, 549, 557, 565, 574, + 582, 591, 599, 609, 618, 627, 637, 647, 657, 667, 677, 688, 699, 710, 721, 733, 744, 756, 768, 781, 793, 806, 819, + 833, 846, 860, 874, 888, 903, 918, 933, 948, 964, 980, 996, 1012, 1029, 1046, 1063, 1081, 1099, 1117, 1135, 1154, + 1173, 1192, 1212, 1232, 1252, 1273, 1294, 1315, 1336, 1358, 1380, 1403, 1426, 1449, 1472, 1496, 1520, 1545, 1570, + 1595, 1620, 1646, 1673, 1699, 1726, 1754, 1781, 1810, 1838, 1867, 1896, 1926, 1956, 1986, 2017, 2048, 2080, 2112, + 2144, 2177, 2210, 2244, 2278, 2312, 2347, 2382, 2418, 2454, 2491, 2528, 2565, 2603, 2641, 2680, 2719, 2758, 2798, + 2839, 2879, 2921, 2962, 3005, 3047, 3090, 3134, 3178, 3222, 3267, 3312, 3358, 3404, 3451, 3498, 3546, 3594, 3642, + 3691, 3741, 3791, 3841, 3892, 3943, 3995, 4047, 4100, 4153, 4207, 4261, 4316, 4371, 4426, 4482, 4539, 4596, 4653, + 4711, 4769, 4828, 4888, 4947, 5008, 5068, 5130, 5191, 5253, 5316, 5379, 5443, 5507, 5571, 5636, 5702, 5767, 5834, + 5901, 5968, 6036, 6104, 6172, 6241, 6311, 6381, 6451, 6522, 6594, 6665, 6738, 6810, 6883, 6957, 7031, 7105, 7180, + 7255, 7331, 7407, 7484, 7561, 7638, 7716, 7794, 7873, 7952, 8031, 8111, ]; #[embassy::main] diff --git a/examples/nrf/src/bin/pwm_double_sequence.rs b/examples/nrf/src/bin/pwm_double_sequence.rs index 6fc42921..facafa77 100644 --- a/examples/nrf/src/bin/pwm_double_sequence.rs +++ b/examples/nrf/src/bin/pwm_double_sequence.rs @@ -6,13 +6,10 @@ use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::pwm::{ - Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, - StartSequence, + Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, StartSequence, }; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs index 3b2919ba..b7cb385c 100644 --- a/examples/nrf/src/bin/pwm_sequence.rs +++ b/examples/nrf/src/bin/pwm_sequence.rs @@ -5,13 +5,9 @@ use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; -use embassy_nrf::pwm::{ - Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer, -}; +use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/pwm_sequence_ppi.rs b/examples/nrf/src/bin/pwm_sequence_ppi.rs index 1f3662c6..7d020e48 100644 --- a/examples/nrf/src/bin/pwm_sequence_ppi.rs +++ b/examples/nrf/src/bin/pwm_sequence_ppi.rs @@ -4,18 +4,15 @@ #![feature(array_from_fn)] use core::future::pending; + use defmt::*; use embassy::executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; use embassy_nrf::ppi::Ppi; -use embassy_nrf::pwm::{ - Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer, -}; +use embassy_nrf::pwm::{Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer}; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs index 8bfe1d50..0dee8c94 100644 --- a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs +++ b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs @@ -6,13 +6,10 @@ use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::pwm::{ - Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, - SingleSequencer, + Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, SingleSequencer, }; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; // WS2812B LED light demonstration. Drives just one light. // The following reference on WS2812B may be of use: diff --git a/examples/nrf/src/bin/pwm_servo.rs b/examples/nrf/src/bin/pwm_servo.rs index 40863bf3..71a90a94 100644 --- a/examples/nrf/src/bin/pwm_servo.rs +++ b/examples/nrf/src/bin/pwm_servo.rs @@ -7,9 +7,7 @@ use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::pwm::{Prescaler, SimplePwm}; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/qdec.rs b/examples/nrf/src/bin/qdec.rs index bf5b1146..9529c7bb 100644 --- a/examples/nrf/src/bin/qdec.rs +++ b/examples/nrf/src/bin/qdec.rs @@ -4,14 +4,9 @@ use defmt::info; use embassy::executor::Spawner; -use embassy_nrf::{ - interrupt, - qdec::{self, Qdec}, - Peripherals, -}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use embassy_nrf::qdec::{self, Qdec}; +use embassy_nrf::{interrupt, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/qspi.rs b/examples/nrf/src/bin/qspi.rs index 8673b796..96c90f9c 100644 --- a/examples/nrf/src/bin/qspi.rs +++ b/examples/nrf/src/bin/qspi.rs @@ -4,11 +4,8 @@ use defmt::{assert_eq, info, unwrap}; use embassy::executor::Spawner; -use embassy_nrf::Peripherals; -use embassy_nrf::{interrupt, qspi}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use embassy_nrf::{interrupt, qspi, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; const PAGE_SIZE: usize = 4096; diff --git a/examples/nrf/src/bin/qspi_lowpower.rs b/examples/nrf/src/bin/qspi_lowpower.rs index 255ce5d5..ce2e40b2 100644 --- a/examples/nrf/src/bin/qspi_lowpower.rs +++ b/examples/nrf/src/bin/qspi_lowpower.rs @@ -3,14 +3,12 @@ #![feature(type_alias_impl_trait)] use core::mem; + use defmt::{info, unwrap}; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; -use embassy_nrf::Peripherals; -use embassy_nrf::{interrupt, qspi}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use embassy_nrf::{interrupt, qspi, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; // Workaround for alignment requirements. // Nicer API will probably come in the future. diff --git a/examples/nrf/src/bin/raw_spawn.rs b/examples/nrf/src/bin/raw_spawn.rs index 1d9d3ed5..d564b6b2 100644 --- a/examples/nrf/src/bin/raw_spawn.rs +++ b/examples/nrf/src/bin/raw_spawn.rs @@ -2,15 +2,14 @@ #![no_main] use core::mem; + use cortex_m_rt::entry; use defmt::{info, unwrap}; use embassy::executor::raw::TaskStorage; use embassy::executor::Executor; use embassy::time::{Duration, Timer}; use embassy::util::Forever; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; async fn run1() { loop { diff --git a/examples/nrf/src/bin/rng.rs b/examples/nrf/src/bin/rng.rs index 4b4b3a19..08d3abe1 100644 --- a/examples/nrf/src/bin/rng.rs +++ b/examples/nrf/src/bin/rng.rs @@ -3,13 +3,10 @@ #![feature(type_alias_impl_trait)] use embassy::executor::Spawner; -use embassy_nrf::interrupt; use embassy_nrf::rng::Rng; -use embassy_nrf::Peripherals; +use embassy_nrf::{interrupt, Peripherals}; use rand::Rng as _; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { @@ -27,12 +24,6 @@ async fn main(_spawner: Spawner, p: Peripherals) { rng.fill_bytes(&mut bytes).await; let zero_count: u32 = bytes.iter().fold(0, |acc, val| acc + val.count_zeros()); let one_count: u32 = bytes.iter().fold(0, |acc, val| acc + val.count_ones()); - defmt::info!( - "Chance of zero: {}%", - zero_count * 100 / (bytes.len() as u32 * 8) - ); - defmt::info!( - "Chance of one: {}%", - one_count * 100 / (bytes.len() as u32 * 8) - ); + defmt::info!("Chance of zero: {}%", zero_count * 100 / (bytes.len() as u32 * 8)); + defmt::info!("Chance of one: {}%", one_count * 100 / (bytes.len() as u32 * 8)); } diff --git a/examples/nrf/src/bin/saadc.rs b/examples/nrf/src/bin/saadc.rs index 5835be31..cb928978 100644 --- a/examples/nrf/src/bin/saadc.rs +++ b/examples/nrf/src/bin/saadc.rs @@ -7,9 +7,7 @@ use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::saadc::{ChannelConfig, Config, Saadc}; use embassy_nrf::{interrupt, Peripherals}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, mut p: Peripherals) { diff --git a/examples/nrf/src/bin/saadc_continuous.rs b/examples/nrf/src/bin/saadc_continuous.rs index 5e357f79..234294ea 100644 --- a/examples/nrf/src/bin/saadc_continuous.rs +++ b/examples/nrf/src/bin/saadc_continuous.rs @@ -8,9 +8,7 @@ use embassy::time::Duration; use embassy_nrf::saadc::{ChannelConfig, Config, Saadc, SamplerState}; use embassy_nrf::timer::Frequency; use embassy_nrf::{interrupt, Peripherals}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; // Demonstrates both continuous sampling and scanning multiple channels driven by a PPI linked timer diff --git a/examples/nrf/src/bin/self_spawn.rs b/examples/nrf/src/bin/self_spawn.rs index 35e73a8d..4b8ac04b 100644 --- a/examples/nrf/src/bin/self_spawn.rs +++ b/examples/nrf/src/bin/self_spawn.rs @@ -6,9 +6,7 @@ use defmt::{info, unwrap}; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::task(pool_size = 2)] async fn my_task(spawner: Spawner, n: u32) { diff --git a/examples/nrf/src/bin/self_spawn_current_executor.rs b/examples/nrf/src/bin/self_spawn_current_executor.rs index 4850d295..3c3379ce 100644 --- a/examples/nrf/src/bin/self_spawn_current_executor.rs +++ b/examples/nrf/src/bin/self_spawn_current_executor.rs @@ -6,9 +6,7 @@ use defmt::{info, unwrap}; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::task(pool_size = 2)] async fn my_task(n: u32) { diff --git a/examples/nrf/src/bin/spim.rs b/examples/nrf/src/bin/spim.rs index f2a4ab38..62040168 100644 --- a/examples/nrf/src/bin/spim.rs +++ b/examples/nrf/src/bin/spim.rs @@ -5,11 +5,8 @@ use defmt::{info, unwrap}; use embassy::executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; -use embassy_nrf::Peripherals; -use embassy_nrf::{interrupt, spim}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use embassy_nrf::{interrupt, spim, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/temp.rs b/examples/nrf/src/bin/temp.rs index aa807910..939cb39e 100644 --- a/examples/nrf/src/bin/temp.rs +++ b/examples/nrf/src/bin/temp.rs @@ -5,10 +5,9 @@ use defmt::info; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; -use embassy_nrf::{interrupt, temp::Temp, Peripherals}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use embassy_nrf::temp::Temp; +use embassy_nrf::{interrupt, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/timer.rs b/examples/nrf/src/bin/timer.rs index ff8ee9a8..64376dd7 100644 --- a/examples/nrf/src/bin/timer.rs +++ b/examples/nrf/src/bin/timer.rs @@ -6,9 +6,7 @@ use defmt::{info, unwrap}; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::task] async fn run1() { diff --git a/examples/nrf/src/bin/twim.rs b/examples/nrf/src/bin/twim.rs index 08c61415..fb8372a1 100644 --- a/examples/nrf/src/bin/twim.rs +++ b/examples/nrf/src/bin/twim.rs @@ -10,9 +10,7 @@ use defmt::*; use embassy::executor::Spawner; use embassy_nrf::twim::{self, Twim}; use embassy_nrf::{interrupt, Peripherals}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x50; diff --git a/examples/nrf/src/bin/twim_lowpower.rs b/examples/nrf/src/bin/twim_lowpower.rs index 45b347ea..c9c2d503 100644 --- a/examples/nrf/src/bin/twim_lowpower.rs +++ b/examples/nrf/src/bin/twim_lowpower.rs @@ -9,14 +9,13 @@ #![feature(type_alias_impl_trait)] use core::mem; + use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::twim::{self, Twim}; use embassy_nrf::{interrupt, Peripherals}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x50; diff --git a/examples/nrf/src/bin/uart.rs b/examples/nrf/src/bin/uart.rs index 91f7f4fd..c8c4a67a 100644 --- a/examples/nrf/src/bin/uart.rs +++ b/examples/nrf/src/bin/uart.rs @@ -5,9 +5,7 @@ use defmt::*; use embassy::executor::Spawner; use embassy_nrf::{interrupt, uarte, Peripherals}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/uart_idle.rs b/examples/nrf/src/bin/uart_idle.rs index 89336faa..6679b28d 100644 --- a/examples/nrf/src/bin/uart_idle.rs +++ b/examples/nrf/src/bin/uart_idle.rs @@ -5,9 +5,7 @@ use defmt::*; use embassy::executor::Spawner; use embassy_nrf::{interrupt, uarte, Peripherals}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { @@ -16,9 +14,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { config.baudrate = uarte::Baudrate::BAUD115200; let irq = interrupt::take!(UARTE0_UART0); - let mut uart = uarte::UarteWithIdle::new( - p.UARTE0, p.TIMER0, p.PPI_CH0, p.PPI_CH1, irq, p.P0_08, p.P0_06, config, - ); + let mut uart = uarte::UarteWithIdle::new(p.UARTE0, p.TIMER0, p.PPI_CH0, p.PPI_CH1, irq, p.P0_08, p.P0_06, config); info!("uarte initialized!"); diff --git a/examples/nrf/src/bin/uart_split.rs b/examples/nrf/src/bin/uart_split.rs index 958cfeba..1ffb6370 100644 --- a/examples/nrf/src/bin/uart_split.rs +++ b/examples/nrf/src/bin/uart_split.rs @@ -9,9 +9,7 @@ use embassy::executor::Spawner; use embassy_nrf::peripherals::UARTE0; use embassy_nrf::uarte::UarteRx; use embassy_nrf::{interrupt, uarte, Peripherals}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; static CHANNEL: Channel<ThreadModeRawMutex, [u8; 8], 1> = Channel::new(); diff --git a/examples/nrf/src/bin/usb_ethernet.rs b/examples/nrf/src/bin/usb_ethernet.rs index 3d85d22b..a20321fe 100644 --- a/examples/nrf/src/bin/usb_ethernet.rs +++ b/examples/nrf/src/bin/usb_ethernet.rs @@ -6,6 +6,7 @@ use core::mem; use core::sync::atomic::{AtomicBool, Ordering}; use core::task::Waker; + use defmt::*; use embassy::blocking_mutex::raw::ThreadModeRawMutex; use embassy::channel::mpmc::Channel; @@ -13,18 +14,13 @@ use embassy::executor::Spawner; use embassy::util::Forever; use embassy_net::tcp::TcpSocket; use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources}; -use embassy_nrf::pac; use embassy_nrf::rng::Rng; use embassy_nrf::usb::Driver; -use embassy_nrf::Peripherals; -use embassy_nrf::{interrupt, peripherals}; +use embassy_nrf::{interrupt, pac, peripherals, Peripherals}; use embassy_usb::{Builder, Config, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; - -use defmt_rtt as _; use embedded_io::asynch::{Read, Write}; -// global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; type MyDriver = Driver<'static, peripherals::USBD>; @@ -180,9 +176,7 @@ async fn main(spawner: Spawner, p: Peripherals) { let seed = u64::from_le_bytes(seed); // Init network stack - let device = Device { - mac_addr: our_mac_addr, - }; + let device = Device { mac_addr: our_mac_addr }; let stack = &*forever!(Stack::new( device, config, diff --git a/examples/nrf/src/bin/usb_hid_keyboard.rs b/examples/nrf/src/bin/usb_hid_keyboard.rs index 98e7dd69..97ec861d 100644 --- a/examples/nrf/src/bin/usb_hid_keyboard.rs +++ b/examples/nrf/src/bin/usb_hid_keyboard.rs @@ -5,25 +5,22 @@ use core::mem; use core::sync::atomic::{AtomicBool, Ordering}; + use defmt::*; use embassy::channel::signal::Signal; use embassy::executor::Spawner; use embassy::time::Duration; use embassy::util::{select, select3, Either, Either3}; use embassy_nrf::gpio::{Input, Pin, Pull}; -use embassy_nrf::interrupt; use embassy_nrf::interrupt::InterruptExt; -use embassy_nrf::pac; use embassy_nrf::usb::Driver; -use embassy_nrf::Peripherals; +use embassy_nrf::{interrupt, pac, Peripherals}; use embassy_usb::control::OutResponse; use embassy_usb::{Builder, Config, DeviceStateHandler}; use embassy_usb_hid::{HidReaderWriter, ReportId, RequestHandler, State}; use futures::future::join; use usbd_hid::descriptor::{KeyboardReport, SerializedDescriptor}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; static ENABLE_USB: Signal<bool> = Signal::new(); static SUSPENDED: AtomicBool = AtomicBool::new(false); @@ -182,9 +179,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { power_irq.unpend(); power_irq.enable(); - power - .intenset - .write(|w| w.usbdetected().set().usbremoved().set()); + power.intenset.write(|w| w.usbdetected().set().usbremoved().set()); // Run everything concurrently. // If we had made everything `'static` above instead, we could do this using separate tasks instead. @@ -260,9 +255,7 @@ impl DeviceStateHandler for MyDeviceStateHandler { fn configured(&self, configured: bool) { self.configured.store(configured, Ordering::Relaxed); if configured { - info!( - "Device configured, it may now draw up to the configured current limit from Vbus." - ) + info!("Device configured, it may now draw up to the configured current limit from Vbus.") } else { info!("Device is no longer configured, the Vbus current limit is 100mA."); } @@ -275,9 +268,7 @@ impl DeviceStateHandler for MyDeviceStateHandler { } else { SUSPENDED.store(false, Ordering::Release); if self.configured.load(Ordering::Relaxed) { - info!( - "Device resumed, it may now draw up to the configured current limit from Vbus" - ); + info!("Device resumed, it may now draw up to the configured current limit from Vbus"); } else { info!("Device resumed, the Vbus current limit is 100mA"); } diff --git a/examples/nrf/src/bin/usb_hid_mouse.rs b/examples/nrf/src/bin/usb_hid_mouse.rs index c526c1c6..9c44e5cc 100644 --- a/examples/nrf/src/bin/usb_hid_mouse.rs +++ b/examples/nrf/src/bin/usb_hid_mouse.rs @@ -4,21 +4,18 @@ #![feature(type_alias_impl_trait)] use core::mem; + use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; -use embassy_nrf::interrupt; -use embassy_nrf::pac; use embassy_nrf::usb::Driver; -use embassy_nrf::Peripherals; +use embassy_nrf::{interrupt, pac, Peripherals}; use embassy_usb::control::OutResponse; use embassy_usb::{Builder, Config}; use embassy_usb_hid::{HidWriter, ReportId, RequestHandler, State}; use futures::future::join; use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/nrf/src/bin/usb_serial.rs b/examples/nrf/src/bin/usb_serial.rs index 2551c4ba..f108db46 100644 --- a/examples/nrf/src/bin/usb_serial.rs +++ b/examples/nrf/src/bin/usb_serial.rs @@ -4,19 +4,16 @@ #![feature(type_alias_impl_trait)] use core::mem; + use defmt::{info, panic}; use embassy::executor::Spawner; -use embassy_nrf::interrupt; -use embassy_nrf::pac; use embassy_nrf::usb::{Driver, Instance}; -use embassy_nrf::Peripherals; +use embassy_nrf::{interrupt, pac, Peripherals}; use embassy_usb::driver::EndpointError; use embassy_usb::{Builder, Config}; use embassy_usb_serial::{CdcAcmClass, State}; use futures::future::join; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { @@ -104,9 +101,7 @@ impl From<EndpointError> for Disconnected { } } -async fn echo<'d, T: Instance + 'd>( - class: &mut CdcAcmClass<'d, Driver<'d, T>>, -) -> Result<(), Disconnected> { +async fn echo<'d, T: Instance + 'd>(class: &mut CdcAcmClass<'d, Driver<'d, T>>) -> Result<(), Disconnected> { let mut buf = [0; 64]; loop { let n = class.read_packet(&mut buf).await?; diff --git a/examples/nrf/src/bin/usb_serial_multitask.rs b/examples/nrf/src/bin/usb_serial_multitask.rs index 0e82ba31..dc503e67 100644 --- a/examples/nrf/src/bin/usb_serial_multitask.rs +++ b/examples/nrf/src/bin/usb_serial_multitask.rs @@ -4,19 +4,16 @@ #![feature(type_alias_impl_trait)] use core::mem; + use defmt::{info, panic, unwrap}; use embassy::executor::Spawner; use embassy::util::Forever; -use embassy_nrf::pac; use embassy_nrf::usb::Driver; -use embassy_nrf::Peripherals; -use embassy_nrf::{interrupt, peripherals}; +use embassy_nrf::{interrupt, pac, peripherals, Peripherals}; use embassy_usb::driver::EndpointError; use embassy_usb::{Builder, Config, UsbDevice}; use embassy_usb_serial::{CdcAcmClass, State}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; type MyDriver = Driver<'static, peripherals::USBD>; diff --git a/examples/nrf/src/bin/wdt.rs b/examples/nrf/src/bin/wdt.rs index 431ccca8..280e23bc 100644 --- a/examples/nrf/src/bin/wdt.rs +++ b/examples/nrf/src/bin/wdt.rs @@ -7,9 +7,7 @@ use embassy::executor::Spawner; use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::wdt::{Config, Watchdog}; use embassy_nrf::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/rp/src/bin/blinky.rs b/examples/rp/src/bin/blinky.rs index 6f199d07..35612a4c 100644 --- a/examples/rp/src/bin/blinky.rs +++ b/examples/rp/src/bin/blinky.rs @@ -7,9 +7,7 @@ use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_rp::{gpio, Peripherals}; use gpio::{Level, Output}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/rp/src/bin/button.rs b/examples/rp/src/bin/button.rs index 2418ad01..980e54ea 100644 --- a/examples/rp/src/bin/button.rs +++ b/examples/rp/src/bin/button.rs @@ -5,9 +5,7 @@ use embassy::executor::Spawner; use embassy_rp::gpio::{Input, Level, Output, Pull}; use embassy_rp::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/rp/src/bin/spi.rs b/examples/rp/src/bin/spi.rs index b3842436..d97aa94b 100644 --- a/examples/rp/src/bin/spi.rs +++ b/examples/rp/src/bin/spi.rs @@ -4,13 +4,10 @@ use defmt::*; use embassy::executor::Spawner; -use embassy_rp::spi; use embassy_rp::spi::Spi; -use embassy_rp::{gpio, Peripherals}; +use embassy_rp::{gpio, spi, Peripherals}; use gpio::{Level, Output}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/rp/src/bin/spi_display.rs b/examples/rp/src/bin/spi_display.rs index 5c3c4c4c..f4a411ba 100644 --- a/examples/rp/src/bin/spi_display.rs +++ b/examples/rp/src/bin/spi_display.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use core::cell::RefCell; + use defmt::*; use embassy::executor::Spawner; use embassy::time::Delay; use embassy_rp::gpio::{Level, Output}; -use embassy_rp::spi; use embassy_rp::spi::Spi; -use embassy_rp::Peripherals; +use embassy_rp::{spi, Peripherals}; use embedded_graphics::image::{Image, ImageRawLE}; use embedded_graphics::mono_font::ascii::FONT_10X20; use embedded_graphics::mono_font::MonoTextStyle; @@ -18,14 +18,12 @@ use embedded_graphics::prelude::*; use embedded_graphics::primitives::{PrimitiveStyleBuilder, Rectangle}; use embedded_graphics::text::Text; use st7789::{Orientation, ST7789}; +use {defmt_rtt as _, panic_probe as _}; use crate::my_display_interface::SPIDeviceInterface; use crate::shared_spi::SpiDeviceWithCs; use crate::touch::Touch; -use defmt_rtt as _; // global logger -use panic_probe as _; - //const DISPLAY_FREQ: u32 = 64_000_000; const TOUCH_FREQ: u32 = 200_000; @@ -94,9 +92,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { loop { if let Some((x, y)) = touch.read() { - let style = PrimitiveStyleBuilder::new() - .fill_color(Rgb565::BLUE) - .build(); + let style = PrimitiveStyleBuilder::new().fill_color(Rgb565::BLUE).build(); Rectangle::new(Point::new(x - 1, y - 1), Size::new(3, 3)) .into_styled(style) diff --git a/examples/rp/src/bin/uart.rs b/examples/rp/src/bin/uart.rs index bc941dd8..99072253 100644 --- a/examples/rp/src/bin/uart.rs +++ b/examples/rp/src/bin/uart.rs @@ -4,9 +4,7 @@ use embassy::executor::Spawner; use embassy_rp::{uart, Peripherals}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/std/src/serial_port.rs b/examples/std/src/serial_port.rs index 6825cbeb..c41abd4d 100644 --- a/examples/std/src/serial_port.rs +++ b/examples/std/src/serial_port.rs @@ -1,18 +1,16 @@ +use std::io; +use std::os::unix::io::{AsRawFd, RawFd}; + use nix::errno::Errno; use nix::fcntl::OFlag; use nix::sys::termios; -use std::io; -use std::os::unix::io::{AsRawFd, RawFd}; pub struct SerialPort { fd: RawFd, } impl SerialPort { - pub fn new<P: ?Sized + nix::NixPath>( - path: &P, - baudrate: termios::BaudRate, - ) -> io::Result<Self> { + pub fn new<P: ?Sized + nix::NixPath>(path: &P, baudrate: termios::BaudRate) -> io::Result<Self> { let fd = nix::fcntl::open( path, OFlag::O_RDWR | OFlag::O_NOCTTY | OFlag::O_NONBLOCK, diff --git a/examples/std/src/tuntap.rs b/examples/std/src/tuntap.rs index b70767a3..a0cace7f 100644 --- a/examples/std/src/tuntap.rs +++ b/examples/std/src/tuntap.rs @@ -1,9 +1,10 @@ -use async_io::Async; -use log::*; use std::io; use std::io::{Read, Write}; use std::os::unix::io::{AsRawFd, RawFd}; +use async_io::Async; +use log::*; + pub const SIOCGIFMTU: libc::c_ulong = 0x8921; pub const _SIOCGIFINDEX: libc::c_ulong = 0x8933; pub const _ETH_P_ALL: libc::c_short = 0x0003; @@ -32,11 +33,7 @@ fn ifreq_for(name: &str) -> ifreq { ifreq } -fn ifreq_ioctl( - lower: libc::c_int, - ifreq: &mut ifreq, - cmd: libc::c_ulong, -) -> io::Result<libc::c_int> { +fn ifreq_ioctl(lower: libc::c_int, ifreq: &mut ifreq, cmd: libc::c_ulong) -> io::Result<libc::c_int> { unsafe { let res = libc::ioctl(lower, cmd as _, ifreq as *mut ifreq); if res == -1 { @@ -141,11 +138,10 @@ impl TunTapDevice { } use core::task::Waker; -use embassy_net::{ - Device, DeviceCapabilities, LinkState, Packet, PacketBox, PacketBoxExt, PacketBuf, -}; use std::task::Context; +use embassy_net::{Device, DeviceCapabilities, LinkState, Packet, PacketBox, PacketBoxExt, PacketBuf}; + impl Device for TunTapDevice { fn is_transmit_ready(&mut self) -> bool { true diff --git a/examples/stm32f0/src/bin/hello.rs b/examples/stm32f0/src/bin/hello.rs index 975e94f3..225f1c3a 100644 --- a/examples/stm32f0/src/bin/hello.rs +++ b/examples/stm32f0/src/bin/hello.rs @@ -6,9 +6,7 @@ use defmt::info; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, _p: Peripherals) -> ! { diff --git a/examples/stm32f1/src/bin/adc.rs b/examples/stm32f1/src/bin/adc.rs index af403423..09904d4c 100644 --- a/examples/stm32f1/src/bin/adc.rs +++ b/examples/stm32f1/src/bin/adc.rs @@ -7,9 +7,7 @@ use embassy::executor::Spawner; use embassy::time::{Delay, Duration, Timer}; use embassy_stm32::adc::Adc; use embassy_stm32::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f1/src/bin/blinky.rs b/examples/stm32f1/src/bin/blinky.rs index 657bcdd1..c98d0cda 100644 --- a/examples/stm32f1/src/bin/blinky.rs +++ b/examples/stm32f1/src/bin/blinky.rs @@ -7,9 +7,7 @@ use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f1/src/bin/hello.rs b/examples/stm32f1/src/bin/hello.rs index 8054a899..82f11bc2 100644 --- a/examples/stm32f1/src/bin/hello.rs +++ b/examples/stm32f1/src/bin/hello.rs @@ -6,11 +6,8 @@ use defmt::info; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::time::Hertz; -use embassy_stm32::Config; -use embassy_stm32::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use embassy_stm32::{Config, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32f1/src/bin/usb_serial.rs b/examples/stm32f1/src/bin/usb_serial.rs index fe4aa4cc..d06315d7 100644 --- a/examples/stm32f1/src/bin/usb_serial.rs +++ b/examples/stm32f1/src/bin/usb_serial.rs @@ -2,24 +2,18 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt::panic; -use defmt::*; -use defmt_rtt as _; // global logger +use defmt::{panic, *}; use embassy::executor::Spawner; -use embassy::time::Duration; -use embassy::time::Timer; -use embassy_stm32::gpio::Level; -use embassy_stm32::gpio::Output; -use embassy_stm32::gpio::Speed; -use embassy_stm32::interrupt; +use embassy::time::{Duration, Timer}; +use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::time::Hertz; use embassy_stm32::usb::{Driver, Instance}; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::{interrupt, Config, Peripherals}; use embassy_usb::driver::EndpointError; use embassy_usb::Builder; use embassy_usb_serial::{CdcAcmClass, State}; use futures::future::join; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { let mut config = Config::default(); @@ -104,9 +98,7 @@ impl From<EndpointError> for Disconnected { } } -async fn echo<'d, T: Instance + 'd>( - class: &mut CdcAcmClass<'d, Driver<'d, T>>, -) -> Result<(), Disconnected> { +async fn echo<'d, T: Instance + 'd>(class: &mut CdcAcmClass<'d, Driver<'d, T>>) -> Result<(), Disconnected> { let mut buf = [0; 64]; loop { let n = class.read_packet(&mut buf).await?; diff --git a/examples/stm32f2/src/bin/blinky.rs b/examples/stm32f2/src/bin/blinky.rs index 395f4df5..dd20ba85 100644 --- a/examples/stm32f2/src/bin/blinky.rs +++ b/examples/stm32f2/src/bin/blinky.rs @@ -7,9 +7,7 @@ use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f2/src/bin/pll.rs b/examples/stm32f2/src/bin/pll.rs index 4bd74f0b..b09d64b0 100644 --- a/examples/stm32f2/src/bin/pll.rs +++ b/examples/stm32f2/src/bin/pll.rs @@ -3,20 +3,16 @@ #![feature(type_alias_impl_trait)] use core::convert::TryFrom; + use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; -use embassy_stm32::{ - rcc::{ - APBPrescaler, ClockSrc, HSEConfig, HSESrc, PLL48Div, PLLConfig, PLLMainDiv, PLLMul, - PLLPreDiv, PLLSrc, - }, - time::Hertz, - Config, Peripherals, +use embassy_stm32::rcc::{ + APBPrescaler, ClockSrc, HSEConfig, HSESrc, PLL48Div, PLLConfig, PLLMainDiv, PLLMul, PLLPreDiv, PLLSrc, }; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use embassy_stm32::time::Hertz; +use embassy_stm32::{Config, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; // Example config for maximum performance on a NUCLEO-F207ZG board fn config() -> Config { diff --git a/examples/stm32f3/src/bin/blinky.rs b/examples/stm32f3/src/bin/blinky.rs index 4b181a78..4d0b33f6 100644 --- a/examples/stm32f3/src/bin/blinky.rs +++ b/examples/stm32f3/src/bin/blinky.rs @@ -7,9 +7,7 @@ use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f3/src/bin/button.rs b/examples/stm32f3/src/bin/button.rs index 207381bd..b55bf390 100644 --- a/examples/stm32f3/src/bin/button.rs +++ b/examples/stm32f3/src/bin/button.rs @@ -4,9 +4,8 @@ use cortex_m_rt::entry; use defmt::*; -use defmt_rtt as _; // global logger use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[entry] fn main() -> ! { diff --git a/examples/stm32f3/src/bin/button_events.rs b/examples/stm32f3/src/bin/button_events.rs index 59370179..45862ddc 100644 --- a/examples/stm32f3/src/bin/button_events.rs +++ b/examples/stm32f3/src/bin/button_events.rs @@ -19,9 +19,7 @@ use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; use embassy_stm32::peripherals::PA0; use embassy_stm32::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; struct Leds<'a> { leds: [Output<'a, AnyPin>; 8], @@ -57,8 +55,7 @@ impl<'a> Leds<'a> { self.process_event(new_message).await; } else { self.leds[self.current_led].set_low(); - if let Ok(new_message) = with_timeout(Duration::from_millis(200), CHANNEL.recv()).await - { + if let Ok(new_message) = with_timeout(Duration::from_millis(200), CHANNEL.recv()).await { self.process_event(new_message).await; } } @@ -137,22 +134,16 @@ async fn button_waiter(mut button: ExtiInput<'static, PA0>) { button.wait_for_rising_edge().await; loop { - if with_timeout( - Duration::from_millis(HOLD_DELAY), - button.wait_for_falling_edge(), - ) - .await - .is_err() + if with_timeout(Duration::from_millis(HOLD_DELAY), button.wait_for_falling_edge()) + .await + .is_err() { info!("Hold"); CHANNEL.send(ButtonEvent::Hold).await; button.wait_for_falling_edge().await; - } else if with_timeout( - Duration::from_millis(DOUBLE_CLICK_DELAY), - button.wait_for_rising_edge(), - ) - .await - .is_err() + } else if with_timeout(Duration::from_millis(DOUBLE_CLICK_DELAY), button.wait_for_rising_edge()) + .await + .is_err() { info!("Single click"); CHANNEL.send(ButtonEvent::SingleClick).await; diff --git a/examples/stm32f3/src/bin/button_exti.rs b/examples/stm32f3/src/bin/button_exti.rs index 68d16636..add6712b 100644 --- a/examples/stm32f3/src/bin/button_exti.rs +++ b/examples/stm32f3/src/bin/button_exti.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f3/src/bin/flash.rs b/examples/stm32f3/src/bin/flash.rs index 3890f051..ce16f6de 100644 --- a/examples/stm32f3/src/bin/flash.rs +++ b/examples/stm32f3/src/bin/flash.rs @@ -7,9 +7,7 @@ use embassy::executor::Spawner; use embassy_stm32::flash::Flash; use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f3/src/bin/hello.rs b/examples/stm32f3/src/bin/hello.rs index a79d6838..3b89f1c7 100644 --- a/examples/stm32f3/src/bin/hello.rs +++ b/examples/stm32f3/src/bin/hello.rs @@ -6,11 +6,8 @@ use defmt::info; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::time::Hertz; -use embassy_stm32::Config; -use embassy_stm32::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use embassy_stm32::{Config, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32f3/src/bin/multiprio.rs b/examples/stm32f3/src/bin/multiprio.rs index 68429560..4f2cf9a6 100644 --- a/examples/stm32f3/src/bin/multiprio.rs +++ b/examples/stm32f3/src/bin/multiprio.rs @@ -57,16 +57,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt::*; -use defmt_rtt as _; // global logger -use panic_probe as _; - use cortex_m_rt::entry; +use defmt::*; use embassy::time::{Duration, Instant, Timer}; use embassy::util::Forever; use embassy_stm32::executor::{Executor, InterruptExecutor}; use embassy_stm32::interrupt; use embassy_stm32::interrupt::InterruptExt; +use {defmt_rtt as _, panic_probe as _}; #[embassy::task] async fn run_high() { diff --git a/examples/stm32f3/src/bin/spi_dma.rs b/examples/stm32f3/src/bin/spi_dma.rs index 6d80c408..ece1ae6f 100644 --- a/examples/stm32f3/src/bin/spi_dma.rs +++ b/examples/stm32f3/src/bin/spi_dma.rs @@ -4,14 +4,14 @@ use core::fmt::Write; use core::str::from_utf8; + use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; use heapless::String; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { @@ -32,9 +32,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { let mut write: String<128> = String::new(); let mut read = [0; 128]; core::write!(&mut write, "Hello DMA World {}!\r\n", n).unwrap(); - spi.transfer(&mut read[0..write.len()], write.as_bytes()) - .await - .ok(); + spi.transfer(&mut read[0..write.len()], write.as_bytes()).await.ok(); info!("read via spi+dma: {}", from_utf8(&read).unwrap()); } } diff --git a/examples/stm32f3/src/bin/usart_dma.rs b/examples/stm32f3/src/bin/usart_dma.rs index 859749eb..4660f812 100644 --- a/examples/stm32f3/src/bin/usart_dma.rs +++ b/examples/stm32f3/src/bin/usart_dma.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use core::fmt::Write; + use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; use heapless::String; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f3/src/bin/usb_serial.rs b/examples/stm32f3/src/bin/usb_serial.rs index fc33d0bc..8a76d454 100644 --- a/examples/stm32f3/src/bin/usb_serial.rs +++ b/examples/stm32f3/src/bin/usb_serial.rs @@ -2,24 +2,18 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt::panic; -use defmt::*; -use defmt_rtt as _; // global logger +use defmt::{panic, *}; use embassy::executor::Spawner; -use embassy::time::Duration; -use embassy::time::Timer; -use embassy_stm32::gpio::Level; -use embassy_stm32::gpio::Output; -use embassy_stm32::gpio::Speed; -use embassy_stm32::interrupt; +use embassy::time::{Duration, Timer}; +use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::time::U32Ext; use embassy_stm32::usb::{Driver, Instance}; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::{interrupt, Config, Peripherals}; use embassy_usb::driver::EndpointError; use embassy_usb::Builder; use embassy_usb_serial::{CdcAcmClass, State}; use futures::future::join; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { let mut config = Config::default(); @@ -103,9 +97,7 @@ impl From<EndpointError> for Disconnected { } } -async fn echo<'d, T: Instance + 'd>( - class: &mut CdcAcmClass<'d, Driver<'d, T>>, -) -> Result<(), Disconnected> { +async fn echo<'d, T: Instance + 'd>(class: &mut CdcAcmClass<'d, Driver<'d, T>>) -> Result<(), Disconnected> { let mut buf = [0; 64]; loop { let n = class.read_packet(&mut buf).await?; diff --git a/examples/stm32f4/src/bin/adc.rs b/examples/stm32f4/src/bin/adc.rs index f0b1ad23..84ddbfd3 100644 --- a/examples/stm32f4/src/bin/adc.rs +++ b/examples/stm32f4/src/bin/adc.rs @@ -2,14 +2,12 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::executor::Spawner; use embassy::time::{Delay, Duration, Timer}; use embassy_stm32::adc::Adc; use embassy_stm32::Peripherals; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f4/src/bin/blinky.rs b/examples/stm32f4/src/bin/blinky.rs index 8b85ca96..907492b3 100644 --- a/examples/stm32f4/src/bin/blinky.rs +++ b/examples/stm32f4/src/bin/blinky.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f4/src/bin/button.rs b/examples/stm32f4/src/bin/button.rs index 4f9af7fb..b13e6453 100644 --- a/examples/stm32f4/src/bin/button.rs +++ b/examples/stm32f4/src/bin/button.rs @@ -4,9 +4,8 @@ use cortex_m_rt::entry; use defmt::*; -use defmt_rtt as _; // global logger use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[entry] fn main() -> ! { diff --git a/examples/stm32f4/src/bin/button_exti.rs b/examples/stm32f4/src/bin/button_exti.rs index 78f2e6ee..24ece992 100644 --- a/examples/stm32f4/src/bin/button_exti.rs +++ b/examples/stm32f4/src/bin/button_exti.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f4/src/bin/can.rs b/examples/stm32f4/src/bin/can.rs index 0f41d686..8abce87a 100644 --- a/examples/stm32f4/src/bin/can.rs +++ b/examples/stm32f4/src/bin/can.rs @@ -2,15 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use cortex_m_rt::entry; use defmt::*; use embassy_stm32::can::bxcan::filter::Mask32; use embassy_stm32::can::bxcan::{Frame, StandardId}; use embassy_stm32::can::Can; use embassy_stm32::gpio::{Input, Pull}; +use {defmt_rtt as _, panic_probe as _}; #[entry] fn main() -> ! { diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs index 92d87ced..8e69e89d 100644 --- a/examples/stm32f4/src/bin/hello.rs +++ b/examples/stm32f4/src/bin/hello.rs @@ -6,11 +6,8 @@ use defmt::info; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::time::Hertz; -use embassy_stm32::Config; -use embassy_stm32::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use embassy_stm32::{Config, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32f4/src/bin/multiprio.rs b/examples/stm32f4/src/bin/multiprio.rs index 68429560..4f2cf9a6 100644 --- a/examples/stm32f4/src/bin/multiprio.rs +++ b/examples/stm32f4/src/bin/multiprio.rs @@ -57,16 +57,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt::*; -use defmt_rtt as _; // global logger -use panic_probe as _; - use cortex_m_rt::entry; +use defmt::*; use embassy::time::{Duration, Instant, Timer}; use embassy::util::Forever; use embassy_stm32::executor::{Executor, InterruptExecutor}; use embassy_stm32::interrupt; use embassy_stm32::interrupt::InterruptExt; +use {defmt_rtt as _, panic_probe as _}; #[embassy::task] async fn run_high() { diff --git a/examples/stm32f4/src/bin/sdmmc.rs b/examples/stm32f4/src/bin/sdmmc.rs index eab0fad4..b08d26f4 100644 --- a/examples/stm32f4/src/bin/sdmmc.rs +++ b/examples/stm32f4/src/bin/sdmmc.rs @@ -2,14 +2,12 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::U32Ext; use embassy_stm32::{interrupt, Config, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32f4/src/bin/spi.rs b/examples/stm32f4/src/bin/spi.rs index 69be8143..05b48f47 100644 --- a/examples/stm32f4/src/bin/spi.rs +++ b/examples/stm32f4/src/bin/spi.rs @@ -2,15 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use cortex_m_rt::entry; use defmt::*; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; +use {defmt_rtt as _, panic_probe as _}; #[entry] fn main() -> ! { diff --git a/examples/stm32f4/src/bin/spi_dma.rs b/examples/stm32f4/src/bin/spi_dma.rs index 1bf9b856..f3c0f2cd 100644 --- a/examples/stm32f4/src/bin/spi_dma.rs +++ b/examples/stm32f4/src/bin/spi_dma.rs @@ -4,14 +4,14 @@ use core::fmt::Write; use core::str::from_utf8; + use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; use heapless::String; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { @@ -32,9 +32,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { let mut write: String<128> = String::new(); let mut read = [0; 128]; core::write!(&mut write, "Hello DMA World {}!\r\n", n).unwrap(); - spi.transfer(&mut read[0..write.len()], write.as_bytes()) - .await - .ok(); + spi.transfer(&mut read[0..write.len()], write.as_bytes()).await.ok(); info!("read via spi+dma: {}", from_utf8(&read).unwrap()); } } diff --git a/examples/stm32f4/src/bin/usart.rs b/examples/stm32f4/src/bin/usart.rs index a302667e..90ad882b 100644 --- a/examples/stm32f4/src/bin/usart.rs +++ b/examples/stm32f4/src/bin/usart.rs @@ -4,10 +4,9 @@ use cortex_m_rt::entry; use defmt::*; -use defmt_rtt as _; // global logger use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[entry] fn main() -> ! { diff --git a/examples/stm32f4/src/bin/usart_buffered.rs b/examples/stm32f4/src/bin/usart_buffered.rs index 2a613ee4..039e43bd 100644 --- a/examples/stm32f4/src/bin/usart_buffered.rs +++ b/examples/stm32f4/src/bin/usart_buffered.rs @@ -3,13 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; use embassy_stm32::{interrupt, Peripherals}; use embedded_io::asynch::BufRead; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f4/src/bin/usart_dma.rs b/examples/stm32f4/src/bin/usart_dma.rs index cf45b71c..8d06f843 100644 --- a/examples/stm32f4/src/bin/usart_dma.rs +++ b/examples/stm32f4/src/bin/usart_dma.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use core::fmt::Write; + use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; use heapless::String; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f7/build.rs b/examples/stm32f7/build.rs index b72dd55e..c4e15f19 100644 --- a/examples/stm32f7/build.rs +++ b/examples/stm32f7/build.rs @@ -1,7 +1,8 @@ //! adapted from https://github.com/stm32-rs/stm32f7xx-hal/blob/master/build.rs use std::env; use std::fs::File; -use std::io::{self, prelude::*}; +use std::io::prelude::*; +use std::io::{self}; use std::path::PathBuf; #[derive(Debug)] diff --git a/examples/stm32f7/src/bin/adc.rs b/examples/stm32f7/src/bin/adc.rs index 87f5d30d..fc835962 100644 --- a/examples/stm32f7/src/bin/adc.rs +++ b/examples/stm32f7/src/bin/adc.rs @@ -2,14 +2,12 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::executor::Spawner; use embassy::time::{Delay, Duration, Timer}; use embassy_stm32::adc::Adc; use embassy_stm32::Peripherals; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f7/src/bin/blinky.rs b/examples/stm32f7/src/bin/blinky.rs index 8b85ca96..907492b3 100644 --- a/examples/stm32f7/src/bin/blinky.rs +++ b/examples/stm32f7/src/bin/blinky.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f7/src/bin/button.rs b/examples/stm32f7/src/bin/button.rs index 4f9af7fb..b13e6453 100644 --- a/examples/stm32f7/src/bin/button.rs +++ b/examples/stm32f7/src/bin/button.rs @@ -4,9 +4,8 @@ use cortex_m_rt::entry; use defmt::*; -use defmt_rtt as _; // global logger use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[entry] fn main() -> ! { diff --git a/examples/stm32f7/src/bin/button_exti.rs b/examples/stm32f7/src/bin/button_exti.rs index 78f2e6ee..24ece992 100644 --- a/examples/stm32f7/src/bin/button_exti.rs +++ b/examples/stm32f7/src/bin/button_exti.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index af012f82..dc0b3c60 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs @@ -13,13 +13,10 @@ use embassy_stm32::eth::{Ethernet, State}; use embassy_stm32::peripherals::ETH; use embassy_stm32::rng::Rng; use embassy_stm32::time::U32Ext; -use embassy_stm32::Config; -use embassy_stm32::{interrupt, Peripherals}; +use embassy_stm32::{interrupt, Config, Peripherals}; use embedded_io::asynch::Write; - -use defmt_rtt as _; // global logger -use panic_probe as _; use rand_core::RngCore; +use {defmt_rtt as _, panic_probe as _}; macro_rules! forever { ($val:expr) => {{ diff --git a/examples/stm32f7/src/bin/flash.rs b/examples/stm32f7/src/bin/flash.rs index 9eb8e4b9..af66275d 100644 --- a/examples/stm32f7/src/bin/flash.rs +++ b/examples/stm32f7/src/bin/flash.rs @@ -8,9 +8,7 @@ use embassy::time::{Duration, Timer}; use embassy_stm32::flash::Flash; use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { @@ -40,8 +38,8 @@ async fn main(_spawner: Spawner, p: Peripherals) { unwrap!(f.write( ADDR, &[ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32 + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32 ] )); @@ -52,8 +50,8 @@ async fn main(_spawner: Spawner, p: Peripherals) { assert_eq!( &buf[..], &[ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32 + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32 ] ); } diff --git a/examples/stm32f7/src/bin/hello.rs b/examples/stm32f7/src/bin/hello.rs index 92d87ced..8e69e89d 100644 --- a/examples/stm32f7/src/bin/hello.rs +++ b/examples/stm32f7/src/bin/hello.rs @@ -6,11 +6,8 @@ use defmt::info; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::time::Hertz; -use embassy_stm32::Config; -use embassy_stm32::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use embassy_stm32::{Config, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32f7/src/bin/sdmmc.rs b/examples/stm32f7/src/bin/sdmmc.rs index dae07c30..1af1061b 100644 --- a/examples/stm32f7/src/bin/sdmmc.rs +++ b/examples/stm32f7/src/bin/sdmmc.rs @@ -2,14 +2,12 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::U32Ext; use embassy_stm32::{interrupt, Config, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32f7/src/bin/usart_dma.rs b/examples/stm32f7/src/bin/usart_dma.rs index 69fa21a0..d8551620 100644 --- a/examples/stm32f7/src/bin/usart_dma.rs +++ b/examples/stm32f7/src/bin/usart_dma.rs @@ -3,15 +3,14 @@ #![feature(type_alias_impl_trait)] use core::fmt::Write; + use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; -use panic_probe as _; - use heapless::String; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32g0/src/bin/blinky.rs b/examples/stm32g0/src/bin/blinky.rs index 8b85ca96..907492b3 100644 --- a/examples/stm32g0/src/bin/blinky.rs +++ b/examples/stm32g0/src/bin/blinky.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32g0/src/bin/button.rs b/examples/stm32g0/src/bin/button.rs index 78d7ba1f..72a3f5cb 100644 --- a/examples/stm32g0/src/bin/button.rs +++ b/examples/stm32g0/src/bin/button.rs @@ -4,9 +4,8 @@ use cortex_m_rt::entry; use defmt::*; -use defmt_rtt as _; // global logger use embassy_stm32::gpio::{Input, Pull}; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[entry] fn main() -> ! { diff --git a/examples/stm32g0/src/bin/button_exti.rs b/examples/stm32g0/src/bin/button_exti.rs index 4b1cadcb..924feeb3 100644 --- a/examples/stm32g0/src/bin/button_exti.rs +++ b/examples/stm32g0/src/bin/button_exti.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32g4/src/bin/blinky.rs b/examples/stm32g4/src/bin/blinky.rs index 92ec2b57..cd488327 100644 --- a/examples/stm32g4/src/bin/blinky.rs +++ b/examples/stm32g4/src/bin/blinky.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32g4/src/bin/button.rs b/examples/stm32g4/src/bin/button.rs index f6c98130..15abd86d 100644 --- a/examples/stm32g4/src/bin/button.rs +++ b/examples/stm32g4/src/bin/button.rs @@ -4,9 +4,8 @@ use cortex_m_rt::entry; use defmt::*; -use defmt_rtt as _; // global logger use embassy_stm32::gpio::{Input, Pull}; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[entry] fn main() -> ! { diff --git a/examples/stm32g4/src/bin/button_exti.rs b/examples/stm32g4/src/bin/button_exti.rs index 78f2e6ee..24ece992 100644 --- a/examples/stm32g4/src/bin/button_exti.rs +++ b/examples/stm32g4/src/bin/button_exti.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32g4/src/bin/pwm.rs b/examples/stm32g4/src/bin/pwm.rs index 3770f6f3..525b6001 100644 --- a/examples/stm32g4/src/bin/pwm.rs +++ b/examples/stm32g4/src/bin/pwm.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; -use embassy_stm32::pwm::{simple_pwm::SimplePwm, Channel}; +use embassy_stm32::pwm::simple_pwm::SimplePwm; +use embassy_stm32::pwm::Channel; use embassy_stm32::time::U32Ext; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs index b12bca30..e2439074 100644 --- a/examples/stm32h7/src/bin/adc.rs +++ b/examples/stm32h7/src/bin/adc.rs @@ -2,16 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] +use defmt::*; use embassy::executor::Spawner; use embassy::time::{Delay, Duration, Timer}; use embassy_stm32::adc::{Adc, SampleTime}; use embassy_stm32::rcc::AdcClockSource; use embassy_stm32::time::U32Ext; use embassy_stm32::{Config, Peripherals}; - -use defmt::*; -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32h7/src/bin/blinky.rs b/examples/stm32h7/src/bin/blinky.rs index 2329125a..7982f4a0 100644 --- a/examples/stm32h7/src/bin/blinky.rs +++ b/examples/stm32h7/src/bin/blinky.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32h7/src/bin/button_exti.rs b/examples/stm32h7/src/bin/button_exti.rs index 78f2e6ee..24ece992 100644 --- a/examples/stm32h7/src/bin/button_exti.rs +++ b/examples/stm32h7/src/bin/button_exti.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32h7/src/bin/camera.rs b/examples/stm32h7/src/bin/camera.rs index 3311ba85..918eab65 100644 --- a/examples/stm32h7/src/bin/camera.rs +++ b/examples/stm32h7/src/bin/camera.rs @@ -7,14 +7,10 @@ use embassy::time::{Duration, Timer}; use embassy_stm32::dcmi::{self, *}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::i2c::I2c; -use embassy_stm32::interrupt; use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; use embassy_stm32::time::U32Ext; -use embassy_stm32::Config; -use embassy_stm32::Peripherals; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use embassy_stm32::{interrupt, Config, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; #[allow(unused)] pub fn config() -> Config { @@ -43,15 +39,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { let mut led = Output::new(p.PE3, Level::High, Speed::Low); let i2c_irq = interrupt::take!(I2C1_EV); - let cam_i2c = I2c::new( - p.I2C1, - p.PB8, - p.PB9, - i2c_irq, - p.DMA1_CH1, - p.DMA1_CH2, - 100u32.khz(), - ); + let cam_i2c = I2c::new(p.I2C1, p.PB8, p.PB9, i2c_irq, p.DMA1_CH1, p.DMA1_CH2, 100u32.khz()); let mut camera = Ov7725::new(cam_i2c, mco); @@ -60,17 +48,13 @@ async fn main(_spawner: Spawner, p: Peripherals) { let manufacturer_id = defmt::unwrap!(camera.read_manufacturer_id().await); let camera_id = defmt::unwrap!(camera.read_product_id().await); - defmt::info!( - "manufacturer: 0x{:x}, pid: 0x{:x}", - manufacturer_id, - camera_id - ); + defmt::info!("manufacturer: 0x{:x}, pid: 0x{:x}", manufacturer_id, camera_id); let dcmi_irq = interrupt::take!(DCMI); let config = dcmi::Config::default(); let mut dcmi = Dcmi::new_8bit( - p.DCMI, p.DMA1_CH0, dcmi_irq, p.PC6, p.PC7, p.PE0, p.PE1, p.PE4, p.PD3, p.PE5, p.PE6, - p.PB7, p.PA4, p.PA6, config, + p.DCMI, p.DMA1_CH0, dcmi_irq, p.PC6, p.PC7, p.PE0, p.PE1, p.PE4, p.PD3, p.PE5, p.PE6, p.PB7, p.PA4, p.PA6, + config, ); defmt::info!("attempting capture"); @@ -258,10 +242,8 @@ mod ov7725 { let com3 = self.read(Register::Com3).await?; let vflip = com3 & 0x80 > 0; - self.modify(Register::HRef, |reg| { - reg & 0xbf | if vflip { 0x40 } else { 0x40 } - }) - .await?; + self.modify(Register::HRef, |reg| reg & 0xbf | if vflip { 0x40 } else { 0x40 }) + .await?; if horizontal <= 320 || vertical <= 240 { self.write(Register::HStart, 0x3f).await?; @@ -291,11 +273,7 @@ mod ov7725 { .map_err(Error::I2c) } - async fn modify<F: FnOnce(u8) -> u8>( - &mut self, - register: Register, - f: F, - ) -> Result<(), Error<Bus::Error>> { + async fn modify<F: FnOnce(u8) -> u8>(&mut self, register: Register, f: F) -> Result<(), Error<Bus::Error>> { let value = self.read(register).await?; let value = f(value); self.write(register, value).await diff --git a/examples/stm32h7/src/bin/dac.rs b/examples/stm32h7/src/bin/dac.rs index 86c874a6..8ed33350 100644 --- a/examples/stm32h7/src/bin/dac.rs +++ b/examples/stm32h7/src/bin/dac.rs @@ -2,14 +2,12 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use cortex_m_rt::entry; use defmt::*; use embassy_stm32::dac::{Channel, Dac, Value}; use embassy_stm32::time::U32Ext; use embassy_stm32::Config; +use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 649ff260..6dabadc4 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs @@ -13,13 +13,10 @@ use embassy_stm32::eth::{Ethernet, State}; use embassy_stm32::peripherals::ETH; use embassy_stm32::rng::Rng; use embassy_stm32::time::U32Ext; -use embassy_stm32::Config; -use embassy_stm32::{interrupt, Peripherals}; +use embassy_stm32::{interrupt, Config, Peripherals}; use embedded_io::asynch::Write; - -use defmt_rtt as _; // global logger -use panic_probe as _; use rand_core::RngCore; +use {defmt_rtt as _, panic_probe as _}; macro_rules! forever { ($val:expr) => {{ diff --git a/examples/stm32h7/src/bin/flash.rs b/examples/stm32h7/src/bin/flash.rs index b008c088..5f97d2b3 100644 --- a/examples/stm32h7/src/bin/flash.rs +++ b/examples/stm32h7/src/bin/flash.rs @@ -3,13 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::{info, unwrap}; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::flash::Flash; use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { @@ -39,8 +38,8 @@ async fn main(_spawner: Spawner, p: Peripherals) { unwrap!(f.write( ADDR, &[ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32 + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32 ] )); @@ -51,8 +50,8 @@ async fn main(_spawner: Spawner, p: Peripherals) { assert_eq!( &buf[..], &[ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32 + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32 ] ); } diff --git a/examples/stm32h7/src/bin/fmc.rs b/examples/stm32h7/src/bin/fmc.rs index ba8215d6..2f55479c 100644 --- a/examples/stm32h7/src/bin/fmc.rs +++ b/examples/stm32h7/src/bin/fmc.rs @@ -3,14 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy::time::{Delay, Duration, Timer}; use embassy_stm32::fmc::Fmc; use embassy_stm32::time::U32Ext; -use embassy_stm32::Config; -use embassy_stm32::Peripherals; -use panic_probe as _; +use embassy_stm32::{Config, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { let mut config = Config::default(); @@ -62,16 +60,8 @@ async fn main(_spawner: Spawner, p: Peripherals) { const REGION_WRITE_BACK: u32 = 0x01; const REGION_ENABLE: u32 = 0x01; - crate::assert_eq!( - size & (size - 1), - 0, - "SDRAM memory region size must be a power of 2" - ); - crate::assert_eq!( - size & 0x1F, - 0, - "SDRAM memory region size must be 32 bytes or more" - ); + crate::assert_eq!(size & (size - 1), 0, "SDRAM memory region size must be a power of 2"); + crate::assert_eq!(size & 0x1F, 0, "SDRAM memory region size must be 32 bytes or more"); fn log2minus1(sz: u32) -> u32 { for i in 5..=31 { if sz == (1 << i) { @@ -104,8 +94,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { // Enable unsafe { - mpu.ctrl - .modify(|r| r | MPU_DEFAULT_MMAP_FOR_PRIVILEGED | MPU_ENABLE); + mpu.ctrl.modify(|r| r | MPU_DEFAULT_MMAP_FOR_PRIVILEGED | MPU_ENABLE); scb.shcsr.modify(|r| r | MEMFAULTENA); diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index 647c5a8f..3a728a0d 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs @@ -3,8 +3,6 @@ #![feature(type_alias_impl_trait)] use core::marker::PhantomData; -use defmt_rtt as _; // global logger -use panic_probe as _; use defmt::*; use embassy::executor::Spawner; @@ -13,9 +11,8 @@ use embassy_stm32::gpio::low_level::AFType; use embassy_stm32::gpio::Speed; use embassy_stm32::pwm::*; use embassy_stm32::time::{Hertz, U32Ext}; -use embassy_stm32::unborrow; -use embassy_stm32::Unborrow; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::{unborrow, Config, Peripherals, Unborrow}; +use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { let mut config = Config::default(); @@ -108,25 +105,18 @@ impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> { pub fn enable(&mut self, channel: Channel) { unsafe { - T::regs_gp32() - .ccer() - .modify(|w| w.set_cce(channel.raw(), true)); + T::regs_gp32().ccer().modify(|w| w.set_cce(channel.raw(), true)); } } pub fn disable(&mut self, channel: Channel) { unsafe { - T::regs_gp32() - .ccer() - .modify(|w| w.set_cce(channel.raw(), false)); + T::regs_gp32().ccer().modify(|w| w.set_cce(channel.raw(), false)); } } pub fn set_freq<F: Into<Hertz>>(&mut self, freq: F) { - <T as embassy_stm32::timer::low_level::GeneralPurpose32bitInstance>::set_frequency( - &mut self.inner, - freq, - ); + <T as embassy_stm32::timer::low_level::GeneralPurpose32bitInstance>::set_frequency(&mut self.inner, freq); } pub fn get_max_duty(&self) -> u32 { @@ -135,10 +125,6 @@ impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> { pub fn set_duty(&mut self, channel: Channel, duty: u32) { defmt::assert!(duty < self.get_max_duty()); - unsafe { - T::regs_gp32() - .ccr(channel.raw()) - .modify(|w| w.set_ccr(duty)) - } + unsafe { T::regs_gp32().ccr(channel.raw()).modify(|w| w.set_ccr(duty)) } } } diff --git a/examples/stm32h7/src/bin/mco.rs b/examples/stm32h7/src/bin/mco.rs index a6735036..6f03b547 100644 --- a/examples/stm32h7/src/bin/mco.rs +++ b/examples/stm32h7/src/bin/mco.rs @@ -3,13 +3,12 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs index c33ba066..0e85b8d8 100644 --- a/examples/stm32h7/src/bin/pwm.rs +++ b/examples/stm32h7/src/bin/pwm.rs @@ -3,13 +3,13 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; -use embassy_stm32::pwm::{simple_pwm::SimplePwm, Channel}; +use embassy_stm32::pwm::simple_pwm::SimplePwm; +use embassy_stm32::pwm::Channel; use embassy_stm32::time::U32Ext; use embassy_stm32::{Config, Peripherals}; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32h7/src/bin/rng.rs b/examples/stm32h7/src/bin/rng.rs index b914fa70..2b42a6af 100644 --- a/examples/stm32h7/src/bin/rng.rs +++ b/examples/stm32h7/src/bin/rng.rs @@ -3,11 +3,10 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::rng::Rng; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32h7/src/bin/sdmmc.rs b/examples/stm32h7/src/bin/sdmmc.rs index c3b2ebcd..4a74780f 100644 --- a/examples/stm32h7/src/bin/sdmmc.rs +++ b/examples/stm32h7/src/bin/sdmmc.rs @@ -2,14 +2,12 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::executor::Spawner; use embassy_stm32::sdmmc::Sdmmc; use embassy_stm32::time::U32Ext; use embassy_stm32::{interrupt, Config, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32h7/src/bin/signal.rs b/examples/stm32h7/src/bin/signal.rs index c63b2836..f798b1c9 100644 --- a/examples/stm32h7/src/bin/signal.rs +++ b/examples/stm32h7/src/bin/signal.rs @@ -2,17 +2,12 @@ #![no_main] #![feature(type_alias_impl_trait)] -// global logger use defmt::{info, unwrap}; -use defmt_rtt as _; - -use panic_probe as _; - use embassy::channel::signal::Signal; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; - use embassy_stm32::Peripherals; +use {defmt_rtt as _, panic_probe as _}; static SIGNAL: Signal<u32> = Signal::new(); diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index a0acb03d..d4ee4429 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs @@ -2,21 +2,19 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use core::fmt::Write; use core::str::from_utf8; + use cortex_m_rt::entry; use defmt::*; use embassy::executor::Executor; use embassy::util::Forever; use embassy_stm32::dma::NoDma; use embassy_stm32::peripherals::SPI3; -use embassy_stm32::spi; use embassy_stm32::time::U32Ext; -use embassy_stm32::Config; +use embassy_stm32::{spi, Config}; use heapless::String; +use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index 8f77b1d0..003bc7ad 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs @@ -2,20 +2,18 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use core::fmt::Write; use core::str::from_utf8; + use cortex_m_rt::entry; use defmt::*; use embassy::executor::Executor; use embassy::util::Forever; use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; -use embassy_stm32::spi; use embassy_stm32::time::U32Ext; -use embassy_stm32::Config; +use embassy_stm32::{spi, Config}; use heapless::String; +use {defmt_rtt as _, panic_probe as _}; pub fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32h7/src/bin/usart.rs b/examples/stm32h7/src/bin/usart.rs index 0982a6ac..fc3db5a3 100644 --- a/examples/stm32h7/src/bin/usart.rs +++ b/examples/stm32h7/src/bin/usart.rs @@ -2,15 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] +use cortex_m_rt::entry; use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Executor; use embassy::util::Forever; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use panic_probe as _; - -use cortex_m_rt::entry; +use {defmt_rtt as _, panic_probe as _}; #[embassy::task] async fn main_task() { diff --git a/examples/stm32h7/src/bin/usart_dma.rs b/examples/stm32h7/src/bin/usart_dma.rs index 74de8b2a..d3325b0c 100644 --- a/examples/stm32h7/src/bin/usart_dma.rs +++ b/examples/stm32h7/src/bin/usart_dma.rs @@ -3,16 +3,15 @@ #![feature(type_alias_impl_trait)] use core::fmt::Write; + +use cortex_m_rt::entry; use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Executor; use embassy::util::Forever; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; -use panic_probe as _; - -use cortex_m_rt::entry; use heapless::String; +use {defmt_rtt as _, panic_probe as _}; #[embassy::task] async fn main_task() { diff --git a/examples/stm32h7/src/bin/usart_split.rs b/examples/stm32h7/src/bin/usart_split.rs index eb3f9578..678d8c91 100644 --- a/examples/stm32h7/src/bin/usart_split.rs +++ b/examples/stm32h7/src/bin/usart_split.rs @@ -3,17 +3,14 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::blocking_mutex::raw::ThreadModeRawMutex; use embassy::channel::mpmc::Channel; use embassy::executor::Spawner; use embassy_stm32::dma::NoDma; -use embassy_stm32::{ - peripherals::{DMA1_CH1, UART7}, - usart::{Config, Uart, UartRx}, - Peripherals, -}; -use panic_probe as _; +use embassy_stm32::peripherals::{DMA1_CH1, UART7}; +use embassy_stm32::usart::{Config, Uart, UartRx}; +use embassy_stm32::Peripherals; +use {defmt_rtt as _, panic_probe as _}; #[embassy::task] async fn writer(mut usart: Uart<'static, UART7, NoDma, NoDma>) { diff --git a/examples/stm32l0/src/bin/blinky.rs b/examples/stm32l0/src/bin/blinky.rs index 72f13f06..e027192b 100644 --- a/examples/stm32l0/src/bin/blinky.rs +++ b/examples/stm32l0/src/bin/blinky.rs @@ -2,14 +2,12 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l0/src/bin/button.rs b/examples/stm32l0/src/bin/button.rs index dfa91259..43ea8c2a 100644 --- a/examples/stm32l0/src/bin/button.rs +++ b/examples/stm32l0/src/bin/button.rs @@ -3,11 +3,10 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l0/src/bin/button_exti.rs b/examples/stm32l0/src/bin/button_exti.rs index b1892e2c..d87870a0 100644 --- a/examples/stm32l0/src/bin/button_exti.rs +++ b/examples/stm32l0/src/bin/button_exti.rs @@ -2,14 +2,12 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; +use {defmt_rtt as _, panic_probe as _}; fn config() -> embassy_stm32::Config { let mut config = embassy_stm32::Config::default(); diff --git a/examples/stm32l0/src/bin/flash.rs b/examples/stm32l0/src/bin/flash.rs index c2ccb5b6..a2fec929 100644 --- a/examples/stm32l0/src/bin/flash.rs +++ b/examples/stm32l0/src/bin/flash.rs @@ -7,9 +7,7 @@ use embassy::executor::Spawner; use embassy_stm32::flash::Flash; use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l0/src/bin/lorawan.rs b/examples/stm32l0/src/bin/lorawan.rs index c3b97de5..8b7e8f82 100644 --- a/examples/stm32l0/src/bin/lorawan.rs +++ b/examples/stm32l0/src/bin/lorawan.rs @@ -6,20 +6,16 @@ #![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - -use embassy_lora::{sx127x::*, LoraTimer}; -use embassy_stm32::{ - exti::ExtiInput, - gpio::{Input, Level, Output, Pull, Speed}, - rng::Rng, - spi, - time::U32Ext, - Peripherals, -}; +use embassy_lora::sx127x::*; +use embassy_lora::LoraTimer; +use embassy_stm32::exti::ExtiInput; +use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use embassy_stm32::rng::Rng; +use embassy_stm32::time::U32Ext; +use embassy_stm32::{spi, Peripherals}; use lorawan::default_crypto::DefaultFactory as Crypto; use lorawan_device::async_device::{region, Device, JoinMode}; +use {defmt_rtt as _, panic_probe as _}; fn config() -> embassy_stm32::Config { let mut config = embassy_stm32::Config::default(); @@ -49,13 +45,10 @@ async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { let ready = Input::new(p.PB4, Pull::Up); let ready_pin = ExtiInput::new(ready, p.EXTI4); - let radio = Sx127xRadio::new(spi, cs, reset, ready_pin, DummySwitch) - .await - .unwrap(); + let radio = Sx127xRadio::new(spi, cs, reset, ready_pin, DummySwitch).await.unwrap(); let region = region::EU868::default().into(); - let mut device: Device<_, Crypto, _, _> = - Device::new(region, radio, LoraTimer, Rng::new(p.RNG)); + let mut device: Device<_, Crypto, _, _> = Device::new(region, radio, LoraTimer, Rng::new(p.RNG)); defmt::info!("Joining LoRaWAN network"); diff --git a/examples/stm32l0/src/bin/raw_spawn.rs b/examples/stm32l0/src/bin/raw_spawn.rs index 4601d85d..dfe2cddb 100644 --- a/examples/stm32l0/src/bin/raw_spawn.rs +++ b/examples/stm32l0/src/bin/raw_spawn.rs @@ -1,17 +1,15 @@ #![no_std] #![no_main] -use defmt::*; -use defmt_rtt as _; // global logger -use panic_probe as _; - use core::mem; -use cortex_m_rt::entry; +use cortex_m_rt::entry; +use defmt::*; use embassy::executor::raw::TaskStorage; use embassy::executor::Executor; use embassy::time::{Duration, Timer}; use embassy::util::Forever; +use {defmt_rtt as _, panic_probe as _}; async fn run1() { loop { diff --git a/examples/stm32l0/src/bin/spi.rs b/examples/stm32l0/src/bin/spi.rs index 5ed783b1..dba0b281 100644 --- a/examples/stm32l0/src/bin/spi.rs +++ b/examples/stm32l0/src/bin/spi.rs @@ -2,17 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::executor::Spawner; -use embassy_stm32::gpio::{Level, Output, Speed}; - use embassy_stm32::dma::NoDma; +use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l0/src/bin/usart_dma.rs b/examples/stm32l0/src/bin/usart_dma.rs index b3fdcacb..86124163 100644 --- a/examples/stm32l0/src/bin/usart_dma.rs +++ b/examples/stm32l0/src/bin/usart_dma.rs @@ -2,25 +2,15 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; - use embassy::executor::Spawner; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { - let mut usart = Uart::new( - p.USART1, - p.PB7, - p.PB6, - p.DMA1_CH2, - p.DMA1_CH3, - Config::default(), - ); + let mut usart = Uart::new(p.USART1, p.PB7, p.PB6, p.DMA1_CH2, p.DMA1_CH3, Config::default()); usart.write(b"Hello Embassy World!\r\n").await.unwrap(); info!("wrote Hello, starting echo"); diff --git a/examples/stm32l0/src/bin/usart_irq.rs b/examples/stm32l0/src/bin/usart_irq.rs index 4413a294..09b1b0b0 100644 --- a/examples/stm32l0/src/bin/usart_irq.rs +++ b/examples/stm32l0/src/bin/usart_irq.rs @@ -2,18 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; -use embedded_io::asynch::{Read, Write}; -// global logger -use panic_probe as _; - use defmt::*; - use embassy::executor::Spawner; use embassy_stm32::dma::NoDma; -use embassy_stm32::interrupt; use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; -use embassy_stm32::Peripherals; +use embassy_stm32::{interrupt, Peripherals}; +use embedded_io::asynch::{Read, Write}; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l1/src/bin/blinky.rs b/examples/stm32l1/src/bin/blinky.rs index e8145552..bace53d9 100644 --- a/examples/stm32l1/src/bin/blinky.rs +++ b/examples/stm32l1/src/bin/blinky.rs @@ -2,14 +2,12 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l1/src/bin/flash.rs b/examples/stm32l1/src/bin/flash.rs index eea838cb..fc519b07 100644 --- a/examples/stm32l1/src/bin/flash.rs +++ b/examples/stm32l1/src/bin/flash.rs @@ -7,9 +7,7 @@ use embassy::executor::Spawner; use embassy_stm32::flash::Flash; use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l1/src/bin/spi.rs b/examples/stm32l1/src/bin/spi.rs index bced0c54..81ccba4e 100644 --- a/examples/stm32l1/src/bin/spi.rs +++ b/examples/stm32l1/src/bin/spi.rs @@ -2,17 +2,14 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::executor::Spawner; -use embassy_stm32::gpio::{Level, Output, Speed}; - use embassy_stm32::dma::NoDma; +use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l4/src/bin/adc.rs b/examples/stm32l4/src/bin/adc.rs index 58ef6eba..499ea47d 100644 --- a/examples/stm32l4/src/bin/adc.rs +++ b/examples/stm32l4/src/bin/adc.rs @@ -2,13 +2,11 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::time::Delay; use embassy_stm32::adc::{Adc, Resolution}; use embassy_stm32::pac; +use {defmt_rtt as _, panic_probe as _}; #[cortex_m_rt::entry] fn main() -> ! { diff --git a/examples/stm32l4/src/bin/blinky.rs b/examples/stm32l4/src/bin/blinky.rs index e24a5bd3..54f8e03b 100644 --- a/examples/stm32l4/src/bin/blinky.rs +++ b/examples/stm32l4/src/bin/blinky.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l4/src/bin/button.rs b/examples/stm32l4/src/bin/button.rs index ff270b51..73b1962e 100644 --- a/examples/stm32l4/src/bin/button.rs +++ b/examples/stm32l4/src/bin/button.rs @@ -3,9 +3,8 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy_stm32::gpio::{Input, Pull}; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[cortex_m_rt::entry] fn main() -> ! { diff --git a/examples/stm32l4/src/bin/button_exti.rs b/examples/stm32l4/src/bin/button_exti.rs index 4b1cadcb..924feeb3 100644 --- a/examples/stm32l4/src/bin/button_exti.rs +++ b/examples/stm32l4/src/bin/button_exti.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l4/src/bin/dac.rs b/examples/stm32l4/src/bin/dac.rs index c26e7e70..d6e744aa 100644 --- a/examples/stm32l4/src/bin/dac.rs +++ b/examples/stm32l4/src/bin/dac.rs @@ -2,12 +2,10 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy_stm32::dac::{Channel, Dac, Value}; use embassy_stm32::pac; +use {defmt_rtt as _, panic_probe as _}; #[cortex_m_rt::entry] fn main() -> ! { diff --git a/examples/stm32l4/src/bin/i2c.rs b/examples/stm32l4/src/bin/i2c.rs index 46776564..a22b5218 100644 --- a/examples/stm32l4/src/bin/i2c.rs +++ b/examples/stm32l4/src/bin/i2c.rs @@ -2,16 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::i2c::I2c; -use embassy_stm32::interrupt; use embassy_stm32::time::Hertz; -use embassy_stm32::Peripherals; +use embassy_stm32::{interrupt, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x5F; const WHOAMI: u8 = 0x0F; diff --git a/examples/stm32l4/src/bin/i2c_blocking_async.rs b/examples/stm32l4/src/bin/i2c_blocking_async.rs index eb74223b..6c4a8670 100644 --- a/examples/stm32l4/src/bin/i2c_blocking_async.rs +++ b/examples/stm32l4/src/bin/i2c_blocking_async.rs @@ -2,18 +2,15 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::executor::Spawner; use embassy_embedded_hal::adapter::BlockingAsync; use embassy_stm32::dma::NoDma; use embassy_stm32::i2c::I2c; -use embassy_stm32::interrupt; use embassy_stm32::time::Hertz; -use embassy_stm32::Peripherals; +use embassy_stm32::{interrupt, Peripherals}; use embedded_hal_async::i2c::I2c as I2cTrait; +use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x5F; const WHOAMI: u8 = 0x0F; diff --git a/examples/stm32l4/src/bin/i2c_dma.rs b/examples/stm32l4/src/bin/i2c_dma.rs index 886a0e09..48d2e92c 100644 --- a/examples/stm32l4/src/bin/i2c_dma.rs +++ b/examples/stm32l4/src/bin/i2c_dma.rs @@ -2,15 +2,12 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::executor::Spawner; use embassy_stm32::i2c::I2c; -use embassy_stm32::interrupt; use embassy_stm32::time::Hertz; -use embassy_stm32::Peripherals; +use embassy_stm32::{interrupt, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; const ADDRESS: u8 = 0x5F; const WHOAMI: u8 = 0x0F; @@ -18,15 +15,7 @@ const WHOAMI: u8 = 0x0F; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) -> ! { let irq = interrupt::take!(I2C2_EV); - let mut i2c = I2c::new( - p.I2C2, - p.PB10, - p.PB11, - irq, - p.DMA1_CH4, - p.DMA1_CH5, - Hertz(100_000), - ); + let mut i2c = I2c::new(p.I2C2, p.PB10, p.PB11, irq, p.DMA1_CH4, p.DMA1_CH5, Hertz(100_000)); let mut data = [0u8; 1]; unwrap!(i2c.write_read(ADDRESS, &[WHOAMI], &mut data).await); diff --git a/examples/stm32l4/src/bin/rng.rs b/examples/stm32l4/src/bin/rng.rs index 03773e61..7aaa122e 100644 --- a/examples/stm32l4/src/bin/rng.rs +++ b/examples/stm32l4/src/bin/rng.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; use embassy_stm32::rng::Rng; use embassy_stm32::{Config, Peripherals}; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32l4/src/bin/spi.rs b/examples/stm32l4/src/bin/spi.rs index 44fdf81a..76e316a2 100644 --- a/examples/stm32l4/src/bin/spi.rs +++ b/examples/stm32l4/src/bin/spi.rs @@ -2,14 +2,12 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy_stm32::dma::NoDma; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; +use {defmt_rtt as _, panic_probe as _}; #[cortex_m_rt::entry] fn main() -> ! { diff --git a/examples/stm32l4/src/bin/spi_blocking_async.rs b/examples/stm32l4/src/bin/spi_blocking_async.rs index e1a40010..20a2ff80 100644 --- a/examples/stm32l4/src/bin/spi_blocking_async.rs +++ b/examples/stm32l4/src/bin/spi_blocking_async.rs @@ -2,9 +2,6 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::executor::Spawner; use embassy_embedded_hal::adapter::BlockingAsync; @@ -14,6 +11,7 @@ use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; use embedded_hal_async::spi::SpiBus; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index 88d02c7e..d0c3609a 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs @@ -2,15 +2,13 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::executor::Spawner; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::spi::{Config, Spi}; use embassy_stm32::time::Hertz; use embassy_stm32::Peripherals; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l4/src/bin/usart.rs b/examples/stm32l4/src/bin/usart.rs index b38f5545..4a4b46c5 100644 --- a/examples/stm32l4/src/bin/usart.rs +++ b/examples/stm32l4/src/bin/usart.rs @@ -2,12 +2,10 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; +use {defmt_rtt as _, panic_probe as _}; #[cortex_m_rt::entry] fn main() -> ! { diff --git a/examples/stm32l4/src/bin/usart_dma.rs b/examples/stm32l4/src/bin/usart_dma.rs index 40e2c367..7ae7e9e1 100644 --- a/examples/stm32l4/src/bin/usart_dma.rs +++ b/examples/stm32l4/src/bin/usart_dma.rs @@ -3,14 +3,14 @@ #![feature(type_alias_impl_trait)] use core::fmt::Write; + use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::dma::NoDma; use embassy_stm32::usart::{Config, Uart}; use embassy_stm32::Peripherals; use heapless::String; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l5/src/bin/button_exti.rs b/examples/stm32l5/src/bin/button_exti.rs index 304ce0a8..c7a6cfa2 100644 --- a/examples/stm32l5/src/bin/button_exti.rs +++ b/examples/stm32l5/src/bin/button_exti.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32l5/src/bin/rng.rs b/examples/stm32l5/src/bin/rng.rs index 5f75c1ff..d3627d2c 100644 --- a/examples/stm32l5/src/bin/rng.rs +++ b/examples/stm32l5/src/bin/rng.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; use embassy_stm32::rng::Rng; use embassy_stm32::{Config, Peripherals}; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { let mut config = Config::default(); diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index 526b2753..d711616e 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs @@ -5,29 +5,24 @@ use core::sync::atomic::{AtomicBool, Ordering}; use core::task::Waker; + use defmt::*; -use defmt_rtt as _; // global logger use embassy::blocking_mutex::raw::ThreadModeRawMutex; use embassy::channel::mpmc::Channel; use embassy::executor::Spawner; use embassy::util::Forever; use embassy_net::tcp::TcpSocket; use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources}; -use embassy_stm32::interrupt; use embassy_stm32::rcc::*; use embassy_stm32::rng::Rng; use embassy_stm32::time::Hertz; use embassy_stm32::usb::Driver; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::{interrupt, Config, Peripherals}; use embassy_usb::{Builder, UsbDevice}; use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; -use panic_probe as _; - -use defmt_rtt as _; use embedded_io::asynch::{Read, Write}; -// global logger -use panic_probe as _; use rand_core::RngCore; +use {defmt_rtt as _, panic_probe as _}; type MyDriver = Driver<'static, embassy_stm32::peripherals::USB>; @@ -92,13 +87,7 @@ fn config() -> Config { let mut config = Config::default(); config.rcc.mux = ClockSrc::HSE(Hertz(16_000_000)); - config.rcc.mux = ClockSrc::PLL( - PLLSource::HSI16, - PLLClkDiv::Div2, - PLLSrcDiv::Div1, - PLLMul::Mul10, - None, - ); + config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); config.rcc.hsi48 = true; config @@ -186,9 +175,7 @@ async fn main(spawner: Spawner, p: Peripherals) { let seed = rng.next_u64(); // Init network stack - let device = Device { - mac_addr: our_mac_addr, - }; + let device = Device { mac_addr: our_mac_addr }; let stack = &*forever!(Stack::new( device, config, diff --git a/examples/stm32l5/src/bin/usb_hid_mouse.rs b/examples/stm32l5/src/bin/usb_hid_mouse.rs index d275aba3..d139e6bb 100644 --- a/examples/stm32l5/src/bin/usb_hid_mouse.rs +++ b/examples/stm32l5/src/bin/usb_hid_mouse.rs @@ -6,31 +6,22 @@ use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; -use embassy_stm32::interrupt; use embassy_stm32::rcc::*; use embassy_stm32::time::Hertz; use embassy_stm32::usb::Driver; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::{interrupt, Config, Peripherals}; use embassy_usb::control::OutResponse; use embassy_usb::Builder; use embassy_usb_hid::{HidWriter, ReportId, RequestHandler, State}; use futures::future::join; use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { let mut config = Config::default(); config.rcc.mux = ClockSrc::HSE(Hertz(16_000_000)); - config.rcc.mux = ClockSrc::PLL( - PLLSource::HSI16, - PLLClkDiv::Div2, - PLLSrcDiv::Div1, - PLLMul::Mul10, - None, - ); + config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); config.rcc.hsi48 = true; config diff --git a/examples/stm32l5/src/bin/usb_serial.rs b/examples/stm32l5/src/bin/usb_serial.rs index 987f1b69..8dab001c 100644 --- a/examples/stm32l5/src/bin/usb_serial.rs +++ b/examples/stm32l5/src/bin/usb_serial.rs @@ -2,32 +2,23 @@ #![no_main] #![feature(type_alias_impl_trait)] -use defmt::panic; -use defmt::*; -use defmt_rtt as _; // global logger +use defmt::{panic, *}; use embassy::executor::Spawner; -use embassy_stm32::interrupt; use embassy_stm32::rcc::*; use embassy_stm32::time::Hertz; use embassy_stm32::usb::{Driver, Instance}; -use embassy_stm32::{Config, Peripherals}; +use embassy_stm32::{interrupt, Config, Peripherals}; use embassy_usb::driver::EndpointError; use embassy_usb::Builder; use embassy_usb_serial::{CdcAcmClass, State}; use futures::future::join; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; fn config() -> Config { let mut config = Config::default(); config.rcc.mux = ClockSrc::HSE(Hertz(16_000_000)); - config.rcc.mux = ClockSrc::PLL( - PLLSource::HSI16, - PLLClkDiv::Div2, - PLLSrcDiv::Div1, - PLLMul::Mul10, - None, - ); + config.rcc.mux = ClockSrc::PLL(PLLSource::HSI16, PLLClkDiv::Div2, PLLSrcDiv::Div1, PLLMul::Mul10, None); config.rcc.hsi48 = true; config @@ -99,9 +90,7 @@ impl From<EndpointError> for Disconnected { } } -async fn echo<'d, T: Instance + 'd>( - class: &mut CdcAcmClass<'d, Driver<'d, T>>, -) -> Result<(), Disconnected> { +async fn echo<'d, T: Instance + 'd>(class: &mut CdcAcmClass<'d, Driver<'d, T>>) -> Result<(), Disconnected> { let mut buf = [0; 64]; loop { let n = class.read_packet(&mut buf).await?; diff --git a/examples/stm32u5/src/bin/blinky.rs b/examples/stm32u5/src/bin/blinky.rs index e1bcccf5..4910e0b9 100644 --- a/examples/stm32u5/src/bin/blinky.rs +++ b/examples/stm32u5/src/bin/blinky.rs @@ -3,13 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -// global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) -> ! { diff --git a/examples/stm32u5/src/bin/boot.rs b/examples/stm32u5/src/bin/boot.rs index e0402134..e2112ce5 100644 --- a/examples/stm32u5/src/bin/boot.rs +++ b/examples/stm32u5/src/bin/boot.rs @@ -3,10 +3,7 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger -use panic_probe as _; - -use embassy_stm32 as _; +use {defmt_rtt as _, embassy_stm32 as _, panic_probe as _}; #[cortex_m_rt::entry] fn main() -> ! { diff --git a/examples/stm32wb/src/bin/blinky.rs b/examples/stm32wb/src/bin/blinky.rs index 59324161..8ab9b749 100644 --- a/examples/stm32wb/src/bin/blinky.rs +++ b/examples/stm32wb/src/bin/blinky.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32wb/src/bin/button_exti.rs b/examples/stm32wb/src/bin/button_exti.rs index a30a4a21..2ddeb887 100644 --- a/examples/stm32wb/src/bin/button_exti.rs +++ b/examples/stm32wb/src/bin/button_exti.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32wl/src/bin/blinky.rs b/examples/stm32wl/src/bin/blinky.rs index 78079bfd..9393af1c 100644 --- a/examples/stm32wl/src/bin/blinky.rs +++ b/examples/stm32wl/src/bin/blinky.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32wl/src/bin/button.rs b/examples/stm32wl/src/bin/button.rs index f80b9ab4..982a7a11 100644 --- a/examples/stm32wl/src/bin/button.rs +++ b/examples/stm32wl/src/bin/button.rs @@ -2,12 +2,10 @@ #![no_main] #![feature(type_alias_impl_trait)] +use cortex_m_rt::entry; use defmt::*; -use defmt_rtt as _; // global logger use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use panic_probe as _; - -use cortex_m_rt::entry; +use {defmt_rtt as _, panic_probe as _}; #[entry] fn main() -> ! { diff --git a/examples/stm32wl/src/bin/button_exti.rs b/examples/stm32wl/src/bin/button_exti.rs index 9a427c2d..7d5c1b3c 100644 --- a/examples/stm32wl/src/bin/button_exti.rs +++ b/examples/stm32wl/src/bin/button_exti.rs @@ -3,12 +3,11 @@ #![feature(type_alias_impl_trait)] use defmt::*; -use defmt_rtt as _; // global logger use embassy::executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Pull}; use embassy_stm32::Peripherals; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32wl/src/bin/flash.rs b/examples/stm32wl/src/bin/flash.rs index f8481822..6531feae 100644 --- a/examples/stm32wl/src/bin/flash.rs +++ b/examples/stm32wl/src/bin/flash.rs @@ -7,9 +7,7 @@ use embassy::executor::Spawner; use embassy_stm32::flash::Flash; use embassy_stm32::Peripherals; use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; - -use defmt_rtt as _; // global logger -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; #[embassy::main] async fn main(_spawner: Spawner, p: Peripherals) { diff --git a/examples/stm32wl/src/bin/lorawan.rs b/examples/stm32wl/src/bin/lorawan.rs index 393828c8..4f0dc7df 100644 --- a/examples/stm32wl/src/bin/lorawan.rs +++ b/examples/stm32wl/src/bin/lorawan.rs @@ -5,20 +5,16 @@ #![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - -use embassy_lora::{stm32wl::*, LoraTimer}; -use embassy_stm32::{ - dma::NoDma, - gpio::{Level, Output, Pin, Speed}, - interrupt, pac, - rng::Rng, - subghz::*, - Peripherals, -}; +use embassy_lora::stm32wl::*; +use embassy_lora::LoraTimer; +use embassy_stm32::dma::NoDma; +use embassy_stm32::gpio::{Level, Output, Pin, Speed}; +use embassy_stm32::rng::Rng; +use embassy_stm32::subghz::*; +use embassy_stm32::{interrupt, pac, Peripherals}; use lorawan::default_crypto::DefaultFactory as Crypto; use lorawan_device::async_device::{region, Device, JoinMode}; +use {defmt_rtt as _, panic_probe as _}; fn config() -> embassy_stm32::Config { let mut config = embassy_stm32::Config::default(); @@ -43,8 +39,7 @@ async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { let radio = unsafe { SubGhzRadio::new(&mut RADIO_STATE, radio, rfs, irq) }; let region = region::EU868::default().into(); - let mut device: Device<_, Crypto, _, _> = - Device::new(region, radio, LoraTimer, Rng::new(p.RNG)); + let mut device: Device<_, Crypto, _, _> = Device::new(region, radio, LoraTimer, Rng::new(p.RNG)); defmt::info!("Joining LoRaWAN network"); diff --git a/examples/stm32wl/src/bin/subghz.rs b/examples/stm32wl/src/bin/subghz.rs index f5f9b6a3..c5f6e502 100644 --- a/examples/stm32wl/src/bin/subghz.rs +++ b/examples/stm32wl/src/bin/subghz.rs @@ -5,18 +5,15 @@ #![feature(generic_associated_types)] #![feature(type_alias_impl_trait)] -use defmt_rtt as _; // global logger -use panic_probe as _; - use defmt::*; use embassy::channel::signal::Signal; use embassy_stm32::dma::NoDma; use embassy_stm32::exti::ExtiInput; use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use embassy_stm32::interrupt; use embassy_stm32::interrupt::{Interrupt, InterruptExt}; use embassy_stm32::subghz::*; -use embassy_stm32::Peripherals; +use embassy_stm32::{interrupt, Peripherals}; +use {defmt_rtt as _, panic_probe as _}; const PING_DATA: &str = "PING"; const DATA_LEN: u8 = PING_DATA.len() as u8; @@ -46,20 +43,13 @@ const LORA_MOD_PARAMS: LoRaModParams = LoRaModParams::new() // configuration for +10 dBm output power // see table 35 "PA optimal setting and operating modes" -const PA_CONFIG: PaConfig = PaConfig::new() - .set_pa_duty_cycle(0x1) - .set_hp_max(0x0) - .set_pa(PaSel::Lp); +const PA_CONFIG: PaConfig = PaConfig::new().set_pa_duty_cycle(0x1).set_hp_max(0x0).set_pa(PaSel::Lp); const TCXO_MODE: TcxoMode = TcxoMode::new() .set_txco_trim(TcxoTrim::Volts1pt7) - .set_timeout(Timeout::from_duration_sat( - core::time::Duration::from_millis(10), - )); + .set_timeout(Timeout::from_duration_sat(core::time::Duration::from_millis(10))); -const TX_PARAMS: TxParams = TxParams::new() - .set_power(0x0D) - .set_ramp_time(RampTime::Micros40); +const TX_PARAMS: TxParams = TxParams::new().set_power(0x0D).set_ramp_time(RampTime::Micros40); fn config() -> embassy_stm32::Config { let mut config = embassy_stm32::Config::default(); diff --git a/examples/wasm/src/lib.rs b/examples/wasm/src/lib.rs index 0aa32a70..61757ebd 100644 --- a/examples/wasm/src/lib.rs +++ b/examples/wasm/src/lib.rs @@ -1,10 +1,8 @@ #![feature(type_alias_impl_trait)] #![allow(incomplete_features)] -use embassy::{ - executor::Spawner, - time::{Duration, Timer}, -}; +use embassy::executor::Spawner; +use embassy::time::{Duration, Timer}; #[embassy::task] async fn ticker() { @@ -13,13 +11,9 @@ async fn ticker() { let mut counter = 0; loop { let document = window.document().expect("should have a document on window"); - let list = document - .get_element_by_id("log") - .expect("should have a log element"); + let list = document.get_element_by_id("log").expect("should have a log element"); - let li = document - .create_element("li") - .expect("error creating list item element"); + let li = document.create_element("li").expect("error creating list item element"); li.set_text_content(Some(&format!("tick {}", counter))); list.append_child(&li).expect("error appending list item"); |