17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Function:<br />

Availability:<br />

Requires:<br />

Examples:<br />

Reads a byte over the I2C interface. In master mode this function will<br />

generate the clock and in slave mode it will wait for the clock. There is no<br />

timeout for the slave, use i2c_poll() to prevent a lockup. Use restart_wdt() in<br />

the #USE I2C to strobe the watch-dog timer in the slave mode while waiting.<br />

All devices.<br />

#USE I2C<br />

i2c_start();<br />

i2c_write(0xa1);<br />

data1 = i2c_read(TRUE);<br />

data2 = i2c_read(FALSE);<br />

i2c_stop();<br />

Example Files: ex_extee.c with 2416.c<br />

Also See:<br />

i2c_poll, i2c_speed, i2c_start, i2c_stop, i2c_slaveaddr, i2c_isr_state, i2c_write,<br />

#USE I2C, I2C Overview<br />

i2c_slaveaddr( )<br />

Syntax:<br />

Parameters:<br />

Returns:<br />

Function:<br />

Availability:<br />

Requires:<br />

Examples:<br />

Example Files:<br />

Also See:<br />

I2C_SlaveAddr(addr);<br />

I2C_SlaveAddr(stream, addr);<br />

addr = 8 bit device address<br />

stream(optional) - specifies the stream used in #USE I2C<br />

Nothing<br />

This functions sets the address for the I2C interface in slave mode.<br />

Devices with built in I2C<br />

#USE I2C<br />

i2c_SlaveAddr(0x08);<br />

i2c_SlaveAddr(i2cStream1, 0x08);<br />

ex_slave.c<br />

i2c_poll, i2c_speed, i2c_start, i2c_stop, i2c_isr_state, i2c_write, i2c_read,<br />

#USE I2C, I2C Overview<br />

202

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!