public final class GPIOPinConfig extends java.lang.Object implements PeripheralConfig
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.| 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 portNumber,
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 |
|---|---|
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 |
getPortNumber()
Gets the configured port number for the pin.
|
int |
getTrigger()
Gets the configured initial pin interrupt trigger.
|
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 portNumber,
int pinNumber,
int direction,
int mode,
int trigger,
boolean initValue)
GPIOPinConfig with the specified hardware addressing information and configuration
parameters.portNumber - the hardware port's number (a positive or null integer) or PeripheralConfig.DEFAULT.pinNumber - the hardware pin's number (a positive or null 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:
portNumber 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 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 getPortNumber()
PeripheralConfig.DEFAULT.public int getTrigger()
TRIGGER_NONE, TRIGGER_FALLING_EDGE,
TRIGGER_RISING_EDGE, TRIGGER_BOTH_EDGES, TRIGGER_HIGH_LEVEL,
TRIGGER_LOW_LEVEL, TRIGGER_BOTH_LEVELS.Copyright (c) 2012, Oracle and/or its affiliates. All Rights Reserved. Use of this specification is subject to license terms.