Main Page   Modules   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

I2C driver


Files

file  analog.c
file  analog.h
file  digital.c
file  digital.h
file  i2cd.h
file  i2cd.h

Compounds

struct  i2c
 i2c bus controller structure. More...

struct  _I2C_ad_datas
 i2c a/d data structure. More...

struct  _I2C_bin_datas
 I2C digital datastructure. More...

struct  i2cmess
 I2C message structure. More...


Functions

int I2C_ConfigureAnalog (int chip, char how)
 configure the a/d function of one PCF8591 chip. More...

int I2C_WriteAnalogOut (int chip, int value)
 sets the D/A output channel of a PCF8591 chip. More...

int I2C_init_analog ()
 configure all PCF8591 A/D-D/A devices. More...

unsigned char I2C_ReadBinIn (int chip)
 read the binary input on a PCF8574(A) device. More...

int I2C_init_digital ()
 initializes all PCF8574 devices in the system. More...

void GenerateStop (struct i2c *p, unsigned char mess)
 I2C driver internal function. More...

void _I2C_master_handler (struct i2c *p)
 internal I2C master queue handler. More...

void _I2C_slave_handler (struct i2c *p)
 internal I2C slave handler. More...

void I2C_inthandler (unsigned long minor)
 internal I2C interrupt handler. More...

int I2C_init (int which, unsigned long ioaddr)
 Initialize I2C. More...

int I2C_Start_I2C_Transfer (unsigned char which, struct i2cmess *msg)
 initiate an I2C transfer. More...

int I2C_slprocess (unsigned char which, struct i2cmess *msg)
 process I2C slave message. More...

int I2C_process (unsigned char whichBus, unsigned char whichQueue, struct i2cmess *msg)
 generic I2C processing function. More...

int I2C_messagestatus (struct i2cmess *msg)
 check the message status of an I2C message. More...

int I2C_scanbus (unsigned char bus)
 scan the I2C bus for devices. More...


Variables

_I2C_ad_datas _I2C_ad_data [16]
 keeps information about the PCF8591 A/D - D/A converters in the system. More...

_I2C_bin_datas _I2C_bin_data [32]
 keeps the internal data for all PCF8574(A) bin i/o devices. More...


Function Documentation

void _I2C_master_handler struct i2c   p
 

internal I2C master queue handler.

Parameters:
p  is a pointer to the host controller structure

Definition at line 62 of file i2cd.c.

References ACK, i2cmess::address, BB, i2cmess::buf, i2c_device::control, i2c_device::data, dummy, ENI, ESO, GenerateStop, I2C_ARBITRATION_LOST, I2C_ERR, I2C_MASTER_MODE, I2C_NACK_ON_ADDRESS, I2C_NACK_ON_DATA, I2C_OK, I2C_SLAVE_MODE, I2C_TIME_OUT, I2C_TIMEOUT_VAL, i2c::ioaddr, LAB, LRB, i2c::m_buff, i2c::m_dcnt, i2c::m_state, i2c::m_tail, MASTER_IDLE, MASTER_RECV, MASTER_RECV_LAST, MASTER_SEND, MASTER_WAIT_ACK, i2c::mode, i2cmess::nrBytes, PIN, i2c::s_state_handler, STA, and STO.

Referenced by I2C_init.

void _I2C_slave_handler struct i2c   p
 

internal I2C slave handler.

Parameters:
p  is a pointer to the host controller structure

Definition at line 152 of file i2cd.c.

References AAS, ACK, i2c_device::control, i2c_device::data, ENI, ESO, I2C_SLAVE_ERR, I2C_SLAVE_IBUF_OVERFLOW, I2C_SLAVE_OBUF_EMPTY, i2c::ioaddr, LRB, PIN, i2c::s_ibuff, i2c::s_icnt, i2c::s_iptr, i2c::s_isem, i2c::s_obuff, i2c::s_ocnt, i2c::s_optr, i2c::s_osem, i2c::s_state, i2c::s_status, SBUFLEN, SLAVE_IDLE, SLAVE_RECV, SLAVE_SEND, ssem_signal, and STS.

Referenced by I2C_init.

void GenerateStop struct i2c   p,
unsigned char    mess
[static]
 

I2C driver internal function.

Parameters:
p  is a pointer to the host controller structure
mess  is the current I2C message

Definition at line 38 of file i2cd.c.

