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 |
|