Calibre UK ICA93LV user manual Visual Basic 3.0 function, Setup

Page 16

slv% = &ha1

‘* I2C Address of slave, this is a typical read address *

 

‘* for an I2C static RAM or EEPROM*

setnack% = 0

‘* Enable Acknowledge (see parameter descriptions) *

call restart(baseaddr%, slv%, setnack%) print”Restart and I2C Slave Address sent”

‘* This will send a Restart and the I2C Slave Address of the device to *

5.3.DLLs for Programming in Microsoft Windows 3.X Environments

5.3.1. Files

 

\readme.doc

User Information

\c\i2inc.h

“C” function prototypes

\c\cali2c.lib

I2C “C” library

\vb30\cali2c.bas

Visual Basic 3.0 declarations

\vb30cali2c.dll

I2C Visual Basic dynamic link library

C functions – Function Prototypes

The following function prototypes are required by the DLL, these are defined in the file I2CINC.H Void far_pascal_export setup (int baseaddress, int ownaddress, int sclk, int statuswait);

int far_pascal_export sendaddress (int sendaddress, int setnack); int far_pascal_export restart (int slaveaddress, int setnack);

int far_pascal_export getstatus (void);

int far_pascal_export writebyte (int wrData); int far_pascal_export readbyte (int setnack); int far_pascal_export sendstop (void);

int far_pascal_export recover (void);

int far_pascal_export sendbytes (int_far *transferarray); int far_pascal_export getbytes (int_far *transferarray); void far_pascal_export slavelastbyte (void);

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 CALI2C.LIB to your project make file.

Visual Basic 3.0 function

Add the file CALI2.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))

DLL function descriptions – Applies to both C++ and Visual Basic

setup

 

Function specification

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

Revision 1.7

Page 15 of 27

09/12/1999

 

Image 16
Contents Contents ICA93LVIntroduction Packing ListSetting the Adapter Base Address Configuring the AdapterWait State Generator Installing the Adapter Bus Termination and ProtectionConnecting the Adapter to your System Connector Pinout Normal/Long Distance ModeVariable Voltage Bus Power Supply Bus Capacitance Limitations/Cable ChoiceGetting Started Resetting the Adapter Introduction to the UtilitiesLibrary/Programs TurboBASIC Library/ProgramsRoutines 1. I2C Setup/Initialisation Routine Using the Utilities2. I2C Status Checking Routine 3. I2C Address and Start Sending Routine 4. I2C Read Data Byte from Slave Routine Write Data Byte to Slave Routine Send an I2C Stop RoutineTurboBASIC Routines 1. I2C Setup/Initialisation Routines 7. I2C Restart and Address Sending Routine2. I2C Status Checking Routine 3. I2C Address and Start Sending Routine Write Data Byte to Slave Routine 7. I2C Restart and Address Sending Routine Setup Visual Basic 3.0 functionSendaddress Sendstop SendaddressRestart Getstatus SendbytesGetbytes Slavelastbyte Further Information BUS Error Real-Time Bus MonitorAppendix a I2C Communications Adapter Status Codes Bit 7 MSB The PIN BitBit 6 Not Used Bit 5 The STS BitAppendix B I2C Communications Adapter Control Codes Question Do you have software to talk to my........? DOS Software QuestionsHkeylocalmachine System