I2C library functions.
More...
|
int | i2c_init () |
| Initialises the i2c-dev interface for the I2C peripheral exposed on the P1 header (which is dependent on the board revision) More...
|
|
int | i2c_init_name (char *devname) |
| Initialises the i2c-dev interface for the sysfs entry specified by the devname parameter. More...
|
|
int | i2c_select_device (unsigned int fd, unsigned int addr) |
| Selects a specific I2C slave device. More...
|
|
int | i2c_write (unsigned int fd, unsigned int addr, unsigned char *data, unsigned int len) |
| Initiates an I2C write operation. More...
|
|
int | i2c_read (unsigned int fd, unsigned int addr, unsigned char *data, unsigned int len) |
| Initiates an I2C read operation. More...
|
|
I2C library functions.
◆ i2c_init()
Initialises the i2c-dev interface for the I2C peripheral exposed on the P1 header (which is dependent on the board revision)
- Returns
- The file descriptor for the relevant i2c-dev interface, -1 for failure
Definition at line 54 of file pi_i2c.c.
◆ i2c_init_name()
int i2c_init_name |
( |
char * |
devname | ) |
|
Initialises the i2c-dev interface for the sysfs entry specified by the devname parameter.
- Parameters
-
devname | The sysfs entry for a particular I2C peripheral |
- Returns
- The file descriptor for the relevant i2c-dev interface, -1 for failure
Definition at line 97 of file pi_i2c.c.
◆ i2c_read()
int i2c_read |
( |
unsigned int |
fd, |
|
|
unsigned int |
addr, |
|
|
unsigned char * |
data, |
|
|
unsigned int |
len |
|
) |
| |
Initiates an I2C read operation.
- Parameters
-
fd | File descriptor for the i2c-dev interface |
addr | I2C slave device address |
data | Pointer to the read buffer |
len | Length of data |
- Returns
- 1 for success, -1 for failure
Definition at line 176 of file pi_i2c.c.
◆ i2c_select_device()
int i2c_select_device |
( |
unsigned int |
fd, |
|
|
unsigned int |
addr |
|
) |
| |
Selects a specific I2C slave device.
- Parameters
-
fd | File descriptor for the i2c-dev interface
|
addr | I2C slave device address |
- Returns
- 1 for success, -1 for failure
Definition at line 121 of file pi_i2c.c.
◆ i2c_write()
int i2c_write |
( |
unsigned int |
fd, |
|
|
unsigned int |
addr, |
|
|
unsigned char * |
data, |
|
|
unsigned int |
len |
|
) |
| |
Initiates an I2C write operation.
- Parameters
-
fd | File descriptor for the i2c-dev interface |
addr | I2C slave device address |
data | Data to write to the device |
len | Length of data |
- Returns
- 1 for success, -1 for failure
Definition at line 145 of file pi_i2c.c.