[esp] Add no std example reading from AHT20. #2
@ -1,16 +1,16 @@
 | 
			
		||||
[build]
 | 
			
		||||
target = "xtensa-esp32-espidf"
 | 
			
		||||
 | 
			
		||||
[target.xtensa-esp32-espidf]
 | 
			
		||||
linker = "ldproxy"
 | 
			
		||||
runner = "espflash flash --monitor"
 | 
			
		||||
rustflags = [ "--cfg",  "espidf_time64"]
 | 
			
		||||
 | 
			
		||||
[unstable]
 | 
			
		||||
build-std = ["std", "panic_abort"]
 | 
			
		||||
[target.xtensa-esp32-none-elf]
 | 
			
		||||
runner = "espflash flash --monitor --chip esp32"
 | 
			
		||||
 | 
			
		||||
[env]
 | 
			
		||||
MCU="esp32"
 | 
			
		||||
# Note: this variable is not used by the pio builder (`cargo build --features pio`)
 | 
			
		||||
ESP_IDF_VERSION = "v5.3.3"
 | 
			
		||||
ESP_LOG = "info"
 | 
			
		||||
 | 
			
		||||
[build]
 | 
			
		||||
rustflags = [
 | 
			
		||||
    "-C", "link-arg=-Wl,-Tlinkall.x",
 | 
			
		||||
    "-C", "link-arg=-nostartfiles",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
target = "xtensa-esp32-none-elf"
 | 
			
		||||
 | 
			
		||||
[unstable]
 | 
			
		||||
build-std = ["core"]
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,12 @@
 | 
			
		||||
[package]
 | 
			
		||||
name = "aht20"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
authors = ["shaun"]
 | 
			
		||||
authors = ["Shaun Reed <shaunrd0@gmail.com>"]
 | 
			
		||||
edition = "2021"
 | 
			
		||||
resolver = "2"
 | 
			
		||||
rust-version = "1.77"
 | 
			
		||||
description = "test"
 | 
			
		||||
publish = false
 | 
			
		||||
 | 
			
		||||
[[bin]]
 | 
			
		||||
name = "aht20"
 | 
			
		||||
@ -19,17 +21,27 @@ opt-level = "z"
 | 
			
		||||
 | 
			
		||||
[features]
 | 
			
		||||
default = []
 | 
			
		||||
esp32 = [
 | 
			
		||||
    "esp-backtrace/esp32",
 | 
			
		||||
    "esp-hal/esp32",
 | 
			
		||||
    "esp-bootloader-esp-idf/esp32",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
experimental = ["esp-idf-svc/experimental"]
 | 
			
		||||
#experimental = ["esp-idf-svc/experimental"]
 | 
			
		||||
 | 
			
		||||
[dependencies]
 | 
			
		||||
log = "0.4"
 | 
			
		||||
esp-idf-svc = "0.51"
 | 
			
		||||
embedded-hal = "1.0.0"
 | 
			
		||||
esp-backtrace = "0.17.0"
 | 
			
		||||
esp-hal = { version = "1.0.0-rc.0", features = ["unstable"] }
 | 
			
		||||
fugit = "0.3.7"
 | 
			
		||||
esp-println = { version = "0.15.0", features = ["log-04"] }
 | 
			
		||||
esp-backtrace = { version = "0.17.0", features = ["esp32", "println", "panic-handler"] }
 | 
			
		||||
esp-hal = { version = "1.0.0-rc.0", features = ["esp32", "unstable"] }
 | 
			
		||||
esp-println = { version = "0.15.0", features = ["auto", "log-04"] }
 | 
			
		||||
esp-bootloader-esp-idf = { version = "0.2.0", default-features = false, features = ["esp-rom-sys", "log-04", "esp32"] }
 | 
			
		||||
#esp-rom-sys = { version = "0.1.1", features = ["esp32"] }
 | 
			
		||||
#esp-idf-svc = { version = "0.51", features = [""], default-features = false}
 | 
			
		||||
#esp-idf-hal = "0.45.2"
 | 
			
		||||
#anyhow = "1.0.98"
 | 
			
		||||
#fugit = "0.3.7"
 | 
			
		||||
#esp-rom-sys = { version = "0.1.1", features = ["esp32"] }
 | 
			
		||||
 | 
			
		||||
# --- Optional Embassy Integration ---
 | 
			
		||||
# esp-idf-svc = { version = "0.51", features = ["critical-section", "embassy-time-driver", "embassy-sync"] }
 | 
			
		||||
 | 
			
		||||
@ -1,3 +0,0 @@
 | 
			
		||||
fn main() {
 | 
			
		||||
    embuild::espidf::sysenv::output();
 | 
			
		||||
}
 | 
			
		||||
@ -1,6 +1,13 @@
 | 
			
		||||
#![no_std]
 | 
			
		||||
#![no_main]
 | 
			
		||||
 | 
			
		||||
use embedded_hal::{delay::DelayNs, i2c::I2c as I2cEmbedded};
 | 
			
		||||
use esp_backtrace as _;
 | 
			
		||||
use esp_hal::{
 | 
			
		||||
    delay::Delay,
 | 
			
		||||
    xtensa_lx_rt::entry,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/// Represents a reading from the sensor.
 | 
			
		||||
pub struct SensorReading<T> {
 | 
			
		||||
    pub humidity: T,
 | 
			
		||||
@ -111,19 +118,15 @@ impl<I: I2cEmbedded, D: DelayNs> Dht20<I, D> {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
use embedded_hal::{delay::DelayNs, i2c::I2c as I2cEmbedded};
 | 
			
		||||
use esp_backtrace as _;
 | 
			
		||||
use esp_hal::{
 | 
			
		||||
    clock::CpuClock,
 | 
			
		||||
    delay::Delay,
 | 
			
		||||
    gpio::{Level, Pull},
 | 
			
		||||
    i2c::master::I2c,
 | 
			
		||||
    xtensa_lx_rt::entry,
 | 
			
		||||
};
 | 
			
		||||
use fugit::{ExtU64, HertzU32};
 | 
			
		||||
// #[panic_handler]
 | 
			
		||||
// fn panic(_: &core::panic::PanicInfo) -> ! {
 | 
			
		||||
//     loop {}
 | 
			
		||||
// }
 | 
			
		||||
 | 
			
		||||
esp_bootloader_esp_idf::esp_app_desc!();
 | 
			
		||||
#[entry]
 | 
			
		||||
fn main() -> ! {
 | 
			
		||||
 | 
			
		||||
    let peripherals = esp_hal::init(esp_hal::Config::default());
 | 
			
		||||
    esp_println::logger::init_logger_from_env();
 | 
			
		||||
    let mut delay = Delay::new();
 | 
			
		||||
@ -132,8 +135,8 @@ fn main() -> ! {
 | 
			
		||||
    let i2c_for_dht20 =
 | 
			
		||||
        esp_hal::i2c::master::I2c::new(peripherals.I2C0, esp_hal::i2c::master::Config::default())
 | 
			
		||||
            .unwrap()
 | 
			
		||||
            .with_sda(peripherals.pins.gpio21)
 | 
			
		||||
            .with_scl(peripherals.pins.gpio22);
 | 
			
		||||
            .with_sda(peripherals.GPIO21)
 | 
			
		||||
            .with_scl(peripherals.GPIO22);
 | 
			
		||||
    let mut dht20 = Dht20::new(i2c_for_dht20, delay);
 | 
			
		||||
 | 
			
		||||
    loop {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user