mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
fix(gpio): oe control by register only take effect when func sel is GPIO
This commit is contained in:
@@ -207,7 +207,8 @@ esp_err_t gpio_output_disable(gpio_num_t gpio_num)
|
||||
{
|
||||
GPIO_CHECK(GPIO_IS_VALID_GPIO(gpio_num), "GPIO number error", ESP_ERR_INVALID_ARG);
|
||||
gpio_hal_output_disable(gpio_context.gpio_hal, gpio_num);
|
||||
gpio_hal_set_output_enable_ctrl(gpio_context.gpio_hal, gpio_num, false, false); // so that output disable could take effect
|
||||
gpio_hal_set_output_enable_ctrl(gpio_context.gpio_hal, gpio_num, false, false); // so that output disable could always take effect when func sel is GPIO
|
||||
gpio_hal_func_sel(gpio_context.gpio_hal, gpio_num, PIN_FUNC_GPIO); // otherwise the oe can only be controlled by peripheral
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -216,6 +217,7 @@ esp_err_t gpio_output_enable(gpio_num_t gpio_num)
|
||||
GPIO_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "GPIO output gpio_num error", ESP_ERR_INVALID_ARG);
|
||||
gpio_hal_matrix_out_default(gpio_context.gpio_hal, gpio_num); // No peripheral output signal routed to the pin, just as a simple GPIO output
|
||||
gpio_hal_output_enable(gpio_context.gpio_hal, gpio_num);
|
||||
gpio_hal_func_sel(gpio_context.gpio_hal, gpio_num, PIN_FUNC_GPIO); // otherwise the oe can only be controlled by peripheral
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -1085,9 +1087,10 @@ esp_err_t gpio_dump_io_configuration(FILE *out_stream, uint64_t io_bit_mask)
|
||||
gpio_get_io_config(gpio_num, &io_config);
|
||||
|
||||
// When the IO is used as a simple GPIO output, oe signal can only be controlled by the oe register
|
||||
// When the IO is not used as a simple GPIO output, oe signal could be controlled by the peripheral
|
||||
// When the IO connects to a peripheral signal through GPIO Matrix, oe signal can be controlled by the peripheral or the oe register (switch by oe_ctrl_by_periph)
|
||||
// When the IO connects to a peripheral signal through IOMUX, oe signal can only be controlled by the peripheral
|
||||
const char *oe_str = io_config.oe ? "1" : "0";
|
||||
if (io_config.sig_out != SIG_GPIO_OUT_IDX && io_config.oe_ctrl_by_periph) {
|
||||
if (io_config.fun_sel != PIN_FUNC_GPIO || io_config.oe_ctrl_by_periph) {
|
||||
oe_str = "[periph_sig_ctrl]";
|
||||
}
|
||||
|
||||
|
||||
@@ -710,7 +710,7 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the source of output enable signal for the GPIO pin.
|
||||
* @brief Configure the source of output enable signal for the pad (only takes effect if func sel is selected to be GPIO).
|
||||
*
|
||||
* @param hw Peripheral GPIO hardware instance address.
|
||||
* @param gpio_num GPIO number of the pad.
|
||||
|
||||
@@ -512,7 +512,7 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the source of output enable signal for the GPIO pin.
|
||||
* @brief Configure the source of output enable signal for the pad (only takes effect if func sel is selected to be GPIO).
|
||||
*
|
||||
* @param hw Peripheral GPIO hardware instance address.
|
||||
* @param gpio_num GPIO number of the pad.
|
||||
|
||||
@@ -510,7 +510,7 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the source of output enable signal for the GPIO pin.
|
||||
* @brief Configure the source of output enable signal for the pad (only takes effect if func sel is selected to be GPIO).
|
||||
*
|
||||
* @param hw Peripheral GPIO hardware instance address.
|
||||
* @param gpio_num GPIO number of the pad.
|
||||
|
||||
@@ -508,7 +508,7 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the source of output enable signal for the GPIO pin.
|
||||
* @brief Configure the source of output enable signal for the pad (only takes effect if func sel is selected to be GPIO).
|
||||
*
|
||||
* @param hw Peripheral GPIO hardware instance address.
|
||||
* @param gpio_num GPIO number of the pad.
|
||||
|
||||
@@ -471,7 +471,7 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the source of output enable signal for the GPIO pin.
|
||||
* @brief Configure the source of output enable signal for the pad (only takes effect if func sel is selected to be GPIO).
|
||||
*
|
||||
* @param hw Peripheral GPIO hardware instance address.
|
||||
* @param gpio_num GPIO number of the pad.
|
||||
|
||||
@@ -508,7 +508,7 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the source of output enable signal for the GPIO pin.
|
||||
* @brief Configure the source of output enable signal for the pad (only takes effect if func sel is selected to be GPIO).
|
||||
*
|
||||
* @param hw Peripheral GPIO hardware instance address.
|
||||
* @param gpio_num GPIO number of the pad.
|
||||
|
||||
@@ -517,7 +517,7 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the source of output enable signal for the GPIO pin.
|
||||
* @brief Configure the source of output enable signal for the pad (only takes effect if func sel is selected to be GPIO).
|
||||
*
|
||||
* @param hw Peripheral GPIO hardware instance address.
|
||||
* @param gpio_num GPIO number of the pad.
|
||||
|
||||
@@ -498,7 +498,7 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the source of output enable signal for the GPIO pin.
|
||||
* @brief Configure the source of output enable signal for the pad (only takes effect if func sel is selected to be GPIO).
|
||||
*
|
||||
* @param hw Peripheral GPIO hardware instance address.
|
||||
* @param gpio_num GPIO number of the pad.
|
||||
|
||||
@@ -518,7 +518,7 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set peripheral output to an GPIO pad through the IOMUX.
|
||||
* @brief Configure the source of output enable signal for the pad (only takes effect if func sel is selected to be GPIO).
|
||||
*
|
||||
* @param hw Peripheral GPIO hardware instance address.
|
||||
* @param gpio_num GPIO number of the pad.
|
||||
|
||||
@@ -635,7 +635,7 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the source of output enable signal for the GPIO pin.
|
||||
* @brief Configure the source of output enable signal for the pad (only takes effect if func sel is selected to be GPIO).
|
||||
*
|
||||
* @param hw Peripheral GPIO hardware instance address.
|
||||
* @param gpio_num GPIO number of the pad.
|
||||
|
||||
@@ -524,7 +524,7 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the source of output enable signal for the GPIO pin.
|
||||
* @brief Configure the source of output enable signal for the pad (only takes effect if func sel is selected to be GPIO).
|
||||
*
|
||||
* @param hw Peripheral GPIO hardware instance address.
|
||||
* @param gpio_num GPIO number of the pad.
|
||||
|
||||
@@ -525,7 +525,7 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the source of output enable signal for the GPIO pin.
|
||||
* @brief Configure the source of output enable signal for the pad (only takes effect if func sel is selected to be GPIO).
|
||||
*
|
||||
* @param hw Peripheral GPIO hardware instance address.
|
||||
* @param gpio_num GPIO number of the pad.
|
||||
|
||||
@@ -42,8 +42,8 @@ void gpio_hal_iomux_in(gpio_hal_context_t *hal, uint32_t gpio_num, int func, uin
|
||||
|
||||
void gpio_hal_iomux_out(gpio_hal_context_t *hal, uint32_t gpio_num, int func)
|
||||
{
|
||||
gpio_ll_set_output_enable_ctrl(hal->dev, gpio_num, true, false);
|
||||
gpio_ll_func_sel(hal->dev, gpio_num, func);
|
||||
// as long as the func sel is not GPIO, the oe can only be controlled by the peripheral
|
||||
}
|
||||
|
||||
void gpio_hal_matrix_in(gpio_hal_context_t *hal, uint32_t gpio_num, uint32_t signal_idx, bool in_inv)
|
||||
|
||||
@@ -161,7 +161,7 @@ void gpio_hal_intr_disable(gpio_hal_context_t *hal, uint32_t gpio_num);
|
||||
#define gpio_hal_output_enable(hal, gpio_num) gpio_ll_output_enable((hal)->dev, gpio_num)
|
||||
|
||||
/**
|
||||
* @brief Configure the source of output enable signal for the GPIO pin.
|
||||
* @brief Configure the source of output enable signal for the pad (only takes effect if func sel is selected to be GPIO).
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param gpio_num GPIO number
|
||||
|
||||
Reference in New Issue
Block a user