i2ccom.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  i2c_t

Typedefs

typedef unsigned int i2c_dev_t

Functions

int i2c_open (i2c_t *i2c, const char *device)
void i2c_close (i2c_t *i2c)
int i2c_llread (i2c_t *i2c, i2c_dev_t dev, char *buf, unsigned int len)
int i2c_llwrite (i2c_t *i2c, i2c_dev_t dev, const char *buf, unsigned int len)
int i2c_lltransfer (i2c_t *i2c, i2c_dev_t dev, const char *write_buf, unsigned int write_len, char *read_buf, unsigned int read_len)
int i2c_exists (i2c_t *i2c, i2c_dev_t dev)
int i2c_scan (i2c_t *i2c, int(*callback)(i2c_t *i2c, i2c_dev_t dev, void *context), void *context)


Detailed Description

I²C Low-Level Communication Layer

Definition in file i2ccom.h.


Typedef Documentation

typedef unsigned int i2c_dev_t

I²C Device Address Definition

Definition at line 20 of file i2ccom.h.


Function Documentation

void i2c_close ( i2c_t i2c  ) 

This procedure closes an I²C Bus.

Parameters:
i2c I²C Bus Handle

Definition at line 87 of file i2ccom.c.

References i2c_t::fd.

Referenced by knet_i2c_exit(), and knet_i2c_init().

int i2c_exists ( i2c_t i2c,
i2c_dev_t  dev 
)

This function verifies the existance of a given device on a given I²C Bus.

Parameters:
i2c I²C Bus Handle.
dev I²C Device Address. This value contains only the I²C address bits (7-bit or 10-bit).
Returns:
A value indicating if a device is present or not:
  • 1 device present
  • 0 no device present

Definition at line 243 of file i2ccom.c.

References i2c_t::fd.

Referenced by knet_i2c_open().

int i2c_llread ( i2c_t i2c,
i2c_dev_t  dev,
char *  buf,
unsigned int  len 
)

This function is the primitive to read data from a given device on a given I²C Bus.

Parameters:
i2c I²C Bus Handle
dev I²C Device Address. This value contains only the I²C address bits (7-bit or 10-bit).
buf Pointer to the buffer that will receive the data bytes.
len Size of the buffer in bytes.
Returns:
an error code:
  • <0 standard error number. See errno.h
  • >=0 number of bytes read

Definition at line 138 of file i2ccom.c.

References i2c_t::fd, and i2c_priv_select_device().

Referenced by knet_i2c_read().

Here is the call graph for this function:

int i2c_lltransfer ( i2c_t i2c,
i2c_dev_t  dev,
const char *  write_buf,
unsigned int  write_len,
char *  read_buf,
unsigned int  read_len 
)

This function is the primitive to write data to and then read data from a given device on a given I²C Bus.

Parameters:
i2c I²C Bus Handle.
dev I²C Device Address. This value contains only the I²C address bits (7-bit or 10-bit).
write_buf Pointer to the buffer that contains the data to be written.
write_len Number of bytes to write. The data are in the write buffer.
read_buf Pointer to the buffer that will receive the data.
read_len Size of the read buffer in bytes.
Returns:
an error code:
  • <0 standard error code. See errno.h
  • >=0 on success

Definition at line 202 of file i2ccom.c.

References i2c_t::fd.

Referenced by knet_i2c_transfer().

int i2c_llwrite ( i2c_t i2c,
i2c_dev_t  dev,
const char *  buf,
unsigned int  len 
)

This function is the primitive to write data to a given device on a given I²C Bus.

Parameters:
i2c I²C Bus Handle
dev I²C Device Address. This value contains only the I²C address bits (7-bit or 10-bit).
buf Pointer to the buffer that will be written.
len Number of bytes to write
Returns:
an error code:
  • <0 standard error number. See errno.h
  • >=0 number of bytes written

Definition at line 166 of file i2ccom.c.

References i2c_t::fd, and i2c_priv_select_device().

Referenced by knet_i2c_write().

Here is the call graph for this function:

int i2c_open ( i2c_t i2c,
char const *  device 
)

This function opens an I²C Bus.

Parameters:
i2c Pointer to I²C Bus Descriptor. This descriptor must be allocated by the caller.
device A string representing the device name. A NULL should be used for default I²C Bus. (e.g. /dev/i2c/0)
Returns:
an error code
  • <0 standard error number. See errno.h
  • 0 if I²C Bus Device has been opened

Definition at line 66 of file i2ccom.c.

References i2c_t::dev, and i2c_t::fd.

Referenced by knet_i2c_init().

int i2c_scan ( i2c_t i2c,
int(*)(i2c_t *i2c, i2c_dev_t dev, void *context)  callback,
void *  context 
)

This function scans a given I²C Bus to find devices

Parameters:
i2c I²C Bus Handle.
callback A callback function called when a device is found. If this callback function returns a value <0 the bus scan stops immedialety and the value is used as return value by i2c_scan.
context A value or a pointer passed to the callback function.
Returns:
an error code:
  • <0 standard error code (See errno.h) or a user error code.
  • >=0 Number of devices found on the I²C bus.

Definition at line 280 of file i2ccom.c.

References i2c_t::fd.

Referenced by knet_i2c_init().


Generated on Wed Dec 15 11:49:27 2010 for KoreBot Library by  doxygen 1.5.5