|
Oracle Java Wireless Client | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface GPIOPort
Interface for GPIO Port.
Port is distinguished by its ID.
Platform provide GPIOPort
to bind multiple GPIO pins as one data port
and perform read/write operation for several pins at a time. Port provide
convenient way to access multiple pins simultaneously.
getPort()
method and
use port for data read/write. and GPIO Port has maximum and minimum data
range that can be written or read.Application can check maximum value
by calling getMaxValue()
method and minimum value is zero.
If value which exceeds its range is written to GPIO port then Exception
will be thrown.
int data = 1; //data to write
GPIOPort port1;
GPIOPort port2;
port1 = GPIO.getPort(1);
port2 = GPIO.getPort(2);
port1.setValue(data); //write to first port
data = port2.getValue(); //read from second port
System.out.println("result = "+ data);
port1.release();
port2.release();
Application can register listener for receive notification for interrupt for
specific GPIO port. If application try to register listener to GPIO port which
is not configured to support listener then it will be thrown InvalidOperationException.
Field Summary | |
static int |
INPUT
|
static int |
OUTPUT
|
Method Summary | |
int |
getDirection()
Returns the current direction of port. |
int |
getMaxValue()
Returns maximum value of this port |
int |
getValue()
Get data from GPIO port. |
void |
setDirection(int direction)
Change current port's direction. |
void |
setInputListener(PortListener listener)
Start notification from GPIO port and register listener. |
void |
setValue(int value)
Set value to the GPIO port. |
Methods inherited from interface com.oracle.deviceaccess.Peripheral |
close, getID, getName |
Field Detail |
static final int INPUT
static final int OUTPUT
Method Detail |
int getMaxValue()
void setValue(int value) throws java.io.IOException, PeripheralNotAvailableException
value
- value to be written to the port.
java.io.IOException
- error occured while writing data to port.
InvalidOperationException
- throws when try to write value to input port.
java.lang.SecurityException
- throws when application has not enough permission.
java.lang.IllegalArgumentException
- throws when application try to set value which exceeds device's value range.
PeripheralNotAvailableException
int getValue() throws java.io.IOException, PeripheralNotAvailableException
java.io.IOException
- error occured while reading data from port.
java.lang.SecurityException
- throws when application has not enough permission.
PeripheralNotAvailableException
int getDirection() throws java.io.IOException, PeripheralNotAvailableException
java.io.IOException
PeripheralNotAvailableException
void setDirection(int direction) throws java.io.IOException, PeripheralNotAvailableException
direction
- OUTPUT for output port and INPUT for input port.
InvalidOperationException
- throws when try to change direction to invalid one.
java.lang.SecurityException
- throws when application has not enough permission.
java.io.IOException
PeripheralNotAvailableException
void setInputListener(PortListener listener) throws PeripheralNotAvailableException
listener
- Listener for input event.
InvalidOperationException
- when adding listener to unsupporting or output port.
java.lang.SecurityException
- throws when application has not enough permission.
PeripheralNotAvailableException
|
Oracle Java Wireless Client | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |