Calibre UK PICA93LV user manual Int i2cstatus

Page 15

CALIBRE

￿

￿

4.2.6.Send an I2C Stop Routine

Function definition:

int sendstop(void)

Usage:

i2cstatus = sendstop();

Function:

This is the procedure to send a stop (end of communication signal) down the

 

I2C Bus, ending a transmission or reception with a slave which was

 

addressed previously by sendaddress.

Parameters are: Value Returned:

I2C status on exit:

Example Usage:

None.

int i2cstatus.

The value returned depends on whether the bus became free. If the bus became free then the status (0x81) is returned.

If the bus does not became free then the last status read IORed with 0x8000 will be returned.

The function will read the status a number of times, waiting for the bus to become free, before returning an none free status - this number is defined by the MAXNUMBEROFGOES constant defined in I2CINC.C, this value may be altered to suit your system.

The status of the Parallel I2C Communications Adapter will be 0x81 - bus idle and no unread / untransmitted data in data register.

Note - this may not be the case in a system where there is another master as well as the Parallel I2C Communications Adapter, since this other master may well have taken control of the bus by the time a program next uses getstatus to read the status register.

(See Appendix A for details of status codes). (see also sample programs)

/* This will write a Stop to the I2C Bus */ main()

{

int i2cstatus;

i2cstatus = sendstop();

printf("Stop has been transmitted status is %x\n", i2cstatus);

}

4.2.7.I2C Restart and Address Sending Routine

Function Definition:

int restart(int slaveaddress, int setnack)

Usage:

i2cstatus = restart(slaveaddress, setnack)

Function:

This is the procedure to send Restart and slave address of device which is to

 

be communicated with, without a Stop having been sent at the end of last

 

transmission/reception. This routine is particularly useful for reading

 

memories which must first have a data pointer written to them to select where

 

the read is to occur from, and must have their address sent a Restart to

 

proceed with the read operation.

Issue 1.3

Page 12

22/07/99

Image 15
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