Dallas Semiconductor DS80C400 C Libraries Home Page

Main Page   Data Structures   File List   Data Fields   Globals  

tini_i2c.h File Reference


Detailed Description

I2C function library.

This library contains functions for communicating to I2C devices via user specified port pins.

For detailed information on the DS80C400 please see the High-Speed Microcontroller User's Guide: DS80C400 Supplement.

Warning:
The functions in this library are NOT multi-process safe--that is, if you call the same method from two different processes at the same time, the parameters to the function may be destroyed, yielding unpredictable results. However, I2C pins are a system resource and should not be shared among different processes.

Go to the source code of this file.

Defines

#define TINI_I2C_VERSION   1
#define I2C_SDA   P3_4
#define I2C_SCL   P3_5
#define I2C_ENABLE_SCL_WAIT_FOR_SLOW_SLAVES   0
#define I2C_MAXIMUM_SCL_WAITCOUNT   10000
#define I2C_DELAY_LOOP_COUNT   0

Functions

int i2c_version ()
 Return the library version.

void i2c_delay (void)
 Delay function.

void i2c_start (void)
 Performs an I2C start condition.

void i2c_bit (unsigned char singlebit)
 Performs an I2C bit write.

unsigned char i2c_readbit (void)
 Performs an I2C bit read.

void i2c_stop (void)
 Performs an I2C stop condition.

unsigned char i2c_readbyte (unsigned char doACK)
 Performs an I2C byte read.

unsigned char i2c_writebyte (unsigned char singlebyte)
 Performs an I2C byte write.

unsigned char i2c_select (unsigned char address)
 Perform I2C start, address selection.

unsigned char i2c_writeblock (unsigned char address, unsigned char *barr, int length)
 Perform I2C start, address selection, write specified bytes and I2C stop.

unsigned char i2c_readblock (unsigned char address, unsigned char *barr, int length)
 Perform I2C start, address selection, read specified number of bytes and I2C stop.

unsigned char i2c_writereadblock (unsigned char address, unsigned char *barr1, int length1, unsigned char *barr2, int length2)
 Perform I2C start, address selection, write specified bytes, I2C start, address slection, read bytes and I2C stop.


Define Documentation

#define I2C_DELAY_LOOP_COUNT   0
 

Number of loops to wait between any host SCL and SDA transitions

#define I2C_ENABLE_SCL_WAIT_FOR_SLOW_SLAVES   0
 

Enable communication with slow slave devices. Value of 1 enables SCL waiting/flow control.

#define I2C_MAXIMUM_SCL_WAITCOUNT   10000
 

Number of loops to wait for SCL to return high if SCL flow control is used.

#define I2C_SCL   P3_5
 

Define SCL (clock) line to talk to the DS1672 on the TINIm400

#define I2C_SDA   P3_4
 

Define SDA (data) line to talk to the DS1672 on the TINIm400

#define TINI_I2C_VERSION   1
 

Version number associated with this header file. Should be the same as the version number returned by the i2c_version function.

See also:
i2c_version


Function Documentation

void i2c_bit unsigned char    singlebit
 

Performs an I2C bit write.

Parameters:
singlebit Bit to write on I2C bus

void i2c_delay void   
 

Delay function.

unsigned char i2c_readbit void   
 

Performs an I2C bit read.

Returns:
Value of SDA line during read timeslot

unsigned char i2c_readblock unsigned char    address,
unsigned char *    barr,
int    length
 

Perform I2C start, address selection, read specified number of bytes and I2C stop.

Parameters:
address Address of device to select. Upper 7 bits are address, LSbit automatically set to 1 by function.
barr Array destination for read bytes
length Number of bytes to read
Returns:
0 if device acknowledged address selection and data transfer

unsigned char i2c_readbyte unsigned char    doACK
 

Performs an I2C byte read.

Parameters:
doACK Set to 1 to assert acknowledge after reading 8 bits, or 0 to not assert ACK.
Returns:
Value of SDA line during read timeslot

unsigned char i2c_select unsigned char    address
 

Perform I2C start, address selection.

Parameters:
address Address of device to select. Upper 7 bits are address, LSbit denotes read if 1 and write if 0.
Returns:
0 if device acknowledged address selection

void i2c_start void   
 

Performs an I2C start condition.

void i2c_stop void   
 

Performs an I2C stop condition.

int i2c_version  
 

Return the library version.

unsigned char i2c_writeblock unsigned char    address,
unsigned char *    barr,
int    length
 

Perform I2C start, address selection, write specified bytes and I2C stop.

Parameters:
address Address of device to select. Upper 7 bits are address, LSbit automatically set to 0 by function.
barr Array of bytes to write
length Number of bytes to write
Returns:
0 if device acknowledged address selection and data transfer

unsigned char i2c_writebyte unsigned char    singlebyte
 

Performs an I2C byte write.

Parameters:
singlebyte Value to write to bus.
Returns:
0 if byte was acknowledged

unsigned char i2c_writereadblock unsigned char    address,
unsigned char *    barr1,
int    length1,
unsigned char *    barr2,
int    length2
 

Perform I2C start, address selection, write specified bytes, I2C start, address slection, read bytes and I2C stop.

Parameters:
address Address of device to select. Upper 7 bits are address, LSbit automatically set to 0 by function.
barr1 Array of bytes to write
length1 Number of bytes to write
barr2 Array destination for read bytes
length2 Number of bytes to read
Returns:
0 if device acknowledged address selection and data transfer


Copyright 2004 Dallas Semiconductor, Inc.. Documentation generated by Doxygen.