esp-hal/examples/src/bin/lp_core_basic.rs
Dániel Buga 99bf346898
Remove the need to manually pass clocks around (#1999)
* Clean up passing clocks to drivers

* Update changelog

* Initialise Clocks in a critical section

* Fix calling now() before init

* Fix doc

* Fix esp-wifi migration guide

* Add safety comment

* Update tests
2024-09-04 14:13:51 +00:00

51 lines
1.3 KiB
Rust

//! This shows a very basic example of running code on the LP core.
//!
//! Code on LP core increments a counter and continuously toggles LED. The
//! current value is printed by the HP core.
//!
//! Make sure to first compile the `esp-lp-hal/examples/blinky.rs` example
//!
//! The following wiring is assumed:
//! - LED => GPIO1
//% CHIPS: esp32c6
#![no_std]
#![no_main]
use esp_backtrace as _;
use esp_hal::{
gpio::{lp_io::LowPowerOutput, Io},
lp_core::{LpCore, LpCoreWakeupSource},
prelude::*,
};
use esp_println::{print, println};
#[entry]
fn main() -> ! {
let peripherals = esp_hal::init(esp_hal::Config::default());
// configure GPIO 1 as LP output pin
let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
let lp_pin = LowPowerOutput::new(io.pins.gpio1);
let mut lp_core = LpCore::new(peripherals.LP_CORE);
lp_core.stop();
println!("lp core stopped");
// load code to LP core
let lp_core_code =
load_lp_code!("../esp-lp-hal/target/riscv32imac-unknown-none-elf/release/examples/blinky");
// start LP core
lp_core_code.run(&mut lp_core, LpCoreWakeupSource::HpCpu, lp_pin);
println!("lpcore run");
let data = (0x5000_2000) as *mut u32;
loop {
print!("Current {:x} \u{000d}", unsafe {
data.read_volatile()
});
}
}