Справочник Пользователя для Calibre UK PICA93LV

Скачать
Страница из 35
CALIBRE
Issue 1.3
 
Page 24
22/07/99
Functional description
This function issues two consecutive stop commands on the bus, with a delay
in between. It then clears the adapter registers and reads the status. This
should normally set the adapter into a known idle state when a bus error or
other problem has occurred.
If the status does not indicate bus free or the bus Error bit is still set then
8006H is returned otherwise the status is returned.
4.4.12.
sendbytes
Function specification
Int sendbytes(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 to be sent.
"
"
byte n
Last byte to be sent.
Parameters returned
int bsent
The number of bytes actually sent.
Prerequisites
Adapter must be configured using setup. Array elements 0, 1 and 2 must be
initialised. Usually elements 3 to n would also be initialised. Array must be
pre-defined to a size at least large enough to hold all the parameters and data
concerned.
Transmission format
There are two transmission formats, these are :
i.
start-slaveaddress-byte(s)-stop
If transmission format i) is required set the wordaddress to a number
greater than FFH.
ii.
start-slaveaddress-wordaddress-byte(s)-stop
If transmission format ii) is required set the wordaddress to a number
less than or equal to FFH.
Functional description
The function determines the required transmission format and then sends a
start code and the slave address.
If transmission format ii) has been selected the wordaddress is sent.
The data bytes are then transmitted sequentially.
Should a time-out occur or the slave not acknowledge a transfer the
transmission is terminated by a stop and the number of bytes actually
transmitted is returned.