mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 04:02:27 +00:00
fix(gpio): fix pu, pd, drv value incorrect from gpio_dump_io_configuration on esp32
Closes https://github.com/espressif/esp-idf/issues/14931
This commit is contained in:
@@ -55,15 +55,33 @@ static inline void gpio_ll_get_io_config(gpio_dev_t *hw, uint32_t gpio_num,
|
||||
uint32_t bit_shift = (gpio_num < 32) ? gpio_num : (gpio_num - 32);
|
||||
uint32_t bit_mask = 1 << bit_shift;
|
||||
uint32_t iomux_reg_val = REG_READ(GPIO_PIN_MUX_REG[gpio_num]);
|
||||
*pu = (iomux_reg_val & FUN_PU_M) >> FUN_PU_S;
|
||||
*pd = (iomux_reg_val & FUN_PD_M) >> FUN_PD_S;
|
||||
*ie = (iomux_reg_val & FUN_IE_M) >> FUN_IE_S;
|
||||
*oe = (((gpio_num < 32) ? hw->enable : hw->enable1.val) & bit_mask) >> bit_shift;
|
||||
*od = hw->pin[gpio_num].pad_driver;
|
||||
*drv = (iomux_reg_val & FUN_DRV_M) >> FUN_DRV_S;
|
||||
*fun_sel = (iomux_reg_val & MCU_SEL_M) >> MCU_SEL_S;
|
||||
*sig_out = hw->func_out_sel_cfg[gpio_num].func_sel;
|
||||
*slp_sel = (iomux_reg_val & SLP_SEL_M) >> SLP_SEL_S;
|
||||
if (pu) {
|
||||
*pu = (iomux_reg_val & FUN_PU_M) >> FUN_PU_S;
|
||||
}
|
||||
if (pd) {
|
||||
*pd = (iomux_reg_val & FUN_PD_M) >> FUN_PD_S;
|
||||
}
|
||||
if (ie) {
|
||||
*ie = (iomux_reg_val & FUN_IE_M) >> FUN_IE_S;
|
||||
}
|
||||
if (oe) {
|
||||
*oe = (((gpio_num < 32) ? hw->enable : hw->enable1.val) & bit_mask) >> bit_shift;
|
||||
}
|
||||
if (od) {
|
||||
*od = hw->pin[gpio_num].pad_driver;
|
||||
}
|
||||
if (drv) {
|
||||
*drv = (iomux_reg_val & FUN_DRV_M) >> FUN_DRV_S;
|
||||
}
|
||||
if (fun_sel) {
|
||||
*fun_sel = (iomux_reg_val & MCU_SEL_M) >> MCU_SEL_S;
|
||||
}
|
||||
if (sig_out) {
|
||||
*sig_out = hw->func_out_sel_cfg[gpio_num].func_sel;
|
||||
}
|
||||
if (slp_sel) {
|
||||
*slp_sel = (iomux_reg_val & SLP_SEL_M) >> SLP_SEL_S;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include "soc/rtc_io_struct.h"
|
||||
#include "soc/rtc_io_reg.h"
|
||||
@@ -25,7 +26,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
RTCIO_LL_FUNC_RTC = 0x0, /*!< The pin controled by RTC module. */
|
||||
RTCIO_LL_FUNC_RTC = 0x0, /*!< The pin controlled by RTC module. */
|
||||
RTCIO_LL_FUNC_DIGITAL = 0x1, /*!< The pin controlled by DIGITAL module. */
|
||||
} rtcio_ll_func_t;
|
||||
|
||||
@@ -197,6 +198,21 @@ static inline void rtcio_ll_pullup_disable(int rtcio_num)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get RTC GPIO pad pullup status.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ MAX(rtcio).
|
||||
* @return Whether the pullup of the pad is enabled or not.
|
||||
*/
|
||||
static inline bool rtcio_ll_is_pullup_enabled(int rtcio_num)
|
||||
{
|
||||
if (rtc_io_desc[rtcio_num].pullup) {
|
||||
return GET_PERI_REG_MASK(rtc_io_desc[rtcio_num].reg, rtc_io_desc[rtcio_num].pullup);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* RTC GPIO pulldown enable.
|
||||
*
|
||||
@@ -221,6 +237,21 @@ static inline void rtcio_ll_pulldown_disable(int rtcio_num)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get RTC GPIO pad pulldown status.
|
||||
*
|
||||
* @param rtcio_num The index of rtcio. 0 ~ MAX(rtcio).
|
||||
* @return Whether the pulldown of the pad is enabled or not.
|
||||
*/
|
||||
static inline bool rtcio_ll_is_pulldown_enabled(int rtcio_num)
|
||||
{
|
||||
if (rtc_io_desc[rtcio_num].pulldown) {
|
||||
return GET_PERI_REG_MASK(rtc_io_desc[rtcio_num].reg, rtc_io_desc[rtcio_num].pulldown);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable force hold function on an RTC IO pad.
|
||||
*
|
||||
|
Reference in New Issue
Block a user