From 94ab1c6218292cbd2eba8d1646451e7d9ff3bb93 Mon Sep 17 00:00:00 2001 From: Andelf Date: Wed, 18 Sep 2024 23:03:01 +0800 Subject: [PATCH] fix(build): make it compiles without rt and embassy feature --- Cargo.toml | 17 ++++++----------- src/adc/mod.rs | 2 +- src/i2c/mod.rs | 5 +++-- src/lib.rs | 5 +++++ 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c553128..17fc462 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,19 +24,19 @@ embedded-hal = { version = "1.0.0" } embassy-time-driver = { version = "0.1.0", features = [ "tick-hz-1_000_000", ], optional = true } -embassy-sync = { version = "0.6.0", optional = true } -embassy-futures = { version = "0.1.1", optional = true } +embassy-sync = { version = "0.6.0" } +embassy-futures = { version = "0.1.1" } embassy-hal-internal = { version = "0.2.0", default-features = false } -embassy-time = { version = "0.3.0", optional = true } +embassy-time = { version = "0.3.2", optional = true } embassy-usb-driver = { version = "0.1.0", features = ["defmt"] } -critical-section = "1.1.2" +critical-section = "1.1.3" static_assertions = "1" defmt = { version = "0.3.8", optional = true } embedded-io = "0.6.1" nb = "1.1.0" -futures-util = { version = "0.3.30", optional = true, default-features = false } +futures-util = { version = "0.3.30", default-features = false } embedded-hal-nb = "1.0.0" embedded-io-async = "0.6.1" embedded-hal-async = "1.0.0" @@ -62,12 +62,7 @@ defmt = ["dep:defmt"] time = ["dep:embassy-time"] chrono = ["dep:chrono"] usb-pin-reuse-hpm5300 = [] -embassy = [ - "dep:embassy-sync", - "dep:embassy-futures", - "dep:embassy-time-driver", - "dep:futures-util", -] +embassy = ["dep:embassy-time-driver"] mcan = ["dep:mcan"] diff --git a/src/adc/mod.rs b/src/adc/mod.rs index f19171f..4185378 100644 --- a/src/adc/mod.rs +++ b/src/adc/mod.rs @@ -108,8 +108,8 @@ impl<'d, T: Instance> Adc<'d, T> { let adc_freq = T::frequency() / config.clock_divider; - defmt::info!("ADC conversion freq => {}Hz", adc_freq.0); if adc_freq.0 > MAX_ADC_CLK_FREQ { + #[cfg(feature = "defmt")] defmt::warn!("ADC clock frequency is too high"); } diff --git a/src/i2c/mod.rs b/src/i2c/mod.rs index 87d61e2..e783a79 100644 --- a/src/i2c/mod.rs +++ b/src/i2c/mod.rs @@ -546,6 +546,7 @@ impl<'d, M: Mode> I2c<'d, M> { }); if r.status().read().linescl() == false { + #[cfg(feature = "defmt")] defmt::info!("CLK is low, panic"); loop {} } @@ -555,7 +556,7 @@ impl<'d, M: Mode> I2c<'d, M> { use embedded_hal::delay::DelayNs; use riscv::delay::McycleDelay; - defmt::info!("SDA is low, reset bus"); + // SDA is low, reset bus // i2s_gen_reset_signal // generate SCL clock as reset signal r.ctrl().modify(|w| { @@ -565,7 +566,7 @@ impl<'d, M: Mode> I2c<'d, M> { }); McycleDelay::new(crate::sysctl::clocks().cpu0.0).delay_ms(100); - defmt::info!("bus cleared"); + // bus cleared } } diff --git a/src/lib.rs b/src/lib.rs index f695e08..c41c5a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -176,3 +176,8 @@ pub fn init(config: Config) -> Peripherals { Peripherals::take() } + +/// A handly function to get the peripherals without initializing anything. +pub unsafe fn uninited() -> Peripherals { + Peripherals::take() +}