MRAA

MRAA is a low level skeleton library for communication on GNU/Linux platforms. See examples here.

Gpio Class

Module: mraa

This file defines the gpio interface for libmraa

Methods

Gpio

(
  • pin
  • owner
  • raw
)
Number

Instantiates a Gpio object

Parameters:

  • pin Number

    pin number to use

  • owner Boolean

    (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 Boolean

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

Returns:

Number:

edge

(
  • mode
)
Enum Result

Set the edge mode for ISR

Parameters:

  • mode Enum Edge

    The edge mode to set

Returns:

Enum Result:

Result of operation

isr

(
  • mode
  • func
)
Enum mraa_result_t

Sets a callback to be called when pin value changes

Parameters:

  • mode Enum Edge

    The edge mode to set

  • func Function

    Function to be called when interrupt is triggered

Returns:

Enum mraa_result_t:

Result of operation

isrExit

() Enum Result

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

Returns:

Enum Result:

Result of operation

mode

(
  • mode
)
Enum Result

Change Gpio mode

Parameters:

  • mode Enum Mode

    The mode to change the gpio into

Returns:

Enum Result:

Result of operation

dir

(
  • dir
)
Enum Result

Change Gpio direction

Parameters:

  • dir Enum Dir

    The direction to change the gpio into

Returns:

Enum Result:

Result of operation

readDir

() Enum Dir

Read Gpio direction

Returns:

Enum Dir:

Result of operation

read

() Number

Read value from Gpio

Returns:

Number:

Gpio value

write

(
  • value
)
Enum Result

Write value to Gpio

Parameters:

  • value Number

    Value to write to Gpio

Returns:

Enum Result:

Result of operation

useMmap

(
  • enable
)
Enum Result

Enable use of mmap i/o if available.

Parameters:

  • enable Boolean

    true to use mmap

Returns:

Enum Result:

Result of operation

getPin

(
  • raw
)
Number

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

Parameters:

  • raw Boolean

    (optional) get the raw gpio number.

Returns:

Number:

Pin number

inputMode

(
  • mode
)
Enum Result

Change Gpio input mode

Parameters:

  • mode Enum InputMode

    The mode to change the gpio input

Returns:

Enum Result:

Result of operation

outputMode

(
  • mode
)
Enum Result

Change Gpio output driver mode

Parameters:

  • mode Enum OutputMode

    Set output driver mode

Returns:

Enum Result:

Result of operation