public final class SPIDeviceConfig extends java.lang.Object implements PeripheralConfig
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 PeripheralConfig.DEFAULT
.
Whether such default settings are supported is platform- as well as peripheral 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 PeripheralManager.open(PeripheralConfig)
or
PeripheralManager.open(Class, PeripheralConfig)
method to open the designated SPI slave device with the
specified configuration. A PeripheralConfigInvalidException
is thrown when attempting to open a peripheral
device with an invalid or unsupported configuration.DEFAULT
Constructor and Description |
---|
SPIDeviceConfig(int busNumber,
int address,
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 |
---|---|
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 |
getBusNumber()
Gets the configured SPI bus number the SPI slave device is connected to.
|
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.
|
int |
getWordLength()
Gets the configured word length for communicating with the SPI slave device.
|
public SPIDeviceConfig(int busNumber, int address, int clockFrequency, int clockMode, int wordLength, int bitOrdering) throws java.lang.IllegalArgumentException
SPIDeviceConfig
with the specified hardware addressing information and configuration
parameters.busNumber
- the number of the bus the slave device is connected to (a positive or null integer) or
PeripheralConfig.DEFAULT
.address
- the Chip Select address of the slave device on the bus (a positive or null integer).clockFrequency
- the clock frequency of the slave device in Hz (a positive integer) or PeripheralConfig.DEFAULT
.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 PeripheralConfig.DEFAULT
.bitOrdering
- the bit (shifting) ordering of the slave device, one of: Peripheral.BIG_ENDIAN
,
Peripheral.LITTLE_ENDIAN
or PeripheralConfig.DEFAULT
.java.lang.IllegalArgumentException
- if any of the following is true:
busNumber
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 int getAddress()
public int getBusNumber()
PeripheralConfig.DEFAULT
.public int getBitOrdering()
Peripheral.BIG_ENDIAN
,
Peripheral.LITTLE_ENDIAN
or PeripheralConfig.DEFAULT
.public int getClockFrequency()
PeripheralConfig.DEFAULT
.public int getClockMode()
0
, 1
, 2
or 4
(see SPI Clock
Modes).public int getWordLength()
PeripheralConfig.DEFAULT
.Copyright (c) 1990, 2013, Oracle and/or its affiliates. All rights reserved.