public final class SPIDeviceConfig extends Object implements DeviceConfig, DeviceConfig.HardwareAddressing
SPIDeviceConfig
class encapsulates the hardware addressing information, and static and dynamic
configuration parameters of an SPI slave device.
Some hardware addressing, static or dynamic configuration parameters may be
set to UNASSIGNED
or null
(see
Unassigned, Default or Unused Parameter Values).
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
An instance of SPIDeviceConfig
can be passed to the open(DeviceConfig, ...)
methods of the DeviceManager
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.
DeviceManager.open(DeviceConfig)
,
DeviceManager.open(DeviceConfig, int)
Modifier and Type | Class and Description |
---|---|
static class |
SPIDeviceConfig.Builder
The
Builder class allows for creating and initializing
SPIDeviceConfig objects. |
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, UNASSIGNED
Constructor and Description |
---|
SPIDeviceConfig(int controllerNumber,
int address,
int clockFrequency,
int clockMode,
int wordLength,
int bitOrdering)
Deprecated.
As of 1.1, use
SPIDeviceConfig.Builder instead. |
SPIDeviceConfig(int controllerNumber,
int address,
int csActive,
int clockFrequency,
int clockMode,
int wordLength,
int bitOrdering)
Deprecated.
As of 1.1, use
SPIDeviceConfig.Builder instead. |
SPIDeviceConfig(String controllerName,
int address,
int clockFrequency,
int clockMode,
int wordLength,
int bitOrdering)
Deprecated.
As of 1.1, use
SPIDeviceConfig.Builder instead. |
SPIDeviceConfig(String controllerName,
int address,
int csActive,
int clockFrequency,
int clockMode,
int wordLength,
int bitOrdering)
Deprecated.
As of 1.1, use
SPIDeviceConfig.Builder instead. |
Modifier and Type | Method and Description |
---|---|
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.
|
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 |
getInputBufferSize()
Gets the requested or allocated input buffer size.
|
int |
getOutputBufferSize()
Gets the requested or allocated output buffer size.
|
int |
getWordLength()
Gets the configured word length for communicating with the SPI slave device.
|
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.Builder
instead.SPIDeviceConfig
with the specified hardware addressing information and configuration
parameters. The Chip Select active level is platform and/or driver-dependent (i.e. UNASSIGNED
).
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 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 UNASSIGNED
.clockMode
- the clock mode, one of: 0
, 1
, 2
or 3
(see SPI Clock
Modes).wordLength
- the word length of the slave device (a positive integer) or UNASSIGNED
.bitOrdering
- the bit (shifting) ordering of the slave device, one of: Device.BIG_ENDIAN
,
Device.LITTLE_ENDIAN
, Device.MIXED_ENDIAN
or UNASSIGNED
.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.Builder
instead.SPIDeviceConfig
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 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 UNASSIGNED
.clockFrequency
- the clock frequency of the slave device in Hz (a positive integer) or UNASSIGNED
.clockMode
- the clock mode, one of: 0
, 1
, 2
or 3
(see SPI Clock
Modes).wordLength
- the word length of the slave device (a positive integer) or UNASSIGNED
.bitOrdering
- the bit (shifting) ordering of the slave device, one of: Device.BIG_ENDIAN
,
Device.LITTLE_ENDIAN
, Device.MIXED_ENDIAN
or UNASSIGNED
.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(String controllerName, int address, int clockFrequency, int clockMode, int wordLength, int bitOrdering)
SPIDeviceConfig.Builder
instead.SPIDeviceConfig
with the specified hardware addressing information and configuration
parameters. The Chip Select active level is platform and/or driver-dependent (i.e. UNASSIGNED
).
The controller number is set to UNASSIGNED
.
The requested input and output buffer sizes are set to UNASSIGNED
.
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 UNASSIGNED
.clockMode
- the clock mode, one of: 0
, 1
, 2
or 3
(see SPI Clock
Modes).wordLength
- the word length of the slave device (a positive integer) or UNASSIGNED
.bitOrdering
- the bit (shifting) ordering of the slave device, one of: Device.BIG_ENDIAN
,
Device.LITTLE_ENDIAN
, Device.MIXED_ENDIAN
or UNASSIGNED
.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.NullPointerException
- if controllerName
is null
.public SPIDeviceConfig(String controllerName, int address, int csActive, int clockFrequency, int clockMode, int wordLength, int bitOrdering)
SPIDeviceConfig.Builder
instead.SPIDeviceConfig
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 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 UNASSIGNED
.clockFrequency
- the clock frequency of the slave device in Hz (a positive integer) or UNASSIGNED
.clockMode
- the clock mode, one of: 0
, 1
, 2
or 3
(see SPI Clock
Modes).wordLength
- the word length of the slave device (a positive integer) or UNASSIGNED
.bitOrdering
- the bit (shifting) ordering of the slave device, one of: Device.BIG_ENDIAN
,
Device.LITTLE_ENDIAN
, Device.MIXED_ENDIAN
or UNASSIGNED
.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.NullPointerException
- if controllerName
is null
.public int getAddress()
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 getBitOrdering()
Device.BIG_ENDIAN
,
Device.LITTLE_ENDIAN
, Device.MIXED_ENDIAN
or UNASSIGNED
.public int getClockFrequency()
UNASSIGNED
.public int getClockMode()
0
, 1
, 2
or 3
(see SPI Clock
Modes).public int getCSActiveLevel()
CS_ACTIVE_LOW
,
CS_ACTIVE_HIGH
, CS_NOT_CONTROLLED
or UNASSIGNED
.public int getWordLength()
UNASSIGNED
.