Now you can download a copy of these docs so you can use them offline! Download now

I2C Class Reference

#include <I2C.h>

Inheritance diagram for I2C:
Collaboration diagram for I2C:

List of all members.

Public Member Functions

virtual ~I2C ()
bool Transaction (UINT8 *dataToSend, UINT8 sendSize, UINT8 *dataReceived, UINT8 receiveSize)
bool AddressOnly ()
bool Write (UINT8 registerAddress, UINT8 data)
bool Read (UINT8 registerAddress, UINT8 count, UINT8 *data)
void Broadcast (UINT8 registerAddress, UINT8 data)
void SetCompatibilityMode (bool enable)
bool VerifySensor (UINT8 registerAddress, UINT8 count, const UINT8 *expected)

Friends

class DigitalModule

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.

Definition at line 22 of file I2C.h.


Constructor & Destructor Documentation

I2C::~I2C (  )  [virtual]

Destructor.

Definition at line 37 of file I2C.cpp.


Member Function Documentation

bool I2C::AddressOnly (  ) 

Attempt to address a device on the I2C bus.

This allows you to figure out if there is a device on the I2C bus that responds to the address specified in the constructor.

Returns:
Transfer Aborted... false for success, true for aborted.

Definition at line 122 of file I2C.cpp.

void I2C::Broadcast ( UINT8  registerAddress,
UINT8  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.

Definition at line 182 of file I2C.cpp.

bool I2C::Read ( UINT8  registerAddress,
UINT8  count,
UINT8 *  buffer 
)

Execute a read transaction with the device.

Read 1 to 7 bytes from a device. Most I2C devices will auto-increment the register pointer internally allowing you to read up to 7 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. [1..7]
buffer A pointer to the array of bytes to store the data read from the device.
Returns:
Transfer Aborted... false for success, true for aborted.

Definition at line 158 of file I2C.cpp.

void I2C::SetCompatibilityMode ( bool  enable  ) 

SetCompatibilityMode

Enables bitwise clock skewing detection. This will reduce the I2C interface speed, but will allow you to communicate with devices that skew the clock at abnormal times.

Parameters:
enable Enable compatibility mode for this sensor or not.

Definition at line 194 of file I2C.cpp.

bool I2C::Transaction ( UINT8 *  dataToSend,
UINT8  sendSize,
UINT8 *  dataReceived,
UINT8  receiveSize 
)

Generic transaction.

This is a lower-level interface to the I2C hardware giving you more control over each transaction.

Parameters:
dataToSend Buffer of data to send as part of the transaction.
sendSize Number of bytes to send as part of the transaction. [0..6]
dataReceived Buffer to read data into.
receiveSize Number of byted to read from the device. [0..7]
Returns:
Transfer Aborted... false for success, true for aborted.

Definition at line 58 of file I2C.cpp.

bool I2C::VerifySensor ( UINT8  registerAddress,
UINT8  count,
const UINT8 *  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.

Definition at line 212 of file I2C.cpp.

bool I2C::Write ( UINT8  registerAddress,
UINT8  data 
)

Execute a write transaction with the device.

Write a single 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.
Returns:
Transfer Aborted... false for success, true for aborted.

Definition at line 137 of file I2C.cpp.


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

Generated on Thu Jan 12 2012 22:35:32 for WPILibC++ by doxygen 1.7.1