Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
856 changes: 544 additions & 312 deletions examples/esp/Cargo.lock

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions examples/esp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resolver = "2"
categories = ["embedded", "hardware-support"]
keywords = ["thread", "openthread", "embedded", "embassy"]
description = "openthread examples for Espressif chips"
repository = "https://github.com/ivmarkov/esp-openthread"
repository = "https://github.com/esp-rs/openthread"
license = "MIT OR Apache-2.0"
readme = "README.md"
rust-version = "1.84"
Expand All @@ -27,29 +27,29 @@ overflow-checks = false

[features]
default = ["esp32c6"]
esp32c6 = [ "esp-hal-embassy/esp32c6", "esp-ieee802154/esp32c6", "esp-backtrace/esp32c6", "esp-println/esp32c6", "esp-bootloader-esp-idf/esp32c6"]
esp32h2 = [ "esp-hal-embassy/esp32h2", "esp-ieee802154/esp32h2", "esp-backtrace/esp32h2", "esp-println/esp32h2", "esp-bootloader-esp-idf/esp32h2"]
esp32c6 = ["esp-rtos/esp32c6", "esp-radio/esp32c6", "esp-backtrace/esp32c6", "esp-println/esp32c6", "esp-bootloader-esp-idf/esp32c6"]
esp32h2 = ["esp-rtos/esp32h2", "esp-radio/esp32h2", "esp-backtrace/esp32h2", "esp-println/esp32h2", "esp-bootloader-esp-idf/esp32h2"]

[dependencies]
embassy-executor = { version = "0.7", features = ["task-arena-size-32768", "log"] }
embassy-executor = "0.9"
embassy-sync = "0.7"
embassy-futures = "0.1"
embassy-time = "0.4"
embassy-net = { version = "0.6", features = ["proto-ipv6", "medium-ip", "udp", "log"] }
esp-hal = { version = "=1.0.0-rc.0", features = ["log-04","unstable"] }
esp-hal-embassy = "0.9"
esp-alloc = { version = "0.8", optional = true }
esp-backtrace = { version = "0.17", features = ["panic-handler", "exception-handler", "println"] }
esp-println = { version = "0.15", features = ["log-04"] }
esp-ieee802154 = { version= "0.8", features = ["log-04"] }
esp-bootloader-esp-idf = { version = "0.2", features = ["log-04"] }
embassy-time = "0.5"
embassy-net = { version = "0.7", features = ["proto-ipv6", "medium-ip", "udp", "log"] }
esp-hal = { version = "=1.0.0-rc.1", features = ["log-04", "unstable", "exception-handler"] }
esp-rtos = { version = "0.1.0", features = ["esp-radio", "embassy"] }
esp-alloc = { version = "0.9", optional = true }
esp-backtrace = { version = "0.18", features = ["panic-handler", "println"] }
esp-println = { version = "0.16", features = ["log-04"] }
esp-radio = { version = "0.16", features = ["unstable", "ieee802154"] }
esp-bootloader-esp-idf = { version = "0.3", features = ["log-04"] }
log = "0.4"
heapless = "0.8"
critical-section = "1.2"
rand_core = "0.9"
static_cell = "2.1"

openthread = { path = "../../openthread", features = ["udp", "srp", "embassy-net-driver-channel", "esp-ieee802154", "isupper", "log"] }
openthread = { path = "../../openthread", features = ["udp", "srp", "embassy-net-driver-channel", "esp-radio", "isupper", "log"] }
tinyrlibc = { version = "0.5", default-features = false, features = ["utoa", "strtoul"] }

[[bin]]
Expand Down
19 changes: 13 additions & 6 deletions examples/esp/src/bin/basic_enet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use embassy_net::udp::{PacketMetadata, UdpMetadata, UdpSocket};
use embassy_net::{Config, ConfigV6, Ipv6Cidr, Runner, StackResources, StaticConfigV6};

use esp_hal::rng::Rng;
use esp_hal::timer::systimer::SystemTimer;
use esp_ieee802154::Ieee802154;
use esp_hal::timer::timg::TimerGroup;
use esp_radio::ieee802154::Ieee802154;
use {esp_backtrace as _, esp_println as _};

