Tizen Native API
5.0
|
The GPIO API provides functions to control GPIO peripherals connected to the IoT device.
Required Header
#include <peripheral_io.h>
Overview
This GPIO API provides functions to control GPIO peripherals connected to the IoT device.
Realted Features
This API is related with the following feature:
It is recommended to use features in your application for reliability.
You can check if a IoT device supports the related features for this API
by using System Information, and control your application's actions accordingly.
To ensure your application is only running on the IoT device with specific features,
please define the features in your manifest file using the manifest editor in the SDK.
More details on featuring your application can be found from Feature Element.
Functions | |
int | peripheral_gpio_open (int gpio_pin, peripheral_gpio_h *gpio) |
Opens a GPIO pin. | |
int | peripheral_gpio_close (peripheral_gpio_h gpio) |
Closes a GPIO pin. | |
int | peripheral_gpio_set_direction (peripheral_gpio_h gpio, peripheral_gpio_direction_e direction) |
Sets the GPIO direction. | |
int | peripheral_gpio_set_edge_mode (peripheral_gpio_h gpio, peripheral_gpio_edge_e edge) |
Sets the GPIO edge mode. | |
int | peripheral_gpio_set_interrupted_cb (peripheral_gpio_h gpio, peripheral_gpio_interrupted_cb callback, void *user_data) |
Sets the GPIO interrupted callback to be invoked when the GPIO interrupt is triggered. | |
int | peripheral_gpio_unset_interrupted_cb (peripheral_gpio_h gpio) |
Unsets the GPIO interrupted callback. | |
int | peripheral_gpio_read (peripheral_gpio_h gpio, uint32_t *value) |
Gets the current value of the GPIO pin. | |
int | peripheral_gpio_write (peripheral_gpio_h gpio, uint32_t value) |
Sets the value of the GPIO pin. | |
Typedefs | |
typedef struct _peripheral_gpio_s * | peripheral_gpio_h |
The handle of a GPIO pin. | |
typedef void(* | peripheral_gpio_interrupted_cb )(peripheral_gpio_h gpio, peripheral_error_e error, void *user_data) |
The GPIO interrupted callback called when the GPIO interrupt is triggered. |
Typedef Documentation
typedef struct _peripheral_gpio_s* peripheral_gpio_h |
The handle of a GPIO pin.
- Since :
- 4.0
typedef void(* peripheral_gpio_interrupted_cb)(peripheral_gpio_h gpio, peripheral_error_e error, void *user_data) |
The GPIO interrupted callback called when the GPIO interrupt is triggered.
- Warning:
- This is not for use by third-party applications.
The following errors can be received:
PERIPHERAL_ERROR_NONE Successful
PERIPHERAL_ERROR_IO_ERROR I/O operation failed
PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
PERIPHERAL_ERROR_TRY_AGAIN Try again
PERIPHERAL_ERROR_OUT_OF_MEMORY Memory allocation failed
PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
PERIPHERAL_ERROR_RESOURCE_BUSY Device is in use
PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- Since :
- 4.0
- Parameters:
-
[in] gpio The GPIO handle [in] error The GPIO error [in] user_data The user data passed from the callback registration function
- See also:
- peripheral_gpio_set_interrupted_cb()
Enumeration Type Documentation
Function Documentation
int peripheral_gpio_close | ( | peripheral_gpio_h | gpio | ) |
Closes a GPIO pin.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] gpio The GPIO handle
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- Precondition:
- peripheral_gpio_open()
int peripheral_gpio_open | ( | int | gpio_pin, |
peripheral_gpio_h * | gpio | ||
) |
Opens a GPIO pin.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Remarks:
- gpio should be released with peripheral_gpio_close()
- Parameters:
-
[in] gpio_pin The GPIO pin number [out] gpio The GPIO handle is created on success
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed PERIPHERAL_ERROR_OUT_OF_MEMORY Memory allocation failed PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_RESOURCE_BUSY Device is in use PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- Postcondition:
- peripheral_gpio_close()
int peripheral_gpio_read | ( | peripheral_gpio_h | gpio, |
uint32_t * | value | ||
) |
Gets the current value of the GPIO pin.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] gpio The GPIO handle [out] value The value to get
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- See also:
- peripheral_gpio_write()
int peripheral_gpio_set_direction | ( | peripheral_gpio_h | gpio, |
peripheral_gpio_direction_e | direction | ||
) |
Sets the GPIO direction.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Remarks:
- To set the direction to PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_HIGH or PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW, the edge mode must be set to PERIPHERAL_GPIO_EDGE_NONE.
- Parameters:
-
[in] gpio The GPIO handle [in] direction The direction of the GPIO pin
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_UNKNOWN Unknown internal error
int peripheral_gpio_set_edge_mode | ( | peripheral_gpio_h | gpio, |
peripheral_gpio_edge_e | edge | ||
) |
Sets the GPIO edge mode.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Remarks:
- To set the edge mode to PERIPHERAL_GPIO_EDGE_RISING, PERIPHERAL_GPIO_EDGE_FALLING, PERIPHERAL_GPIO_EDGE_BOTH, the data direction must be set to the PERIPHERAL_GPIO_DIRECTION_IN.
- Parameters:
-
[in] gpio The GPIO handle [in] edge The edge mode of the GPIO pin
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_UNKNOWN Unknown internal error
int peripheral_gpio_set_interrupted_cb | ( | peripheral_gpio_h | gpio, |
peripheral_gpio_interrupted_cb | callback, | ||
void * | user_data | ||
) |
Sets the GPIO interrupted callback to be invoked when the GPIO interrupt is triggered.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Remarks:
- The interrupted callback is unset when called peripheral_gpio_unset_interrupted_cb() or callback receives an error value other than PERIPHERAL_ERROR_NONE.
- Parameters:
-
[in] gpio The GPIO handle [in] callback The GPIO interrupted callback function to set [in] user_data The user data to be passed to the callback function
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
- Postcondition:
- peripheral_gpio_unset_interrupted_cb()
- See also:
- peripheral_gpio_set_edge_mode()
Unsets the GPIO interrupted callback.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] gpio The GPIO handle
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- peripheral_gpio_set_interrupted_cb()
int peripheral_gpio_write | ( | peripheral_gpio_h | gpio, |
uint32_t | value | ||
) |
Sets the value of the GPIO pin.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Remarks:
- To write binary data, the direction must be set to PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_HIGH or PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW.
- Parameters:
-
[in] gpio The GPIO handle [in] value The value to set (must be 0 or 1)
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_UNKNOWN Unknown internal error