Class upisnd::Gpio#
Detailed Description#
The GPIO element class.
#include <gpio.h>
Inherits the following classes: upisnd::Element
Public Functions#
Type | Name |
---|---|
upisnd_pin_direction_e | getDirection () const Get the direction of the GPIO element. |
upisnd_pin_pull_e | getPull () const Get the pull of the GPIO Input element. |
int | get () const This is for quick access to the value, otherwise, it's recommended to keep the ValueFd returned byElement::openValueFd , to avoid file open and close overhead. |
int | set (bool high) Set the output value of the GPIO output element. |
Element () |
|
Element (upisnd_element_ref_t el) Implicitly increments the refcount. If you got the element from C API, don't forget to unref it afterwards. |
|
Element (const Element & rhs) |
|
Element (Element && rhs) |
|
Element (upisnd_element_ref_t el, bool) |
Public Functions inherited from upisnd::Element#
See upisnd::Element
Type | Name |
---|---|
Element () |
|
Element (upisnd_element_ref_t el) Implicitly increments the refcount. If you got the element from C API, don't forget to unref it afterwards. |
|
Element (const Element & rhs) |
|
Element & | operator= (const Element & rhs) |
Element (Element && rhs) |
|
Element & | operator= (Element && rhs) |
~Element () Unreferences the element. |
|
bool | isValid () const Checks if the element is valid. |
void | release () Unreferences the underlying C upisnd_element_ref_t handle and resets the object. |
const char * | getName () const Gets the name of the element. |
upisnd_element_type_e | getType () const Gets the type of the element. |
upisnd_pin_t | getPin () const Gets the pin of the element. |
ValueFd | openValueFd (int flags) const Opens the Element 's value attribute as a file descriptor. |
T | as () const Safely casts the element to the requested class. Returns an invalid object if the cast is not possible. |
Public Static Functions#
Type | Name |
---|---|
Gpio | setupInput (ElementName name, upisnd_pin_t pin, upisnd_pin_pull_e pull) Set up a GPIO element as input. |
Gpio | setupOutput (ElementName name, upisnd_pin_t pin, bool high) Set up a GPIO element as output. |
Public Static Functions inherited from upisnd::Element#
See upisnd::Element
Type | Name |
---|---|
Element | get (ElementName name) Gets an Element followingupisnd_element_get semantics. |
Element | setup (ElementName name, upisnd_setup_t setup) Sets up a new Element from aupisnd_setup_t setup option container. |
Protected Functions inherited from upisnd::Element#
See upisnd::Element
Type | Name |
---|---|
upisnd_element_ref_t | ref () const |
Element (upisnd_element_ref_t el, bool) |
getDirection#
Get the direction of the GPIO element.
upisnd_pin_direction_e upisnd::Gpio::getDirection () const
getPull#
Get the pull of the GPIO Input element.
upisnd_pin_pull_e upisnd::Gpio::getPull () const
Returns:
Returns UPISND_PIN_PULL_INVALID if the element is not an input.
get#
This is for quick access to the value, otherwise, it's recommended to keep the ValueFd returned byElement::openValueFd , to avoid file open and close overhead.
int upisnd::Gpio::get () const
Returns:
Negative return value indicates an error.
set#
Set the output value of the GPIO output element.
int upisnd::Gpio::set (
bool high
)
Returns:
Negative return value indicates an error.
Element [1/5]#
upisnd::Gpio::Element ()
Element [2/5]#
Implicitly increments the refcount. If you got the element from C API, don't forget to unref it afterwards.
explicit upisnd::Gpio::Element (
upisnd_element_ref_t el
)
Element [3/5]#
upisnd::Gpio::Element (
const Element & rhs
)
Element [4/5]#
upisnd::Gpio::Element (
Element && rhs
)
Element [5/5]#
upisnd::Gpio::Element (
upisnd_element_ref_t el,
bool
)
setupInput#
Set up a GPIO element as input.
static Gpio upisnd::Gpio::setupInput (
ElementName name,
upisnd_pin_t pin,
upisnd_pin_pull_e pull
)
See also: upisnd_setup_gpio_input
setupOutput#
Set up a GPIO element as output.
static Gpio upisnd::Gpio::setupOutput (
ElementName name,
upisnd_pin_t pin,
bool high
)
See also: upisnd_setup_gpio_output