Rpi-hw  0.7.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions | Private Attributes | List of all members
rpihw::driver::spi Class Reference

Serial Peripheral Interface. More...

#include <spi.hpp>

Public Types

enum  Modes { MODE_0 = SPI_MODE_0, MODE_1 = SPI_MODE_1, MODE_2 = SPI_MODE_2, MODE_3 = SPI_MODE_3 }
 The SPI modes (see: https://www.kernel.org/doc/Documentation/spi/spi-summary). More...
 

Public Member Functions

 spi (const std::string &dev_path, Modes mode, uint8_t word_len, uint32_t speed)
 Constructor method. More...
 
virtual ~spi ()
 Destructor method.
 
void setMode (uint8_t mode)
 Sets the SPI mode. More...
 
uint8_t getMode () const
 Returns the SPI mode. More...
 
void setWordLen (uint8_t word_len)
 Sets the device word length. More...
 
uint8_t getWordLen () const
 Returns the device word length. More...
 
void setSpeed (uint32_t speed)
 Sets the device max speed. More...
 
uint32_t getSpeed () const
 Returns the device max speed. More...
 
void transfer (uint8_t *data, size_t size)
 Sends/receives a data buffer.
 

Private Attributes

std::string m_dev_path
 The device path.
 
uint8_t m_mode
 SPI mode.
 
uint8_t m_word_len
 Device word length.
 
uint32_t m_speed
 Device max speed (hz).
 
int m_dev_fd
 File descriptor of the device.
 

Detailed Description

Serial Peripheral Interface.

Definition at line 45 of file spi.hpp.

Member Enumeration Documentation

The SPI modes (see: https://www.kernel.org/doc/Documentation/spi/spi-summary).

Enumerator
MODE_0 

Sets CPOL=0, SPI_CPHA=0.

MODE_1 

Sets CPOL=0, SPI_CPHA=1.

MODE_2 

Sets CPOL=1, SPI_CPHA=0.

MODE_3 

Sets CPOL=1, SPI_CPHA=1.

Definition at line 50 of file spi.hpp.

Constructor & Destructor Documentation

rpihw::driver::spi::spi ( const std::string &  dev_path,
Modes  mode,
uint8_t  word_len,
uint32_t  speed 
)

Constructor method.

Parameters
[in]dev_pathThe device path.
[in]modeThe SPI mode.
[in]word_lenThe device word length.
[in]speedThe device max speed (hz).

Member Function Documentation

uint8_t rpihw::driver::spi::getMode ( ) const
inline

Returns the SPI mode.

Returns
The SPI mode.

Definition at line 30 of file spi-inl.hpp.

uint32_t rpihw::driver::spi::getSpeed ( ) const
inline

Returns the device max speed.

Returns
The new device speed.

Definition at line 44 of file spi-inl.hpp.

uint8_t rpihw::driver::spi::getWordLen ( ) const
inline

Returns the device word length.

Returns
The bits per word.

Definition at line 37 of file spi-inl.hpp.

void rpihw::driver::spi::setMode ( uint8_t  mode)

Sets the SPI mode.

Parameters
[in]modeThe new SPI mode.
void rpihw::driver::spi::setSpeed ( uint32_t  speed)

Sets the device max speed.

Parameters
[in]speedThe new device speed.
void rpihw::driver::spi::setWordLen ( uint8_t  word_len)

Sets the device word length.

Parameters
[in]word_lenThe bits per word.

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