As old one, this version is able to use 2 types of hardware :
- Elektor ISA Card (based on the PCF8584)
- Philips's parallel adapter (bit banging on centronic port)
and this version introduce a new custom // adapter whitch let you specify
what assigment you are using on the printer port.
You can select hardware by software (if unspecified, the driver use
the default hardware from I2C.INI).
You should have :
I2C_Drv32.DLL
DlPortIO.sys
DlPortIO.dll
DlportIO.reg
I2C_Drv32.h
I2C_Drv32.lib
Description\*.* (Delphi 2.0 project for sample soft))
PCF8574\*.* (Demo using PCF8574 with LED on its outputs)
Typon\*.* (Printer raw file (HP LaserJet 300DPI) of the printed circuit
board for the Philips adapter, it requires a external power >7.5V)
Tests
Simply run DESCRIPT, a windows with Adresse, Mode, Name and Description
field appears. Select address to use, access mode (read only, write only,
read/write), click "Test" to check if the device is present. You can add
a description (saved in I2C.INI) for futur use.
PCF8574 scan the I2C bus. If any device is found, you can change its
ouput with the check boxes.
DEMO is a little demo using a PCF8574 with LED.
TESTI2C is a little shell that let you send command on the bus (start, stop,...). It's very usefull when you have to test new device or hardware.
Using the DLL
When writing software that will use the DLL, you must declare imported
function, in C language :
#define DllImport __declspec( dllimport )
DllExport short pascal I2C_Info(void);
DllExport short pascal I2C_Read(short nbr, unsigned char *buf);
DllExport short pascal I2C_Send(short nbr, unsigned char *buf);
DllExport short pascal I2C_Address(short address);
DllExport short pascal I2C_Stop(void);
DllExport short pascal I2C_Start(void);
DllExport short pascal I2C_Init(void);
DllExport short pascal I2C_SelectInterface(short Carte);
or in Pascal language :
{ Declaration du bus I2C }
function I2C_Address(address : Word) : Word; stdcall; external
'I2C_Drv32.dll';
function I2C_Start : Word; stdcall; external 'I2C_Drv32.dll';
function I2C_Stop : Word; stdcall; external 'I2C_Drv32.dll';
function I2C_Send(nb:Word; data : pointer ) : Word; stdcall; external
'I2C_Drv32.dll';
function I2C_Read(nb:Word; data : pointer ) : Word; stdcall; external
'I2C_Drv32.dll';
function I2C_Init : Word; stdcall; external 'I2C_Drv32.dll';
function I2C_Info : Word; stdcall; external 'I2C_Drv32.dll';
function I2C_SelectInterface(I2Ccard : Word) : Word; stdcall; external
'I2C_Drv32.dll';
(I don't now other language, so you should report to the help file)
This is the SECOND function to call. It initialise the driver, make
the harwdare OK for bus use and clear all internal data. (If uncalled you
should get "General Protection Fault in module xxx" !)
It display a dialog box with the hardware name in use.
This function open the bus sending a start condition.
Output :
0 = OK
or I2CBUSERROR
CAUTION : the driver use internal semaphore to avoid problem with many
software using the same bus at the same time. If the return code isn't
0 (OK), you shouldn't try to send/read data, sometimes others running tranferts
may be corrupted (I don't know why, it must be a bug)
This function close the bus sending a stop condition.
Output :
0 = OK
or I2CBUSERROR
This function send the device address. If the bus was already opened, it make stop/start (or reapeated start if same address).
Ouput :
0 : OK
1 : I2CBUSERROR , bus error (short circuit or another master have the
control)
2 : I2CBUSBUSY , bus busy (bus already opened by another master)
3 : I2CNOACK , no acknoledge on addresse (no device ?)
4 : I2CTIMEOUT , time out (should never occur here)
This function send N bytes from the buffer to the bus. The return code is the number of byte sent (like printf)
This function read N bytes from the bus to the buffer. The return code
is the number of byte read (like canf)
unsigned char buffer[50];
I2C_SelectInterface(1);
I2C_init();
I2C_Start();
I2C_Address(0x20);
I2C_Read(15, buffer);
I2C_Stop();
(In this case I don't test return codes).
This relesae was not fully tested and may be unstable, you use it at your own risk. I AM NOT RESPONSIBLE OF ANY DAMMAGE OR DESTRUCTION CAUSED BY THE USE OF THIS SOFWARE, it should be used only for private purpose.
You can freely use this software for private or educative use.
Professional, industrial or commercial use of this software is prohibited
unless my written consentment.
(c) Marc BOUGET - 1997/2000
IMPORTANT -- IMPORTANT -- IMPORTANT -- IMPORTANT -- IMPORTANT – IMPORTANT
For any problem or suggestion, email me.
Marc BOUGET
mbouget@club-internet.fr
http://perso.club-internet.fr/mbouget
November 2000.