public final class SPIDeviceConfig extends java.lang.Object implements PeripheralConfig<SPIDevice>, PeripheralConfig.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 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.PeripheralConfig.HardwareAddressingDEFAULT| Constructor and Description |
|---|
SPIDeviceConfig(int deviceNumber,
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 deviceName,
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 |
|---|---|
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 |
getDeviceName()
Gets the configured device name (such as to its device file name on UNIX systems).
|
int |
getDeviceNumber()
Gets the configured device number (the device number of the SPI bus adapter the slave device is connected to).
|
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 SPIDeviceConfig(int deviceNumber,
int address,
int clockFrequency,
int clockMode,
int wordLength,
int bitOrdering)
SPIDeviceConfig with the specified hardware addressing information and configuration
parameters.deviceNumber - the number of the bus the slave device is connected to (a positive or zero integer) or
PeripheralConfig.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 PeripheralConfig.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 PeripheralConfig.DEFAULT.bitOrdering - the bit (shifting) ordering of the slave device, one of: Peripheral.BIG_ENDIAN,
Peripheral.LITTLE_ENDIAN, Peripheral.MIXED_ENDIAN or PeripheralConfig.DEFAULT.java.lang.IllegalArgumentException - if any of the following is true:
deviceNumber 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 deviceName,
int address,
int clockFrequency,
int clockMode,
int wordLength,
int bitOrdering)
SPIDeviceConfig with the specified hardware addressing information and configuration
parameters.deviceName - the device name (such as to 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 PeripheralConfig.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 PeripheralConfig.DEFAULT.bitOrdering - the bit (shifting) ordering of the slave device, one of: Peripheral.BIG_ENDIAN,
Peripheral.LITTLE_ENDIAN, Peripheral.MIXED_ENDIAN or PeripheralConfig.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 deviceName is null.public int getAddress()
public int getDeviceNumber()
getDeviceNumber in interface PeripheralConfig.HardwareAddressingPeripheralConfig.DEFAULT.public java.lang.String getDeviceName()
getDeviceName in interface PeripheralConfig.HardwareAddressingnull.public int getBitOrdering()
Peripheral.BIG_ENDIAN,
Peripheral.LITTLE_ENDIAN, Peripheral.MIXED_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.public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
SPIDeviceConfig objects for equality.equals in class java.lang.Objectobj - 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, 2013, Oracle and/or its affiliates. All rights reserved.
Legal Notices