Writebyte, Readbyte, Sendstop – Calibre UK UCA93 User Manual

Page 11: Restart, Calibre

Advertising
background image

CALIBRE

Issue 1.0

Page 8

01/07/03

WriteByte

Function specification

Int WriteByte(int DataByte)

Parameters are:

int DataByte
This is the byte of data to be written.

Parameters returned

int ErrCode.
If the transfer time out occurs error code 8002H is returned otherwise the
status is returned.

Prerequisites

Adapter must be configured using Setup, start and write address sent by
SendAddress.

Functional description The function writes the data to the Adapter and then waits for it to be sent.

Should a time-out occur during the sending of the data then error code 8002H
is returned, otherwise the status is returned.
WriteByte is compatible with both master write and slave write modes.

3.3.3.

ReadByte

Function specification

Int ReadByte(int SetNack)

Parameters are:

int SetNack
This controls whether the Adapter transmits an acknowledge down the I2C bus
on reception of a byte. The last byte received during a transfer must not be
acknowledged, in all other cases acknowledge must be enabled. If SetNack = 0
then acknowledge is enabled, if SetNack = 1 then acknowledge is disabled.

Parameters returned

int I2CData
If a time-out occurs the ErrCode 8003H is returned, otherwise the data is
returned.

Prerequisites

Adapter must be configured using Setup, start and read address sent by
SendAddress.

Functional description The data is read from the Adapter.

ReadByte is compatible with both master read and slave read modes.

3.3.4.

SendStop

Function specification

Int SendStop(void)

Parameters are:

None

Parameters returned

int ErrCode.
If the transfer time out occurs error code 8006H is returned otherwise the
status is returned.

Prerequisites

Adapter must be configured using Setup. Should normally only be used at the
end of a transmission. Correct acknowledge sequence must have been applied
if the transmission was a read.

Functional description

Instructs the Adapter to send a stop code and wait for it to be sent.
Should a time-out occur during the sending of a stop then an error code 8006H
is returned, otherwise the status is returned.

3.3.5.

Restart

Function specification

Int Restart(int SlaveAddress, int SetNack)

Parameters are:

int slaveaddress
The address to be accessed via the I2C, e.g. A1H.
int SetNack
This controls whether the Adapter transmits an acknowledge down the I2C bus
on reception of a byte. The last byte received during a transfer must not be
acknowledged, in all other cases acknowledge must be enabled. If SetNack = 0
then acknowledge is enabled, if SetNack = 1 then acknowledge is disabled. It is
normal to read data after a restart and hence SetNack will normally be 0.

Parameters returned

int ErrCode
If the transfer time out occurs error code 8004H is returned otherwise the
status is returned.

Prerequisites

Adapter must be configured using Setup. A start and slave address must have
previously been sent using SendAddress.

Advertising