# GPIO - input/output

Source: [https://docs.qualcomm.com/doc/80-58740-4/topic/gpio-input-output.html](https://docs.qualcomm.com/doc/80-58740-4/topic/gpio-input-output.html)

This demo mainly introduces the GPIO 0 output and GPIO 1 input functions.

## Hardware connection

Connect the GPIO 0 and GPIO 1 pins using Dupont wire.

## Software implementation

For more detailed code, refer to
                    examples/peripherals/gpio/gpio\_input\_output.

    board_init();Copy to clipboard

- Turn on the clock in `board_init`

    gpio = qcc74x_device_get_by_name("gpio");
    
    qcc74x_gpio_init(gpio, GPIO_PIN_0, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_0);
    qcc74x_gpio_init(gpio, GPIO_PIN_1, GPIO_INPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_0);Copy to clipboard

- Configure GPIO 0 as GPIO\_OUTPUT function and GPIO 1 as GPIO\_INPUT
                        function

    while (1) {
        qcc74x_gpio_set(gpio, GPIO_PIN_0);
        printf("GPIO_PIN_1=%x\r\n", qcc74x_gpio_read(gpio, GPIO_PIN_1));
        qcc74x_mtimer_delay_ms(2000);
    
        qcc74x_gpio_reset(gpio, GPIO_PIN_0);
        printf("GPIO_PIN_1=%x\r\n", qcc74x_gpio_read(gpio, GPIO_PIN_1));
        qcc74x_mtimer_delay_ms(2000);
    }Copy to clipboard

- `qcc74x_gpio_set(gpio, GPIO_PIN_0)` sets the GPIO 0 pin
- `qcc74x_gpio_read(gpio, GPIO_PIN_1)` read GPIO 1 pin level
- `qcc74x_gpio_reset(gpio, GPIO_PIN_0)` sets the GPIO 0 pin to 0

## Experimental phenomena

Print GPIO 1 pin level.

**Parent Topic:** [GPIO](https://docs.qualcomm.com/doc/80-58740-4/topic/gpio.html)

Last Published: Feb 10, 2025

[Previous Topic
GPIO](https://docs.qualcomm.com/bundle/publicresource/80-58740-4/topics/gpio.md) [Next Topic
GPIO - interrupt](https://docs.qualcomm.com/bundle/publicresource/80-58740-4/topics/gpio-interrupt.md)