Calibre UK PICA93LV user manual Slave using the adapter

Page 29

 

 

CALIBRE

 

 

 

 

 

 

￿

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

￿

Functional description

The function determines the required transfer format, sends the appropriate

 

sequence of start(s) and slave address(es) and checks for acknowledges

 

where necessary.

 

If the slave fails to acknowledge then a stop is sent and nobytesread is

 

returned equal to 0.

 

The first data byte read is the slave read address sent (see readbyte

 

description). This is discarded, it is not returned in the transfer array. The data

 

bytes are then read and stored in the transfer array. At the appropriate point

 

acknowledges are ceased - for the last and the last but one byte to be

 

transferred.

 

A stop is sent after the last byte has been read. On completion the number of

 

bytes read is returned.

 

Should a time-out occur the transfer is terminated by a stop and the number

 

of bytes successfully read is returned.

 

Getbytes can only be used in master read mode.

4.4.14. slavelastbyte

 

 

 

 

 

Function specification

void slavelastbyte( )

Parameters returned

none.

Prerequisites

Adapter must be configured using setup. This function would normally only

 

be called following the end of a transmission in slave write mode - when the

 

adapter is being read as a slave, by another master, not when writing to a

 

slave using the adapter.

Functional description

This function is used when the adapter is a slave being read by a master

 

elsewhere on the bus - the adapter is in slave write mode. The function must

 

be called immediately after the master indicates the last byte has been read

 

(by not acknowledging that byte). This function is required to clear the I2C

 

data lines so that the master can send a stop signal.

Issue 1.3

Page 26

22/07/99

Image 29
Contents Calibre Copyright CalibreContents Introduction Configuring the AdapterGeneral Introduction Packing ListTypical PC Connection Installing the AdapterConnector Pinout Connecting the Adapter to Your SystemPower Supply Bus Capacitance Limitations\C\CLIB\SPICA.LIB Software Utilities\C\CLIB\CPICA.LIB \C\CLIB\MPICA.LIB\B\SOURCE\I2CINC.BAS DOS Qbasic Library/Programs\B\SOURCE\PROMREAD.BAS \B\SOURCE\PROMWRIT.BASWindows LIB/DLL Functions Routines Using the UtilitiesInt ownaddress Int sclkInt setnack Int i2cstatusInt slaveaddress Calibre Int i2cdata Calibre Int i2cstatus Number if the adapter is to read from the slave Ownaddress% Qbasic RoutinesSclk% I2cstatus%Slaveaddress% I2cdata% Setnack%See Appendix a for details status codes I2cstatus% Is to read from the slave Int statuswait Libraries for Programming in Microsoft Windows EnvironmentsInt baseaddress Int wrData Int ErrCodeSendaddress Address to be accessed via the I2C, e.g. A1H Int bsent Int sendbytesint far *transferarrayInt far *transferarray Int nobytesread Int getbytesint far *transferarraySlave using the adapter Further Information Appendix a Parallel I2C Communications Adapter Status Codes Bit 4 The Bus Error BER BitBit 7 MSB The Pending Interrupt Not PIN Bit Bit 6 Not UsedAppendix B Parallel I2C Communications Adapter Control Codes Most Commonly Asked I2C Questions Question Get corrupted transfers why is this?Question Do you have software to talk to my........? QuestionCode. Why? Please Email Your Query to