Skip to content

Commit 175abe7

Browse files
authored
Clarify pio_gpio_init doxygen (fixes #2387) (#2574)
1 parent 4242010 commit 175abe7

File tree

1 file changed

+19
-3
lines changed
  • src/rp2_common/hardware_pio/include/hardware

1 file changed

+19
-3
lines changed

src/rp2_common/hardware_pio/include/hardware/pio.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,9 +872,25 @@ static inline PIO pio_get_instance(uint instance) {
872872
*
873873
* PIO appears as an alternate function in the GPIO muxing, just like an SPI
874874
* or UART. This function configures that multiplexing to connect a given PIO
875-
* instance to a GPIO. Note that this is not necessary for a state machine to
876-
* be able to read the *input* value from a GPIO, but only for it to set the
877-
* output value or output enable.
875+
* instance to a GPIO. It also configures the GPIO pad to pass signals in and
876+
* out, by:
877+
*
878+
* * Clearing the pad output disable (OD) bit
879+
* * Setting the pad input enable (IE) bit
880+
* * (Non-RP2040) removing pad isolation
881+
*
882+
* This function achieves this low-level pad setup by calling gpio_set_function()
883+
* internally.
884+
*
885+
* Note that, if your PIO program only needs the *input* from a given GPIO,
886+
* it's not necessary to select the PIO GPIO function, because PIO input
887+
* paths ignore the GPIO muxing. However, you must still configure the GPIO
888+
* pad itself for input.
889+
*
890+
* Conversely, if using PIO for both input and output on a given pin, you must
891+
* select the PIO GPIO function for the given PIO instance, as well as
892+
* configuring the pad for input and output. Calling this function is
893+
* sufficient for both the input-only and input/output case.
878894
*
879895
* \param pio The PIO instance; e.g. \ref pio0 or \ref pio1
880896
* \param pin the GPIO pin whose function select to set

0 commit comments

Comments
 (0)