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

Inter Integrated Circuit. More...

#include <i2c.hpp>

Public Member Functions

 i2c (const std::string &dev_path, uint8_t addr)
 Constructor method. More...
 
virtual ~i2c ()
 Destructor method.
 
void write (uint8_t *data, uint8_t size)
 Writes data on the device. More...
 
void read (uint8_t *data, uint8_t size)
 Reads data from the device. More...
 
void writeReg8 (uint8_t reg, uint8_t data)
 Writes a byte data to a register on the device. More...
 
uint8_t readReg8 (uint8_t reg)
 Reads a byte from a register on the device. More...
 
void writeReg16 (uint8_t reg, uint16_t data)
 Writes a word data to a register on the device. More...
 
uint16_t readReg16 (uint8_t reg)
 Reads a word from a register on the device. More...
 

Private Attributes

std::string m_dev_path
 The device path.
 
uint32_t m_addr
 The I2C slave address.
 
int m_dev_fd
 File descriptor of the device.
 
uint8_t m_buffer [3]
 Data buffer used for I2C transmission.
 

Detailed Description

Inter Integrated Circuit.

Definition at line 46 of file i2c.hpp.

Constructor & Destructor Documentation

rpihw::driver::i2c::i2c ( const std::string &  dev_path,
uint8_t  addr 
)

Constructor method.

Parameters
[in]dev_pathThe device path.
[in]addrThe I2C slave address.

Member Function Documentation

void rpihw::driver::i2c::read ( uint8_t *  data,
uint8_t  size 
)

Reads data from the device.

Parameters
[in]dataThe buffer to store the data.
[in]sizeSize of the data to read.
uint16_t rpihw::driver::i2c::readReg16 ( uint8_t  reg)

Reads a word from a register on the device.

Parameters
[in]regThe device register.
Returns
The data read from the register.
uint8_t rpihw::driver::i2c::readReg8 ( uint8_t  reg)

Reads a byte from a register on the device.

Parameters
[in]regThe device register.
Returns
The data read from the register.
void rpihw::driver::i2c::write ( uint8_t *  data,
uint8_t  size 
)

Writes data on the device.

Parameters
[in]dataThe data to write on the device.
[in]sizeSize of the data to write.
void rpihw::driver::i2c::writeReg16 ( uint8_t  reg,
uint16_t  data 
)

Writes a word data to a register on the device.

Parameters
[in]regThe device register.
[in]dataThe data to write to the register.
void rpihw::driver::i2c::writeReg8 ( uint8_t  reg,
uint8_t  data 
)

Writes a byte data to a register on the device.

Parameters
[in]regThe device register.
[in]dataThe data to write to the register.

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