|
Exploring BeagleBone
V1.0
|
Generic I2C Device class that can be used to connect to any type of I2C device and read or write to its registers. More...
#include <I2CDevice.h>


Public Member Functions | |
| I2CDevice (unsigned int bus, unsigned int device) | |
| virtual int | open () |
| virtual int | write (unsigned char value) |
| virtual unsigned char | readRegister (unsigned int registerAddress) |
| virtual unsigned char * | readRegisters (unsigned int number, unsigned int fromAddress=0) |
| virtual int | writeRegister (unsigned int registerAddress, unsigned char value) |
| virtual void | debugDumpRegisters (unsigned int number=0xff) |
| virtual void | close () |
| virtual | ~I2CDevice () |
Public Member Functions inherited from exploringBB::BusDevice | |
| BusDevice (unsigned int bus, unsigned int device) | |
| virtual | ~BusDevice () |
Additional Inherited Members | |
Protected Attributes inherited from exploringBB::BusDevice | |
| unsigned int | bus |
| unsigned int | device |
| int | file |
Generic I2C Device class that can be used to connect to any type of I2C device and read or write to its registers.
| exploringBB::I2CDevice::I2CDevice | ( | unsigned int | bus, |
| unsigned int | device | ||
| ) |
Constructor for the I2CDevice class. It requires the bus number and device number. The constructor opens a file handle to the I2C device, which is destroyed when the destructor is called
| bus | The bus number. Usually 0 or 1 on the BBB |
| device | The device ID on the bus. |
|
virtual |
Closes the file on destruction, provided that it has not already been closed.
|
virtual |
|
virtual |
Method to dump the registers to the standard output. It inserts a return character after every 16 values and displays the results in hexadecimal to give a standard output using the HEX() macro that is defined at the top of this file. The standard output will stay in hexadecimal format, hence the call on the last like.
| number | the total number of registers to dump, defaults to 0xff |
Implements exploringBB::BusDevice.
|
virtual |
Open a connection to an I2C device
Implements exploringBB::BusDevice.
|
virtual |
Read a single register value from the address on the device.
| registerAddress | the address to read from |
Implements exploringBB::BusDevice.
|
virtual |
Method to read a number of registers from a single device. This is much more efficient than reading the registers individually. The from address is the starting address to read from, which defaults to 0x00.
| number | the number of registers to read from the device |
| fromAddress | the starting address to read from |
Implements exploringBB::BusDevice.
|
virtual |
Write a single value to the I2C device. Used to set up the device to read from a particular address.
| value | the value to write to the device |
Implements exploringBB::BusDevice.
|
virtual |
Write a single byte value to a single register.
| registerAddress | The register address |
| value | The value to be written to the register |
Implements exploringBB::BusDevice.
1.8.8