
CALIBRE
Issue 1.1 Page 7
06/03/2007
LIBRARIES FOR PROGRAMMING IN MICROSOFT WINDOWS ENVIRONMENTS
5.1. Introduction
Each utility is documented in a standard format which lists its name, usage, function and effect on the
adapter is given. The adapter should be setup prior to any data transfer.
5.2. Function Prototypes
If you are using ‘C’ or ‘C++’ copy the file CALI2C32.H into the directory containing your project and add
the line:
#include "CALI2C32.H"
The following functions are implemented in the windows libraries:-
extern __declspec(dllimport) int WINAPI setup (int, int, int);
extern __declspec(dllimport) int WINAPI sendaddress (int, int, int);
extern __declspec(dllimport) int WINAPI writebyte(int, int);
extern __declspec(dllimport) int WINAPI readbyte(int, int);
extern __declspec(dllimport) int WINAPI sendstop(int);
extern __declspec(dllimport) int WINAPI restart (int, int, int);
extern __declspec(dllimport) int WINAPI getstatus(int);
extern __declspec(dllimport) int WINAPI recover(int);
extern __declspec(dllimport) int WINAPI slavelastbyte(int);
extern __declspec(dllimport) int WINAPI dllissue(void);
If you are using Visual Basic copy the file CALI2C32.BAS into the directory containing your project and
add the file CALI2C32.BAS to your project:
The following functions are implemented in the windows libraries:-
Public Declare Function setup% Lib "cali2c32.dll" (ByVal Board%, ByVal
OwnAddress%, ByVal Sclk%)
Public Declare Function sendaddress% Lib "cali2c32.dll" (ByVal Board%, ByVal
slaveaddress%, ByVal Setnack%)
Public Declare Function restart% Lib "cali2c32.dll" (ByVal Board%, ByVal
slaveaddress%, ByVal Setnack%)
Public Declare Function writebyte% Lib "cali2c32" (ByVal Board%, ByVal
wrdata%)
Public Declare Function readbyte% Lib "cali2c32.dll" (ByVal Board%, ByVal
Setnack%)
Public Declare Function sendstop% Lib "cali2c32.dll" (ByVal Board%)
Public Declare Function getstatus% Lib "cali2c32.dll" (ByVal Board%)
Public Declare Function recover% Lib "cali2c32.dll" (ByVal Board%)
Public Declare Function slavelastbyte% Lib "cali2c32.dll" (ByVal Board%)
Public Declare Function dllversion% Lib "cali2c32.dll" ()
NOTE A type is defined in cali2c32.bas to help passing parameters to the DLL, if you do not
wish to use this local variables MUST be declared as static
5.3. Function Description
5.3.1. setup
Function specification int setup(int board, int ownaddress, int sclk)
Parameters are: int board
This parameter .is reserved for future use and should always be set to zero (0).
int ownaddress
This is the I2C address to which the adapter is to respond in slave mode. This
forms the upper 7 bits of the 8 bit address, the lowest bit being the read(1) or
write(0) bit. This means that if ownaddress = 57H the card will respond to a
write address of AEH and a read address of AFH.
int sclk
This is the clock rate (bit rate for the I2C serial bus) when operating as a
master.