mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-28 04:40:52 +00:00

* Fix warning in `esp-hal-procmacros` when building for `esp-lp-hal` * Document cargo features, use `embedded-hal@1.x.x` by default * Derive more traits on public types, assorted cleanup and improvements * Implement `embedded-hal-nb` and `embedded-io` traits for UART * Update `CHANGELOG.md` * Silence `clippy` for now... * Module documentation for UART * Update module documentation format
46 lines
1.1 KiB
Rust
46 lines
1.1 KiB
Rust
//! Counts a 32 bit value at a known point in memory, and blink GPIO1.
|
|
//!
|
|
//! When using the ESP32-C6's LP core, this address in memory is `0x5000_2000`.
|
|
//!
|
|
//! When using the ESP32-S2 or ESP32-S3's ULP core, this address in memory is
|
|
//! `0x5000_0400` (but is `0x400`` from the ULP's point of view!).
|
|
//!
|
|
//! Make sure the LP RAM is cleared before loading the code.
|
|
|
|
//% FEATURES: embedded-hal-02
|
|
|
|
#![no_std]
|
|
#![no_main]
|
|
|
|
use embedded_hal_02::{blocking::delay::DelayMs, digital::v2::OutputPin};
|
|
use esp_lp_hal::{delay::Delay, gpio::Output, prelude::*};
|
|
use panic_halt as _;
|
|
|
|
cfg_if::cfg_if! {
|
|
if #[cfg(feature = "esp32c6")] {
|
|
const ADDRESS: u32 = 0x5000_2000;
|
|
} else if #[cfg(any(feature = "esp32s2", feature = "esp32s3"))] {
|
|
const ADDRESS: u32 = 0x400;
|
|
}
|
|
}
|
|
|
|
#[entry]
|
|
fn main(mut gpio1: Output<1>) -> ! {
|
|
let mut i: u32 = 0;
|
|
|
|
let ptr = ADDRESS as *mut u32;
|
|
|
|
loop {
|
|
i = i.wrapping_add(1u32);
|
|
unsafe {
|
|
ptr.write_volatile(i);
|
|
}
|
|
|
|
gpio1.set_high().unwrap();
|
|
Delay.delay_ms(500);
|
|
|
|
gpio1.set_low().unwrap();
|
|
Delay.delay_ms(500);
|
|
}
|
|
}
|