Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Use unified esp-hal (#149)
Browse files Browse the repository at this point in the history
* feat: Use unified esp-hal

* build: Use released esp-hal

* style: Format dependencies

* build: Use esp-wifi release
  • Loading branch information
SergioGasquez authored Mar 12, 2024
1 parent 2f269b1 commit 0e2b0d7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
33 changes: 24 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]
{{ mcu }}-hal = "{{ hal_version }}"
esp-backtrace = { version = "0.11.0", features = ["{{ mcu }}", "panic-handler", "exception-handler", "println"] }
esp-backtrace = { version = "0.11.0", features = [
"{{ mcu }}",
"exception-handler",
"panic-handler",
"println",
] }
esp-hal = { version = "0.16.0", features = [ "{{ mcu }}" ] }
{% if logging -%}
esp-println = { version = "0.9.0", features = ["{{ mcu }}", "log"] }
log = { version = "0.4.20" }
Expand All @@ -18,18 +23,28 @@ esp-println = { version = "0.9.0", features = ["{{ mcu }}"] }
esp-alloc = { version = "0.3.0" }
{% endif -%}
{% if wifi -%}
esp-wifi = { version = "0.3.0", features = ["{{ mcu }}", "wifi"] }
smoltcp = { version = "0.10.0", default-features=false, features = ["proto-igmp", "proto-ipv4", "socket-tcp", "socket-icmp", "socket-udp", "medium-ethernet", "proto-dhcpv4", "socket-raw", "socket-dhcpv4"] }
embedded-svc = { version = "0.26.1", default-features = false, features = [] }
embedded-io = "0.6.1"
esp-wifi = { version = "0.4.0", features = [
"{{ mcu }}",
"phy-enable-usb",
"utils",
"wifi-default",
] }
heapless = { version = "0.8.0", default-features = false }
smoltcp = { version = "0.10.0", default-features = false, features = [
"medium-ethernet",
"proto-dhcpv4",
"proto-igmp",
"proto-ipv4",
"socket-dhcpv4",
"socket-icmp",
"socket-raw",
"socket-tcp",
"socket-udp",
] }
{% endif -%}

{% if mcu == "esp32" or mcu == "esp32c2" %}
[features]
default = ["{{ mcu }}-hal/xtal-40mhz"]
{% endif %}

[profile.dev]
# Rust debug is too slow.
# For debug builds always builds with some optimization
Expand Down
8 changes: 0 additions & 8 deletions pre-script.rhai
Original file line number Diff line number Diff line change
@@ -1,45 +1,37 @@
let metadata = #{
// Xtensa devices:
esp32: #{
hal_version: "0.18.0",
wokwi_board: "board-esp32-devkit-c-v4",
},
esp32s2: #{
hal_version: "0.15.0",
wokwi_board: "board-esp32-s2-devkitm-1",
},
esp32s3: #{
hal_version: "0.15.0",
wokwi_board: "board-esp32-s3-devkitc-1",
},

// RISC-V devices:
esp32c2: #{
extensions: "imc",
hal_version: "0.13.0",
wokwi_board: "",
},
esp32c3: #{
extensions: "imc",
hal_version: "0.15.0",
wokwi_board: "board-esp32-c3-devkitm-1",
},
esp32c6: #{
extensions: "imac",
hal_version: "0.8.0",
wokwi_board: "board-esp32-c6-devkitc-1",
},
esp32h2: #{
extensions: "imac",
hal_version: "0.6.0",
wokwi_board: "board-esp32-h2-devkitm-1",
},
};

let mcu = variable::get("mcu");
let meta = metadata.get(mcu);

variable::set("hal_version", meta.get("hal_version"));
variable::set("wokwi_board", meta.get("wokwi_board"));

if mcu in ["esp32", "esp32s2", "esp32s3"] {
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
extern crate alloc;
use core::mem::MaybeUninit;
{% endif -%}
use {{ mcu }}_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, Delay};
use esp_backtrace as _;
use esp_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, Delay};
use esp_println::println;

{% if wifi -%}
use esp_wifi::{initialize, EspWifiInitFor};

{% if arch == "riscv" -%}
use {{ mcu }}_hal::{systimer::SystemTimer, Rng};
use esp_hal::{systimer::SystemTimer, Rng};
{% else -%}
use {{ mcu }}_hal::{timer::TimerGroup, Rng};
use esp_hal::{timer::TimerGroup, Rng};
{% endif -%}
{% endif -%}

Expand Down

0 comments on commit 0e2b0d7

Please sign in to comment.