From a19fcfaef93885bcdf05d17244af782d3e877942 Mon Sep 17 00:00:00 2001 From: ice Date: Wed, 6 Dec 2023 11:31:10 +0800 Subject: [PATCH 1/5] 1.fix compile error for esp32c3 --- esp-wifi/src/common_adapter/common_adapter_esp32c3.rs | 8 ++++---- esp-wifi/src/timer/riscv.rs | 4 ++-- esp-wifi/src/wifi/os_adapter_esp32c3.rs | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/esp-wifi/src/common_adapter/common_adapter_esp32c3.rs b/esp-wifi/src/common_adapter/common_adapter_esp32c3.rs index b9d8ba15..bbd5f587 100644 --- a/esp-wifi/src/common_adapter/common_adapter_esp32c3.rs +++ b/esp-wifi/src/common_adapter/common_adapter_esp32c3.rs @@ -39,18 +39,18 @@ pub(crate) fn enable_wifi_power_domain() { let syscon = &*crate::hal::peripherals::APB_CTRL::ptr(); rtc_cntl - .dig_pwc() + .dig_pwc .modify(|_, w| w.wifi_force_pd().clear_bit()); syscon - .wifi_rst_en() + .wifi_rst_en .modify(|r, w| w.bits(r.bits() | MODEM_RESET_FIELD_WHEN_PU)); syscon - .wifi_rst_en() + .wifi_rst_en .modify(|r, w| w.bits(r.bits() & !MODEM_RESET_FIELD_WHEN_PU)); rtc_cntl - .dig_iso() + .dig_iso .modify(|_, w| w.wifi_force_iso().clear_bit()); } } diff --git a/esp-wifi/src/timer/riscv.rs b/esp-wifi/src/timer/riscv.rs index 53cf17c8..227898fa 100644 --- a/esp-wifi/src/timer/riscv.rs +++ b/esp-wifi/src/timer/riscv.rs @@ -72,7 +72,7 @@ fn FROM_CPU_INTR3(trap_frame: &mut TrapFrame) { unsafe { // clear FROM_CPU_INTR3 (&*SystemPeripheral::PTR) - .cpu_intr_from_cpu_3() + .cpu_intr_from_cpu_3 .modify(|_, w| w.cpu_intr_from_cpu_3().clear_bit()); } @@ -90,7 +90,7 @@ fn FROM_CPU_INTR3(trap_frame: &mut TrapFrame) { pub fn yield_task() { unsafe { (&*SystemPeripheral::PTR) - .cpu_intr_from_cpu_3() + .cpu_intr_from_cpu_3 .modify(|_, w| w.cpu_intr_from_cpu_3().set_bit()); } } diff --git a/esp-wifi/src/wifi/os_adapter_esp32c3.rs b/esp-wifi/src/wifi/os_adapter_esp32c3.rs index 57da8e68..646e658f 100644 --- a/esp-wifi/src/wifi/os_adapter_esp32c3.rs +++ b/esp-wifi/src/wifi/os_adapter_esp32c3.rs @@ -3,7 +3,7 @@ use crate::hal::{peripherals, riscv}; pub(crate) fn chip_ints_on(mask: u32) { unsafe { (*peripherals::INTERRUPT_CORE0::PTR) - .cpu_int_enable() + .cpu_int_enable .modify(|r, w| w.bits(r.bits() | mask)); } } @@ -11,7 +11,7 @@ pub(crate) fn chip_ints_on(mask: u32) { pub(crate) fn chip_ints_off(mask: u32) { unsafe { (*peripherals::INTERRUPT_CORE0::PTR) - .cpu_int_enable() + .cpu_int_enable .modify(|r, w| w.bits(r.bits() & !mask)); } } From 9de66e6f78a91232be70a4335f8e03f696e102ec Mon Sep 17 00:00:00 2001 From: ice Date: Wed, 6 Dec 2023 15:16:59 +0800 Subject: [PATCH 2/5] Fix affect the esp32c2 compile --- esp-wifi/src/timer/riscv.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/esp-wifi/src/timer/riscv.rs b/esp-wifi/src/timer/riscv.rs index 227898fa..c5b9a4b3 100644 --- a/esp-wifi/src/timer/riscv.rs +++ b/esp-wifi/src/timer/riscv.rs @@ -71,9 +71,14 @@ fn SYSTIMER_TARGET0(trap_frame: &mut TrapFrame) { fn FROM_CPU_INTR3(trap_frame: &mut TrapFrame) { unsafe { // clear FROM_CPU_INTR3 + #[cfg(feature = "esp32c2")] (&*SystemPeripheral::PTR) - .cpu_intr_from_cpu_3 + .cpu_intr_from_cpu_3() .modify(|_, w| w.cpu_intr_from_cpu_3().clear_bit()); + #[cfg(feature = "esp32c3")] + (&*SystemPeripheral::PTR) + .cpu_intr_from_cpu_3 + .modify(|_, w| w.cpu_intr_from_cpu_3().clear_bit()); } critical_section::with(|cs| { @@ -89,6 +94,11 @@ fn FROM_CPU_INTR3(trap_frame: &mut TrapFrame) { pub fn yield_task() { unsafe { + #[cfg(feature = "esp32c2")] + (&*SystemPeripheral::PTR) + .cpu_intr_from_cpu_3() + .modify(|_, w| w.cpu_intr_from_cpu_3().set_bit()); + #[cfg(feature = "esp32c3")] (&*SystemPeripheral::PTR) .cpu_intr_from_cpu_3 .modify(|_, w| w.cpu_intr_from_cpu_3().set_bit()); From feb23406ed2b4112b272f246ee39293233773b80 Mon Sep 17 00:00:00 2001 From: ice Date: Wed, 6 Dec 2023 15:23:15 +0800 Subject: [PATCH 3/5] Fix affected esp32c2 compile error --- esp-wifi/src/timer/riscv.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esp-wifi/src/timer/riscv.rs b/esp-wifi/src/timer/riscv.rs index c5b9a4b3..1f691a88 100644 --- a/esp-wifi/src/timer/riscv.rs +++ b/esp-wifi/src/timer/riscv.rs @@ -75,7 +75,7 @@ fn FROM_CPU_INTR3(trap_frame: &mut TrapFrame) { (&*SystemPeripheral::PTR) .cpu_intr_from_cpu_3() .modify(|_, w| w.cpu_intr_from_cpu_3().clear_bit()); - #[cfg(feature = "esp32c3")] + #[cfg(not(feature = "esp32c2"))] (&*SystemPeripheral::PTR) .cpu_intr_from_cpu_3 .modify(|_, w| w.cpu_intr_from_cpu_3().clear_bit()); @@ -98,7 +98,7 @@ pub fn yield_task() { (&*SystemPeripheral::PTR) .cpu_intr_from_cpu_3() .modify(|_, w| w.cpu_intr_from_cpu_3().set_bit()); - #[cfg(feature = "esp32c3")] + #[cfg(not(feature = "esp32c2"))] (&*SystemPeripheral::PTR) .cpu_intr_from_cpu_3 .modify(|_, w| w.cpu_intr_from_cpu_3().set_bit()); From ecdcb086e409745bfb71af8131b57f02abc595fe Mon Sep 17 00:00:00 2001 From: ice Date: Wed, 6 Dec 2023 15:29:27 +0800 Subject: [PATCH 4/5] Format riscv.rs --- esp-wifi/src/timer/riscv.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esp-wifi/src/timer/riscv.rs b/esp-wifi/src/timer/riscv.rs index 1f691a88..4fb651f6 100644 --- a/esp-wifi/src/timer/riscv.rs +++ b/esp-wifi/src/timer/riscv.rs @@ -77,8 +77,8 @@ fn FROM_CPU_INTR3(trap_frame: &mut TrapFrame) { .modify(|_, w| w.cpu_intr_from_cpu_3().clear_bit()); #[cfg(not(feature = "esp32c2"))] (&*SystemPeripheral::PTR) - .cpu_intr_from_cpu_3 - .modify(|_, w| w.cpu_intr_from_cpu_3().clear_bit()); + .cpu_intr_from_cpu_3 + .modify(|_, w| w.cpu_intr_from_cpu_3().clear_bit()); } critical_section::with(|cs| { From bc7ae5657a6b51e9912752c6dc6a3cc9398769be Mon Sep 17 00:00:00 2001 From: ice Date: Wed, 6 Dec 2023 16:02:08 +0800 Subject: [PATCH 5/5] Add #[cfg(feature = "esp32c3")] --- esp-wifi/src/timer/riscv.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/esp-wifi/src/timer/riscv.rs b/esp-wifi/src/timer/riscv.rs index 4fb651f6..9c79464c 100644 --- a/esp-wifi/src/timer/riscv.rs +++ b/esp-wifi/src/timer/riscv.rs @@ -71,13 +71,13 @@ fn SYSTIMER_TARGET0(trap_frame: &mut TrapFrame) { fn FROM_CPU_INTR3(trap_frame: &mut TrapFrame) { unsafe { // clear FROM_CPU_INTR3 - #[cfg(feature = "esp32c2")] + #[cfg(feature = "esp32c3")] (&*SystemPeripheral::PTR) - .cpu_intr_from_cpu_3() + .cpu_intr_from_cpu_3 .modify(|_, w| w.cpu_intr_from_cpu_3().clear_bit()); - #[cfg(not(feature = "esp32c2"))] + #[cfg(not(feature = "esp32c3"))] (&*SystemPeripheral::PTR) - .cpu_intr_from_cpu_3 + .cpu_intr_from_cpu_3() .modify(|_, w| w.cpu_intr_from_cpu_3().clear_bit()); } @@ -94,13 +94,13 @@ fn FROM_CPU_INTR3(trap_frame: &mut TrapFrame) { pub fn yield_task() { unsafe { - #[cfg(feature = "esp32c2")] + #[cfg(feature = "esp32c3")] (&*SystemPeripheral::PTR) - .cpu_intr_from_cpu_3() + .cpu_intr_from_cpu_3 .modify(|_, w| w.cpu_intr_from_cpu_3().set_bit()); - #[cfg(not(feature = "esp32c2"))] + #[cfg(not(feature = "esp32c3"))] (&*SystemPeripheral::PTR) - .cpu_intr_from_cpu_3 + .cpu_intr_from_cpu_3() .modify(|_, w| w.cpu_intr_from_cpu_3().set_bit()); } }