CALIBRE
Example Usage: | (see also sample programs) |
'This will write a byte of data to a slave previously addressed by sendaddress. */ Sub main
i2cdata$ = &H69 ' Data byte which is to be transmitted */ i2cstatus$ = writebyte (i2cdata$)
if (i2cstatus and &H8000) = &H8000 then
print "Data has not been transmitted status is " + HEX$( i2cstatus%)
else
print "Data has been transmitted"
End If
End Sub
4.3.6.Send an I2C Stop Routine
Function definition: | sendstop%() |
Usage: | i2cstatus% = sendstop |
Function: | procedure to send a Stop (end of communication signal) down the I2C Bus, |
| sending a transmission or reception with a slave which was address |
| previously by sendaddress. |
Parameters are: Value Returned:
I2C status on exit:
Example Usage:
None.
i2cstatus%.
The value returned depends on whether the bus became free. If the bus became free then the status (&H81) is returned.
If the bus does not became free then the last status read IORed with &H8000 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.BAS, this value may be altered to suit your system.
The status of the Parallel I2C Communications Adapter will be &H81 - 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). (see also sample programs)
'This will write a Stop to the I2C Bus sub main
i2cstatus = sendstop
print "Stop has been transmitted status is " + HEX$( i2cstatus%)
end sub
Issue 1.3 | Page 18 |
22/07/99