public class I2C extends SensorBase
Modifier and Type | Class and Description |
---|---|
static class |
I2C.Port |
kAnalogInputChannels, kAnalogOutputChannels, kDigitalChannels, kPDPChannels, kPwmChannels, kRelayChannels, kSolenoidChannels, kSolenoidModules, kSystemClockTicksPerMicrosecond
Constructor and Description |
---|
I2C(I2C.Port port,
int deviceAddress)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addressOnly()
Attempt to address a device on the I2C bus.
|
void |
broadcast(int registerAddress,
int data)
Send a broadcast write to all devices on the I2C bus.
|
void |
free()
Destructor.
|
boolean |
read(int registerAddress,
int count,
byte[] buffer)
Execute a read transaction with the device.
|
boolean |
readOnly(byte[] buffer,
int count)
Execute a read only transaction with the device.
|
boolean |
transaction(byte[] dataToSend,
int sendSize,
byte[] dataReceived,
int receiveSize)
Generic transaction.
|
boolean |
verifySensor(int registerAddress,
int count,
byte[] expected)
Verify that a device's registers contain expected values.
|
boolean |
write(int registerAddress,
int data)
Execute a write transaction with the device.
|
boolean |
writeBulk(byte[] data)
Execute a write transaction with the device.
|
checkAnalogInputChannel, checkAnalogOutputChannel, checkDigitalChannel, checkPDPChannel, checkPWMChannel, checkRelayChannel, checkSolenoidChannel, checkSolenoidModule, getDefaultSolenoidModule, setDefaultSolenoidModule
public I2C(I2C.Port port, int deviceAddress)
port
- The I2C port the device is connected to.deviceAddress
- The address of the device on the I2C bus.public void free()
free
in class SensorBase
public boolean transaction(byte[] dataToSend, int sendSize, byte[] dataReceived, int receiveSize)
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 bytes to read from the device. [0..7]public boolean addressOnly()
public boolean write(int registerAddress, int data)
registerAddress
- The address of the register on the device to be written.data
- The byte to write to the register on the device.public boolean writeBulk(byte[] data)
data
- The data to write to the device.public boolean read(int registerAddress, int count, byte[] buffer)
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.public boolean readOnly(byte[] buffer, int count)
buffer
- A pointer to the array of bytes to store the data read from
the device.count
- The number of bytes to read in the transaction. [1..7]public void broadcast(int registerAddress, int data)
registerAddress
- The register to write on all devices on the bus.data
- The value to write to the devices.public boolean verifySensor(int registerAddress, int count, byte[] expected)
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.Copyright © 2015. All rights reserved.