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.

Built-in Functions<br />

i2c_poll( )<br />

Syntax:<br />

Parameters:<br />

Returns:<br />

Function:<br />

Availability:<br />

Requires:<br />

Examples:<br />

Example Files:<br />

Also See:<br />

i2c_poll()<br />

i2c_poll(stream)<br />

stream (optional)- specify the stream defined in #USE I2C<br />

1 (TRUE) or 0 (FALSE)<br />

The I2C_POLL() function should only be used when the built-in SSP is<br />

used. This function returns TRUE if the hardware has a received byte in the<br />

buffer. When a TRUE is returned, a call to I2C_READ() will immediately return<br />

the byte that was received.<br />

Devices with built in I2C<br />

#USE I2C<br />

if(i2c-poll())<br />

buffer [index]=i2c-read();//read data<br />

None<br />

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

#USE I2C, I2C Overview<br />

i2c_read( )<br />

Syntax:<br />

data = i2c_read();<br />

data = i2c_read(ack);<br />

data = i2c_read(stream, ack);<br />

Parameters: ack -Optional, defaults to 1.<br />

0 indicates do not ack.<br />

1 indicates to ack.<br />

2 slave only, indicates to not release clock at end of read. Use when<br />

i2c_isr_state ()<br />

returns 0x80.<br />

stream - specify the stream defined in #USE I2C<br />

Returns:<br />

data - 8 bit int<br />

201

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

Saved successfully!

Ooh no, something went wrong!