public static final class SPIDeviceConfig.Builder extends Object
Builder
class allows for creating and initializing
SPIDeviceConfig
objects. Calls can be chained in the following
manner:
SPIDeviceConfig config = new SPIDeviceConfig.Builder() .setControllerNumber(1) .setAddress(0x8) .setClockFrequency(8000000) .setClockMode(2) .setWordLength(10) .setBitOrdering(LITTLE_ENDIAN) .build();
Constructor and Description |
---|
SPIDeviceConfig.Builder()
Creates a new
Builder instance. |
Modifier and Type | Method and Description |
---|---|
SPIDeviceConfig |
build()
Creates a new
SPIDeviceConfig instance initialized with the
values set for each configuration parameters. |
SPIDeviceConfig.Builder |
setAddress(int address)
Sets the Chip Select address of the slave device on the bus.
|
SPIDeviceConfig.Builder |
setBitOrdering(int bitOrdering)
Sets the bit (shifting) ordering of the slave device (default value
is
UNASSIGNED if not set). |
SPIDeviceConfig.Builder |
setClockFrequency(int clockFrequency)
Sets the clock frequency of the slave device in Hz (default value is
UNASSIGNED if not set). |
SPIDeviceConfig.Builder |
setClockMode(int clockMode)
Sets the clock mode (default value is
0 if not set). |
SPIDeviceConfig.Builder |
setControllerName(String controllerName)
Sets the name of the bus the slave device is connected to (default
value is
null if not set). |
SPIDeviceConfig.Builder |
setControllerNumber(int controllerNumber)
Sets the number of the bus the slave device is connected to (default
value is
UNASSIGNED if not set). |
SPIDeviceConfig.Builder |
setCSActiveLevel(int csActive)
Sets the Chip Select active level (default value is
UNASSIGNED if not set). |
SPIDeviceConfig.Builder |
setInputBufferSize(int inputBufferSize)
Sets the requested input buffer size (default value is
UNASSIGNED if not set). |
SPIDeviceConfig.Builder |
setOutputBufferSize(int outputBufferSize)
Sets the requested output buffer size (default value is
UNASSIGNED if not set). |
SPIDeviceConfig.Builder |
setWordLength(int wordLength)
Sets the word length of the slave device (default value is
UNASSIGNED if not set). |
public SPIDeviceConfig.Builder()
Builder
instance.public SPIDeviceConfig build()
SPIDeviceConfig
instance initialized with the
values set for each configuration parameters. If a configuration
parameter was not explictly set its default value will be used.SPIDeviceConfig
instance.IllegalStateException
- if any of the following is true:
public SPIDeviceConfig.Builder setControllerName(String controllerName)
null
if not set).controllerName
- the name of the bus the slave device is
connected to (such as its device file name on UNIX systems) or null
.Builder
instance.public SPIDeviceConfig.Builder setAddress(int address)
address
- the Chip Select address of the slave device on the bus
(a positive or zero integer).Builder
instance.IllegalArgumentException
- if any of the following is true:
address
is not in the defined range;public SPIDeviceConfig.Builder setControllerNumber(int controllerNumber)
UNASSIGNED
if not set).controllerNumber
- the number of the bus the slave device is
connected to (a positive or zero integer) or UNASSIGNED
.Builder
instance.IllegalArgumentException
- if controllerNumber
is not
in the defined range.public SPIDeviceConfig.Builder setInputBufferSize(int inputBufferSize)
UNASSIGNED
if not set).inputBufferSize
- the requested input buffer size in number of
samples (a positive or zero integer) or
UNASSIGNED
.Builder
instance.IllegalArgumentException
- if inputBufferSize
is not in
the defined range.public SPIDeviceConfig.Builder setOutputBufferSize(int outputBufferSize)
UNASSIGNED
if not set).outputBufferSize
- the requested output buffer size in number of
samples (a positive or zero integer) or
UNASSIGNED
.Builder
instance.IllegalArgumentException
- if outputBufferSize
is not
in the defined range.public SPIDeviceConfig.Builder setCSActiveLevel(int csActive)
UNASSIGNED
if not set).csActive
- the Chip Select active level, one of SPIDeviceConfig.CS_ACTIVE_LOW
,
SPIDeviceConfig.CS_ACTIVE_HIGH
, SPIDeviceConfig.CS_NOT_CONTROLLED
or
UNASSIGNED
.Builder
instance.IllegalArgumentException
- if csActive
is not in the
defined range.public SPIDeviceConfig.Builder setBitOrdering(int bitOrdering)
UNASSIGNED
if not set).bitOrdering
- the bit (shifting) ordering of the slave device,
one of: Device.BIG_ENDIAN
,
Device.LITTLE_ENDIAN
, Device.MIXED_ENDIAN
or
UNASSIGNED
.Builder
instance.IllegalArgumentException
- if bitOrdering
is not in the
defined range.public SPIDeviceConfig.Builder setClockMode(int clockMode)
0
if not set).clockMode
- the clock mode, one of:
0
, 1
, 2
or 3
(see SPI
Clock Modes).Builder
instance.IllegalArgumentException
- if clockMode
is not in the
defined range.public SPIDeviceConfig.Builder setWordLength(int wordLength)
UNASSIGNED
if not set).wordLength
- the word length of the slave device (a positive
integer) or UNASSIGNED
.Builder
instance.IllegalArgumentException
- if wordLength
is not in the
defined range.public SPIDeviceConfig.Builder setClockFrequency(int clockFrequency)
UNASSIGNED
if not set).clockFrequency
- the clock frequency of the slave device in Hz
(a positive integer) or UNASSIGNED
.Builder
instance.IllegalArgumentException
- if clockFrequency
is not in
the defined range.