Class Gpio
Gpio is the General Purpose IO interface to libmraa. Its features depend on the board type used, it can use gpiolibs (exported via a kernel module through sysfs), or memory mapped IO via a /dev/uio device or /dev/mem depending again on the board configuration.
Inheritance
Namespace:MraaSharp
Assembly:MraaSharp.dll
Syntax
public class Gpio : IDisposable
Constructors
View SourceGpio(Int32, MraaGpioDir, MraaGpioMode, Boolean)
Declaration
public Gpio(int pin, MraaGpioDir dir, MraaGpioMode mode, bool raw = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pin | |
MraaGpioDir | dir | |
MraaGpioMode | mode | |
System.Boolean | raw |
Gpio(Int32, MraaGpioDir, Boolean)
Declaration
public Gpio(int pin, MraaGpioDir dir, bool raw = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pin | |
MraaGpioDir | dir | |
System.Boolean | raw |
Gpio(Int32, Boolean)
Initialise gpio context.
Declaration
public Gpio(int pin, bool raw = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pin | Pin number read from the board, i.e IO3 is 3. if raw parameter is true, gpio pin as listed in SYSFS. |
System.Boolean | raw | without any mapping to a pin if true. |
Properties
View SourceDirection
Gpio direction
Declaration
public MraaGpioDir Direction
{
get;
set;
}
Property Value
Type | Description |
---|---|
MraaGpioDir |
EdgeMode
the edge mode on the gpio
Declaration
public MraaGpioEdge EdgeMode
{
set;
}
Property Value
Type | Description |
---|---|
MraaGpioEdge |
Mode
Gpio Output Mode
Declaration
public MraaGpioMode Mode
{
set;
}
Property Value
Type | Description |
---|---|
MraaGpioMode |
Owner
Change ownership of the context.
Declaration
public bool Owner
{
set;
}
Property Value
Type | Description |
---|---|
System.Boolean |
Pin
Get a pin number of the gpio, invalid will return -1
Declaration
public int Pin
{
get;
}
Property Value
Type | Description |
---|---|
System.Int32 |
PinRaw
Get a gpio number as used within sysfs, invalid will return -1
Declaration
public int PinRaw
{
get;
}
Property Value
Type | Description |
---|---|
System.Int32 |
UseMmaped
Enable using memory mapped io instead of sysfs
Declaration
public bool UseMmaped
{
set;
}
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
View SourceDispose()
Declaration
public void Dispose()
Read()
Read the Gpio value. This can be 0 or 1. A resonse of -1 means that there was a fatal error.
Declaration
public MraaGpioValue Read()
Returns
Type | Description |
---|---|
MraaGpioValue | Result of operation |
Write(MraaGpioValue)
Write to the Gpio Value.
Declaration
public void Write(MraaGpioValue value)
Parameters
Type | Name | Description |
---|---|---|
MraaGpioValue | value | value to write |