Calibre UK ICA93LV user manual 3. I2C Address and Start Sending Routine

Page 8
/*Optional, but recommended if your compiler */ /*supports DOS I/O functions */
/*This contains the I2C routines */

Parameters are:

 

int controladdress

address of I2C control register. This is equal to 1+(base address of adapter set

 

by links on circuit board).

Value Returned:

 

int <status>

where status is an integer from 0x00 to 0xFF which indicates the current status

 

of I2C Communications Adapter. See Appendix A for details of the status values

 

returned.

I2C status on exit from routine:

The status of the I2C Communications Adapter will not be affected by using the getstatus function.

Example Usage: (see also sample programs) #include <stdio.h.>

#include <dos.h>

#include <i2c.h> main

{

int status, base, controladdress;

base = 0x310;/*Adapter’s base address = 0x310 (hex) */ controladdress = base + 1;

Status = getstatus (controladdress);

printf(“I2C Communications Adapter Status = %x\n”, status);

}

/*This will read the I2C Communications Adapter’s current status */

5.1.3.I2C Address and Start Sending Routine

Name:

sendaddress (base, slv, setnack)

Usage:

sendaddress(base, slv, setnack)

Function:

procedure to send Start and slave address of device that is to be communicated

 

with.

Parameters are:

 

int base

the base address of the I2C Communications Adapter set by links on circuit

 

board.

int slv

the slave address of the device which is to be communicated with. This will be an

 

even number if the adapter is to write to the slave, add 1 to get an odd number if

 

the adapter is to read from the slave.

int setnack

this controls whether the I2C Communications Adapter transmits an

 

Acknowledge down the I2C Bus on reception of a byte. The last byte received

 

during a transfer must not be acknowledged, in all other cases acknowledge is

 

enabled, if setnack = 1 then acknowledge is disabled. Therefore, if a read (odd

 

numbered) address is being sent AND only 1 byte is to be read, setnack should

 

be set to = 1; in all other cases it must be set = 0.

Value Returned:none.

 

I2C status on exit from routine

 

The status of the I2C/ the Communications Adapter will be either 0x00 - bus busy

 

and unread data in the data register or 0x80 - bus busy and no unread data in the

 

data register when a Start and Slave Address have been successfully transmitted

 

(see Appendix A for details of Status Codes).

Example Usage:

(see also sample programs)

#include <stdio.h>

 

#include <dos.h>

/* Adapter’s base address = 0x310 (hex) */

 

/* compiler supports DOS I/O functions */

#include <i2c.h>

/* This contains the I2C routines */

main

 

Revision 1.7

Page 7 of 27

09/12/1999

 

Image 8
Contents Contents ICA93LVIntroduction Packing ListWait State Generator Configuring the AdapterSetting the Adapter Base Address 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/Programs2. I2C Status Checking Routine Using the UtilitiesRoutines 1. I2C Setup/Initialisation 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 Restart SendaddressSendstop 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