CALIBRE
Issue 1.3 Page 12
22/07/99
4.2.6. Send an I2C Stop Routine
Function definition: int sendstop(void)
Usage: i2cstatus = sendstop();
Function: This is the procedure to send a stop (end of communication signal) down the
I2C Bus, ending a transmission or reception with a slave which was
addressed previously by sendaddress.
Parameters are: None.
Value Returned: int i2cstatus.
The value returned depends on whether the bus became free.
If the bus became free then the status (0x81) is returned.
If the bus does not became free then the last status read IORed with 0x8000
will be returned.
The function will read the status a number of times, waiting for the bus to
become free, before returning an none free status - this number is defined by
the MAXNUMBEROFGOES constant defined in I2CINC.C, this value may be
altered to suit your system.
I2C status on exit: The status of the Parallel I2C Communications Adapter will be 0x81 - bus idle
and no unread / untransmitted data in data register.
Note - this may not be the case in a system where there is another master as
well as the Parallel I2C 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)
/* This will write a Stop to the I2C Bus */
main()
{
int i2cstatus;
i2cstatus = sendstop();
printf("Stop has been transmitted status is %x\n", i2cstatus);
}
4.2.7. I2C Restart and Address Sending Routine
Function Definition: int restart(int slaveaddress, int setnack)
Usage: i2cstatus = restart(slaveaddress, setnack)
Function: This is the procedure to send Restart and slave address of device which is to
be communicated with, without a Stop having been sent at the end of last
transmission/reception. This routine is particularly useful for reading
memories which must first have a data pointer written to them to select where
the read is to occur from, and must have their address sent a Restart to
proceed with the read operation.