Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): make it compiles without rt and embassy feature #29

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Use nightly Rust
# lock to 2024-08-23 and wait for embassy-executor to be updated
run: |
rustup default nightly
rustup default nightly-2024-08-23
rustup component add rust-src
rustup target add riscv32imafc-unknown-none-elf
- name: Build Only
Expand Down
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()
}
Loading