Calibre UK PICA93LV Libraries for Programming in Microsoft Windows Environments, Int baseaddress

Page 23

CALIBRE

￿

￿

4.4.Libraries for Programming in Microsoft Windows Environments

The library function descriptions in this section apply equally to both C++ and Visual Basic applications.

4.4.1.Users of ICA90 / 93 I2C adapters

For those customers who have already used the ICA90 or ICA93 I2C adapters and are wishing to convert there windows applications to the Parallel I2C Adapter the following changes will have to be made:-

C++ applications

Change the link option to c:\your path\LPTI2C.LIB.

The I2CINC.H file is identical for both the ICA90 / 93 and the PICA93LV applications.

VB3.0 applications

Replace the project file CALI2C.BAS for the LPTI2C.BAS supplied.

To simplify the conversion the setup function retains the base address parameter, this is not used by the PICA93LV function and any integer value may be passed (even your existing 310 hex).

4.4.2.C functions - Function Prototypes

To ensure the prototypes are added correctly copy the file I2CINC.H into the directory containing your project and add the line:

#include "I2CINC.H"

Remember to add the library LPTI2C.LIB to your project make file.

4.4.3.Visual Basic 3.0 functions

Add the file LPTI2C.BAS to your project, this contains the declarations for the procedures within the DLL. If the DLL is not in the root directory change the path to the DLL to suit your system.

The sendbytes and getbytes functions pass the transfer array to the DLL by reference, the following example indicates how to do this:

ReDim transferarray(0 to 258) 'remember 3 locations are required for

 

'the slave write and word addresses so

 

'array allows 256 bytes of data.

transferarray(0) = &HA0

'slave write address.

transferarray(1) = &H00

'slave word address.

transferarray(2) = 256

'the number of bytes.

bytes_sent = sendbytes(transferarray(0))

4.4.4.

setup

 

Function specification

Void setup(int baseaddress, int ownaddress, int sclk, int statuswait)

Parameters are:

int baseaddress

 

 

This has no function and any value may be passed to setup, The

 

 

baseaddress has been retained to enable applications written for the ICA90 /

 

 

ICA93 to be rapidly ported to the PICA93LV.

 

 

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 statuswait

Issue 1.3

 

Page 20

22/07/99

Image 23
Contents Calibre Copyright CalibreContents Packing List Configuring the AdapterIntroduction General IntroductionTypical PC Connection Installing the AdapterBus Capacitance Limitations Connecting the Adapter to Your SystemConnector Pinout Power Supply\C\CLIB\MPICA.LIB Software Utilities\C\CLIB\SPICA.LIB \C\CLIB\CPICA.LIB\B\SOURCE\PROMWRIT.BAS DOS Qbasic Library/Programs\B\SOURCE\I2CINC.BAS \B\SOURCE\PROMREAD.BASWindows LIB/DLL Functions Int sclk Using the UtilitiesRoutines Int ownaddressInt setnack Int i2cstatusInt slaveaddress Calibre Int i2cdata Calibre Int i2cstatus Number if the adapter is to read from the slave I2cstatus% Qbasic RoutinesOwnaddress% Sclk%Slaveaddress% I2cdata% Setnack%See Appendix a for details status codes I2cstatus% Is to read from the slave Int statuswait Libraries for Programming in Microsoft Windows EnvironmentsInt baseaddress Int wrData Int ErrCodeSendaddress Address to be accessed via the I2C, e.g. A1H Int bsent Int sendbytesint far *transferarrayInt far *transferarray Int nobytesread Int getbytesint far *transferarraySlave using the adapter Further Information Bit 6 Not Used Bit 4 The Bus Error BER BitAppendix a Parallel I2C Communications Adapter Status Codes Bit 7 MSB The Pending Interrupt Not PIN BitAppendix B Parallel I2C Communications Adapter Control Codes Question Question Get corrupted transfers why is this?Most Commonly Asked I2C Questions Question Do you have software to talk to my........?Code. Why? Please Email Your Query to