Appearance
I2C
I2C API.
Functions for the Inter-IC-Communication Bus
Sysprops
sysprop | description |
---|---|
gpio_sda | SDA GPIO |
gpio_scl | SCL GPIO |
Functions Overview
Name | |
---|---|
CW_DRIVER_FUNC | i2c_read(int hDev, uint8_t addr, uint8_t * data, uint8_t len) |
CW_DRIVER_FUNC | i2c_read_reg(int hDev, uint8_t addr, uint8_t reg, uint8_t * data, uint8_t len) |
CW_DRIVER_FUNC | i2c_write(int hDev, uint8_t addr, const uint8_t * data, uint8_t len) |
CW_DRIVER_FUNC | i2c_write_reg(int hDev, uint8_t addr, uint8_t reg, const uint8_t * data, uint8_t len) |
CW_DRIVER_FUNC | i2c_transfer(int hDev, uint8_t addr, const uint8_t * data_w, uint8_t len_w, uint8_t * data_r, uint8_t len_r) |
CW_DRIVER_FUNC | i2c_clear(int hDev) resets a stuck bus by sending 9 clock pulses |
Function Details
function i2c_read
cpp
CW_DRIVER_FUNC i2c_read(
int hDev,
uint8_t addr,
uint8_t * data,
uint8_t len
)
Parameters:
- hDev device handle as returned by open(const char*)
- addr the 7bit address of the device to read from.
- data buffer holding the space for the data to be read.
- len length of the data buffer in bytes.
Return: 0 if the data has successfully been read.
function i2c_read_reg
cpp
CW_DRIVER_FUNC i2c_read_reg(
int hDev,
uint8_t addr,
uint8_t reg,
uint8_t * data,
uint8_t len
)
Parameters:
- hDev device handle as returned by open(const char*)
- addr the 7bit address of the device to read from.
- reg the device register to read data from
- data buffer holding the space for the data to be read.
- len length of the data buffer in bytes.
Return: 0 if the data has successfully been read.
function i2c_write
cpp
CW_DRIVER_FUNC i2c_write(
int hDev,
uint8_t addr,
const uint8_t * data,
uint8_t len
)
Parameters:
- hDev device handle as returned by open(const char*)
- addr the 7bit address of the device to write to.
- data buffer containing the data to be written.
- len length of the data buffer in bytes.
- send_stop pass 1 to send a STOP condition after completing the write, for a repeated-start pass 0.
Return: 0 if the data has been successfully written.
function i2c_write_reg
cpp
CW_DRIVER_FUNC i2c_write_reg(
int hDev,
uint8_t addr,
uint8_t reg,
const uint8_t * data,
uint8_t len
)
Parameters:
- hDev device handle as returned by open(const char*)
- addr the 7bit address of the device to write to.
- reg the device register to be written to
- data buffer containing the data to be written.
- len length of the data buffer in bytes.
Return: 0 if the data has been successfully written.
function i2c_transfer
cpp
CW_DRIVER_FUNC i2c_transfer(
int hDev,
uint8_t addr,
const uint8_t * data_w,
uint8_t len_w,
uint8_t * data_r,
uint8_t len_r
)
Parameters:
- hDev device handle as returned by open(const char*)
- addr the 7bit address of the device to write to.
- data buffer containing the data to be written.
- len length of the data buffer in bytes.
- send_stop pass 1 to send a STOP condition after completing the write, for a repeated-start pass 0.
Return: 0 if the data has been successfully written.
function i2c_clear
cpp
CW_DRIVER_FUNC i2c_clear(
int hDev
)
resets a stuck bus by sending 9 clock pulses
Parameters:
- hDev device handle as returned by open(const char*)