public final class SPIDeviceConfig extends java.lang.Object implements DeviceConfig<SPIDevice>, DeviceConfig.HardwareAddressing
SPIDeviceConfig
class encapsulates the hardware addressing information, and static and dynamic
configuration parameters of an SPI slave device.
Some hardware addressing parameter, and static and dynamic configuration parameters may be set to DeviceConfig.DEFAULT
.
Whether such default settings are supported is platform- as well as device driver-dependent.
Mode | CPOL | CPHA |
---|---|---|
0 | 0 = Active-high clocks selected. | 0 = Sampling of data occurs at odd edges of the SCK clock |
1 | 0 = Active-high clocks selected. | 1 = Sampling of data occurs at even edges of the SCK clock |
2 | 1 = Active-low clocks selected. | 0 = Sampling of data occurs at odd edges of the SCK clock |
3 | 1 = Active-low clocks selected. | 1 = Sampling of data occurs at even edges of the SCK clock |
SPIDeviceConfig
can be passed to the DeviceManager.open(DeviceConfig)
or
DeviceManager.open(Class, DeviceConfig)
method to open the designated SPI slave device with the
specified configuration. A InvalidDeviceConfigException
is thrown when attempting to open a
device with an invalid or unsupported configuration.DeviceConfig.HardwareAddressing
Modifier and Type | Field and Description |
---|---|
static int |
CS_ACTIVE_HIGH
High Chip Select active level.
|
static int |
CS_ACTIVE_LOW
Low Chip Select active level.
|
static int |
CS_NOT_CONTROLLED
Chip Select not controlled by driver.
|
DEFAULT
Constructor and Description |
---|
SPIDeviceConfig(int controllerNumber,
int address,
int clockFrequency,
int clockMode,
int wordLength,
int bitOrdering)
Creates a new
SPIDeviceConfig with the specified hardware addressing information and configuration
parameters. |
SPIDeviceConfig(int controllerNumber,
int address,
int csActive,
int clockFrequency,
int clockMode,
int wordLength,
int bitOrdering)
Creates a new
SPIDeviceConfig with the specified hardware addressing information and configuration
parameters. |
SPIDeviceConfig(java.lang.String controllerName,
int address,
int clockFrequency,
int clockMode,
int wordLength,
int bitOrdering)
Creates a new
SPIDeviceConfig with the specified hardware addressing information and configuration
parameters. |
SPIDeviceConfig(java.lang.String controllerName,
int address,
int csActive,
int clockFrequency,
int clockMode,
int wordLength,
int bitOrdering)
Creates a new
SPIDeviceConfig with the specified hardware addressing information and configuration
parameters. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Checks two
SPIDeviceConfig objects for equality. |
int |
getAddress()
Gets the configured address of the SPI slave device.
|
int |
getBitOrdering()
Gets the configured bit (shifting) ordering of the SPI slave device.
|
int |
getClockFrequency()
Gets the clock frequency (in Hz) supported by the SPI slave device.
|
int |
getClockMode()
Gets the configured clock mode (combining clock polarity and phase) for communicating with the SPI slave device.
|
java.lang.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 of the SPI bus adapter the slave device is connected to).
|
int |
getCSActiveLevel()
Gets the configured Chip Select active level for selecting the SPI slave device.
|
int |
getWordLength()
Gets the configured word length for communicating with the SPI slave device.
|
int |
hashCode()
Returns the hash code value for this object.
|
public static final int CS_ACTIVE_HIGH
public static final int CS_ACTIVE_LOW
public static final int CS_NOT_CONTROLLED
GPIOPin
.public SPIDeviceConfig(int controllerNumber, int address, int clockFrequency, int clockMode, int wordLength, int bitOrdering)
SPIDeviceConfig
with the specified hardware addressing information and configuration
parameters. The Chip Select active level is platform and/or driver-dependent (i.e. DeviceConfig.DEFAULT
).controllerNumber
- the number of the bus the slave device is connected to (a positive or zero integer) or
DeviceConfig.DEFAULT
.address
- the Chip Select address of the slave device on the bus (a positive or zero integer).clockFrequency
- the clock frequency of the slave device in Hz (a positive integer) or DeviceConfig.DEFAULT
.clockMode
- the clock mode, one of: 0
, 1
, 2
or 4
(see SPI Clock
Modes).wordLength
- the word length of the slave device (a positive integer) or DeviceConfig.DEFAULT
.bitOrdering
- the bit (shifting) ordering of the slave device, one of: Device.BIG_ENDIAN
,
Device.LITTLE_ENDIAN
, Device.MIXED_ENDIAN
or DeviceConfig.DEFAULT
.java.lang.IllegalArgumentException
- if any of the following is true:
controllerNumber
is not in the defined range;address
is not in the defined range;clockFrequency
is not in the defined range;clockMode
is not one of the defined values;wordLength
is not in the defined range;bitOrdering
is not one of the defined values.public SPIDeviceConfig(int controllerNumber, int address, int csActive, int clockFrequency, int clockMode, int wordLength, int bitOrdering)
SPIDeviceConfig
with the specified hardware addressing information and configuration
parameters.controllerNumber
- the number of the bus the slave device is connected to (a positive or zero integer) or
DeviceConfig.DEFAULT
.address
- the Chip Select address of the slave device on the bus (a positive or zero integer).csActive
- the Chip Select active level, one of CS_ACTIVE_LOW
,
CS_ACTIVE_HIGH
, CS_NOT_CONTROLLED
or DeviceConfig.DEFAULT
.clockFrequency
- the clock frequency of the slave device in Hz (a positive integer) or DeviceConfig.DEFAULT
.clockMode
- the clock mode, one of: 0
, 1
, 2
or 4
(see SPI Clock
Modes).wordLength
- the word length of the slave device (a positive integer) or DeviceConfig.DEFAULT
.bitOrdering
- the bit (shifting) ordering of the slave device, one of: Device.BIG_ENDIAN
,
Device.LITTLE_ENDIAN
, Device.MIXED_ENDIAN
or DeviceConfig.DEFAULT
.java.lang.IllegalArgumentException
- if any of the following is true:
controllerNumber
is not in the defined range;address
is not in the defined range;clockFrequency
is not in the defined range;clockMode
is not one of the defined values;wordLength
is not in the defined range;bitOrdering
is not one of the defined values.public SPIDeviceConfig(java.lang.String controllerName, int address, int clockFrequency, int clockMode, int wordLength, int bitOrdering)
SPIDeviceConfig
with the specified hardware addressing information and configuration
parameters. The Chip Select active level is platform and/or driver-dependent (i.e. DeviceConfig.DEFAULT
).controllerName
- the controller name (such as its device file name on UNIX systems).address
- the Chip Select address of the slave device on the bus (a positive or zero integer).clockFrequency
- the clock frequency of the slave device in Hz (a positive integer) or DeviceConfig.DEFAULT
.clockMode
- the clock mode, one of: 0
, 1
, 2
or 4
(see SPI Clock
Modes).wordLength
- the word length of the slave device (a positive integer) or DeviceConfig.DEFAULT
.bitOrdering
- the bit (shifting) ordering of the slave device, one of: Device.BIG_ENDIAN
,
Device.LITTLE_ENDIAN
, Device.MIXED_ENDIAN
or DeviceConfig.DEFAULT
.java.lang.IllegalArgumentException
- if any of the following is true:
address
is not in the defined range;clockFrequency
is not in the defined range;clockMode
is not one of the defined values;wordLength
is not in the defined range;bitOrdering
is not one of the defined values.java.lang.NullPointerException
- if controllerName
is null
.public SPIDeviceConfig(java.lang.String controllerName, int address, int csActive, int clockFrequency, int clockMode, int wordLength, int bitOrdering)
SPIDeviceConfig
with the specified hardware addressing information and configuration
parameters.controllerName
- the controller name (such as its device file name on UNIX systems).address
- the Chip Select address of the slave device on the bus (a positive or zero integer).csActive
- the Chip Select active level, one of CS_ACTIVE_LOW
,
CS_ACTIVE_HIGH
, CS_NOT_CONTROLLED
or DeviceConfig.DEFAULT
.clockFrequency
- the clock frequency of the slave device in Hz (a positive integer) or DeviceConfig.DEFAULT
.clockMode
- the clock mode, one of: 0
, 1
, 2
or 4
(see SPI Clock
Modes).wordLength
- the word length of the slave device (a positive integer) or DeviceConfig.DEFAULT
.bitOrdering
- the bit (shifting) ordering of the slave device, one of: Device.BIG_ENDIAN
,
Device.LITTLE_ENDIAN
, Device.MIXED_ENDIAN
or DeviceConfig.DEFAULT
.java.lang.IllegalArgumentException
- if any of the following is true:
address
is not in the defined range;clockFrequency
is not in the defined range;clockMode
is not one of the defined values;wordLength
is not in the defined range;bitOrdering
is not one of the defined values.java.lang.NullPointerException
- if controllerName
is null
.public int getAddress()
public int getControllerNumber()
getControllerNumber
in interface DeviceConfig.HardwareAddressing
DeviceConfig.DEFAULT
.public java.lang.String getControllerName()
getControllerName
in interface DeviceConfig.HardwareAddressing
null
.public int getBitOrdering()
Device.BIG_ENDIAN
,
Device.LITTLE_ENDIAN
, Device.MIXED_ENDIAN
or DeviceConfig.DEFAULT
.public int getClockFrequency()
DeviceConfig.DEFAULT
.public int getClockMode()
0
, 1
, 2
or 4
(see SPI Clock
Modes).public int getCSActiveLevel()
CS_ACTIVE_LOW
,
CS_ACTIVE_HIGH
, CS_NOT_CONTROLLED
or DeviceConfig.DEFAULT
.public int getWordLength()
DeviceConfig.DEFAULT
.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
SPIDeviceConfig
objects for equality.equals
in class java.lang.Object
obj
- the object to test for equality with this object.true
if obj
is a SPIDeviceConfig
and has
the same hardware addressing information and configuration parameter values
as this SPIDeviceConfig
object.Copyright © 2012, 2014, Oracle and/or its affiliates. All rights reserved.
Legal Notices