use heapless::Vec;
Expand All @@ -41,7 +41,7 @@ macro_rules! mk_static {
($t:ty,$val:expr) => {{
static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new();
#[deny(unused_attributes)]
let x = STATIC_CELL.uninit().write(($val));
let x = STATIC_CELL.uninit().write($val);
x
}};
}
Expand All @@ -59,17 +59,24 @@ const THREAD_DATASET: &str = if let Some(dataset) = option_env!("THREAD_DATASET"

esp_bootloader_esp_idf::esp_app_desc!();

#[esp_hal_embassy::main]
#[esp_rtos::main]
async fn main(spawner: Spawner) {
esp_println::logger::init_logger_from_env();

info!("Starting...");

let peripherals = esp_hal::init(esp_hal::Config::default());

esp_hal_embassy::init(SystemTimer::new(peripherals.SYSTIMER).alarm0);
let timg0 = TimerGroup::new(peripherals.TIMG0);
esp_rtos::start(
timg0.timer0,
#[cfg(target_arch = "riscv32")]
esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT)
.software_interrupt0,
);

let rng = mk_static!(Rng, Rng::new(peripherals.RNG));
// TODO: Use TRNG?
let rng = mk_static!(Rng, Rng::new());

let enet_seed = rng.next_u64();

Expand Down
19 changes: 13 additions & 6 deletions examples/esp/src/bin/basic_udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use log::info;
use embassy_executor::Spawner;

use esp_hal::rng::Rng;
use esp_hal::timer::systimer::SystemTimer;
use esp_ieee802154::Ieee802154;
use esp_hal::timer::timg::TimerGroup;
use esp_radio::ieee802154::Ieee802154;
use {esp_backtrace as _, esp_println as _};

use openthread::esp::EspRadio;
Expand All @@ -36,7 +36,7 @@ macro_rules! mk_static {
($t:ty,$val:expr) => {{
static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new();
#[deny(unused_attributes)]
let x = STATIC_CELL.uninit().write(($val));
let x = STATIC_CELL.uninit().write($val);
x
}};
}
Expand All @@ -54,17 +54,24 @@ const THREAD_DATASET: &str = if let Some(dataset) = option_env!("THREAD_DATASET"

esp_bootloader_esp_idf::esp_app_desc!();

#[esp_hal_embassy::main]
#[esp_rtos::main]
async fn main(spawner: Spawner) {
esp_println::logger::init_logger_from_env();

info!("Starting...");

let peripherals = esp_hal::init(esp_hal::Config::default());

esp_hal_embassy::init(SystemTimer::new(peripherals.SYSTIMER).alarm0);
let timg0 = TimerGroup::new(peripherals.TIMG0);
esp_rtos::start(
timg0.timer0,
#[cfg(target_arch = "riscv32")]
esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT)
.software_interrupt0,
);

let rng = mk_static!(Rng, Rng::new(peripherals.RNG));
// TODO: Use TRNG?
let rng = mk_static!(Rng, Rng::new());

let mut ieee_eui64 = [0; 8];
rng.fill_bytes(&mut ieee_eui64);
Expand Down
19 changes: 13 additions & 6 deletions examples/esp/src/bin/srp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use log::info;
use embassy_executor::Spawner;

use esp_hal::rng::Rng;
use esp_hal::timer::systimer::SystemTimer;
use esp_ieee802154::Ieee802154;
use esp_hal::timer::timg::TimerGroup;
use esp_radio::ieee802154::Ieee802154;
use {esp_backtrace as _, esp_println as _};

use openthread::esp::EspRadio;
Expand All @@ -41,7 +41,7 @@ macro_rules! mk_static {
($t:ty,$val:expr) => {{
static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new();
#[deny(unused_attributes)]
let x = STATIC_CELL.uninit().write(($val));
let x = STATIC_CELL.uninit().write($val);
x
}};
}
Expand All @@ -62,17 +62,24 @@ const THREAD_DATASET: &str = if let Some(dataset) = option_env!("THREAD_DATASET"

esp_bootloader_esp_idf::esp_app_desc!();

#[esp_hal_embassy::main]
#[esp_rtos::main]
async fn main(spawner: Spawner) {
esp_println::logger::init_logger_from_env();

info!("Starting...");

let peripherals = esp_hal::init(esp_hal::Config::default());

esp_hal_embassy::init(SystemTimer::new(peripherals.SYSTIMER).alarm0);
let timg0 = TimerGroup::new(peripherals.TIMG0);
esp_rtos::start(
timg0.timer0,
#[cfg(target_arch = "riscv32")]
esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT)
.software_interrupt0,
);

let rng = mk_static!(Rng, Rng::new(peripherals.RNG));
// TODO: Use TRNG?
let rng = mk_static!(Rng, Rng::new());

let mut ieee_eui64 = [0; 8];
rng.fill_bytes(&mut ieee_eui64);
Expand Down
Loading