GPIO¶
API for manipulating general-purpose input/output.
Defines
-
METAL_GPIO_INT_DISABLE
¶
-
METAL_GPIO_INT_RISING
¶
-
METAL_GPIO_INT_FALLING
¶
-
METAL_GPIO_INT_BOTH_EDGE
¶
-
METAL_GPIO_INT_LOW
¶
-
METAL_GPIO_INT_HIGH
¶
-
METAL_GPIO_INT_BOTH_LEVEL
¶
-
METAL_GPIO_INT_MAX
¶
Functions
-
struct metal_gpio *
metal_gpio_get_device
(unsigned 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
-
__inline__ int
metal_gpio_enable_input
(struct metal_gpio *gpio, int pin)¶ enable input on a pin
- Return
0 if the input is successfully enabled
- Parameters
gpio
: The handle for the GPIO interfacepin
: The pin number indexed from 0
-
__inline__ 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 interfacepin
: The pin number indexed from 0
-
__inline__ 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 interfacepin
: The pin number indexed from 0
-
__inline__ int
metal_gpio_disable_output
(struct metal_gpio *gpio, int pin)¶ Disable output on a pin.
- Return
0 if the output is successfully disabled
- Parameters
gpio
: The handle for the GPIO interfacepin
: The pin number indexed from 0
-
__inline__ 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 interfacepin
: The pin number indexed from 0value
: The value to set the pin to
-
__inline__ int
metal_gpio_get_input_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 interfacepin
: The pin number indexed from 0
-
__inline__ int
metal_gpio_get_output_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 interfacepin
: The pin number indexed from 0
-
__inline__ 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 interfacepin
: The pin number indexed from 0
-
__inline__ 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 interfacepin
: The pin number indexed from 0
-
__inline__ 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 interfacepin
: The bitmask for the pin to enable pinmux onio_function
: The IO function to set
-
__inline__ int
metal_gpio_disable_pinmux
(struct metal_gpio *gpio, int pin)¶ Disables the pinmux for a GPIO pin.
- Return
0 if the pinmux is successfully set
- Parameters
gpio
: The handle for the GPIO interfacepin
: The bitmask for the pin to disable pinmux on
-
__inline__ int
metal_gpio_config_interrupt
(struct metal_gpio *gpio, int pin, int intr_type)¶ Config gpio interrupt type.
- Return
0 if the interrupt mode is setup properly
- Parameters
gpio
: The handle for the GPIO interfacepin
: The bitmask for the pin to enable gpio interruptintr_type
: The interrupt type
-
__inline__ int
metal_gpio_clear_interrupt
(struct metal_gpio *gpio, int pin, int intr_type)¶ Clear gpio interrupt status.
- Return
0 if the interrupt is cleared
- Parameters
gpio
: The handle for the GPIO interfacepin
: The bitmask for the pin to clear gpio interruptintr_type
: The interrupt type to be clear
-
__inline__ struct metal_interrupt *
metal_gpio_interrupt_controller
(struct metal_gpio *gpio)¶ Get the interrupt controller for a gpio.
- Return
A pointer to the interrupt controller responsible for handling gpio interrupts.
- Parameters
gpio
: The handle for the gpio
-
__inline__ int
metal_gpio_get_interrupt_id
(struct metal_gpio *gpio, int pin)¶ Get the interrupt id for a gpio.
- Return
The interrupt id corresponding to a gpio.
- Parameters
gpio
: The handle for the gpiopin
: The bitmask for the pin to get gpio interrupt id
-
struct
metal_gpio
¶ - #include <gpio.h>
The handle for a GPIO interface.