CALIBRE
Issue 1.3 Page 5
22/07/99
The I2CINC.C file contains all the functions required to build an I2C transfer. This will require
compiling (note the include file) to produce an object file. Once the object files have been created link
them together with the library file to create your applications executable file.
The functions contained in I2CINC.C are as detailed below:-
Subroutine Name Brief Functional Description
setup Sets user defined initial conditions.
getstatus Reads status register.
sendaddress Sends slave address, data transmission mode and start signal.
sendstop Sends stop signal.
writebyte Writes a byte of data to a previously specified address.
readbyte Reads a byte of data from a previously specified address.
restart Sends Restart and slave address of device which is to be communicated
with, without sending a Stop.
Two sample programs are also supplied, these examples show how the functions provided in
I2CINC.C are put together to provide a complete I2C transfer. The sample programs are:-
PROMREAD.C Reads a number of bytes from an I2C serial EEPROM.
PROMWRIT.C W rites a number of bytes to an I2C serial EEPROM.
These programs were compiled using the Zortech C compiler the make files used ar e supplied. If you
are using the Zortech C compiler copy the desired make file to MAKEFILE then type MAKE<CR>.
Editing the make files will reveal that the file I2CINC.C is compiled and linked with the application.
The makefiles are:-
READ.MAK The make file for PROMREAD.C
WRITE.MAK The make file for PROMWRIT.C
If you are not using the Zortech C compiler you will have to create a similar make file - see your
compiler documentation for further information.
3.3. DOS QBASIC Library/Programs
3.3.1. Files on disc
\B\SOURCE\I2CINC.BAS The I2C transfer functions
\B\SOURCE\PROMREAD.BAS Sample EEPROM reading function
\B\SOURCE\PROMWRIT.BAS Sample EEPROM writing function
The I2C functions contained in I2CINC.BAS are detailed below:-
Subroutine Name Brief Functional Description
setup Sets user defined initial conditions.
getstatus% Reads status register.
sendaddress% Sends slave address, data transmiss ion mode and start signal.
sendstop% Sends stop signal.
writebyte% Writes a byte of data to a previously specified address.
readbyte% Reads a byte of data from a previously specified address.
restart% Sends restart and slave address of device which is to be communicated with,
without sending a Stop.
Two sample programs are also supplied, these examples show how the functions provided in
I2CINC.BAS are put together to provide a complete I2C transfer. The sample programs are:-
PROMREAD.BAS Reads a number of bytes from an I2C serial EEPROM.
PROMWRIT.BAS W rites a number of bytes to an I2C serial EEPROM.