Calibre UK PICA93LV user manual Int i2cstatus, Int slaveaddress, Int setnack

Page 11

CALIBRE

￿

￿

4.2.2.I2C Status Checking Routine

Function definition:

int getstatus(void)

Usage:

i2cstatus = getstatus();

Function:

function to read status register of the Parallel I2C Communications Adapter.

Parameters are:

None

Value Returned:

int i2cstatus

I2C status on exit:

where i2cstatus is an integer from 0x00 to 0xFF which indicates the current status of Parallel I2C Communications Adapter. See Appendix A for details of the status values returned.

the status of the Parallel I2C Communications Adapter will not be affected by using the getstatus function.

Example Usage: (see also sample programs) main()

{

int i2cstatus;

i2ctatus = getstatus ();

printf("Parallel I2C Communications Adapter Status = %x\n", i2cstatus);

}

/*This will read the Parallel I2C Communications Adapter's current status*/

4.2.3.I2C Address and Start Sending Routine

Function definition:

int sendaddress (int slaveaddress, int setnack)

Usage:

i2cstatus = sendaddress(slaveaddress, setnack)

Function:

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

 

communicated with.

Parameters are:

int slaveaddress

 

The 8 bit slave address of the device which is to be communicated with. This

 

will be an even number if the adapter is to write to the slave, add 1 to get an

 

odd number if the adapter is to read from the slave.

 

int setnack

 

This controls whether the Parallel I2C Communications Adapter transmits an

 

Acknowledge down the I2C Bus on reception of a byte. The last byte received

 

during a transfer must not be acknowledged. If setnack = 0 then acknowledge

 

is enabled, if setnack = 1 then acknowledge is disabled. Therefore, if a read

 

(odd numbered) address is being sent AND only 1 byte is to be read, setnack

 

should be set = 1; in all other cases it must be clear = 0.

Value Returned:

int i2cstatus

 

The value returned depends on whether the Start and address were sent.

 

If the start and address have been sent then the status returned will either be

 

0x00 (bus busy data sent and acknowledged), or 0x08 (bus busy, data sent

 

but not acknowledged).

 

If the start or the address cannot be sent (either the bus remained busy or the

 

address did not get sent) then the last status read IORed with 0x8000 will be

 

returned.

Issue 1.3

Page 8

22/07/99

Image 11
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 setnack Int i2cstatusInt slaveaddress 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 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 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