I2c library for C

From Tuxamito
Revision as of 13:37, 11 November 2015 by Daniel (talk | contribs)
Jump to: navigation, search

This library was created to make communication with I2C devices from C language. Up to know it has work fine for in Raspberry Pi boards (and similar ones!).

Download: File:I2c-driver.tar.gz

Usage

int i2c_dev_open(struct i2c_dev *dev, int adapter);
int i2c_dev_close(struct i2c_dev *dev);

int i2c_dev_write(struct i2c_dev *dev, uint8_t *buf, int n);
int i2c_dev_read(struct i2c_dev *dev, uint8_t *buf, int n);
int i2c_dev_wrrs(struct i2c_dev *dev, uint8_t *wbuf, int wn, uint8_t *rbuf, int rn);

Set Up I2C device

int i2c_dev_open(struct i2c_dev *dev, int adapter);

Close I2C device

int i2c_dev_close(struct i2c_dev *dev);

Write to device

int i2c_dev_write(struct i2c_dev *dev, uint8_t *buf, int n);


Read from device

int i2c_dev_read(struct i2c_dev *dev, uint8_t *buf, int n);

Combined Write/Read

int i2c_dev_wrrs(struct i2c_dev *dev, uint8_t *wbuf, int wn, uint8_t *rbuf, int rn);

Example