public final class I2CDeviceConfig extends Object implements DeviceConfig, DeviceConfig.HardwareAddressing
I2CDeviceConfig
class encapsulates the hardware addressing information, and static
and dynamic configuration parameters of an I2C slave device.
Some hardware addressing, static or dynamic configuration parameters may be
set to UNASSIGNED
or null
(see
Unassigned, Default or Unused Parameter Values).
An instance of I2CDeviceConfig
can be passed to the
open(DeviceConfig, ...)
and
open(Class, DeviceConfig, ...)
methods of the DeviceManager
to open the designated I2C slave
device with the specified configuration. A InvalidDeviceConfigException
is thrown
when attempting to open a device with an invalid or unsupported configuration.
DeviceManager.open(DeviceConfig)
,
DeviceManager.open(DeviceConfig, int)
,
DeviceManager#open(Class, DeviceConfig)
,
DeviceManager#open(Class, DeviceConfig, int)
Modifier and Type | Class and Description |
---|---|
static class |
I2CDeviceConfig.Builder
The
Builder class allows for creating and initializing
I2CDeviceConfig objects. |
DeviceConfig.HardwareAddressing
Modifier and Type | Field and Description |
---|---|
static int |
ADDR_SIZE_10
10 bit slave address.
|
static int |
ADDR_SIZE_7
7 bit slave address.
|
DEFAULT, UNASSIGNED
Constructor and Description |
---|
I2CDeviceConfig(int controllerNumber,
int address,
int addressSize,
int clockFrequency)
Deprecated.
As of 1.1, use
I2CDeviceConfig.Builder instead. |
I2CDeviceConfig(String controllerName,
int address,
int addressSize,
int clockFrequency)
Deprecated.
As of 1.1, use
I2CDeviceConfig.Builder instead. |
Modifier and Type | Method and Description |
---|---|
int |
getAddress()
Gets the configured address of the I2C slave device.
|
int |
getAddressSize()
Gets the configured address size of the I2C slave device.
|
int |
getClockFrequency()
Gets the configured clock frequency (in Hz) supported by the I2C slave device.
|
String |
getControllerName()
Gets the configured controller name (such as its device file name on UNIX systems).
|
int |
getControllerNumber()
Gets the configured controller number (the controller number the I2C bus adapter the I2C slave device
is connected to).
|
int |
getInputBufferSize()
Gets the requested input buffer size.
|
int |
getOutputBufferSize()
Gets the requested or allocated output buffer size.
|
public static final int ADDR_SIZE_7
public static final int ADDR_SIZE_10
public I2CDeviceConfig(int controllerNumber, int address, int addressSize, int clockFrequency)
I2CDeviceConfig.Builder
instead.I2CDeviceConfig
with the specified hardware addressing information and
configuration parameters.
The controller name is set to null
.
The requested input and output buffer sizes are set to UNASSIGNED
.
controllerNumber
- the number of the bus the slave device is connected to (a positive or zero
integer) or UNASSIGNED
.address
- the address of the slave device on the bus (a positive or zero integer, strictly lesser than
2addressSize
).addressSize
- the address size: ADDR_SIZE_7
bits, ADDR_SIZE_10
bits.clockFrequency
- the clock frequency of the slave device in Hz (a positive integer) or
UNASSIGNED
.IllegalArgumentException
- if any of the following is true:
controllerNumber
is not in the defined range;address
is not in the defined range;addressSize
is not in the defined range;clockFrequency
is not in the defined range.public I2CDeviceConfig(String controllerName, int address, int addressSize, int clockFrequency)
I2CDeviceConfig.Builder
instead.I2CDeviceConfig
with the specified hardware addressing information and
configuration parameters.
The controller number is set to UNASSIGNED
.
The requested input and output buffer sizes are set to UNASSIGNED
.
controllerName
- the name of the bus the slave device is connected to (such as its device file name on UNIX systems).address
- the address of the slave device on the bus (a positive or zero integer, strictly lesser than
2addressSize
).addressSize
- the address size: ADDR_SIZE_7
bits, ADDR_SIZE_10
bits.clockFrequency
- the clock frequency of the slave device in Hz (a positive integer) or
UNASSIGNED
.IllegalArgumentException
- if any of the following is true:
address
is not in the defined range;addressSize
is not in the defined range;clockFrequency
is not in the defined range.NullPointerException
- if controllerName
is null
.public int getAddress()
public int getAddressSize()
ADDR_SIZE_7
bits, ADDR_SIZE_10
bits or
UNASSIGNED
.public int getControllerNumber()
getControllerNumber
in interface DeviceConfig.HardwareAddressing
UNASSIGNED
.public String getControllerName()
getControllerName
in interface DeviceConfig.HardwareAddressing
null
.public int getInputBufferSize()
UNASSIGNED
.public int getOutputBufferSize()
UNASSIGNED
.public int getClockFrequency()
UNASSIGNED
.