From e75066820ad320495ca70570641c90d75247b19b Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Fri, 7 Nov 2025 10:07:33 -0800 Subject: cargo +nightly fmt Signed-off-by: Felipe Balbi --- examples/adc_interrupt.rs | 9 ++------- examples/adc_polling.rs | 9 +++------ examples/blink.rs | 5 +---- examples/lpuart_buffered.rs | 9 ++------- examples/lpuart_polling.rs | 8 +++----- examples/ostimer_alarm.rs | 15 +++++---------- examples/ostimer_async.rs | 5 +---- examples/ostimer_counter.rs | 8 ++------ examples/ostimer_race_test.rs | 14 +++++--------- examples/rtc_alarm.rs | 9 +++------ 10 files changed, 27 insertions(+), 64 deletions(-) (limited to 'examples') diff --git a/examples/adc_interrupt.rs b/examples/adc_interrupt.rs index 26afd70b4..f0df3196c 100644 --- a/examples/adc_interrupt.rs +++ b/examples/adc_interrupt.rs @@ -1,24 +1,19 @@ #![no_std] #![no_main] -use cortex_m; use embassy_executor::Spawner; -use embassy_mcxa276 as hal; - use hal::adc::{LpadcConfig, TriggerPriorityPolicy}; use hal::pac::adc1::cfg::{Pwrsel, Refsel}; use hal::pac::adc1::cmdl1::{Adch, Mode}; use hal::pac::adc1::ctrl::CalAvgs; use hal::pac::adc1::tctrl::Tcmd; - use hal::uart; +use {cortex_m, embassy_mcxa276 as hal}; mod common; +use hal::{bind_interrupts, InterruptExt}; use {defmt_rtt as _, panic_probe as _}; -use hal::InterruptExt; -use hal::bind_interrupts; - bind_interrupts!(struct Irqs { ADC1 => hal::adc::AdcHandler; }); diff --git a/examples/adc_polling.rs b/examples/adc_polling.rs index 90be87c3f..561500d2d 100644 --- a/examples/adc_polling.rs +++ b/examples/adc_polling.rs @@ -1,24 +1,21 @@ #![no_std] #![no_main] -use embassy_mcxa276 as hal; - use embassy_executor::Spawner; - +use embassy_mcxa276 as hal; use hal::adc::{ConvResult, LpadcConfig, TriggerPriorityPolicy}; use hal::pac::adc1::cfg::{Pwrsel, Refsel}; use hal::pac::adc1::cmdl1::{Adch, Mode}; use hal::pac::adc1::ctrl::CalAvgs; use hal::pac::adc1::tctrl::Tcmd; - use hal::uart; mod common; -use {defmt_rtt as _, panic_probe as _}; - use core::fmt::Write; + use heapless::String; +use {defmt_rtt as _, panic_probe as _}; const G_LPADC_RESULT_SHIFT: u32 = 0; diff --git a/examples/blink.rs b/examples/blink.rs index a9b6e7093..564353d5c 100644 --- a/examples/blink.rs +++ b/examples/blink.rs @@ -34,10 +34,7 @@ async fn main(_spawner: Spawner) { } // Initialize embassy-time global driver backed by OSTIMER0 - hal::ostimer::time_driver::init( - hal::config::Config::default().time_interrupt_priority, - 1_000_000, - ); + hal::ostimer::time_driver::init(hal::config::Config::default().time_interrupt_priority, 1_000_000); // Configure LED pin for GPIO mode PIO3_18::set_mux_gpio(); diff --git a/examples/lpuart_buffered.rs b/examples/lpuart_buffered.rs index d0d4d2ee0..30ba3f333 100644 --- a/examples/lpuart_buffered.rs +++ b/examples/lpuart_buffered.rs @@ -4,13 +4,10 @@ use embassy_executor::Spawner; use embassy_mcxa276 as hal; use embassy_mcxa276::interrupt::typelevel::Handler; -use embassy_mcxa276::lpuart; use embassy_mcxa276::lpuart::buffered::BufferedLpuart; - +use embassy_mcxa276::{bind_interrupts, lpuart}; use embedded_io_async::{Read, Write}; -use embassy_mcxa276::bind_interrupts; - mod common; // Bind OS_EVENT for timers plus LPUART2 IRQ for the buffered driver @@ -69,9 +66,7 @@ async fn main(_spawner: Spawner) { let (tx, rx) = uart.split_ref(); tx.write(b"Hello buffered LPUART.\r\n").await.unwrap(); - tx.write(b"Type characters to echo them back.\r\n") - .await - .unwrap(); + tx.write(b"Type characters to echo them back.\r\n").await.unwrap(); // Echo loop let mut buf = [0u8; 4]; diff --git a/examples/lpuart_polling.rs b/examples/lpuart_polling.rs index f9172de40..067c7eb53 100644 --- a/examples/lpuart_polling.rs +++ b/examples/lpuart_polling.rs @@ -1,11 +1,10 @@ #![no_std] #![no_main] -use crate::hal::lpuart::{Config, Lpuart, lib}; use embassy_executor::Spawner; -use embassy_mcxa276 as hal; +use {defmt_rtt as _, embassy_mcxa276 as hal, panic_probe as _}; -use {defmt_rtt as _, panic_probe as _}; +use crate::hal::lpuart::{lib, Config, Lpuart}; mod common; @@ -43,8 +42,7 @@ async fn main(_spawner: Spawner) { // Write hello messages tx.blocking_write(b"Hello world.\r\n").unwrap(); - tx.blocking_write(b"Echoing. Type characters...\r\n") - .unwrap(); + tx.blocking_write(b"Echoing. Type characters...\r\n").unwrap(); // Echo loop loop { diff --git a/examples/ostimer_alarm.rs b/examples/ostimer_alarm.rs index eca669509..78ca4bbc5 100644 --- a/examples/ostimer_alarm.rs +++ b/examples/ostimer_alarm.rs @@ -2,16 +2,15 @@ #![no_main] use core::sync::atomic::{AtomicBool, Ordering}; -use cortex_m; + use embassy_executor::Spawner; -use embassy_mcxa276 as hal; use hal::uart; +use {cortex_m, embassy_mcxa276 as hal}; mod common; -use {defmt_rtt as _, panic_probe as _}; - use embassy_mcxa276::bind_interrupts; +use {defmt_rtt as _, panic_probe as _}; // Bind only OS_EVENT, and retain the symbol explicitly so it can't be GC'ed. bind_interrupts!(struct Irqs { @@ -46,18 +45,14 @@ async fn main(_spawner: Spawner) { uart.write_str_blocking("OSTIMER Alarm Example\n"); // Initialize embassy-time global driver backed by OSTIMER0 - hal::ostimer::time_driver::init( - hal::config::Config::default().time_interrupt_priority, - 1_000_000, - ); + hal::ostimer::time_driver::init(hal::config::Config::default().time_interrupt_priority, 1_000_000); // Create OSTIMER instance let config = hal::ostimer::Config { init_match_max: true, clock_frequency_hz: 1_000_000, // 1MHz }; - let ostimer = - hal::ostimer::Ostimer::::new(p.OSTIMER0, config, hal::pac()); + let ostimer = hal::ostimer::Ostimer::::new(p.OSTIMER0, config, hal::pac()); // Create alarm with callback let alarm = hal::ostimer::Alarm::new() diff --git a/examples/ostimer_async.rs b/examples/ostimer_async.rs index 37fb3b3d1..27e14e022 100644 --- a/examples/ostimer_async.rs +++ b/examples/ostimer_async.rs @@ -42,10 +42,7 @@ async fn main(_spawner: Spawner) { // Initialize OSTIMER with default 1MHz frequency // Adjust this value to match your actual OSTIMER clock frequency - hal::ostimer::time_driver::init( - hal::config::Config::default().time_interrupt_priority, - 1_000_000, - ); + hal::ostimer::time_driver::init(hal::config::Config::default().time_interrupt_priority, 1_000_000); // Removed force-pend; rely on real hardware match to trigger OS_EVENT. diff --git a/examples/ostimer_counter.rs b/examples/ostimer_counter.rs index 1f5bdf434..e95140a88 100644 --- a/examples/ostimer_counter.rs +++ b/examples/ostimer_counter.rs @@ -8,11 +8,8 @@ use embassy_executor::Spawner; use embassy_time::{Duration, Timer}; - -use {defmt_rtt as _, panic_probe as _}; - -use embassy_mcxa276 as hal; use hal::bind_interrupts; +use {defmt_rtt as _, embassy_mcxa276 as hal, panic_probe as _}; mod common; @@ -32,8 +29,7 @@ async fn main(_spawner: Spawner) { common::init_uart2(hal::pac()); } let src = unsafe { hal::clocks::uart2_src_hz(hal::pac()) }; - let mut uart = - hal::uart::Uart::::new(p.LPUART2, hal::uart::Config::new(src)); + let mut uart = hal::uart::Uart::::new(p.LPUART2, hal::uart::Config::new(src)); uart.write_str_blocking("OSTIMER Counter Reading and Reset Example\n"); diff --git a/examples/ostimer_race_test.rs b/examples/ostimer_race_test.rs index 072310309..a637b6353 100644 --- a/examples/ostimer_race_test.rs +++ b/examples/ostimer_race_test.rs @@ -9,13 +9,12 @@ #![no_std] #![no_main] +use core::sync::atomic::{AtomicU32, Ordering}; + use embassy_executor::Spawner; use embassy_time::{Duration, Timer}; - -use core::sync::atomic::{AtomicU32, Ordering}; -use embassy_mcxa276 as hal; use hal::bind_interrupts; -use {defmt_rtt as _, panic_probe as _}; +use {defmt_rtt as _, embassy_mcxa276 as hal, panic_probe as _}; mod common; @@ -80,8 +79,7 @@ async fn main(_spawner: Spawner) { common::init_uart2(hal::pac()); } let src = unsafe { hal::clocks::uart2_src_hz(hal::pac()) }; - let mut uart = - hal::uart::Uart::::new(p.LPUART2, hal::uart::Config::new(src)); + let mut uart = hal::uart::Uart::::new(p.LPUART2, hal::uart::Config::new(src)); uart.write_str_blocking("OSTIMER Race Condition Test Starting...\n"); @@ -250,9 +248,7 @@ async fn test_concurrent_operations( let alarm = hal::ostimer::Alarm::new().with_callback(alarm_callback); if !ostimer.schedule_alarm_delay(&alarm, 1000) { RACE_DETECTED.fetch_add(1, Ordering::SeqCst); - uart.write_str_blocking( - "ERROR: Failed to program OSTIMER alarm before concurrent operations\n", - ); + uart.write_str_blocking("ERROR: Failed to program OSTIMER alarm before concurrent operations\n"); } // Wait for both to complete diff --git a/examples/rtc_alarm.rs b/examples/rtc_alarm.rs index a190b8ba5..c27fd4c55 100644 --- a/examples/rtc_alarm.rs +++ b/examples/rtc_alarm.rs @@ -1,20 +1,17 @@ #![no_std] #![no_main] -use cortex_m; use embassy_executor::Spawner; -use embassy_mcxa276 as hal; -use hal::InterruptExt; use hal::rtc::{RtcDateTime, RtcInterruptEnable}; -use hal::uart; +use hal::{uart, InterruptExt}; +use {cortex_m, embassy_mcxa276 as hal}; mod common; type MyRtc = hal::rtc::Rtc; -use {defmt_rtt as _, panic_probe as _}; - use embassy_mcxa276::bind_interrupts; +use {defmt_rtt as _, panic_probe as _}; bind_interrupts!(struct Irqs { RTC => hal::rtc::RtcHandler; -- cgit