mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
Merge branch 'bugfix/esp_idf_s3_deepsleep_dead_v5.5' into 'release/v5.5'
fix(hal): fix the issue of dual-core contention for RTC_CNTL regs (v5.5) See merge request espressif/esp-idf!46171
This commit is contained in:
@@ -69,6 +69,8 @@
|
|||||||
|
|
||||||
#define BT_LOG_TAG "BLE_INIT"
|
#define BT_LOG_TAG "BLE_INIT"
|
||||||
|
|
||||||
|
#define RTC_CNTL_ATOMIC() PERIPH_RCC_ATOMIC()
|
||||||
|
|
||||||
#define BTDM_INIT_PERIOD (5000) /* ms */
|
#define BTDM_INIT_PERIOD (5000) /* ms */
|
||||||
|
|
||||||
/* Low Power Clock Selection */
|
/* Low Power Clock Selection */
|
||||||
@@ -804,8 +806,10 @@ void IRAM_ATTR btdm_hw_mac_power_down_wrapper(void)
|
|||||||
#if CONFIG_MAC_BB_PD
|
#if CONFIG_MAC_BB_PD
|
||||||
#if SOC_PM_SUPPORT_BT_PD
|
#if SOC_PM_SUPPORT_BT_PD
|
||||||
// Bluetooth module power down
|
// Bluetooth module power down
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
RTC_CNTL_ATOMIC() {
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
||||||
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
esp_mac_bb_power_down();
|
esp_mac_bb_power_down();
|
||||||
#endif
|
#endif
|
||||||
@@ -816,8 +820,10 @@ void IRAM_ATTR btdm_hw_mac_power_up_wrapper(void)
|
|||||||
#if CONFIG_MAC_BB_PD
|
#if CONFIG_MAC_BB_PD
|
||||||
#if SOC_PM_SUPPORT_BT_PD
|
#if SOC_PM_SUPPORT_BT_PD
|
||||||
// Bluetooth module power up
|
// Bluetooth module power up
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
RTC_CNTL_ATOMIC() {
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
||||||
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
esp_mac_bb_power_up();
|
esp_mac_bb_power_up();
|
||||||
#endif
|
#endif
|
||||||
@@ -834,8 +840,10 @@ static inline void esp_bt_power_domain_on(void)
|
|||||||
{
|
{
|
||||||
// Bluetooth module power up
|
// Bluetooth module power up
|
||||||
#if SOC_PM_SUPPORT_BT_PD
|
#if SOC_PM_SUPPORT_BT_PD
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
RTC_CNTL_ATOMIC() {
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
||||||
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
esp_wifi_bt_power_domain_on();
|
esp_wifi_bt_power_domain_on();
|
||||||
}
|
}
|
||||||
@@ -844,8 +852,10 @@ static inline void esp_bt_power_domain_off(void)
|
|||||||
{
|
{
|
||||||
// Bluetooth module power down
|
// Bluetooth module power down
|
||||||
#if SOC_PM_SUPPORT_BT_PD
|
#if SOC_PM_SUPPORT_BT_PD
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
RTC_CNTL_ATOMIC() {
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_BT_FORCE_ISO);
|
||||||
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_BT_FORCE_PD);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
esp_wifi_bt_power_domain_off();
|
esp_wifi_bt_power_domain_off();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "hal/gpio_hal.h"
|
#include "hal/gpio_hal.h"
|
||||||
#include "esp_private/esp_gpio_reserve.h"
|
#include "esp_private/esp_gpio_reserve.h"
|
||||||
#include "esp_private/io_mux.h"
|
#include "esp_private/io_mux.h"
|
||||||
|
#include "esp_private/periph_ctrl.h"
|
||||||
|
|
||||||
#if (SOC_RTCIO_PIN_COUNT > 0)
|
#if (SOC_RTCIO_PIN_COUNT > 0)
|
||||||
#include "hal/rtc_io_hal.h"
|
#include "hal/rtc_io_hal.h"
|
||||||
@@ -37,6 +38,12 @@ static const char *GPIO_TAG = "gpio";
|
|||||||
#define SOC_GPIO_SUPPORT_RTC_INDEPENDENT 0
|
#define SOC_GPIO_SUPPORT_RTC_INDEPENDENT 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS
|
||||||
|
#define RTC_CNTL_ATOMIC() PERIPH_RCC_ATOMIC()
|
||||||
|
#else
|
||||||
|
#define RTC_CNTL_ATOMIC()
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gpio_isr_t fn; /*!< isr function */
|
gpio_isr_t fn; /*!< isr function */
|
||||||
void *args; /*!< isr function args */
|
void *args; /*!< isr function args */
|
||||||
@@ -781,14 +788,18 @@ esp_err_t gpio_hold_dis(gpio_num_t gpio_num)
|
|||||||
void gpio_deep_sleep_hold_en(void)
|
void gpio_deep_sleep_hold_en(void)
|
||||||
{
|
{
|
||||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
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);
|
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpio_deep_sleep_hold_dis(void)
|
void gpio_deep_sleep_hold_dis(void)
|
||||||
{
|
{
|
||||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
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);
|
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||||
}
|
}
|
||||||
#endif //!SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP
|
#endif //!SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP
|
||||||
@@ -800,7 +811,9 @@ esp_err_t IRAM_ATTR gpio_force_hold_all()
|
|||||||
rtc_gpio_force_hold_en_all();
|
rtc_gpio_force_hold_en_all();
|
||||||
#endif
|
#endif
|
||||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
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);
|
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
@@ -808,7 +821,9 @@ esp_err_t IRAM_ATTR gpio_force_hold_all()
|
|||||||
esp_err_t IRAM_ATTR gpio_force_unhold_all()
|
esp_err_t IRAM_ATTR gpio_force_unhold_all()
|
||||||
{
|
{
|
||||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
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);
|
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||||
#if SOC_RTCIO_HOLD_SUPPORTED
|
#if SOC_RTCIO_HOLD_SUPPORTED
|
||||||
rtc_gpio_force_hold_dis_all();
|
rtc_gpio_force_hold_dis_all();
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ extern "C" {
|
|||||||
* @note User code protected by this macro should be as short as possible, because it's a critical section
|
* @note User code protected by this macro should be as short as possible, because it's a critical section
|
||||||
*/
|
*/
|
||||||
#define PERIPH_RCC_ATOMIC() \
|
#define PERIPH_RCC_ATOMIC() \
|
||||||
for (int _rc_cnt = 1, __DECLARE_RCC_ATOMIC_ENV; \
|
for (int _rc_cnt = 1, __DECLARE_RCC_ATOMIC_ENV __attribute__((unused)); \
|
||||||
_rc_cnt ? (periph_rcc_enter(), 1) : 0; \
|
_rc_cnt ? (periph_rcc_enter(), 1) : 0; \
|
||||||
periph_rcc_exit(), _rc_cnt--)
|
periph_rcc_exit(), _rc_cnt--)
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
/// @brief For simplicity and backward compatible, we are using the same spin lock for both bus clock on/off and reset
|
/// @brief For simplicity and backward compatible, we are using the same spin lock for both bus clock on/off and reset
|
||||||
/// @note We may want to split them into two spin locks in the future
|
/// @note We may want to split them into two spin locks in the future
|
||||||
static portMUX_TYPE periph_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
static portMUX_TYPE __attribute__((unused)) periph_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||||
|
|
||||||
static uint8_t ref_counts[PERIPH_MODULE_MAX] = {0};
|
static uint8_t ref_counts[PERIPH_MODULE_MAX] = {0};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2016-2026 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -18,8 +18,15 @@
|
|||||||
#include "esp_intr_alloc.h"
|
#include "esp_intr_alloc.h"
|
||||||
#include "sys/lock.h"
|
#include "sys/lock.h"
|
||||||
#include "esp_private/rtc_ctrl.h"
|
#include "esp_private/rtc_ctrl.h"
|
||||||
|
#include "esp_private/periph_ctrl.h"
|
||||||
#include "esp_attr.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
|
#ifndef NDEBUG
|
||||||
// Enable built-in checks in queue.h in debug builds
|
// Enable built-in checks in queue.h in debug builds
|
||||||
@@ -187,8 +194,10 @@ IRAM_ATTR void rtc_isr_noniram_disable(uint32_t cpu)
|
|||||||
{
|
{
|
||||||
#if SOC_LP_PERIPH_SHARE_INTERRUPT // TODO: IDF-8008
|
#if SOC_LP_PERIPH_SHARE_INTERRUPT // TODO: IDF-8008
|
||||||
if (rtc_isr_cpu == cpu) {
|
if (rtc_isr_cpu == cpu) {
|
||||||
rtc_intr_enabled |= RTCCNTL.int_ena.val;
|
RTC_CNTL_ATOMIC() {
|
||||||
RTCCNTL.int_ena.val &= rtc_intr_cache;
|
rtc_intr_enabled |= RTCCNTL.int_ena.val;
|
||||||
|
RTCCNTL.int_ena.val &= rtc_intr_cache;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -197,8 +206,10 @@ IRAM_ATTR void rtc_isr_noniram_enable(uint32_t cpu)
|
|||||||
{
|
{
|
||||||
#if SOC_LP_PERIPH_SHARE_INTERRUPT // TODO: IDF-8008
|
#if SOC_LP_PERIPH_SHARE_INTERRUPT // TODO: IDF-8008
|
||||||
if (rtc_isr_cpu == cpu) {
|
if (rtc_isr_cpu == cpu) {
|
||||||
RTCCNTL.int_ena.val = rtc_intr_enabled;
|
RTC_CNTL_ATOMIC() {
|
||||||
rtc_intr_enabled = 0;
|
RTCCNTL.int_ena.val = rtc_intr_enabled;
|
||||||
|
rtc_intr_enabled = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,6 +103,11 @@ static uint32_t* s_phy_digital_regs_mem = NULL;
|
|||||||
static uint8_t s_phy_modem_init_ref = 0;
|
static uint8_t s_phy_modem_init_ref = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS
|
||||||
|
#define RTC_CNTL_ATOMIC() PERIPH_RCC_ATOMIC()
|
||||||
|
#else
|
||||||
|
#define RTC_CNTL_ATOMIC()
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN
|
#if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN
|
||||||
#if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN_EMBED
|
#if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN_EMBED
|
||||||
@@ -425,7 +430,9 @@ void IRAM_ATTR esp_wifi_bt_power_domain_on(void)
|
|||||||
#if SOC_PM_MODEM_PD_BY_SW // TODO: [ESP32C5] IDF-8667
|
#if SOC_PM_MODEM_PD_BY_SW // TODO: [ESP32C5] IDF-8667
|
||||||
_lock_acquire(&s_wifi_bt_pd_controller.lock);
|
_lock_acquire(&s_wifi_bt_pd_controller.lock);
|
||||||
if (s_wifi_bt_pd_controller.count++ == 0) {
|
if (s_wifi_bt_pd_controller.count++ == 0) {
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_WIFI_FORCE_PD);
|
RTC_CNTL_ATOMIC() {
|
||||||
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_WIFI_FORCE_PD);
|
||||||
|
}
|
||||||
esp_rom_delay_us(10);
|
esp_rom_delay_us(10);
|
||||||
wifi_bt_common_module_enable();
|
wifi_bt_common_module_enable();
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
@@ -436,7 +443,9 @@ void IRAM_ATTR esp_wifi_bt_power_domain_on(void)
|
|||||||
SET_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, MODEM_RESET_FIELD_WHEN_PU);
|
SET_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, MODEM_RESET_FIELD_WHEN_PU);
|
||||||
CLEAR_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, MODEM_RESET_FIELD_WHEN_PU);
|
CLEAR_PERI_REG_MASK(SYSCON_WIFI_RST_EN_REG, MODEM_RESET_FIELD_WHEN_PU);
|
||||||
#endif
|
#endif
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_WIFI_FORCE_ISO);
|
RTC_CNTL_ATOMIC() {
|
||||||
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_WIFI_FORCE_ISO);
|
||||||
|
}
|
||||||
wifi_bt_common_module_disable();
|
wifi_bt_common_module_disable();
|
||||||
}
|
}
|
||||||
_lock_release(&s_wifi_bt_pd_controller.lock);
|
_lock_release(&s_wifi_bt_pd_controller.lock);
|
||||||
@@ -450,8 +459,10 @@ void esp_wifi_bt_power_domain_off(void)
|
|||||||
#if SOC_PM_MODEM_PD_BY_SW // TODO: [ESP32C5] IDF-8667
|
#if SOC_PM_MODEM_PD_BY_SW // TODO: [ESP32C5] IDF-8667
|
||||||
_lock_acquire(&s_wifi_bt_pd_controller.lock);
|
_lock_acquire(&s_wifi_bt_pd_controller.lock);
|
||||||
if (--s_wifi_bt_pd_controller.count == 0) {
|
if (--s_wifi_bt_pd_controller.count == 0) {
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_WIFI_FORCE_ISO);
|
RTC_CNTL_ATOMIC() {
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_WIFI_FORCE_PD);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_WIFI_FORCE_ISO);
|
||||||
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_WIFI_FORCE_PD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_lock_release(&s_wifi_bt_pd_controller.lock);
|
_lock_release(&s_wifi_bt_pd_controller.lock);
|
||||||
#endif // SOC_PM_MODEM_PD_BY_SW
|
#endif // SOC_PM_MODEM_PD_BY_SW
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -591,22 +591,32 @@ static inline void gpio_ll_get_drive_capability(gpio_dev_t *hw, uint32_t gpio_nu
|
|||||||
*
|
*
|
||||||
* @param hw Peripheral GPIO hardware instance address.
|
* @param hw Peripheral GPIO hardware instance address.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_deep_sleep_hold_en(gpio_dev_t *hw)
|
static inline void _gpio_ll_deep_sleep_hold_en(gpio_dev_t *hw)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_deep_sleep_hold_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_deep_sleep_hold_en(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Disable all digital gpio pad hold function during Deep-sleep.
|
* @brief Disable all digital gpio pad hold function during Deep-sleep.
|
||||||
*
|
*
|
||||||
* @param hw Peripheral GPIO hardware instance address.
|
* @param hw Peripheral GPIO hardware instance address.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_deep_sleep_hold_dis(gpio_dev_t *hw)
|
static inline void _gpio_ll_deep_sleep_hold_dis(gpio_dev_t *hw)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_deep_sleep_hold_dis(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_deep_sleep_hold_dis(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get deep sleep hold status
|
* @brief Get deep sleep hold status
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2020-2026 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -397,22 +397,32 @@ static inline void gpio_ll_get_drive_capability(gpio_dev_t *hw, uint32_t gpio_nu
|
|||||||
*
|
*
|
||||||
* @param hw Peripheral GPIO hardware instance address.
|
* @param hw Peripheral GPIO hardware instance address.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_deep_sleep_hold_en(gpio_dev_t *hw)
|
static inline void _gpio_ll_deep_sleep_hold_en(gpio_dev_t *hw)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_deep_sleep_hold_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_deep_sleep_hold_en(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Disable all digital gpio pad hold function during Deep-sleep.
|
* @brief Disable all digital gpio pad hold function during Deep-sleep.
|
||||||
*
|
*
|
||||||
* @param hw Peripheral GPIO hardware instance address.
|
* @param hw Peripheral GPIO hardware instance address.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_deep_sleep_hold_dis(gpio_dev_t *hw)
|
static inline void _gpio_ll_deep_sleep_hold_dis(gpio_dev_t *hw)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_deep_sleep_hold_dis(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_deep_sleep_hold_dis(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get deep sleep hold status
|
* @brief Get deep sleep hold status
|
||||||
*
|
*
|
||||||
@@ -537,18 +547,23 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
|||||||
* @brief Force hold all digital(VDD3P3_CPU) and rtc(VDD3P3_RTC) gpio pads.
|
* @brief Force hold all digital(VDD3P3_CPU) and rtc(VDD3P3_RTC) gpio pads.
|
||||||
* @note GPIO force hold, whether the chip in sleep mode or wakeup mode.
|
* @note GPIO force hold, whether the chip in sleep mode or wakeup mode.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_force_hold_all(void)
|
static inline void _gpio_ll_force_hold_all(void)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_PWC_REG, RTC_CNTL_PAD_FORCE_HOLD_M);
|
SET_PERI_REG_MASK(RTC_CNTL_PWC_REG, RTC_CNTL_PAD_FORCE_HOLD_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, RTC_CNTL_PWC_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_force_hold_all(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_force_hold_all(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Force unhold all digital(VDD3P3_CPU) and rtc(VDD3P3_RTC) gpio pads.
|
* @brief Force unhold all digital(VDD3P3_CPU) and rtc(VDD3P3_RTC) gpio pads.
|
||||||
* @note GPIO force unhold, whether the chip in sleep mode or wakeup mode.
|
* @note GPIO force unhold, whether the chip in sleep mode or wakeup mode.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_force_unhold_all(void)
|
static inline void _gpio_ll_force_unhold_all(void)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
||||||
@@ -556,6 +571,11 @@ static inline void gpio_ll_force_unhold_all(void)
|
|||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_PWC_REG, RTC_CNTL_PAD_FORCE_HOLD_M);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_PWC_REG, RTC_CNTL_PAD_FORCE_HOLD_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, RTC_CNTL_PWC_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_force_unhold_all(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_force_unhold_all(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enable GPIO pin used for wakeup from sleep.
|
* @brief Enable GPIO pin used for wakeup from sleep.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2020-2026 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -395,22 +395,32 @@ static inline void gpio_ll_get_drive_capability(gpio_dev_t *hw, uint32_t gpio_nu
|
|||||||
*
|
*
|
||||||
* @param hw Peripheral GPIO hardware instance address.
|
* @param hw Peripheral GPIO hardware instance address.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_deep_sleep_hold_en(gpio_dev_t *hw)
|
static inline void _gpio_ll_deep_sleep_hold_en(gpio_dev_t *hw)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_deep_sleep_hold_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_deep_sleep_hold_en(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Disable all digital gpio pad hold function during Deep-sleep.
|
* @brief Disable all digital gpio pad hold function during Deep-sleep.
|
||||||
*
|
*
|
||||||
* @param hw Peripheral GPIO hardware instance address.
|
* @param hw Peripheral GPIO hardware instance address.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_deep_sleep_hold_dis(gpio_dev_t *hw)
|
static inline void _gpio_ll_deep_sleep_hold_dis(gpio_dev_t *hw)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_deep_sleep_hold_dis(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_deep_sleep_hold_dis(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get deep sleep hold status
|
* @brief Get deep sleep hold status
|
||||||
*
|
*
|
||||||
@@ -535,18 +545,23 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
|||||||
* @brief Force hold all digital(VDD3P3_CPU) and rtc(VDD3P3_RTC) gpio pads.
|
* @brief Force hold all digital(VDD3P3_CPU) and rtc(VDD3P3_RTC) gpio pads.
|
||||||
* @note GPIO force hold, whether the chip in sleep mode or wakeup mode.
|
* @note GPIO force hold, whether the chip in sleep mode or wakeup mode.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_force_hold_all(void)
|
static inline void _gpio_ll_force_hold_all(void)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_PWC_REG, RTC_CNTL_PAD_FORCE_HOLD_M);
|
SET_PERI_REG_MASK(RTC_CNTL_PWC_REG, RTC_CNTL_PAD_FORCE_HOLD_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, RTC_CNTL_PWC_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_force_hold_all(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_force_hold_all(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Force unhold all digital(VDD3P3_CPU) and rtc(VDD3P3_RTC) gpio pads.
|
* @brief Force unhold all digital(VDD3P3_CPU) and rtc(VDD3P3_RTC) gpio pads.
|
||||||
* @note GPIO force unhold, whether the chip in sleep mode or wakeup mode.
|
* @note GPIO force unhold, whether the chip in sleep mode or wakeup mode.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_force_unhold_all(void)
|
static inline void _gpio_ll_force_unhold_all(void)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
||||||
@@ -554,6 +569,11 @@ static inline void gpio_ll_force_unhold_all(void)
|
|||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_PWC_REG, RTC_CNTL_PAD_FORCE_HOLD_M);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_PWC_REG, RTC_CNTL_PAD_FORCE_HOLD_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, RTC_CNTL_PWC_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_force_unhold_all(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_force_unhold_all(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enable GPIO pin used for wakeup from sleep.
|
* @brief Enable GPIO pin used for wakeup from sleep.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -417,22 +417,32 @@ static inline void gpio_ll_get_drive_capability(gpio_dev_t *hw, uint32_t gpio_nu
|
|||||||
*
|
*
|
||||||
* @param hw Peripheral GPIO hardware instance address.
|
* @param hw Peripheral GPIO hardware instance address.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_deep_sleep_hold_en(gpio_dev_t *hw)
|
static inline void _gpio_ll_deep_sleep_hold_en(gpio_dev_t *hw)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_deep_sleep_hold_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_deep_sleep_hold_en(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Disable all digital gpio pad hold function during Deep-sleep.
|
* @brief Disable all digital gpio pad hold function during Deep-sleep.
|
||||||
*
|
*
|
||||||
* @param hw Peripheral GPIO hardware instance address.
|
* @param hw Peripheral GPIO hardware instance address.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_deep_sleep_hold_dis(gpio_dev_t *hw)
|
static inline void _gpio_ll_deep_sleep_hold_dis(gpio_dev_t *hw)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_deep_sleep_hold_dis(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_deep_sleep_hold_dis(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get deep sleep hold status
|
* @brief Get deep sleep hold status
|
||||||
*
|
*
|
||||||
@@ -549,23 +559,33 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
|||||||
* @brief Force hold digital gpio pad.
|
* @brief Force hold digital gpio pad.
|
||||||
* @note GPIO force hold, whether the chip in sleep mode or wakeup mode.
|
* @note GPIO force hold, whether the chip in sleep mode or wakeup mode.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_force_hold_all(void)
|
static inline void _gpio_ll_force_hold_all(void)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_force_hold_all(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_force_hold_all(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Force unhold digital gpio pad.
|
* @brief Force unhold digital gpio pad.
|
||||||
* @note GPIO force unhold, whether the chip in sleep mode or wakeup mode.
|
* @note GPIO force unhold, whether the chip in sleep mode or wakeup mode.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_force_unhold_all(void)
|
static inline void _gpio_ll_force_unhold_all(void)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_CLR_DG_PAD_AUTOHOLD);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_CLR_DG_PAD_AUTOHOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_force_unhold_all(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_force_unhold_all(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enable GPIO pin used for wakeup from sleep.
|
* @brief Enable GPIO pin used for wakeup from sleep.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -418,22 +418,32 @@ static inline void gpio_ll_get_drive_capability(gpio_dev_t *hw, uint32_t gpio_nu
|
|||||||
*
|
*
|
||||||
* @param hw Peripheral GPIO hardware instance address.
|
* @param hw Peripheral GPIO hardware instance address.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_deep_sleep_hold_en(gpio_dev_t *hw)
|
static inline void _gpio_ll_deep_sleep_hold_en(gpio_dev_t *hw)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_deep_sleep_hold_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_deep_sleep_hold_en(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Disable all digital gpio pad hold function during Deep-sleep.
|
* @brief Disable all digital gpio pad hold function during Deep-sleep.
|
||||||
*
|
*
|
||||||
* @param hw Peripheral GPIO hardware instance address.
|
* @param hw Peripheral GPIO hardware instance address.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_deep_sleep_hold_dis(gpio_dev_t *hw)
|
static inline void _gpio_ll_deep_sleep_hold_dis(gpio_dev_t *hw)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_AUTOHOLD_EN_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_deep_sleep_hold_dis(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_deep_sleep_hold_dis(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get deep sleep hold status
|
* @brief Get deep sleep hold status
|
||||||
*
|
*
|
||||||
@@ -550,23 +560,33 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
|||||||
* @brief Force hold digital gpio pad.
|
* @brief Force hold digital gpio pad.
|
||||||
* @note GPIO force hold, whether the chip in sleep mode or wakeup mode.
|
* @note GPIO force hold, whether the chip in sleep mode or wakeup mode.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_force_hold_all(void)
|
static inline void _gpio_ll_force_hold_all(void)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_force_hold_all(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_force_hold_all(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Force unhold digital gpio pad.
|
* @brief Force unhold digital gpio pad.
|
||||||
* @note GPIO force unhold, whether the chip in sleep mode or wakeup mode.
|
* @note GPIO force unhold, whether the chip in sleep mode or wakeup mode.
|
||||||
*/
|
*/
|
||||||
static inline void gpio_ll_force_unhold_all(void)
|
static inline void _gpio_ll_force_unhold_all(void)
|
||||||
{
|
{
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_HOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_DG_PAD_FORCE_UNHOLD);
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_CLR_DG_PAD_AUTOHOLD);
|
SET_PERI_REG_MASK(RTC_CNTL_DIG_ISO_REG, RTC_CNTL_CLR_DG_PAD_AUTOHOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||||
|
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||||
|
/// When operating RTC_CNTL_DIG_ISO_REG, PERIPH_RCC_ATOMIC() must be used to ensure atomicity.
|
||||||
|
#define gpio_ll_force_unhold_all(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gpio_ll_force_unhold_all(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enable GPIO pin used for wakeup from sleep.
|
* @brief Enable GPIO pin used for wakeup from sleep.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -627,6 +627,10 @@ config SOC_RTCIO_WAKE_SUPPORTED
|
|||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
|
|
||||||
|
config SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS
|
||||||
|
bool
|
||||||
|
default y
|
||||||
|
|
||||||
config SOC_SDM_GROUPS
|
config SOC_SDM_GROUPS
|
||||||
int
|
int
|
||||||
default 1
|
default 1
|
||||||
|
|||||||
@@ -291,6 +291,10 @@
|
|||||||
#define SOC_RTCIO_HOLD_SUPPORTED 1
|
#define SOC_RTCIO_HOLD_SUPPORTED 1
|
||||||
#define SOC_RTCIO_WAKE_SUPPORTED 1
|
#define SOC_RTCIO_WAKE_SUPPORTED 1
|
||||||
|
|
||||||
|
/* RTC_CNTL registers on this SoC are not atomic and require software protection
|
||||||
|
* (e.g., spinlocks) when accessed from multiple cores or threads. */
|
||||||
|
#define SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS 1
|
||||||
|
|
||||||
/*-------------------------- Sigma Delta Modulator CAPS -----------------*/
|
/*-------------------------- Sigma Delta Modulator CAPS -----------------*/
|
||||||
#define SOC_SDM_GROUPS 1U
|
#define SOC_SDM_GROUPS 1U
|
||||||
#define SOC_SDM_CHANNELS_PER_GROUP 8
|
#define SOC_SDM_CHANNELS_PER_GROUP 8
|
||||||
|
|||||||
@@ -439,6 +439,10 @@ config SOC_RTC_CNTL_CPU_PD_REG_FILE_NUM
|
|||||||
int
|
int
|
||||||
default 108
|
default 108
|
||||||
|
|
||||||
|
config SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS
|
||||||
|
bool
|
||||||
|
default y
|
||||||
|
|
||||||
config SOC_RTCIO_PIN_COUNT
|
config SOC_RTCIO_PIN_COUNT
|
||||||
int
|
int
|
||||||
default 0
|
default 0
|
||||||
|
|||||||
@@ -193,6 +193,10 @@
|
|||||||
|
|
||||||
#define SOC_RTC_CNTL_CPU_PD_RETENTION_MEM_SIZE (SOC_RTC_CNTL_CPU_PD_REG_FILE_NUM * (SOC_RTC_CNTL_CPU_PD_DMA_BUS_WIDTH >> 3))
|
#define SOC_RTC_CNTL_CPU_PD_RETENTION_MEM_SIZE (SOC_RTC_CNTL_CPU_PD_REG_FILE_NUM * (SOC_RTC_CNTL_CPU_PD_DMA_BUS_WIDTH >> 3))
|
||||||
|
|
||||||
|
/* RTC_CNTL registers on this SoC are not atomic and require software protection
|
||||||
|
* (e.g., spinlocks) when accessed from multiple cores or threads. */
|
||||||
|
#define SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS 1
|
||||||
|
|
||||||
/*-------------------------- RTCIO CAPS --------------------------------------*/
|
/*-------------------------- RTCIO CAPS --------------------------------------*/
|
||||||
/* No dedicated RTCIO subsystem on ESP32-C2. RTC functions are still supported
|
/* No dedicated RTCIO subsystem on ESP32-C2. RTC functions are still supported
|
||||||
* for hold, wake & 32kHz crystal functions - via rtc_cntl_reg */
|
* for hold, wake & 32kHz crystal functions - via rtc_cntl_reg */
|
||||||
|
|||||||
@@ -651,6 +651,10 @@ config SOC_RTC_CNTL_CPU_PD_REG_FILE_NUM
|
|||||||
int
|
int
|
||||||
default 108
|
default 108
|
||||||
|
|
||||||
|
config SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS
|
||||||
|
bool
|
||||||
|
default y
|
||||||
|
|
||||||
config SOC_SLEEP_SYSTIMER_STALL_WORKAROUND
|
config SOC_SLEEP_SYSTIMER_STALL_WORKAROUND
|
||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
|
|||||||
@@ -265,6 +265,10 @@
|
|||||||
|
|
||||||
#define SOC_RTC_CNTL_CPU_PD_RETENTION_MEM_SIZE (SOC_RTC_CNTL_CPU_PD_REG_FILE_NUM * (SOC_RTC_CNTL_CPU_PD_DMA_BUS_WIDTH >> 3))
|
#define SOC_RTC_CNTL_CPU_PD_RETENTION_MEM_SIZE (SOC_RTC_CNTL_CPU_PD_REG_FILE_NUM * (SOC_RTC_CNTL_CPU_PD_DMA_BUS_WIDTH >> 3))
|
||||||
|
|
||||||
|
/* RTC_CNTL registers on this SoC are not atomic and require software protection
|
||||||
|
* (e.g., spinlocks) when accessed from multiple cores or threads. */
|
||||||
|
#define SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS 1
|
||||||
|
|
||||||
#define SOC_SLEEP_SYSTIMER_STALL_WORKAROUND 1
|
#define SOC_SLEEP_SYSTIMER_STALL_WORKAROUND 1
|
||||||
#define SOC_SLEEP_TGWDT_STOP_WORKAROUND 1
|
#define SOC_SLEEP_TGWDT_STOP_WORKAROUND 1
|
||||||
|
|
||||||
|
|||||||
@@ -407,6 +407,10 @@ config SOC_GPIO_CLOCKOUT_CHANNEL_NUM
|
|||||||
int
|
int
|
||||||
default 3
|
default 3
|
||||||
|
|
||||||
|
config SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS
|
||||||
|
bool
|
||||||
|
default y
|
||||||
|
|
||||||
config SOC_DEDIC_GPIO_OUT_CHANNELS_NUM
|
config SOC_DEDIC_GPIO_OUT_CHANNELS_NUM
|
||||||
int
|
int
|
||||||
default 8
|
default 8
|
||||||
|
|||||||
@@ -182,6 +182,10 @@
|
|||||||
#define SOC_GPIO_CLOCKOUT_BY_IO_MUX (1)
|
#define SOC_GPIO_CLOCKOUT_BY_IO_MUX (1)
|
||||||
#define SOC_GPIO_CLOCKOUT_CHANNEL_NUM (3)
|
#define SOC_GPIO_CLOCKOUT_CHANNEL_NUM (3)
|
||||||
|
|
||||||
|
/* RTC_CNTL registers on this SoC are not atomic and require software protection
|
||||||
|
* (e.g., spinlocks) when accessed from multiple cores or threads. */
|
||||||
|
#define SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS 1
|
||||||
|
|
||||||
/*-------------------------- Dedicated GPIO CAPS ---------------------------------------*/
|
/*-------------------------- Dedicated GPIO CAPS ---------------------------------------*/
|
||||||
#define SOC_DEDIC_GPIO_OUT_CHANNELS_NUM (8) /*!< 8 outward channels on each CPU core */
|
#define SOC_DEDIC_GPIO_OUT_CHANNELS_NUM (8) /*!< 8 outward channels on each CPU core */
|
||||||
#define SOC_DEDIC_GPIO_IN_CHANNELS_NUM (8) /*!< 8 inward channels on each CPU core */
|
#define SOC_DEDIC_GPIO_IN_CHANNELS_NUM (8) /*!< 8 inward channels on each CPU core */
|
||||||
|
|||||||
@@ -835,6 +835,10 @@ config SOC_RTC_CNTL_TAGMEM_PD_DMA_BUS_WIDTH
|
|||||||
int
|
int
|
||||||
default 128
|
default 128
|
||||||
|
|
||||||
|
config SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS
|
||||||
|
bool
|
||||||
|
default y
|
||||||
|
|
||||||
config SOC_RTCIO_PIN_COUNT
|
config SOC_RTCIO_PIN_COUNT
|
||||||
int
|
int
|
||||||
default 22
|
default 22
|
||||||
|
|||||||
@@ -321,6 +321,10 @@
|
|||||||
#define SOC_RTC_CNTL_TAGMEM_PD_DMA_BUS_WIDTH (128)
|
#define SOC_RTC_CNTL_TAGMEM_PD_DMA_BUS_WIDTH (128)
|
||||||
#define SOC_RTC_CNTL_TAGMEM_PD_DMA_ADDR_ALIGN (SOC_RTC_CNTL_TAGMEM_PD_DMA_BUS_WIDTH >> 3)
|
#define SOC_RTC_CNTL_TAGMEM_PD_DMA_ADDR_ALIGN (SOC_RTC_CNTL_TAGMEM_PD_DMA_BUS_WIDTH >> 3)
|
||||||
|
|
||||||
|
/* RTC_CNTL registers on this SoC are not atomic and require software protection
|
||||||
|
* (e.g., spinlocks) when accessed from multiple cores or threads. */
|
||||||
|
#define SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS 1
|
||||||
|
|
||||||
/*-------------------------- RTCIO CAPS --------------------------------------*/
|
/*-------------------------- RTCIO CAPS --------------------------------------*/
|
||||||
#define SOC_RTCIO_PIN_COUNT 22
|
#define SOC_RTCIO_PIN_COUNT 22
|
||||||
#define SOC_RTCIO_INPUT_OUTPUT_SUPPORTED 1 /* This macro indicates that the target has separate RTC IOMUX hardware feature,
|
#define SOC_RTCIO_INPUT_OUTPUT_SUPPORTED 1 /* This macro indicates that the target has separate RTC IOMUX hardware feature,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2010-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2010-2026 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -30,6 +30,13 @@
|
|||||||
|
|
||||||
#include "esp_check.h"
|
#include "esp_check.h"
|
||||||
#include "esp_private/rtc_ctrl.h"
|
#include "esp_private/rtc_ctrl.h"
|
||||||
|
#include "esp_private/periph_ctrl.h"
|
||||||
|
|
||||||
|
#if SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS
|
||||||
|
#define RTC_CNTL_ATOMIC() PERIPH_RCC_ATOMIC()
|
||||||
|
#else
|
||||||
|
#define RTC_CNTL_ATOMIC()
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
@@ -46,7 +53,10 @@ static const char* TAG = "ulp";
|
|||||||
esp_err_t ulp_isr_register(intr_handler_t fn, void *arg)
|
esp_err_t ulp_isr_register(intr_handler_t fn, void *arg)
|
||||||
{
|
{
|
||||||
ESP_RETURN_ON_FALSE(fn, ESP_ERR_INVALID_ARG, TAG, "ULP ISR is NULL");
|
ESP_RETURN_ON_FALSE(fn, ESP_ERR_INVALID_ARG, TAG, "ULP ISR is NULL");
|
||||||
REG_SET_BIT(RTC_CNTL_INT_ENA_REG, RTC_CNTL_ULP_CP_INT_ENA_M);
|
/* Enable the interrupt bit atomically to avoid race condition with other code accessing RTC_CNTL_INT_ENA_REG */
|
||||||
|
RTC_CNTL_ATOMIC() {
|
||||||
|
REG_SET_BIT(RTC_CNTL_INT_ENA_REG, RTC_CNTL_ULP_CP_INT_ENA_M);
|
||||||
|
}
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
return rtc_isr_register(fn, arg, RTC_CNTL_SAR_INT_ST_M, 0);
|
return rtc_isr_register(fn, arg, RTC_CNTL_SAR_INT_ST_M, 0);
|
||||||
#else
|
#else
|
||||||
@@ -57,7 +67,10 @@ esp_err_t ulp_isr_register(intr_handler_t fn, void *arg)
|
|||||||
esp_err_t ulp_isr_deregister(intr_handler_t fn, void *arg)
|
esp_err_t ulp_isr_deregister(intr_handler_t fn, void *arg)
|
||||||
{
|
{
|
||||||
ESP_RETURN_ON_FALSE(fn, ESP_ERR_INVALID_ARG, TAG, "ULP ISR is NULL");
|
ESP_RETURN_ON_FALSE(fn, ESP_ERR_INVALID_ARG, TAG, "ULP ISR is NULL");
|
||||||
REG_CLR_BIT(RTC_CNTL_INT_ENA_REG, RTC_CNTL_ULP_CP_INT_ENA_M);
|
/* Disable the interrupt bit atomically to avoid race condition with other code accessing RTC_CNTL_INT_ENA_REG */
|
||||||
|
RTC_CNTL_ATOMIC() {
|
||||||
|
REG_CLR_BIT(RTC_CNTL_INT_ENA_REG, RTC_CNTL_ULP_CP_INT_ENA_M);
|
||||||
|
}
|
||||||
return rtc_isr_deregister(fn, arg);
|
return rtc_isr_deregister(fn, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2020-2026 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -22,6 +22,13 @@
|
|||||||
#include "esp_rom_sys.h"
|
#include "esp_rom_sys.h"
|
||||||
#include "esp_check.h"
|
#include "esp_check.h"
|
||||||
#include "esp_private/rtc_ctrl.h"
|
#include "esp_private/rtc_ctrl.h"
|
||||||
|
#include "esp_private/periph_ctrl.h"
|
||||||
|
|
||||||
|
#if SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS
|
||||||
|
#define RTC_CNTL_ATOMIC() PERIPH_RCC_ATOMIC()
|
||||||
|
#else
|
||||||
|
#define RTC_CNTL_ATOMIC()
|
||||||
|
#endif
|
||||||
|
|
||||||
__attribute__((unused)) static const char* TAG = "ulp-riscv";
|
__attribute__((unused)) static const char* TAG = "ulp-riscv";
|
||||||
|
|
||||||
@@ -44,8 +51,10 @@ esp_err_t ulp_riscv_isr_register(intr_handler_t fn, void *arg, uint32_t mask)
|
|||||||
/* Register the RTC ISR */
|
/* Register the RTC ISR */
|
||||||
ESP_RETURN_ON_ERROR(rtc_isr_register(fn, arg, mask, 0), TAG, "rtc_isr_register() failed");
|
ESP_RETURN_ON_ERROR(rtc_isr_register(fn, arg, mask, 0), TAG, "rtc_isr_register() failed");
|
||||||
|
|
||||||
/* Enable the interrupt bits */
|
/* Enable the interrupt bits atomically to avoid race condition with other code accessing RTC_CNTL_INT_ENA_REG */
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_INT_ENA_REG, mask);
|
RTC_CNTL_ATOMIC() {
|
||||||
|
SET_PERI_REG_MASK(RTC_CNTL_INT_ENA_REG, mask);
|
||||||
|
}
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
@@ -64,8 +73,10 @@ esp_err_t ulp_riscv_isr_deregister(intr_handler_t fn, void *arg, uint32_t mask)
|
|||||||
/* Make sure we disable only the ULP interrupt bits */
|
/* Make sure we disable only the ULP interrupt bits */
|
||||||
mask &= (RTC_CNTL_COCPU_INT_ST_M | RTC_CNTL_COCPU_TRAP_INT_ST_M);
|
mask &= (RTC_CNTL_COCPU_INT_ST_M | RTC_CNTL_COCPU_TRAP_INT_ST_M);
|
||||||
|
|
||||||
/* Disable the interrupt bits */
|
/* Disable the interrupt bits atomically to avoid race condition with other code accessing RTC_CNTL_INT_ENA_REG */
|
||||||
CLEAR_PERI_REG_MASK(RTC_CNTL_INT_ENA_REG, mask);
|
RTC_CNTL_ATOMIC() {
|
||||||
|
CLEAR_PERI_REG_MASK(RTC_CNTL_INT_ENA_REG, mask);
|
||||||
|
}
|
||||||
|
|
||||||
/* Deregister the RTC ISR */
|
/* Deregister the RTC ISR */
|
||||||
ESP_RETURN_ON_ERROR(rtc_isr_deregister(fn, arg), TAG, "rtc_isr_deregister() failed");
|
ESP_RETURN_ON_ERROR(rtc_isr_deregister(fn, arg), TAG, "rtc_isr_deregister() failed");
|
||||||
@@ -103,7 +114,7 @@ esp_err_t ulp_riscv_config_and_run(ulp_riscv_cfg_t* cfg)
|
|||||||
/* Reset COCPU when power on. */
|
/* Reset COCPU when power on. */
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_COCPU_CTRL_REG, RTC_CNTL_COCPU_SHUT_RESET_EN);
|
SET_PERI_REG_MASK(RTC_CNTL_COCPU_CTRL_REG, RTC_CNTL_COCPU_SHUT_RESET_EN);
|
||||||
|
|
||||||
/* The coprocessor cpu trap signal doesnt have a stable reset value,
|
/* The coprocessor cpu trap signal doesn't have a stable reset value,
|
||||||
force ULP-RISC-V clock on to stop RTC_COCPU_TRAP_TRIG_EN from waking the CPU*/
|
force ULP-RISC-V clock on to stop RTC_COCPU_TRAP_TRIG_EN from waking the CPU*/
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_COCPU_CTRL_REG, RTC_CNTL_COCPU_CLK_FO);
|
SET_PERI_REG_MASK(RTC_CNTL_COCPU_CTRL_REG, RTC_CNTL_COCPU_CLK_FO);
|
||||||
|
|
||||||
@@ -123,7 +134,7 @@ esp_err_t ulp_riscv_config_and_run(ulp_riscv_cfg_t* cfg)
|
|||||||
/* Reset COCPU when power on. */
|
/* Reset COCPU when power on. */
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_COCPU_CTRL_REG, RTC_CNTL_COCPU_SHUT_RESET_EN);
|
SET_PERI_REG_MASK(RTC_CNTL_COCPU_CTRL_REG, RTC_CNTL_COCPU_SHUT_RESET_EN);
|
||||||
|
|
||||||
/* The coprocessor cpu trap signal doesnt have a stable reset value,
|
/* The coprocessor cpu trap signal doesn't have a stable reset value,
|
||||||
force ULP-RISC-V clock on to stop RTC_COCPU_TRAP_TRIG_EN from waking the CPU*/
|
force ULP-RISC-V clock on to stop RTC_COCPU_TRAP_TRIG_EN from waking the CPU*/
|
||||||
SET_PERI_REG_MASK(RTC_CNTL_COCPU_CTRL_REG, RTC_CNTL_COCPU_CLK_FO);
|
SET_PERI_REG_MASK(RTC_CNTL_COCPU_CTRL_REG, RTC_CNTL_COCPU_CLK_FO);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user