Calibre UK PICA93LV User Manual

Page of 35
CALIBRE
Issue 1.3
 
Page 25
22/07/99
When all the bytes have been transmitted a stop is issued and the total
number of bytes is returned.
Sendbytes can only be used in master write mode.
4.4.13.
getbytes
Function specification
Int getbytes(int far *transferarray)
Parameters are:
int far *transferarray
The far pointer must point to a single dimensional array the format of which is
detailed below.
The calling function must have initialised elements 0, 1 and 2 prior to calling
the function.
Element no
Element name
Description
0
slaveaddress
Slaveaddress is the address to be accessed via the
I2C Bus, this is in hexadecimal e.g. A0H.
1
wordaddress
Wordaddress is the offset within the slave to which
the first byte of data is to be written, see
transmission format for more detail.
2
nobytes
The number of bytes (n) to be sent. Min value 1.
3
byte 0
First byte read.
"
"
byte n
Last byte read.
Parameters returned
int nobytesread
The number of bytes actually read.
Prerequisites
Adapter must be configured using setup. Array elements 0, 1 and 2 must be
initialised. Elements 3 to n do not need to be initialised since they are where
the read data is returned. The array must be pre-defined to a size at least
large enough to hold all the parameters and data concerned.
Transmission Format
If the slaveaddress has the least significant bit set (1) then this forms a read
address, if the least significant bit is clear (0) then this forms the write
address e.g. A0H is the write address and A1H is the associated read
address.
getbytes supports two transfer formats these being:
i.
start-slavereadaddress-byte(s)-stop
To select transfer format i) pass the read address as slaveaddress.
The wordaddress is not used in this format and is ignored by getbytes.
ii.
start-slavewriteaddress-wordaddress-restart-slavereadaddress-byte(s)-
stop
To select transfer format ii) pass the write address as slaveaddress.
In this format the wordaddress must be valid.
wordaddress is pointer to the first byte of data to be read.
nobytestoread is the number of bytes to be read. The minimum value
allowable is 1.