admin管理员组文章数量:1384106
I'm a student passionate about embedded systems, and I'm trying to program an ESP32 using Rust. I'm using esp-hal and esp-backtrace for error handling, but I'm encountering a compilation issue.
#![no_std]
#![no_main]
use esp_backtrace as _;
use esp_hal::{
analog::adc::{Adc, AdcConfig, Attenuation},
delay::Delay,
gpio::{Level, Output, OutputConfig},
main,
};
use log::{info, warn};
use nb::block;
#[main]
fn main() -> ! {
let peripherals = esp_hal::init(esp_hal::Config::default());
esp_println::logger::init_logger_from_env();
let mut led = Output::new(peripherals.GPIO4, Level::High, OutputConfig::default());
// ADC
let analog_pin = peripherals.GPIO32;
let mut adc1_config = AdcConfig::new();
let mut pin = adc1_config.enable_pin(
analog_pin,
Attenuation::_11dB,
);
let mut adc1 = Adc::new(peripherals.ADC1, adc1_config);
// Delay
let delay = Delay::new();
info!("Start...");
loop {
// Intentar leer el ADC
match block!(adc1.read_oneshot(&mut pin)) {
Ok(pin_value) => {
info!("ADC Value: {}", pin_value);
//
if pin_value > 2000 {
led.set_high();
} else {
led.set_low();
}
}
Err(e) => {
warn!("Error al leer el ADC: {:?}", e);
//
led.set_high(); //
}
}
delay.delay_millis(500);
}
}
this is my cargo.toml
[package]
name = "esp-32-project"
version = "0.1.0"
edition = "2021"
[dependencies]
esp-hal = { version = "1.0.0-beta.0", features = ["esp32", "unstable"] }
esp-backtrace = { version = "0.15.1", features = ["esp32", "panic-handler", "println"] }
esp-println = { version = "0.13.1", features = ["esp32", "log"] }
log = "0.4.26"
nb = "1.1"
Compilation Error: When I try to compile with cargo build, I get the following error:
error[E0583]: file not found for module `arch`
--> C:\Users\Richard\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\esp-backtrace-0.15.1\src\lib.rs:46:1
|
46 | pub mod arch;
| ^^^^^^^^^^^^^
|
= help: to create the module `arch`, create file "C:\Users\Richard\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\esp-backtrace-0.15.1\src\arch.rs" or "C:\Users\Richard\.cargo\registry\src\arch\mod.rs"
= note: if there is a `mod arch` elsewhere in the crate already, import it with `use crate::...` instead
Why is esp-backtrace unable to find the arch module? Am I missing a configuration in Cargo.toml or my code?
Any help would be greatly appreciated!
I tried running cargo build, but I got an error saying the arch module was missing.
I expected the code to compile successfully and upload to my ESP32.
To fix it, I tried:
Running cargo clean and then cargo build. Checking that esp-backtrace has the correct features enabled. Downgrading esp-backtrace to an older version. But the error persists. How can I fix this?
本文标签: embeddedRust en ESP32 quotfile not found for module archquot con espbacktraceStack Overflow
版权声明:本文标题:embedded - Rust en ESP32: "file not found for module arch" con esp-backtrace - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744486459a2608477.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论