Skip to content

Commit

Permalink
feat: Update to latest hal
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioGasquez committed Jan 15, 2025
1 parent 5dc92db commit 99a30ed
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 40 deletions.
34 changes: 16 additions & 18 deletions template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ path = "./src/bin/main.rs"
#ENDIF

[dependencies]
esp-backtrace = { version = "0.14.2", features = [
esp-backtrace = { version = "0.15.0", features = [
#REPLACE esp32c6 mcu
"esp32c6",
"exception-handler",
Expand All @@ -25,20 +25,21 @@ esp-backtrace = { version = "0.14.2", features = [
"println",
#ENDIF
]}
esp-hal = { version = "0.22.0", features = [
esp-hal = { version = "0.23.0", features = [
#REPLACE esp32c6 mcu
"esp32c6",
"unstable",
#IF option("probe-rs")
#+"defmt",
#ENDIF
] }
#IF !option("probe-rs")
#REPLACE esp32c6 mcu
esp-println = { version = "0.12.0", features = ["esp32c6", "log"] }
esp-println = { version = "0.13.0", features = ["esp32c6", "log"] }
log = { version = "0.4.21" }
#ENDIF
#IF option("alloc")
esp-alloc = { version = "0.5.0" }
esp-alloc = { version = "0.6.0" }
#ENDIF
#IF option("wifi") || option("ble")
embedded-io = "0.6.1"
Expand All @@ -48,7 +49,7 @@ embedded-io-async = "0.6.1"
embassy-net = { version = "0.4.0", features = [ "tcp", "udp", "dhcpv4", "medium-ethernet"] }
#ENDIF
#ENDIF
esp-wifi = { version = "0.11.0", default-features=false, features = [
esp-wifi = { version = "0.12.0", default-features=false, features = [
#REPLACE esp32c6 mcu
"esp32c6",
"utils",
Expand All @@ -70,35 +71,32 @@ esp-wifi = { version = "0.11.0", default-features=false, features = [
#ENDIF
] }
heapless = { version = "0.8.0", default-features = false }
smoltcp = { version = "0.11.0", default-features = false, features = [
smoltcp = { version = "0.12.0", default-features = false, features = [
"medium-ethernet",
"proto-dhcpv4",
"proto-igmp",
"proto-ipv4",
"socket-dhcpv4",
"socket-icmp",
"socket-raw",
"socket-tcp",
"socket-udp",
] }
edge-dhcp = { version = "0.5.0", git = "https://github.com/bugadani/edge-net", rev = "b72678e15bb7c6e72809df235778bb7b48ac146d" }
edge-raw = { version = "0.5.0", git = "https://github.com/bugadani/edge-net", rev = "b72678e15bb7c6e72809df235778bb7b48ac146d" }
edge-nal = { version = "0.5.0", git = "https://github.com/bugadani/edge-net", rev = "b72678e15bb7c6e72809df235778bb7b48ac146d" }
edge-nal-embassy = { version = "0.5.0", git = "https://github.com/bugadani/edge-net", rev = "b72678e15bb7c6e72809df235778bb7b48ac146d" }
#ENDIF
#IF option("ble")
#+bleps = { git = "https://github.com/bjoernQ/bleps", package = "bleps", rev = "a5148d8ae679e021b78f53fd33afb8bb35d0b62e", features = [ "macros", "async"] }
#ENDIF
#IF option("probe-rs")
#+defmt = "0.3.8"
#+defmt = "0.3.10"
#+defmt-rtt = "0.4.1"
#ENDIF
#IF option("embassy")
embassy-executor = { version = "0.6.0", features = [
"task-arena-size-12288",
embassy-executor = { version = "0.7.0", features = [
"task-arena-size-20480",
#IF option("probe-rs")
"defmt"
#ENDIF
] }
embassy-time = { version = "0.3.1", features = ["generic-queue-8"] }
embassy-time = { version = "0.4.0", features = ["generic-queue-8"] }
#REPLACE esp32c6 mcu
esp-hal-embassy = { version = "0.5.0", features = ["esp32c6"] }
esp-hal-embassy = { version = "0.6.0", features = ["esp32c6"] }
static_cell = { version = "2.1.0", features = ["nightly"] }
#ENDIF
critical-section = "1.2.0"
Expand Down
17 changes: 6 additions & 11 deletions template/src/bin/async_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![no_main]

use esp_backtrace as _;
use esp_hal::prelude::*;
use esp_hal::clock::CpuClock;
//IF option("probe-rs")
//+ use defmt_rtt as _;
//+ use defmt::info;
Expand All @@ -19,16 +19,13 @@ use embassy_time::{Duration, Timer};
extern crate alloc;
//ENDIF

#[main]
#[esp_hal_embassy::main]
async fn main(spawner: Spawner) {
//REPLACE generate-version generate-version
// generator version: generate-version

let peripherals = esp_hal::init({
let mut config = esp_hal::Config::default();
config.cpu_clock = CpuClock::max();
config
});
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
let peripherals = esp_hal::init(config);

//IF option("alloc")
esp_alloc::heap_allocator!(72 * 1024);
Expand All @@ -39,8 +36,7 @@ async fn main(spawner: Spawner) {
//ENDIF

//IF !option("esp32")
let timer0 = esp_hal::timer::systimer::SystemTimer::new(peripherals.SYSTIMER)
.split::<esp_hal::timer::systimer::Target>();
let timer0 = esp_hal::timer::systimer::SystemTimer::new(peripherals.SYSTIMER);
esp_hal_embassy::init(timer0.alarm0);
//ELSE
let timer0 = esp_hal::timer::timg::TimerGroup::new(peripherals.TIMG1);
Expand All @@ -67,6 +63,5 @@ async fn main(spawner: Spawner) {
Timer::after(Duration::from_secs(1)).await;
}

// for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/v0.22.0/examples/src/bin

// for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/v0.23.0/examples/src/bin
}
19 changes: 8 additions & 11 deletions template/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![no_main]

use esp_backtrace as _;
use esp_hal::{delay::Delay, prelude::*};
use esp_hal::{clock::CpuClock, delay::Delay, main};
//IF option("wifi") || option("ble")
use esp_hal::timer::timg::TimerGroup;
//ENDIF
Expand All @@ -19,20 +19,18 @@ use log::info;
extern crate alloc;
//ENDIF

#[entry]
#[main]
fn main() -> ! {
//REPLACE generate-version generate-version
// generator version: generate-version

let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
//IF option("wifi") || option("ble")
let peripherals = esp_hal::init({
let peripherals = esp_hal::init(config);
//ELSE
//+let _peripherals = esp_hal::init({
//+let _peripherals = esp_hal::init(config);
//ENDIF
let mut config = esp_hal::Config::default();
config.cpu_clock = CpuClock::max();
config
});

//IF !option("probe-rs")
esp_println::logger::init_logger_from_env();
//ENDIF
Expand All @@ -54,9 +52,8 @@ fn main() -> ! {
let delay = Delay::new();
loop {
info!("Hello world!");
delay.delay(500.millis());
delay.delay_millis(500);
}

// for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/v0.22.0/examples/src/bin

// for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/v0.23.0/examples/src/bin
}

0 comments on commit 99a30ed

Please sign in to comment.