Private
Public Access
2
0

spi.hpp: styling/identation fix

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2015-01-14 11:47:47 +00:00
parent c28eea88f7
commit 16fc50bc31

View File

@@ -61,12 +61,14 @@ class Spi {
throw std::invalid_argument("Error initialising SPI bus"); throw std::invalid_argument("Error initialising SPI bus");
} }
} }
/** /**
* Closes spi bus * Closes spi bus
*/ */
~Spi() { ~Spi() {
mraa_spi_stop(m_spi); mraa_spi_stop(m_spi);
} }
/** /**
* Set the SPI device mode. see spidev0-3 * Set the SPI device mode. see spidev0-3
* *
@@ -76,6 +78,7 @@ class Spi {
mraa_result_t mode(Spi_Mode mode) { mraa_result_t mode(Spi_Mode mode) {
return mraa_spi_mode(m_spi, (mraa_spi_mode_t) mode); return mraa_spi_mode(m_spi, (mraa_spi_mode_t) mode);
} }
/** /**
* Set the SPI device operating clock frequency * Set the SPI device operating clock frequency
* *
@@ -85,6 +88,7 @@ class Spi {
mraa_result_t frequency(int hz) { mraa_result_t frequency(int hz) {
return mraa_spi_frequency(m_spi, hz); return mraa_spi_frequency(m_spi, hz);
} }
/** /**
* Write single byte to the SPI device * Write single byte to the SPI device
* *
@@ -94,6 +98,7 @@ class Spi {
uint8_t writeByte(uint8_t data) { uint8_t writeByte(uint8_t data) {
return mraa_spi_write(m_spi, (uint8_t) data); return mraa_spi_write(m_spi, (uint8_t) data);
} }
/** /**
* Write buffer of bytes to SPI device The pointer return has to be * Write buffer of bytes to SPI device The pointer return has to be
* free'd by the caller. It will return a NULL pointer in cases of * free'd by the caller. It will return a NULL pointer in cases of
@@ -106,10 +111,11 @@ class Spi {
uint8_t* write(uint8_t* txBuf, int length) { uint8_t* write(uint8_t* txBuf, int length) {
return mraa_spi_write_buf(m_spi, txBuf, length); return mraa_spi_write_buf(m_spi, txBuf, length);
} }
#ifndef SWIG #ifndef SWIG
/** /**
* Transfer data to and from SPI device Receive pointer may be null if return * Transfer data to and from SPI device Receive pointer may be null if
* data is not needed. * return data is not needed.
* *
* @param data buffer to send * @param data buffer to send
* @param rxBuf buffer to optionally receive data from spi device * @param rxBuf buffer to optionally receive data from spi device
@@ -120,6 +126,7 @@ class Spi {
return mraa_spi_transfer_buf(m_spi, txBuf, rxBuf, length); return mraa_spi_transfer_buf(m_spi, txBuf, rxBuf, length);
} }
#endif #endif
/** /**
* Change the SPI lsb mode * Change the SPI lsb mode
* *
@@ -129,6 +136,7 @@ class Spi {
mraa_result_t lsbmode(bool lsb) { mraa_result_t lsbmode(bool lsb) {
return mraa_spi_lsbmode(m_spi, (mraa_boolean_t) lsb); return mraa_spi_lsbmode(m_spi, (mraa_boolean_t) lsb);
} }
/** /**
* Set bits per mode on transaction, default is 8 * Set bits per mode on transaction, default is 8
* *
@@ -138,7 +146,8 @@ class Spi {
mraa_result_t bitPerWord(unsigned int bits) { mraa_result_t bitPerWord(unsigned int bits) {
return mraa_spi_bit_per_word(m_spi, bits); return mraa_spi_bit_per_word(m_spi, bits);
} }
private: private:
mraa_spi_context m_spi; mraa_spi_context m_spi;
}; };
} }