fix(hal): fix the issue of dual-core contention for RTC_CNTL regs

This commit is contained in:
hebinglin
2026-03-02 14:29:08 +08:00
parent 926523d24d
commit e2e1aa4502
21 changed files with 256 additions and 55 deletions
+16 -5
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2016-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2016-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -19,8 +19,15 @@
#include "sys/lock.h"
#include "esp_private/rtc_ctrl.h"
#include "esp_private/critical_section.h"
#include "esp_private/periph_ctrl.h"
#include "esp_attr.h"
#if SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS
#define RTC_CNTL_ATOMIC() PERIPH_RCC_ATOMIC()
#else
#define RTC_CNTL_ATOMIC()
#endif
#ifndef NDEBUG
// Enable built-in checks in queue.h in debug builds
@@ -188,8 +195,10 @@ IRAM_ATTR void rtc_isr_noniram_disable(uint32_t cpu)
{
#if SOC_LP_PERIPH_SHARE_INTERRUPT // TODO: IDF-8008
if (rtc_isr_cpu == cpu) {
rtc_intr_enabled |= RTCCNTL.int_ena.val;
RTCCNTL.int_ena.val &= rtc_intr_cache;
RTC_CNTL_ATOMIC() {
rtc_intr_enabled |= RTCCNTL.int_ena.val;
RTCCNTL.int_ena.val &= rtc_intr_cache;
}
}
#endif
}
@@ -198,8 +207,10 @@ IRAM_ATTR void rtc_isr_noniram_enable(uint32_t cpu)
{
#if SOC_LP_PERIPH_SHARE_INTERRUPT // TODO: IDF-8008
if (rtc_isr_cpu == cpu) {
RTCCNTL.int_ena.val = rtc_intr_enabled;
rtc_intr_enabled = 0;
RTC_CNTL_ATOMIC() {
RTCCNTL.int_ena.val = rtc_intr_enabled;
rtc_intr_enabled = 0;
}
}
#endif
}