knet_i2c.c File Reference

This module is the low-level communication layer between the KoreBot Library and the Linux Operating System. More...

Include dependency graph for knet_i2c.c:

Go to the source code of this file.

Functions

static int knet_i2c_exit (knet_bus_t *bus)
static struct knet_dev_sknet_i2c_open (struct knet_bus_s *bus, knet_ext_t ext, knet_mod_t mod, const char *name, int argc, char *argv[])
static int knet_i2c_transfer (knet_bus_t *bus, knet_dev_t *dev, const char *write_buf, unsigned int write_len, char *read_buf, unsigned int read_len)
static int knet_i2c_read (knet_bus_t *bus, knet_dev_t *dev, char *buf, unsigned int len)
static int knet_i2c_write (knet_bus_t *bus, knet_dev_t *dev, const char *buf, unsigned int len)
static int knet_i2c_scan_callback (i2c_t *i2c, i2c_dev_t dev, void *context)
int knet_i2c_init (knet_bus_t *bus, int argc, char *argv[])


Detailed Description

This module is the low-level communication layer between the KoreBot Library and the Linux Operating System.

IC Communication Adaptor for K-Net

Author:
Cdric Gaudin (K-Team SA)
Note:
Copyright (C) 2004 K-TEAM SA
Bug:
none discovered.
Todo:
nothing.

Definition in file knet_i2c.c.


Function Documentation

static int knet_i2c_exit ( knet_bus_t bus  )  [static]

This function releases all resources used by an IC Bus

Parameters:
bus KNet IC bus handle
Returns:
always 0
Remarks:
This function is NOT exported outside this module.

Definition at line 148 of file knet_i2c.c.

References knet_bus_s::bus_info, i2c_close(), and kb_free.

Referenced by knet_i2c_init().

Here is the call graph for this function:

int knet_i2c_init ( knet_bus_t bus,
int  argc,
char *  argv[] 
)

This function initializes the IC bus.

Parameters:
bus KNet Bus Handle
argc number of elements in argv
argv string used as initialization parameters
Returns:
An error code:
  • <0 on error - error code
  • >=0 on success - number of devices found on the bus

Definition at line 80 of file knet_i2c.c.

References knet_bus_s::bus_info, knet_bus_s::close, device, knet_bus_s::exit, i2c_close(), i2c_open(), i2c_scan(), KB_ALLOC, kb_error(), KB_ERROR_OPENBUS, KB_ERROR_SCANBUS, kb_free, knet_i2c_exit(), knet_i2c_open(), knet_i2c_read(), knet_i2c_scan_callback(), knet_i2c_transfer(), knet_i2c_write(), knet_bus_s::open, knet_bus_s::read, knet_bus_s::transfer, and knet_bus_s::write.

Referenced by knet_init().

Here is the call graph for this function:

static struct knet_dev_s * knet_i2c_open ( struct knet_bus_s bus,
knet_ext_t  ext,
knet_mod_t  mod,
const char *  name,
int  argc,
char *  argv[] 
) [static, read]

This function opens a given device on the IC Bus

Parameters:
bus KNet IC bus handle
ext KNet Extension Id (don't care for IC Bus)
mod KNet Module Id (IC Device Address).
Returns:
A Pointer to a KNet Device Descriptor or NULL in case of error.
Remarks:
This function is NOT exported outside this module.

Definition at line 168 of file knet_i2c.c.

References knet_bus_s::bus_info, i2c_exists(), kb_error(), KB_ERROR_NODEVFOUND, knet_bus_find_device(), and knet_device_create().

Referenced by knet_i2c_init().

Here is the call graph for this function:

static int knet_i2c_read ( knet_bus_t bus,
knet_dev_t dev,
char *  buf,
unsigned int  len 
) [static]

This function reads data from an IC bus.

Parameters:
bus KNet IC bus handle
dev KNet IC device handle
buf Pointer to the buffer that will receive the data
len Size of the buffer
Returns:
A value:
  • <0 on error
  • >=0 on success, number of bytes read
Remarks:
This function is NOT exported outside this module.

Definition at line 250 of file knet_i2c.c.

References knet_bus_s::bus_info, i2c_llread(), and knet_dev_s::mod_addr.

Referenced by knet_i2c_init().

Here is the call graph for this function:

static int knet_i2c_scan_callback ( i2c_t i2c,
i2c_dev_t  dev,
void *  context 
) [static]

This function is used internally.

Definition at line 56 of file knet_i2c.c.

References knet_dev_s::bus, knet_device_create(), and knet_bus_s::lock.

Referenced by knet_i2c_init().

Here is the call graph for this function:

static int knet_i2c_transfer ( knet_bus_t bus,
knet_dev_t dev,
const char *  write_buf,
unsigned int  write_len,
char *  read_buf,
unsigned int  read_len 
) [static]

This function transfers data to and from an IC bus.

Parameters:
bus KNet IC bus handle
dev KNet IC device handle
write_buf Pointer to the buffer that contains data to be written
write_len Number of bytes in the write buffer
read_buf Pointer to the buffer that will receive data
read_len Size of the read buffer in bytes
Returns:
A value:
  • <0 on error
  • >=0 on success
Remarks:
This function is NOT exported outside this module.

Definition at line 223 of file knet_i2c.c.

References knet_bus_s::bus_info, i2c_lltransfer(), and knet_dev_s::mod_addr.

Referenced by knet_i2c_init().

Here is the call graph for this function:

static int knet_i2c_write ( knet_bus_t bus,
knet_dev_t dev,
const char *  buf,
unsigned int  len 
) [static]

This function writes data to an IC bus.

Parameters:
bus KNet IC bus handle
dev KNet IC device handle
buf Pointer to the buffer that contains the data to be written
len Number of the bytes in the buffer
Returns:
A value:
  • <0 on error
  • >=0 on success, number of byte written
Remarks:
This function is NOT exported outside this module.

Definition at line 276 of file knet_i2c.c.

References knet_bus_s::bus_info, i2c_llwrite(), and knet_dev_s::mod_addr.

Referenced by knet_i2c_init().

Here is the call graph for this function:


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