References I2C_SLAVE_MODE, i2c::m_buff, i2c::m_cnt, i2c::m_dcnt, i2c::m_sem, i2c::m_state, i2c::m_state_handler, i2c::m_tail, MASTER_IDLE, MBUFLEN, i2c::mode, and ssem_signal.

Referenced by _I2C_master_handler.

int I2C_ConfigureAnalog int    chip,
char    how
 

configure the a/d function of one PCF8591 chip.

Parameters:
chip  is the chip ID as set by init_analog()
how  is the config word
This function allows the configuration of the PCF8591 chip as differential or single-ended A/D. For more information, check the datasheet.

Definition at line 77 of file analog.c.

References _I2C_analog_mbuf, _I2C_ad_datas::active, _I2C_ad_datas::address, i2cmess::address, i2cmess::buf, I2C_MASTER, I2C_OK, I2C_process, i2cmess::nrBytes, i2cmess::status, and _I2C_ad_datas::status.

int I2C_init int    which,
unsigned long    ioaddr
 

Initialize I2C.

Parameters:
which  is the device ID to be initialized
ioaddr  is the base IO address of the controller

Definition at line 237 of file i2cd.c.

References _I2C_master_handler, _I2C_slave_handler, _KERN_IVTab_setvector, ACK, i2c_device::control, i2c_device::data, ENI, ESO, I2C_int_a, I2C_int_b, I2C_SLAVE_MODE, I2C_SPEED, I2CA, I2CA_SLAVE_ADDR, I2CB, I2CB_SLAVE_ADDR, i2c::ioaddr, i2c::m_cnt, i2c::m_dcnt, i2c::m_head, i2c::m_sem, i2c::m_state, i2c::m_state_handler, i2c::m_tail, MASTER_IDLE, MBUFLEN, i2c::mode, PIN, readshort, i2c::s_icnt, i2c::s_iptr, i2c::s_isem, i2c::s_ocnt, i2c::s_optr, i2c::s_osem, i2c::s_state, i2c::s_state_handler, i2c::s_status, SIM_CSBAR3, SIM_CSBAR4, SIM_CSOR3, SIM_CSOR4, SIM_CSPAR0, SLAVE_IDLE, and writeshort.

int I2C_init_analog  
 

configure all PCF8591 A/D-D/A devices.

This function looks for PCF8591 devices on all I2C channels, configures the devices as 4 times single-ended and lists all of them in an internal table. The devices get increasing device IDs from 0 to 15 depending on their bus address.

Definition at line 129 of file analog.c.

References _I2C_adnum, _I2C_analog_mbuf, _I2C_ad_datas::active, i2cmess::address, i2cmess::buf, I2C_MASTER, I2C_messagestatus, I2C_NACK_ON_ADDRESS, I2C_NO_BUS, I2C_OK, I2C_process, I2C_TIME_OUT, I2CA, I2CB, i2cmess::nrBytes, and i2cmess::status.

int I2C_init_digital  
 

initializes all PCF8574 devices in the system.

This function scanns all I2C busses for PCF8574 and PCF8574A devices. It first looks for PCF8574 (device address 0x4x), then for PCF8574A (device address 0x7x) on the first, then on the second I2C bus. Devices found get assigned an ID from 0 to 31.

Definition at line 87 of file digital.c.

References _I2C_binnum, _I2C_digital_mbuf, _I2C_bin_datas::active, i2cmess::address, i2cmess::buf, I2C_MASTER, I2C_messagestatus, I2C_NACK_ON_ADDRESS, I2C_NO_BUS, I2C_OK, I2C_process, I2C_TIME_OUT, I2CA, I2CB, i2cmess::nrBytes, and i2cmess::status.

void I2C_inthandler unsigned long    minor
 

internal I2C interrupt handler.

Parameters:
minor  is the "minor" device ID, it denotes the controller Although CubeOS does not know device IDs, this concept has been used for I2C. The corresponding I2C interrupt handler pushes one int to the stack and calls the generic interrupt handler which then decides upon mode (master or slave) and ID which handler to call with which controller structure.

Definition at line 220 of file i2cd.c.

References I2C_MASTER_MODE, i2c::m_state_handler, i2c::mode, and i2c::s_state_handler.

int I2C_messagestatus struct i2cmess   msg
 

check the message status of an I2C message.

Parameters:
msg  is the I2C message struct to check
This function checks the status of an I2C message and reports the result back to the user via stdout

