This file defines the gpio interface for libmraa
return EXIT_FAILURE;
}
return EXIT_FAILURE;
}
while (flag) {
status = gpio_1.write(1);
return EXIT_FAILURE;
}
status = gpio_2.write(0);
return EXIT_FAILURE;
}
sleep(1);
status = gpio_1.write(0);
return EXIT_FAILURE;
}
status = gpio_2.write(1);
return EXIT_FAILURE;
}
sleep(1);
}
Gpio |
( |
int |
pin, |
|
|
bool |
owner = true , |
|
|
bool |
raw = false |
|
) |
| |
|
inline |
Instantiates a Gpio object
- Parameters
-
pin | pin 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 |
( |
void * |
gpio_context | ) |
|
|
inline |
Gpio Constructor, takes a pointer to the GPIO context and initialises the GPIO class
- Parameters
-
gpio_context | void * to GPIO context |
Gpio object destructor, this will only unexport the gpio if we where the owner
Set the edge mode for ISR
- Parameters
-
- Returns
- Result of operation
Result isr |
( |
Edge |
mode, |
|
|
void(*)(void *) |
fptr, |
|
|
void * |
args |
|
) |
| |
|
inline |
Sets a callback to be called when pin value changes
- Parameters
-
mode | The edge mode to set |
fptr | Function pointer to function to be called when interrupt is triggered |
args | Arguments passed to the interrupt handler (fptr) |
- Returns
- Result of operation
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
Change Gpio mode
- Parameters
-
mode | The mode to change the gpio into |
- Returns
- Result of operation
Change Gpio direction
- Parameters
-
dir | The direction to change the gpio into |
- Returns
- Result of operation
Read Gpio direction
- Exceptions
-
std::runtime_error | in case of failure |
- Returns
- Result of operation
Write value to Gpio
- Parameters
-
value | Value to write to Gpio |
- Returns
- Result of operation
Enable use of mmap i/o if available.
- Parameters
-
- Returns
- Result of operation
int getPin |
( |
bool |
raw = false | ) |
|
|
inline |
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
Change Gpio input mode
- Parameters
-
mode | The mode to change the gpio input |
- Returns
- Result of operation
Change Gpio output driver mode
- Parameters
-
mode | Set output driver mode |
- Returns
- Result of operation
The documentation for this class was generated from the following file: