Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(driver/gpio): funtion to read pin-holders (IDFGH-14020) #14843

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions components/esp_driver_gpio/include/driver/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,18 @@ esp_err_t gpio_hold_en(gpio_num_t gpio_num);
*/
esp_err_t gpio_hold_dis(gpio_num_t gpio_num);

/**
* @brief Get gpio pad hold function.
*
* @param gpio_num GPIO number, only support output-capable GPIOs
* @param out pointer
*
* @return
* - ESP_OK Success
* - ESP_ERR_NOT_SUPPORTED Not support pad hold function
*/
esp_err_t gpio_hold_get(gpio_num_t gpio_num, bool * out);

#if SOC_GPIO_SUPPORT_HOLD_IO_IN_DSLP && !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP
/**
* @brief Enable all digital gpio pads hold function during Deep-sleep.
Expand Down
20 changes: 20 additions & 0 deletions components/esp_driver_gpio/src/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,26 @@ esp_err_t gpio_hold_dis(gpio_num_t gpio_num)
return ret;
}

esp_err_t gpio_hold_get(gpio_num_t gpio_num, bool * out)
{
GPIO_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "Only output-capable GPIO support this function", ESP_ERR_NOT_SUPPORTED);
int ret = ESP_OK;

if (rtc_gpio_is_valid_gpio(gpio_num)) {
#if SOC_RTCIO_HOLD_SUPPORTED
ret = ESP_ERR_NOT_SUPPORTED;
#endif
} else if (GPIO_HOLD_MASK[gpio_num]) {
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
*out = gpio_hal_is_digital_io_hold(gpio_context.gpio_hal, gpio_num);
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
} else {
ret = ESP_ERR_NOT_SUPPORTED;
}

return ret;
}

#if SOC_GPIO_SUPPORT_HOLD_IO_IN_DSLP && !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP
void gpio_deep_sleep_hold_en(void)
{
Expand Down
Loading