I2C Class Reference

#include <I2C.h>

Inheritance diagram for I2C:

Inheritance graph
[legend]
Collaboration diagram for I2C:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~I2C (void)
void Write (unsigned char registerAddress, unsigned char data)
void Read (unsigned char registerAddress, unsigned char count, unsigned char *data)
void Broadcast (unsigned char registerAddress, unsigned char data)
bool VerifySensor (unsigned char registerAddress, unsigned char count, const unsigned char *expected)


Detailed Description

I2C bus interface class.

This class is intended to be used by sensor (and other I2C device) drivers. It probably should not be used directly.

It is constructed by calling DigitalModule::GetI2C() on a DigitalModule object.


Constructor & Destructor Documentation

I2C::~I2C ( void   ) 

Destructor.


Member Function Documentation

void I2C::Write ( unsigned char  registerAddress,
unsigned char  data 
)

Execute a write transaction with the device.

Write a byte to a register on a device and wait until the transaction is complete.

Parameters:
registerAddress The address of the register on the device to be written.
data The byte to write to the register on the device.

void I2C::Read ( unsigned char  registerAddress,
unsigned char  count,
unsigned char *  buffer 
)

Execute a read transaction with the device.

Read 1, 2, 3, or 4 bytes from a device. Most I2C devices will auto-increment the register pointer internally allowing you to read up to 4 consecutive registers on a device in a single transaction.

Parameters:
registerAddress The register to read first in the transaction.
count The number of bytes to read in the transaction.
buffer A pointer to the array of bytes to store the data read from the device.

void I2C::Broadcast ( unsigned char  registerAddress,
unsigned char  data 
)

Send a broadcast write to all devices on the I2C bus.

This is not currently implemented!

Parameters:
registerAddress The register to write on all devices on the bus.
data The value to write to the devices.

bool I2C::VerifySensor ( unsigned char  registerAddress,
unsigned char  count,
const unsigned char *  expected 
)

Verify that a device's registers contain expected values.

Most devices will have a set of registers that contain a known value that can be used to identify them. This allows an I2C device driver to easily verify that the device contains the expected value.

Precondition:
The device must support and be configured to use register auto-increment.
Parameters:
registerAddress The base register to start reading from the device.
count The size of the field to be verified.
expected A buffer containing the values expected from the device.


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

Generated on Thu Oct 2 14:01:27 2008 for WPI Robotics Library by  doxygen 1.5.5