Calibre UK PICA93LV user manual Int getbytesint far *transferarray, Int nobytesread

Page 28

CALIBRE

 

 

 

 

￿

 

 

 

 

￿

 

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.

Issue 1.3

Page 25

22/07/99

Image 28
Contents Calibre Calibre CopyrightContents Configuring the Adapter IntroductionGeneral Introduction Packing ListInstalling the Adapter Typical PC ConnectionConnecting the Adapter to Your System Connector PinoutPower Supply Bus Capacitance LimitationsSoftware Utilities \C\CLIB\SPICA.LIB\C\CLIB\CPICA.LIB \C\CLIB\MPICA.LIBDOS Qbasic Library/Programs \B\SOURCE\I2CINC.BAS\B\SOURCE\PROMREAD.BAS \B\SOURCE\PROMWRIT.BASWindows LIB/DLL Functions Using the Utilities RoutinesInt ownaddress Int sclkInt slaveaddress Int i2cstatusInt setnack Calibre Int i2cdata Calibre Int i2cstatus Number if the adapter is to read from the slave Qbasic Routines Ownaddress%Sclk% I2cstatus%Slaveaddress% Setnack% I2cdata%See Appendix a for details status codes I2cstatus% Is to read from the slave Int baseaddress Libraries for Programming in Microsoft Windows EnvironmentsInt statuswait Int ErrCode Int wrDataSendaddress Address to be accessed via the I2C, e.g. A1H Int far *transferarray Int sendbytesint far *transferarrayInt bsent Int getbytesint far *transferarray Int nobytesreadSlave using the adapter Further Information Bit 4 The Bus Error BER Bit Appendix a Parallel I2C Communications Adapter Status CodesBit 7 MSB The Pending Interrupt Not PIN Bit Bit 6 Not UsedAppendix B Parallel I2C Communications Adapter Control Codes Question Get corrupted transfers why is this? Most Commonly Asked I2C QuestionsQuestion Do you have software to talk to my........? QuestionCode. Why? Please Email Your Query to