mraa  2.0.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
Public Member Functions | List of all members
Gpio Class Reference

Detailed Description

This file defines the gpio interface for libmraa

Gpio gpio = new Gpio(iopin);
Result result = gpio.dir(Dir.DIR_OUT);
if (result != Result.SUCCESS) {
mraa.printError(result);
System.exit(1);
}
for (int i = 100; i > 0; --i) {
gpio.write(1);
Thread.sleep(1000);
gpio.write(0);
Thread.sleep(1000);
}

Public Member Functions

synchronized void delete ()
 
 Gpio (int pin, boolean owner, boolean raw)
 
 Gpio (int pin, boolean owner)
 
 Gpio (int pin)
 
Result edge (Edge mode)
 
Result isr (Edge mode, java.lang.Runnable runnable)
 
Result isrExit ()
 
Result mode (Mode mode)
 
Result dir (Dir dir)
 
Dir readDir ()
 
int read ()
 
Result write (int value)
 
Result useMmap (boolean enable)
 
int getPin (boolean raw)
 
int getPin ()
 
Result inputMode (InputMode mode)
 
Result outputMode (OutputMode mode)
 

Constructor & Destructor Documentation

Gpio ( int  pin,
boolean  owner,
boolean  raw 
)

Instantiates a Gpio object

Parameters
pinpin number to use
owner(optional) Set pin owner, default behaviour is to 'own' the pin if we exported it. This means we will close it on destruct. Otherwise it will get left open. This is only valid in sysfs use cases
raw(optional) Raw pins will use gpiolibs pin numbering from the kernel module. Note that you will not get any muxers set up for you so this may not always work as expected.
Gpio ( int  pin)

Gpio Constructor, takes a pointer to the GPIO context and initialises the GPIO class

Parameters
gpio_contextvoid * to GPIO context

Member Function Documentation

Result dir ( Dir  dir)

Change Gpio direction

Parameters
dirThe direction to change the gpio into
Returns
Result of operation
Result edge ( Edge  mode)

Set the edge mode for ISR

Parameters
modeThe edge mode to set
Returns
Result of operation

Here is the call graph for this function:

int getPin ( boolean  raw)

Get pin number of Gpio. If raw param is True will return the number as used within sysfs. Invalid will return -1.

Parameters
raw(optional) get the raw gpio number.
Returns
Pin number

Here is the call graph for this function:

Here is the caller graph for this function:

Result inputMode ( InputMode  mode)

Change Gpio input mode

Parameters
modeThe mode to change the gpio input
Returns
Result of operation
Result isrExit ( )

Exits callback - this call will not kill the isr thread immediately but only when it is out of it's critical section

Returns
Result of operation
Result mode ( Mode  mode)

Change Gpio mode

Parameters
modeThe mode to change the gpio into
Returns
Result of operation

Here is the caller graph for this function:

Result outputMode ( OutputMode  mode)

Change Gpio output driver mode

Parameters
modeSet output driver mode
Returns
Result of operation
int read ( )

Read value from Gpio

Returns
Gpio value
Dir readDir ( )

Read Gpio direction

Exceptions
std::runtime_errorin case of failure
Returns
Result of operation
Result useMmap ( boolean  enable)

Enable use of mmap i/o if available.

Parameters
enabletrue to use mmap
Returns
Result of operation
Result write ( int  value)

Write value to Gpio

Parameters
valueValue to write to Gpio
Returns
Result of operation

The documentation for this class was generated from the following file: