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 />

Transfers data to and reads data from an SPI device.<br />

All devices with SPI support.<br />

#USE SPI<br />

Examples:<br />

int i = 34;<br />

spi_xfer(i);<br />

// transfers the number 34 via SPI<br />

int trans = 34, res;<br />

res = spi_xfer(trans);<br />

// transfers the number 34 via SPI<br />

// also reads the number coming in from SPI<br />

Example Files: None<br />

Also See:<br />

#USE SPI<br />

SPII_XFER_IN()<br />

Syntax:<br />

Parameters:<br />

Returns:<br />

Function:<br />

Availability:<br />

Requires:<br />

Examples:<br />

Example Files:<br />

Also See:<br />

value = spi_xfer_in();<br />

value = spi_xfer_in(bits);<br />

value = spi_xfer_in(stream,bits);<br />

stream – is the SPI stream to use as defined in the STREAM=name<br />

option in #USE SPI.<br />

bits – is how many bits of data to be received.<br />

The data read in from the SPI<br />

Reads data from the SPI, without writing data into the transmit buffer first.<br />

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

#USE SPI, and the option SLAVE is used in #USE SPI to setup PIC as a<br />

SPI slave device.<br />

data_in = spi_xfer_in();<br />

ex_spi_slave.c<br />

#USE SPI, spi_xfer(), spi_prewrite(), spi_init(), spi_speed()<br />

sprintf( )<br />

Syntax:<br />

sprintf(string, cstring, values...);<br />

bytes=sprintf(string, cstring, values...)<br />

318

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

Saved successfully!

Ooh no, something went wrong!