Calibre UK IC Communication Adapter ICA93LV User Manual
Page 10

Revision 1.7
Page 9 of 27
09/12/1999
/* This will read a byte of data from a slave previously addressed */
/* by and with acknowledge already disabled by sendaddress. */
/* After reading the data, acknowledge will be re-enabled. */
5.1.5.
Write Data Byte to Slave Routine
Name:
writebyte(base, data)
Usage:
writebyte(base, data)
Function:
procedure to write a byte of data to a slave device whose slave address has
already been sent by sendaddress.
Parameters are:
int base
The base address of the I
2
C Communications Adapter set by links on circuit
board.
int data
The byte of data which is to be written to the slave device.
Value Returned:none.
I
2
C status on exit from routine:
The status of the I
2
C Communications Adapter will be 0x00 - bus busy and data
in the data register transmitted successfully. (See Appendix A for details of
Status Codes).
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 base, data;
base = 0x310;
/* Adapter’s base address = 0 x 310- (hex) */
data = 0x69;
/* Data byte which is to be transmitted */
writebyte (base, data) ;
printf(“Data has been transmitted\n”);
}
/* This will write a byte of data to a slave previously addressed */
/* by sendaddress. */
5.1.6.
Send an I
2
C Stop Routine
Name:
sendstop(controladdress)
Usage:
sendstop(controladdress);
Function:
procedure to send a stop (end of communication signal) down the I
2
C Bus,
ending a transmission or reception with a slave which was addressed previously
by sendaddress.
Parameters are:
int controladdress
the address of the I
2
C Communications Adapter control register, equal to
1+(base address set by links on circuit board).
Value Returned:none.
I
2
C status on exit from routines:
The status of the I
2
C/ the Communications Adapter will be 0x81 - bus idle and no
unread/untransmitted data in the data register. Note - this may not be the case in
a system where there is another master as well as the I
2
C Communications
Adapter, since this other master may well have taken control of the bus by the
time a program next uses getstatus to read the status register. (See Appendix A
for details of Status Codes).
Example Usage:
(see also sample programs)
#include