Definition at line 474 of file i2cd.c.

References I2C_ARBITRATION_LOST, I2C_ERR, I2C_NACK_ON_ADDRESS, I2C_NACK_ON_DATA, I2C_NO_BUS, I2C_OK, I2C_TIME_OUT, and i2cmess::status.

int I2C_process unsigned char    whichBus,
unsigned char    whichQueue,
struct i2cmess   msg
 

generic I2C processing function.

Parameters:
whichBus  is which host controller to use
whichQueue  is master or slave queue
msg  is the message to process

Definition at line 457 of file i2cd.c.

References I2C_MASTER, I2C_slprocess, and I2C_Start_I2C_Transfer.

unsigned char I2C_ReadBinIn int    chip
 

read the binary input on a PCF8574(A) device.

Parameters:
chip  denotes the chip ID as set by init_digital()

Definition at line 41 of file digital.c.

References _I2C_digital_mbuf, _I2C_bin_datas::active, _I2C_bin_datas::address, i2cmess::address, i2cmess::buf, I2C_MASTER, I2C_process, and i2cmess::nrBytes.

int I2C_scanbus unsigned char    bus
 

scan the I2C bus for devices.

Parameters:
bus  is which host controller to use for the scan

Definition at line 517 of file i2cd.c.

References i2cmess::address, i2cmess::buf, I2C_MASTER, I2C_messagestatus, I2C_NACK_ON_ADDRESS, I2C_NACK_ON_DATA, I2C_NO_BUS, I2C_OK, I2C_process, I2C_TIME_OUT, i2cmess::nrBytes, and i2cmess::status.

int I2C_slprocess unsigned char    which,
struct i2cmess   msg
 

process I2C slave message.

Parameters:
which  is the host controller to use
msg  is the I2C message struct to process

Definition at line 392 of file i2cd.c.

References i2cmess::address, i2cmess::buf, disable, enable, I2C_ERR, I2C_NO_BUS, I2C_NOT_PROCESSED, I2C_OK, I2C_SLAVE_IBUF_OVERFLOW, I2C_SLAVE_OBUF_EMPTY, I2CA, i2c::ioaddr, i2cmess::nrBytes, i2cmess::procBytes, i2c::s_ibuff, i2c::s_icnt, i2c::s_iptr, i2c::s_isem, i2c::s_obuff, i2c::s_ocnt, i2c::s_optr, i2c::s_osem, i2c::s_status, SBUFLEN, ssem_wait, and i2cmess::status.

Referenced by I2C_process.

int I2C_Start_I2C_Transfer unsigned char    which,
struct i2cmess   msg
 

initiate an I2C transfer.

Parameters:
which  is the controller to be used
msg  is the I2C message to work on

Definition at line 326 of file i2cd.c.

References disable, enable, I2C_ARBITRATION_LOST, I2C_ERR, I2C_MASTER_MODE, I2C_NACK_ON_ADDRESS, I2C_NACK_ON_DATA, I2C_NO_BUS, I2C_NOT_PROCESSED, I2C_OK, I2C_SLAVE_MODE, I2C_TIME_OUT, I2CA, i2c::ioaddr, i2c::m_buff, i2c::m_cnt, i2c::m_head, i2c::m_sem, i2c::m_state_handler, MBUFLEN, i2c::mode, i2c::s_state, SLAVE_IDLE, ssem_wait, and i2cmess::status.

Referenced by I2C_process.

int I2C_WriteAnalogOut int    chip,
int    value
 

sets the D/A output channel of a PCF8591 chip.

Parameters:
chip  is the chip ID as set by init_analog()
value  is the output value

Definition at line 101 of file analog.c.

References _I2C_analog_mbuf, _I2C_ad_datas::active, _I2C_ad_datas::address, i2cmess::address, i2cmess::buf, I2C_MASTER, I2C_OK, I2C_process, i2cmess::nrBytes, i2cmess::status, and _I2C_ad_datas::status.


Variable Documentation

struct _I2C_ad_datas _I2C_ad_data[16]
 

keeps information about the PCF8591 A/D - D/A converters in the system.

Definition at line 29 of file analog.c.

struct _I2C_bin_datas _I2C_bin_data[32]
 

keeps the internal data for all PCF8574(A) bin i/o devices.

Definition at line 29 of file digital.c.


Generated on Thu Feb 20 15:39:03 2003 for cubeOS by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002