I2C Driver 32 Version 4.11

Running under Windows 95, 98, NT 4.0 and 2000

Presentation

This is an evolution of the 4th version of my I2C bus driver.

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

The package

After download, you have to unzip the archive with folders.

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)
 

Installation

A faire par tous, même ceux qui utilisaient une ancienne version de I2C_Drv32.

Configuration

You have to edit the I2C.INI file to specify your hardware (default interface to use, NOPS for your computer (depend on speed, 40 works fine in my Dual Celeron 400 under Windows 2000))

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)
 

Function description

I2C_SelectInterface

Input parameter(s) : integer 16 bits
Output parameter : integer 16 bits
This must be the FIRST function call in your program for selecting the right hardware to use. If uncalled, the driver will switch to the default device specified in I2C.INI (if any !).
Input :
0 = default device specified in I2C.INI
1 = Elektor card PCF8584
2 = Philips // adapter
3 = Custom  // adapter
Ouput :
0 = OK
1 = interface error
 

I2C_Init

Input parameter(s) : none
Output parameter : integer 16 bits (unused)

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" !)
 

I2C_Info

Input parameter(s) : none
Output parameter : integer 16 bits (unused)

It display a dialog box with the hardware name in use.
 

I2C_Start

Input parameter(s) : none
Output parameter : integer 16 bits

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)
 

I2C_Stop

Input parameter(s) : none
Output parameter : integer 16 bits

This function close the bus sending a stop condition.
Output :
0 = OK
or I2CBUSERROR
 

I2C_Address

Input parameter(s) : integer 16 bits (address on the LSB)
Output parameter : integer 16 bits

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)
 

I2C_Send

Input parameter(s) : integer 16 bits, 32 bits pointer on buffer
Output parameter : integer 16 bits

This function send N bytes from the buffer to the bus. The return code is the number of byte sent (like printf)

I2C_Read

Input parameter(s) : integer 16 bits, 32 bits pointer on buffer
Output parameter : integer 16 bits

This function read N bytes from the bus to the buffer. The return code is the number of byte read (like canf)
 

Example (C)

Reading of 15 bytes from the device at address 0x20 :

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

Philips Adapter

                                        LS05 pin 14 (Vcc) o      -------
                                                          |      |     |
           +--+--+---------------------+--+--+------------+------+-o 1 |
           |  |  |                     |  |  |           ===.1uF | +5V |
 -------- [R][R][R] 3x10K       3x10K [R][R][R]   LS05    |      |     |
 |      |  |  |  |                     |  |  |    pin 7 o-+------+-o 2 |
 | 12 o-+--+  |  |   3|\ 4             |  |  |    (Gnd)          | GND |
 | 17 o-+-----|--|----| >o-------------+--|--|--------------+    |     |
 |      |     |  |    |/        8 /|9     |  |     10 /|11  +----+-o 3 |
 | 15 o-+-----+--|--------------o< |------+--|------o< |----+    | SCL |
 |      |        |   1|\ 2        \|         |        \|         |     |
 |  9 o-+--------|----| >o-------------------+--------------+----+-o 4 |
 |      |        |    |/                            6 /|5   |    | SDA |
 | 11 o-+--------+----------------------------------o< |----+    -------
 | 10 o-+-+                                           \|          4-pin
 | 13 o-+-+--oGND                                               Connector
 | 25 o-+-+        ------------------ Part List --------------------------
 --------          | 1 - .1 uF capacitor   | 6 - 10K 5% resistors        |
 25-pin male D     | 1 - 4-pin connector   | 1 - 25-pin male D connector |
 connector to PC   | 1 - 74LS05 open collector hex inverter              |
 printer port      -------------------------------------------------------
( (c) Philips Electronics )
 

Todo

-Use registry
-Make it beter ?
-Integrate Brooktree BT848 I2C support (I've ask some questions 2 years to Brooktree, I'm still waiting for any reply !)
-If you have any idea

Conclusion

IMPORTANT -- IMPORTANT -- IMPORTANT -- IMPORTANT -- IMPORTANT -- IMPORTANT

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.