Skip to content

Commit

Permalink
Compatibility with ESP-IDF V5
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed May 1, 2022
1 parent 1edcce2 commit df907d5
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "esp-idf-hal"
version = "0.37.1"
version = "0.37.2"
authors = ["sapir <yasapir@gmail.com>", "Ivan Markov <ivan.markov@gmail.com>"]
edition = "2018"
resolver = "2"
Expand Down Expand Up @@ -29,7 +29,7 @@ mutex-trait = { version = "0.2", optional = true, default-features = false }
embedded-hal = "=1.0.0-alpha.8"
embedded-hal-0-2 = { package = "embedded-hal", version = "0.2.7", features = ["unproven"] }
embedded-svc = { version = "0.21", optional = true, default-features = false }
esp-idf-sys = { version = "0.31.1", optional = true, default-features = false, features = ["native"] }
esp-idf-sys = { version = "0.31.2", optional = true, default-features = false, features = ["native"] }
critical-section = { version = "0.2.5", optional = true, features = ["custom-impl"] }
embassy = { version = "0", optional = true }
# The real version is this one and it needs to be patched into the binary crate:
Expand All @@ -41,4 +41,4 @@ anyhow = "1"

[dev-dependencies]
anyhow = "1"
esp-idf-sys = { version = "0.31.1", features = ["native", "binstart"] }
esp-idf-sys = { version = "0.31.2", features = ["native", "binstart"] }
4 changes: 4 additions & 0 deletions src/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ pub mod task {
if let Some(yielder) = super::get_isr_yielder() {
yielder();
} else {
#[cfg(esp_idf_version_major = "4")]
vPortEvaluateYieldFromISR(0);

#[cfg(esp_idf_version_major = "5")]
_frxt_setup_switch();
}
}
} else {
Expand Down
58 changes: 49 additions & 9 deletions src/ulp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ impl Default for SleepTimer {
}

#[cfg(any(
all(esp32, esp_idf_esp32_ulp_coproc_enabled),
all(
not(esp_idf_version_major = "4"),
esp_idf_ulp_coproc_enabled,
esp_idf_ulp_coproc_type_fsm
),
all(esp_idf_version_major = "4", esp32, esp_idf_esp32_ulp_coproc_enabled),
all(
esp_idf_version_major = "4",
esp32s2,
esp_idf_esp32s2_ulp_coproc_enabled,
not(esp_idf_esp32s2_ulp_coproc_riscv)
),
all(
esp_idf_version_major = "4",
esp32s3,
esp_idf_esp32s3_ulp_coproc_enabled,
not(esp_idf_esp32s3_ulp_coproc_riscv)
Expand All @@ -37,13 +44,20 @@ pub struct Word {
}

#[cfg(any(
all(esp32, esp_idf_esp32_ulp_coproc_enabled),
all(
not(esp_idf_version_major = "4"),
esp_idf_ulp_coproc_enabled,
esp_idf_ulp_coproc_type_fsm
),
all(esp_idf_version_major = "4", esp32, esp_idf_esp32_ulp_coproc_enabled),
all(
esp_idf_version_major = "4",
esp32s2,
esp_idf_esp32s2_ulp_coproc_enabled,
not(esp_idf_esp32s2_ulp_coproc_riscv)
),
all(
esp_idf_version_major = "4",
esp32s3,
esp_idf_esp32s3_ulp_coproc_enabled,
not(esp_idf_esp32s3_ulp_coproc_riscv)
Expand Down Expand Up @@ -77,9 +91,18 @@ impl ULP {
}

#[cfg(any(
all(esp32, esp_idf_esp32_ulp_coproc_enabled),
all(esp32s2, esp_idf_esp32s2_ulp_coproc_enabled),
all(esp32s3, esp_idf_esp32s3_ulp_coproc_enabled)
all(not(esp_idf_version_major = "4"), esp_idf_ulp_coproc_enabled),
all(esp_idf_version_major = "4", esp32, esp_idf_esp32_ulp_coproc_enabled),
all(
esp_idf_version_major = "4",
esp32s2,
esp_idf_esp32s2_ulp_coproc_enabled
),
all(
esp_idf_version_major = "4",
esp32s3,
esp_idf_esp32s3_ulp_coproc_enabled
)
))]
impl ULP {
const RTC_SLOW_MEM: u32 = 0x5000_0000_u32;
Expand All @@ -88,15 +111,18 @@ impl ULP {

pub const MEM_START: *mut core::ffi::c_void = Self::RTC_SLOW_MEM as _;

#[cfg(esp32)]
#[cfg(all(esp32, esp_idf_version_major = "4"))]
pub const MEM_SIZE: usize = esp_idf_sys::CONFIG_ESP32_ULP_COPROC_RESERVE_MEM as _;

#[cfg(esp32s2)]
#[cfg(all(esp32s2, esp_idf_version_major = "4"))]
pub const MEM_SIZE: usize = esp_idf_sys::CONFIG_ESP32S2_ULP_COPROC_RESERVE_MEM as _;

#[cfg(esp32s3)]
#[cfg(all(esp32s3, esp_idf_version_major = "4"))]
pub const MEM_SIZE: usize = esp_idf_sys::CONFIG_ESP32S3_ULP_COPROC_RESERVE_MEM as _;

#[cfg(not(esp_idf_version_major = "4"))]
pub const MEM_SIZE: usize = esp_idf_sys::CONFIG_ULP_COPROC_RESERVE_MEM as _;

#[cfg(esp32)]
const TIMER_REG: *mut u32 = esp_idf_sys::RTC_CNTL_STATE0_REG as _;

Expand Down Expand Up @@ -170,13 +196,20 @@ impl ULP {
}

#[cfg(any(
all(esp32, esp_idf_esp32_ulp_coproc_enabled),
all(
not(esp_idf_version_major = "4"),
esp_idf_ulp_coproc_enabled,
esp_idf_ulp_coproc_type_fsm
),
all(esp_idf_version_major = "4", esp32, esp_idf_esp32_ulp_coproc_enabled),
all(
esp_idf_version_major = "4",
esp32s2,
esp_idf_esp32s2_ulp_coproc_enabled,
not(esp_idf_esp32s2_ulp_coproc_riscv)
),
all(
esp_idf_version_major = "4",
esp32s3,
esp_idf_esp32s3_ulp_coproc_enabled,
not(esp_idf_esp32s3_ulp_coproc_riscv)
Expand Down Expand Up @@ -266,11 +299,18 @@ impl ULP {

#[cfg(any(
all(
not(esp_idf_version_major = "4"),
esp_idf_ulp_coproc_enabled,
not(esp_idf_ulp_coproc_type_fsm)
),
all(
esp_idf_version_major = "4",
esp32s2,
esp_idf_esp32s2_ulp_coproc_enabled,
esp_idf_esp32s2_ulp_coproc_riscv
),
all(
esp_idf_version_major = "4",
esp32s3,
esp_idf_esp32s3_ulp_coproc_enabled,
esp_idf_esp32s3_ulp_coproc_riscv
Expand Down

0 comments on commit df907d5

Please sign in to comment.