Tizen Native API
5.5
|
The I2C API provides functions to control I2C peripherals connected to the IoT device.
Required Header
#include <peripheral_io.h>
Overview
This I2C API provides functions to control I2C 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_i2c_open (int bus, int address, peripheral_i2c_h *i2c) |
Opens an I2C slave device. | |
int | peripheral_i2c_close (peripheral_i2c_h i2c) |
Closes an I2C slave device. | |
int | peripheral_i2c_read (peripheral_i2c_h i2c, uint8_t *data, uint32_t length) |
Reads the bytes data from the I2C slave device. | |
int | peripheral_i2c_write (peripheral_i2c_h i2c, uint8_t *data, uint32_t length) |
Writes the bytes data to the I2C slave device. | |
int | peripheral_i2c_read_register_byte (peripheral_i2c_h i2c, uint8_t reg, uint8_t *data) |
Reads single byte data from the register of the I2C slave device. | |
int | peripheral_i2c_write_register_byte (peripheral_i2c_h i2c, uint8_t reg, uint8_t data) |
Writes single byte data to the register of the I2C slave device. | |
int | peripheral_i2c_read_register_word (peripheral_i2c_h i2c, uint8_t reg, uint16_t *data) |
Reads word data from the register of the I2C slave device. | |
int | peripheral_i2c_write_register_word (peripheral_i2c_h i2c, uint8_t reg, uint16_t data) |
Writes word data to the register of the I2C slave device. | |
Typedefs | |
typedef struct _peripheral_i2c_s * | peripheral_i2c_h |
The handle of the I2C slave device. |
Typedef Documentation
typedef struct _peripheral_i2c_s* peripheral_i2c_h |
The handle of the I2C slave device.
- Since :
- 4.0
Function Documentation
int peripheral_i2c_close | ( | peripheral_i2c_h | i2c | ) |
Closes an I2C slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] i2c The I2C 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 PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- Precondition:
- peripheral_i2c_open()
int peripheral_i2c_open | ( | int | bus, |
int | address, | ||
peripheral_i2c_h * | i2c | ||
) |
Opens an I2C slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Remarks:
- i2c should be released with peripheral_i2c_close()
- Parameters:
-
[in] bus The I2C bus number that the slave device is connected [in] address The address of the slave device [out] i2c The I2C 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_i2c_close()
int peripheral_i2c_read | ( | peripheral_i2c_h | i2c, |
uint8_t * | data, | ||
uint32_t | length | ||
) |
Reads the bytes data from the I2C slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] i2c The I2C handle [out] data The data buffer to read [in] length The size of data buffer (in bytes)
- 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_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_i2c_write()
int peripheral_i2c_read_register_byte | ( | peripheral_i2c_h | i2c, |
uint8_t | reg, | ||
uint8_t * | data | ||
) |
Reads single byte data from the register of the I2C slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] i2c The I2C handle [in] reg The register address of the I2C slave device to read [out] data The single byte data to read
- 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_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_i2c_write_register_byte()
int peripheral_i2c_read_register_word | ( | peripheral_i2c_h | i2c, |
uint8_t | reg, | ||
uint16_t * | data | ||
) |
Reads word data from the register of the I2C slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] i2c The I2C handle [in] reg The register address of the I2C slave device to read [out] data The word(2 bytes) data to read
- 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_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_i2c_write_register_word()
int peripheral_i2c_write | ( | peripheral_i2c_h | i2c, |
uint8_t * | data, | ||
uint32_t | length | ||
) |
Writes the bytes data to the I2C slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] i2c The I2C handle [in] data The data buffer to write [in] length The size of data buffer (in bytes)
- 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_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_i2c_read()
int peripheral_i2c_write_register_byte | ( | peripheral_i2c_h | i2c, |
uint8_t | reg, | ||
uint8_t | data | ||
) |
Writes single byte data to the register of the I2C slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] i2c The I2C handle [in] reg The register address of the I2C slave device to write [in] data The single byte data to write
- 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_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_i2c_read_register_byte()
int peripheral_i2c_write_register_word | ( | peripheral_i2c_h | i2c, |
uint8_t | reg, | ||
uint16_t | data | ||
) |
Writes word data to the register of the I2C slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] i2c The I2C handle [in] reg The register address of the I2C slave device to write [in] data The word(2 bytes) data to write
- 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_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_i2c_read_register_word()