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.

Built-in Functions<br />

spi_write( ) spi_write2( )<br />

Syntax:<br />

Parameters:<br />

Returns:<br />

Function:<br />

Availability:<br />

Requires:<br />

spi_write([wait],value);<br />

spi_write2([wait],value);<br />

value is an 8 bit int<br />

wait- an optional parameter specifying whether the function will wait for the<br />

SPI transfer to complete before exiting. Default is TRUE if not specified.<br />

Nothing<br />

Sends a byte out the SPI interface. This will cause 8 clocks to be generated.<br />

This function will write the value out to the SPI. At the same time data is<br />

clocked out data is clocked in and stored in a receive buffer. spi_read() may<br />

be used to read the buffer.<br />

This function is only available on devices with SPI hardware.<br />

Nothing<br />

Examples:<br />

spi_write( data_out );<br />

data_in = spi_read();<br />

Example Files:<br />

Also See:<br />

ex_spi.c<br />

spi_read(), spi_data_is_in(), SPI Overview, spi_write_16(), spi_read_16()<br />

spi_xfer( )<br />

Syntax:<br />

Parameters:<br />

Returns:<br />

spi_xfer(data)<br />

spi_xfer(stream, data)<br />

spi_xfer(stream, data, bits)<br />

result = spi_xfer(data)<br />

result = spi_xfer(stream, data)<br />

result = spi_xfer(stream, data, bits)<br />

data is the variable or constant to transfer via SPI. The pin used to<br />

transfer data is defined in the DO=pin option in #use spi. stream is the<br />

SPI stream to use as defined in the STREAM=name option in #USE<br />

SPI.<br />

bits is how many bits of data will be transferred.<br />

The data read in from the SPI. The pin used to transfer result is defined<br />

in the DI=pin option in #USE SPI.<br />

317

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

Saved successfully!

Ooh no, something went wrong!