Hotwheels-Cluster 1.2
Creation of Cluster APP for SEA:ME project.
 
Loading...
Searching...
No Matches
I2CController Class Reference

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.
 
- Public Member Functions inherited from II2CController
virtual ~II2CController ()=default
 

Private Attributes

int i2c_fd_
 
int i2c_addr_
 

Detailed Description

Class that controls I2C devices.

Definition at line 26 of file I2CController.hpp.

Constructor & Destructor Documentation

◆ I2CController()

I2CController::I2CController ( const char * i2c_device,
int address )

Construct a new I2CController object.

Parameters
i2c_deviceThe I2C device to use for communication.
addressThe I2C address of the device.
Exceptions
std::runtime_errorif 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.

◆ ~I2CController()

I2CController::~I2CController ( )
override

Destroy the I2CController object.

This destructor closes the I2C device.

Definition at line 54 of file I2CController.cpp.

Member Function Documentation

◆ readRegister()

uint16_t I2CController::readRegister ( uint8_t reg)
overridevirtual

Read a 16-bit value from a register.

Parameters
regThe register address to read from.
Returns
uint16_t The value read from the register.

This function reads a 16-bit value from a register on the I2C device.

Implements II2CController.

Definition at line 81 of file I2CController.cpp.

◆ writeRegister()

void I2CController::writeRegister ( uint8_t reg,
uint16_t value )
overridevirtual

Write a 16-bit value to a register.

Parameters
regThe register address to write to.
valueThe 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.

Field Documentation

◆ i2c_addr_

int I2CController::i2c_addr_
private

Definition at line 30 of file I2CController.hpp.

◆ i2c_fd_

int I2CController::i2c_fd_
private

Definition at line 29 of file I2CController.hpp.


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