mraa  0.6.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
 All Data Structures Namespaces Files Functions Typedefs Enumerations Enumerator Pages
Public Member Functions
Gpio Class Reference

Detailed Description

This file defines the gpio interface for libmraa

mraa::Gpio* gpio = new mraa::Gpio(iopin);
if (gpio == NULL) {
}
mraa_result_t response = gpio->dir(mraa::DIR_OUT);
if (response != MRAA_SUCCESS) {
mraa::printError(response);
return 1;
}
while (running == 0) {
response = gpio->write(1);
sleep(1);
response = gpio->write(0);
sleep(1);
}
delete gpio;
return response;

Public Member Functions

 Gpio (int pin, bool owner=true, bool raw=false)
 
 ~Gpio ()
 
mraa_result_t edge (Edge mode)
 
mraa_result_t isr (Edge mode, void(*fptr)(void *), void *args)
 
mraa_result_t isrExit ()
 
mraa_result_t mode (Mode mode)
 
mraa_result_t dir (Dir dir)
 
int read ()
 
mraa_result_t write (int value)
 
mraa_result_t useMmap (bool enable)
 
int getPin (bool raw=false)
 

Constructor & Destructor Documentation

Gpio ( int  pin,
bool  owner = true,
bool  raw = false 
)
inline

Instanciates 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.

Here is the call graph for this function:

~Gpio ( )
inline

Gpio object destructor, this will only unexport the gpio if we where the owner

Here is the call graph for this function:

Member Function Documentation

mraa_result_t edge ( Edge  mode)
inline

Set the edge mode for ISR

Parameters
modeThe edge mode to set
Returns
Result of operation

Here is the call graph for this function:

mraa_result_t isr ( Edge  mode,
void(*)(void *)  fptr,
void *  args 
)
inline

Sets a callback to be called when pin value changes

Parameters
modeThe edge mode to set
fptrFunction pointer to function to be called when interupt is triggered
argsArguments passed to the interrupt handler (fptr)
Returns
Result of operation

Here is the call graph for this function:

mraa_result_t isrExit ( )
inline

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

Returns
Result of operation

Here is the call graph for this function:

mraa_result_t mode ( Mode  mode)
inline

Change Gpio mode

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

Here is the call graph for this function:

mraa_result_t dir ( Dir  dir)
inline

Change Gpio direction

Parameters
dirThe direction to change the gpio into
Returns
Result of operation

Here is the call graph for this function:

int read ( )
inline

Read value from Gpio

Returns
Gpio value

Here is the call graph for this function:

mraa_result_t write ( int  value)
inline

Write value to Gpio

Parameters
valueValue to write to Gpio
Returns
Result of operation

Here is the call graph for this function:

mraa_result_t useMmap ( bool  enable)
inline

Enable use of mmap i/o if available.

Parameters
enabletrue to use mmap
Returns
Result of operation

Here is the call graph for this function:

int getPin ( bool  raw = false)
inline

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

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

Here is the call graph for this function:


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