17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Also See:<br />

I2C_POLL( ), i2c_speed( ), I2C_SlaveAddr( ), I2C_ISR_STATE(_)<br />

,I2C_WRITE( ),<br />

I2C_READ( ), _USE_I2C( ), I2C( )<br />

i2c_isr_state( )<br />

Syntax:<br />

Parameters:<br />

Returns:<br />

Function:<br />

state = i2c_isr_state();<br />

state = i2c_isr_state(stream);<br />

None<br />

state is an 8 bit int<br />

0 - Address match received with R/W bit clear, perform i2c_read( ) to read<br />

the I2C address.<br />

1-0x7F - Master has written data; i2c_read() will immediately return the<br />

data<br />

0x80 - Address match received with R/W bit set; perform i2c_read( ) to<br />

read the I2C address, and use i2c_write( ) to pre-load the transmit buffer<br />

for the next transaction (next I2C read performed by master will read this<br />

byte).<br />

0x81-0xFF - Transmission completed and acknowledged; respond with<br />

i2c_write() to pre-load the transmit buffer for the next transation (the next<br />

I2C read performed by master will read this byte).<br />

Returns the state of I2C communications in I2C slave mode after an SSP<br />

interrupt. The return value increments with each byte received or sent.<br />

If 0x00 or 0x80 is returned, an i2C_read( ) needs to be performed to read<br />

the I2C address that was sent (it will match the address configured by<br />

#USE I2C so this value can be ignored)<br />

Availability:<br />

Requires:<br />

Examples:<br />

Example Files:<br />

Also See:<br />

Devices with i2c hardware<br />

#USE I2C<br />

#INT_SSP<br />

void i2c_isr() {<br />

state = i2c_isr_state();<br />

if(state== 0 ) i2c_read();<br />

i@c_read();<br />

if(state == 0x80)<br />

i2c_read(2);<br />

if(state >= 0x80)<br />

i2c_write(send_buffer[state - 0x80]);<br />

else if(state > 0)<br />

rcv_buffer[state - 1] = i2c_read();<br />

}<br />

ex_slave.c<br />

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

#USE I2C, I2C Overview<br />

200

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

Saved successfully!

Ooh no, something went wrong!