Calibre UK PICA93LV Manual De Usuario

Descargar
Página de 35
CALIBRE
Issue 1.3
 
Page 15
22/07/99
See Appendix A for details of the status values returned.
I2C status on exit:
The status of the Parallel I2C Communications Adapter will not be affected by
using the FNgetstatus% function.
Example Usage:
(see also sample programs)
'This will read the Parallel I2C Communications Adapters current status
sub main
i2cstatus% = getstatus
print"Parallel I2C Communications Adapter Status = " + hex$(i2cstatus)
end sub
4.3.3.
I2C Address and Start Sending Routine
Function definition:
sendaddress(slaveaddress as integer, setnack as integer)
Usage:
i2cstatus = sendaddress(slaveaddress%, setnack%)
Function:
procedure to send Start and slave address of device which is to be
communicated with.
Parameters are:
slaveaddress%
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.
setnack%
This controls whether the Parallel 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
must be enabled. If setnack% = 0 then 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 clear = 0.
Value Returned:
I2cstatus%
The value returned depends on whether the Start and address were sent.
If the start and address have been sent then the status returned will either be
&H00 (bus busy data sent and acknowledged), or 0x08 (bus busy, data sent
but not acknowledged).
If the start or the address cannot be sent (either the bus remained busy or the
address did not get sent) then the last status read IORed with &H8000 will be
returned.
The function will read the status a number of times before returning an error
condition - this number is defined by the MAXNUMBEROFGOES constant
defined in I2CINC.BAS, this value may be altered to suit your system.
I2C status on exit 
&H00 bus busy and address sent and acknowledged
&H08 bus busy and address sent but not acknowledged
&H80 bus busy and address not sent.
(see Appendix A for details of Status codes).
Example Usage:
(see also sample programs)
' This will send a Start and the I2C Slave Address of the device to be communicated with.