Jesse Braham 9bf70ff792
Combine the esp-ulp-riscv-hal and esp32c6-lp-hal packages (#1115)
* Combine `esp-ulp-riscv-hal` and `esp32c6-lp-hal` into a single package

* Update LP core examples

* Update CI workflow

* Fix `LP_UART` example
2024-01-26 13:46:51 +00:00

48 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.
#![no_std]
#![no_main]
use embedded_hal_02::{blocking::delay::DelayMs, digital::v2::OutputPin};
use esp_lp_hal::{
delay::Delay,
gpio::{GpioPin, Output, PushPull},
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: GpioPin<Output<PushPull>, 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);
}
}