From 4f0eb421de9e08bbbf7f9a58f8b29c451de59894 Mon Sep 17 00:00:00 2001 From: Mathis Deroo Date: Tue, 9 Dec 2025 15:13:07 -0800 Subject: run rustfmt Signed-off-by: Mathis Deroo --- embassy-mcxa/src/adc.rs | 30 ++++++++++-------------------- examples/mcxa/src/bin/adc_interrupt.rs | 11 +++++------ examples/mcxa/src/bin/adc_polling.rs | 4 ++-- 3 files changed, 17 insertions(+), 28 deletions(-) diff --git a/embassy-mcxa/src/adc.rs b/embassy-mcxa/src/adc.rs index abcdf86f8..6500754ba 100644 --- a/embassy-mcxa/src/adc.rs +++ b/embassy-mcxa/src/adc.rs @@ -10,7 +10,7 @@ use maitake_sync::WaitCell; use paste::paste; use crate::clocks::periph_helpers::{AdcClockSel, AdcConfig, Div4}; -use crate::clocks::{Gate, PoweredClock, enable_and_reset, ClockError}; +use crate::clocks::{ClockError, Gate, PoweredClock, enable_and_reset}; use crate::pac::adc1::cfg::{HptExdi, Pwrsel, Refsel, Tcmdres, Tprictrl, Tres}; use crate::pac::adc1::cmdh1::{Avgs, Cmpen, Next, Sts}; @@ -18,7 +18,6 @@ use crate::pac::adc1::cmdl1::{Adch, Mode}; use crate::pac::adc1::ctrl::CalAvgs; use crate::pac::adc1::tctrl::{Tcmd, Tpri}; - const G_LPADC_RESULT_SHIFT: u32 = 0; /// Trigger priority policy for ADC conversions. @@ -166,12 +165,7 @@ impl<'a, I: Instance> Adc<'a, I, Blocking> { /// * `_inst` - ADC peripheral instance /// * `pin` - GPIO pin to use for ADC /// * `config` - ADC configuration - pub fn new_blocking( - _inst: Peri<'a, I>, - pin: Peri<'a, - impl AdcPin>, - config: LpadcConfig - ) -> Result { + pub fn new_blocking(_inst: Peri<'a, I>, pin: Peri<'a, impl AdcPin>, config: LpadcConfig) -> Result { Self::new_inner(_inst, pin, config) } } @@ -223,23 +217,19 @@ impl<'a, I: Instance> Adc<'a, I, Async> { } } - - impl<'a, I: Instance, M: ModeAdc> Adc<'a, I, M> { /// Internal initialization function shared by `new_async` and `new_blocking`. - fn new_inner( - _inst: Peri<'a, I>, - pin: Peri<'a, impl AdcPin>, - config: LpadcConfig - ) -> Result { + fn new_inner(_inst: Peri<'a, I>, pin: Peri<'a, impl AdcPin>, config: LpadcConfig) -> Result { let adc = I::ptr(); - _ = unsafe { enable_and_reset::(&AdcConfig { + _ = unsafe { + enable_and_reset::(&AdcConfig { power: config.power, source: config.source, div: config.div, }) - .map_err(Error::ClockSetup)? }; + .map_err(Error::ClockSetup)? + }; pin.mux(); @@ -324,9 +314,9 @@ impl<'a, I: Instance, M: ModeAdc> Adc<'a, I, M> { // Enable ADC adc.ctrl().modify(|_, w| w.adcen().enabled()); - Ok(Self { + Ok(Self { _inst: PhantomData, - _phantom: PhantomData, + _phantom: PhantomData, }) } @@ -435,7 +425,7 @@ impl<'a, I: Instance, M: ModeAdc> Adc<'a, I, M> { /// # Arguments /// * `index` - Command index /// * `config` - Command configuration - /// + /// /// # Returns /// * `Ok(())` if the command was configured successfully /// * `Err(Error::InvalidConfig)` if the index is out of range diff --git a/examples/mcxa/src/bin/adc_interrupt.rs b/examples/mcxa/src/bin/adc_interrupt.rs index 257e04491..5876923a1 100644 --- a/examples/mcxa/src/bin/adc_interrupt.rs +++ b/examples/mcxa/src/bin/adc_interrupt.rs @@ -2,16 +2,16 @@ #![no_main] use embassy_executor::Spawner; -use hal::adc::{Adc, LpadcConfig, TriggerPriorityPolicy, InterruptHandler}; +use hal::adc::{Adc, InterruptHandler, LpadcConfig, TriggerPriorityPolicy}; +use hal::bind_interrupts; use hal::clocks::PoweredClock; -use hal::config::Config; use hal::clocks::config::Div8; use hal::clocks::periph_helpers::{AdcClockSel, Div4}; +use hal::config::Config; 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::bind_interrupts; use hal::peripherals::ADC1; use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; @@ -19,12 +19,11 @@ bind_interrupts!(struct Irqs { ADC1 => InterruptHandler; }); - #[embassy_executor::main] async fn main(_spawner: Spawner) { let mut config = Config::default(); config.clock_cfg.sirc.fro_lf_div = Div8::from_divisor(1); - + let p = hal::init(config); defmt::info!("ADC interrupt Example"); @@ -62,7 +61,7 @@ async fn main(_spawner: Spawner) { defmt::info!("ADC configuration done..."); loop { - match adc.read().await { + match adc.read().await { Ok(value) => { defmt::info!("*** ADC interrupt TRIGGERED! *** -- value: {}", value); } diff --git a/examples/mcxa/src/bin/adc_polling.rs b/examples/mcxa/src/bin/adc_polling.rs index b11b8957f..d048bb56f 100644 --- a/examples/mcxa/src/bin/adc_polling.rs +++ b/examples/mcxa/src/bin/adc_polling.rs @@ -4,9 +4,9 @@ use embassy_executor::Spawner; use hal::adc::{Adc, LpadcConfig, TriggerPriorityPolicy}; use hal::clocks::PoweredClock; -use hal::config::Config; use hal::clocks::config::Div8; use hal::clocks::periph_helpers::{AdcClockSel, Div4}; +use hal::config::Config; use hal::pac::adc1::cfg::{Pwrsel, Refsel}; use hal::pac::adc1::cmdl1::{Adch, Mode}; use hal::pac::adc1::ctrl::CalAvgs; @@ -19,7 +19,7 @@ const G_LPADC_RESULT_SHIFT: u32 = 0; async fn main(_spawner: Spawner) { let mut config = Config::default(); config.clock_cfg.sirc.fro_lf_div = Div8::from_divisor(1); - + let p = hal::init(config); defmt::info!("=== ADC polling Example ==="); -- cgit