Calibre UK PICA93LV Int sendbytesint far *transferarray, Int far *transferarray, Int bsent

Page 27

CALIBRE

￿

￿

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.

Issue 1.3

Page 24

22/07/99

Image 27
Contents Calibre Copyright CalibreContents Packing List Configuring the AdapterIntroduction General IntroductionTypical PC Connection Installing the AdapterBus Capacitance Limitations Connecting the Adapter to Your SystemConnector Pinout Power Supply\C\CLIB\MPICA.LIB Software Utilities\C\CLIB\SPICA.LIB \C\CLIB\CPICA.LIB\B\SOURCE\PROMWRIT.BAS DOS Qbasic Library/Programs\B\SOURCE\I2CINC.BAS \B\SOURCE\PROMREAD.BASWindows LIB/DLL Functions Int sclk Using the UtilitiesRoutines Int ownaddressInt i2cstatus Int slaveaddressInt setnack Calibre Int i2cdata Calibre Int i2cstatus Number if the adapter is to read from the slave I2cstatus% Qbasic RoutinesOwnaddress% Sclk%Slaveaddress% I2cdata% Setnack%See Appendix a for details status codes I2cstatus% Is to read from the slave Libraries for Programming in Microsoft Windows Environments Int baseaddressInt statuswait Int wrData Int ErrCodeSendaddress Address to be accessed via the I2C, e.g. A1H Int sendbytesint far *transferarray Int far *transferarrayInt bsent Int nobytesread Int getbytesint far *transferarraySlave using the adapter Further Information Bit 6 Not Used Bit 4 The Bus Error BER BitAppendix a Parallel I2C Communications Adapter Status Codes Bit 7 MSB The Pending Interrupt Not PIN BitAppendix B Parallel I2C Communications Adapter Control Codes Question Question Get corrupted transfers why is this?Most Commonly Asked I2C Questions Question Do you have software to talk to my........?Code. Why? Please Email Your Query to