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
The handle of the I2C slave device.
- Since :
- 4.0
Function Documentation
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
- 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:
-
- Postcondition:
- peripheral_i2c_close()
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:
-
- See also:
- peripheral_i2c_write()
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:
-
- See also:
- peripheral_i2c_write_register_byte()
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:
-
- See also:
- peripheral_i2c_write_register_word()
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:
-
- See also:
- peripheral_i2c_read()
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:
-
- See also:
- peripheral_i2c_read_register_byte()
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:
-
- See also:
- peripheral_i2c_read_register_word()