"Fossies" - the Fresh Open Source Software Archive

Member "i2c-tools-4.3/lib/libi2c.3" (22 Jul 2021, 5339 Bytes) of package /linux/misc/i2c-tools-4.3.tar.gz:


Caution: As a special service "Fossies" has tried to format the requested manual source page into HTML format but links to other man pages may be missing or even erroneous. Alternatively you can here view or download the uninterpreted manual source code. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

libi2c

NAME
SYNOPSIS
DESCRIPTION
DATA STRUCTURES
BUGS
AUTHOR

NAME

libi2c − publicly accessible functions provided by the i2c library

SYNOPSIS

#include <linux/i2c.h>
#include <i2c/smbus.h>

/* Universal SMBus transaction */
__s32 i2c_smbus_access(int
file, char read_write, __u8 command,
int
size, union i2c_smbus_data *data);

/* Simple SMBus transactions */
__s32 i2c_smbus_write_quick(int
file, __u8 value);
__s32 i2c_smbus_read_byte(int
file);
__s32 i2c_smbus_write_byte(int
file, __u8 value);
__s32 i2c_smbus_read_byte_data(int
file, __u8 command);
__s32 i2c_smbus_write_byte_data(int
file, __u8 command, __u8 value);
__s32 i2c_smbus_read_word_data(int
file, __u8 command);
__s32 i2c_smbus_write_word_data(int
file, __u8 command, __u16 value);
__s32 i2c_smbus_process_call(int
file, __u8 command, __u16 value);

/* Block SMBus (and non-SMBus) transactions */
__s32 i2c_smbus_read_block_data(int
file, __u8 command, __u8 *values);
__s32 i2c_smbus_write_block_data(int
file, __u8 command, __u8 length,
const __u8 *
values);
__s32 i2c_smbus_block_process_call(int
file, __u8 command, __u8 length,
__u8 *
values);
__s32 i2c_smbus_read_i2c_block_data(int
file, __u8 command, __u8 length,
__u8 *
values);
__s32 i2c_smbus_write_i2c_block_data(int
file, __u8 command, __u8 length,
const __u8 *
values);

DESCRIPTION

This library offers to user-space an SMBus-level API similar to the in-kernel one. Each function is a wrapper around the appropriate ioctl call for i2c-dev to process. The i2c-dev kernel driver will convert the ioctl to its in-kernel equivalent function call, and pass the result back to the user-space caller.

i2c_smbus_access() is the universal function to run any SMBus transaction. You have to fill out and link the data structures yourself. It returns 0 on success, or a negative errno value on error. In practice you should never need to call this function directly, instead use one of the specific functions below, which will prepare the data and then call it for you.

i2c_smbus_write_quick() runs an SMBus "Quick command" transaction.

i2c_smbus_write_byte() runs an SMBus "Send byte" transaction.

i2c_smbus_write_byte_data() runs an SMBus "Write byte" transaction.

i2c_smbus_write_word_data() runs an SMBus "Write word" transaction.

These write transaction functions return 0 on success. On error, a negative errno value is returned.

i2c_smbus_read_byte() runs an SMBus "Receive byte" transaction.

i2c_smbus_read_byte_data() runs an SMBus "Read byte" transaction.

i2c_smbus_read_word_data() runs an SMBus "Read word" transaction.

i2c_smbus_process_call() runs an SMBus "Process call" transaction.

These read transaction functions return the read byte or word value on success. On error, a negative errno value is returned.

i2c_smbus_write_block_data() runs an SMBus "Block write" transaction.

i2c_smbus_read_block_data() runs an SMBus "Block read" transaction.

i2c_smbus_block_process_call() runs an SMBus "Block write-block read process call" transaction.

These block transaction functions return 0 on success. On error, a negative errno value is returned. The block length is limited to 32 bytes.

i2c_smbus_write_i2c_block_data() runs an "I2C block write" transaction. This is typically used to write to an EEPROM up to 4 kb in size.

i2c_smbus_read_i2c_block_data() runs an "I2C block read" transaction. This is typically used to read from an EEPROM up to 4 kb in size.

While technically not part of the SMBus specification, these I2C block transactions are supported by many SMBus host controllers. These block transaction functions return 0 on success. On error, a negative errno value is returned. Like their SMBus counterparts, the block length is limited to 32 bytes.

DATA STRUCTURES

Structure i2c_smbus_ioctl_data is used to send data to and retrieve data from the kernel through the i2c-dev driver. It will be filled out for you by i2c_smbus_access() so you do not need to care about the details.

Union i2c_smbus_data is used to store all possible SMBus data.

union i2c_smbus_data {

__u8 byte;

__u16 word;

__u8 block[I2C_SMBUS_BLOCK_MAX + 2];

};

block[0] is used for length and the last byte is reserved. If you use the higher-level functions, this structure will be filled out for you so you do not have to care about the details. Only if you call i2c_smbus_access() directly, you need to fill it out yourself.

BUGS

To report bugs or send fixes, please write to the Linux I2C mailing list <linux-i2c@vger.kernel.org> with Cc to the current maintainer: Jean Delvare <jdelvare@suse.de>.

AUTHOR

Simon G. Vogl, Frodo Looijaard, Jean Delvare and others