GPIO_OpenAsOutput Function
Header: #include <applibs/gpio.h>
Opens a GPIO (General Purpose Input/Output) as an output.
An output GPIO may be configured as push-pull, open drain, or open source. Call GPIO_SetValue on an open output GPIO to set the output value. You can also call GPIO_GetValue on an open output GPIO to read the current value (for example, when the output GPIO is configured as GPIO_OutputMode_OpenDrain or GPIO_OutputMode_OpenSource).
GPIO functions are thread-safe between calls to different GPIOs; however, it is the caller’s responsibility to ensure thread safety for accesses to the same GPIO.
int GPIO_OpenAsOutput(GPIO_Id gpioId, GPIO_OutputMode_Type outputMode, GPIO_Value_Type initialValue);
Parameters
gpioId
A GPIO_Id that identifies the GPIO.outputMode
The output mode of the GPIO. An output may be configured as push-pull, open drain, or open source.initialValue
The initial GPIO_Value for the GPIO - GPIO_Value_High or GPIO_Value_Low.
Errors
Returns -1 if an error is encountered and sets errno
to the error value.
EACCES: access to
gpioId
is not permitted as the GPIO is not listed in the Gpio field of the application manifest.EBUSY: the
gpioId
is already open.ENODEV: the
gpioId
is invalid.EINVAL: the
outputMode
is not a valid GPIO_OutputMode or theinitialValue
is not a valid GPIO_Value.
Any other errno
may also be specified; such errors aren't deterministic and the same behavior might not be retained through system updates.
Return value
Returns a file descriptor for the opened GPIO on success, or -1 for failure, in which case errno
will be set to the error value.
Application manifest requirements
To access individual GPIOs, your application must identify them in the Gpio field of the application manifest.