Class that controls I2C devices. More...
#include <I2CController.hpp>
Public Member Functions | |
I2CController (const char *i2c_device, int address) | |
Construct a new I2CController object. | |
~I2CController () override | |
Destroy the I2CController object. | |
void | writeRegister (uint8_t reg, uint16_t value) override |
Write a 16-bit value to a register. | |
uint16_t | readRegister (uint8_t reg) override |
Read a 16-bit value from a register. | |
![]() | |
virtual | ~II2CController ()=default |
Private Attributes | |
int | i2c_fd_ |
int | i2c_addr_ |
Class that controls I2C devices.
Definition at line 26 of file I2CController.hpp.
I2CController::I2CController | ( | const char * | i2c_device, |
int | address ) |
Construct a new I2CController object.
i2c_device | The I2C device to use for communication. |
address | The I2C address of the device. |
std::runtime_error | if the I2C device cannot be opened or the address cannot be set. |
This constructor initializes the I2CController object with the specified I2C device and address.
Definition at line 36 of file I2CController.cpp.
|
override |
Destroy the I2CController object.
This destructor closes the I2C device.
Definition at line 54 of file I2CController.cpp.
|
overridevirtual |
Read a 16-bit value from a register.
reg | The register address to read from. |
This function reads a 16-bit value from a register on the I2C device.
Implements II2CController.
Definition at line 81 of file I2CController.cpp.
|
overridevirtual |
Write a 16-bit value to a register.
reg | The register address to write to. |
value | The value to write. |
This function writes a 16-bit value to a register on the I2C device.
Implements II2CController.
Definition at line 66 of file I2CController.cpp.
|
private |
Definition at line 30 of file I2CController.hpp.
|
private |
Definition at line 29 of file I2CController.hpp.