gpio: add ownership gaurd
* Will not unexport if the context did not export it. Can be forced. * Checks if pin is already exported. Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
5fa6f50edc
commit
7abd8f5529
@@ -56,11 +56,13 @@ typedef enum {
|
||||
|
||||
class Gpio {
|
||||
public:
|
||||
Gpio(int pin, bool raw=false) {
|
||||
Gpio(int pin, bool owner=true, bool raw=false) {
|
||||
if (raw)
|
||||
m_gpio = maa_gpio_init_raw(pin);
|
||||
else
|
||||
m_gpio = maa_gpio_init(pin);
|
||||
if (!owner)
|
||||
maa_gpio_owner(m_gpio, 0);
|
||||
}
|
||||
~Gpio() {
|
||||
maa_result_t x = maa_gpio_close(m_gpio);
|
||||
|
||||
Reference in New Issue
Block a user