mraa  0.4.5
Low Level Skeleton Library for Communication on GNU/Linux platforms
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions
Spi Class Reference

Detailed Description

This file defines the SPI interface for libmraa

mraa::Spi* spi;
spi = new mraa::Spi(0);
char data[] = {0x00, 100};
char *recv;
while (running == 0) {
int i;
for (i = 90; i < 130; i++) {
data[1] = i;
recv = spi->write(data, 2);
printf("Writing -%i",i);
printf("RECIVED-%i-%i\n",recv[0],recv[1]);
usleep(100000);
}
for (i = 130; i > 90; i--) {
data[1] = i;
recv = spi->write(data, 2);
printf("Writing -%i",i);
printf("RECIVED-%i-%i\n",recv[0],recv[1]);
usleep(100000);
}
}
delete spi;

Public Member Functions

 Spi (int bus)
 
 ~Spi ()
 
mraa_result_t mode (mraa_spi_mode_t mode)
 
mraa_result_t frequency (int hz)
 
char write (char data)
 
char * write (char *data, size_t length)
 
mraa_result_t lsbmode (bool lsb)
 
mraa_result_t bitPerWord (unsigned int bits)
 

Constructor & Destructor Documentation

Spi ( int  bus)
inline

Initialise SPI object using the board mapping to set muxes

Parameters
busto use, as listed in the platform definition, normally 0

Here is the call graph for this function:

~Spi ( )
inline

Closes spi bus

Here is the call graph for this function:

Member Function Documentation

mraa_result_t mode ( mraa_spi_mode_t  mode)
inline

Set the SPI device mode. see spidev0-3

Parameters
modethe mode. See Linux spidev doc
Returns
Result of operation

Here is the call graph for this function:

mraa_result_t frequency ( int  hz)
inline

Set the SPI device operating clock frequency

Parameters
hzthe frequency to set in hz
Returns
Result of operation

Here is the call graph for this function:

char write ( char  data)
inline

Write single byte to the SPI device

Parameters
datathe byte to send
Returns
data received on the miso line

Here is the call graph for this function:

char* write ( char *  data,
size_t  length 
)
inline

Write buffer of bytes to SPI device

Parameters
databuffer to send
lengthsize of buffer to send
Returns
char* data received on the miso line. Same length as passed in

Here is the call graph for this function:

mraa_result_t lsbmode ( bool  lsb)
inline

Change the SPI lsb mode

Parameters
lsbUse least significant bit transmission - 0 for msbi
Returns
Result of operation

Here is the call graph for this function:

mraa_result_t bitPerWord ( unsigned int  bits)
inline

Set bits per mode on transaction, default is 8

Parameters
bitsbits per word
Returns
Result of operation

Here is the call graph for this function:


The documentation for this class was generated from the following file: