GPIO

API for manipulating general-purpose input/output.

Functions

struct metal_gpio *metal_gpio_get_device(int device_num)

Get a GPIO device handle.

Return
The GPIO device handle, or NULL if there is no device at that index
Parameters
  • device_num: The GPIO device index

int metal_gpio_disable_input(struct metal_gpio *gpio, int pin)

Disable input on a pin.

Return
0 if the input is successfully disabled
Parameters
  • gpio: The handle for the GPIO interface
  • pin: The pin number indexed from 0

int metal_gpio_enable_output(struct metal_gpio *gpio, int pin)

Enable output on a pin.

Return
0 if the output is successfully enabled
Parameters
  • gpio: The handle for the GPIO interface
  • pin: The pin number indexed from 0

int metal_gpio_set_pin(struct metal_gpio *gpio, int pin, int value)

Set the output value of a GPIO pin.

Return
0 if the output is successfully set
Parameters
  • gpio: The handle for the GPIO interface
  • pin: The pin number indexed from 0
  • value: The value to set the pin to

int metal_gpio_get_pin(struct metal_gpio *gpio, int pin)

Get the value of the GPIO pin.

Return
The value of the GPIO pin
Parameters
  • gpio: The handle for the GPIO interface
  • pin: The pin number indexed from 0

int metal_gpio_clear_pin(struct metal_gpio *gpio, int pin)

Clears the value of the GPIO pin.

Return
0 if the pin is successfully cleared
Parameters
  • gpio: The handle for the GPIO interface
  • pin: The pin number indexed from 0

int metal_gpio_toggle_pin(struct metal_gpio *gpio, int pin)

Toggles the value of the GPIO pin.

Return
0 if the pin is successfully toggled
Parameters
  • gpio: The handle for the GPIO interface
  • pin: The pin number indexed from 0

int metal_gpio_enable_pinmux(struct metal_gpio *gpio, int pin, int io_function)

Enables and sets the pinmux for a GPIO pin.

Return
0 if the pinmux is successfully set
Parameters
  • gpio: The handle for the GPIO interface
  • pin: The bitmask for the pin to enable pinmux on
  • io_function: The IO function to set

struct metal_gpio
#include <gpio.h>

The handle for a GPIO interface.