Skip to content

Commit

Permalink
fix(build): make it compiles without rt and embassy feature
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Sep 19, 2024
1 parent 756236c commit 94ab1c6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
17 changes: 6 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]

Expand Down
2 changes: 1 addition & 1 deletion src/adc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
5 changes: 3 additions & 2 deletions src/i2c/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
}
Expand All @@ -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| {
Expand All @@ -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
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

0 comments on commit 94ab1c6

Please sign in to comment.