GPIO_OutputMode Enum

Header: #include <applibs/gpio.h>

The options for the output mode of a GPIO.

The output value of a GPIO is set by the GPIO_SetValue function.

typedef enum {
    GPIO_OutputMode_PushPull = 0,
    GPIO_OutputMode_OpenDrain = 1,
    GPIO_OutputMode_OpenSource = 2
} GPIO_OutputMode;

Values

GPIO_OutputMode_PushPull

Configures the GPIO output pin such that it sinks current when driven low and sources current when driven high. The behavior is summarized in the following table:

GPIO output value GPIO output driven as
GPIO_Value_Low Logic state 0, current sink
GPIO_Value_High Logic state 1, current source

Use this mode when a single unidirectional interface, such as SPI or UART, is connected to the GPIO output pin. This mode doesn't allow multiple devices to be connected together in a bus configuration.

GPIO_OutputMode_OpenDrain

Configures the GPIO output pin such that it sinks current when driven low; it cannot source current. The behavior is summarized in the following table:

GPIO output value GPIO output driven as
GPIO_Value_Low Logic state 0, current sink
GPIO_Value_High High impedance (or logic state 1, with external pull-up resistor)

Use this mode when multiple bidirectional interfaces, such as I2C, are connected to the GPIO output pin in a bus configuration. When all outputs of the connected interfaces are in a high impedance state, the GPIO output pin can be driven to a logic 1 with an external pull-up resistor. Any of the connected interfaces can pull the line to logic 0 using its open-drain output.

GPIO_OutputMode_OpenSource

Configures the GPIO output pin such that it sources current when driven high; it cannot sink current. The behavior is summarized in the following table:

GPIO output value GPIO output driven as
GPIO_Value_Low High impedance (or logic state 0, with external pull-down resistor)
GPIO_Value_High Logic state 1, current source

There is no well known use for this mode, but it is available for those who want to use it.