GPIO_OpenAsInput Function

Header: #include <applibs/gpio.h>

Opens a GPIO (General Purpose Input/Output) as an input.

  • Call GPIO_GetValue on an open input GPIO to read the input value.

  • A GPIO_SetValue call on an open input GPIO will have no effect.

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_OpenAsInput(GPIO_Id gpioId);

Parameters

  • gpioId A GPIO_Id that identifies the GPIO.

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.

  • ENODEV: the provided gpioId is invalid.

  • EBUSY: the gpioId is already open.

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 is 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.