public final class GPIOPinConfig extends java.lang.Object implements PeripheralConfig<GPIOPin>, PeripheralConfig.HardwareAddressing
GPIOPinConfig class encapsulates the hardware addressing information, and static and dynamic
configuration parameters of a GPIO pin.
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.
An instance of GPIOPinConfig can be passed to the PeripheralManager.open(PeripheralConfig) or
PeripheralManager.open(Class, PeripheralConfig) method to open the designated GPIO pin with the specified
configuration. A PeripheralConfigInvalidException is thrown when attempting to open a peripheral device with
an invalid or unsupported configuration.PeripheralConfig.HardwareAddressing| Modifier and Type | Field and Description |
|---|---|
static int |
DIR_BOTH_INIT_INPUT
Bidirectional port direction with initial input direction.
|
static int |
DIR_BOTH_INIT_OUTPUT
Bidirectional port direction with initial output direction.
|
static int |
DIR_INPUT_ONLY
Input port direction.
|
static int |
DIR_OUTPUT_ONLY
Output port direction.
|
static int |
MODE_INPUT_PULL_DOWN
Input pull-down drive mode.
|
static int |
MODE_INPUT_PULL_UP
Input pull-up drive mode.
|
static int |
MODE_OUTPUT_OPEN_DRAIN
Output open-drain drive mode.
|
static int |
MODE_OUTPUT_PUSH_PULL
Output push-pull drive mode.
|
static int |
TRIGGER_BOTH_EDGES
Rising edge trigger.
|
static int |
TRIGGER_BOTH_LEVELS
Both levels trigger.
|
static int |
TRIGGER_FALLING_EDGE
Falling edge trigger.
|
static int |
TRIGGER_HIGH_LEVEL
High level trigger.
|
static int |
TRIGGER_LOW_LEVEL
Low level trigger.
|
static int |
TRIGGER_NONE
No interrupt trigger.
|
static int |
TRIGGER_RISING_EDGE
Rising edge trigger.
|
DEFAULT| Constructor and Description |
|---|
GPIOPinConfig(int deviceNumber,
int pinNumber,
int direction,
int mode,
int trigger,
boolean initValue)
Creates a new
GPIOPinConfig with the specified hardware addressing information and configuration
parameters. |
GPIOPinConfig(java.lang.String deviceName,
int pinNumber,
int direction,
int mode,
int trigger,
boolean initValue)
Creates a new
GPIOPinConfig with the specified hardware addressing information and configuration
parameters. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj)
Checks two
GPIOPinConfig objects for equality. |
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 for the pin.
|
int |
getDirection()
Gets the configured pin direction.
|
int |
getDriveMode()
Gets the configured pin drive mode.
|
boolean |
getInitValue()
Gets the configured initial value of the pin, if configured for output.
|
int |
getPinNumber()
Gets the configured pin number.
|
int |
getTrigger()
Gets the configured initial pin interrupt trigger.
|
int |
hashCode()
Returns the hash code value for this object.
|
public static final int DIR_BOTH_INIT_INPUT
public static final int DIR_BOTH_INIT_OUTPUT
public static final int DIR_INPUT_ONLY
public static final int DIR_OUTPUT_ONLY
public static final int MODE_INPUT_PULL_DOWN
public static final int MODE_INPUT_PULL_UP
public static final int MODE_OUTPUT_OPEN_DRAIN
public static final int MODE_OUTPUT_PUSH_PULL
public static final int TRIGGER_BOTH_EDGES
public static final int TRIGGER_BOTH_LEVELS
public static final int TRIGGER_FALLING_EDGE
public static final int TRIGGER_HIGH_LEVEL
public static final int TRIGGER_LOW_LEVEL
public static final int TRIGGER_NONE
public static final int TRIGGER_RISING_EDGE
public GPIOPinConfig(int deviceNumber,
int pinNumber,
int direction,
int mode,
int trigger,
boolean initValue)
GPIOPinConfig with the specified hardware addressing information and configuration
parameters.deviceNumber - the hardware port's number (a positive or zero integer) or PeripheralConfig.DEFAULT.pinNumber - the hardware pin's number (a positive or zero integer) or PeripheralConfig.DEFAULT.direction - the allowed and initial direction of the pin, one of: DIR_INPUT_ONLY,
DIR_OUTPUT_ONLY, DIR_BOTH_INIT_INPUT, DIR_BOTH_INIT_OUTPUT.mode - the drive mode of the pin: either PeripheralConfig.DEFAULT or a bitwise OR of at least one of:
MODE_INPUT_PULL_UP, MODE_INPUT_PULL_DOWN , MODE_OUTPUT_PUSH_PULL,
MODE_OUTPUT_OPEN_DRAIN; if the pin can be set in both input and output direction then the
mode must specify both an input drive mode and an output drive mode (bit mask).trigger - the initial interrupt trigger events, one of: TRIGGER_NONE, TRIGGER_FALLING_EDGE,
TRIGGER_RISING_EDGE, TRIGGER_BOTH_EDGES, TRIGGER_HIGH_LEVEL,
TRIGGER_LOW_LEVEL, TRIGGER_BOTH_LEVELS.initValue - the initial value of the pin when initially set for output; ignored otherwise.java.lang.IllegalArgumentException - if any of the following is true:
deviceNumber is not in the defined range;pinNumber is not in the defined range;direction is not one of the defined values;trigger is not one of the defined values;mode does not designate any mode (i.e. equals 0);mode designates more than one input or output drive mode;mode does not designates a drive mode for or designates a drive mode incompatible with
the direction(s) designated by direction.public GPIOPinConfig(java.lang.String deviceName,
int pinNumber,
int direction,
int mode,
int trigger,
boolean initValue)
GPIOPinConfig with the specified hardware addressing information and configuration
parameters.deviceName - the device name (such as to its device file name on UNIX systems).pinNumber - the hardware pin's number (a positive or zero integer) or PeripheralConfig.DEFAULT.direction - the allowed and initial direction of the pin, one of: DIR_INPUT_ONLY,
DIR_OUTPUT_ONLY, DIR_BOTH_INIT_INPUT, DIR_BOTH_INIT_OUTPUT.mode - the drive mode of the pin: either PeripheralConfig.DEFAULT or a bitwise OR of at least one of:
MODE_INPUT_PULL_UP, MODE_INPUT_PULL_DOWN , MODE_OUTPUT_PUSH_PULL,
MODE_OUTPUT_OPEN_DRAIN; if the pin can be set in both input and output direction then the
mode must specify both an input drive mode and an output drive mode (bit mask).trigger - the initial interrupt trigger events, one of: TRIGGER_NONE, TRIGGER_FALLING_EDGE,
TRIGGER_RISING_EDGE, TRIGGER_BOTH_EDGES, TRIGGER_HIGH_LEVEL,
TRIGGER_LOW_LEVEL, TRIGGER_BOTH_LEVELS.initValue - the initial value of the pin when initially set for output; ignored otherwise.java.lang.IllegalArgumentException - if any of the following is true:
pinNumber is not in the defined range;direction is not one of the defined values;trigger is not one of the defined values;mode does not designate any mode (i.e. equals 0);mode designates more than one input or output drive mode;mode does not designates a drive mode for or designates a drive mode incompatible with
the direction(s) designated by direction.java.lang.NullPointerException - if deviceName is null.public int getDirection()
DIR_INPUT_ONLY, DIR_OUTPUT_ONLY,
DIR_BOTH_INIT_INPUT, DIR_BOTH_INIT_OUTPUT.public int getDriveMode()
PeripheralConfig.DEFAULT or a bitwise OR of at least one of :
MODE_INPUT_PULL_UP, MODE_INPUT_PULL_DOWN, MODE_OUTPUT_PUSH_PULL,
MODE_OUTPUT_OPEN_DRAIN.public boolean getInitValue()
false if configured for input.public int getPinNumber()
PeripheralConfig.DEFAULT.public int getDeviceNumber()
getDeviceNumber in interface PeripheralConfig.HardwareAddressingPeripheralConfig.DEFAULT.public java.lang.String getDeviceName()
getDeviceName in interface PeripheralConfig.HardwareAddressingnull.public int getTrigger()
TRIGGER_NONE, TRIGGER_FALLING_EDGE,
TRIGGER_RISING_EDGE, TRIGGER_BOTH_EDGES, TRIGGER_HIGH_LEVEL,
TRIGGER_LOW_LEVEL, TRIGGER_BOTH_LEVELS.public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
GPIOPinConfig objects for equality.equals in class java.lang.Objectobj - the object to test for equality with this object.true if obj is a GPIOPinConfig and has
the same hardware addressing information and configuration parameter values
as this GPIOPinConfig object.Copyright © 2012, 2013, Oracle and/or its affiliates. All rights reserved.
Legal Notices