MAE 3185 - Introduction to Mechatronics

Logo

View the Project on GitHub Abhiricky1992/UTA-MAE3185-Notes

hardware_gpio Library Functions

All the GPIOs in the μC are set to Input Pull-Down configuration during power up by default. To use this library, add following to the C/C++ file,

#include <hardware/gpio.h>

and following to the CMakeLists.txt file.

target_link_libraries(projectName pico_stdlib hardware_gpio)

Following are some of the most commonly used functions for configuring the GPIOs.

gpio_init(uint8_t pinNo)

This function initializes a GPIO to the peripheral function SIO (Single-Cycle IO). This function is similar to controlling a GPIO directly. However, this peripheral allows the processor to switch GPIO states in a single clock cycle.

gpio_set_dir(uint8_t pinNo, bool dir)

This function configures a GPIO to Input or Output.

gpio_put(uint8_t pinNo, bool outVal)

This function drives a GPIO to High or Low if it is configured as an Output.

bool gpio_get(uint8_t pinNo)

This function reads the state of a GPIO.

gpio_set_pulls(uint8_t pinNo, bool pUp, bool pDown)

This function enables or disables pull-down or pull-up resistors if the GPIO is configured as an Input.

gpio_set_function(uint8_t pinNo, uint8_t func)

This function sets up the state of the GPIO to be controlled by a specific peripheral as discussed in the table.

Next

Code Examples

Back

Working of a GPIO