refactor(gpio): public some IO configuration functions
This allows different peripheral drivers to act on the same IO.
This commit is contained in:
@@ -29,6 +29,18 @@ GPIO Summary
|
||||
- Analog functions such as ADC/DAC/etc are in use
|
||||
:SOC_LP_PERIPHERALS_SUPPORTED: - LP peripherals, such as LP_UART, LP_I2C, are in use
|
||||
|
||||
IO Configuration
|
||||
----------------
|
||||
|
||||
An IO can be used in two ways:
|
||||
|
||||
- As a simple GPIO input to read the level on the pin, or as a simple GPIO output to output the desired level on the pin.
|
||||
- As a peripheral signal input/output.
|
||||
|
||||
IDF peripheral drivers always take care of the necessary IO configurations that need to be applied onto the pins, so that they can be used as the peripheral signal inputs or outputs. This means the users usually only need to be responsible for configuring the IOs as simple inputs or outputs. :cpp:func:`gpio_config` is an all-in-one API that can be used to configure the I/O mode, internal pull-up/pull-down resistors, etc. for pins.
|
||||
|
||||
In some applications, an IO pin can serve dual purposes. For example, the IO, which outputs a LEDC PWM signal, can also act as a GPIO input to generate interrupts or GPIO ETM events. Careful handling on the configuration step is necessary for such dual use of IO pins cases. :cpp:func:`gpio_config` is an API that overwrites all the current configurations, so it must be called to set the pin mode to :cpp:enumerator:`gpio_mode_t::GPIO_MODE_INPUT` before calling the LEDC driver API which connects the output signal to the pin. As an alternative, if no other configuration is needed other than making the pin input enabled, :cpp:func:`gpio_input_enable` can be the one to call at any time to achieve the same purpose.
|
||||
|
||||
Check Current Configuration of IOs
|
||||
----------------------------------
|
||||
|
||||
@@ -75,7 +87,7 @@ If an IO pin is routed to a peripheral signal through the GPIO matrix, the signa
|
||||
|
||||
Do not rely on the default configurations values in the Technical Reference Manual, because it may be changed in the bootloader or application startup code before app_main.
|
||||
|
||||
.. only:: esp32c3 or esp32c6 or esp32h2 or esp32p4 or esp32s2 or esp32s3 or esp32c5
|
||||
.. only:: esp32c3 or esp32c6 or esp32h2 or esp32p4 or esp32s2 or esp32s3 or esp32c5 or esp32c61
|
||||
|
||||
Configure USB PHY Pins to GPIO
|
||||
-------------------------------
|
||||
|
||||
Reference in New Issue
Block a user