diff --git a/esp-hal/src/system.rs b/esp-hal/src/system.rs index 96e80b87a3f..4f9ac9064fd 100755 --- a/esp-hal/src/system.rs +++ b/esp-hal/src/system.rs @@ -141,6 +141,9 @@ pub enum Peripheral { /// LCD Camera peripheral. #[cfg(lcd_cam)] LcdCam, + /// Systimer peripheral. + #[cfg(systimer)] + Systimer, } /// The `DPORT`/`PCR`/`SYSTEM` peripheral split into its different logical @@ -540,6 +543,11 @@ impl PeripheralClockControl { perip_clk_en1.modify(|_, w| w.lcd_cam_clk_en().set_bit()); perip_rst_en1.modify(|_, w| w.lcd_cam_rst().clear_bit()); } + #[cfg(systimer)] + Peripheral::Systimer => { + perip_clk_en0.modify(|_, w| w.systimer_clk_en().set_bit()); + perip_rst_en0.modify(|_, w| w.systimer_rst().clear_bit()); + } }); } @@ -744,6 +752,11 @@ impl PeripheralClockControl { perip_rst_en1.modify(|_, w| w.lcd_cam_rst().set_bit()); perip_rst_en1.modify(|_, w| w.lcd_cam_rst().clear_bit()); } + #[cfg(systimer)] + Peripheral::Systimer => { + perip_rst_en0.modify(|_, w| w.systimer_rst().set_bit()); + perip_rst_en0.modify(|_, w| w.systimer_rst().clear_bit()); + } }); } } @@ -962,6 +975,15 @@ impl PeripheralClockControl { .trace_conf() .modify(|_, w| w.trace_rst_en().clear_bit()); } + #[cfg(systimer)] + Peripheral::Systimer => { + system + .systimer_conf() + .modify(|_, w| w.systimer_clk_en().set_bit()); + system + .systimer_conf() + .modify(|_, w| w.systimer_rst_en().clear_bit()); + } } } @@ -1154,6 +1176,15 @@ impl PeripheralClockControl { .trace_conf() .modify(|_, w| w.trace_rst_en().clear_bit()); } + #[cfg(systimer)] + Peripheral::Systimer => { + system + .systimer_conf() + .modify(|_, w| w.systimer_rst_en().set_bit()); + system + .systimer_conf() + .modify(|_, w| w.systimer_rst_en().clear_bit()); + } } } } diff --git a/esp-hal/src/timer/systimer.rs b/esp-hal/src/timer/systimer.rs index ed7969e1a86..d2e36f38179 100644 --- a/esp-hal/src/timer/systimer.rs +++ b/esp-hal/src/timer/systimer.rs @@ -81,6 +81,7 @@ use crate::{ interrupt::{self, InterruptHandler}, peripheral::Peripheral, peripherals::{Interrupt, SYSTIMER}, + system::{Peripheral as PeripheralEnable, PeripheralClockControl}, Async, Blocking, Cpu, @@ -145,6 +146,9 @@ impl<'d> SystemTimer<'d> { /// Create a new instance. pub fn new(_systimer: impl Peripheral
+ 'd) -> Self {
+ // Don't reset Systimer as it will break `current_time`, only enable it
+ PeripheralClockControl::enable(PeripheralEnable::Systimer);
+
#[cfg(soc_etm)]
etm::enable_etm();
diff --git a/hil-test/Cargo.toml b/hil-test/Cargo.toml
index c8444811cba..fad3a4f8f10 100644
--- a/hil-test/Cargo.toml
+++ b/hil-test/Cargo.toml
@@ -175,6 +175,10 @@ p256 = { version = "0.13.2", default-features = false, features =
sha1 = { version = "0.10.6", default-features = false }
sha2 = { version = "0.10.8", default-features = false }
+[build-dependencies]
+esp-build = { version = "0.1.0", path = "../esp-build" }
+esp-metadata = { version = "0.2.0", path = "../esp-metadata" }
+
[features]
default = ["async", "embassy"]
@@ -232,3 +236,6 @@ incremental = false
opt-level = 3
lto = "fat"
overflow-checks = false
+
+[lints.rust]
+unexpected_cfgs = "allow"
diff --git a/hil-test/build.rs b/hil-test/build.rs
new file mode 100644
index 00000000000..1c7ecfc2ff6
--- /dev/null
+++ b/hil-test/build.rs
@@ -0,0 +1,41 @@
+use std::{error::Error, str::FromStr};
+
+use esp_build::assert_unique_used_features;
+use esp_metadata::{Chip, Config};
+
+fn main() -> Result<(), Box