mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
fix(hal): fix the issue of dual-core contention for RTC_CNTL regs
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "hal/gpio_hal.h"
|
||||
#include "esp_private/esp_gpio_reserve.h"
|
||||
#include "esp_private/io_mux.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
|
||||
#if (SOC_RTCIO_PIN_COUNT > 0)
|
||||
#include "hal/rtc_io_hal.h"
|
||||
@@ -40,6 +41,12 @@ static const char *GPIO_TAG = "gpio";
|
||||
#define GPIO_RTCIO_ARE_INDEPENDENT 1
|
||||
#endif
|
||||
|
||||
#if SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS
|
||||
#define RTC_CNTL_ATOMIC() PERIPH_RCC_ATOMIC()
|
||||
#else
|
||||
#define RTC_CNTL_ATOMIC()
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
gpio_isr_t fn; /*!< isr function */
|
||||
void *args; /*!< isr function args */
|
||||
@@ -784,14 +791,18 @@ esp_err_t gpio_hold_dis(gpio_num_t gpio_num)
|
||||
void gpio_deep_sleep_hold_en(void)
|
||||
{
|
||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
gpio_hal_deep_sleep_hold_en(gpio_context.gpio_hal);
|
||||
RTC_CNTL_ATOMIC() {
|
||||
gpio_hal_deep_sleep_hold_en(gpio_context.gpio_hal);
|
||||
}
|
||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
}
|
||||
|
||||
void gpio_deep_sleep_hold_dis(void)
|
||||
{
|
||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
gpio_hal_deep_sleep_hold_dis(gpio_context.gpio_hal);
|
||||
RTC_CNTL_ATOMIC() {
|
||||
gpio_hal_deep_sleep_hold_dis(gpio_context.gpio_hal);
|
||||
}
|
||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
}
|
||||
#endif //!SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP
|
||||
@@ -803,7 +814,9 @@ esp_err_t IRAM_ATTR gpio_force_hold_all()
|
||||
rtc_gpio_force_hold_en_all();
|
||||
#endif
|
||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
gpio_hal_force_hold_all();
|
||||
RTC_CNTL_ATOMIC() {
|
||||
gpio_hal_force_hold_all();
|
||||
}
|
||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -811,7 +824,9 @@ esp_err_t IRAM_ATTR gpio_force_hold_all()
|
||||
esp_err_t IRAM_ATTR gpio_force_unhold_all()
|
||||
{
|
||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
gpio_hal_force_unhold_all();
|
||||
RTC_CNTL_ATOMIC() {
|
||||
gpio_hal_force_unhold_all();
|
||||
}
|
||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
#if SOC_RTCIO_HOLD_SUPPORTED
|
||||
rtc_gpio_force_hold_dis_all();
|
||||
|
||||
Reference in New Issue
Block a user