Function esp_idf_sys::gpio_hold_en

source ·
pub unsafe extern "C" fn gpio_hold_en(
    gpio_num: gpio_num_t
) -> esp_err_t
Expand description

@brief Enable gpio pad hold function.

When a GPIO is set to hold, its state is latched at that moment and will not change when the internal signal or the IO MUX/GPIO configuration is modified (including input enable, output enable, output value, function, and drive strength values). This function can be used to retain the state of GPIOs when the chip or system is reset, for example, when watchdog time-out or Deep-sleep events are triggered.

This function works in both input and output modes, and only applicable to output-capable GPIOs. If this function is enabled: in output mode: the output level of the GPIO will be locked and can not be changed. in input mode: the input read value can still reflect the changes of the input signal.

However, on ESP32/S2/C3/S3/C2, this function cannot be used to hold the state of a digital GPIO during Deep-sleep. Even if this function is enabled, the digital GPIO will be reset to its default state when the chip wakes up from Deep-sleep. If you want to hold the state of a digital GPIO during Deep-sleep, please call gpio_deep_sleep_hold_en.

Power down or call gpio_hold_dis will disable this function.

@param gpio_num GPIO number, only support output-capable GPIOs

@return - ESP_OK Success - ESP_ERR_NOT_SUPPORTED Not support pad hold function