* After more analysis and coding * More work is done, writing/reading WIP * `write` prototype done, small fixes. Read next * pre-rebase * Rebased and updated * Pre-final state of driver * More work (near-final state) done * WIP * WIP * working * cleanup * changelog * address review comments * remove Option from conjure and improve lp-i2c example description --------- Co-authored-by: Kirill Mikhailov <konnor1980@yandex.ru>
47 lines
1.3 KiB
Rust
47 lines
1.3 KiB
Rust
//! This shows a very basic example of running code on the LP core.
|
|
//!
|
|
//! Code on LP core uses LP_I2C initialized on HP core. For more information
|
|
//! check `lp_core_i2c` example in the `esp-lp-hal`.
|
|
//!
|
|
//! Make sure to first compile the `esp-lp-hal/examples/i2c.rs` example
|
|
|
|
#![no_std]
|
|
#![no_main]
|
|
|
|
use esp32c6_hal::{
|
|
gpio::lp_gpio::IntoLowPowerPin,
|
|
i2c::lp_i2c::LpI2c,
|
|
lp_core,
|
|
peripherals::Peripherals,
|
|
prelude::*,
|
|
IO,
|
|
};
|
|
use esp_backtrace as _;
|
|
use esp_println::println;
|
|
|
|
#[entry]
|
|
fn main() -> ! {
|
|
let peripherals = Peripherals::take();
|
|
|
|
let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
|
|
|
|
let lp_sda = io.pins.gpio6.into_low_power().into_open_drain_output();
|
|
let lp_scl = io.pins.gpio7.into_low_power().into_open_drain_output();
|
|
|
|
let lp_i2c = LpI2c::new(peripherals.LP_I2C0, lp_sda, lp_scl, 100u32.kHz());
|
|
|
|
let mut lp_core = esp32c6_hal::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/i2c");
|
|
|
|
// start LP core
|
|
lp_core_code.run(&mut lp_core, lp_core::LpCoreWakeupSource::HpCpu, lp_i2c);
|
|
println!("lpcore run");
|
|
|
|
loop {}
|
|
}
|