Calibre UK IC Communication Adapter ICA93LV User Manual
Page 8
Revision 1.7
Page 7 of 27
09/12/1999
Parameters are:
int controladdress
address of I
2
C control register. This is equal to 1+(base address of adapter set
by links on circuit board).
Value Returned:
int
where status is an integer from 0x00 to 0xFF which indicates the current status
of I
2
C Communications Adapter. See Appendix A for details of the status values
returned.
I
2
C status on exit from routine:
The status of the I
2
C Communications Adapter will not be affected by using the
getstatus function.
Example Usage: (see also sample programs)
#include
#include
/*Optional, but recommended if your compiler */
/*supports DOS I/O functions */
#include
/*This contains the I
2
C routines */
main
{
int status, base, controladdress;
base = 0x310;
/*Adapter’s base address = 0x310 (hex) */
controladdress = base + 1;
Status = getstatus (controladdress);
printf(“I
2
C Communications Adapter Status = %x\n”, status);
}
/*This will read the I
2
C Communications Adapter’s current status */
5.1.3.
I
2
C 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 I
2
C 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 I
2
C Communications Adapter transmits an
Acknowledge down the I
2
C 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.
I
2
C status on exit from routine
The status of the I
2
C/ 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
#include
/* Adapter’s base address = 0x310 (hex) */
/* compiler supports DOS I/O functions */
#include
/* This contains the I
2
C routines */
main