.. include:: ../substitutions.rst .. include:: stdout.rst GPIO ==== The phyCORE-RT1170 module provides extensive support for General-Purpose Input/Output (GPIO) pins. These pins can be configured as either inputs or outputs and many signals on the phyCORE Connector are available as GPIOs through pin multiplexing. The i.MX RT1170 processor includes 13 independent GPIO controllers. For detailed hardware-level information, refer to the *GPIO Interface* chapter in the |hw-manual-link|. GPIO Controller Mapping ----------------------- Each GPIO controller is exposed as a device node in the system. To list all available GPIO controllers, you can use the Zephyr shell: .. code-block:: console :substitutions: |target-prompt| gpio devices |intf-gpio-devices| You can inspect the available GPIO lines within a specific controller by running: .. code-block:: console :substitutions: |target-prompt| gpio info gpio1 |intf-gpio-info| Alternatively, run the command without arguments to list all GPIO lines across all controllers: .. code-block:: console :substitutions: |target-prompt| gpio info Controlling GPIOs via Shell --------------------------- The Zephyr GPIO Shell subsystem enables configuration and control of GPIO pins directly from the shell. To configure a GPIO line (e.g., pin 13 on ``gpio@40c64000`` / ``gpio9``) as output: .. code-block:: console :substitutions: |target-prompt| gpio conf gpio9 13 o To set the output value of the pin (e.g., turn LED2 located on the carrier-board on): .. code-block:: console :substitutions: |target-prompt| gpio set gpio9 13 1 To configure the button as input (e.g., pin 10 on ``gpio@40c68000`` / ``gpio10``): .. code-block:: console :substitutions: |target-prompt| gpio conf gpio10 2 i After configuring a pin as input, you can read its current value: .. code-block:: console :substitutions: |target-prompt| gpio get gpio10 2 **Example**: If a button (e.g., S1 on the carrier board) is connected to the pin, press and release it between consecutive `gpio get` commands to observe the change in value. Heartbeat LED Example --------------------- .. jinja:: :file: templates/gpio-heartbeat.jinja Source Code ~~~~~~~~~~~ .. literalinclude :: source-code/heartbeat.c :language: c For more information see the |http-link-intf-gpio-heartbeat| file. GPIO Button Example ------------------- .. jinja:: :file: templates/gpio-button.jinja Source Code ~~~~~~~~~~~ .. literalinclude :: source-code/button.c :language: c For more information see the |http-link-intf-gpio-button| file.